From 5b16dfb39af0c90695c9d5921b1886e8e8d285aa Mon Sep 17 00:00:00 2001 From: Baligh Uddin Date: Tue, 11 Feb 2020 17:27:19 -0800 Subject: Allow for setting a logging_parent for an Android App. Unit test: go test ./... -test.v -run TestOverrideAndroidApp Unit test: python manifest_fixer_test.py BUG: 148198056 Change-Id: Ib5ff235d2a93e88b86aec1c0b16327ea938a094d --- scripts/manifest_fixer_test.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'scripts/manifest_fixer_test.py') diff --git a/scripts/manifest_fixer_test.py b/scripts/manifest_fixer_test.py index ea8095e48..d6e7f2674 100755 --- a/scripts/manifest_fixer_test.py +++ b/scripts/manifest_fixer_test.py @@ -226,6 +226,47 @@ class RaiseMinSdkVersionTest(unittest.TestCase): self.assertEqual(output, expected) +class AddLoggingParentTest(unittest.TestCase): + """Unit tests for add_logging_parent function.""" + + def add_logging_parent_test(self, input_manifest, logging_parent=None): + doc = minidom.parseString(input_manifest) + if logging_parent: + manifest_fixer.add_logging_parent(doc, logging_parent) + output = StringIO.StringIO() + manifest_fixer.write_xml(output, doc) + return output.getvalue() + + manifest_tmpl = ( + '\n' + '\n' + '%s' + '\n') + + def uses_logging_parent(self, logging_parent=None): + attrs = '' + if logging_parent: + meta_text = ('\n') % (logging_parent) + attrs += ' \n %s \n' % (meta_text) + + return attrs + + def test_no_logging_parent(self): + """Tests manifest_fixer with no logging_parent.""" + manifest_input = self.manifest_tmpl % '' + expected = self.manifest_tmpl % self.uses_logging_parent() + output = self.add_logging_parent_test(manifest_input) + self.assertEqual(output, expected) + + def test_logging_parent(self): + """Tests manifest_fixer with no logging_parent.""" + manifest_input = self.manifest_tmpl % '' + expected = self.manifest_tmpl % self.uses_logging_parent('FOO') + output = self.add_logging_parent_test(manifest_input, 'FOO') + self.assertEqual(output, expected) + + class AddUsesLibrariesTest(unittest.TestCase): """Unit tests for add_uses_libraries function.""" -- cgit v1.2.3-59-g8ed1b