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

Side by Side Diff: chrome/browser/media_galleries/media_galleries_test_util.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 (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 "chrome/browser/media_galleries/media_galleries_test_util.h" 5 #include "chrome/browser/media_galleries/media_galleries_test_util.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/base_paths.h" 11 #include "base/base_paths.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
14 #include "base/memory/ptr_util.h"
14 #include "base/path_service.h" 15 #include "base/path_service.h"
15 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
16 #include "base/threading/thread_restrictions.h" 17 #include "base/threading/thread_restrictions.h"
18 #include "base/values.h"
17 #include "build/build_config.h" 19 #include "build/build_config.h"
18 #include "chrome/browser/extensions/extension_service.h" 20 #include "chrome/browser/extensions/extension_service.h"
19 #include "chrome/browser/media_galleries/fileapi/picasa_finder.h" 21 #include "chrome/browser/media_galleries/fileapi/picasa_finder.h"
20 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/common/chrome_paths.h" 23 #include "chrome/common/chrome_paths.h"
22 #include "components/crx_file/id_util.h" 24 #include "components/crx_file/id_util.h"
23 #include "extensions/browser/extension_prefs.h" 25 #include "extensions/browser/extension_prefs.h"
24 #include "extensions/browser/extension_system.h" 26 #include "extensions/browser/extension_system.h"
25 #include "extensions/common/manifest_constants.h" 27 #include "extensions/common/manifest_constants.h"
26 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
27 29
28 #if defined(OS_MACOSX) 30 #if defined(OS_MACOSX)
29 #include "base/mac/foundation_util.h" 31 #include "base/mac/foundation_util.h"
30 #include "base/strings/sys_string_conversions.h" 32 #include "base/strings/sys_string_conversions.h"
31 #include "chrome/browser/media_galleries/fileapi/iapps_finder_impl.h" 33 #include "chrome/browser/media_galleries/fileapi/iapps_finder_impl.h"
32 #include "components/policy/core/common/preferences_mock_mac.h" 34 #include "components/policy/core/common/preferences_mock_mac.h"
33 #endif // OS_MACOSX 35 #endif // OS_MACOSX
34 36
35 #if defined(OS_WIN) 37 #if defined(OS_WIN)
36 #include <windows.h> 38 #include <windows.h>
37 #include "base/test/test_reg_util_win.h" 39 #include "base/test/test_reg_util_win.h"
38 #include "base/win/registry.h" 40 #include "base/win/registry.h"
39 #endif // OS_WIN 41 #endif // OS_WIN
40 42
41 scoped_refptr<extensions::Extension> AddMediaGalleriesApp( 43 scoped_refptr<extensions::Extension> AddMediaGalleriesApp(
42 const std::string& name, 44 const std::string& name,
43 const std::vector<std::string>& media_galleries_permissions, 45 const std::vector<std::string>& media_galleries_permissions,
44 Profile* profile) { 46 Profile* profile) {
45 std::unique_ptr<base::DictionaryValue> manifest(new base::DictionaryValue); 47 auto manifest = base::MakeUnique<base::DictionaryValue>();
46 manifest->SetString(extensions::manifest_keys::kName, name); 48 manifest->SetString(extensions::manifest_keys::kName, name);
47 manifest->SetString(extensions::manifest_keys::kVersion, "0.1"); 49 manifest->SetString(extensions::manifest_keys::kVersion, "0.1");
48 manifest->SetInteger(extensions::manifest_keys::kManifestVersion, 2); 50 manifest->SetInteger(extensions::manifest_keys::kManifestVersion, 2);
49 base::ListValue* background_script_list = new base::ListValue; 51 auto background_script_list = base::MakeUnique<base::ListValue>();
50 background_script_list->AppendString("background.js"); 52 background_script_list->AppendString("background.js");
51 manifest->Set(extensions::manifest_keys::kPlatformAppBackgroundScripts, 53 manifest->Set(extensions::manifest_keys::kPlatformAppBackgroundScripts,
52 background_script_list); 54 std::move(background_script_list));
53 55
54 base::ListValue* permission_detail_list = new base::ListValue; 56 auto permission_detail_list = base::MakeUnique<base::ListValue>();
55 for (size_t i = 0; i < media_galleries_permissions.size(); i++) 57 for (size_t i = 0; i < media_galleries_permissions.size(); i++)
56 permission_detail_list->AppendString(media_galleries_permissions[i]); 58 permission_detail_list->AppendString(media_galleries_permissions[i]);
57 std::unique_ptr<base::DictionaryValue> media_galleries_permission( 59 auto media_galleries_permission = base::MakeUnique<base::DictionaryValue>();
58 new base::DictionaryValue()); 60 media_galleries_permission->Set("mediaGalleries",
59 media_galleries_permission->Set("mediaGalleries", permission_detail_list); 61 std::move(permission_detail_list));
60 base::ListValue* permission_list = new base::ListValue; 62 auto permission_list = base::MakeUnique<base::ListValue>();
61 permission_list->Append(std::move(media_galleries_permission)); 63 permission_list->Append(std::move(media_galleries_permission));
62 manifest->Set(extensions::manifest_keys::kPermissions, permission_list); 64 manifest->Set(extensions::manifest_keys::kPermissions,
65 std::move(permission_list));
63 66
64 extensions::ExtensionPrefs* extension_prefs = 67 extensions::ExtensionPrefs* extension_prefs =
65 extensions::ExtensionPrefs::Get(profile); 68 extensions::ExtensionPrefs::Get(profile);
66 base::FilePath path = extension_prefs->install_directory().AppendASCII(name); 69 base::FilePath path = extension_prefs->install_directory().AppendASCII(name);
67 std::string errors; 70 std::string errors;
68 scoped_refptr<extensions::Extension> extension = 71 scoped_refptr<extensions::Extension> extension =
69 extensions::Extension::Create(path, extensions::Manifest::INTERNAL, 72 extensions::Extension::Create(path, extensions::Manifest::INTERNAL,
70 *manifest.get(), 73 *manifest.get(),
71 extensions::Extension::NO_FLAGS, &errors); 74 extensions::Extension::NO_FLAGS, &errors);
72 EXPECT_TRUE(extension.get() != NULL) << errors; 75 EXPECT_TRUE(extension.get() != NULL) << errors;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 225
223 base::FilePath MakeMediaGalleriesTestingPath(const std::string& dir) { 226 base::FilePath MakeMediaGalleriesTestingPath(const std::string& dir) {
224 #if defined(OS_WIN) 227 #if defined(OS_WIN)
225 return base::FilePath(FILE_PATH_LITERAL("C:\\")).AppendASCII(dir); 228 return base::FilePath(FILE_PATH_LITERAL("C:\\")).AppendASCII(dir);
226 #elif defined(OS_POSIX) 229 #elif defined(OS_POSIX)
227 return base::FilePath(FILE_PATH_LITERAL("/")).Append(dir); 230 return base::FilePath(FILE_PATH_LITERAL("/")).Append(dir);
228 #else 231 #else
229 NOTREACHED(); 232 NOTREACHED();
230 #endif 233 #endif
231 } 234 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698