Merge "clang-format ManifestFixer_test.cpp"
This commit is contained in:
@@ -350,133 +350,133 @@ TEST_F(ManifestFixerTest, UseDefaultVersionNameAndCode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ManifestFixerTest, DontUseDefaultVersionNameAndCode) {
|
TEST_F(ManifestFixerTest, DontUseDefaultVersionNameAndCode) {
|
||||||
ManifestFixerOptions options;
|
ManifestFixerOptions options;
|
||||||
options.version_name_default = std::string("Beta");
|
options.version_name_default = std::string("Beta");
|
||||||
options.version_code_default = std::string("0x10000000");
|
options.version_code_default = std::string("0x10000000");
|
||||||
|
|
||||||
std::unique_ptr<xml::XmlResource> doc = VerifyWithOptions(R"EOF(
|
std::unique_ptr<xml::XmlResource> doc = VerifyWithOptions(R"EOF(
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="android"
|
package="android"
|
||||||
android:versionCode="0x20000000"
|
android:versionCode="0x20000000"
|
||||||
android:versionName="Alpha" />)EOF",
|
android:versionName="Alpha" />)EOF",
|
||||||
options);
|
options);
|
||||||
ASSERT_THAT(doc, NotNull());
|
ASSERT_THAT(doc, NotNull());
|
||||||
|
|
||||||
xml::Element* manifest_el = doc->root.get();
|
xml::Element* manifest_el = doc->root.get();
|
||||||
ASSERT_THAT(manifest_el, NotNull());
|
ASSERT_THAT(manifest_el, NotNull());
|
||||||
|
|
||||||
xml::Attribute* attr =
|
xml::Attribute* attr =
|
||||||
manifest_el->FindAttribute(xml::kSchemaAndroid, "versionName");
|
manifest_el->FindAttribute(xml::kSchemaAndroid, "versionName");
|
||||||
ASSERT_THAT(attr, NotNull());
|
ASSERT_THAT(attr, NotNull());
|
||||||
EXPECT_THAT(attr->value, StrEq("Alpha"));
|
EXPECT_THAT(attr->value, StrEq("Alpha"));
|
||||||
|
|
||||||
attr = manifest_el->FindAttribute(xml::kSchemaAndroid, "versionCode");
|
attr = manifest_el->FindAttribute(xml::kSchemaAndroid, "versionCode");
|
||||||
ASSERT_THAT(attr, NotNull());
|
ASSERT_THAT(attr, NotNull());
|
||||||
EXPECT_THAT(attr->value, StrEq("0x20000000"));
|
EXPECT_THAT(attr->value, StrEq("0x20000000"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ManifestFixerTest, ReplaceVersionNameAndCode) {
|
TEST_F(ManifestFixerTest, ReplaceVersionNameAndCode) {
|
||||||
ManifestFixerOptions options;
|
ManifestFixerOptions options;
|
||||||
options.replace_version = true;
|
options.replace_version = true;
|
||||||
options.version_name_default = std::string("Beta");
|
options.version_name_default = std::string("Beta");
|
||||||
options.version_code_default = std::string("0x10000000");
|
options.version_code_default = std::string("0x10000000");
|
||||||
|
|
||||||
std::unique_ptr<xml::XmlResource> doc = VerifyWithOptions(R"EOF(
|
std::unique_ptr<xml::XmlResource> doc = VerifyWithOptions(R"EOF(
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="android"
|
package="android"
|
||||||
android:versionCode="0x20000000"
|
android:versionCode="0x20000000"
|
||||||
android:versionName="Alpha" />)EOF",
|
android:versionName="Alpha" />)EOF",
|
||||||
options);
|
options);
|
||||||
ASSERT_THAT(doc, NotNull());
|
ASSERT_THAT(doc, NotNull());
|
||||||
|
|
||||||
xml::Element* manifest_el = doc->root.get();
|
xml::Element* manifest_el = doc->root.get();
|
||||||
ASSERT_THAT(manifest_el, NotNull());
|
ASSERT_THAT(manifest_el, NotNull());
|
||||||
|
|
||||||
xml::Attribute* attr =
|
xml::Attribute* attr =
|
||||||
manifest_el->FindAttribute(xml::kSchemaAndroid, "versionName");
|
manifest_el->FindAttribute(xml::kSchemaAndroid, "versionName");
|
||||||
ASSERT_THAT(attr, NotNull());
|
ASSERT_THAT(attr, NotNull());
|
||||||
EXPECT_THAT(attr->value, StrEq("Beta"));
|
EXPECT_THAT(attr->value, StrEq("Beta"));
|
||||||
|
|
||||||
attr = manifest_el->FindAttribute(xml::kSchemaAndroid, "versionCode");
|
attr = manifest_el->FindAttribute(xml::kSchemaAndroid, "versionCode");
|
||||||
ASSERT_THAT(attr, NotNull());
|
ASSERT_THAT(attr, NotNull());
|
||||||
EXPECT_THAT(attr->value, StrEq("0x10000000"));
|
EXPECT_THAT(attr->value, StrEq("0x10000000"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ManifestFixerTest, ReplaceVersionName) {
|
TEST_F(ManifestFixerTest, ReplaceVersionName) {
|
||||||
ManifestFixerOptions options;
|
ManifestFixerOptions options;
|
||||||
options.replace_version = true;
|
options.replace_version = true;
|
||||||
options.version_name_default = std::string("Beta");
|
options.version_name_default = std::string("Beta");
|
||||||
|
|
||||||
std::unique_ptr<xml::XmlResource> doc = VerifyWithOptions(R"EOF(
|
std::unique_ptr<xml::XmlResource> doc = VerifyWithOptions(R"EOF(
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="android"
|
package="android"
|
||||||
android:versionCode="0x20000000"
|
android:versionCode="0x20000000"
|
||||||
android:versionName="Alpha" />)EOF",
|
android:versionName="Alpha" />)EOF",
|
||||||
options);
|
options);
|
||||||
ASSERT_THAT(doc, NotNull());
|
ASSERT_THAT(doc, NotNull());
|
||||||
|
|
||||||
xml::Element* manifest_el = doc->root.get();
|
xml::Element* manifest_el = doc->root.get();
|
||||||
ASSERT_THAT(manifest_el, NotNull());
|
ASSERT_THAT(manifest_el, NotNull());
|
||||||
|
|
||||||
xml::Attribute* attr =
|
xml::Attribute* attr =
|
||||||
manifest_el->FindAttribute(xml::kSchemaAndroid, "versionName");
|
manifest_el->FindAttribute(xml::kSchemaAndroid, "versionName");
|
||||||
ASSERT_THAT(attr, NotNull());
|
ASSERT_THAT(attr, NotNull());
|
||||||
EXPECT_THAT(attr->value, StrEq("Beta"));
|
EXPECT_THAT(attr->value, StrEq("Beta"));
|
||||||
|
|
||||||
attr = manifest_el->FindAttribute(xml::kSchemaAndroid, "versionCode");
|
attr = manifest_el->FindAttribute(xml::kSchemaAndroid, "versionCode");
|
||||||
ASSERT_THAT(attr, NotNull());
|
ASSERT_THAT(attr, NotNull());
|
||||||
EXPECT_THAT(attr->value, StrEq("0x20000000"));
|
EXPECT_THAT(attr->value, StrEq("0x20000000"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ManifestFixerTest, ReplaceVersionCode) {
|
TEST_F(ManifestFixerTest, ReplaceVersionCode) {
|
||||||
ManifestFixerOptions options;
|
ManifestFixerOptions options;
|
||||||
options.replace_version = true;
|
options.replace_version = true;
|
||||||
options.version_code_default = std::string("0x10000000");
|
options.version_code_default = std::string("0x10000000");
|
||||||
|
|
||||||
std::unique_ptr<xml::XmlResource> doc = VerifyWithOptions(R"EOF(
|
std::unique_ptr<xml::XmlResource> doc = VerifyWithOptions(R"EOF(
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="android"
|
package="android"
|
||||||
android:versionCode="0x20000000"
|
android:versionCode="0x20000000"
|
||||||
android:versionName="Alpha" />)EOF",
|
android:versionName="Alpha" />)EOF",
|
||||||
options);
|
options);
|
||||||
ASSERT_THAT(doc, NotNull());
|
ASSERT_THAT(doc, NotNull());
|
||||||
|
|
||||||
xml::Element* manifest_el = doc->root.get();
|
xml::Element* manifest_el = doc->root.get();
|
||||||
ASSERT_THAT(manifest_el, NotNull());
|
ASSERT_THAT(manifest_el, NotNull());
|
||||||
|
|
||||||
xml::Attribute* attr =
|
xml::Attribute* attr =
|
||||||
manifest_el->FindAttribute(xml::kSchemaAndroid, "versionName");
|
manifest_el->FindAttribute(xml::kSchemaAndroid, "versionName");
|
||||||
ASSERT_THAT(attr, NotNull());
|
ASSERT_THAT(attr, NotNull());
|
||||||
EXPECT_THAT(attr->value, StrEq("Alpha"));
|
EXPECT_THAT(attr->value, StrEq("Alpha"));
|
||||||
|
|
||||||
attr = manifest_el->FindAttribute(xml::kSchemaAndroid, "versionCode");
|
attr = manifest_el->FindAttribute(xml::kSchemaAndroid, "versionCode");
|
||||||
ASSERT_THAT(attr, NotNull());
|
ASSERT_THAT(attr, NotNull());
|
||||||
EXPECT_THAT(attr->value, StrEq("0x10000000"));
|
EXPECT_THAT(attr->value, StrEq("0x10000000"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ManifestFixerTest, DontReplaceVersionNameOrCode) {
|
TEST_F(ManifestFixerTest, DontReplaceVersionNameOrCode) {
|
||||||
ManifestFixerOptions options;
|
ManifestFixerOptions options;
|
||||||
options.replace_version = true;
|
options.replace_version = true;
|
||||||
|
|
||||||
std::unique_ptr<xml::XmlResource> doc = VerifyWithOptions(R"EOF(
|
std::unique_ptr<xml::XmlResource> doc = VerifyWithOptions(R"EOF(
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="android"
|
package="android"
|
||||||
android:versionCode="0x20000000"
|
android:versionCode="0x20000000"
|
||||||
android:versionName="Alpha" />)EOF",
|
android:versionName="Alpha" />)EOF",
|
||||||
options);
|
options);
|
||||||
ASSERT_THAT(doc, NotNull());
|
ASSERT_THAT(doc, NotNull());
|
||||||
|
|
||||||
xml::Element* manifest_el = doc->root.get();
|
xml::Element* manifest_el = doc->root.get();
|
||||||
ASSERT_THAT(manifest_el, NotNull());
|
ASSERT_THAT(manifest_el, NotNull());
|
||||||
|
|
||||||
xml::Attribute* attr =
|
xml::Attribute* attr =
|
||||||
manifest_el->FindAttribute(xml::kSchemaAndroid, "versionName");
|
manifest_el->FindAttribute(xml::kSchemaAndroid, "versionName");
|
||||||
ASSERT_THAT(attr, NotNull());
|
ASSERT_THAT(attr, NotNull());
|
||||||
EXPECT_THAT(attr->value, StrEq("Alpha"));
|
EXPECT_THAT(attr->value, StrEq("Alpha"));
|
||||||
|
|
||||||
attr = manifest_el->FindAttribute(xml::kSchemaAndroid, "versionCode");
|
attr = manifest_el->FindAttribute(xml::kSchemaAndroid, "versionCode");
|
||||||
ASSERT_THAT(attr, NotNull());
|
ASSERT_THAT(attr, NotNull());
|
||||||
EXPECT_THAT(attr->value, StrEq("0x20000000"));
|
EXPECT_THAT(attr->value, StrEq("0x20000000"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ManifestFixerTest, EnsureManifestAttributesAreTyped) {
|
TEST_F(ManifestFixerTest, EnsureManifestAttributesAreTyped) {
|
||||||
@@ -673,7 +673,8 @@ TEST_F(ManifestFixerTest, UnexpectedElementsInManifest) {
|
|||||||
options.warn_validation = true;
|
options.warn_validation = true;
|
||||||
|
|
||||||
// Unexpected element should result in a warning if the flag is set to 'true'.
|
// Unexpected element should result in a warning if the flag is set to 'true'.
|
||||||
std::unique_ptr<xml::XmlResource> manifest = VerifyWithOptions(input, options);
|
std::unique_ptr<xml::XmlResource> manifest =
|
||||||
|
VerifyWithOptions(input, options);
|
||||||
ASSERT_THAT(manifest, NotNull());
|
ASSERT_THAT(manifest, NotNull());
|
||||||
|
|
||||||
// Unexpected element should result in an error if the flag is set to 'false'.
|
// Unexpected element should result in an error if the flag is set to 'false'.
|
||||||
|
|||||||
Reference in New Issue
Block a user