1- // Copyright (c) Microsoft Corporation. All rights reserved.
1+ // Copyright (c) Microsoft Corporation. All rights reserved.
22// Licensed under the MIT License. See LICENSE in the project root for license information.
33
44
@@ -50,7 +50,7 @@ public void TestCleanup()
5050 [ TestProperty ( "TestSuite" , "A" ) ]
5151 public void SelectionTest ( )
5252 {
53- using ( var setup = new TestSetupHelper ( "RadioButtons Tests" ) )
53+ using ( var setup = new TestSetupHelper ( new [ ] { "RadioButtons Tests" , "RadioButtons Test" } ) )
5454 {
5555 elements = new RadioButtonsTestPageElements ( ) ;
5656 SetItemType ( RadioButtonsSourceType . RadioButton ) ;
@@ -81,7 +81,7 @@ public void SelectByItem()
8181 Log . Warning ( "This test requires TrySetNewFocusedElement from RS4" ) ;
8282 return ;
8383 }
84- using ( var setup = new TestSetupHelper ( "RadioButtons Tests" ) )
84+ using ( var setup = new TestSetupHelper ( new [ ] { "RadioButtons Tests" , "RadioButtons Test" } ) )
8585 {
8686 elements = new RadioButtonsTestPageElements ( ) ;
8787 SetItemType ( RadioButtonsSourceType . RadioButton ) ;
@@ -118,29 +118,90 @@ public void FocusComingFromAnotherRepeaterTest()
118118 Log . Warning ( "This test requires TrySetNewFocusedElement from RS4" ) ;
119119 return ;
120120 }
121- using ( var setup = new TestSetupHelper ( "RadioButtons Tests" ) )
121+ using ( var setup = new TestSetupHelper ( new [ ] { "RadioButtons Tests" , "RadioButtonsFocus Test" } ) )
122122 {
123- elements = new RadioButtonsTestPageElements ( ) ;
124- SetItemType ( RadioButtonsSourceType . RadioButton ) ;
125- foreach ( RadioButtonsSourceLocation location in Enum . GetValues ( typeof ( RadioButtonsSourceLocation ) ) )
123+ var elements = new RadioButtonsFocusTestPageElements ( ) ;
124+
125+ // Select items
126+ SelectByIndex ( 1 , false ) ;
127+ SelectByIndex ( 2 , true ) ;
128+
129+ // Verify selection
130+ VerifySelectedIndex ( 1 , false ) ;
131+ VerifySelectedIndex ( 2 , true ) ;
132+
133+ VerifyRadioButtonsHasFocus ( true , false ) ;
134+
135+ // Move focus to second RadioButtons control by pressing TAB
136+ KeyboardHelper . PressKey ( Key . Tab ) ;
137+
138+ // Verify that
139+ // - the first RadioButtons control no longer has focus and
140+ // - the third radio button of the second RadioButtons control now has focus
141+ VerifyRadioButtonsHasFocus ( false , false ) ;
142+ VerifySelectedFocusedIndex ( 2 , true ) ;
143+
144+ // Move focus to the first RadioButtons control by pressing TAB again
145+ KeyboardHelper . PressKey ( Key . Tab ) ;
146+
147+ // Verify that the second radio button is still selected and now has focus
148+ VerifySelectedFocusedIndex ( 1 , false ) ;
149+
150+ void SelectByIndex ( int index , bool checkRadioButtons2 )
126151 {
127- SetSource ( location ) ;
152+ if ( checkRadioButtons2 )
153+ {
154+ elements . GetIndexToSelectTextBox2 ( ) . SetValue ( index . ToString ( ) ) ;
155+ elements . GetSelectByIndexButton2 ( ) . Click ( ) ;
156+ }
157+ else
158+ {
159+ elements . GetIndexToSelectTextBox1 ( ) . SetValue ( index . ToString ( ) ) ;
160+ elements . GetSelectByIndexButton1 ( ) . Click ( ) ;
161+ }
162+ }
128163
129- TapOnItem ( 3 ) ;
130- VerifySelectedFocusedIndex ( 3 ) ;
131- RadioButton item3 = FindElement . ByName < RadioButton > ( "Radio Button 3" ) ;
132- Verify . IsTrue ( item3 . IsSelected ) ;
164+ void VerifySelectedIndex ( int index , bool checkRadioButtons2 )
165+ {
166+ if ( checkRadioButtons2 )
167+ {
168+ Verify . AreEqual ( index , Int32 . Parse ( elements . GetSelectedIndexTextBlock2 ( ) . DocumentText ) , $ "RadioButton with index { index } should have been selected.") ;
169+ }
170+ else
171+ {
172+ Verify . AreEqual ( index , Int32 . Parse ( elements . GetSelectedIndexTextBlock1 ( ) . DocumentText ) , $ "RadioButton with index { index } should have been selected.") ;
173+ }
174+ }
133175
134- KeyboardHelper . PressKey ( Key . Tab ) ;
135- VerifyRadioButtonsHasFocus ( false ) ;
136- Verify . IsTrue ( item3 . IsSelected ) ;
176+ void VerifyRadioButtonsHasFocus ( bool hasFocus , bool checkRadioButtons2 )
177+ {
178+ if ( checkRadioButtons2 )
179+ {
180+ Verify . AreEqual ( hasFocus , elements . GetRadioButtons2HasFocusCheckBox ( ) . ToggleState == ToggleState . On ) ;
181+ }
182+ else
183+ {
184+ Verify . AreEqual ( hasFocus , elements . GetRadioButtons1HasFocusCheckBox ( ) . ToggleState == ToggleState . On ) ;
185+ }
186+ }
137187
138- KeyboardHelper . PressDownModifierKey ( ModifierKey . Shift ) ;
139- KeyboardHelper . PressKey ( Key . Tab ) ;
140- KeyboardHelper . ReleaseModifierKey ( ModifierKey . Shift ) ;
141- VerifySelectedFocusedIndex ( 3 ) ;
142- Verify . IsTrue ( item3 . IsSelected ) ;
188+ void VerifyFocusedIndex ( int index , bool checkRadioButtons2 )
189+ {
190+ if ( checkRadioButtons2 )
191+ {
192+ Verify . AreEqual ( index , Int32 . Parse ( elements . GetFocusedIndexTextBlock2 ( ) . DocumentText ) , $ "RadioButton with index { index } should have focus.") ;
193+ }
194+ else
195+ {
196+ Verify . AreEqual ( index , Int32 . Parse ( elements . GetFocusedIndexTextBlock1 ( ) . DocumentText ) , $ "RadioButton with index { index } should have focus.") ;
197+ }
198+
199+ }
143200
201+ void VerifySelectedFocusedIndex ( int index , bool checkRadioButtons2 )
202+ {
203+ VerifySelectedIndex ( index , checkRadioButtons2 ) ;
204+ VerifyFocusedIndex ( index , checkRadioButtons2 ) ;
144205 }
145206 }
146207 }
@@ -154,7 +215,7 @@ public void BasicKeyboardTest()
154215 Log . Warning ( "This test requires RS3+ keyboarding behavior" ) ;
155216 return ;
156217 }
157- using ( var setup = new TestSetupHelper ( "RadioButtons Tests" ) )
218+ using ( var setup = new TestSetupHelper ( new [ ] { "RadioButtons Tests" , "RadioButtons Test" } ) )
158219 {
159220 elements = new RadioButtonsTestPageElements ( ) ;
160221 foreach ( RadioButtonsSourceLocation location in Enum . GetValues ( typeof ( RadioButtonsSourceLocation ) ) )
@@ -198,7 +259,7 @@ public void MultiColumnKeyboardTest()
198259 Log . Warning ( "This test requires RS3+ keyboarding behavior" ) ;
199260 return ;
200261 }
201- using ( var setup = new TestSetupHelper ( "RadioButtons Tests" ) )
262+ using ( var setup = new TestSetupHelper ( new [ ] { "RadioButtons Tests" , "RadioButtons Test" } ) )
202263 {
203264 elements = new RadioButtonsTestPageElements ( ) ;
204265 foreach ( RadioButtonsSourceLocation location in Enum . GetValues ( typeof ( RadioButtonsSourceLocation ) ) )
@@ -261,7 +322,7 @@ public void DisabledItemsKeyboardTest()
261322 Log . Warning ( "This test requires RS3+ keyboarding behavior" ) ;
262323 return ;
263324 }
264- using ( var setup = new TestSetupHelper ( "RadioButtons Tests" ) )
325+ using ( var setup = new TestSetupHelper ( new [ ] { "RadioButtons Tests" , "RadioButtons Test" } ) )
265326 {
266327 elements = new RadioButtonsTestPageElements ( ) ;
267328 SetItemType ( RadioButtonsSourceType . RadioButton ) ;
@@ -333,7 +394,7 @@ public void DisabledItemsAtTopOfColumnKeyboardTest()
333394 Log . Warning ( "This test requires RS3+ keyboarding behavior" ) ;
334395 return ;
335396 }
336- using ( var setup = new TestSetupHelper ( "RadioButtons Tests" ) )
397+ using ( var setup = new TestSetupHelper ( new [ ] { "RadioButtons Tests" , "RadioButtons Test" } ) )
337398 {
338399 elements = new RadioButtonsTestPageElements ( ) ;
339400 SetItemType ( RadioButtonsSourceType . RadioButton ) ;
@@ -396,7 +457,7 @@ public void RS2MultiColumnKeyboardTest()
396457 Log . Warning ( "This test requires RS2 keyboarding behavior" ) ;
397458 return ;
398459 }
399- using ( var setup = new TestSetupHelper ( "RadioButtons Tests" ) )
460+ using ( var setup = new TestSetupHelper ( new [ ] { "RadioButtons Tests" , "RadioButtons Test" } ) )
400461 {
401462 elements = new RadioButtonsTestPageElements ( ) ;
402463 foreach ( RadioButtonsSourceLocation location in Enum . GetValues ( typeof ( RadioButtonsSourceLocation ) ) )
@@ -447,7 +508,7 @@ public void RS2MultiColumnKeyboardTest()
447508 [ TestProperty ( "TestSuite" , "B" ) ]
448509 public void GamepadCanEscapeAndDoesNotSelectWithFocus ( )
449510 {
450- using ( var setup = new TestSetupHelper ( "RadioButtons Tests" ) )
511+ using ( var setup = new TestSetupHelper ( new [ ] { "RadioButtons Tests" , "RadioButtons Test" } ) )
451512 {
452513 elements = new RadioButtonsTestPageElements ( ) ;
453514 foreach ( RadioButtonsSourceLocation location in Enum . GetValues ( typeof ( RadioButtonsSourceLocation ) ) )
@@ -506,7 +567,7 @@ public void ControlKeyKeyboardTest()
506567 Log . Warning ( "This test fails on RS2 because of a repeater bug: #1447" ) ;
507568 return ;
508569 }
509- using ( var setup = new TestSetupHelper ( "RadioButtons Tests" ) )
570+ using ( var setup = new TestSetupHelper ( new [ ] { "RadioButtons Tests" , "RadioButtons Test" } ) )
510571 {
511572 elements = new RadioButtonsTestPageElements ( ) ;
512573 foreach ( RadioButtonsSourceLocation location in Enum . GetValues ( typeof ( RadioButtonsSourceLocation ) ) )
@@ -532,7 +593,7 @@ public void ControlKeyKeyboardTest()
532593 [ TestProperty ( "TestSuite" , "A" ) ]
533594 public void ColumnsTest ( )
534595 {
535- using ( var setup = new TestSetupHelper ( "RadioButtons Tests" ) )
596+ using ( var setup = new TestSetupHelper ( new [ ] { "RadioButtons Tests" , "RadioButtons Test" } ) )
536597 {
537598 elements = new RadioButtonsTestPageElements ( ) ;
538599 foreach ( RadioButtonsSourceLocation location in Enum . GetValues ( typeof ( RadioButtonsSourceLocation ) ) )
@@ -579,7 +640,7 @@ public void ColumnsTest()
579640 [ TestProperty ( "TestSuite" , "B" ) ]
580641 public void UIAProperties ( )
581642 {
582- using ( var setup = new TestSetupHelper ( "RadioButtons Tests" ) )
643+ using ( var setup = new TestSetupHelper ( new [ ] { "RadioButtons Tests" , "RadioButtons Test" } ) )
583644 {
584645 elements = new RadioButtonsTestPageElements ( ) ;
585646 SetItemType ( RadioButtonsSourceType . RadioButton ) ;
@@ -622,7 +683,7 @@ public void UIAProperties()
622683 [ TestProperty ( "TestSuite" , "C" ) ]
623684 public void InsertedCheckedRadioButtonGetsSelection ( )
624685 {
625- using ( var setup = new TestSetupHelper ( "RadioButtons Tests" ) )
686+ using ( var setup = new TestSetupHelper ( new [ ] { "RadioButtons Tests" , "RadioButtons Test" } ) )
626687 {
627688 elements = new RadioButtonsTestPageElements ( ) ;
628689 SetItemType ( RadioButtonsSourceType . RadioButton ) ;
@@ -645,7 +706,7 @@ public void ScrollViewerSettingSelectionDoesNotMoveFocus()
645706 Log . Warning ( "This test is disabled on RS2 because it requires RS3+ keyboarding behavior." ) ;
646707 return ;
647708 }
648- using ( var setup = new TestSetupHelper ( "RadioButtons Tests" ) )
709+ using ( var setup = new TestSetupHelper ( new [ ] { "RadioButtons Tests" , "RadioButtons Test" } ) )
649710 {
650711 elements = new RadioButtonsTestPageElements ( ) ;
651712 foreach ( RadioButtonsSourceLocation location in Enum . GetValues ( typeof ( RadioButtonsSourceLocation ) ) )
@@ -678,7 +739,7 @@ public void AccessKeys()
678739 Log . Warning ( "This test requires RS3+ keyboarding behavior" ) ;
679740 return ;
680741 }
681- using ( var setup = new TestSetupHelper ( "RadioButtons Tests" ) )
742+ using ( var setup = new TestSetupHelper ( new [ ] { "RadioButtons Tests" , "RadioButtons Test" } ) )
682743 {
683744 elements = new RadioButtonsTestPageElements ( ) ;
684745 foreach ( RadioButtonsSourceLocation location in Enum . GetValues ( typeof ( RadioButtonsSourceLocation ) ) )
0 commit comments