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

Side by Side Diff: extensions/common/manifest_handler_unittest.cc

Issue 1908953003: Convert //extensions/{common,shell} from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase? Created 4 years, 8 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_handler.h"
6
5 #include <stddef.h> 7 #include <stddef.h>
6 8
9 #include <memory>
7 #include <string> 10 #include <string>
8 #include <vector> 11 #include <vector>
9 12
10 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/stl_util.h" 14 #include "base/stl_util.h"
13 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
14 #include "extensions/common/extension.h" 16 #include "extensions/common/extension.h"
15 #include "extensions/common/extension_builder.h" 17 #include "extensions/common/extension_builder.h"
16 #include "extensions/common/install_warning.h" 18 #include "extensions/common/install_warning.h"
17 #include "extensions/common/manifest_handler.h"
18 #include "extensions/common/value_builder.h" 19 #include "extensions/common/value_builder.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 namespace extensions { 22 namespace extensions {
22 23
23 namespace { 24 namespace {
24 25
25 std::vector<std::string> SingleKey(const std::string& key) { 26 std::vector<std::string> SingleKey(const std::string& key) {
26 return std::vector<std::string>(1, key); 27 return std::vector<std::string>(1, key);
27 } 28 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 EXPECT_EQ(5u, watcher.parsed_names().size()); 206 EXPECT_EQ(5u, watcher.parsed_names().size());
206 EXPECT_TRUE(watcher.ParsedBefore("B", "C.D")); 207 EXPECT_TRUE(watcher.ParsedBefore("B", "C.D"));
207 EXPECT_TRUE(watcher.ParsedBefore("K", "C.D")); 208 EXPECT_TRUE(watcher.ParsedBefore("K", "C.D"));
208 EXPECT_TRUE(watcher.ParsedBefore("C.D", "C.EZ")); 209 EXPECT_TRUE(watcher.ParsedBefore("C.D", "C.EZ"));
209 } 210 }
210 211
211 TEST_F(ManifestHandlerTest, FailingHandlers) { 212 TEST_F(ManifestHandlerTest, FailingHandlers) {
212 ScopedTestingManifestHandlerRegistry registry; 213 ScopedTestingManifestHandlerRegistry registry;
213 // Can't use ExtensionBuilder, because this extension will fail to 214 // Can't use ExtensionBuilder, because this extension will fail to
214 // be parsed. 215 // be parsed.
215 scoped_ptr<base::DictionaryValue> manifest_a( 216 std::unique_ptr<base::DictionaryValue> manifest_a(
216 DictionaryBuilder() 217 DictionaryBuilder()
217 .Set("name", "no name") 218 .Set("name", "no name")
218 .Set("version", "0") 219 .Set("version", "0")
219 .Set("manifest_version", 2) 220 .Set("manifest_version", 2)
220 .Set("a", 1) 221 .Set("a", 1)
221 .Build()); 222 .Build());
222 223
223 // Succeeds when "a" is not recognized. 224 // Succeeds when "a" is not recognized.
224 std::string error; 225 std::string error;
225 scoped_refptr<Extension> extension = Extension::Create( 226 scoped_refptr<Extension> extension = Extension::Create(
226 base::FilePath(), 227 base::FilePath(),
227 Manifest::INVALID_LOCATION, 228 Manifest::INVALID_LOCATION,
228 *manifest_a, 229 *manifest_a,
229 Extension::NO_FLAGS, 230 Extension::NO_FLAGS,
230 &error); 231 &error);
231 EXPECT_TRUE(extension.get()); 232 EXPECT_TRUE(extension.get());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 EXPECT_TRUE( 273 EXPECT_TRUE(
273 ManifestHandler::ValidateExtension(extension.get(), &error, &warnings)); 274 ManifestHandler::ValidateExtension(extension.get(), &error, &warnings));
274 275
275 // Validates "a" and fails. 276 // Validates "a" and fails.
276 (new TestManifestValidator(false, true, SingleKey("a")))->Register(); 277 (new TestManifestValidator(false, true, SingleKey("a")))->Register();
277 EXPECT_FALSE( 278 EXPECT_FALSE(
278 ManifestHandler::ValidateExtension(extension.get(), &error, &warnings)); 279 ManifestHandler::ValidateExtension(extension.get(), &error, &warnings));
279 } 280 }
280 281
281 } // namespace extensions 282 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/manifest_handler_helpers.h ('k') | extensions/common/manifest_handlers/app_isolation_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698