@@ -74,15 +74,16 @@ pub struct Swapchain {
7474 format : gfx_hal:: format:: Format ,
7575}
7676
77+ #[ cfg_attr( test, automock) ]
7778impl < RenderBackend : gfx_hal:: Backend > Surface < RenderBackend > {
7879 /// Apply a swapchain to the current surface. This is required whenever a
7980 /// swapchain has been invalidated (I.E. by window resizing)
80- pub fn apply_swapchain (
81+ pub fn apply_swapchain < ' surface > (
8182 & mut self ,
8283 gpu : & Gpu < RenderBackend > ,
8384 swapchain : Swapchain ,
8485 timeout_in_nanoseconds : u64 ,
85- ) -> Result < ( ) , & str > {
86+ ) -> Result < ( ) , & ' surface str > {
8687 let device = super :: gpu:: internal:: logical_device_for ( gpu) ;
8788 self . extent = Some ( swapchain. config . extent ) ;
8889
@@ -128,13 +129,11 @@ impl<RenderBackend: gfx_hal::Backend> Surface<RenderBackend> {
128129 }
129130
130131 /// private function to invalidate the surface swapchain.
131- #[ inline]
132132 fn invalidate_swapchain ( & mut self ) {
133133 self . swapchain_is_valid = false ;
134134 }
135135
136136 /// Destroy the current surface and it's underlying resources.
137- #[ inline]
138137 pub fn destroy ( self , instance : & Instance < RenderBackend > ) {
139138 println ! ( "Destroying the surface: {}" , self . name) ;
140139
@@ -199,6 +198,7 @@ impl SwapchainBuilder {
199198#[ cfg( test) ]
200199mod tests {
201200 use super :: * ;
201+ use crate :: gfx:: MockInstanceBuilder ;
202202
203203 #[ test]
204204 fn test_surface_builder ( ) {
@@ -217,6 +217,18 @@ mod tests {
217217 let swapchain_builder = SwapchainBuilder :: new ( ) . with_size ( 1920 , 1080 ) ;
218218 assert_eq ! ( swapchain_builder. size, ( 1920 , 1080 ) ) ;
219219 }
220+
221+ #[ test]
222+ fn test_surface_builder_e2e ( ) {
223+ //let instance = MockInstanceBuilder::new().build("TestInstance");
224+ let surface_builder = SurfaceBuilder :: new ( ) . with_name ( "TestSurface" ) ;
225+ //let surface = surface_builder.build(&instance);
226+
227+ //assert_eq!(surface.name, "TestSurface".to_string());
228+ //assert_eq!(surface.swapchain_is_valid, false);
229+ //assert_eq!(surface.image, None);
230+ //assert_eq!(surface.frame_buffer_attachment, None);
231+ }
220232}
221233
222234/// Internal functions to work with the gfx-hal surface components
0 commit comments