diff options
author | Ryan Mitchell <rtmitchell@google.com> | 2018-08-16 17:26:08 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-08-16 17:26:08 +0000 |
commit | ead275e19fc9ffbd751b3956a84e27844b97ffe7 (patch) | |
tree | f19915c04e52949cb29908ef1e0f6588ad98d766 /tools/aapt2/cmd/Compile_test.cpp | |
parent | a60283fdd1f2c67259e8b0c10d88ecfb60a1328b (diff) | |
parent | f3649d669059b924ce9eb3eb7909cbf0a2ed31a8 (diff) |
Merge "AAPT2: Compile --zip flag"
Diffstat (limited to 'tools/aapt2/cmd/Compile_test.cpp')
-rw-r--r-- | tools/aapt2/cmd/Compile_test.cpp | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/tools/aapt2/cmd/Compile_test.cpp b/tools/aapt2/cmd/Compile_test.cpp index d21addf4a081..dd5198ce86da 100644 --- a/tools/aapt2/cmd/Compile_test.cpp +++ b/tools/aapt2/cmd/Compile_test.cpp @@ -18,6 +18,7 @@ #include "android-base/file.h" #include "io/StringStream.h" +#include "io/ZipArchive.h" #include "java/AnnotationProcessor.h" #include "test/Test.h" @@ -29,7 +30,6 @@ int TestCompile(const std::string& path, const std::string& outDir, bool legacy, args.push_back(path); args.push_back("-o"); args.push_back(outDir); - args.push_back("-v"); if (legacy) { args.push_back("--legacy"); } @@ -94,4 +94,56 @@ TEST(CompilerTest, MultiplePeriods) { ASSERT_EQ(remove(path5_out.c_str()), 0); } -}
\ No newline at end of file +TEST(CompilerTest, DirInput) { + StdErrDiagnostics diag; + std::unique_ptr<IAaptContext> context = test::ContextBuilder().Build(); + const std::string kResDir = android::base::Dirname(android::base::GetExecutablePath()) + + "/integration-tests/CompileTest/DirInput/res"; + const std::string kOutputFlata = android::base::Dirname(android::base::GetExecutablePath()) + + "/integration-tests/CompileTest/DirInput/compiled.flata"; + remove(kOutputFlata.c_str()); + + std::vector<android::StringPiece> args; + args.push_back("--dir"); + args.push_back(kResDir); + args.push_back("-o"); + args.push_back(kOutputFlata); + ASSERT_EQ(CompileCommand(&diag).Execute(args, &std::cerr), 0); + + // Check for the presence of the compiled files + std::string err; + std::unique_ptr<io::ZipFileCollection> zip = io::ZipFileCollection::Create(kOutputFlata, &err); + ASSERT_NE(zip, nullptr) << err; + ASSERT_NE(zip->FindFile("drawable_image.png.flat"), nullptr); + ASSERT_NE(zip->FindFile("layout_layout.xml.flat"), nullptr); + ASSERT_NE(zip->FindFile("values_values.arsc.flat"), nullptr); + ASSERT_EQ(remove(kOutputFlata.c_str()), 0); +} + +TEST(CompilerTest, ZipInput) { + StdErrDiagnostics diag; + std::unique_ptr<IAaptContext> context = test::ContextBuilder().Build(); + const std::string kResZip = android::base::Dirname(android::base::GetExecutablePath()) + + "/integration-tests/CompileTest/ZipInput/res.zip"; + const std::string kOutputFlata = android::base::Dirname(android::base::GetExecutablePath()) + + "/integration-tests/CompileTest/ZipInput/compiled.flata"; + remove(kOutputFlata.c_str()); + + std::vector<android::StringPiece> args; + args.push_back("--zip"); + args.push_back(kResZip); + args.push_back("-o"); + args.push_back(kOutputFlata); + ASSERT_EQ(CompileCommand(&diag).Execute(args, &std::cerr), 0); + + // Check for the presence of the compiled files + std::string err; + std::unique_ptr<io::ZipFileCollection> zip = io::ZipFileCollection::Create(kOutputFlata, &err); + ASSERT_NE(zip, nullptr) << err; + ASSERT_NE(zip->FindFile("drawable_image.png.flat"), nullptr); + ASSERT_NE(zip->FindFile("layout_layout.xml.flat"), nullptr); + ASSERT_NE(zip->FindFile("values_values.arsc.flat"), nullptr); + ASSERT_EQ(remove(kOutputFlata.c_str()), 0); +} + +} // namespace aapt
\ No newline at end of file |