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

Side by Side Diff: components/wifi_sync/wifi_config_delegate_chromeos_unittest.cc

Issue 1917673002: Convert //components/[u-z]* from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Build fix Created 4 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 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 "components/wifi_sync/wifi_config_delegate_chromeos.h" 5 #include "components/wifi_sync/wifi_config_delegate_chromeos.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ptr_util.h"
11 #include "base/values.h" 12 #include "base/values.h"
12 #include "chromeos/network/managed_network_configuration_handler.h" 13 #include "chromeos/network/managed_network_configuration_handler.h"
13 #include "chromeos/network/network_handler_callbacks.h" 14 #include "chromeos/network/network_handler_callbacks.h"
14 #include "components/wifi_sync/wifi_credential.h" 15 #include "components/wifi_sync/wifi_credential.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 namespace wifi_sync { 18 namespace wifi_sync {
18 19
19 namespace { 20 namespace {
20 const char kSsid[] = "fake-ssid"; 21 const char kSsid[] = "fake-ssid";
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 144
144 // Wrapper for WifiConfigDelegateChromeOs::AddToLocalNetworks. 145 // Wrapper for WifiConfigDelegateChromeOs::AddToLocalNetworks.
145 void AddToLocalNetworks(const WifiCredential& network_credential) { 146 void AddToLocalNetworks(const WifiCredential& network_credential) {
146 config_delegate_->AddToLocalNetworks(network_credential); 147 config_delegate_->AddToLocalNetworks(network_credential);
147 } 148 }
148 149
149 // Returns a new WifiCredential constructed from the given parameters. 150 // Returns a new WifiCredential constructed from the given parameters.
150 WifiCredential MakeCredential(const std::string& ssid, 151 WifiCredential MakeCredential(const std::string& ssid,
151 WifiSecurityClass security_class, 152 WifiSecurityClass security_class,
152 const std::string& passphrase) { 153 const std::string& passphrase) {
153 scoped_ptr<WifiCredential> credential = 154 std::unique_ptr<WifiCredential> credential = WifiCredential::Create(
danakj 2016/04/25 18:32:58 include memory
dcheng 2016/04/25 19:55:06 DOne.
154 WifiCredential::Create( 155 WifiCredential::MakeSsidBytesForTest(ssid), security_class, passphrase);
155 WifiCredential::MakeSsidBytesForTest(ssid),
156 security_class,
157 passphrase);
158 CHECK(credential); 156 CHECK(credential);
159 return *credential; 157 return *credential;
160 } 158 }
161 159
162 // Runs the last |callback| passed to CreateConfiguration, unless 160 // Runs the last |callback| passed to CreateConfiguration, unless
163 // that |callback| is null. 161 // that |callback| is null.
164 void RunCreateConfigurationSuccessCallback() { 162 void RunCreateConfigurationSuccessCallback() {
165 const char new_service_path[] = "/service/0"; 163 const char new_service_path[] = "/service/0";
166 const ServiceResultCallback callback = 164 const ServiceResultCallback callback =
167 fake_managed_network_configuration_handler_ 165 fake_managed_network_configuration_handler_
(...skipping 10 matching lines...) Expand all
178 } 176 }
179 177
180 // Returns the last |error_callback| passed to the CreateConfiguration 178 // Returns the last |error_callback| passed to the CreateConfiguration
181 // method of |fake_managed_network_configuration_handler_|. 179 // method of |fake_managed_network_configuration_handler_|.
182 const ErrorCallback& create_configuration_error_callback() const { 180 const ErrorCallback& create_configuration_error_callback() const {
183 return fake_managed_network_configuration_handler_ 181 return fake_managed_network_configuration_handler_
184 ->create_configuration_error_callback(); 182 ->create_configuration_error_callback();
185 } 183 }
186 184
187 private: 185 private:
188 scoped_ptr<WifiConfigDelegateChromeOs> config_delegate_; 186 std::unique_ptr<WifiConfigDelegateChromeOs> config_delegate_;
189 scoped_ptr<FakeManagedNetworkConfigurationHandler> 187 std::unique_ptr<FakeManagedNetworkConfigurationHandler>
190 fake_managed_network_configuration_handler_; 188 fake_managed_network_configuration_handler_;
191 189
192 DISALLOW_COPY_AND_ASSIGN(WifiConfigDelegateChromeOsTest); 190 DISALLOW_COPY_AND_ASSIGN(WifiConfigDelegateChromeOsTest);
193 }; 191 };
194 192
195 TEST_F(WifiConfigDelegateChromeOsTest, AddToLocalNetworksOpen) { 193 TEST_F(WifiConfigDelegateChromeOsTest, AddToLocalNetworksOpen) {
196 AddToLocalNetworks(MakeCredential(kSsid, SECURITY_CLASS_NONE, "")); 194 AddToLocalNetworks(MakeCredential(kSsid, SECURITY_CLASS_NONE, ""));
197 ASSERT_TRUE(create_configuration_called()); 195 ASSERT_TRUE(create_configuration_called());
198 RunCreateConfigurationSuccessCallback(); 196 RunCreateConfigurationSuccessCallback();
199 } 197 }
200 198
(...skipping 16 matching lines...) Expand all
217 EXPECT_FALSE(create_configuration_called()); 215 EXPECT_FALSE(create_configuration_called());
218 } 216 }
219 217
220 TEST_F(WifiConfigDelegateChromeOsTest, 218 TEST_F(WifiConfigDelegateChromeOsTest,
221 AddToLocalNetworksCreateConfigurationFailure) { 219 AddToLocalNetworksCreateConfigurationFailure) {
222 AddToLocalNetworks(MakeCredential(kSsid, SECURITY_CLASS_NONE, "")); 220 AddToLocalNetworks(MakeCredential(kSsid, SECURITY_CLASS_NONE, ""));
223 EXPECT_TRUE(create_configuration_called()); 221 EXPECT_TRUE(create_configuration_called());
224 if (!create_configuration_error_callback().is_null()) { 222 if (!create_configuration_error_callback().is_null()) {
225 create_configuration_error_callback().Run( 223 create_configuration_error_callback().Run(
226 "Config.CreateConfiguration Failed", 224 "Config.CreateConfiguration Failed",
227 make_scoped_ptr(new base::DictionaryValue())); 225 base::WrapUnique(new base::DictionaryValue()));
228 } 226 }
229 } 227 }
230 228
231 } // namespace wifi_sync 229 } // namespace wifi_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698