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..abf706e0fbdb10626320007f0d386b6c29cbc078 100644 |
--- a/tools/perf/page_sets/system_health/searching_stories.py |
+++ b/tools/perf/page_sets/system_health/searching_stories.py |
@@ -1,13 +1,22 @@ |
+# encoding: utf-8 |
# Copyright 2016 The Chromium Authors. All rights reserved. |
# 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 |
+from telemetry import decorators |
+from telemetry.util import js_template |
+ |
+# 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 +42,162 @@ 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 = 'search:google:omnibox' |
perezju
2017/04/10 10:13:57
this one should be called already: browse:chrome:o
ssid
2017/04/11 03:55:58
Done.
|
+ 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 = 'search:chrome:newtab' |
perezju
2017/04/10 10:13:57
should be called already: browse:chrome:newtab
ssid
2017/04/11 03:55:58
Done.
|
+ 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) |
+ return app_ui.GetUiNode(resource_id=resource) |
+ |
+ |
+@decorators.Disabled('win') # crbug.com/673775 |
+class GoogleDesktopStory(system_health_story.SystemHealthStory): |
+ """ |
+ A typical google search story: |
+ _ Start at https://www.google.com/search?q=flower |
+ _ Click on the wikipedia link & navigate to |
+ https://en.wikipedia.org/wiki/Flower |
+ _ Scroll down the wikipedia page about flower. |
+ _ Back to the search main page. |
+ _ Refine the search query to 'flower delivery'. |
+ _ Scroll down the page. |
+ _ Click the next page result of 'flower delivery'. |
+ _ Scroll the search page. |
+ |
+ """ |
+ NAME = 'browse:search:google' |
+ URL = 'https://www.google.com/search?q=flower' |
+ _SEARCH_BOX_SELECTOR = 'input[aria-label="Search"]' |
+ _SEARCH_PAGE_2_SELECTOR = 'a[aria-label=\'Page 2\']' |
+ SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
+ |
+ def _DidLoadDocument(self, action_runner): |
+ # Click on flower Wikipedia link. |
+ action_runner.Wait(2) |
+ action_runner.ClickElement(text='Flower - Wikipedia') |
+ action_runner.WaitForNavigate() |
+ |
+ # Scroll the flower Wikipedia page, then navigate back. |
+ action_runner.Wait(2) |
+ action_runner.ScrollPage() |
+ action_runner.Wait(2) |
+ action_runner.NavigateBack() |
+ |
+ # Click on the search box. |
+ action_runner.WaitForElement(selector=self._SEARCH_BOX_SELECTOR) |
+ action_runner.ClickElement(selector=self._SEARCH_BOX_SELECTOR) |
+ action_runner.Wait(2) |
+ |
+ # Submit search query. |
+ action_runner.EnterText(' delivery') |
+ action_runner.Wait(0.5) |
+ action_runner.PressKey('Return') |
+ |
+ # Scroll down & click next search result page. |
+ action_runner.Wait(2) |
+ action_runner.ScrollPageToElement(selector=self._SEARCH_PAGE_2_SELECTOR) |
+ action_runner.Wait(2) |
+ action_runner.ClickElement(selector=self._SEARCH_PAGE_2_SELECTOR) |
+ action_runner.Wait(2) |
+ action_runner.ScrollPage() |
+ |
+ |
+class GoogleIndiaDesktopStory(system_health_story.SystemHealthStory): |
+ """ |
+ A typical google search story in India: |
+ 1. Start at https://www.google.co.in/search?q=%E0%A4%AB%E0%A5%82%E0%A4%B2` |
+ 2. Scroll down the page. |
+ 3. Refine the query & click search box, which navigates to |
+ https://www.google.co.in/search?q=%E0%A4%AB%E0%A5%82%E0%A4%B2&rct=j#q=%E0%A4%AB%E0%A5%82%E0%A4%B2+%E0%A4%B5%E0%A4%BF%E0%A4%A4%E0%A4%B0%E0%A4%A3 |
+ 4. Scroll down the page. |
+ 5. Click the next page result |
+ 6. Scroll the search result page. |
+ |
+ """ |
+ NAME = 'browse:search:google_india' |
+ URL = 'https://www.google.co.in/search?q=%E0%A4%AB%E0%A5%82%E0%A4%B2' |
+ _SEARCH_BOX_SELECTOR = 'input[aria-label="Search"]' |
+ _SEARCH_BUTTON_SELECTOR = 'button[aria-label="Google Search"]' |
+ _SEARCH_PAGE_2_SELECTOR = 'a[aria-label=\'Page 2\']' |
+ SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
+ TAGS = [story_tags.INTERNATIONAL] |
+ |
+ def _DidLoadDocument(self, action_runner): |
+ action_runner.Wait(2) |
+ action_runner.ScrollPage() |
+ action_runner.Wait(2) |
+ |
+ action_runner.ScrollPage(direction='up') |
+ |
+ # Refine search query in the search box. |
+ # TODO(nednguyen): replace this with input text gesture to make it more |
+ # realistic. |
+ action_runner.ExecuteJavaScript( |
+ js_template.Render( |
+ 'document.querySelector({{ selector }}).value += "वितरण";', |
+ selector=self._SEARCH_BOX_SELECTOR)) |
+ action_runner.Wait(2) |
+ action_runner.ClickElement(selector=self._SEARCH_BUTTON_SELECTOR) |
+ |
+ # Scroll down & click next search result page. |
+ action_runner.Wait(2) |
+ action_runner.ScrollPageToElement(selector=self._SEARCH_PAGE_2_SELECTOR) |
+ action_runner.Wait(2) |
+ action_runner.ClickElement(selector=self._SEARCH_PAGE_2_SELECTOR) |
+ action_runner.Wait(2) |
+ action_runner.ScrollPage() |