Exemple #1
0
 def test_construct_android_manifest(self):
     m = android.AndroidManifest(None)
     self.assertEqual(m.min_sdk, 0)
     self.assertEqual(m.target_sdk, 0)
     self.assertIsNone(m.path)
     with self.assertRaises(common.ConfigurationError):
         android.AndroidManifest('/non existent/bogus_path')
Exemple #2
0
    def _create_update_build_xml_setup(self):
        build_environment = android.BuildEnvironment(
            android.BuildEnvironment.build_defaults())
        build_environment.sdk_home = ''

        build_environment._find_best_android_sdk = (
            lambda unused_android, unused_min_sdk, unused_target_sdk: 10)

        project_directory = build_environment.get_project_directory()
        buildxml_filename = os.path.join(project_directory, 'build.xml')

        manifest = android.AndroidManifest(None)
        manifest.path = os.path.join(project_directory, 'AndroidManifest.xml')
        manifest._parse(
            FileMock(
                '<manifest '
                '  xmlns:android="http://schemas.android.com/apk/res/android"\n'
                '  package="com.google.fpl.libfplutil_test">\n'
                '  <uses-sdk android:minSdkVersion="1"/>\n'
                '  <application>\n'
                '    <activity android:name="android.app.NativeActivity">\n'
                '      <meta-data android:name="android.app.lib_name"\n'
                '                 android:value="test"/>\n'
                '    </activity>\n'
                '  </application>\n'
                '</manifest>'))

        __builtin__.open = FileMockFactory(
            self, ('<?xml version="1.0" encoding="UTF-8"?>\n'
                   '<project name="libfplutil_test" default="help">\n'
                   '</project>\n'))

        return build_environment, manifest, buildxml_filename
Exemple #3
0
 def test_manifest_parse_missing_uses_sdk(self):
     f = FileMock(
         '<manifest '
         'xmlns:android="http://schemas.android.com/apk/res/android">\n'
         '</manifest>')
     m = android.AndroidManifest(None)
     with self.assertRaises(common.ConfigurationError):
         m._parse(f)
Exemple #4
0
 def test_manifest_parse_native_activity_no_lib(self):
     f = FileMock(
         '<manifest '
         '  xmlns:android="http://schemas.android.com/apk/res/android"\n'
         '  package="com.google.fpl.libfplutil_test">\n'
         '  <uses-sdk android:minSdkVersion="1"/>\n'
         '  <application>\n'
         '    <activity android:name="android.app.NativeActivity">\n'
         '    </activity>\n'
         '  </application>\n'
         '</manifest>')
     m = android.AndroidManifest(None)
     with self.assertRaises(common.ConfigurationError):
         m._parse(f)
Exemple #5
0
 def parse_manifest(self, path=None):
     manifest = android.AndroidManifest(None)
     manifest._parse(
         FileMock(
             '<manifest '
             '  xmlns:android="http://schemas.android.com/apk/res/android"\n'
             '  package="com.google.fpl.libfplutil_test">\n'
             '  <uses-sdk android:minSdkVersion="1"/>\n'
             '  <application>\n'
             '    <activity android:name="android.app.NativeActivity">\n'
             '      <meta-data android:name="android.app.lib_name"\n'
             '                 android:value="test"/>\n'
             '    </activity>\n'
             '  </application>\n'
             '</manifest>'))
     return manifest
Exemple #6
0
 def test_manifest_parse_trivial(self):
     f = FileMock(
         '<manifest '
         '  xmlns:android="http://schemas.android.com/apk/res/android"\n'
         '  package="com.google.fpl.libfplutil_test">\n'
         '  <uses-sdk android:minSdkVersion="1"/>\n'
         '  <application>\n'
         '    <activity android:name="android.app.NativeActivity">\n'
         '      <meta-data android:name="android.app.lib_name"\n'
         '                 android:value="test"/>\n'
         '    </activity>\n'
         '  </application>\n'
         '</manifest>')
     m = android.AndroidManifest(None)
     m._parse(f)
     self.assertEqual(m.min_sdk, 1)
     self.assertEqual(m.target_sdk, m.min_sdk)
Exemple #7
0
 def test_manifest_parse_with_bad_target(self):
     f = FileMock(
         '<manifest \n'
         '  xmlns:android="http://schemas.android.com/apk/res/android"\n'
         '  package="com.google.fpl.libfplutil_test">\n'
         '  <uses-sdk android:minSdkVersion="1" '
         '            android:targetSdkVersion="-2"/>\n'
         '  <application>\n'
         '    <activity android:name="android.app.NativeActivity">\n'
         '      <meta-data android:name="android.app.lib_name"\n'
         '                 android:value="test"/>\n'
         '    </activity>\n'
         '  </application>\n'
         '</manifest>')
     m = android.AndroidManifest(None)
     m._parse(f)
     self.assertEqual(m.min_sdk, 1)
     # this is an error but we want to catch in processing, not parsing
     self.assertEqual(m.target_sdk, -2)
Exemple #8
0
 def test_manifest_parse_error(self):
     f = FileMock('<manifest ')
     m = android.AndroidManifest(None)
     with self.assertRaises(common.ConfigurationError):
         m._parse(f)