AAPT2: Separate out the various steps
An early refactor. Some ideas became clearer as
development continued. Now the various phases are much
clearer and more easily reusable.
Also added a ton of tests!
Change-Id: Ic8f0a70c8222370352e63533b329c40457c0903e
diff --git a/tools/aapt2/XmlDom_test.cpp b/tools/aapt2/XmlDom_test.cpp
index 0217144..a1b9ed0 100644
--- a/tools/aapt2/XmlDom_test.cpp
+++ b/tools/aapt2/XmlDom_test.cpp
@@ -36,12 +36,13 @@
</Layout>
)EOF";
- SourceLogger logger(Source{ "/test/path" });
- std::unique_ptr<xml::Node> root = xml::inflate(&in, &logger);
- ASSERT_NE(root, nullptr);
+ const Source source = { "test.xml" };
+ StdErrDiagnostics diag;
+ std::unique_ptr<XmlResource> doc = xml::inflate(&in, &diag, source);
+ ASSERT_NE(doc, nullptr);
- EXPECT_EQ(root->type, xml::NodeType::kNamespace);
- xml::Namespace* ns = static_cast<xml::Namespace*>(root.get());
+ xml::Namespace* ns = xml::nodeCast<xml::Namespace>(doc->root.get());
+ ASSERT_NE(ns, nullptr);
EXPECT_EQ(ns->namespaceUri, u"http://schemas.android.com/apk/res/android");
EXPECT_EQ(ns->namespacePrefix, u"android");
}