OLD | NEW |
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/unlock_manager.h" | 5 #include "components/proximity_auth/unlock_manager.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 RemoteStatusUpdate kRemoteScreenlockStateUnknown = { | 55 RemoteStatusUpdate kRemoteScreenlockStateUnknown = { |
56 USER_PRESENCE_UNKNOWN, SECURE_SCREEN_LOCK_STATE_UNKNOWN, | 56 USER_PRESENCE_UNKNOWN, SECURE_SCREEN_LOCK_STATE_UNKNOWN, |
57 TRUST_AGENT_UNSUPPORTED}; | 57 TRUST_AGENT_UNSUPPORTED}; |
58 | 58 |
59 class MockRemoteDeviceLifeCycle : public RemoteDeviceLifeCycle { | 59 class MockRemoteDeviceLifeCycle : public RemoteDeviceLifeCycle { |
60 public: | 60 public: |
61 MockRemoteDeviceLifeCycle() {} | 61 MockRemoteDeviceLifeCycle() {} |
62 ~MockRemoteDeviceLifeCycle() override {} | 62 ~MockRemoteDeviceLifeCycle() override {} |
63 | 63 |
64 MOCK_METHOD0(Start, void()); | 64 MOCK_METHOD0(Start, void()); |
65 MOCK_CONST_METHOD0(GetRemoteDevice, RemoteDevice()); | 65 MOCK_CONST_METHOD0(GetRemoteDevice, cryptauth::RemoteDevice()); |
66 MOCK_CONST_METHOD0(GetState, State()); | 66 MOCK_CONST_METHOD0(GetState, State()); |
67 MOCK_METHOD0(GetMessenger, Messenger*()); | 67 MOCK_METHOD0(GetMessenger, Messenger*()); |
68 MOCK_METHOD1(AddObserver, void(Observer*)); | 68 MOCK_METHOD1(AddObserver, void(Observer*)); |
69 MOCK_METHOD1(RemoveObserver, void(Observer*)); | 69 MOCK_METHOD1(RemoveObserver, void(Observer*)); |
70 }; | 70 }; |
71 | 71 |
72 class MockMessenger : public Messenger { | 72 class MockMessenger : public Messenger { |
73 public: | 73 public: |
74 MockMessenger() {} | 74 MockMessenger() {} |
75 ~MockMessenger() override {} | 75 ~MockMessenger() override {} |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 using MessengerObserver::OnUnlockResponse; | 152 using MessengerObserver::OnUnlockResponse; |
153 using MessengerObserver::OnDisconnected; | 153 using MessengerObserver::OnDisconnected; |
154 using ScreenlockBridge::Observer::OnScreenDidLock; | 154 using ScreenlockBridge::Observer::OnScreenDidLock; |
155 using ScreenlockBridge::Observer::OnScreenDidUnlock; | 155 using ScreenlockBridge::Observer::OnScreenDidUnlock; |
156 using ScreenlockBridge::Observer::OnFocusedUserChanged; | 156 using ScreenlockBridge::Observer::OnFocusedUserChanged; |
157 | 157 |
158 MockProximityMonitor* proximity_monitor() { return proximity_monitor_; } | 158 MockProximityMonitor* proximity_monitor() { return proximity_monitor_; } |
159 | 159 |
160 private: | 160 private: |
161 std::unique_ptr<ProximityMonitor> CreateProximityMonitor( | 161 std::unique_ptr<ProximityMonitor> CreateProximityMonitor( |
162 const RemoteDevice& remote_device) override { | 162 const cryptauth::RemoteDevice& remote_device) override { |
163 EXPECT_EQ(kTestRemoteDevicePublicKey, remote_device.public_key); | 163 EXPECT_EQ(kTestRemoteDevicePublicKey, remote_device.public_key); |
164 std::unique_ptr<MockProximityMonitor> proximity_monitor( | 164 std::unique_ptr<MockProximityMonitor> proximity_monitor( |
165 new NiceMock<MockProximityMonitor>()); | 165 new NiceMock<MockProximityMonitor>()); |
166 proximity_monitor_ = proximity_monitor.get(); | 166 proximity_monitor_ = proximity_monitor.get(); |
167 return std::move(proximity_monitor); | 167 return std::move(proximity_monitor); |
168 } | 168 } |
169 | 169 |
170 // Owned by the super class. | 170 // Owned by the super class. |
171 MockProximityMonitor* proximity_monitor_; | 171 MockProximityMonitor* proximity_monitor_; |
172 | 172 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 unlock_manager_->OnRemoteStatusUpdate(kRemoteScreenUnlocked); | 246 unlock_manager_->OnRemoteStatusUpdate(kRemoteScreenUnlocked); |
247 } | 247 } |
248 | 248 |
249 void RunPendingTasks() { task_runner_->RunPendingTasks(); } | 249 void RunPendingTasks() { task_runner_->RunPendingTasks(); } |
250 | 250 |
251 MockProximityMonitor* proximity_monitor() { | 251 MockProximityMonitor* proximity_monitor() { |
252 return unlock_manager_ ? unlock_manager_->proximity_monitor() : nullptr; | 252 return unlock_manager_ ? unlock_manager_->proximity_monitor() : nullptr; |
253 } | 253 } |
254 | 254 |
255 protected: | 255 protected: |
256 RemoteDevice remote_device_; | 256 cryptauth::RemoteDevice remote_device_; |
257 | 257 |
258 // Mock used for verifying interactions with the Bluetooth subsystem. | 258 // Mock used for verifying interactions with the Bluetooth subsystem. |
259 scoped_refptr<device::MockBluetoothAdapter> bluetooth_adapter_; | 259 scoped_refptr<device::MockBluetoothAdapter> bluetooth_adapter_; |
260 | 260 |
261 NiceMock<MockProximityAuthClient> proximity_auth_client_; | 261 NiceMock<MockProximityAuthClient> proximity_auth_client_; |
262 NiceMock<MockRemoteDeviceLifeCycle> life_cycle_; | 262 NiceMock<MockRemoteDeviceLifeCycle> life_cycle_; |
263 NiceMock<MockMessenger> messenger_; | 263 NiceMock<MockMessenger> messenger_; |
264 std::unique_ptr<TestUnlockManager> unlock_manager_; | 264 std::unique_ptr<TestUnlockManager> unlock_manager_; |
265 FakeSecureContext secure_context_; | 265 FakeSecureContext secure_context_; |
266 | 266 |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
924 })); | 924 })); |
925 | 925 |
926 EXPECT_CALL(messenger_, RequestDecryption(kChallenge)); | 926 EXPECT_CALL(messenger_, RequestDecryption(kChallenge)); |
927 unlock_manager_->OnAuthAttempted(ScreenlockBridge::LockHandler::USER_CLICK); | 927 unlock_manager_->OnAuthAttempted(ScreenlockBridge::LockHandler::USER_CLICK); |
928 | 928 |
929 EXPECT_CALL(proximity_auth_client_, FinalizeSignin(std::string())); | 929 EXPECT_CALL(proximity_auth_client_, FinalizeSignin(std::string())); |
930 unlock_manager_->OnDecryptResponse(std::string()); | 930 unlock_manager_->OnDecryptResponse(std::string()); |
931 } | 931 } |
932 | 932 |
933 } // namespace proximity_auth | 933 } // namespace proximity_auth |
OLD | NEW |