@@ -2104,3 +2104,125 @@ def test_focus_mode_on_focusable_read_only_lists():
21042104 ]),
21052105 message = "focus mode - focus list item and turn on focus mode"
21062106 )
2107+
2108+
2109+ def test_ARIASwitchRole ():
2110+ """
2111+ Ensure that ARIA switch controls have an appropriate role and states in browse mode.
2112+ """
2113+ testFile = os .path .join (ARIAExamplesDir , "switch" , "switch.html" )
2114+ _chrome .prepareChrome (
2115+ f"""
2116+ <iframe src="{ testFile } "></iframe>
2117+ """
2118+ )
2119+ # Jump to the first heading 2 in the iframe.
2120+ actualSpeech = _chrome .getSpeechAfterKey ("2" )
2121+ _asserts .strings_match (
2122+ actualSpeech ,
2123+ SPEECH_SEP .join ([
2124+ "frame" ,
2125+ "main landmark" ,
2126+ "Example" ,
2127+ "heading level 2"
2128+ ]),
2129+ message = "Move to first heading 2 in frame" ,
2130+ )
2131+ # Tab to the switch control
2132+ actualSpeech = _chrome .getSpeechAfterKey ("tab" )
2133+ _asserts .strings_match (
2134+ actualSpeech ,
2135+ SPEECH_SEP .join ([
2136+ "Notifications" ,
2137+ "switch" ,
2138+ "off" ,
2139+ ]),
2140+ message = "tab to switch control" ,
2141+ )
2142+ # Read the current line
2143+ actualSpeech = _chrome .getSpeechAfterKey ("numpad8" )
2144+ _asserts .strings_match (
2145+ actualSpeech ,
2146+ SPEECH_SEP .join ([
2147+ "switch" ,
2148+ "off" ,
2149+ "Notifications" ,
2150+ ]),
2151+ message = "Read current line" ,
2152+ )
2153+ # Report the current focus
2154+ actualSpeech = _chrome .getSpeechAfterKey ("NVDA+tab" )
2155+ _asserts .strings_match (
2156+ actualSpeech ,
2157+ SPEECH_SEP .join ([
2158+ "Notifications" ,
2159+ "switch" ,
2160+ "focused" ,
2161+ "off" ,
2162+ ]),
2163+ message = "Report focus" ,
2164+ )
2165+ # Toggle the switch on
2166+ actualSpeech = _chrome .getSpeechAfterKey ("space" )
2167+ _asserts .strings_match (
2168+ actualSpeech ,
2169+ SPEECH_SEP .join ([
2170+ "on" ,
2171+ ]),
2172+ message = "Toggle switch control on" ,
2173+ )
2174+ # Read the current line
2175+ actualSpeech = _chrome .getSpeechAfterKey ("numpad8" )
2176+ _asserts .strings_match (
2177+ actualSpeech ,
2178+ SPEECH_SEP .join ([
2179+ "switch" ,
2180+ "on" ,
2181+ "Notifications" ,
2182+ ]),
2183+ message = "Read current line" ,
2184+ )
2185+ # Report the current focus
2186+ actualSpeech = _chrome .getSpeechAfterKey ("NVDA+tab" )
2187+ _asserts .strings_match (
2188+ actualSpeech ,
2189+ SPEECH_SEP .join ([
2190+ "Notifications" ,
2191+ "switch" ,
2192+ "focused" ,
2193+ "on" ,
2194+ ]),
2195+ message = "Report focus" ,
2196+ )
2197+ # Toggle the switch off
2198+ actualSpeech = _chrome .getSpeechAfterKey ("space" )
2199+ _asserts .strings_match (
2200+ actualSpeech ,
2201+ SPEECH_SEP .join ([
2202+ "off" ,
2203+ ]),
2204+ message = "Toggle switch control off" ,
2205+ )
2206+ # Read the current line
2207+ actualSpeech = _chrome .getSpeechAfterKey ("numpad8" )
2208+ _asserts .strings_match (
2209+ actualSpeech ,
2210+ SPEECH_SEP .join ([
2211+ "switch" ,
2212+ "off" ,
2213+ "Notifications" ,
2214+ ]),
2215+ message = "Read current line" ,
2216+ )
2217+ # Report the current focus
2218+ actualSpeech = _chrome .getSpeechAfterKey ("NVDA+tab" )
2219+ _asserts .strings_match (
2220+ actualSpeech ,
2221+ SPEECH_SEP .join ([
2222+ "Notifications" ,
2223+ "switch" ,
2224+ "focused" ,
2225+ "off" ,
2226+ ]),
2227+ message = "Report focus" ,
2228+ )
0 commit comments