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

Side by Side Diff: components/proximity_auth/remote_device_loader_unittest.cc

Issue 1912433002: Convert //components/proximity_auth from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits 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 "components/proximity_auth/remote_device_loader.h" 5 #include "components/proximity_auth/remote_device_loader.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8
9 #include <memory>
8 #include <utility> 10 #include <utility>
9 11
10 #include "base/bind.h" 12 #include "base/bind.h"
11 #include "base/macros.h" 13 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "components/proximity_auth/cryptauth/fake_secure_message_delegate.h" 14 #include "components/proximity_auth/cryptauth/fake_secure_message_delegate.h"
14 #include "components/proximity_auth/proximity_auth_pref_manager.h" 15 #include "components/proximity_auth/proximity_auth_pref_manager.h"
15 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
18 namespace proximity_auth { 19 namespace proximity_auth {
19 namespace { 20 namespace {
20 21
21 // Prefixes for RemoteDevice fields. 22 // Prefixes for RemoteDevice fields.
22 const char kDeviceNamePrefix[] = "device"; 23 const char kDeviceNamePrefix[] = "device";
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 void OnRemoteDevicesLoaded(const std::vector<RemoteDevice>& remote_devices) { 64 void OnRemoteDevicesLoaded(const std::vector<RemoteDevice>& remote_devices) {
64 remote_devices_ = remote_devices; 65 remote_devices_ = remote_devices;
65 LoadCompleted(); 66 LoadCompleted();
66 } 67 }
67 68
68 MOCK_METHOD0(LoadCompleted, void()); 69 MOCK_METHOD0(LoadCompleted, void());
69 70
70 protected: 71 protected:
71 // Handles deriving the PSK. Ownership will be passed to the 72 // Handles deriving the PSK. Ownership will be passed to the
72 // RemoteDeviceLoader under test. 73 // RemoteDeviceLoader under test.
73 scoped_ptr<FakeSecureMessageDelegate> secure_message_delegate_; 74 std::unique_ptr<FakeSecureMessageDelegate> secure_message_delegate_;
74 75
75 // The private key of the user local device. 76 // The private key of the user local device.
76 std::string user_private_key_; 77 std::string user_private_key_;
77 78
78 // Stores the result of the RemoteDeviceLoader. 79 // Stores the result of the RemoteDeviceLoader.
79 std::vector<RemoteDevice> remote_devices_; 80 std::vector<RemoteDevice> remote_devices_;
80 81
81 // Stores the bluetooth address for BLE devices. 82 // Stores the bluetooth address for BLE devices.
82 scoped_ptr<MockProximityAuthPrefManager> pref_manager_; 83 std::unique_ptr<MockProximityAuthPrefManager> pref_manager_;
83 84
84 DISALLOW_COPY_AND_ASSIGN(ProximityAuthRemoteDeviceLoaderTest); 85 DISALLOW_COPY_AND_ASSIGN(ProximityAuthRemoteDeviceLoaderTest);
85 }; 86 };
86 87
87 TEST_F(ProximityAuthRemoteDeviceLoaderTest, LoadZeroDevices) { 88 TEST_F(ProximityAuthRemoteDeviceLoaderTest, LoadZeroDevices) {
88 std::vector<cryptauth::ExternalDeviceInfo> unlock_keys; 89 std::vector<cryptauth::ExternalDeviceInfo> unlock_keys;
89 RemoteDeviceLoader loader(unlock_keys, user_private_key_, kUserId, 90 RemoteDeviceLoader loader(unlock_keys, user_private_key_, kUserId,
90 std::move(secure_message_delegate_), 91 std::move(secure_message_delegate_),
91 pref_manager_.get()); 92 pref_manager_.get());
92 93
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 for (size_t i = 0; i < 3; ++i) { 167 for (size_t i = 0; i < 3; ++i) {
167 EXPECT_FALSE(remote_devices_[i].persistent_symmetric_key.empty()); 168 EXPECT_FALSE(remote_devices_[i].persistent_symmetric_key.empty());
168 EXPECT_EQ(unlock_keys[i].friendly_device_name(), remote_devices_[i].name); 169 EXPECT_EQ(unlock_keys[i].friendly_device_name(), remote_devices_[i].name);
169 EXPECT_EQ(unlock_keys[i].public_key(), remote_devices_[i].public_key); 170 EXPECT_EQ(unlock_keys[i].public_key(), remote_devices_[i].public_key);
170 EXPECT_EQ(unlock_keys[i].bluetooth_address(), 171 EXPECT_EQ(unlock_keys[i].bluetooth_address(),
171 remote_devices_[i].bluetooth_address); 172 remote_devices_[i].bluetooth_address);
172 } 173 }
173 } 174 }
174 175
175 } // namespace proximity_auth 176 } // namespace proximity_auth
OLDNEW
« no previous file with comments | « components/proximity_auth/remote_device_loader.cc ('k') | components/proximity_auth/remote_status_update.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698