@@ -314,7 +314,7 @@ public async Task CornerRadius_AppliedToContentCoverBorder_WhenSetOnEmbeddedDial
314314 await Wait . For ( async ( ) =>
315315 {
316316 var contentCoverBorder = await dialogHost . GetElement < Border > ( "ContentCoverBorder" ) ;
317-
317+
318318 await Assert . That ( ( await contentCoverBorder . GetCornerRadius ( ) ) . TopLeft ) . IsEqualTo ( 1 ) ;
319319 await Assert . That ( ( await contentCoverBorder . GetCornerRadius ( ) ) . TopRight ) . IsEqualTo ( 2 ) ;
320320 await Assert . That ( ( await contentCoverBorder . GetCornerRadius ( ) ) . BottomRight ) . IsEqualTo ( 3 ) ;
@@ -500,7 +500,7 @@ public async Task DialogHost_WithComboBox_CanSelectItem()
500500 var comboBox = await dialogHost . GetElement < ComboBox > ( "TargetedPlatformComboBox" ) ;
501501 await Task . Delay ( 500 , TestContext . Current ! . CancellationToken ) ;
502502 await comboBox . LeftClick ( ) ;
503-
503+
504504 var item = await Wait . For ( ( ) => comboBox . GetElement < ComboBoxItem > ( "TargetItem" ) ) ;
505505 await Task . Delay ( TimeSpan . FromSeconds ( 1 ) ) ;
506506 await item . LeftClick ( ) ;
@@ -514,4 +514,40 @@ await Wait.For(async () =>
514514
515515 recorder . Success ( ) ;
516516 }
517+
518+ [ Test ]
519+ [ Description ( "Issue 3434" ) ]
520+ [ Arguments ( WindowState . Minimized , WindowState . Maximized ) ]
521+ [ Arguments ( WindowState . Minimized , WindowState . Normal ) ]
522+ [ Arguments ( WindowState . Maximized , WindowState . Normal ) ]
523+ public async Task DialogHost_WhenWindowStateChanges_FocusedElementStaysFocused ( WindowState firstWindowState , WindowState secondWindowState )
524+ {
525+ await using var recorder = new TestRecorder ( App ) ;
526+
527+ var dialogHost = ( await LoadUserControl < WithMultipleTextBoxes > ( ) ) . As < DialogHost > ( ) ;
528+ await Task . Delay ( 400 , TestContext . Current ! . CancellationToken ) ;
529+
530+ // Select the second TextBox
531+ var tbTwo = await dialogHost . GetElement < TextBox > ( "TextBoxTwo" ) ;
532+ await tbTwo . MoveKeyboardFocus ( ) ;
533+ await Assert . That ( await tbTwo . GetIsFocused ( ) ) . IsTrue ( ) ;
534+
535+ // First state
536+ await dialogHost . RemoteExecute ( SetStateOfParentWindow , firstWindowState ) ;
537+ await Task . Delay ( 400 , TestContext . Current ! . CancellationToken ) ;
538+ // Second state
539+ await dialogHost . RemoteExecute ( SetStateOfParentWindow , secondWindowState ) ;
540+ await Task . Delay ( 400 , TestContext . Current ! . CancellationToken ) ;
541+
542+ // After changing state of the window the previously focused element should be focused again
543+ await Assert . That ( await tbTwo . GetIsFocused ( ) ) . IsTrue ( ) ;
544+ recorder . Success ( ) ;
545+
546+ static object SetStateOfParentWindow ( DialogHost dialogHost , WindowState state )
547+ {
548+ var window = Window . GetWindow ( dialogHost ) ;
549+ window . WindowState = state ;
550+ return null ! ;
551+ }
552+ }
517553}
0 commit comments