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

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

Issue 2352533003: [Autofill] Migrate ChromePasswordManagerClient<-->PasswordGenerationAgent IPCs to mojo. (Closed)
Patch Set: Address comments from Vaclav Created 4 years, 2 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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 21 matching lines...) Expand all
32 #include "components/password_manager/core/common/password_manager_features.h" 32 #include "components/password_manager/core/common/password_manager_features.h"
33 #include "components/password_manager/core/common/password_manager_pref_names.h" 33 #include "components/password_manager/core/common/password_manager_pref_names.h"
34 #include "components/prefs/pref_registry_simple.h" 34 #include "components/prefs/pref_registry_simple.h"
35 #include "components/prefs/pref_service.h" 35 #include "components/prefs/pref_service.h"
36 #include "components/prefs/testing_pref_service.h" 36 #include "components/prefs/testing_pref_service.h"
37 #include "components/sessions/content/content_record_password_state.h" 37 #include "components/sessions/content/content_record_password_state.h"
38 #include "components/syncable_prefs/testing_pref_service_syncable.h" 38 #include "components/syncable_prefs/testing_pref_service_syncable.h"
39 #include "components/version_info/version_info.h" 39 #include "components/version_info/version_info.h"
40 #include "content/public/browser/browser_context.h" 40 #include "content/public/browser/browser_context.h"
41 #include "content/public/browser/web_contents.h" 41 #include "content/public/browser/web_contents.h"
42 #include "content/public/test/web_contents_tester.h"
42 #include "mojo/public/cpp/bindings/binding.h" 43 #include "mojo/public/cpp/bindings/binding.h"
43 #include "services/shell/public/cpp/interface_provider.h" 44 #include "services/shell/public/cpp/interface_provider.h"
44 #include "testing/gmock/include/gmock/gmock.h" 45 #include "testing/gmock/include/gmock/gmock.h"
45 #include "testing/gtest/include/gtest/gtest.h" 46 #include "testing/gtest/include/gtest/gtest.h"
46 47
47 using content::BrowserContext; 48 using content::BrowserContext;
48 using content::WebContents; 49 using content::WebContents;
49 using sessions::GetPasswordStateFromNavigation; 50 using sessions::GetPasswordStateFromNavigation;
50 using sessions::SerializedNavigationEntry; 51 using sessions::SerializedNavigationEntry;
51 using testing::Return; 52 using testing::Return;
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 kPasswordManagerSettingsBehaviourChangeDisabledGroupName); 365 kPasswordManagerSettingsBehaviourChangeDisabledGroupName);
365 prefs()->SetUserPref(password_manager::prefs::kPasswordManagerSavingEnabled, 366 prefs()->SetUserPref(password_manager::prefs::kPasswordManagerSavingEnabled,
366 new base::FundamentalValue(true)); 367 new base::FundamentalValue(true));
367 EXPECT_TRUE(client->IsFillingEnabledForCurrentPage()); 368 EXPECT_TRUE(client->IsFillingEnabledForCurrentPage());
368 prefs()->SetUserPref(password_manager::prefs::kPasswordManagerSavingEnabled, 369 prefs()->SetUserPref(password_manager::prefs::kPasswordManagerSavingEnabled,
369 new base::FundamentalValue(false)); 370 new base::FundamentalValue(false));
370 EXPECT_TRUE(client->IsFillingEnabledForCurrentPage()); 371 EXPECT_TRUE(client->IsFillingEnabledForCurrentPage());
371 } 372 }
372 373
373 TEST_F(ChromePasswordManagerClientTest, SavingAndFillingEnabledConditionsTest) { 374 TEST_F(ChromePasswordManagerClientTest, SavingAndFillingEnabledConditionsTest) {
375 std::unique_ptr<WebContents> test_web_contents(
376 content::WebContentsTester::CreateTestWebContents(
377 web_contents()->GetBrowserContext(), nullptr));
374 std::unique_ptr<MockChromePasswordManagerClient> client( 378 std::unique_ptr<MockChromePasswordManagerClient> client(
375 new MockChromePasswordManagerClient(web_contents())); 379 new MockChromePasswordManagerClient(test_web_contents.get()));
376 // Functionality disabled if there is SSL errors. 380 // Functionality disabled if there is SSL errors.
377 EXPECT_CALL(*client, DidLastPageLoadEncounterSSLErrors()) 381 EXPECT_CALL(*client, DidLastPageLoadEncounterSSLErrors())
378 .WillRepeatedly(Return(true)); 382 .WillRepeatedly(Return(true));
379 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage()); 383 EXPECT_FALSE(client->IsSavingAndFillingEnabledForCurrentPage());
380 EXPECT_FALSE(client->IsFillingEnabledForCurrentPage()); 384 EXPECT_FALSE(client->IsFillingEnabledForCurrentPage());
381 385
382 // Functionality disabled if there are SSL errors and the manager itself is 386 // Functionality disabled if there are SSL errors and the manager itself is
383 // disabled. 387 // disabled.
384 prefs()->SetUserPref(password_manager::prefs::kPasswordManagerSavingEnabled, 388 prefs()->SetUserPref(password_manager::prefs::kPasswordManagerSavingEnabled,
385 new base::FundamentalValue(false)); 389 new base::FundamentalValue(false));
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 // State transition: true->false (retains true) 545 // State transition: true->false (retains true)
542 TEST_F(ChromePasswordManagerClientTest, AnnotateNavigationEntryTrueToFalse) { 546 TEST_F(ChromePasswordManagerClientTest, AnnotateNavigationEntryTrueToFalse) {
543 SetupNavigationForAnnotation(); 547 SetupNavigationForAnnotation();
544 548
545 GetClient()->AnnotateNavigationEntry(true); 549 GetClient()->AnnotateNavigationEntry(true);
546 GetClient()->AnnotateNavigationEntry(false); 550 GetClient()->AnnotateNavigationEntry(false);
547 EXPECT_EQ( 551 EXPECT_EQ(
548 SerializedNavigationEntry::HAS_PASSWORD_FIELD, 552 SerializedNavigationEntry::HAS_PASSWORD_FIELD,
549 GetPasswordStateFromNavigation(*controller().GetLastCommittedEntry())); 553 GetPasswordStateFromNavigation(*controller().GetLastCommittedEntry()));
550 } 554 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698