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

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

Issue 580513002: Add support for gcm_sender_id in Manifest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@manifest_start_url
Patch Set: add gcm_sender_id to ipc traits Created 6 years, 3 months 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 0e500aec9e2c2bce3f123bbd36cd2b8d1ecc2f07..4ab92863772309182ab87f56dc799945b9c07df3 100644
--- a/content/renderer/manifest/manifest_parser_unittest.cc
+++ b/content/renderer/manifest/manifest_parser_unittest.cc
@@ -7,6 +7,7 @@
#include "base/strings/string_util.h"
#include "content/public/common/manifest.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
namespace content {
@@ -160,4 +161,45 @@ TEST_F(ManifestParserTest, StartURLParseRules) {
}
}
+TEST_F(ManifestParserTest, GCMSenderIDParseRules) {
+ bool push_messaging_enabled =
+ blink::WebRuntimeFeatures::isPushMessagingEnabled();
+
+ blink::WebRuntimeFeatures::enablePushMessaging(true);
+
+ // Smoke test.
+ {
+ Manifest manifest = ParseManifest("{ \"gcm_sender_id\": \"foo\" }");
+ ASSERT_TRUE(EqualsASCII(manifest.gcm_sender_id.string(), "foo"));
+ }
+
+ // Trim whitespaces.
+ {
+ Manifest manifest = ParseManifest("{ \"gcm_sender_id\": \" foo \" }");
+ ASSERT_TRUE(EqualsASCII(manifest.gcm_sender_id.string(), "foo"));
+ }
+
+ // Don't parse if name isn't a string.
+ {
+ Manifest manifest = ParseManifest("{ \"gcm_sender_id\": {} }");
+ ASSERT_TRUE(manifest.gcm_sender_id.is_null());
+ }
+
+ // Don't parse if name isn't a string.
+ {
+ Manifest manifest = ParseManifest("{ \"gcm_sender_id\": 42 }");
+ ASSERT_TRUE(manifest.gcm_sender_id.is_null());
+ }
+
+ blink::WebRuntimeFeatures::enablePushMessaging(false);
+
+ // Check that we don't parse it if PushMessaging isn't enabled.
+ {
+ Manifest manifest = ParseManifest("{ \"gcm_sender_id\": \"foo\" }");
+ ASSERT_TRUE(manifest.gcm_sender_id.is_null());
+ }
+
+ blink::WebRuntimeFeatures::enablePushMessaging(push_messaging_enabled);
+}
+
} // namespace content
« content/renderer/manifest/manifest_parser.cc ('K') | « content/renderer/manifest/manifest_parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698