| 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 <utility> | 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/macros.h" | 10 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/test/test_simple_task_runner.h" | 12 #include "base/test/test_simple_task_runner.h" |
| 13 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "components/proximity_auth/fake_secure_context.h" | 15 #include "components/proximity_auth/fake_secure_context.h" |
| 16 #include "components/proximity_auth/logging/logging.h" | 16 #include "components/proximity_auth/logging/logging.h" |
| 17 #include "components/proximity_auth/messenger.h" | 17 #include "components/proximity_auth/messenger.h" |
| 18 #include "components/proximity_auth/mock_proximity_auth_client.h" | 18 #include "components/proximity_auth/mock_proximity_auth_client.h" |
| 19 #include "components/proximity_auth/proximity_auth_test_util.h" | 19 #include "components/proximity_auth/proximity_auth_test_util.h" |
| 20 #include "components/proximity_auth/proximity_monitor.h" | 20 #include "components/proximity_auth/proximity_monitor.h" |
| 21 #include "components/proximity_auth/remote_device_life_cycle.h" | 21 #include "components/proximity_auth/remote_device_life_cycle.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 using MessengerObserver::OnDecryptResponse; | 151 using MessengerObserver::OnDecryptResponse; |
| 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 scoped_ptr<ProximityMonitor> CreateProximityMonitor( | 161 std::unique_ptr<ProximityMonitor> CreateProximityMonitor( |
| 162 const RemoteDevice& remote_device) override { | 162 const RemoteDevice& remote_device) override { |
| 163 EXPECT_EQ(kTestRemoteDevicePublicKey, remote_device.public_key); | 163 EXPECT_EQ(kTestRemoteDevicePublicKey, remote_device.public_key); |
| 164 scoped_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 |
| 173 DISALLOW_COPY_AND_ASSIGN(TestUnlockManager); | 173 DISALLOW_COPY_AND_ASSIGN(TestUnlockManager); |
| 174 }; | 174 }; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 | 254 |
| 255 protected: | 255 protected: |
| 256 RemoteDevice remote_device_; | 256 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 scoped_ptr<TestUnlockManager> unlock_manager_; | 264 std::unique_ptr<TestUnlockManager> unlock_manager_; |
| 265 FakeSecureContext secure_context_; | 265 FakeSecureContext secure_context_; |
| 266 | 266 |
| 267 private: | 267 private: |
| 268 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; | 268 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; |
| 269 base::ThreadTaskRunnerHandle thread_task_runner_handle_; | 269 base::ThreadTaskRunnerHandle thread_task_runner_handle_; |
| 270 FakeLockHandler lock_handler_; | 270 FakeLockHandler lock_handler_; |
| 271 ScopedDisableLoggingForTesting disable_logging_; | 271 ScopedDisableLoggingForTesting disable_logging_; |
| 272 }; | 272 }; |
| 273 | 273 |
| 274 TEST_F(ProximityAuthUnlockManagerTest, IsUnlockAllowed_InitialState) { | 274 TEST_F(ProximityAuthUnlockManagerTest, IsUnlockAllowed_InitialState) { |
| (...skipping 649 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 |