OLD | NEW |
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 | 4 |
5 """Gathers information about APKs.""" | 5 """Gathers information about APKs.""" |
6 | 6 |
7 import collections | 7 import collections |
8 import os | 8 import os |
9 import re | 9 import re |
10 | 10 |
11 import cmd_helper | 11 import cmd_helper |
12 | 12 |
13 | 13 |
14 class ApkInfo(object): | 14 class ApkInfo(object): |
15 """Helper class for inspecting APKs.""" | 15 """Helper class for inspecting APKs.""" |
16 _PROGUARD_PATH = os.path.join(os.environ['ANDROID_SDK_ROOT'], | |
17 'tools/proguard/bin/proguard.sh') | |
18 if not os.path.exists(_PROGUARD_PATH): | |
19 _PROGUARD_PATH = os.path.join(os.environ['ANDROID_BUILD_TOP'], | |
20 'external/proguard/bin/proguard.sh') | |
21 _PROGUARD_CLASS_RE = re.compile(r'\s*?- Program class:\s*([\S]+)$') | |
22 _PROGUARD_METHOD_RE = re.compile(r'\s*?- Method:\s*(\S*)[(].*$') | |
23 _PROGUARD_ANNOTATION_RE = re.compile(r'\s*?- Annotation \[L(\S*);\]:$') | |
24 _PROGUARD_ANNOTATION_CONST_RE = re.compile(r'\s*?- Constant element value.*$') | |
25 _PROGUARD_ANNOTATION_VALUE_RE = re.compile(r'\s*?- \S+? \[(.*)\]$') | |
26 _AAPT_PACKAGE_NAME_RE = re.compile(r'package: .*name=\'(\S*)\'') | |
27 | 16 |
28 def __init__(self, apk_path, jar_path): | 17 def __init__(self, apk_path, jar_path): |
| 18 self._PROGUARD_PATH = os.path.join(os.environ['ANDROID_SDK_ROOT'], |
| 19 'tools/proguard/bin/proguard.sh') |
| 20 if not os.path.exists(self._PROGUARD_PATH): |
| 21 self._PROGUARD_PATH = os.path.join(os.environ['ANDROID_BUILD_TOP'], |
| 22 'external/proguard/bin/proguard.sh') |
| 23 self._PROGUARD_CLASS_RE = re.compile(r'\s*?- Program class:\s*([\S]+)$') |
| 24 self._PROGUARD_METHOD_RE = re.compile(r'\s*?- Method:\s*(\S*)[(].*$') |
| 25 self._PROGUARD_ANNOTATION_RE = re.compile(r'\s*?- Annotation \[L(\S*);\]:$') |
| 26 self._PROGUARD_ANNOTATION_CONST_RE = ( |
| 27 re.compile(r'\s*?- Constant element value.*$')) |
| 28 self._PROGUARD_ANNOTATION_VALUE_RE = re.compile(r'\s*?- \S+? \[(.*)\]$') |
| 29 self._AAPT_PACKAGE_NAME_RE = re.compile(r'package: .*name=\'(\S*)\'') |
| 30 |
29 if not os.path.exists(apk_path): | 31 if not os.path.exists(apk_path): |
30 raise Exception('%s not found, please build it' % apk_path) | 32 raise Exception('%s not found, please build it' % apk_path) |
31 self._apk_path = apk_path | 33 self._apk_path = apk_path |
32 if not os.path.exists(jar_path): | 34 if not os.path.exists(jar_path): |
33 raise Exception('%s not found, please build it' % jar_path) | 35 raise Exception('%s not found, please build it' % jar_path) |
34 self._jar_path = jar_path | 36 self._jar_path = jar_path |
35 self._annotation_map = collections.defaultdict(list) | 37 self._annotation_map = collections.defaultdict(list) |
36 self._test_methods = [] | 38 self._test_methods = [] |
37 self._Initialize() | 39 self._Initialize() |
38 | 40 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 if self._IsTestMethod(test) and self._AnnotationsMatchFilters( | 135 if self._IsTestMethod(test) and self._AnnotationsMatchFilters( |
134 annotation_filter_list, annotations)] | 136 annotation_filter_list, annotations)] |
135 | 137 |
136 def GetTestMethods(self): | 138 def GetTestMethods(self): |
137 """Returns a list of all test methods in this apk as Class#testMethod.""" | 139 """Returns a list of all test methods in this apk as Class#testMethod.""" |
138 return self._test_methods | 140 return self._test_methods |
139 | 141 |
140 @staticmethod | 142 @staticmethod |
141 def IsPythonDrivenTest(test): | 143 def IsPythonDrivenTest(test): |
142 return 'pythonDrivenTests' in test | 144 return 'pythonDrivenTests' in test |
OLD | NEW |