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

Side by Side Diff: chrome/browser/password_manager/chrome_password_manager_client_unittest.cc

Issue 816403003: Make callers of CommandLine use it via the base:: namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years, 12 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
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 "chrome/browser/password_manager/chrome_password_manager_client.h" 5 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/sync/profile_sync_service_factory.h" 10 #include "chrome/browser/sync/profile_sync_service_factory.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 EXPECT_FALSE(logging_active); 196 EXPECT_FALSE(logging_active);
197 } 197 }
198 198
199 TEST_F(ChromePasswordManagerClientTest, 199 TEST_F(ChromePasswordManagerClientTest,
200 IsAutomaticPasswordSavingEnabledDefaultBehaviourTest) { 200 IsAutomaticPasswordSavingEnabledDefaultBehaviourTest) {
201 EXPECT_FALSE(GetClient()->IsAutomaticPasswordSavingEnabled()); 201 EXPECT_FALSE(GetClient()->IsAutomaticPasswordSavingEnabled());
202 } 202 }
203 203
204 TEST_F(ChromePasswordManagerClientTest, 204 TEST_F(ChromePasswordManagerClientTest,
205 IsAutomaticPasswordSavingEnabledWhenFlagIsSetTest) { 205 IsAutomaticPasswordSavingEnabledWhenFlagIsSetTest) {
206 CommandLine::ForCurrentProcess()->AppendSwitch( 206 base::CommandLine::ForCurrentProcess()->AppendSwitch(
207 password_manager::switches::kEnableAutomaticPasswordSaving); 207 password_manager::switches::kEnableAutomaticPasswordSaving);
208 if (chrome::VersionInfo::GetChannel() == chrome::VersionInfo::CHANNEL_UNKNOWN) 208 if (chrome::VersionInfo::GetChannel() == chrome::VersionInfo::CHANNEL_UNKNOWN)
209 EXPECT_TRUE(GetClient()->IsAutomaticPasswordSavingEnabled()); 209 EXPECT_TRUE(GetClient()->IsAutomaticPasswordSavingEnabled());
210 else 210 else
211 EXPECT_FALSE(GetClient()->IsAutomaticPasswordSavingEnabled()); 211 EXPECT_FALSE(GetClient()->IsAutomaticPasswordSavingEnabled());
212 } 212 }
213 213
214 TEST_F(ChromePasswordManagerClientTest, LogToAReceiver) { 214 TEST_F(ChromePasswordManagerClientTest, LogToAReceiver) {
215 ChromePasswordManagerClient* client = GetClient(); 215 ChromePasswordManagerClient* client = GetClient();
216 service_->RegisterReceiver(&receiver_); 216 service_->RegisterReceiver(&receiver_);
(...skipping 14 matching lines...) Expand all
231 EXPECT_FALSE(client->ShouldAskUserToSubmitURL(GURL("https://hostname.com/"))); 231 EXPECT_FALSE(client->ShouldAskUserToSubmitURL(GURL("https://hostname.com/")));
232 } 232 }
233 233
234 TEST_F(ChromePasswordManagerClientTest, ShouldAskUserToSubmitURLEmptyURL) { 234 TEST_F(ChromePasswordManagerClientTest, ShouldAskUserToSubmitURLEmptyURL) {
235 ChromePasswordManagerClient* client = GetClient(); 235 ChromePasswordManagerClient* client = GetClient();
236 EXPECT_FALSE(client->ShouldAskUserToSubmitURL(GURL::EmptyGURL())); 236 EXPECT_FALSE(client->ShouldAskUserToSubmitURL(GURL::EmptyGURL()));
237 } 237 }
238 238
239 TEST_F(ChromePasswordManagerClientTest, ShouldFilterAutofillResult_Reauth) { 239 TEST_F(ChromePasswordManagerClientTest, ShouldFilterAutofillResult_Reauth) {
240 // Make client disallow only reauth requests. 240 // Make client disallow only reauth requests.
241 CommandLine* command_line = CommandLine::ForCurrentProcess(); 241 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
242 command_line->AppendSwitch( 242 command_line->AppendSwitch(
243 password_manager::switches::kDisallowAutofillSyncCredentialForReauth); 243 password_manager::switches::kDisallowAutofillSyncCredentialForReauth);
244 scoped_ptr<TestChromePasswordManagerClient> client( 244 scoped_ptr<TestChromePasswordManagerClient> client(
245 new TestChromePasswordManagerClient(web_contents())); 245 new TestChromePasswordManagerClient(web_contents()));
246 autofill::PasswordForm form; 246 autofill::PasswordForm form;
247 247
248 client->set_is_sync_account_credential(false); 248 client->set_is_sync_account_credential(false);
249 NavigateAndCommit( 249 NavigateAndCommit(
250 GURL("https://accounts.google.com/login?rart=123&continue=blah")); 250 GURL("https://accounts.google.com/login?rart=123&continue=blah"));
251 EXPECT_FALSE(client->ShouldFilterAutofillResult(form)); 251 EXPECT_FALSE(client->ShouldFilterAutofillResult(form));
(...skipping 19 matching lines...) Expand all
271 // Normally the client should allow any credentials through, even if they 271 // Normally the client should allow any credentials through, even if they
272 // are the sync credential. 272 // are the sync credential.
273 scoped_ptr<TestChromePasswordManagerClient> client( 273 scoped_ptr<TestChromePasswordManagerClient> client(
274 new TestChromePasswordManagerClient(web_contents())); 274 new TestChromePasswordManagerClient(web_contents()));
275 autofill::PasswordForm form; 275 autofill::PasswordForm form;
276 client->set_is_sync_account_credential(true); 276 client->set_is_sync_account_credential(true);
277 NavigateAndCommit(GURL("https://accounts.google.com/Login")); 277 NavigateAndCommit(GURL("https://accounts.google.com/Login"));
278 EXPECT_FALSE(client->ShouldFilterAutofillResult(form)); 278 EXPECT_FALSE(client->ShouldFilterAutofillResult(form));
279 279
280 // Adding disallow switch should cause sync credential to be filtered. 280 // Adding disallow switch should cause sync credential to be filtered.
281 CommandLine* command_line = CommandLine::ForCurrentProcess(); 281 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
282 command_line->AppendSwitch( 282 command_line->AppendSwitch(
283 password_manager::switches::kDisallowAutofillSyncCredential); 283 password_manager::switches::kDisallowAutofillSyncCredential);
284 client.reset(new TestChromePasswordManagerClient(web_contents())); 284 client.reset(new TestChromePasswordManagerClient(web_contents()));
285 client->set_is_sync_account_credential(true); 285 client->set_is_sync_account_credential(true);
286 NavigateAndCommit(GURL("https://accounts.google.com/Login")); 286 NavigateAndCommit(GURL("https://accounts.google.com/Login"));
287 EXPECT_TRUE(client->ShouldFilterAutofillResult(form)); 287 EXPECT_TRUE(client->ShouldFilterAutofillResult(form));
288 } 288 }
289 289
290 TEST_F(ChromePasswordManagerClientTest, 290 TEST_F(ChromePasswordManagerClientTest,
291 IsPasswordManagerEnabledForCurrentPage) { 291 IsPasswordManagerEnabledForCurrentPage) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 394
395 // Again, without a custom passphrase. 395 // Again, without a custom passphrase.
396 EXPECT_CALL(*mock_sync_service, IsUsingSecondaryPassphrase()) 396 EXPECT_CALL(*mock_sync_service, IsUsingSecondaryPassphrase())
397 .WillRepeatedly(Return(false)); 397 .WillRepeatedly(Return(false));
398 398
399 EXPECT_FALSE( 399 EXPECT_FALSE(
400 client->IsPasswordSyncEnabled(password_manager::ONLY_CUSTOM_PASSPHRASE)); 400 client->IsPasswordSyncEnabled(password_manager::ONLY_CUSTOM_PASSPHRASE));
401 EXPECT_FALSE(client->IsPasswordSyncEnabled( 401 EXPECT_FALSE(client->IsPasswordSyncEnabled(
402 password_manager::WITHOUT_CUSTOM_PASSPHRASE)); 402 password_manager::WITHOUT_CUSTOM_PASSPHRASE));
403 } 403 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698