summaryrefslogtreecommitdiff
path: root/scripts/manifest_check_test.py
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2024-09-11 13:28:16 -0700
committer Colin Cross <ccross@android.com> 2024-09-13 11:20:21 -0700
commite1ab849b391c6d5c7fbf57310701c99cad88ba21 (patch)
tree558714e1e6952e7c6509e36b5d259e153b655c52 /scripts/manifest_check_test.py
parent6cb462b38c07507e0fc1518762ac2b579a3ede8c (diff)
Support multiple <application> or <uses-sdk> elements in manifest_*.py
Manifests may now have multiple copies of elements if they are disambiguated with android:featureFlag attributes. Remove the restrictions on duplicate elements from manifest_check.py and manifest_fixer.py, and instead iterate over all matching elements. Test: manifest_check_test.py, manifest_fixer_test.py Bug: 365170653 Flag: EXEMPT bugfix Change-Id: Ib577439d03a808a20a5fcc3e15a3117e0970d729
Diffstat (limited to 'scripts/manifest_check_test.py')
-rwxr-xr-xscripts/manifest_check_test.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/scripts/manifest_check_test.py b/scripts/manifest_check_test.py
index 7aaf8a966..abe0d8b0e 100755
--- a/scripts/manifest_check_test.py
+++ b/scripts/manifest_check_test.py
@@ -234,6 +234,32 @@ class EnforceUsesLibrariesTest(unittest.TestCase):
optional_uses_libraries=['//x/y/z:bar'])
self.assertTrue(matches)
+ def test_multiple_applications(self):
+ xml = """<?xml version="1.0" encoding="utf-8"?>
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
+ <application android:featureFlag="foo">
+ <uses-library android:name="foo" />
+ <uses-library android:name="bar" android:required="false" />
+ </application>
+ <application android:featureFlag="!foo">
+ <uses-library android:name="foo" />
+ <uses-library android:name="qux" android:required="false" />
+ </application>
+ </manifest>
+ """
+ apk = self.apk_tmpl % ('\n'.join([
+ uses_library_apk('foo'),
+ uses_library_apk('bar', required_apk(False)),
+ uses_library_apk('foo'),
+ uses_library_apk('qux', required_apk(False))
+ ]))
+ matches = self.run_test(
+ xml,
+ apk,
+ uses_libraries=['//x/y/z:foo'],
+ optional_uses_libraries=['//x/y/z:bar', '//x/y/z:qux'])
+ self.assertTrue(matches)
+
class ExtractTargetSdkVersionTest(unittest.TestCase):