def _CreateSuitesFromManifest(self, manifest, build_path, class_name=None, java_package_name=None): """Creates TestSuites from a AndroidManifest. Args: manifest: the AndroidManifest build_path: the build path to use for test class_name: optionally, the class filter for the suite java_package_name: optionally, the java package filter for the suite Returns: the list of tests created """ tests = [] for instr_name in manifest.GetInstrumentationNames(): pkg_name = manifest.GetPackageName() logger.SilentLog('Found instrumentation %s/%s' % (pkg_name, instr_name)) suite = instrumentation_test.InstrumentationTestSuite() suite.SetPackageName(pkg_name) suite.SetBuildPath(build_path) suite.SetRunnerName(instr_name) suite.SetName(pkg_name) suite.SetClassName(class_name) suite.SetJavaPackageFilter(java_package_name) # this is a bit of a hack, assume if 'com.android.cts' is in # package name, this is a cts test # this logic can be removed altogether when cts tests no longer require # custom build steps suite.SetCts(suite.GetPackageName().startswith('com.android.cts')) tests.append(suite) return tests
def Parse(self, suite_element): """Creates suite and populate with data from xml element.""" suite = instrumentation_test.InstrumentationTestSuite() XmlSuiteParser._ParseCommonAttributes(self, suite_element, suite) suite.SetPackageName(self._ParseAttribute(suite_element, self._PKG_ATTR, True)) suite.SetRunnerName(self._ParseAttribute( suite_element, self._RUNNER_ATTR, False, instrumentation_test.InstrumentationTestSuite.DEFAULT_RUNNER)) suite.SetClassName(self._ParseAttribute(suite_element, self._CLASS_ATTR, False)) suite.SetTargetName(self._ParseAttribute(suite_element, self._TARGET_ATTR, False)) return suite