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 362177eb0511119d4c3efd1fc8ea92dcce9f4254..28d1c7a44cb73e46deadca726b741c13ecbc7431 100644 |
--- a/content/renderer/manifest/manifest_parser_unittest.cc |
+++ b/content/renderer/manifest/manifest_parser_unittest.cc |
@@ -6,13 +6,19 @@ |
#include "base/strings/string_util.h" |
#include "content/public/common/manifest.h" |
+#include "content/public/renderer/content_renderer_client.h" |
+#include "content/test/test_content_client.h" |
#include "testing/gtest/include/gtest/gtest.h" |
namespace content { |
class ManifestParserTest : public testing::Test { |
protected: |
- ManifestParserTest() {} |
+ ManifestParserTest() { |
+ SetContentClient(&test_content_client_); |
+ SetRendererClientForTesting(&test_content_renderer_client_); |
+ } |
+ |
~ManifestParserTest() override {} |
Manifest ParseManifestWithURLs(const base::StringPiece& data, |
@@ -43,6 +49,9 @@ class ManifestParserTest : public testing::Test { |
private: |
std::vector<std::string> errors_; |
+ TestContentClient test_content_client_; |
+ ContentRendererClient test_content_renderer_client_; |
+ |
DISALLOW_COPY_AND_ASSIGN(ManifestParserTest); |
}; |
@@ -78,8 +87,6 @@ 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) { |
@@ -95,16 +102,14 @@ 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\": {}, \"gcm_user_visible_only\": 42 }"); |
+ "\"icons\": {} }"); |
- EXPECT_EQ(7u, GetErrorCount()); |
+ EXPECT_EQ(6u, GetErrorCount()); |
EXPECT_EQ("Manifest parsing error: property 'name' ignored," |
" type string expected.", |
@@ -123,9 +128,6 @@ 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) { |
@@ -797,84 +799,4 @@ TEST_F(ManifestParserTest, IconSizesParseRules) { |
} |
} |
-TEST_F(ManifestParserTest, GCMSenderIDParseRules) { |
- // Smoke test. |
- { |
- Manifest manifest = ParseManifest("{ \"gcm_sender_id\": \"foo\" }"); |
- EXPECT_TRUE(EqualsASCII(manifest.gcm_sender_id.string(), "foo")); |
- EXPECT_EQ(0u, GetErrorCount()); |
- } |
- |
- // Trim whitespaces. |
- { |
- Manifest manifest = ParseManifest("{ \"gcm_sender_id\": \" foo \" }"); |
- EXPECT_TRUE(EqualsASCII(manifest.gcm_sender_id.string(), "foo")); |
- EXPECT_EQ(0u, GetErrorCount()); |
- } |
- |
- // Don't parse if the property isn't a string. |
- { |
- Manifest manifest = ParseManifest("{ \"gcm_sender_id\": {} }"); |
- EXPECT_TRUE(manifest.gcm_sender_id.is_null()); |
- EXPECT_EQ(1u, GetErrorCount()); |
- EXPECT_EQ("Manifest parsing error: property 'gcm_sender_id' ignored," |
- " type string expected.", |
- errors()[0]); |
- } |
- { |
- Manifest manifest = ParseManifest("{ \"gcm_sender_id\": 42 }"); |
- EXPECT_TRUE(manifest.gcm_sender_id.is_null()); |
- EXPECT_EQ(1u, GetErrorCount()); |
- EXPECT_EQ("Manifest parsing error: property 'gcm_sender_id' ignored," |
- " type string expected.", |
- errors()[0]); |
- } |
-} |
- |
-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 |