summaryrefslogtreecommitdiff
path: root/scripts/manifest_fixer_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/manifest_fixer_test.py')
-rwxr-xr-xscripts/manifest_fixer_test.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/scripts/manifest_fixer_test.py b/scripts/manifest_fixer_test.py
index 20354218c..ea8095e48 100755
--- a/scripts/manifest_fixer_test.py
+++ b/scripts/manifest_fixer_test.py
@@ -424,5 +424,47 @@ class AddExtractNativeLibsTest(unittest.TestCase):
self.assertRaises(RuntimeError, self.run_test, manifest_input, False)
+class AddNoCodeApplicationTest(unittest.TestCase):
+ """Unit tests for set_has_code_to_false function."""
+
+ def run_test(self, input_manifest):
+ doc = minidom.parseString(input_manifest)
+ manifest_fixer.set_has_code_to_false(doc)
+ output = StringIO.StringIO()
+ manifest_fixer.write_xml(output, doc)
+ return output.getvalue()
+
+ manifest_tmpl = (
+ '<?xml version="1.0" encoding="utf-8"?>\n'
+ '<manifest xmlns:android="http://schemas.android.com/apk/res/android">\n'
+ '%s'
+ '</manifest>\n')
+
+ def test_no_application(self):
+ manifest_input = self.manifest_tmpl % ''
+ expected = self.manifest_tmpl % ' <application android:hasCode="false"/>\n'
+ output = self.run_test(manifest_input)
+ self.assertEqual(output, expected)
+
+ def test_has_application_no_has_code(self):
+ manifest_input = self.manifest_tmpl % ' <application/>\n'
+ expected = self.manifest_tmpl % ' <application android:hasCode="false"/>\n'
+ output = self.run_test(manifest_input)
+ self.assertEqual(output, expected)
+
+ def test_has_application_has_code_false(self):
+ """ Do nothing if there's already an application elemeent. """
+ manifest_input = self.manifest_tmpl % ' <application android:hasCode="false"/>\n'
+ output = self.run_test(manifest_input)
+ self.assertEqual(output, manifest_input)
+
+ def test_has_application_has_code_true(self):
+ """ Do nothing if there's already an application elemeent even if its
+ hasCode attribute is true. """
+ manifest_input = self.manifest_tmpl % ' <application android:hasCode="true"/>\n'
+ output = self.run_test(manifest_input)
+ self.assertEqual(output, manifest_input)
+
+
if __name__ == '__main__':
unittest.main(verbosity=2)