OLD | NEW |
---|---|
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 pylib.instrumentation import test_jar | 9 from pylib.instrumentation import test_jar |
10 from pylib.utils import apk_helper | 10 from pylib.utils import apk_helper |
11 | 11 |
12 | 12 |
13 class TestPackage(test_jar.TestJar): | 13 class TestPackage(test_jar.TestJar): |
14 def __init__(self, apk_path, jar_path): | 14 def __init__(self, apk_path, jar_path): |
15 test_jar.TestJar.__init__(self, jar_path) | 15 test_jar.TestJar.__init__(self, jar_path) |
16 | 16 |
17 if not os.path.exists(apk_path): | 17 if not os.path.exists(apk_path): |
18 raise Exception('%s not found, please build it' % apk_path) | 18 raise Exception('%s not found, please build it' % apk_path) |
19 self._apk_path = apk_path | 19 self._apk_path = apk_path |
20 self._apk_name = os.path.splitext(os.path.basename(apk_path))[0] | 20 self._apk_name = os.path.splitext(os.path.basename(apk_path))[0] |
21 self._package_name = apk_helper.GetPackageName(self._apk_path) | 21 self._package_name = apk_helper.GetPackageName(self._apk_path) |
22 self._support_apk_name = "%sSupport%s" % ( | |
jbudorick
2014/06/17 20:17:08
I don't think hardcoding this is a good idea. Can
aberent
2014/06/17 20:39:42
We could add it as an extra instrumentation option
| |
23 os.path.splitext(self._apk_path)[0], | |
24 os.path.splitext(self._apk_path)[1]) | |
22 | 25 |
23 def GetApkPath(self): | 26 def GetApkPath(self): |
24 """Returns the absolute path to the APK.""" | 27 """Returns the absolute path to the APK.""" |
25 return self._apk_path | 28 return self._apk_path |
26 | 29 |
27 def GetApkName(self): | 30 def GetApkName(self): |
28 """Returns the name of the apk without the suffix.""" | 31 """Returns the name of the apk without the suffix.""" |
29 return self._apk_name | 32 return self._apk_name |
30 | 33 |
31 def GetPackageName(self): | 34 def GetPackageName(self): |
32 """Returns the package name of this APK.""" | 35 """Returns the package name of this APK.""" |
33 return self._package_name | 36 return self._package_name |
34 | 37 |
35 # Override. | 38 # Override. |
36 def Install(self, device): | 39 def Install(self, device): |
37 device.Install(self.GetApkPath()) | 40 device.Install(self.GetApkPath()) |
41 if os.path.exists(self._support_apk_name): | |
42 device.Install(self._support_apk_name) | |
38 | 43 |
OLD | NEW |