@@ -257,5 +257,57 @@ public async Task Represented_filename_and_edited_flags()
257257
258258 win . SetDocumentEdited ( false ) ;
259259 }
260+
261+ [ IntegrationFact ]
262+ public async Task BoundsChanged_event_fires_with_updated_bounds ( )
263+ {
264+ BrowserWindow window = null ;
265+
266+ try
267+ {
268+ window = await Electron . WindowManager . CreateWindowAsync (
269+ new BrowserWindowOptions { Show = false , Width = 300 , Height = 200 } ,
270+ "about:blank" ) ;
271+
272+ var tcs = new TaskCompletionSource < Rectangle > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
273+ window . OnBoundsChanged += bounds => tcs . TrySetResult ( bounds ) ;
274+
275+ await Task . Delay ( 500 . ms ( ) ) ;
276+
277+ var target = new Rectangle { X = 25 , Y = 35 , Width = 420 , Height = 310 } ;
278+ window . SetBounds ( target ) ;
279+
280+ var completed = await Task . WhenAny ( tcs . Task , Task . Delay ( 3 . seconds ( ) ) ) ;
281+ completed . Should ( ) . Be ( tcs . Task ) ;
282+
283+ var observed = await tcs . Task ;
284+
285+ observed . Width . Should ( ) . Be ( target . Width ) ;
286+ observed . Height . Should ( ) . Be ( target . Height ) ;
287+ }
288+ finally
289+ {
290+ window ? . Destroy ( ) ;
291+ }
292+ }
293+
294+ [ IntegrationFact ]
295+ public async Task BoundsChanged_event_can_fire_on_resize_of_existing_window ( )
296+ {
297+ var win = this . MainWindow ;
298+
299+ var tcs = new TaskCompletionSource < Rectangle > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
300+ win . OnBoundsChanged += bounds => tcs . TrySetResult ( bounds ) ;
301+
302+ await Task . Delay ( 500 . ms ( ) ) ;
303+ win . SetBounds ( new Rectangle { X = 10 , Y = 10 , Width = 560 , Height = 440 } ) ;
304+
305+ var completed = await Task . WhenAny ( tcs . Task , Task . Delay ( 3 . seconds ( ) ) ) ;
306+ completed . Should ( ) . Be ( tcs . Task ) ;
307+
308+ var boundsObserved = await tcs . Task ;
309+ boundsObserved . Width . Should ( ) . Be ( 560 ) ;
310+ boundsObserved . Height . Should ( ) . Be ( 440 ) ;
311+ }
260312 }
261313}
0 commit comments