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

Side by Side Diff: experimental/telemetry_mini/android_go_stories.py

Issue 2996123002: [telemetry_mini] Add AndroidActions class (Closed)
Patch Set: explain **kwargs Created 3 years, 4 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
« no previous file with comments | « no previous file | experimental/telemetry_mini/telemetry_mini.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2017 The Chromium Authors. All rights reserved. 2 # Copyright 2017 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import argparse 6 import argparse
7 import logging 7 import logging
8 import os 8 import os
9 import sys 9 import sys
10 import time 10 import time
11 11
12 import telemetry_mini 12 import telemetry_mini
13 13
14 14
15 BROWSER_FLAGS = [ 15 BROWSER_FLAGS = [
16 '--enable-remote-debugging', 16 '--enable-remote-debugging',
17 '--disable-fre', 17 '--disable-fre',
18 '--no-default-browser-check', 18 '--no-default-browser-check',
19 '--no-first-run', 19 '--no-first-run',
20 ] 20 ]
21 21
22 TRACE_CONFIG = { 22 TRACE_CONFIG = {
23 'excludedCategories': ['*'], 23 'excludedCategories': ['*'],
24 'includedCategories': ['rails', 'toplevel', 'startup', 'blink.user_timing'], 24 'includedCategories': ['rails', 'toplevel', 'startup', 'blink.user_timing'],
25 'memoryDumpConfig': {'triggers': []} 25 'memoryDumpConfig': {'triggers': []}
26 } 26 }
27 27
28 FLIPKART_TWITTER_LINK = [
29 ('package', 'com.twitter.android'),
30 ('class', 'android.widget.TextView'),
31 ('text', 'flipkart.com')
32 ]
33
34 KEYCODE_BACK = 4
35
36 BROWSERS = { 28 BROWSERS = {
37 'android-chrome': telemetry_mini.ChromeApp, 29 'android-chrome': telemetry_mini.ChromeApp,
38 'android-chromium': telemetry_mini.ChromiumApp, 30 'android-chromium': telemetry_mini.ChromiumApp,
39 'android-system-chrome': telemetry_mini.SystemChromeApp, 31 'android-system-chrome': telemetry_mini.SystemChromeApp,
40 } 32 }
41 33
42 34
43 class ProcessWatcher(object): 35 class ProcessWatcher(object):
44 def __init__(self, device): 36 def __init__(self, device):
45 self.device = device 37 self.device = device
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 assert not available_browsers, ( 105 assert not available_browsers, (
114 'Other browsers may intefere with the test: %s' % available_browsers) 106 'Other browsers may intefere with the test: %s' % available_browsers)
115 return browser 107 return browser
116 108
117 109
118 class TwitterApp(telemetry_mini.AndroidApp): 110 class TwitterApp(telemetry_mini.AndroidApp):
119 PACKAGE_NAME = 'com.twitter.android' 111 PACKAGE_NAME = 'com.twitter.android'
120 112
121 113
122 class TwitterFlipkartStory(telemetry_mini.UserStory): 114 class TwitterFlipkartStory(telemetry_mini.UserStory):
115 FLIPKART_TWITTER_LINK = [
116 ('package', 'com.twitter.android'),
117 ('class', 'android.widget.TextView'),
118 ('text', 'flipkart.com')
119 ]
120
123 def __init__(self, *args, **kwargs): 121 def __init__(self, *args, **kwargs):
124 super(TwitterFlipkartStory, self).__init__(*args, **kwargs) 122 super(TwitterFlipkartStory, self).__init__(*args, **kwargs)
125 self.watcher = ProcessWatcher(self.device) 123 self.watcher = ProcessWatcher(self.device)
126 self.twitter = TwitterApp(self.device) 124 self.twitter = TwitterApp(self.device)
127 125
128 def GetExtraStoryApps(self): 126 def GetExtraStoryApps(self):
129 return (self.twitter,) 127 return (self.twitter,)
130 128
131 def RunStorySteps(self): 129 def RunStorySteps(self):
132 # Intent will launch Twitter app on Flipkart profile. 130 # Activity will launch Twitter app on Flipkart profile.
133 self.device.RunShellCommand( 131 self.actions.StartActivity('https://twitter.com/flipkart')
134 'am', 'start', '-a', 'android.intent.action.VIEW',
135 '-d', 'https://twitter.com/flipkart')
136 self.watcher.StartWatching(self.twitter) 132 self.watcher.StartWatching(self.twitter)
137 133
138 # Tapping on Flikpart link on Twitter app will launch Chrome. 134 # Tapping on Flikpart link on Twitter app will launch Chrome.
139 self.device.TapUiNode(FLIPKART_TWITTER_LINK) 135 self.actions.TapUiElement(self.FLIPKART_TWITTER_LINK)
140 self.watcher.StartWatching(self.browser) 136 self.watcher.StartWatching(self.browser)
137 time.sleep(10) # TODO: Replace with wait until page loaded.
138 self.actions.SwipeUp(repeat=3)
141 139
142 time.sleep(10) # TODO: Replace with wait until page loaded. 140 # Return to Twitter app.
143 # Scroll content up a bit. 141 self.actions.GoBack()
144 self.device.RunShellCommand(
145 'input', 'swipe', '240', '568', '240', '284', '400')
146 time.sleep(1)
147
148 # Go "Back" and return to Twitter app.
149 self.device.RunShellCommand('input', 'keyevent', str(KEYCODE_BACK))
150 time.sleep(1)
151
152 self.watcher.AssertAllAlive() 142 self.watcher.AssertAllAlive()
153 143
154 144
155 def main(): 145 def main():
156 browser_names = sorted(BROWSERS) 146 browser_names = sorted(BROWSERS)
157 default_browser = 'android-chrome' 147 default_browser = 'android-chrome'
158 parser = argparse.ArgumentParser() 148 parser = argparse.ArgumentParser()
159 parser.add_argument('--serial', 149 parser.add_argument('--serial',
160 help='device serial on which to run user stories' 150 help='device serial on which to run user stories'
161 ' (defaults to first device found)') 151 ' (defaults to first device found)')
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 189
200 browser = EnsureSingleBrowser(device, args.browser, args.force_install) 190 browser = EnsureSingleBrowser(device, args.browser, args.force_install)
201 browser.SetDevToolsLocalPort(args.port) 191 browser.SetDevToolsLocalPort(args.port)
202 192
203 story = TwitterFlipkartStory(browser) 193 story = TwitterFlipkartStory(browser)
204 story.Run(BROWSER_FLAGS, TRACE_CONFIG, 'trace.json') 194 story.Run(BROWSER_FLAGS, TRACE_CONFIG, 'trace.json')
205 195
206 196
207 if __name__ == '__main__': 197 if __name__ == '__main__':
208 sys.exit(main()) 198 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | experimental/telemetry_mini/telemetry_mini.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698