Loading tools/aapt2/cmd/Convert_test.cpp +10 −2 Original line number Diff line number Diff line Loading @@ -53,7 +53,11 @@ TEST_F(ConvertTest, RemoveRawXmlStrings) { // Load the binary xml tree android::ResXMLTree tree; std::unique_ptr<LoadedApk> apk = LoadedApk::LoadApkFromPath(out_convert_apk, &diag); AssertLoadXml(apk.get(), "res/xml/test.xml", &tree); std::unique_ptr<io::IData> data = OpenFileAsData(apk.get(), "res/xml/test.xml"); ASSERT_THAT(data, Ne(nullptr)); AssertLoadXml(apk.get(), data.get(), &tree); // Check that the raw string index has not been assigned EXPECT_THAT(tree.getAttributeValueStringID(0), Eq(-1)); Loading Loading @@ -87,7 +91,11 @@ TEST_F(ConvertTest, KeepRawXmlStrings) { // Load the binary xml tree android::ResXMLTree tree; std::unique_ptr<LoadedApk> apk = LoadedApk::LoadApkFromPath(out_convert_apk, &diag); AssertLoadXml(apk.get(), "res/xml/test.xml", &tree); std::unique_ptr<io::IData> data = OpenFileAsData(apk.get(), "res/xml/test.xml"); ASSERT_THAT(data, Ne(nullptr)); AssertLoadXml(apk.get(), data.get(), &tree); // Check that the raw string index has been set to the correct string pool entry int32_t raw_index = tree.getAttributeValueStringID(0); Loading tools/aapt2/cmd/Link_test.cpp +10 −2 Original line number Diff line number Diff line Loading @@ -43,7 +43,11 @@ TEST_F(LinkTest, RemoveRawXmlStrings) { // Load the binary xml tree android::ResXMLTree tree; std::unique_ptr<LoadedApk> apk = LoadedApk::LoadApkFromPath(out_apk, &diag); AssertLoadXml(apk.get(), "res/xml/test.xml", &tree); std::unique_ptr<io::IData> data = OpenFileAsData(apk.get(), "res/xml/test.xml"); ASSERT_THAT(data, Ne(nullptr)); AssertLoadXml(apk.get(), data.get(), &tree); // Check that the raw string index has not been assigned EXPECT_THAT(tree.getAttributeValueStringID(0), Eq(-1)); Loading @@ -67,7 +71,11 @@ TEST_F(LinkTest, KeepRawXmlStrings) { // Load the binary xml tree android::ResXMLTree tree; std::unique_ptr<LoadedApk> apk = LoadedApk::LoadApkFromPath(out_apk, &diag); AssertLoadXml(apk.get(), "res/xml/test.xml", &tree); std::unique_ptr<io::IData> data = OpenFileAsData(apk.get(), "res/xml/test.xml"); ASSERT_THAT(data, Ne(nullptr)); AssertLoadXml(apk.get(), data.get(), &tree); // Check that the raw string index has been set to the correct string pool entry int32_t raw_index = tree.getAttributeValueStringID(0); Loading tools/aapt2/test/Fixture.cpp +9 −7 Original line number Diff line number Diff line Loading @@ -133,16 +133,18 @@ std::string CommandTestFixture::GetDefaultManifest() { return manifest_file; } void CommandTestFixture::AssertLoadXml(LoadedApk *apk, const android::StringPiece &xml_path, std::unique_ptr<io::IData> CommandTestFixture::OpenFileAsData(LoadedApk* apk, const android::StringPiece& path) { return apk ->GetFileCollection() ->FindFile(path) ->OpenAsData(); } void CommandTestFixture::AssertLoadXml(LoadedApk* apk, const io::IData* data, android::ResXMLTree *out_tree) { ASSERT_THAT(apk, Ne(nullptr)); io::IFile* file = apk->GetFileCollection()->FindFile(xml_path); ASSERT_THAT(file, Ne(nullptr)); std::unique_ptr<io::IData> data = file->OpenAsData(); ASSERT_THAT(data, Ne(nullptr)); out_tree->setTo(data->data(), data->size()); ASSERT_THAT(out_tree->getError(), Eq(android::OK)); while (out_tree->next() != android::ResXMLTree::START_TAG) { Loading tools/aapt2/test/Fixture.h +5 −1 Original line number Diff line number Diff line Loading @@ -83,8 +83,12 @@ class CommandTestFixture : public TestDirectoryFixture { // Creates a minimal android manifest within the test directory and returns the file path. std::string GetDefaultManifest(); // Returns pointer to data inside APK files std::unique_ptr<io::IData> OpenFileAsData(LoadedApk* apk, const android::StringPiece& path); // Asserts that loading the tree from the specified file in the apk succeeds. void AssertLoadXml(LoadedApk* apk, const android::StringPiece& xml_path, void AssertLoadXml(LoadedApk* apk, const io::IData* data, android::ResXMLTree* out_tree); private: Loading Loading
tools/aapt2/cmd/Convert_test.cpp +10 −2 Original line number Diff line number Diff line Loading @@ -53,7 +53,11 @@ TEST_F(ConvertTest, RemoveRawXmlStrings) { // Load the binary xml tree android::ResXMLTree tree; std::unique_ptr<LoadedApk> apk = LoadedApk::LoadApkFromPath(out_convert_apk, &diag); AssertLoadXml(apk.get(), "res/xml/test.xml", &tree); std::unique_ptr<io::IData> data = OpenFileAsData(apk.get(), "res/xml/test.xml"); ASSERT_THAT(data, Ne(nullptr)); AssertLoadXml(apk.get(), data.get(), &tree); // Check that the raw string index has not been assigned EXPECT_THAT(tree.getAttributeValueStringID(0), Eq(-1)); Loading Loading @@ -87,7 +91,11 @@ TEST_F(ConvertTest, KeepRawXmlStrings) { // Load the binary xml tree android::ResXMLTree tree; std::unique_ptr<LoadedApk> apk = LoadedApk::LoadApkFromPath(out_convert_apk, &diag); AssertLoadXml(apk.get(), "res/xml/test.xml", &tree); std::unique_ptr<io::IData> data = OpenFileAsData(apk.get(), "res/xml/test.xml"); ASSERT_THAT(data, Ne(nullptr)); AssertLoadXml(apk.get(), data.get(), &tree); // Check that the raw string index has been set to the correct string pool entry int32_t raw_index = tree.getAttributeValueStringID(0); Loading
tools/aapt2/cmd/Link_test.cpp +10 −2 Original line number Diff line number Diff line Loading @@ -43,7 +43,11 @@ TEST_F(LinkTest, RemoveRawXmlStrings) { // Load the binary xml tree android::ResXMLTree tree; std::unique_ptr<LoadedApk> apk = LoadedApk::LoadApkFromPath(out_apk, &diag); AssertLoadXml(apk.get(), "res/xml/test.xml", &tree); std::unique_ptr<io::IData> data = OpenFileAsData(apk.get(), "res/xml/test.xml"); ASSERT_THAT(data, Ne(nullptr)); AssertLoadXml(apk.get(), data.get(), &tree); // Check that the raw string index has not been assigned EXPECT_THAT(tree.getAttributeValueStringID(0), Eq(-1)); Loading @@ -67,7 +71,11 @@ TEST_F(LinkTest, KeepRawXmlStrings) { // Load the binary xml tree android::ResXMLTree tree; std::unique_ptr<LoadedApk> apk = LoadedApk::LoadApkFromPath(out_apk, &diag); AssertLoadXml(apk.get(), "res/xml/test.xml", &tree); std::unique_ptr<io::IData> data = OpenFileAsData(apk.get(), "res/xml/test.xml"); ASSERT_THAT(data, Ne(nullptr)); AssertLoadXml(apk.get(), data.get(), &tree); // Check that the raw string index has been set to the correct string pool entry int32_t raw_index = tree.getAttributeValueStringID(0); Loading
tools/aapt2/test/Fixture.cpp +9 −7 Original line number Diff line number Diff line Loading @@ -133,16 +133,18 @@ std::string CommandTestFixture::GetDefaultManifest() { return manifest_file; } void CommandTestFixture::AssertLoadXml(LoadedApk *apk, const android::StringPiece &xml_path, std::unique_ptr<io::IData> CommandTestFixture::OpenFileAsData(LoadedApk* apk, const android::StringPiece& path) { return apk ->GetFileCollection() ->FindFile(path) ->OpenAsData(); } void CommandTestFixture::AssertLoadXml(LoadedApk* apk, const io::IData* data, android::ResXMLTree *out_tree) { ASSERT_THAT(apk, Ne(nullptr)); io::IFile* file = apk->GetFileCollection()->FindFile(xml_path); ASSERT_THAT(file, Ne(nullptr)); std::unique_ptr<io::IData> data = file->OpenAsData(); ASSERT_THAT(data, Ne(nullptr)); out_tree->setTo(data->data(), data->size()); ASSERT_THAT(out_tree->getError(), Eq(android::OK)); while (out_tree->next() != android::ResXMLTree::START_TAG) { Loading
tools/aapt2/test/Fixture.h +5 −1 Original line number Diff line number Diff line Loading @@ -83,8 +83,12 @@ class CommandTestFixture : public TestDirectoryFixture { // Creates a minimal android manifest within the test directory and returns the file path. std::string GetDefaultManifest(); // Returns pointer to data inside APK files std::unique_ptr<io::IData> OpenFileAsData(LoadedApk* apk, const android::StringPiece& path); // Asserts that loading the tree from the specified file in the apk succeeds. void AssertLoadXml(LoadedApk* apk, const android::StringPiece& xml_path, void AssertLoadXml(LoadedApk* apk, const io::IData* data, android::ResXMLTree* out_tree); private: Loading