summaryrefslogtreecommitdiff
path: root/scripts/manifest_check_test.py
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-09-13 19:52:44 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2024-09-13 19:52:44 +0000
commitc2ea958b3d4474d203d2937a02b265a39f77c8e8 (patch)
tree78410d0aa6fc7f3e6ce803f8764be36a3ffa735a /scripts/manifest_check_test.py
parent05d906905193ca79e49fe435e6368a4991154842 (diff)
parente1ab849b391c6d5c7fbf57310701c99cad88ba21 (diff)
Merge changes from topic "flag_application_manifest" into main
* changes: Support multiple <application> or <uses-sdk> elements in manifest_*.py Fix manifest_fixer.py warnings
Diffstat (limited to 'scripts/manifest_check_test.py')
-rwxr-xr-xscripts/manifest_check_test.py42
1 files changed, 34 insertions, 8 deletions
diff --git a/scripts/manifest_check_test.py b/scripts/manifest_check_test.py
index 8003b3e19..abe0d8b0e 100755
--- a/scripts/manifest_check_test.py
+++ b/scripts/manifest_check_test.py
@@ -44,8 +44,8 @@ def required_apk(value):
class EnforceUsesLibrariesTest(unittest.TestCase):
"""Unit tests for add_extract_native_libs function."""
- def run_test(self, xml, apk, uses_libraries=[], optional_uses_libraries=[],
- missing_optional_uses_libraries=[]): #pylint: disable=dangerous-default-value
+ def run_test(self, xml, apk, uses_libraries=(), optional_uses_libraries=(),
+ missing_optional_uses_libraries=()): #pylint: disable=dangerous-default-value
doc = minidom.parseString(xml)
try:
relax = False
@@ -114,14 +114,14 @@ class EnforceUsesLibrariesTest(unittest.TestCase):
self.assertFalse(matches)
def test_missing_uses_library(self):
- xml = self.xml_tmpl % ('')
- apk = self.apk_tmpl % ('')
+ xml = self.xml_tmpl % ''
+ apk = self.apk_tmpl % ''
matches = self.run_test(xml, apk, uses_libraries=['foo'])
self.assertFalse(matches)
def test_missing_optional_uses_library(self):
- xml = self.xml_tmpl % ('')
- apk = self.apk_tmpl % ('')
+ xml = self.xml_tmpl % ''
+ apk = self.apk_tmpl % ''
matches = self.run_test(xml, apk, optional_uses_libraries=['foo'])
self.assertFalse(matches)
@@ -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):
@@ -256,12 +282,12 @@ class ExtractTargetSdkVersionTest(unittest.TestCase):
"targetSdkVersion:'%s'\n"
"uses-permission: name='android.permission.ACCESS_NETWORK_STATE'\n")
- def test_targert_sdk_version_28(self):
+ def test_target_sdk_version_28(self):
xml = self.xml_tmpl % '28'
apk = self.apk_tmpl % '28'
self.run_test(xml, apk, '28')
- def test_targert_sdk_version_29(self):
+ def test_target_sdk_version_29(self):
xml = self.xml_tmpl % '29'
apk = self.apk_tmpl % '29'
self.run_test(xml, apk, '29')