OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/password_manager/content/browser/content_password_manager_d
river.h" | 5 #include "components/password_manager/content/browser/content_password_manager_d
river.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "components/autofill/content/common/autofill_agent.mojom.h" | 10 #include "components/autofill/content/common/autofill_agent.mojom.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 } | 124 } |
125 | 125 |
126 protected: | 126 protected: |
127 MockLogManager log_manager_; | 127 MockLogManager log_manager_; |
128 MockPasswordManagerClient password_manager_client_; | 128 MockPasswordManagerClient password_manager_client_; |
129 autofill::TestAutofillClient autofill_client_; | 129 autofill::TestAutofillClient autofill_client_; |
130 | 130 |
131 FakePasswordAutofillAgent fake_agent_; | 131 FakePasswordAutofillAgent fake_agent_; |
132 }; | 132 }; |
133 | 133 |
134 TEST_P(ContentPasswordManagerDriverTest, | 134 TEST_P(ContentPasswordManagerDriverTest, SendLoggingStateInCtor) { |
135 AnswerToNotificationsAboutLoggingState) { | |
136 const bool should_allow_logging = GetParam(); | 135 const bool should_allow_logging = GetParam(); |
| 136 EXPECT_CALL(log_manager_, IsLoggingActive()) |
| 137 .WillRepeatedly(Return(should_allow_logging)); |
137 std::unique_ptr<ContentPasswordManagerDriver> driver( | 138 std::unique_ptr<ContentPasswordManagerDriver> driver( |
138 new ContentPasswordManagerDriver(main_rfh(), &password_manager_client_, | 139 new ContentPasswordManagerDriver(main_rfh(), &password_manager_client_, |
139 &autofill_client_)); | 140 &autofill_client_)); |
140 | 141 |
141 EXPECT_CALL(log_manager_, IsLoggingActive()) | |
142 .WillRepeatedly(Return(should_allow_logging)); | |
143 driver->SendLoggingAvailability(); | |
144 if (should_allow_logging) { | 142 if (should_allow_logging) { |
145 bool logging_activated = false; | 143 bool logging_activated = false; |
146 EXPECT_TRUE(WasLoggingActivationMessageSent(&logging_activated)); | 144 EXPECT_TRUE(WasLoggingActivationMessageSent(&logging_activated)); |
147 EXPECT_TRUE(logging_activated); | 145 EXPECT_TRUE(logging_activated); |
148 } else { | 146 } else { |
149 bool logging_activated = true; | 147 bool logging_activated = true; |
150 EXPECT_TRUE(WasLoggingActivationMessageSent(&logging_activated)); | 148 EXPECT_TRUE(WasLoggingActivationMessageSent(&logging_activated)); |
151 EXPECT_FALSE(logging_activated); | 149 EXPECT_FALSE(logging_activated); |
152 } | 150 } |
153 } | 151 } |
154 | 152 |
155 TEST_P(ContentPasswordManagerDriverTest, AnswerToIPCPingsAboutLoggingState) { | 153 TEST_P(ContentPasswordManagerDriverTest, SendLoggingStateAfterLogManagerReady) { |
156 const bool should_allow_logging = GetParam(); | 154 const bool should_allow_logging = GetParam(); |
| 155 EXPECT_CALL(password_manager_client_, GetLogManager()) |
| 156 .WillOnce(Return(nullptr)); |
157 std::unique_ptr<ContentPasswordManagerDriver> driver( | 157 std::unique_ptr<ContentPasswordManagerDriver> driver( |
158 new ContentPasswordManagerDriver(main_rfh(), &password_manager_client_, | 158 new ContentPasswordManagerDriver(main_rfh(), &password_manager_client_, |
159 &autofill_client_)); | 159 &autofill_client_)); |
| 160 // Because log manager is not ready yet, should have no logging state sent. |
| 161 EXPECT_FALSE(WasLoggingActivationMessageSent(nullptr)); |
160 | 162 |
| 163 // Log manager is ready, send logging state actually. |
| 164 EXPECT_CALL(password_manager_client_, GetLogManager()) |
| 165 .WillOnce(Return(&log_manager_)); |
161 EXPECT_CALL(log_manager_, IsLoggingActive()) | 166 EXPECT_CALL(log_manager_, IsLoggingActive()) |
162 .WillRepeatedly(Return(should_allow_logging)); | 167 .WillRepeatedly(Return(should_allow_logging)); |
163 driver->SendLoggingAvailability(); | 168 driver->SendLoggingAvailability(); |
164 WasLoggingActivationMessageSent(nullptr); | |
165 | |
166 // Ping the driver for logging activity update. | |
167 driver->PasswordAutofillAgentConstructed(); | |
168 | |
169 bool logging_activated = false; | 169 bool logging_activated = false; |
170 EXPECT_TRUE(WasLoggingActivationMessageSent(&logging_activated)); | 170 EXPECT_TRUE(WasLoggingActivationMessageSent(&logging_activated)); |
171 EXPECT_EQ(should_allow_logging, logging_activated); | 171 EXPECT_EQ(should_allow_logging, logging_activated); |
172 } | 172 } |
173 | 173 |
174 // Tests that password visibility notifications are forwarded to the | 174 // Tests that password visibility notifications are forwarded to the |
175 // WebContents. | 175 // WebContents. |
176 TEST_P(ContentPasswordManagerDriverTest, PasswordVisibility) { | 176 TEST_P(ContentPasswordManagerDriverTest, PasswordVisibility) { |
177 std::unique_ptr<ContentPasswordManagerDriver> driver( | 177 std::unique_ptr<ContentPasswordManagerDriver> driver( |
178 new ContentPasswordManagerDriver(main_rfh(), &password_manager_client_, | 178 new ContentPasswordManagerDriver(main_rfh(), &password_manager_client_, |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 old_rfh_tester->SimulateSwapOutACK(); | 364 old_rfh_tester->SimulateSwapOutACK(); |
365 EXPECT_TRUE(!!(entry->GetSSL().content_status & | 365 EXPECT_TRUE(!!(entry->GetSSL().content_status & |
366 content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP)); | 366 content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP)); |
367 } | 367 } |
368 | 368 |
369 INSTANTIATE_TEST_CASE_P(, | 369 INSTANTIATE_TEST_CASE_P(, |
370 ContentPasswordManagerDriverTest, | 370 ContentPasswordManagerDriverTest, |
371 testing::Values(true, false)); | 371 testing::Values(true, false)); |
372 | 372 |
373 } // namespace password_manager | 373 } // namespace password_manager |
OLD | NEW |