Chromium Code Reviews| Index: tools/perf/page_sets/system_health/searching_stories.py |
| diff --git a/tools/perf/page_sets/system_health/searching_stories.py b/tools/perf/page_sets/system_health/searching_stories.py |
| index 329a0cb5ab276b5a16f3b94ee2e5bd9da0109144..0eaed978aed59750fd21aac1429241904bb87475 100644 |
| --- a/tools/perf/page_sets/system_health/searching_stories.py |
| +++ b/tools/perf/page_sets/system_health/searching_stories.py |
| @@ -2,12 +2,18 @@ |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| +from page_sets.system_health import platforms |
| +from page_sets.system_health import story_tags |
| from page_sets.system_health import system_health_story |
| +from devil.android.sdk import keyevent # pylint: disable=import-error |
| + |
| +# TODO(ssid): Rename the search stories to browse stories crbug.com/708300. |
| class SearchGoogleStory(system_health_story.SystemHealthStory): |
| NAME = 'search:portal:google' |
| URL = 'https://www.google.co.uk/' |
| + TAGS = [story_tags.EMERGING_MARKET] |
| _SEARCH_BOX_SELECTOR = 'input[aria-label="Search"]' |
| _RESULT_SELECTOR = '.r > a[href*="wikipedia"]' |
| @@ -33,3 +39,64 @@ class SearchGoogleStory(system_health_story.SystemHealthStory): |
| action_runner.Wait(1) |
| action_runner.TapElement(selector=self._RESULT_SELECTOR) |
| action_runner.tab.WaitForDocumentReadyStateToBeComplete() |
| + |
| + |
| +class SearchOmniboxStory(system_health_story.SystemHealthStory): |
| + NAME = 'browse:chrome:omnibox' |
| + URL = 'https://www.google.co.in' |
| + SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| + TAGS = [story_tags.EMERGING_MARKET] |
| + |
| + def _DidLoadDocument(self, action_runner): |
| + app_ui = action_runner.tab.browser.app_ui |
| + platform = action_runner.tab.browser.platform |
| + app_ui.WaitForUiNode(resource_id='url_bar') |
| + url_bar = app_ui.GetUiNode(resource_id='url_bar') |
| + url_bar.Tap() |
| + action_runner.Wait(1) # user wait before typing |
| + platform.android_action_runner.InputText('drake') |
| + action_runner.Wait(0.5) # user wait after typing |
| + platform.android_action_runner.InputKeyEvent(keyevent.KEYCODE_ENTER) |
| + |
| + action_runner.WaitForNavigate(15) |
| + action_runner.ScrollPage(use_touch=True, distance=500) |
| + |
| + |
| +class MobileNewTabPageStory(system_health_story.SystemHealthStory): |
| + """Story that loads new tab page and opens menu.""" |
| + |
| + NAME = 'browse:chrome:newtab' |
| + URL = 'chrome://newtab' |
| + _SEARCH_TEXTS = ['does google know everything', |
| + 'most famous paintings', |
| + 'current weather', |
| + 'best movies 2016', |
| + 'how to tie a tie'] |
| + |
| + SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| + TAGS = [story_tags.EMERGING_MARKET] |
| + |
| + def _DidLoadDocument(self, action_runner): |
| + app_ui = action_runner.tab.browser.app_ui |
| + platform = action_runner.tab.browser.platform |
| + renderer_view = self._GetUiNode('compositor_view_holder', app_ui) |
| + scroll_start = 0.5 * ( |
| + renderer_view.bounds.center + renderer_view.bounds.bottom_right) |
| + platform.android_action_runner.SmoothScrollBy( |
| + scroll_start.x, scroll_start.y, 'down', 300) |
| + for keyword in self._SEARCH_TEXTS: |
| + self._GetUiNode('search_box', app_ui).Tap() |
| + platform.android_action_runner.InputText(keyword) |
| + platform.android_action_runner.InputKeyEvent(keyevent.KEYCODE_ENTER) |
| + action_runner.WaitForNavigate() |
| + action_runner.Wait(1.5) # Read results |
| + action_runner.ScrollPage(use_touch=True) |
| + action_runner.NavigateBack() |
| + action_runner.WaitForNavigate() |
| + |
| + self._GetUiNode('menu_button', app_ui).Tap() |
| + app_ui.WaitForUiNode(resource_id='menu_item_text') |
| + |
| + def _GetUiNode(self, resource, app_ui): |
| + app_ui.WaitForUiNode(resource_id=resource) |
|
perezju
2017/04/11 09:43:35
WaitForUiNode already returns the node when found,
ssid
2017/04/11 21:52:55
Done.
|
| + return app_ui.GetUiNode(resource_id=resource) |