Example #1
0
 def manifest(self):
   """The manifest of the AndroidLibrary, if one exists."""
   # Libraries may not have a manifest, so self.manifest can be None for android_libraries.
   if self._manifest_file is None:
     return None
   else:
     manifest_path = os.path.join(self._spec_path, self._manifest_file)
   return AndroidManifestParser.parse_manifest(manifest_path)
Example #2
0
 def manifest(self):
     """The manifest of the AndroidLibrary, if one exists."""
     # Libraries may not have a manifest, so self.manifest can be None for android_libraries.
     if self._manifest_file is None:
         return None
     else:
         manifest_path = os.path.join(self._spec_path, self._manifest_file)
     return AndroidManifestParser.parse_manifest(manifest_path)
Example #3
0
  def manifest(self):
    """Return an AndroidManifest object made from a manifest by AndroidManifestParser."""

    # If there was no 'manifest' field in the BUILD file, try to find one with the default value.
    if self._manifest_file is None:
      self._manifest_file = 'AndroidManifest.xml'
    manifest_path = os.path.join(self._spec_path, self._manifest_file)
    if not os.path.isfile(manifest_path):
      raise TargetDefinitionException(self, "There is no AndroidManifest.xml at path {0}. Please "
                                            "declare a 'manifest' field with its relative "
                                            "path.".format(manifest_path))
    return AndroidManifestParser.parse_manifest(manifest_path)
Example #4
0
    def manifest(self):
        """Return an AndroidManifest object made from a manifest by AndroidManifestParser."""

        # If there was no 'manifest' field in the BUILD file, try to find one with the default value.
        if self._manifest_file is None:
            self._manifest_file = 'AndroidManifest.xml'
        manifest_path = os.path.join(self._spec_path, self._manifest_file)
        if not os.path.isfile(manifest_path):
            raise TargetDefinitionException(
                self, "There is no AndroidManifest.xml at path {0}. Please "
                "declare a 'manifest' field with its relative "
                "path.".format(manifest_path))
        return AndroidManifestParser.parse_manifest(manifest_path)
 def test_parse_manifest(self):
   with self.xml_file() as xml:
     manifest = AndroidManifestParser.parse_manifest(xml)
     self.assertEqual(manifest.path, xml)
 def test_no_android_part(self):
   with self.xml_file(android_attribute='unrelated:targetSdkVersion') as xml:
     manifest = AndroidManifestParser.parse_manifest(xml)
     self.assertEqual(manifest.package_name, 'org.pantsbuild.example.hello')
 def test_no_uses_sdk_element(self):
   with self.xml_file(uses_sdk_element='something-random') as xml:
     manifest = AndroidManifestParser.parse_manifest(xml)
     self.assertIsNone(manifest.target_sdk)
 def test_weird_package_name(self):
   # Should accept unexpected package names, the info gets verified in classes that consume it.
   with self.xml_file(package_value='cola') as xml:
     manifest = AndroidManifestParser.parse_manifest(xml)
     self.assertEqual(manifest.package_name, 'cola')
 def test_missing_manifest_element(self):
   with self.xml_file(manifest_element='some_other_element') as xml:
     with self.assertRaises(AndroidManifestParser.BadManifestError):
       AndroidManifestParser.parse_manifest(xml)
Example #10
0
 def test_weird_package_name(self):
     # Should accept unexpected package names, the info gets verified in classes that consume it.
     with self.xml_file(package_value='cola') as xml:
         manifest = AndroidManifestParser.parse_manifest(xml)
         self.assertEqual(manifest.package_name, 'cola')
Example #11
0
 def test_missing_package_attribute(self):
     with self.xml_file(package_attribute='bad_value') as xml:
         with self.assertRaises(AndroidManifestParser.BadManifestError):
             AndroidManifestParser.parse_manifest(xml)
Example #12
0
 def test_missing_manifest_element(self):
     with self.xml_file(manifest_element='some_other_element') as xml:
         with self.assertRaises(AndroidManifestParser.BadManifestError):
             AndroidManifestParser.parse_manifest(xml)
Example #13
0
 def test_package_name(self):
     with self.xml_file() as xml:
         manifest = AndroidManifestParser.parse_manifest(xml)
         self.assertEqual(manifest.package_name,
                          'org.pantsbuild.example.hello')
Example #14
0
 def test_bad_parse_manifest(self):
     xml = '/no/file/here'
     with self.assertRaises(AndroidManifestParser.BadManifestError):
         AndroidManifestParser.parse_manifest(xml)
Example #15
0
 def test_parse_manifest(self):
     with self.xml_file() as xml:
         manifest = AndroidManifestParser.parse_manifest(xml)
         self.assertEqual(manifest.path, xml)
 def test_bad_parse_manifest(self):
   xml = '/no/file/here'
   with self.assertRaises(AndroidManifestParser.BadManifestError):
     AndroidManifestParser.parse_manifest(xml)
 def test_package_name(self):
   with self.xml_file() as xml:
     manifest = AndroidManifestParser.parse_manifest(xml)
     self.assertEqual(manifest.package_name, 'org.pantsbuild.example.hello')
Example #18
0
 def test_target_sdk(self):
     with self.xml_file() as xml:
         manifest = AndroidManifestParser.parse_manifest(xml)
         self.assertEqual(manifest.target_sdk, '19')
 def test_missing_package_attribute(self):
   with self.xml_file(package_attribute='bad_value') as xml:
     with self.assertRaises(AndroidManifestParser.BadManifestError):
       AndroidManifestParser.parse_manifest(xml)
Example #20
0
 def test_no_uses_sdk_element(self):
     with self.xml_file(uses_sdk_element='something-random') as xml:
         manifest = AndroidManifestParser.parse_manifest(xml)
         self.assertIsNone(manifest.target_sdk)
 def test_target_sdk(self):
   with self.xml_file() as xml:
     manifest = AndroidManifestParser.parse_manifest(xml)
     self.assertEqual(manifest.target_sdk, '19')
Example #22
0
 def test_no_target_sdk_value(self):
     with self.xml_file(android_attribute='android:bad_value') as xml:
         parsed = AndroidManifestParser.parse_manifest(xml)
         self.assertIsNone(parsed.target_sdk)
 def test_no_target_sdk_value(self):
   with self.xml_file(android_attribute='android:bad_value') as xml:
     parsed = AndroidManifestParser.parse_manifest(xml)
     self.assertIsNone(parsed.target_sdk)
Example #24
0
 def test_no_android_part(self):
     with self.xml_file(
             android_attribute='unrelated:targetSdkVersion') as xml:
         manifest = AndroidManifestParser.parse_manifest(xml)
         self.assertEqual(manifest.package_name,
                          'org.pantsbuild.example.hello')
 def test_missing_whole_targetsdk(self):
   with self.xml_file(android_attribute='unrelated:cola') as xml:
     manifest = AndroidManifestParser.parse_manifest(xml)
     self.assertIsNone(manifest.target_sdk)
Example #26
0
 def test_missing_whole_targetsdk(self):
     with self.xml_file(android_attribute='unrelated:cola') as xml:
         manifest = AndroidManifestParser.parse_manifest(xml)
         self.assertIsNone(manifest.target_sdk)