| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/proximity_auth_system.h" | 5 #include "components/proximity_auth/proximity_auth_system.h" |
| 6 | 6 |
| 7 #include "base/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.h" |
| 8 #include "base/threading/thread_task_runner_handle.h" | 8 #include "base/threading/thread_task_runner_handle.h" |
| 9 #include "components/cryptauth/remote_device.h" | 9 #include "components/cryptauth/remote_device.h" |
| 10 #include "components/proximity_auth/fake_lock_handler.h" | 10 #include "components/proximity_auth/fake_lock_handler.h" |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 life_cycle = nullptr; | 294 life_cycle = nullptr; |
| 295 EXPECT_CALL(*unlock_manager_, SetRemoteDeviceLifeCycle(_)) | 295 EXPECT_CALL(*unlock_manager_, SetRemoteDeviceLifeCycle(_)) |
| 296 .WillOnce(SaveArg<0>(&life_cycle)); | 296 .WillOnce(SaveArg<0>(&life_cycle)); |
| 297 FocusUser(kUser1); | 297 FocusUser(kUser1); |
| 298 EXPECT_EQ(kUser1, life_cycle->GetRemoteDevice().user_id); | 298 EXPECT_EQ(kUser1, life_cycle->GetRemoteDevice().user_id); |
| 299 | 299 |
| 300 EXPECT_CALL(*unlock_manager_, SetRemoteDeviceLifeCycle(nullptr)) | 300 EXPECT_CALL(*unlock_manager_, SetRemoteDeviceLifeCycle(nullptr)) |
| 301 .Times(AtLeast(1)); | 301 .Times(AtLeast(1)); |
| 302 } | 302 } |
| 303 | 303 |
| 304 TEST_F(ProximityAuthSystemTest, ToggleFocus_SameUserRefocused) { |
| 305 RemoteDeviceLifeCycle* life_cycle = nullptr; |
| 306 EXPECT_CALL(*unlock_manager_, SetRemoteDeviceLifeCycle(_)) |
| 307 .WillOnce(SaveArg<0>(&life_cycle)); |
| 308 FocusUser(kUser1); |
| 309 EXPECT_EQ(kUser1, life_cycle->GetRemoteDevice().user_id); |
| 310 |
| 311 // Focusing the user again should be idempotent. The screenlock UI may call |
| 312 // focus on the same user multiple times. |
| 313 // SetRemoteDeviceLifeCycle() is only expected to be called once. |
| 314 FocusUser(kUser1); |
| 315 |
| 316 // The RemoteDeviceLifeCycle should be nulled upon destruction. |
| 317 EXPECT_CALL(*unlock_manager_, SetRemoteDeviceLifeCycle(nullptr)) |
| 318 .Times(AtLeast(1)); |
| 319 } |
| 320 |
| 304 TEST_F(ProximityAuthSystemTest, RestartSystem_UnregisteredUserFocused) { | 321 TEST_F(ProximityAuthSystemTest, RestartSystem_UnregisteredUserFocused) { |
| 305 FocusUser(kUser2); | 322 FocusUser(kUser2); |
| 306 | 323 |
| 307 EXPECT_CALL(*unlock_manager_, SetRemoteDeviceLifeCycle(nullptr)) | 324 EXPECT_CALL(*unlock_manager_, SetRemoteDeviceLifeCycle(nullptr)) |
| 308 .Times(AnyNumber()); | 325 .Times(AnyNumber()); |
| 309 proximity_auth_system_->Stop(); | 326 proximity_auth_system_->Stop(); |
| 310 proximity_auth_system_->Start(); | 327 proximity_auth_system_->Start(); |
| 311 EXPECT_FALSE(life_cycle()); | 328 EXPECT_FALSE(life_cycle()); |
| 312 } | 329 } |
| 313 | 330 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 SimulateSuspend(); | 384 SimulateSuspend(); |
| 368 } | 385 } |
| 369 | 386 |
| 370 EXPECT_EQ(kUser1, life_cycle()->GetRemoteDevice().user_id); | 387 EXPECT_EQ(kUser1, life_cycle()->GetRemoteDevice().user_id); |
| 371 | 388 |
| 372 EXPECT_CALL(*unlock_manager_, SetRemoteDeviceLifeCycle(nullptr)) | 389 EXPECT_CALL(*unlock_manager_, SetRemoteDeviceLifeCycle(nullptr)) |
| 373 .Times(AtLeast(1)); | 390 .Times(AtLeast(1)); |
| 374 } | 391 } |
| 375 | 392 |
| 376 } // namespace proximity_auth | 393 } // namespace proximity_auth |
| OLD | NEW |