Loading scripts/test_config_fixer.py +3 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ from manifest import parse_manifest from manifest import parse_test_config from manifest import write_xml KNOWN_PREPARERS = ['com.android.tradefed.targetprep.TestAppInstallSetup', 'com.android.tradefed.targetprep.suite.SuiteApkInstaller'] def parse_args(): """Parse commandline arguments.""" Loading Loading @@ -64,7 +66,7 @@ def overwrite_test_file_name(test_config_doc, test_file_name): tests = get_children_with_tag(test_config, 'target_preparer') for test in tests: if test.getAttribute('class') == "com.android.tradefed.targetprep.TestAppInstallSetup": if test.getAttribute('class') in KNOWN_PREPARERS: options = get_children_with_tag(test, 'option') for option in options: if option.getAttribute('name') == "test-file-name": Loading scripts/test_config_fixer_test.py +27 −4 Original line number Diff line number Diff line Loading @@ -70,7 +70,7 @@ class OverwritePackageNameTest(unittest.TestCase): class OverwriteTestFileNameTest(unittest.TestCase): """ Unit tests for overwrite_test_file_name function """ test_config = ( test_config_test_app_install_setup = ( '<?xml version="1.0" encoding="utf-8"?>\n' '<configuration description="Runs some tests.">\n' ' <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">\n' Loading @@ -82,15 +82,38 @@ class OverwriteTestFileNameTest(unittest.TestCase): ' </test>\n' '</configuration>\n') def test_all(self): doc = minidom.parseString(self.test_config % ("foo.apk")) test_config_suite_apk_installer = ( '<?xml version="1.0" encoding="utf-8"?>\n' '<configuration description="Runs some tests.">\n' ' <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">\n' ' <option name="test-file-name" value="%s"/>\n' ' </target_preparer>\n' ' <test class="com.android.tradefed.testtype.AndroidJUnitTest">\n' ' <option name="package" value="com.android.foo"/>\n' ' <option name="runtime-hint" value="20s"/>\n' ' </test>\n' '</configuration>\n') def test_testappinstallsetup(self): doc = minidom.parseString(self.test_config_test_app_install_setup % ("foo.apk")) test_config_fixer.overwrite_test_file_name(doc, "bar.apk") output = io.StringIO() test_config_fixer.write_xml(output, doc) # Only the matching package name in a test node should be updated. expected = self.test_config_test_app_install_setup % ("bar.apk") self.assertEqual(expected, output.getvalue()) def test_suiteapkinstaller(self): doc = minidom.parseString(self.test_config_suite_apk_installer % ("foo.apk")) test_config_fixer.overwrite_test_file_name(doc, "bar.apk") output = io.StringIO() test_config_fixer.write_xml(output, doc) # Only the matching package name in a test node should be updated. expected = self.test_config % ("bar.apk") expected = self.test_config_suite_apk_installer % ("bar.apk") self.assertEqual(expected, output.getvalue()) Loading Loading
scripts/test_config_fixer.py +3 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ from manifest import parse_manifest from manifest import parse_test_config from manifest import write_xml KNOWN_PREPARERS = ['com.android.tradefed.targetprep.TestAppInstallSetup', 'com.android.tradefed.targetprep.suite.SuiteApkInstaller'] def parse_args(): """Parse commandline arguments.""" Loading Loading @@ -64,7 +66,7 @@ def overwrite_test_file_name(test_config_doc, test_file_name): tests = get_children_with_tag(test_config, 'target_preparer') for test in tests: if test.getAttribute('class') == "com.android.tradefed.targetprep.TestAppInstallSetup": if test.getAttribute('class') in KNOWN_PREPARERS: options = get_children_with_tag(test, 'option') for option in options: if option.getAttribute('name') == "test-file-name": Loading
scripts/test_config_fixer_test.py +27 −4 Original line number Diff line number Diff line Loading @@ -70,7 +70,7 @@ class OverwritePackageNameTest(unittest.TestCase): class OverwriteTestFileNameTest(unittest.TestCase): """ Unit tests for overwrite_test_file_name function """ test_config = ( test_config_test_app_install_setup = ( '<?xml version="1.0" encoding="utf-8"?>\n' '<configuration description="Runs some tests.">\n' ' <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">\n' Loading @@ -82,15 +82,38 @@ class OverwriteTestFileNameTest(unittest.TestCase): ' </test>\n' '</configuration>\n') def test_all(self): doc = minidom.parseString(self.test_config % ("foo.apk")) test_config_suite_apk_installer = ( '<?xml version="1.0" encoding="utf-8"?>\n' '<configuration description="Runs some tests.">\n' ' <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">\n' ' <option name="test-file-name" value="%s"/>\n' ' </target_preparer>\n' ' <test class="com.android.tradefed.testtype.AndroidJUnitTest">\n' ' <option name="package" value="com.android.foo"/>\n' ' <option name="runtime-hint" value="20s"/>\n' ' </test>\n' '</configuration>\n') def test_testappinstallsetup(self): doc = minidom.parseString(self.test_config_test_app_install_setup % ("foo.apk")) test_config_fixer.overwrite_test_file_name(doc, "bar.apk") output = io.StringIO() test_config_fixer.write_xml(output, doc) # Only the matching package name in a test node should be updated. expected = self.test_config_test_app_install_setup % ("bar.apk") self.assertEqual(expected, output.getvalue()) def test_suiteapkinstaller(self): doc = minidom.parseString(self.test_config_suite_apk_installer % ("foo.apk")) test_config_fixer.overwrite_test_file_name(doc, "bar.apk") output = io.StringIO() test_config_fixer.write_xml(output, doc) # Only the matching package name in a test node should be updated. expected = self.test_config % ("bar.apk") expected = self.test_config_suite_apk_installer % ("bar.apk") self.assertEqual(expected, output.getvalue()) Loading