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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 | 6 |
7 #include "chrome/browser/password_manager/chrome_password_manager_client.h" | 7 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
8 | 8 |
9 #include "chrome/common/chrome_version_info.h" | 9 #include "chrome/common/chrome_version_info.h" |
10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 EXPECT_TRUE(client->IsLoggingActive()); | 130 EXPECT_TRUE(client->IsLoggingActive()); |
131 EXPECT_TRUE(WasLoggingActivationMessageSent(&logging_active)); | 131 EXPECT_TRUE(WasLoggingActivationMessageSent(&logging_active)); |
132 EXPECT_TRUE(logging_active); | 132 EXPECT_TRUE(logging_active); |
133 | 133 |
134 service_->UnregisterReceiver(&receiver_); | 134 service_->UnregisterReceiver(&receiver_); |
135 EXPECT_FALSE(client->IsLoggingActive()); | 135 EXPECT_FALSE(client->IsLoggingActive()); |
136 EXPECT_TRUE(WasLoggingActivationMessageSent(&logging_active)); | 136 EXPECT_TRUE(WasLoggingActivationMessageSent(&logging_active)); |
137 EXPECT_FALSE(logging_active); | 137 EXPECT_FALSE(logging_active); |
138 } | 138 } |
139 | 139 |
| 140 TEST_F(ChromePasswordManagerClientTest, AnswerToPingsAboutLoggingState_Active) { |
| 141 service_->RegisterReceiver(&receiver_); |
| 142 |
| 143 process()->sink().ClearMessages(); |
| 144 |
| 145 // Ping the client for logging activity update. |
| 146 AutofillHostMsg_UpdateLoggingState msg(0); |
| 147 static_cast<IPC::Listener*>(GetClient())->OnMessageReceived(msg); |
| 148 |
| 149 bool logging_active = false; |
| 150 EXPECT_TRUE(WasLoggingActivationMessageSent(&logging_active)); |
| 151 EXPECT_TRUE(logging_active); |
| 152 |
| 153 service_->UnregisterReceiver(&receiver_); |
| 154 } |
| 155 |
| 156 TEST_F(ChromePasswordManagerClientTest, |
| 157 AnswerToPingsAboutLoggingState_Inactive) { |
| 158 process()->sink().ClearMessages(); |
| 159 |
| 160 // Ping the client for logging activity update. |
| 161 AutofillHostMsg_UpdateLoggingState msg(0); |
| 162 static_cast<IPC::Listener*>(GetClient())->OnMessageReceived(msg); |
| 163 |
| 164 bool logging_active = true; |
| 165 EXPECT_TRUE(WasLoggingActivationMessageSent(&logging_active)); |
| 166 EXPECT_FALSE(logging_active); |
| 167 } |
| 168 |
140 TEST_F(ChromePasswordManagerClientTest, | 169 TEST_F(ChromePasswordManagerClientTest, |
141 IsAutomaticPasswordSavingEnabledDefaultBehaviourTest) { | 170 IsAutomaticPasswordSavingEnabledDefaultBehaviourTest) { |
142 EXPECT_FALSE(GetClient()->IsAutomaticPasswordSavingEnabled()); | 171 EXPECT_FALSE(GetClient()->IsAutomaticPasswordSavingEnabled()); |
143 } | 172 } |
144 | 173 |
145 TEST_F(ChromePasswordManagerClientTest, | 174 TEST_F(ChromePasswordManagerClientTest, |
146 IsAutomaticPasswordSavingEnabledWhenFlagIsSetTest) { | 175 IsAutomaticPasswordSavingEnabledWhenFlagIsSetTest) { |
147 CommandLine::ForCurrentProcess()->AppendSwitch( | 176 CommandLine::ForCurrentProcess()->AppendSwitch( |
148 password_manager::switches::kEnableAutomaticPasswordSaving); | 177 password_manager::switches::kEnableAutomaticPasswordSaving); |
149 if (chrome::VersionInfo::GetChannel() == chrome::VersionInfo::CHANNEL_UNKNOWN) | 178 if (chrome::VersionInfo::GetChannel() == chrome::VersionInfo::CHANNEL_UNKNOWN) |
150 EXPECT_TRUE(GetClient()->IsAutomaticPasswordSavingEnabled()); | 179 EXPECT_TRUE(GetClient()->IsAutomaticPasswordSavingEnabled()); |
151 else | 180 else |
152 EXPECT_FALSE(GetClient()->IsAutomaticPasswordSavingEnabled()); | 181 EXPECT_FALSE(GetClient()->IsAutomaticPasswordSavingEnabled()); |
153 } | 182 } |
154 | 183 |
155 TEST_F(ChromePasswordManagerClientTest, LogToAReceiver) { | 184 TEST_F(ChromePasswordManagerClientTest, LogToAReceiver) { |
156 ChromePasswordManagerClient* client = GetClient(); | 185 ChromePasswordManagerClient* client = GetClient(); |
157 service_->RegisterReceiver(&receiver_); | 186 service_->RegisterReceiver(&receiver_); |
158 EXPECT_TRUE(client->IsLoggingActive()); | 187 EXPECT_TRUE(client->IsLoggingActive()); |
159 | 188 |
160 EXPECT_CALL(receiver_, LogSavePasswordProgress(kTestText)).Times(1); | 189 EXPECT_CALL(receiver_, LogSavePasswordProgress(kTestText)).Times(1); |
161 client->LogSavePasswordProgress(kTestText); | 190 client->LogSavePasswordProgress(kTestText); |
162 | 191 |
163 service_->UnregisterReceiver(&receiver_); | 192 service_->UnregisterReceiver(&receiver_); |
164 EXPECT_FALSE(client->IsLoggingActive()); | 193 EXPECT_FALSE(client->IsLoggingActive()); |
165 } | 194 } |
OLD | NEW |