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

Side by Side Diff: build/android/pylib/instrumentation/test_package.py

Issue 1680233002: Android Add _incremental targets for instrumentation tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add missing dep Created 4 years, 10 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 (c) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013 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 """Class representing instrumentation test apk and jar.""" 5 """Class representing instrumentation test apk and jar."""
6 6
7 import os 7 import os
8 8
9 from devil.android import apk_helper 9 from devil.android import apk_helper
10 from pylib.instrumentation import test_jar 10 from pylib.instrumentation import test_jar
11 from pylib.local.device import local_device_test_run
11 12
12 13
13 class TestPackage(test_jar.TestJar): 14 class TestPackage(test_jar.TestJar):
14 def __init__(self, apk_path, jar_path, test_support_apk_path, 15 def __init__(self, apk_path, jar_path, test_support_apk_path,
15 additional_apks=None, apk_under_test=None): 16 additional_apks=None, apk_under_test=None,
17 test_apk_incremental_install_script=None,
18 apk_under_test_incremental_install_script=None):
16 test_jar.TestJar.__init__(self, jar_path) 19 test_jar.TestJar.__init__(self, jar_path)
17 20
18 if not os.path.exists(apk_path): 21 if not os.path.exists(apk_path):
19 raise Exception('%s not found, please build it' % apk_path) 22 raise Exception('%s not found, please build it' % apk_path)
20 self._additional_apks = additional_apks or [] 23 self._additional_apks = additional_apks or []
21 self._apk_name = os.path.splitext(os.path.basename(apk_path))[0] 24 self._apk_name = os.path.splitext(os.path.basename(apk_path))[0]
22 if apk_under_test: 25 if apk_under_test:
23 self._apk_under_test = apk_helper.ApkHelper(apk_under_test) 26 self._apk_under_test = apk_helper.ApkHelper(apk_under_test)
24 else: 27 else:
25 self._apk_under_test = None 28 self._apk_under_test = None
26 self._test_apk = apk_helper.ApkHelper(apk_path) 29 self._test_apk = apk_helper.ApkHelper(apk_path)
27 self._test_support_apk_path = test_support_apk_path 30 self._test_support_apk_path = test_support_apk_path
31 self._test_apk_incremental_install_script = (
32 test_apk_incremental_install_script)
33 self._apk_under_test_incremental_install_script = (
34 apk_under_test_incremental_install_script)
28 35
29 def GetApkPath(self): 36 def GetApkPath(self):
30 """Returns the absolute path to the APK.""" 37 """Returns the absolute path to the APK."""
31 return self._test_apk.path 38 return self._test_apk.path
32 39
33 def GetApkUnderTest(self): 40 def GetApkUnderTest(self):
34 """Returns an ApkHelper instance for the apk under test. 41 """Returns an ApkHelper instance for the apk under test.
35 42
36 Note that --apk-under-test is not required, so this can be None. 43 Note that --apk-under-test is not required, so this can be None.
37 """ 44 """
38 return self._apk_under_test 45 return self._apk_under_test
39 46
40 def GetApkName(self): 47 def GetApkName(self):
41 """Returns the name of the apk without the suffix.""" 48 """Returns the name of the apk without the suffix."""
42 return self._apk_name 49 return self._apk_name
43 50
44 def GetPackageName(self): 51 def GetPackageName(self):
45 """Returns the package name of this APK.""" 52 """Returns the package name of this APK."""
46 return self._test_apk.GetPackageName() 53 return self._test_apk.GetPackageName()
47 54
48 def GetTestApk(self): 55 def GetTestApk(self):
49 """Returns an ApkHelper instance for the test apk.""" 56 """Returns an ApkHelper instance for the test apk."""
50 return self._test_apk 57 return self._test_apk
51 58
52 # Override. 59 # Override.
53 def Install(self, device): 60 def Install(self, device):
54 if self._apk_under_test: 61 if self._test_apk_incremental_install_script:
55 device.Install(self._apk_under_test.path) 62 local_device_test_run.IncrementalInstall(device, self._test_apk,
56 device.Install(self.GetApkPath()) 63 self._test_apk_incremental_install_script)
64 else:
65 device.Install(self._test_apk)
66
67 if self._apk_under_test_incremental_install_script:
68 local_device_test_run.IncrementalInstall(device,
69 self._apk_under_test, self._apk_under_test_incremental_install_script)
70 elif self._apk_under_test:
71 device.Install(self._apk_under_test)
72
57 if (self._test_support_apk_path and 73 if (self._test_support_apk_path and
58 os.path.exists(self._test_support_apk_path)): 74 os.path.exists(self._test_support_apk_path)):
59 device.Install(self._test_support_apk_path) 75 device.Install(self._test_support_apk_path)
60 for apk in (a for a in self._additional_apks if os.path.exists(a)): 76 for apk in (a for a in self._additional_apks if os.path.exists(a)):
61 device.Install(apk) 77 device.Install(apk)
OLDNEW
« no previous file with comments | « build/android/pylib/instrumentation/test_options.py ('k') | build/android/pylib/local/device/local_device_environment.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698