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

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: 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
« no previous file with comments | « content/renderer/manifest/manifest_parser.cc ('k') | content/renderer/push_messaging_dispatcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..fd47fe211c833a30b53f0328828b30d9d44e1af7 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_FALSE(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_FALSE(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,50 @@ 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]);
+ }
+ {
+ Manifest manifest = ParseManifest("{ \"gcm_user_visible_only\": 1 }");
+ 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]);
+ }
+
+ // "False" should set the boolean false without throwing errors.
+ {
+ Manifest manifest = ParseManifest("{ \"gcm_user_visible_only\": false }");
+ EXPECT_FALSE(manifest.gcm_user_visible_only);
+ EXPECT_EQ(0u, GetErrorCount());
+ }
+}
+
} // namespace content
« no previous file with comments | « content/renderer/manifest/manifest_parser.cc ('k') | content/renderer/push_messaging_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698