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 "chrome/browser/password_manager/chrome_password_manager_client.h" | 5 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 profile()->ForceIncognito(false); | 298 profile()->ForceIncognito(false); |
299 EXPECT_FALSE(client->IsOffTheRecord()); | 299 EXPECT_FALSE(client->IsOffTheRecord()); |
300 } | 300 } |
301 | 301 |
302 TEST_F(ChromePasswordManagerClientTest, | 302 TEST_F(ChromePasswordManagerClientTest, |
303 SavingDependsOnManagerEnabledPreference) { | 303 SavingDependsOnManagerEnabledPreference) { |
304 // Test that saving passwords depends on the password manager enabled | 304 // Test that saving passwords depends on the password manager enabled |
305 // preference. | 305 // preference. |
306 ChromePasswordManagerClient* client = GetClient(); | 306 ChromePasswordManagerClient* client = GetClient(); |
307 prefs()->SetUserPref(password_manager::prefs::kCredentialsEnableService, | 307 prefs()->SetUserPref(password_manager::prefs::kCredentialsEnableService, |
308 new base::FundamentalValue(true)); | 308 new base::Value(true)); |
309 EXPECT_TRUE(client->IsSavingAndFillingEnabledForCurrentPage()); | 309 EXPECT_TRUE(client->IsSavingAndFillingEnabledForCurrentPage()); |
310 prefs()->SetUserPref(password_manager::prefs::kCredentialsEnableService, | 310 prefs()->SetUserPref(password_manager::prefs::kCredentialsEnableService, |
311 new base::FundamentalValue(false)); | 311 new base::Value(false)); |
312 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); | 312 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); |
313 } | 313 } |
314 | 314 |
315 TEST_F(ChromePasswordManagerClientTest, SavingAndFillingEnabledConditionsTest) { | 315 TEST_F(ChromePasswordManagerClientTest, SavingAndFillingEnabledConditionsTest) { |
316 std::unique_ptr<WebContents> test_web_contents( | 316 std::unique_ptr<WebContents> test_web_contents( |
317 content::WebContentsTester::CreateTestWebContents( | 317 content::WebContentsTester::CreateTestWebContents( |
318 web_contents()->GetBrowserContext(), nullptr)); | 318 web_contents()->GetBrowserContext(), nullptr)); |
319 std::unique_ptr<MockChromePasswordManagerClient> client( | 319 std::unique_ptr<MockChromePasswordManagerClient> client( |
320 new MockChromePasswordManagerClient(test_web_contents.get())); | 320 new MockChromePasswordManagerClient(test_web_contents.get())); |
321 // Functionality disabled if there is SSL errors. | 321 // Functionality disabled if there is SSL errors. |
322 EXPECT_CALL(*client, DidLastPageLoadEncounterSSLErrors()) | 322 EXPECT_CALL(*client, DidLastPageLoadEncounterSSLErrors()) |
323 .WillRepeatedly(Return(true)); | 323 .WillRepeatedly(Return(true)); |
324 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); | 324 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); |
325 EXPECT_FALSE(client->IsFillingEnabledForCurrentPage()); | 325 EXPECT_FALSE(client->IsFillingEnabledForCurrentPage()); |
326 | 326 |
327 // Functionality disabled if there are SSL errors and the manager itself is | 327 // Functionality disabled if there are SSL errors and the manager itself is |
328 // disabled. | 328 // disabled. |
329 prefs()->SetUserPref(password_manager::prefs::kCredentialsEnableService, | 329 prefs()->SetUserPref(password_manager::prefs::kCredentialsEnableService, |
330 new base::FundamentalValue(false)); | 330 new base::Value(false)); |
331 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); | 331 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); |
332 EXPECT_FALSE(client->IsFillingEnabledForCurrentPage()); | 332 EXPECT_FALSE(client->IsFillingEnabledForCurrentPage()); |
333 | 333 |
334 // Functionality disabled if there are no SSL errors, but the manager itself | 334 // Functionality disabled if there are no SSL errors, but the manager itself |
335 // is disabled. | 335 // is disabled. |
336 EXPECT_CALL(*client, DidLastPageLoadEncounterSSLErrors()) | 336 EXPECT_CALL(*client, DidLastPageLoadEncounterSSLErrors()) |
337 .WillRepeatedly(Return(false)); | 337 .WillRepeatedly(Return(false)); |
338 prefs()->SetUserPref(password_manager::prefs::kCredentialsEnableService, | 338 prefs()->SetUserPref(password_manager::prefs::kCredentialsEnableService, |
339 new base::FundamentalValue(false)); | 339 new base::Value(false)); |
340 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); | 340 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); |
341 EXPECT_TRUE(client->IsFillingEnabledForCurrentPage()); | 341 EXPECT_TRUE(client->IsFillingEnabledForCurrentPage()); |
342 | 342 |
343 // Functionality enabled if there are no SSL errors and the manager is | 343 // Functionality enabled if there are no SSL errors and the manager is |
344 // enabled. | 344 // enabled. |
345 EXPECT_CALL(*client, DidLastPageLoadEncounterSSLErrors()) | 345 EXPECT_CALL(*client, DidLastPageLoadEncounterSSLErrors()) |
346 .WillRepeatedly(Return(false)); | 346 .WillRepeatedly(Return(false)); |
347 prefs()->SetUserPref(password_manager::prefs::kCredentialsEnableService, | 347 prefs()->SetUserPref(password_manager::prefs::kCredentialsEnableService, |
348 new base::FundamentalValue(true)); | 348 new base::Value(true)); |
349 EXPECT_TRUE(client->IsSavingAndFillingEnabledForCurrentPage()); | 349 EXPECT_TRUE(client->IsSavingAndFillingEnabledForCurrentPage()); |
350 EXPECT_TRUE(client->IsFillingEnabledForCurrentPage()); | 350 EXPECT_TRUE(client->IsFillingEnabledForCurrentPage()); |
351 | 351 |
352 // Functionality disabled in Incognito mode. | 352 // Functionality disabled in Incognito mode. |
353 profile()->ForceIncognito(true); | 353 profile()->ForceIncognito(true); |
354 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); | 354 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); |
355 EXPECT_TRUE(client->IsFillingEnabledForCurrentPage()); | 355 EXPECT_TRUE(client->IsFillingEnabledForCurrentPage()); |
356 | 356 |
357 // Functionality disabled in Incognito mode also when manager itself is | 357 // Functionality disabled in Incognito mode also when manager itself is |
358 // enabled. | 358 // enabled. |
359 prefs()->SetUserPref(password_manager::prefs::kCredentialsEnableService, | 359 prefs()->SetUserPref(password_manager::prefs::kCredentialsEnableService, |
360 new base::FundamentalValue(true)); | 360 new base::Value(true)); |
361 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); | 361 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); |
362 EXPECT_TRUE(client->IsFillingEnabledForCurrentPage()); | 362 EXPECT_TRUE(client->IsFillingEnabledForCurrentPage()); |
363 profile()->ForceIncognito(false); | 363 profile()->ForceIncognito(false); |
364 } | 364 } |
365 | 365 |
366 TEST_F(ChromePasswordManagerClientTest, GetLastCommittedEntryURL_Empty) { | 366 TEST_F(ChromePasswordManagerClientTest, GetLastCommittedEntryURL_Empty) { |
367 EXPECT_EQ(GURL::EmptyGURL(), GetClient()->GetLastCommittedEntryURL()); | 367 EXPECT_EQ(GURL::EmptyGURL(), GetClient()->GetLastCommittedEntryURL()); |
368 } | 368 } |
369 | 369 |
370 TEST_F(ChromePasswordManagerClientTest, GetLastCommittedEntryURL) { | 370 TEST_F(ChromePasswordManagerClientTest, GetLastCommittedEntryURL) { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 }; | 538 }; |
539 | 539 |
540 for (const TestCase& test_case : kTestCases) { | 540 for (const TestCase& test_case : kTestCases) { |
541 // CanShowBubbleOnURL currently only depends on the scheme. | 541 // CanShowBubbleOnURL currently only depends on the scheme. |
542 GURL url(base::StringPrintf("%s://example.org", test_case.scheme)); | 542 GURL url(base::StringPrintf("%s://example.org", test_case.scheme)); |
543 SCOPED_TRACE(url.possibly_invalid_spec()); | 543 SCOPED_TRACE(url.possibly_invalid_spec()); |
544 EXPECT_EQ(test_case.can_show_bubble, | 544 EXPECT_EQ(test_case.can_show_bubble, |
545 ChromePasswordManagerClient::CanShowBubbleOnURL(url)); | 545 ChromePasswordManagerClient::CanShowBubbleOnURL(url)); |
546 } | 546 } |
547 } | 547 } |
OLD | NEW |