AAPT2: Add support for parsing codeNames with fingerprints.
In addition to supporting manifest declared codenames of the form
"[codename]", also support codenames of the form "[codename].[fingerprint]".
Matches the behaviour of PackageParser as of ag/6056697.
Test: ResourceUtils_test
Change-Id: I814330eba9d383e4549e35da791fcfa9bd0cdf57
diff --git a/tools/aapt2/ResourceUtils_test.cpp b/tools/aapt2/ResourceUtils_test.cpp
index 5ce4640..9018b0f 100644
--- a/tools/aapt2/ResourceUtils_test.cpp
+++ b/tools/aapt2/ResourceUtils_test.cpp
@@ -16,6 +16,7 @@
#include "ResourceUtils.h"
+#include "SdkConstants.h"
#include "Resource.h"
#include "test/Test.h"
@@ -212,6 +213,17 @@
Pointee(ValueEq(BinaryPrimitive(Res_value::TYPE_FLOAT, expected_float_flattened))));
}
+TEST(ResourceUtilsTest, ParseSdkVersionWithCodename) {
+ const android::StringPiece codename =
+ GetDevelopmentSdkCodeNameAndVersion().first;
+ const int version = GetDevelopmentSdkCodeNameAndVersion().second;
+
+ EXPECT_THAT(ResourceUtils::ParseSdkVersion(codename), Eq(Maybe<int>(version)));
+ EXPECT_THAT(
+ ResourceUtils::ParseSdkVersion(codename.to_string() + ".fingerprint"),
+ Eq(Maybe<int>(version)));
+}
+
TEST(ResourceUtilsTest, StringBuilderWhitespaceRemoval) {
EXPECT_THAT(ResourceUtils::StringBuilder()
.AppendText(" hey guys ")