1# Copyright (c) 2014 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import os 6import logging 7import time 8 9from autotest_lib.client.common_lib.cros import chrome 10from autotest_lib.client.cros.a11y import a11y_test_base 11 12 13class accessibility_Sanity(a11y_test_base.a11y_test_base): 14 """Enables then disables all a11y features via accessibilityFeatures API.""" 15 version = 1 16 17 # Features that do not have their own separate tests 18 _FEATURE_LIST = [ 19 'largeCursor', 20 'stickyKeys', 21 'highContrast', 22 'screenMagnifier', 23 'autoclick', 24 'virtualKeyboard' 25 ] 26 27 28 def _check_chromevox(self): 29 """Run ChromeVox specific checks. 30 31 Check the reported state of ChromeVox before/after enable and 32 for the presence of the indicator before/after disable. 33 34 """ 35 # ChromeVox is initially off. 36 self._confirm_chromevox_state(False) 37 38 # Turn ChromeVox on and check that all the pieces work. 39 self._toggle_chromevox() 40 self._confirm_chromevox_state(True) 41 self._tab_move('forwards') # Ensure that indicator is shown. 42 self._confirm_chromevox_indicator(True) 43 44 # Turn ChromeVox off. 45 self._toggle_chromevox() 46 self._tab.Navigate(self._url) # reload page to remove old indicators 47 self._confirm_chromevox_indicator(False) 48 49 50 def run_once(self): 51 """Entry point of this test.""" 52 extension_path = self._get_extension_path() 53 54 with chrome.Chrome(extension_paths=[extension_path], 55 init_network_controller=True) as cr: 56 self._extension = cr.get_extension(extension_path) 57 58 # Open test page. 59 self._tab = cr.browser.tabs[0] 60 cr.browser.platform.SetHTTPServerDirectories( 61 os.path.join(os.path.dirname(__file__))) 62 page_path = os.path.join(self.bindir, 'page.html') 63 self._url = cr.browser.platform.http_server.UrlOf(page_path) 64 self._tab.Navigate(self._url) 65 66 # Check specific features. 67 self._check_chromevox() 68 69 # Enable then disable all other accessibility features. 70 for value in [True, False]: 71 for feature in self._FEATURE_LIST: 72 logging.info('Setting %s to %s.', feature, value) 73 self._set_feature(feature, value) 74 time.sleep(1) 75