diff options
author | 2022-07-27 14:59:18 +0100 | |
---|---|---|
committer | 2022-08-03 12:05:14 +0100 | |
commit | 69cf0f375687f936c1832bc7c049e8b105304abb (patch) | |
tree | fcbaaa3321d663576df87006282e6616404a1759 /scripts/manifest_fixer_test.py | |
parent | 950f28abe243ec7092face27681508480cc92293 (diff) |
Overriding placeholder version in updatable apks
Test: presubmit, checked the app version after build locally
Bug: 231691162
Change-Id: Icd242432540ea424235b226a45aac839dbc995be
Diffstat (limited to 'scripts/manifest_fixer_test.py')
-rwxr-xr-x | scripts/manifest_fixer_test.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/scripts/manifest_fixer_test.py b/scripts/manifest_fixer_test.py index dad104a54..0a62b10a4 100755 --- a/scripts/manifest_fixer_test.py +++ b/scripts/manifest_fixer_test.py @@ -643,5 +643,39 @@ class SetMaxSdkVersionTest(unittest.TestCase): output = self.run_test(manifest_input, '9000') self.assert_xml_equal(output, expected) +class OverrideDefaultVersionTest(unittest.TestCase): + """Unit tests for override_default_version function.""" + + def assert_xml_equal(self, output, expected): + self.assertEqual(ET.canonicalize(output), ET.canonicalize(expected)) + + def run_test(self, input_manifest, version): + doc = minidom.parseString(input_manifest) + manifest_fixer.override_placeholder_version(doc, version) + output = io.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" ' + 'android:versionCode="%s">\n' + '</manifest>\n') + + def test_doesnt_override_existing_version(self): + """Tests that an existing version is not overridden""" + manifest_input = self.manifest_tmpl % '12345' + expected = manifest_input + output = self.run_test(manifest_input, '67890') + self.assert_xml_equal(output, expected) + + def test_overrides_default_version(self): + """Tests that a default version is overridden""" + manifest_input = self.manifest_tmpl % '0' + expected = self.manifest_tmpl % '67890' + output = self.run_test(manifest_input, '67890') + self.assert_xml_equal(output, expected) + + if __name__ == '__main__': unittest.main(verbosity=2) |