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
3 # found in the LICENSE file.
5 """Defines a set of constants shared by test runners and other scripts."""
6 # pylint: disable=W0212
14 DIR_SOURCE_ROOT
= os
.environ
.get('CHECKOUT_SOURCE_ROOT',
15 os
.path
.abspath(os
.path
.join(os
.path
.dirname(__file__
),
16 os
.pardir
, os
.pardir
, os
.pardir
)))
17 ISOLATE_DEPS_DIR
= os
.path
.join(DIR_SOURCE_ROOT
, 'isolate_deps_dir')
19 CHROME_SHELL_HOST_DRIVEN_DIR
= os
.path
.join(
20 DIR_SOURCE_ROOT
, 'chrome', 'android')
23 PackageInfo
= collections
.namedtuple('PackageInfo',
24 ['package', 'activity', 'cmdline_file', 'devtools_socket',
28 'chrome_document': PackageInfo(
29 'com.google.android.apps.chrome.document',
30 'com.google.android.apps.chrome.document.ChromeLauncherActivity',
31 '/data/local/chrome-command-line',
32 'chrome_devtools_remote',
34 'chrome': PackageInfo(
35 'com.google.android.apps.chrome',
36 'com.google.android.apps.chrome.Main',
37 '/data/local/chrome-command-line',
38 'chrome_devtools_remote',
39 'com.google.android.apps.chrome.tests'),
40 'chrome_beta': PackageInfo(
42 'com.google.android.apps.chrome.Main',
43 '/data/local/chrome-command-line',
44 'chrome_devtools_remote',
46 'chrome_stable': PackageInfo(
48 'com.google.android.apps.chrome.Main',
49 '/data/local/chrome-command-line',
50 'chrome_devtools_remote',
52 'chrome_dev': PackageInfo(
53 'com.google.android.apps.chrome_dev',
54 'com.google.android.apps.chrome.Main',
55 '/data/local/chrome-command-line',
56 'chrome_devtools_remote',
58 'chrome_canary': PackageInfo(
60 'com.google.android.apps.chrome.Main',
61 '/data/local/chrome-command-line',
62 'chrome_devtools_remote',
64 'legacy_browser': PackageInfo(
65 'com.google.android.browser',
66 'com.android.browser.BrowserActivity',
70 'chromecast_shell': PackageInfo(
71 'com.google.android.apps.mediashell',
72 'com.google.android.apps.mediashell.MediaShellActivity',
73 '/data/local/tmp/castshell-command-line',
76 'content_shell': PackageInfo(
77 'org.chromium.content_shell_apk',
78 'org.chromium.content_shell_apk.ContentShellActivity',
79 '/data/local/tmp/content-shell-command-line',
81 'org.chromium.content_shell_apk.tests'),
82 'chrome_shell': PackageInfo(
83 'org.chromium.chrome.shell',
84 'org.chromium.chrome.shell.ChromeShellActivity',
85 '/data/local/tmp/chrome-shell-command-line',
86 'chrome_shell_devtools_remote',
87 'org.chromium.chrome.shell.tests'),
88 'android_webview_shell': PackageInfo(
89 'org.chromium.android_webview.shell',
90 'org.chromium.android_webview.shell.AwShellActivity',
93 'org.chromium.android_webview.test'),
95 'org.chromium.native_test',
96 'org.chromium.native_test.ChromeNativeTestActivity',
97 '/data/local/tmp/chrome-native-tests-command-line',
100 'content_browsertests': PackageInfo(
101 'org.chromium.content_browsertests_apk',
102 'org.chromium.content_browsertests_apk.ContentBrowserTestsActivity',
103 '/data/local/tmp/content-browser-tests-command-line',
106 'chromedriver_webview_shell': PackageInfo(
107 'org.chromium.chromedriver_webview_shell',
108 'org.chromium.chromedriver_webview_shell.Main',
115 # Ports arrangement for various test servers used in Chrome for Android.
116 # Lighttpd server will attempt to use 9000 as default port, if unavailable it
117 # will find a free port from 8001 - 8999.
118 LIGHTTPD_DEFAULT_PORT
= 9000
119 LIGHTTPD_RANDOM_PORT_FIRST
= 8001
120 LIGHTTPD_RANDOM_PORT_LAST
= 8999
121 TEST_SYNC_SERVER_PORT
= 9031
122 TEST_SEARCH_BY_IMAGE_SERVER_PORT
= 9041
124 # The net test server is started from port 10201.
125 # TODO(pliard): http://crbug.com/239014. Remove this dirty workaround once
126 # http://crbug.com/239014 is fixed properly.
127 TEST_SERVER_PORT_FIRST
= 10201
128 TEST_SERVER_PORT_LAST
= 30000
129 # A file to record next valid port of test server.
130 TEST_SERVER_PORT_FILE
= '/tmp/test_server_port'
131 TEST_SERVER_PORT_LOCKFILE
= '/tmp/test_server_port.lock'
133 TEST_EXECUTABLE_DIR
= '/data/local/tmp'
134 # Directories for common java libraries for SDK build.
135 # These constants are defined in build/android/ant/common.xml
136 SDK_BUILD_JAVALIB_DIR
= 'lib.java'
137 SDK_BUILD_TEST_JAVALIB_DIR
= 'test.lib.java'
138 SDK_BUILD_APKS_DIR
= 'apks'
140 ADB_KEYS_FILE
= '/data/misc/adb/adb_keys'
142 PERF_OUTPUT_DIR
= os
.path
.join(DIR_SOURCE_ROOT
, 'out', 'step_results')
143 # The directory on the device where perf test output gets saved to.
144 DEVICE_PERF_OUTPUT_DIR
= (
145 '/data/data/' + PACKAGE_INFO
['chrome'].package
+ '/files')
147 SCREENSHOTS_DIR
= os
.path
.join(DIR_SOURCE_ROOT
, 'out_screenshots')
149 class ANDROID_SDK_VERSION_CODES(object):
150 """Android SDK version codes.
152 http://developer.android.com/reference/android/os/Build.VERSION_CODES.html
155 ICE_CREAM_SANDWICH
= 14
156 ICE_CREAM_SANDWICH_MR1
= 15
164 ANDROID_SDK_VERSION
= ANDROID_SDK_VERSION_CODES
.LOLLIPOP
165 ANDROID_SDK_BUILD_TOOLS_VERSION
= '21.0.1'
166 ANDROID_SDK_ROOT
= os
.path
.join(DIR_SOURCE_ROOT
,
167 'third_party/android_tools/sdk')
168 ANDROID_SDK_TOOLS
= os
.path
.join(ANDROID_SDK_ROOT
,
169 'build-tools', ANDROID_SDK_BUILD_TOOLS_VERSION
)
170 ANDROID_NDK_ROOT
= os
.path
.join(DIR_SOURCE_ROOT
,
171 'third_party/android_tools/ndk')
173 EMULATOR_SDK_ROOT
= os
.environ
.get('ANDROID_EMULATOR_SDK_ROOT',
174 os
.path
.join(DIR_SOURCE_ROOT
,
175 'android_emulator_sdk'))
177 BAD_DEVICES_JSON
= os
.path
.join(DIR_SOURCE_ROOT
,
178 os
.environ
.get('CHROMIUM_OUT_DIR', 'out'),
181 UPSTREAM_FLAKINESS_SERVER
= 'test-results.appspot.com'
183 DEVICE_LOCAL_PROPERTIES_PATH
= '/data/local.prop'
185 PYTHON_UNIT_TEST_SUITES
= {
186 'pylib_py_unittests': {
187 'path': os
.path
.join(DIR_SOURCE_ROOT
, 'build', 'android'),
189 'pylib.device.device_utils_test',
190 'pylib.utils.md5sum_test',
193 'gyp_py_unittests': {
194 'path': os
.path
.join(DIR_SOURCE_ROOT
, 'build', 'android', 'gyp'),
196 'java_cpp_enum_tests',
201 LOCAL_MACHINE_TESTS
= ['junit', 'python']
202 VALID_ENVIRONMENTS
= ['local']
207 return os
.environ
['BUILDTYPE']
209 raise Exception('The BUILDTYPE environment variable has not been set')
212 def SetBuildType(build_type
):
213 os
.environ
['BUILDTYPE'] = build_type
216 def SetBuildDirectory(build_directory
):
217 os
.environ
['CHROMIUM_OUT_DIR'] = build_directory
220 def SetOutputDirectort(output_directory
):
221 os
.environ
['CHROMIUM_OUTPUT_DIR'] = output_directory
224 def GetOutDirectory(build_type
=None):
225 """Returns the out directory where the output binaries are built.
228 build_type: Build type, generally 'Debug' or 'Release'. Defaults to the
229 globally set build type environment variable BUILDTYPE.
231 if 'CHROMIUM_OUTPUT_DIR' in os
.environ
:
232 return os
.path
.abspath(os
.path
.join(
233 DIR_SOURCE_ROOT
, os
.environ
.get('CHROMIUM_OUTPUT_DIR')))
235 return os
.path
.abspath(os
.path
.join(
236 DIR_SOURCE_ROOT
, os
.environ
.get('CHROMIUM_OUT_DIR', 'out'),
237 GetBuildType() if build_type
is None else build_type
))
244 except AttributeError:
245 func
._result
= func()
250 def SetAdbPath(adb_path
):
251 os
.environ
['ADB_PATH'] = adb_path
255 # Check if a custom adb path as been set. If not, try to find adb
257 if os
.environ
.get('ADB_PATH'):
258 return os
.environ
.get('ADB_PATH')
260 return _FindAdbPath()
265 if os
.environ
.get('ANDROID_SDK_ROOT'):
267 # If envsetup.sh hasn't been sourced and there's no adb in the path,
270 with
file(os
.devnull
, 'w') as devnull
:
271 subprocess
.call(['adb', 'version'], stdout
=devnull
, stderr
=devnull
)
274 logging
.debug('No adb found in $PATH, fallback to checked in binary.')
275 return os
.path
.join(ANDROID_SDK_ROOT
, 'platform-tools', 'adb')
279 WARNING_EXIT_CODE
= 88