summaryrefslogtreecommitdiff
path: root/libs/androidfw/tests/AttributeResolution_test.cpp
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2016-11-10 16:43:59 -0800
committerAdam Lesinski <adamlesinski@google.com>2016-12-05 19:03:47 -0800
commit4c67a475a334e4f65238d439a3339195e03c03be (patch)
treea853680b90b834cb0a81be09f77be8d0ca8a06da /libs/androidfw/tests/AttributeResolution_test.cpp
parent7dbbf956f73012ad0ea50bba37a21555cccfc726 (diff)
Make tests use APKs instead of exploded APKs
Tests would expect parts of the APK to be unzipped and maintained. Instead, we now decompress the required files from the test APKs on test setup. This simplifies test maintenance substantially. Test: make libandroidfw_tests && libandroidfw_tests --testdata=frameworks/base/libs/androidfw/tests/data Change-Id: I3d2100af22df913e02401dedcf9842cdb32b2a3b
Diffstat (limited to 'libs/androidfw/tests/AttributeResolution_test.cpp')
-rw-r--r--libs/androidfw/tests/AttributeResolution_test.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/libs/androidfw/tests/AttributeResolution_test.cpp b/libs/androidfw/tests/AttributeResolution_test.cpp
index 3aac17838e2a..d417aba1c595 100644
--- a/libs/androidfw/tests/AttributeResolution_test.cpp
+++ b/libs/androidfw/tests/AttributeResolution_test.cpp
@@ -30,12 +30,11 @@ namespace android {
class AttributeResolutionTest : public ::testing::Test {
public:
virtual void SetUp() override {
- std::string test_source_dir = GetTestDataPath();
std::string contents;
- CHECK(base::ReadFileToString(test_source_dir + "/styles/resources.arsc",
- &contents));
- CHECK(table_.add(contents.data(), contents.size(), 1 /*cookie*/,
- true /*copyData*/) == NO_ERROR);
+ ASSERT_TRUE(ReadFileFromZipToString(
+ GetTestDataPath() + "/styles/styles.apk", "resources.arsc", &contents));
+ ASSERT_EQ(NO_ERROR, table_.add(contents.data(), contents.size(),
+ 1 /*cookie*/, true /*copyData*/));
}
protected:
@@ -46,12 +45,14 @@ class AttributeResolutionXmlTest : public AttributeResolutionTest {
public:
virtual void SetUp() override {
AttributeResolutionTest::SetUp();
- std::string test_source_dir = GetTestDataPath();
+
std::string contents;
- CHECK(base::ReadFileToString(test_source_dir + "/styles/layout.xml",
- &contents));
- CHECK(xml_parser_.setTo(contents.data(), contents.size(),
- true /*copyData*/) == NO_ERROR);
+ ASSERT_TRUE(
+ ReadFileFromZipToString(GetTestDataPath() + "/styles/styles.apk",
+ "res/layout/layout.xml", &contents));
+
+ ASSERT_EQ(NO_ERROR, xml_parser_.setTo(contents.data(), contents.size(),
+ true /*copyData*/));
// Skip to the first tag.
while (xml_parser_.next() != ResXMLParser::START_TAG) {