1# Copyright 2019 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. 4from autotest_lib.client.common_lib import error 5from autotest_lib.client.cros.enterprise import enterprise_policy_base 6from autotest_lib.client.cros.input_playback import keyboard 7 8 9class policy_SearchSuggestEnabled( 10 enterprise_policy_base.EnterprisePolicyTest): 11 """Test effect of SearchSuggestEnabled policy on Chrome OS.""" 12 version = 1 13 14 POLICY_NAME = 'SearchSuggestEnabled' 15 16 def _search_bar_check(self, policy_value): 17 """ 18 Checks if the search suggestion options appeared or not. 19 20 @param policy_value: bool or None, the setting of the Policy. 21 22 """ 23 # Open new tab. 24 self.keyboard.press_key('ctrl+t') 25 26 # Input random characters into the omnibox. This will trigger the 27 # search suggestions dropdown (or not). 28 self.keyboard.press_key('f') 29 self.keyboard.press_key('s') 30 self.keyboard.press_key('w') 31 32 search_sugg = self.ui.item_present(name='/search suggestion/', 33 isRegex=True) 34 35 if policy_value is False and search_sugg: 36 raise error.TestError('Search Suggestions are enabled') 37 elif policy_value is not False and not search_sugg: 38 raise error.TestError('Search Suggestions are not enabled.') 39 40 def run_once(self, case): 41 """ 42 Setup and run the test configured for the specified test case. 43 44 @param case: Name of the test case to run. 45 46 """ 47 self.setup_case(user_policies={self.POLICY_NAME: case}) 48 self.ui.start_ui_root(self.cr) 49 self.keyboard = keyboard.Keyboard() 50 self._search_bar_check(case) 51 self.keyboard.close() 52