@@ -327,6 +327,56 @@ public async Task When_BackButton_Pressed(bool isCloseButtonEnabled)
327
327
SUT . Hide ( ) ;
328
328
}
329
329
}
330
+
331
+ [ TestMethod ]
332
+ #if __MACOS__
333
+ [ Ignore ( "Currently fails on macOS, part of #9282 epic" ) ]
334
+ #endif
335
+ public async Task When_Popup_Closed ( )
336
+ {
337
+ var closedEvent = new Event ( ) ;
338
+ var openedEvent = new Event ( ) ;
339
+ var closedRegistration = new SafeEventRegistration < ContentDialog , TypedEventHandler < ContentDialog , ContentDialogClosedEventArgs > > ( "Closed" ) ;
340
+ var openedRegistration = new SafeEventRegistration < ContentDialog , TypedEventHandler < ContentDialog , ContentDialogOpenedEventArgs > > ( "Opened" ) ;
341
+
342
+ var SUT = new MyContentDialog
343
+ {
344
+ Title = "Dialog title" ,
345
+ Content = "Dialog content" ,
346
+ CloseButtonText = "Close" ,
347
+ } ;
348
+
349
+ closedRegistration . Attach ( SUT , ( s , e ) => closedEvent . Set ( ) ) ;
350
+ openedRegistration . Attach ( SUT , ( s , e ) => openedEvent . Set ( ) ) ;
351
+
352
+ try
353
+ {
354
+ var showAsyncResult = SUT . ShowAsync ( ) . AsTask ( ) ;
355
+
356
+ await openedEvent . WaitForDefault ( ) ;
357
+
358
+ SUT . _popup . IsOpen = false ;
359
+
360
+ await closedEvent . WaitForDefault ( ) ;
361
+
362
+ VERIFY_IS_TRUE ( closedEvent . HasFired ( ) ) ;
363
+ VERIFY_IS_FALSE ( SUT . _popup . IsOpen ) ;
364
+
365
+ if ( await Task . WhenAny ( showAsyncResult , Task . Delay ( 2000 ) ) == showAsyncResult )
366
+ {
367
+ var dialogResult = showAsyncResult . Result ;
368
+ VERIFY_ARE_EQUAL ( ContentDialogResult . None , dialogResult ) ;
369
+ }
370
+ else
371
+ {
372
+ Assert . Fail ( "Timed out waiting for ShowAsync" ) ;
373
+ }
374
+ }
375
+ finally
376
+ {
377
+ SUT . Hide ( ) ;
378
+ }
379
+ }
330
380
#endif
331
381
332
382
#if __ANDROID__
@@ -379,6 +429,7 @@ void OnShowing(InputPane sender, InputPaneVisibilityEventArgs args)
379
429
inputPane . Showing -= OnShowing ;
380
430
}
381
431
await WindowHelper . WaitForIdle ( ) ;
432
+ await WindowHelper . WaitForIdle ( ) ;
382
433
}
383
434
384
435
private static async Task ShowDialog ( MyContentDialog dialog )
0 commit comments