diff options
author | Winson <chiuwinson@google.com> | 2019-01-23 11:10:52 -0800 |
---|---|---|
committer | Winson <chiuwinson@google.com> | 2019-01-23 11:11:12 -0800 |
commit | b7be7934b05c810978466c151e17c4e199e7272b (patch) | |
tree | c3c36329b3b26ce09b45c95a36195663340cf796 /tools/aapt2/cmd/Link_test.cpp | |
parent | 3b943e777e57c6f3c7351c23daea2f12ac8ea928 (diff) |
Hold data pointer reference to AAPT2 test file
To try and solve test flakiness, hold the unique_ptr in the method scope to make sure it's cleaned up after we assert on it.
Bug: 123079798
Test: gonna merge and check for failures, since it passes locally
Change-Id: Id348d1112832cbb82f605a84ef675c25a7488b11
Diffstat (limited to 'tools/aapt2/cmd/Link_test.cpp')
-rw-r--r-- | tools/aapt2/cmd/Link_test.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tools/aapt2/cmd/Link_test.cpp b/tools/aapt2/cmd/Link_test.cpp index 3c8b72d3cb2c..9ea93f638aff 100644 --- a/tools/aapt2/cmd/Link_test.cpp +++ b/tools/aapt2/cmd/Link_test.cpp @@ -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)); @@ -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); |