OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ash/login/lock_screen_controller.h" |
| 6 |
| 7 #include "ash/shell.h" |
| 8 #include "ash/test/ash_test_base.h" |
| 9 #include "base/run_loop.h" |
| 10 #include "chromeos/cryptohome/system_salt_getter.h" |
| 11 |
| 12 namespace ash { |
| 13 |
| 14 namespace { |
| 15 |
| 16 class TestLockScreenClient : public mojom::LockScreenClient { |
| 17 public: |
| 18 TestLockScreenClient() : binding_(this) {} |
| 19 ~TestLockScreenClient() override = default; |
| 20 |
| 21 mojom::LockScreenClientPtr CreateInterfacePtrAndBind() { |
| 22 return binding_.CreateInterfacePtrAndBind(); |
| 23 } |
| 24 |
| 25 // mojom::LockScreenClient: |
| 26 void AuthenticateUser(const AccountId& account_id, |
| 27 const std::string& password, |
| 28 bool authenticated_by_pin) override { |
| 29 ++autentication_requests_count_; |
| 30 } |
| 31 |
| 32 int authentication_requests_count() const { |
| 33 return autentication_requests_count_; |
| 34 } |
| 35 |
| 36 private: |
| 37 mojo::Binding<ash::mojom::LockScreenClient> binding_; |
| 38 int autentication_requests_count_ = 0; |
| 39 |
| 40 DISALLOW_COPY_AND_ASSIGN(TestLockScreenClient); |
| 41 }; |
| 42 |
| 43 using LockScreenControllerTest = test::AshTestBase; |
| 44 |
| 45 } // namespace |
| 46 |
| 47 TEST_F(LockScreenControllerTest, RequestAuthentication) { |
| 48 LockScreenController* lock_screen_controller = |
| 49 Shell::Get()->lock_screen_controller(); |
| 50 TestLockScreenClient lock_screen_client; |
| 51 lock_screen_controller->SetClient( |
| 52 lock_screen_client.CreateInterfacePtrAndBind()); |
| 53 EXPECT_EQ(0, lock_screen_client.authentication_requests_count()); |
| 54 |
| 55 AccountId id = AccountId::FromUserEmail("user1@test.com"); |
| 56 lock_screen_controller->AuthenticateUser(id, std::string(), false); |
| 57 base::RunLoop().RunUntilIdle(); |
| 58 EXPECT_EQ(1, lock_screen_client.authentication_requests_count()); |
| 59 } |
| 60 |
| 61 } // namespace ash |
OLD | NEW |