Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 from page_sets.system_health import platforms | |
| 6 from page_sets.system_health import story_tags | |
| 5 from page_sets.system_health import system_health_story | 7 from page_sets.system_health import system_health_story |
| 6 | 8 |
| 9 from devil.android.sdk import keyevent # pylint: disable=import-error | |
| 7 | 10 |
| 11 | |
| 12 # TODO(ssid): Rename the search stories to browse stories crbug.com/708300. | |
| 8 class SearchGoogleStory(system_health_story.SystemHealthStory): | 13 class SearchGoogleStory(system_health_story.SystemHealthStory): |
| 9 NAME = 'search:portal:google' | 14 NAME = 'search:portal:google' |
| 10 URL = 'https://www.google.co.uk/' | 15 URL = 'https://www.google.co.uk/' |
| 16 TAGS = [story_tags.EMERGING_MARKET] | |
| 11 | 17 |
| 12 _SEARCH_BOX_SELECTOR = 'input[aria-label="Search"]' | 18 _SEARCH_BOX_SELECTOR = 'input[aria-label="Search"]' |
| 13 _RESULT_SELECTOR = '.r > a[href*="wikipedia"]' | 19 _RESULT_SELECTOR = '.r > a[href*="wikipedia"]' |
| 14 | 20 |
| 15 def _DidLoadDocument(self, action_runner): | 21 def _DidLoadDocument(self, action_runner): |
| 16 # Click on the search box. | 22 # Click on the search box. |
| 17 action_runner.Wait(1) | 23 action_runner.Wait(1) |
| 18 action_runner.WaitForElement(selector=self._SEARCH_BOX_SELECTOR) | 24 action_runner.WaitForElement(selector=self._SEARCH_BOX_SELECTOR) |
| 19 action_runner.TapElement(selector=self._SEARCH_BOX_SELECTOR) | 25 action_runner.TapElement(selector=self._SEARCH_BOX_SELECTOR) |
| 20 | 26 |
| 21 # Submit search query. | 27 # Submit search query. |
| 22 action_runner.Wait(1) | 28 action_runner.Wait(1) |
| 23 action_runner.EnterText('what is science') | 29 action_runner.EnterText('what is science') |
| 24 action_runner.Wait(0.5) | 30 action_runner.Wait(0.5) |
| 25 action_runner.PressKey('Return') | 31 action_runner.PressKey('Return') |
| 26 | 32 |
| 27 # Scroll to the Wikipedia result. | 33 # Scroll to the Wikipedia result. |
| 28 action_runner.WaitForElement(selector=self._RESULT_SELECTOR) | 34 action_runner.WaitForElement(selector=self._RESULT_SELECTOR) |
| 29 action_runner.Wait(1) | 35 action_runner.Wait(1) |
| 30 action_runner.ScrollPageToElement(selector=self._RESULT_SELECTOR) | 36 action_runner.ScrollPageToElement(selector=self._RESULT_SELECTOR) |
| 31 | 37 |
| 32 # Click on the Wikipedia result. | 38 # Click on the Wikipedia result. |
| 33 action_runner.Wait(1) | 39 action_runner.Wait(1) |
| 34 action_runner.TapElement(selector=self._RESULT_SELECTOR) | 40 action_runner.TapElement(selector=self._RESULT_SELECTOR) |
| 35 action_runner.tab.WaitForDocumentReadyStateToBeComplete() | 41 action_runner.tab.WaitForDocumentReadyStateToBeComplete() |
| 42 | |
| 43 | |
| 44 class SearchOmniboxStory(system_health_story.SystemHealthStory): | |
|
nednguyen
2017/04/11 22:24:10
Can you add description explain what this story do
ssid
2017/04/13 21:08:54
Done.
| |
| 45 NAME = 'browse:chrome:omnibox' | |
| 46 URL = 'https://www.google.co.in' | |
| 47 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | |
| 48 TAGS = [story_tags.EMERGING_MARKET] | |
| 49 | |
| 50 def _DidLoadDocument(self, action_runner): | |
| 51 app_ui = action_runner.tab.browser.app_ui | |
| 52 platform = action_runner.tab.browser.platform | |
| 53 app_ui.WaitForUiNode(resource_id='url_bar') | |
| 54 url_bar = app_ui.GetUiNode(resource_id='url_bar') | |
| 55 url_bar.Tap() | |
| 56 action_runner.Wait(1) # user wait before typing | |
| 57 platform.android_action_runner.InputText('drake') | |
| 58 action_runner.Wait(0.5) # user wait after typing | |
| 59 platform.android_action_runner.InputKeyEvent(keyevent.KEYCODE_ENTER) | |
| 60 | |
| 61 action_runner.WaitForNavigate(15) | |
|
nednguyen
2017/04/11 22:24:10
why is this 15 seconds? Can you make this wait to
ssid
2017/04/13 21:08:54
I didn't know this argument was not required. remo
| |
| 62 action_runner.ScrollPage(use_touch=True, distance=500) | |
| 63 | |
| 64 | |
| 65 class MobileNewTabPageStory(system_health_story.SystemHealthStory): | |
| 66 """Story that loads new tab page and opens menu.""" | |
|
nednguyen
2017/04/11 22:24:10
The story below does more than this. Can you impro
ssid
2017/04/13 21:08:54
Done.
| |
| 67 | |
| 68 NAME = 'browse:chrome:newtab' | |
| 69 URL = 'chrome://newtab' | |
| 70 _SEARCH_TEXTS = ['does google know everything', | |
| 71 'most famous paintings', | |
| 72 'current weather', | |
| 73 'best movies 2016', | |
| 74 'how to tie a tie'] | |
| 75 | |
| 76 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | |
| 77 TAGS = [story_tags.EMERGING_MARKET] | |
| 78 | |
| 79 def _DidLoadDocument(self, action_runner): | |
| 80 app_ui = action_runner.tab.browser.app_ui | |
| 81 platform = action_runner.tab.browser.platform | |
| 82 renderer_view = app_ui.WaitForUiNode(resource_id='compositor_view_holder') | |
| 83 scroll_start = 0.5 * ( | |
| 84 renderer_view.bounds.center + renderer_view.bounds.bottom_right) | |
| 85 platform.android_action_runner.SmoothScrollBy( | |
| 86 scroll_start.x, scroll_start.y, 'down', 300) | |
| 87 for keyword in self._SEARCH_TEXTS: | |
| 88 app_ui.WaitForUiNode(resource_id='search_box').Tap() | |
| 89 platform.android_action_runner.InputText(keyword) | |
| 90 platform.android_action_runner.InputKeyEvent(keyevent.KEYCODE_ENTER) | |
| 91 action_runner.WaitForNavigate() | |
| 92 action_runner.Wait(1.5) # Read results | |
| 93 action_runner.ScrollPage(use_touch=True) | |
| 94 action_runner.NavigateBack() | |
| 95 action_runner.WaitForNavigate() | |
| 96 | |
| 97 app_ui.WaitForUiNode(resource_id='menu_button').Tap() | |
| 98 app_ui.WaitForUiNode(resource_id='menu_item_text') | |
| OLD | NEW |