summaryrefslogtreecommitdiff
path: root/tools/aapt2/cmd/Compile_test.cpp
diff options
context:
space:
mode:
authorBill Peckham <bpeckham@google.com>2018-09-08 10:06:40 -0700
committerBill Peckham <bpeckham@google.com>2018-09-08 10:06:40 -0700
commita74879d25eb0e4ef53855b57181b038bca75d05f (patch)
tree2a1ef83944343e547bebeae9998b098557225070 /tools/aapt2/cmd/Compile_test.cpp
parentb00720941bf751117cf02da40add144683ab51f1 (diff)
Merge QP1A.180823.001
Change-Id: Ia2d6fa811b3c57185c1975db603d59e6eaef73fc
Diffstat (limited to 'tools/aapt2/cmd/Compile_test.cpp')
-rw-r--r--tools/aapt2/cmd/Compile_test.cpp56
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