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

Side by Side Diff: tools/telemetry/telemetry/android_browser_finder.py

Issue 11428107: Telemetry: extends Platform abstraction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/telemetry/telemetry/multi_page_benchmark_runner.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 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 """Finds android browsers that can be controlled by telemetry.""" 4 """Finds android browsers that can be controlled by telemetry."""
5 5
6 import os 6 import os
7 import logging as real_logging 7 import logging as real_logging
8 import re 8 import re
9 import subprocess 9 import subprocess
10 import sys
10 11
11 from telemetry import adb_commands 12 from telemetry import adb_commands
12 from telemetry import android_browser_backend 13 from telemetry import android_browser_backend
13 from telemetry import android_platform 14 from telemetry import android_platform
14 from telemetry import browser 15 from telemetry import browser
15 from telemetry import possible_browser 16 from telemetry import possible_browser
16 17
18 sys.path.append(
nduca 2012/12/04 09:20:17 please call through adb_commands by wrapping. That
19 os.path.abspath(
20 os.path.join(os.path.dirname(__file__),
21 '../../../build/android/pylib')))
22 import perf_tests_helper # pylint: disable=F0401
23 import thermal_throttle # pylint: disable=F0401
24
25
17 ALL_BROWSER_TYPES = ','.join([ 26 ALL_BROWSER_TYPES = ','.join([
18 'android-content-shell', 27 'android-content-shell',
19 'android-chrome', 28 'android-chrome',
20 'android-jb-system-chrome', 29 'android-jb-system-chrome',
21 ]) 30 ])
22 31
23 CHROME_PACKAGE = 'com.google.android.apps.chrome' 32 CHROME_PACKAGE = 'com.google.android.apps.chrome'
24 CHROME_ACTIVITY = '.Main' 33 CHROME_ACTIVITY = '.Main'
25 CHROME_COMMAND_LINE = '/data/local/chrome-command-line' 34 CHROME_COMMAND_LINE = '/data/local/chrome-command-line'
26 CHROME_DEVTOOLS_REMOTE_PORT = 'localabstract:chrome_devtools_remote' 35 CHROME_DEVTOOLS_REMOTE_PORT = 'localabstract:chrome_devtools_remote'
(...skipping 24 matching lines...) Expand all
51 return 'PossibleAndroidBrowser(browser_type=%s)' % self.browser_type 60 return 'PossibleAndroidBrowser(browser_type=%s)' % self.browser_type
52 61
53 def Create(self): 62 def Create(self):
54 backend = android_browser_backend.AndroidBrowserBackend( 63 backend = android_browser_backend.AndroidBrowserBackend(
55 self._options, *self._args) 64 self._options, *self._args)
56 platform = android_platform.AndroidPlatform( 65 platform = android_platform.AndroidPlatform(
57 self._args[0].Adb(), self._args[1], 66 self._args[0].Adb(), self._args[1],
58 self._args[1] + self._args[4]) 67 self._args[1] + self._args[4])
59 return browser.Browser(backend, platform) 68 return browser.Browser(backend, platform)
60 69
70 def CreatePlatformHarness(self):
71 class AndroidPlatformHarness(object):
72 def __init__(self, adb):
73 self._perf_tests_setup = perf_tests_helper.PerfTestSetup(adb)
74 self._thermal_throttle = thermal_throttle.ThermalThrottle(adb)
75
76 def __enter__(self):
77 if self._thermal_throttle.IsThrottled():
78 real_logging.warn('Device is being thermally throttled.')
79 self._perf_tests_setup.SetUp()
80 return self
81
82 def __exit__(self, *args):
83 if self._thermal_throttle.HasBeenThrottled():
84 real_logging.warn('Device was thermally throttled during tests.')
85 self._perf_tests_setup.TearDown()
86
87 return AndroidPlatformHarness(self._args[0].Adb())
88
89
61 def FindAllAvailableBrowsers(options, logging=real_logging): 90 def FindAllAvailableBrowsers(options, logging=real_logging):
62 """Finds all the desktop browsers available on this machine.""" 91 """Finds all the desktop browsers available on this machine."""
63 if not adb_commands.IsAndroidSupported(): 92 if not adb_commands.IsAndroidSupported():
64 return [] 93 return []
65 94
66 # See if adb even works. 95 # See if adb even works.
67 try: 96 try:
68 with open(os.devnull, 'w') as devnull: 97 with open(os.devnull, 'w') as devnull:
69 proc = subprocess.Popen(['adb', 'devices'], 98 proc = subprocess.Popen(['adb', 'devices'],
70 stdout=subprocess.PIPE, 99 stdout=subprocess.PIPE,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 # but make it accessible to the device. 169 # but make it accessible to the device.
141 if len(possible_browsers) and not adb_commands.HasForwarder(): 170 if len(possible_browsers) and not adb_commands.HasForwarder():
142 logging.warn('telemetry detected an android device. However,') 171 logging.warn('telemetry detected an android device. However,')
143 logging.warn('Chrome\'s port-forwarder app is not available.') 172 logging.warn('Chrome\'s port-forwarder app is not available.')
144 logging.warn('To build:') 173 logging.warn('To build:')
145 logging.warn(' make -j16 host_forwarder device_forwarder') 174 logging.warn(' make -j16 host_forwarder device_forwarder')
146 logging.warn('') 175 logging.warn('')
147 logging.warn('') 176 logging.warn('')
148 return [] 177 return []
149 return possible_browsers 178 return possible_browsers
OLDNEW
« no previous file with comments | « no previous file | tools/telemetry/telemetry/multi_page_benchmark_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698