Exemplo n.º 1
0
 def testNoResources(self):
     aar = zipfile.ZipFile(io.BytesIO(), "w")
     os.makedirs("out_dir")
     aar_resources_extractor.ExtractResources(aar, "out_dir")
     self.assertEqual([_HostPath("out_dir/res/values/empty.xml")],
                      self.DirContents("out_dir"))
     with open("out_dir/res/values/empty.xml", "r") as empty_xml:
         self.assertEqual("<resources/>", empty_xml.read())
Exemplo n.º 2
0
 def testContainsResources(self):
   aar = zipfile.ZipFile(StringIO.StringIO(), "w")
   aar.writestr("res/values/values.xml", "some values")
   aar.writestr("res/layouts/layout.xml", "some layout")
   os.makedirs("out_dir")
   aar_resources_extractor.ExtractResources(aar, "out_dir")
   expected_resources = ["out_dir/res/values/values.xml",
                         "out_dir/res/layouts/layout.xml"]
   self.assertItemsEqual(expected_resources, self.DirContents("out_dir"))
   with open("out_dir/res/values/values.xml", "r") as values_xml:
     self.assertEqual("some values", values_xml.read())
   with open("out_dir/res/layouts/layout.xml", "r") as layout_xml:
     self.assertEqual("some layout", layout_xml.read())
Exemplo n.º 3
0
 def testContainsResources(self):
     aar = zipfile.ZipFile(io.BytesIO(), "w")
     aar.writestr("res/values/values.xml", "some values")
     aar.writestr("res/layouts/layout.xml", "some layout")
     aar.writestr("assets/a", "some asset")
     os.makedirs("out_dir")
     aar_resources_extractor.ExtractResources(aar, "out_dir")
     expected_resources = [
         _HostPath("out_dir/res/values/values.xml"),
         _HostPath("out_dir/res/layouts/layout.xml")
     ]
     self.assertCountEqual(expected_resources, self.DirContents("out_dir"))
     with open("out_dir/res/values/values.xml", "r") as values_xml:
         self.assertEqual("some values", values_xml.read())
     with open("out_dir/res/layouts/layout.xml", "r") as layout_xml:
         self.assertEqual("some layout", layout_xml.read())