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

Side by Side Diff: chrome/browser/chromeos/extensions/users_private/users_private_apitest.cc

Issue 1870793002: Convert //chrome/browser/chromeos from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: iwyu fixes 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <vector> 5 #include <vector>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ptr_util.h"
9 #include "base/values.h" 10 #include "base/values.h"
10 #include "build/build_config.h" 11 #include "build/build_config.h"
11 #include "chrome/browser/chromeos/extensions/users_private/users_private_delegat e.h" 12 #include "chrome/browser/chromeos/extensions/users_private/users_private_delegat e.h"
12 #include "chrome/browser/chromeos/extensions/users_private/users_private_delegat e_factory.h" 13 #include "chrome/browser/chromeos/extensions/users_private/users_private_delegat e_factory.h"
13 #include "chrome/browser/extensions/api/settings_private/prefs_util.h" 14 #include "chrome/browser/extensions/api/settings_private/prefs_util.h"
14 #include "chrome/browser/extensions/extension_apitest.h" 15 #include "chrome/browser/extensions/extension_apitest.h"
15 #include "chrome/common/extensions/api/users_private.h" 16 #include "chrome/common/extensions/api/users_private.h"
16 #include "components/keyed_service/core/keyed_service.h" 17 #include "components/keyed_service/core/keyed_service.h"
17 #include "components/prefs/pref_service.h" 18 #include "components/prefs/pref_service.h"
18 #include "content/public/test/test_utils.h" 19 #include "content/public/test/test_utils.h"
19 #include "extensions/common/switches.h" 20 #include "extensions/common/switches.h"
20 21
21 #if defined(OS_CHROMEOS) 22 #if defined(OS_CHROMEOS)
22 #include "chromeos/chromeos_switches.h" 23 #include "chromeos/chromeos_switches.h"
23 #endif 24 #endif
24 25
25 namespace extensions { 26 namespace extensions {
26 27
27 namespace { 28 namespace {
28 29
29 class TestPrefsUtil : public PrefsUtil { 30 class TestPrefsUtil : public PrefsUtil {
30 public: 31 public:
31 explicit TestPrefsUtil(Profile* profile) : PrefsUtil(profile) {} 32 explicit TestPrefsUtil(Profile* profile) : PrefsUtil(profile) {}
32 33
33 scoped_ptr<api::settings_private::PrefObject> GetPref( 34 std::unique_ptr<api::settings_private::PrefObject> GetPref(
34 const std::string& name) override { 35 const std::string& name) override {
35 if (name != "cros.accounts.users") 36 if (name != "cros.accounts.users")
36 return PrefsUtil::GetPref(name); 37 return PrefsUtil::GetPref(name);
37 38
38 scoped_ptr<api::settings_private::PrefObject> pref_object( 39 std::unique_ptr<api::settings_private::PrefObject> pref_object(
39 new api::settings_private::PrefObject()); 40 new api::settings_private::PrefObject());
40 pref_object->key = name; 41 pref_object->key = name;
41 pref_object->type = api::settings_private::PrefType::PREF_TYPE_LIST; 42 pref_object->type = api::settings_private::PrefType::PREF_TYPE_LIST;
42 43
43 base::ListValue* value = new base::ListValue(); 44 base::ListValue* value = new base::ListValue();
44 for (auto& email : whitelisted_users_) { 45 for (auto& email : whitelisted_users_) {
45 value->AppendString(email); 46 value->AppendString(email);
46 } 47 }
47 pref_object->value.reset(value); 48 pref_object->value.reset(value);
48 49
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 if (!prefs_util_) 92 if (!prefs_util_)
92 prefs_util_.reset(new TestPrefsUtil(profile_)); 93 prefs_util_.reset(new TestPrefsUtil(profile_));
93 94
94 return prefs_util_.get(); 95 return prefs_util_.get();
95 } 96 }
96 97
97 ~TestDelegate() override {} 98 ~TestDelegate() override {}
98 99
99 private: 100 private:
100 Profile* profile_; // weak 101 Profile* profile_; // weak
101 scoped_ptr<TestPrefsUtil> prefs_util_; 102 std::unique_ptr<TestPrefsUtil> prefs_util_;
102 103
103 DISALLOW_COPY_AND_ASSIGN(TestDelegate); 104 DISALLOW_COPY_AND_ASSIGN(TestDelegate);
104 }; 105 };
105 106
106 class UsersPrivateApiTest : public ExtensionApiTest { 107 class UsersPrivateApiTest : public ExtensionApiTest {
107 public: 108 public:
108 UsersPrivateApiTest() {} 109 UsersPrivateApiTest() {}
109 ~UsersPrivateApiTest() override {} 110 ~UsersPrivateApiTest() override {}
110 111
111 static scoped_ptr<KeyedService> GetUsersPrivateDelegate( 112 static std::unique_ptr<KeyedService> GetUsersPrivateDelegate(
112 content::BrowserContext* profile) { 113 content::BrowserContext* profile) {
113 CHECK(s_test_delegate_); 114 CHECK(s_test_delegate_);
114 return make_scoped_ptr(s_test_delegate_); 115 return base::WrapUnique(s_test_delegate_);
115 } 116 }
116 117
117 void SetUpCommandLine(base::CommandLine* command_line) override { 118 void SetUpCommandLine(base::CommandLine* command_line) override {
118 ExtensionApiTest::SetUpCommandLine(command_line); 119 ExtensionApiTest::SetUpCommandLine(command_line);
119 #if defined(OS_CHROMEOS) 120 #if defined(OS_CHROMEOS)
120 command_line->AppendSwitch(chromeos::switches::kStubCrosSettings); 121 command_line->AppendSwitch(chromeos::switches::kStubCrosSettings);
121 #endif 122 #endif
122 } 123 }
123 124
124 void SetUpOnMainThread() override { 125 void SetUpOnMainThread() override {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 IN_PROC_BROWSER_TEST_F(UsersPrivateApiTest, AddAndRemoveUsers) { 159 IN_PROC_BROWSER_TEST_F(UsersPrivateApiTest, AddAndRemoveUsers) {
159 EXPECT_TRUE(RunSubtest("addAndRemoveUsers")) << message_; 160 EXPECT_TRUE(RunSubtest("addAndRemoveUsers")) << message_;
160 } 161 }
161 162
162 IN_PROC_BROWSER_TEST_F(UsersPrivateApiTest, IsOwner) { 163 IN_PROC_BROWSER_TEST_F(UsersPrivateApiTest, IsOwner) {
163 EXPECT_TRUE(RunSubtest("isOwner")) << message_; 164 EXPECT_TRUE(RunSubtest("isOwner")) << message_;
164 } 165 }
165 #endif 166 #endif
166 167
167 } // namespace extensions 168 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698