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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/manifest/manifest_parser.h" 5 #include "content/renderer/manifest/manifest_parser.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "content/public/common/manifest.h" 8 #include "content/public/common/manifest.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
10 11
11 namespace content { 12 namespace content {
12 13
13 class ManifestParserTest : public testing::Test { 14 class ManifestParserTest : public testing::Test {
14 protected: 15 protected:
15 ManifestParserTest() {} 16 ManifestParserTest() {}
16 virtual ~ManifestParserTest() {} 17 virtual ~ManifestParserTest() {}
17 18
18 Manifest ParseManifest(const base::StringPiece& json, 19 Manifest ParseManifest(const base::StringPiece& json,
19 const GURL& document_url = default_document_url, 20 const GURL& document_url = default_document_url,
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // Resolving has to happen based on the manifest_url. 154 // Resolving has to happen based on the manifest_url.
154 { 155 {
155 Manifest manifest = 156 Manifest manifest =
156 ParseManifest("{ \"start_url\": \"land.html\" }", 157 ParseManifest("{ \"start_url\": \"land.html\" }",
157 GURL("http://foo.com/landing/manifest.json"), 158 GURL("http://foo.com/landing/manifest.json"),
158 GURL("http://foo.com/index.html")); 159 GURL("http://foo.com/index.html"));
159 ASSERT_EQ(manifest.start_url.spec(), "http://foo.com/landing/land.html"); 160 ASSERT_EQ(manifest.start_url.spec(), "http://foo.com/landing/land.html");
160 } 161 }
161 } 162 }
162 163
164 TEST_F(ManifestParserTest, GCMSenderIDParseRules) {
165 bool push_messaging_enabled =
166 blink::WebRuntimeFeatures::isPushMessagingEnabled();
167
168 blink::WebRuntimeFeatures::enablePushMessaging(true);
169
170 // Smoke test.
171 {
172 Manifest manifest = ParseManifest("{ \"gcm_sender_id\": \"foo\" }");
173 ASSERT_TRUE(EqualsASCII(manifest.gcm_sender_id.string(), "foo"));
174 }
175
176 // Trim whitespaces.
177 {
178 Manifest manifest = ParseManifest("{ \"gcm_sender_id\": \" foo \" }");
179 ASSERT_TRUE(EqualsASCII(manifest.gcm_sender_id.string(), "foo"));
180 }
181
182 // Don't parse if name isn't a string.
183 {
184 Manifest manifest = ParseManifest("{ \"gcm_sender_id\": {} }");
185 ASSERT_TRUE(manifest.gcm_sender_id.is_null());
186 }
187
188 // Don't parse if name isn't a string.
189 {
190 Manifest manifest = ParseManifest("{ \"gcm_sender_id\": 42 }");
191 ASSERT_TRUE(manifest.gcm_sender_id.is_null());
192 }
193
194 blink::WebRuntimeFeatures::enablePushMessaging(false);
195
196 // Check that we don't parse it if PushMessaging isn't enabled.
197 {
198 Manifest manifest = ParseManifest("{ \"gcm_sender_id\": \"foo\" }");
199 ASSERT_TRUE(manifest.gcm_sender_id.is_null());
200 }
201
202 blink::WebRuntimeFeatures::enablePushMessaging(push_messaging_enabled);
203 }
204
163 } // namespace content 205 } // namespace content
OLDNEW
« 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