blob: 307fbf57cb7dc3f0688e60baf0d1e9d86acee001 [file] [log] [blame]
# Copyright 2019 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import time
from autotest_lib.client.common_lib import error
from autotest_lib.client.cros.enterprise import enterprise_policy_base
from autotest_lib.client.cros.input_playback import keyboard
class policy_DefaultSearchProvider(
Verify effects of the DefaultSearchProviderSearchURL and
DefaultSearchProviderKeyword policy. When the
DefaultSearchProviderSearchURL policy is set, the specified search url
will be used when a value is entered in the omnibox. When the
DefaultSearchProviderKeyword is set, the value will trigger the shortcut
used in the omnibox to trigger the search for this provider.
version = 1
def _search_check(self, case):
Open a new tab, use the omnibox as a search box, and check the URL.
@param case: Value of the test being run.
self.keyboard = keyboard.Keyboard()
self.ui.doDefault_on_obj(name='Address and search bar')
# The keys to be pressed for the test
if case == 'Keyword':
buttons = ['d', 'a', 'd', 'tab', 's', 's', 'enter']
expected = '{}{}'.format(self.BASE_URL, 'ss')
buttons = ['f', 's', 'w', 'enter']
expected = '{}{}'.format(self.BASE_URL, 'fsw')
# Enter the buttons
for button in buttons:
tabFound = False
startTime = time.time()
while time.time() - startTime < 1:
tabs = set([tab.GetUrl() for tab in])
if expected in tabs:
tabFound = True
if not tabFound:
raise error.TestFail(
'Search not formated correctly. expected {} got {}'
.format(expected, tabs))
def run_once(self, case):
Setup and run the test configured for the specified test case.
@param case: Name of the test case to run.
self.BASE_URL = 'https://fakeurl/search?q='
POLICIES = {'DefaultSearchProviderEnabled': True,
'%s{searchTerms}' % (self.BASE_URL)}
if case == 'Keyword':
POLICIES['DefaultSearchProviderKeyword'] = 'dad'