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

Side by Side Diff: chrome/common/extensions/manifest_unittest.cc

Issue 2664753002: Remove base::StringValue (Closed)
Patch Set: Rebase Created 3 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "extensions/common/manifest.h" 5 #include "extensions/common/manifest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 feature.set_max_manifest_version(1); 107 feature.set_max_manifest_version(1);
108 EXPECT_EQ( 108 EXPECT_EQ(
109 "'background_page' requires manifest version of 1 or lower.", 109 "'background_page' requires manifest version of 1 or lower.",
110 warnings[0].message); 110 warnings[0].message);
111 } 111 }
112 112
113 // Test DeepCopy and Equals. 113 // Test DeepCopy and Equals.
114 std::unique_ptr<Manifest> manifest2(manifest->DeepCopy()); 114 std::unique_ptr<Manifest> manifest2(manifest->DeepCopy());
115 EXPECT_TRUE(manifest->Equals(manifest2.get())); 115 EXPECT_TRUE(manifest->Equals(manifest2.get()));
116 EXPECT_TRUE(manifest2->Equals(manifest.get())); 116 EXPECT_TRUE(manifest2->Equals(manifest.get()));
117 MutateManifest( 117 MutateManifest(&manifest, "foo", new base::Value("blah"));
118 &manifest, "foo", new base::StringValue("blah"));
119 EXPECT_FALSE(manifest->Equals(manifest2.get())); 118 EXPECT_FALSE(manifest->Equals(manifest2.get()));
120 } 119 }
121 120
122 // Verifies that key restriction based on type works. 121 // Verifies that key restriction based on type works.
123 TEST_F(ManifestUnitTest, ExtensionTypes) { 122 TEST_F(ManifestUnitTest, ExtensionTypes) {
124 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 123 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
125 value->SetString(keys::kName, "extension"); 124 value->SetString(keys::kName, "extension");
126 value->SetString(keys::kVersion, "1"); 125 value->SetString(keys::kVersion, "1");
127 126
128 std::unique_ptr<Manifest> manifest( 127 std::unique_ptr<Manifest> manifest(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 AssertType(manifest.get(), Manifest::TYPE_PLATFORM_APP); 160 AssertType(manifest.get(), Manifest::TYPE_PLATFORM_APP);
162 MutateManifest( 161 MutateManifest(
163 &manifest, keys::kPlatformAppBackground, NULL); 162 &manifest, keys::kPlatformAppBackground, NULL);
164 163
165 // Hosted app. 164 // Hosted app.
166 MutateManifest( 165 MutateManifest(
167 &manifest, keys::kWebURLs, new base::ListValue()); 166 &manifest, keys::kWebURLs, new base::ListValue());
168 AssertType(manifest.get(), Manifest::TYPE_HOSTED_APP); 167 AssertType(manifest.get(), Manifest::TYPE_HOSTED_APP);
169 MutateManifest( 168 MutateManifest(
170 &manifest, keys::kWebURLs, NULL); 169 &manifest, keys::kWebURLs, NULL);
171 MutateManifest( 170 MutateManifest(&manifest, keys::kLaunchWebURL, new base::Value("foo"));
172 &manifest, keys::kLaunchWebURL, new base::StringValue("foo"));
173 AssertType(manifest.get(), Manifest::TYPE_HOSTED_APP); 171 AssertType(manifest.get(), Manifest::TYPE_HOSTED_APP);
174 MutateManifest( 172 MutateManifest(
175 &manifest, keys::kLaunchWebURL, NULL); 173 &manifest, keys::kLaunchWebURL, NULL);
176 } 174 }
177 175
178 // Verifies that the getters filter restricted keys. 176 // Verifies that the getters filter restricted keys.
179 TEST_F(ManifestUnitTest, RestrictedKeys) { 177 TEST_F(ManifestUnitTest, RestrictedKeys) {
180 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 178 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
181 value->SetString(keys::kName, "extension"); 179 value->SetString(keys::kName, "extension");
182 value->SetString(keys::kVersion, "1"); 180 value->SetString(keys::kVersion, "1");
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 EXPECT_FALSE(manifest->Get(keys::kPageAction, &output)); 212 EXPECT_FALSE(manifest->Get(keys::kPageAction, &output));
215 MutateManifest( 213 MutateManifest(
216 &manifest, keys::kPlatformAppBackground, NULL); 214 &manifest, keys::kPlatformAppBackground, NULL);
217 215
218 // Platform apps also can't have a "Commands" key. 216 // Platform apps also can't have a "Commands" key.
219 EXPECT_FALSE(manifest->HasKey(keys::kCommands)); 217 EXPECT_FALSE(manifest->HasKey(keys::kCommands));
220 EXPECT_FALSE(manifest->Get(keys::kCommands, &output)); 218 EXPECT_FALSE(manifest->Get(keys::kCommands, &output));
221 } 219 }
222 220
223 } // namespace extensions 221 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/custom_handlers/protocol_handler.cc ('k') | chrome/common/extensions/sync_type_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698