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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 } | 36 } |
37 | 37 |
38 // Fake lock handler to be used in these tests. | 38 // Fake lock handler to be used in these tests. |
39 class TestLockHandler : public ScreenlockBridge::LockHandler { | 39 class TestLockHandler : public ScreenlockBridge::LockHandler { |
40 public: | 40 public: |
41 explicit TestLockHandler(const std::string& user_email) | 41 explicit TestLockHandler(const std::string& user_email) |
42 : user_email_(user_email), | 42 : user_email_(user_email), |
43 show_icon_count_(0u), | 43 show_icon_count_(0u), |
44 auth_type_(OFFLINE_PASSWORD) { | 44 auth_type_(OFFLINE_PASSWORD) { |
45 } | 45 } |
46 virtual ~TestLockHandler() {} | 46 ~TestLockHandler() override {} |
47 | 47 |
48 // ScreenlockBridge::LockHandler implementation: | 48 // ScreenlockBridge::LockHandler implementation: |
49 virtual void ShowBannerMessage(const base::string16& message) override { | 49 void ShowBannerMessage(const base::string16& message) override { |
50 ASSERT_FALSE(true) << "Should not be reached."; | 50 ASSERT_FALSE(true) << "Should not be reached."; |
51 } | 51 } |
52 | 52 |
53 virtual void ShowUserPodCustomIcon( | 53 void ShowUserPodCustomIcon( |
54 const std::string& user_email, | 54 const std::string& user_email, |
55 const ScreenlockBridge::UserPodCustomIconOptions& icon) override { | 55 const ScreenlockBridge::UserPodCustomIconOptions& icon) override { |
56 ASSERT_EQ(user_email_, user_email); | 56 ASSERT_EQ(user_email_, user_email); |
57 ++show_icon_count_; | 57 ++show_icon_count_; |
58 last_custom_icon_ = icon.ToDictionaryValue().Pass(); | 58 last_custom_icon_ = icon.ToDictionaryValue().Pass(); |
59 ValidateCustomIcon(); | 59 ValidateCustomIcon(); |
60 } | 60 } |
61 | 61 |
62 virtual void HideUserPodCustomIcon(const std::string& user_email) override { | 62 void HideUserPodCustomIcon(const std::string& user_email) override { |
63 ASSERT_EQ(user_email_, user_email); | 63 ASSERT_EQ(user_email_, user_email); |
64 last_custom_icon_.reset(); | 64 last_custom_icon_.reset(); |
65 } | 65 } |
66 | 66 |
67 virtual void EnableInput() override { | 67 void EnableInput() override { |
68 ASSERT_FALSE(true) << "Should not be reached."; | 68 ASSERT_FALSE(true) << "Should not be reached."; |
69 } | 69 } |
70 | 70 |
71 virtual void SetAuthType(const std::string& user_email, | 71 void SetAuthType(const std::string& user_email, |
72 AuthType auth_type, | 72 AuthType auth_type, |
73 const base::string16& auth_value) override { | 73 const base::string16& auth_value) override { |
74 ASSERT_EQ(user_email_, user_email); | 74 ASSERT_EQ(user_email_, user_email); |
75 // Generally, this is allowed, but EasyUnlockScreenlockStateHandler should | 75 // Generally, this is allowed, but EasyUnlockScreenlockStateHandler should |
76 // avoid resetting the same auth type. | 76 // avoid resetting the same auth type. |
77 EXPECT_NE(auth_type_, auth_type); | 77 EXPECT_NE(auth_type_, auth_type); |
78 | 78 |
79 auth_type_ = auth_type; | 79 auth_type_ = auth_type; |
80 auth_value_ = auth_value; | 80 auth_value_ = auth_value; |
81 } | 81 } |
82 | 82 |
83 virtual AuthType GetAuthType(const std::string& user_email) const override { | 83 AuthType GetAuthType(const std::string& user_email) const override { |
84 EXPECT_EQ(user_email_, user_email); | 84 EXPECT_EQ(user_email_, user_email); |
85 return auth_type_; | 85 return auth_type_; |
86 } | 86 } |
87 | 87 |
88 virtual void Unlock(const std::string& user_email) override { | 88 void Unlock(const std::string& user_email) override { |
89 ASSERT_FALSE(true) << "Should not be reached."; | 89 ASSERT_FALSE(true) << "Should not be reached."; |
90 } | 90 } |
91 | 91 |
92 virtual void AttemptEasySignin(const std::string& user_email, | 92 void AttemptEasySignin(const std::string& user_email, |
93 const std::string& secret, | 93 const std::string& secret, |
94 const std::string& key_label) override { | 94 const std::string& key_label) override { |
95 ASSERT_FALSE(true) << "Should not be reached."; | 95 ASSERT_FALSE(true) << "Should not be reached."; |
96 } | 96 } |
97 | 97 |
98 // Utility methods used by tests: | 98 // Utility methods used by tests: |
99 | 99 |
100 // Gets last set auth value. | 100 // Gets last set auth value. |
101 base::string16 GetAuthValue() const { | 101 base::string16 GetAuthValue() const { |
102 return auth_value_; | 102 return auth_value_; |
103 } | 103 } |
104 | 104 |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 | 741 |
742 state_handler_->ChangeState( | 742 state_handler_->ChangeState( |
743 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED); | 743 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED); |
744 EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount()); | 744 EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount()); |
745 EXPECT_TRUE(lock_handler_->HasCustomIcon()); | 745 EXPECT_TRUE(lock_handler_->HasCustomIcon()); |
746 EXPECT_EQ(ScreenlockBridge::LockHandler::OFFLINE_PASSWORD, | 746 EXPECT_EQ(ScreenlockBridge::LockHandler::OFFLINE_PASSWORD, |
747 lock_handler_->GetAuthType(user_email_)); | 747 lock_handler_->GetAuthType(user_email_)); |
748 } | 748 } |
749 | 749 |
750 } // namespace | 750 } // namespace |
OLD | NEW |