Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 50559d15 authored by Yurii Zubrytskyi's avatar Yurii Zubrytskyi
Browse files

[res] Fix ObfuscatorTest to run in Blaze sandbox

blaze creates a sandbox with readonly current directory, and
all tests have to use the system temp dir - which this one didn't

Bug: n/a
Test: atest aapt2_tests
Change-Id: Ia5a03ad5c8a4ef594f3c379c4502b976f5c08ac4
parent 1c4d0f42
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -300,10 +300,11 @@ TEST(ObfuscatorTest, WriteObfuscationMapInProtocolBufferFormat) {
  ASSERT_TRUE(obfuscator.Consume(test::ContextBuilder().Build().get(),
                                 getProtocolBufferTableUnderTest().get()));

  obfuscator.WriteObfuscationMap("obfuscated_map.pb");
  const auto map_path = testing::TempDir() + "/obfuscated_map.pb";
  ASSERT_TRUE(obfuscator.WriteObfuscationMap(map_path));

  std::string pbOut;
  android::base::ReadFileToString("obfuscated_map.pb", &pbOut, false /* follow_symlinks */);
  ASSERT_TRUE(android::base::ReadFileToString(map_path, &pbOut, false /* follow_symlinks */));
  EXPECT_THAT(pbOut, HasSubstr("drawable/xmlfile.xml"));
  EXPECT_THAT(pbOut, HasSubstr("drawable/pngfile.png"));
  EXPECT_THAT(pbOut, HasSubstr("mycolor"));
@@ -328,10 +329,11 @@ TEST(ObfuscatorTest, WriteObfuscatingMapWithNonEnabledOption) {
  ASSERT_TRUE(obfuscator.Consume(test::ContextBuilder().Build().get(),
                                 getProtocolBufferTableUnderTest().get()));

  obfuscator.WriteObfuscationMap("obfuscated_map.pb");
  const auto map_path = testing::TempDir() + "/obfuscated_map.pb";
  ASSERT_TRUE(obfuscator.WriteObfuscationMap(map_path));

  std::string pbOut;
  android::base::ReadFileToString("obfuscated_map.pb", &pbOut, false /* follow_symlinks */);
  ASSERT_TRUE(android::base::ReadFileToString(map_path, &pbOut, false /* follow_symlinks */));
  ASSERT_THAT(pbOut, Eq(""));
}