Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "ash/login/lock_screen_controller.h" | 5 #include "ash/login/lock_screen_controller.h" |
| 6 | 6 |
| 7 #include "ash/login/mock_lock_screen_client.h" | 7 #include "ash/login/mock_lock_screen_client.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 | 11 |
| 12 using ::testing::_; | 12 using ::testing::_; |
| 13 | 13 |
| 14 namespace ash { | 14 namespace ash { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 using LockScreenControllerTest = test::AshTestBase; | 17 using LockScreenControllerTest = test::AshTestBase; |
| 18 } // namespace | 18 } // namespace |
|
James Cook
2017/06/08 19:47:12
nit: This whole file should go in the anonymous na
jdufault
2017/06/08 22:23:14
Done, there doesn't seem to be a strong consensus
| |
| 19 | 19 |
| 20 TEST_F(LockScreenControllerTest, RequestAuthentication) { | 20 TEST_F(LockScreenControllerTest, RequestAuthentication) { |
| 21 LockScreenController* controller = Shell::Get()->lock_screen_controller(); | 21 LockScreenController* controller = Shell::Get()->lock_screen_controller(); |
| 22 std::unique_ptr<MockLockScreenClient> client = BindMockLockScreenClient(); | 22 std::unique_ptr<MockLockScreenClient> client = BindMockLockScreenClient(); |
| 23 | 23 |
| 24 AccountId id = AccountId::FromUserEmail("user1@test.com"); | 24 AccountId id = AccountId::FromUserEmail("user1@test.com"); |
| 25 | 25 |
| 26 // We hardcode the hashed password. This is fine because the password hash | 26 // We hardcode the hashed password. This is fine because the password hash |
| 27 // algorithm should never accidently change; if it does we will need to | 27 // algorithm should never accidentally change; if it does we will need to |
| 28 // have cryptohome migration code and one failing test isn't a problem. | 28 // have cryptohome migration code and one failing test isn't a problem. |
| 29 std::string password = "password"; | 29 std::string password = "password"; |
| 30 std::string hashed_password = "40c7b00f3bccc7675ec5b732de4bfbe4"; | 30 std::string hashed_password = "40c7b00f3bccc7675ec5b732de4bfbe4"; |
| 31 EXPECT_NE(password, hashed_password); | 31 EXPECT_NE(password, hashed_password); |
| 32 | 32 |
| 33 // Verify AuthenticateUser mojo call is run with the same account id, a | 33 // Verify AuthenticateUser mojo call is run with the same account id, a |
| 34 // (hashed) password, and the correct PIN state. | 34 // (hashed) password, and the correct PIN state. |
| 35 EXPECT_CALL(*client, AuthenticateUser(id, hashed_password, false)); | 35 EXPECT_CALL(*client, AuthenticateUser_(id, hashed_password, false, _)); |
| 36 controller->AuthenticateUser(id, password, false); | 36 controller->AuthenticateUser( |
| 37 id, password, false, mojom::LockScreenClient::AuthenticateUserCallback()); | |
| 37 | 38 |
| 38 base::RunLoop().RunUntilIdle(); | 39 base::RunLoop().RunUntilIdle(); |
| 39 } | 40 } |
|
James Cook
2017/06/08 19:47:12
I think this test (or another test) should verify
jdufault
2017/06/08 22:23:14
Done.
| |
| 40 | 41 |
| 41 TEST_F(LockScreenControllerTest, RequestEasyUnlock) { | 42 TEST_F(LockScreenControllerTest, RequestEasyUnlock) { |
| 42 LockScreenController* controller = Shell::Get()->lock_screen_controller(); | 43 LockScreenController* controller = Shell::Get()->lock_screen_controller(); |
| 43 std::unique_ptr<MockLockScreenClient> client = BindMockLockScreenClient(); | 44 std::unique_ptr<MockLockScreenClient> client = BindMockLockScreenClient(); |
| 44 | 45 |
| 45 AccountId id = AccountId::FromUserEmail("user1@test.com"); | 46 AccountId id = AccountId::FromUserEmail("user1@test.com"); |
| 46 | 47 |
| 47 // Verify AttemptUnlock mojo call is run with the same account id. | 48 // Verify AttemptUnlock mojo call is run with the same account id. |
| 48 EXPECT_CALL(*client, AttemptUnlock(id)); | 49 EXPECT_CALL(*client, AttemptUnlock(id)); |
| 49 controller->AttemptUnlock(id); | 50 controller->AttemptUnlock(id); |
| 50 base::RunLoop().RunUntilIdle(); | 51 base::RunLoop().RunUntilIdle(); |
| 51 | 52 |
| 52 // Verify HardlockPod mojo call is run with the same account id. | 53 // Verify HardlockPod mojo call is run with the same account id. |
| 53 EXPECT_CALL(*client, HardlockPod(id)); | 54 EXPECT_CALL(*client, HardlockPod(id)); |
| 54 controller->HardlockPod(id); | 55 controller->HardlockPod(id); |
| 55 base::RunLoop().RunUntilIdle(); | 56 base::RunLoop().RunUntilIdle(); |
| 56 | 57 |
| 57 // Verify RecordClickOnLockIcon mojo call is run with the same account id. | 58 // Verify RecordClickOnLockIcon mojo call is run with the same account id. |
| 58 EXPECT_CALL(*client, RecordClickOnLockIcon(id)); | 59 EXPECT_CALL(*client, RecordClickOnLockIcon(id)); |
| 59 controller->RecordClickOnLockIcon(id); | 60 controller->RecordClickOnLockIcon(id); |
| 60 base::RunLoop().RunUntilIdle(); | 61 base::RunLoop().RunUntilIdle(); |
| 61 } | 62 } |
| 62 | 63 |
| 63 } // namespace ash | 64 } // namespace ash |
| OLD | NEW |