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.utils import apk_helper | 9 from pylib.utils import apk_helper |
10 | 10 |
11 import test_jar | 11 import test_jar |
12 | 12 |
13 | 13 |
14 def _rreplace(s, old, new, occurrence=1): | |
frankf
2013/07/22 20:27:04
Name style issue
craigdh
2013/07/22 23:50:25
Done.
| |
15 li = s.rsplit(old, occurrence) | |
16 return new.join(li) | |
17 | |
frankf
2013/07/22 20:27:04
2 Blank lines
craigdh
2013/07/22 23:50:25
Done.
| |
14 class TestPackage(test_jar.TestJar): | 18 class TestPackage(test_jar.TestJar): |
15 def __init__(self, apk_path, jar_path): | 19 def __init__(self, apk_path, jar_path): |
16 test_jar.TestJar.__init__(self, jar_path) | 20 test_jar.TestJar.__init__(self, jar_path) |
17 | 21 |
18 if not os.path.exists(apk_path): | 22 if not os.path.exists(apk_path): |
19 raise Exception('%s not found, please build it' % apk_path) | 23 raise Exception('%s not found, please build it' % apk_path) |
20 self._apk_path = apk_path | 24 self._apk_path = apk_path |
21 self._apk_name = os.path.splitext(os.path.basename(apk_path))[0] | 25 self._apk_name = os.path.splitext(os.path.basename(apk_path))[0] |
22 self._package_name = apk_helper.GetPackageName(self._apk_path) | 26 self._package_name = apk_helper.GetPackageName(self._apk_path) |
23 | 27 |
24 def GetApkPath(self): | 28 def GetApkPath(self): |
25 """Returns the absolute path to the APK.""" | 29 """Returns the absolute path to the APK.""" |
26 return self._apk_path | 30 return self._apk_path |
27 | 31 |
28 def GetApkName(self): | 32 def GetApkName(self): |
29 """Returns the name of the apk without the suffix.""" | 33 """Returns the name of the apk without the suffix.""" |
30 return self._apk_name | 34 return self._apk_name |
31 | 35 |
32 def GetPackageName(self): | 36 def GetPackageName(self): |
33 """Returns the package name of this APK.""" | 37 """Returns the package name of this APK.""" |
34 return self._package_name | 38 return self._package_name |
35 | 39 |
36 # Override. | 40 # Override. |
37 def Install(self, adb): | 41 def Install(self, adb): |
38 adb.ManagedInstall(self.GetApkPath(), package_name=self.GetPackageName()) | 42 adb.ManagedInstall(self.GetApkPath(), package_name=self.GetPackageName()) |
43 # Install apk to be tested. | |
44 apk_path = _rreplace(self.GetApkPath(), 'Test.apk', '.apk') | |
frankf
2013/07/22 20:27:04
This is not in the CL description. You also need t
craigdh
2013/07/22 23:50:25
Yep I was planning to do that separately. It's not
| |
45 package_name = _rreplace(self.GetPackageName(), '.tests', '') | |
46 adb.ManagedInstall(apk_path, package_name=package_name) | |
OLD | NEW |