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

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

Issue 2888073002: Remove raw DictionaryValue::Set in //chrome (Closed)
Patch Set: Fix Tests Created 3 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 <utility> 5 #include <utility>
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/values.h"
9 #include "build/build_config.h" 10 #include "build/build_config.h"
10 #include "chrome/common/extensions/sync_helper.h" 11 #include "chrome/common/extensions/sync_helper.h"
11 #include "extensions/common/error_utils.h" 12 #include "extensions/common/error_utils.h"
12 #include "extensions/common/extension.h" 13 #include "extensions/common/extension.h"
13 #include "extensions/common/features/simple_feature.h" 14 #include "extensions/common/features/simple_feature.h"
14 #include "extensions/common/manifest.h" 15 #include "extensions/common/manifest.h"
15 #include "extensions/common/manifest_constants.h" 16 #include "extensions/common/manifest_constants.h"
16 #include "extensions/common/manifest_handlers/plugins_handler.h" 17 #include "extensions/common/manifest_handlers/plugins_handler.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 #include "url/gurl.h" 19 #include "url/gurl.h"
(...skipping 21 matching lines...) Expand all
40 int creation_flags, 41 int creation_flags,
41 int num_plugins, 42 int num_plugins,
42 bool has_plugin_permission, 43 bool has_plugin_permission,
43 const std::string& expected_error) { 44 const std::string& expected_error) {
44 base::DictionaryValue source; 45 base::DictionaryValue source;
45 source.SetString(keys::kName, "PossiblySyncableExtension"); 46 source.SetString(keys::kName, "PossiblySyncableExtension");
46 source.SetString(keys::kVersion, "0.0.0.0"); 47 source.SetString(keys::kVersion, "0.0.0.0");
47 if (type == APP) 48 if (type == APP)
48 source.SetString(keys::kApp, "true"); 49 source.SetString(keys::kApp, "true");
49 if (type == THEME) 50 if (type == THEME)
50 source.Set(keys::kTheme, new base::DictionaryValue()); 51 source.Set(keys::kTheme, base::MakeUnique<base::DictionaryValue>());
51 if (!update_url.is_empty()) { 52 if (!update_url.is_empty()) {
52 source.SetString(keys::kUpdateURL, update_url.spec()); 53 source.SetString(keys::kUpdateURL, update_url.spec());
53 } 54 }
54 if (!launch_url.is_empty()) { 55 if (!launch_url.is_empty()) {
55 source.SetString(keys::kLaunchWebURL, launch_url.spec()); 56 source.SetString(keys::kLaunchWebURL, launch_url.spec());
56 } 57 }
57 if (type != THEME) { 58 if (type != THEME) {
58 source.SetBoolean(keys::kConvertedFromUserScript, type == USER_SCRIPT); 59 source.SetBoolean(keys::kConvertedFromUserScript, type == USER_SCRIPT);
59 if (num_plugins >= 0) { 60 if (num_plugins >= 0) {
60 base::ListValue* plugins = new base::ListValue(); 61 auto plugins = base::MakeUnique<base::ListValue>();
61 for (int i = 0; i < num_plugins; ++i) { 62 for (int i = 0; i < num_plugins; ++i) {
62 auto plugin = base::MakeUnique<base::DictionaryValue>(); 63 auto plugin = base::MakeUnique<base::DictionaryValue>();
63 plugin->SetString(keys::kPluginsPath, std::string()); 64 plugin->SetString(keys::kPluginsPath, std::string());
64 plugins->Set(i, std::move(plugin)); 65 plugins->Set(i, std::move(plugin));
65 } 66 }
66 source.Set(keys::kPlugins, plugins); 67 source.Set(keys::kPlugins, std::move(plugins));
67 } 68 }
68 } 69 }
69 if (has_plugin_permission) { 70 if (has_plugin_permission) {
70 base::ListValue* plugins = new base::ListValue(); 71 auto plugins = base::MakeUnique<base::ListValue>();
71 plugins->Set(0, base::MakeUnique<base::Value>("plugin")); 72 plugins->Set(0, base::MakeUnique<base::Value>("plugin"));
72 source.Set(keys::kPermissions, plugins); 73 source.Set(keys::kPermissions, std::move(plugins));
73 } 74 }
74 75
75 std::string error; 76 std::string error;
76 scoped_refptr<Extension> extension = Extension::Create( 77 scoped_refptr<Extension> extension = Extension::Create(
77 extension_path, location, source, creation_flags, &error); 78 extension_path, location, source, creation_flags, &error);
78 if (expected_error.empty()) 79 if (expected_error.empty())
79 EXPECT_TRUE(extension.get()); 80 EXPECT_TRUE(extension.get());
80 else 81 else
81 EXPECT_FALSE(extension.get()); 82 EXPECT_FALSE(extension.get());
82 EXPECT_EQ(expected_error, error); 83 EXPECT_EQ(expected_error, error);
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 EXTENSION, GURL(), GURL(), 312 EXTENSION, GURL(), GURL(),
312 Manifest::INTERNAL, base::FilePath(), 313 Manifest::INTERNAL, base::FilePath(),
313 Extension::NO_FLAGS, 0, true, 314 Extension::NO_FLAGS, 0, true,
314 ErrorUtils::FormatErrorMessage( 315 ErrorUtils::FormatErrorMessage(
315 errors::kPermissionNotAllowedInManifest, "plugin"))); 316 errors::kPermissionNotAllowedInManifest, "plugin")));
316 } 317 }
317 318
318 #endif // !defined(OS_CHROMEOS) 319 #endif // !defined(OS_CHROMEOS)
319 320
320 } // namespace extensions 321 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698