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

Side by Side Diff: content/renderer/manifest/manifest_parser_unittest.cc

Issue 1158923002: Remove support for the "gcm_user_visible_only" manifest key. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a message Created 5 years, 6 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 10
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 errors()[0]); 72 errors()[0]);
73 73
74 // A parsing error is equivalent to an empty manifest. 74 // A parsing error is equivalent to an empty manifest.
75 ASSERT_TRUE(manifest.IsEmpty()); 75 ASSERT_TRUE(manifest.IsEmpty());
76 ASSERT_TRUE(manifest.name.is_null()); 76 ASSERT_TRUE(manifest.name.is_null());
77 ASSERT_TRUE(manifest.short_name.is_null()); 77 ASSERT_TRUE(manifest.short_name.is_null());
78 ASSERT_TRUE(manifest.start_url.is_empty()); 78 ASSERT_TRUE(manifest.start_url.is_empty());
79 ASSERT_EQ(manifest.display, Manifest::DISPLAY_MODE_UNSPECIFIED); 79 ASSERT_EQ(manifest.display, Manifest::DISPLAY_MODE_UNSPECIFIED);
80 ASSERT_EQ(manifest.orientation, blink::WebScreenOrientationLockDefault); 80 ASSERT_EQ(manifest.orientation, blink::WebScreenOrientationLockDefault);
81 ASSERT_TRUE(manifest.gcm_sender_id.is_null()); 81 ASSERT_TRUE(manifest.gcm_sender_id.is_null());
82 ASSERT_FALSE(manifest.gcm_user_visible_only);
83 } 82 }
84 83
85 TEST_F(ManifestParserTest, ValidNoContentParses) { 84 TEST_F(ManifestParserTest, ValidNoContentParses) {
86 Manifest manifest = ParseManifest("{}"); 85 Manifest manifest = ParseManifest("{}");
87 86
88 // Empty Manifest is not a parsing error. 87 // Empty Manifest is not a parsing error.
89 EXPECT_EQ(0u, GetErrorCount()); 88 EXPECT_EQ(0u, GetErrorCount());
90 89
91 // Check that all the fields are null in that case. 90 // Check that all the fields are null in that case.
92 ASSERT_TRUE(manifest.IsEmpty()); 91 ASSERT_TRUE(manifest.IsEmpty());
93 ASSERT_TRUE(manifest.name.is_null()); 92 ASSERT_TRUE(manifest.name.is_null());
94 ASSERT_TRUE(manifest.short_name.is_null()); 93 ASSERT_TRUE(manifest.short_name.is_null());
95 ASSERT_TRUE(manifest.start_url.is_empty()); 94 ASSERT_TRUE(manifest.start_url.is_empty());
96 ASSERT_EQ(manifest.display, Manifest::DISPLAY_MODE_UNSPECIFIED); 95 ASSERT_EQ(manifest.display, Manifest::DISPLAY_MODE_UNSPECIFIED);
97 ASSERT_EQ(manifest.orientation, blink::WebScreenOrientationLockDefault); 96 ASSERT_EQ(manifest.orientation, blink::WebScreenOrientationLockDefault);
98 ASSERT_TRUE(manifest.gcm_sender_id.is_null()); 97 ASSERT_TRUE(manifest.gcm_sender_id.is_null());
99 ASSERT_FALSE(manifest.gcm_user_visible_only);
100 } 98 }
101 99
102 TEST_F(ManifestParserTest, MultipleErrorsReporting) { 100 TEST_F(ManifestParserTest, MultipleErrorsReporting) {
103 Manifest manifest = ParseManifest("{ \"name\": 42, \"short_name\": 4," 101 Manifest manifest = ParseManifest("{ \"name\": 42, \"short_name\": 4,"
104 "\"orientation\": {}, \"display\": \"foo\", \"start_url\": null," 102 "\"orientation\": {}, \"display\": \"foo\", \"start_url\": null,"
105 "\"icons\": {}, \"gcm_user_visible_only\": 42 }"); 103 "\"icons\": {} }");
106 104
107 EXPECT_EQ(7u, GetErrorCount()); 105 EXPECT_EQ(6u, GetErrorCount());
108 106
109 EXPECT_EQ("Manifest parsing error: property 'name' ignored," 107 EXPECT_EQ("Manifest parsing error: property 'name' ignored,"
110 " type string expected.", 108 " type string expected.",
111 errors()[0]); 109 errors()[0]);
112 EXPECT_EQ("Manifest parsing error: property 'short_name' ignored," 110 EXPECT_EQ("Manifest parsing error: property 'short_name' ignored,"
113 " type string expected.", 111 " type string expected.",
114 errors()[1]); 112 errors()[1]);
115 EXPECT_EQ("Manifest parsing error: property 'start_url' ignored," 113 EXPECT_EQ("Manifest parsing error: property 'start_url' ignored,"
116 " type string expected.", 114 " type string expected.",
117 errors()[2]); 115 errors()[2]);
118 EXPECT_EQ("Manifest parsing error: unknown 'display' value ignored.", 116 EXPECT_EQ("Manifest parsing error: unknown 'display' value ignored.",
119 errors()[3]); 117 errors()[3]);
120 EXPECT_EQ("Manifest parsing error: property 'orientation' ignored," 118 EXPECT_EQ("Manifest parsing error: property 'orientation' ignored,"
121 " type string expected.", 119 " type string expected.",
122 errors()[4]); 120 errors()[4]);
123 EXPECT_EQ("Manifest parsing error: property 'icons' ignored, " 121 EXPECT_EQ("Manifest parsing error: property 'icons' ignored, "
124 "type array expected.", 122 "type array expected.",
125 errors()[5]); 123 errors()[5]);
126 EXPECT_EQ("Manifest parsing error: property 'gcm_user_visible_only' ignored, "
127 "type boolean expected.",
128 errors()[6]);
129 } 124 }
130 125
131 TEST_F(ManifestParserTest, NameParseRules) { 126 TEST_F(ManifestParserTest, NameParseRules) {
132 // Smoke test. 127 // Smoke test.
133 { 128 {
134 Manifest manifest = ParseManifest("{ \"name\": \"foo\" }"); 129 Manifest manifest = ParseManifest("{ \"name\": \"foo\" }");
135 ASSERT_TRUE(EqualsASCII(manifest.name.string(), "foo")); 130 ASSERT_TRUE(EqualsASCII(manifest.name.string(), "foo"));
136 ASSERT_FALSE(manifest.IsEmpty()); 131 ASSERT_FALSE(manifest.IsEmpty());
137 EXPECT_EQ(0u, GetErrorCount()); 132 EXPECT_EQ(0u, GetErrorCount());
138 } 133 }
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 { 1001 {
1007 Manifest manifest = ParseManifest("{ \"gcm_sender_id\": 42 }"); 1002 Manifest manifest = ParseManifest("{ \"gcm_sender_id\": 42 }");
1008 EXPECT_TRUE(manifest.gcm_sender_id.is_null()); 1003 EXPECT_TRUE(manifest.gcm_sender_id.is_null());
1009 EXPECT_EQ(1u, GetErrorCount()); 1004 EXPECT_EQ(1u, GetErrorCount());
1010 EXPECT_EQ("Manifest parsing error: property 'gcm_sender_id' ignored," 1005 EXPECT_EQ("Manifest parsing error: property 'gcm_sender_id' ignored,"
1011 " type string expected.", 1006 " type string expected.",
1012 errors()[0]); 1007 errors()[0]);
1013 } 1008 }
1014 } 1009 }
1015 1010
1016 TEST_F(ManifestParserTest, GCMUserVisibleOnlyParseRules) {
1017 // Smoke test.
1018 {
1019 Manifest manifest = ParseManifest("{ \"gcm_user_visible_only\": true }");
1020 EXPECT_TRUE(manifest.gcm_user_visible_only);
1021 EXPECT_EQ(0u, GetErrorCount());
1022 }
1023
1024 // Don't parse if the property isn't a boolean.
1025 {
1026 Manifest manifest = ParseManifest("{ \"gcm_user_visible_only\": {} }");
1027 EXPECT_FALSE(manifest.gcm_user_visible_only);
1028 EXPECT_EQ(1u, GetErrorCount());
1029 EXPECT_EQ(
1030 "Manifest parsing error: property 'gcm_user_visible_only' ignored,"
1031 " type boolean expected.",
1032 errors()[0]);
1033 }
1034 {
1035 Manifest manifest = ParseManifest(
1036 "{ \"gcm_user_visible_only\": \"true\" }");
1037 EXPECT_FALSE(manifest.gcm_user_visible_only);
1038 EXPECT_EQ(1u, GetErrorCount());
1039 EXPECT_EQ(
1040 "Manifest parsing error: property 'gcm_user_visible_only' ignored,"
1041 " type boolean expected.",
1042 errors()[0]);
1043 }
1044 {
1045 Manifest manifest = ParseManifest("{ \"gcm_user_visible_only\": 1 }");
1046 EXPECT_FALSE(manifest.gcm_user_visible_only);
1047 EXPECT_EQ(1u, GetErrorCount());
1048 EXPECT_EQ(
1049 "Manifest parsing error: property 'gcm_user_visible_only' ignored,"
1050 " type boolean expected.",
1051 errors()[0]);
1052 }
1053
1054 // "False" should set the boolean false without throwing errors.
1055 {
1056 Manifest manifest = ParseManifest("{ \"gcm_user_visible_only\": false }");
1057 EXPECT_FALSE(manifest.gcm_user_visible_only);
1058 EXPECT_EQ(0u, GetErrorCount());
1059 }
1060 }
1061
1062 } // namespace content 1011 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/manifest/manifest_parser.cc ('k') | content/renderer/push_messaging/push_messaging_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698