Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: ash/login/lock_screen_controller_unittest.cc

Issue 2876673002: mojo api for view based lockscreen (Closed)
Patch Set: comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_++;
xiyuan 2017/05/16 18:22:25 nit: pre-inc, i.e. ++autentication_requests_count_
xiaoyinh(OOO Sep 11-29) 2017/05/16 21:11:30 Done.
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 class LockScreenControllerTest : public test::AshTestBase {
44 protected:
45 LockScreenControllerTest() {}
James Cook 2017/05/16 20:05:02 nit: = default Also, you need ~LockScreenControll
xiaoyinh(OOO Sep 11-29) 2017/05/16 21:11:30 This has been simplified as using LockScreenContr
46
47 void SetUp() override {
xiyuan 2017/05/16 18:22:25 nit: // test::AshTestBase:
xiaoyinh(OOO Sep 11-29) 2017/05/16 21:11:31 This has been simplified as using LockScreenContr
48 test::AshTestBase::SetUp();
49 chromeos::SystemSaltGetter::Initialize();
xiyuan 2017/05/16 18:22:25 This probably should go into AshTestHelper::SetUp[
xiaoyinh(OOO Sep 11-29) 2017/05/16 21:11:30 Done. Thanks for the information!
50 }
51 void TearDown() override {
52 chromeos::SystemSaltGetter::Shutdown();
53 test::AshTestBase::TearDown();
54 }
55 };
56
57 } // namespace
58
59 TEST_F(LockScreenControllerTest, RequestAuthentication) {
60 LockScreenController* lock_screen_controller =
61 Shell::Get()->lock_screen_controller();
62 TestLockScreenClient lock_screen_client;
63 lock_screen_controller->SetClient(
64 lock_screen_client.CreateInterfacePtrAndBind());
65 EXPECT_EQ(0, lock_screen_client.authentication_requests_count());
66
67 AccountId id = AccountId::FromUserEmail("user1@test.com");
68 lock_screen_controller->AuthenticateUser(id, std::string(), false);
69 base::RunLoop().RunUntilIdle();
70 EXPECT_EQ(1, lock_screen_client.authentication_requests_count());
71 }
James Cook 2017/05/16 20:05:02 Hooray for a simple, clean test!
xiaoyinh(OOO Sep 11-29) 2017/05/16 21:11:30 Thanks!
72
73 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698