Chromium Code Reviews| 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 indempotent. 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 EXPECT_CALL(*unlock_manager_, SetRemoteDeviceLifeCycle(nullptr)) | |
|
Ryan Hansberry
2017/05/09 02:51:43
n00b question: I've generally been told that EXPEC
Tim Song
2017/05/10 18:11:16
Ah, this EXPECT_CALL is to catch the call when the
Ryan Hansberry
2017/05/15 15:48:05
Please update the comment "SetRemoteDeviceLifeCycl
Tim Song
2017/05/15 18:30:48
Done.
| |
| 317 .Times(AtLeast(1)); | |
| 318 } | |
| 319 | |
| 304 TEST_F(ProximityAuthSystemTest, RestartSystem_UnregisteredUserFocused) { | 320 TEST_F(ProximityAuthSystemTest, RestartSystem_UnregisteredUserFocused) { |
| 305 FocusUser(kUser2); | 321 FocusUser(kUser2); |
| 306 | 322 |
| 307 EXPECT_CALL(*unlock_manager_, SetRemoteDeviceLifeCycle(nullptr)) | 323 EXPECT_CALL(*unlock_manager_, SetRemoteDeviceLifeCycle(nullptr)) |
| 308 .Times(AnyNumber()); | 324 .Times(AnyNumber()); |
| 309 proximity_auth_system_->Stop(); | 325 proximity_auth_system_->Stop(); |
| 310 proximity_auth_system_->Start(); | 326 proximity_auth_system_->Start(); |
| 311 EXPECT_FALSE(life_cycle()); | 327 EXPECT_FALSE(life_cycle()); |
| 312 } | 328 } |
| 313 | 329 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 SimulateSuspend(); | 383 SimulateSuspend(); |
| 368 } | 384 } |
| 369 | 385 |
| 370 EXPECT_EQ(kUser1, life_cycle()->GetRemoteDevice().user_id); | 386 EXPECT_EQ(kUser1, life_cycle()->GetRemoteDevice().user_id); |
| 371 | 387 |
| 372 EXPECT_CALL(*unlock_manager_, SetRemoteDeviceLifeCycle(nullptr)) | 388 EXPECT_CALL(*unlock_manager_, SetRemoteDeviceLifeCycle(nullptr)) |
| 373 .Times(AtLeast(1)); | 389 .Times(AtLeast(1)); |
| 374 } | 390 } |
| 375 | 391 |
| 376 } // namespace proximity_auth | 392 } // namespace proximity_auth |
| OLD | NEW |