Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: tools/perf/page_sets/system_health/searching_stories.py

Issue 2787103003: Add System health stories for Emerging market (Closed)
Patch Set: Only add new stories. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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):
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)
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."""
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 = self._GetUiNode('compositor_view_holder', app_ui)
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 self._GetUiNode('search_box', app_ui).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 self._GetUiNode('menu_button', app_ui).Tap()
98 app_ui.WaitForUiNode(resource_id='menu_item_text')
99
100 def _GetUiNode(self, resource, app_ui):
101 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.
102 return app_ui.GetUiNode(resource_id=resource)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698