Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1411)

Unified Diff: content/renderer/manifest/manifest_parser_unittest.cc

Issue 770023002: Push registration should read a "gcm_user_visible_only" key from the Manifest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment fix Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/manifest/manifest_parser_unittest.cc
diff --git a/content/renderer/manifest/manifest_parser_unittest.cc b/content/renderer/manifest/manifest_parser_unittest.cc
index 4419ac5de2c243a9c5004c4a0f17b79373b88689..441bbf83113eba49c8d4ab306692dafb08b58241 100644
--- a/content/renderer/manifest/manifest_parser_unittest.cc
+++ b/content/renderer/manifest/manifest_parser_unittest.cc
@@ -66,6 +66,8 @@ TEST_F(ManifestParserTest, EmptyStringNull) {
ASSERT_TRUE(manifest.start_url.is_empty());
ASSERT_EQ(manifest.display, Manifest::DISPLAY_MODE_UNSPECIFIED);
ASSERT_EQ(manifest.orientation, blink::WebScreenOrientationLockDefault);
+ ASSERT_TRUE(manifest.gcm_sender_id.is_null());
+ ASSERT_TRUE(manifest.gcm_user_visible_only);
}
TEST_F(ManifestParserTest, ValidNoContentParses) {
@@ -81,14 +83,16 @@ TEST_F(ManifestParserTest, ValidNoContentParses) {
ASSERT_TRUE(manifest.start_url.is_empty());
ASSERT_EQ(manifest.display, Manifest::DISPLAY_MODE_UNSPECIFIED);
ASSERT_EQ(manifest.orientation, blink::WebScreenOrientationLockDefault);
+ ASSERT_TRUE(manifest.gcm_sender_id.is_null());
+ ASSERT_TRUE(manifest.gcm_user_visible_only);
}
TEST_F(ManifestParserTest, MultipleErrorsReporting) {
Manifest manifest = ParseManifest("{ \"name\": 42, \"short_name\": 4,"
"\"orientation\": {}, \"display\": \"foo\", \"start_url\": null,"
- "\"icons\": {} }");
+ "\"icons\": {}, \"gcm_user_visible_only\": 42 }");
- EXPECT_EQ(6u, GetErrorCount());
+ EXPECT_EQ(7u, GetErrorCount());
EXPECT_EQ("Manifest parsing error: property 'name' ignored,"
" type string expected.",
@@ -107,6 +111,9 @@ TEST_F(ManifestParserTest, MultipleErrorsReporting) {
EXPECT_EQ("Manifest parsing error: property 'icons' ignored, "
"type array expected.",
errors()[5]);
+ EXPECT_EQ("Manifest parsing error: property 'gcm_user_visible_only' ignored, "
+ "type boolean expected.",
+ errors()[6]);
}
TEST_F(ManifestParserTest, NameParseRules) {
@@ -793,7 +800,7 @@ TEST_F(ManifestParserTest, GCMSenderIDParseRules) {
EXPECT_EQ(0u, GetErrorCount());
}
- // Don't parse if property isn't a string.
+ // Don't parse if the property isn't a string.
{
Manifest manifest = ParseManifest("{ \"gcm_sender_id\": {} }");
EXPECT_TRUE(manifest.gcm_sender_id.is_null());
@@ -812,4 +819,34 @@ TEST_F(ManifestParserTest, GCMSenderIDParseRules) {
}
}
+TEST_F(ManifestParserTest, GCMUserVisibleOnlyParseRules) {
+ // Smoke test.
+ {
+ Manifest manifest = ParseManifest("{ \"gcm_user_visible_only\": true }");
+ EXPECT_TRUE(manifest.gcm_user_visible_only);
+ EXPECT_EQ(0u, GetErrorCount());
+ }
+
+ // Don't parse if the property isn't a boolean.
+ {
+ Manifest manifest = ParseManifest("{ \"gcm_user_visible_only\": {} }");
+ EXPECT_FALSE(manifest.gcm_user_visible_only);
+ EXPECT_EQ(1u, GetErrorCount());
+ EXPECT_EQ(
+ "Manifest parsing error: property 'gcm_user_visible_only' ignored,"
+ " type boolean expected.",
+ errors()[0]);
+ }
+ {
+ Manifest manifest = ParseManifest(
+ "{ \"gcm_user_visible_only\": \"true\" }");
+ EXPECT_FALSE(manifest.gcm_user_visible_only);
+ EXPECT_EQ(1u, GetErrorCount());
+ EXPECT_EQ(
+ "Manifest parsing error: property 'gcm_user_visible_only' ignored,"
+ " type boolean expected.",
+ errors()[0]);
+ }
mlamouri (slow - plz ping) 2014/12/01 21:05:09 Could you check that false is correctly parsed wit
Peter Beverloo 2014/12/03 15:01:59 Done.
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698