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

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_ui_controller_unittest.cc

Issue 1260263002: Move ShouldFilterAutofillResult from ChromePasswordManagerClient to PasswordManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First version with sync layer, IsSyncCredential TODO still pending Created 5 years, 4 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/scoped_ptr.h"
6 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
7 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
8 #include "base/time/time.h" 9 #include "base/time/time.h"
9 #include "chrome/browser/ui/passwords/manage_passwords_bubble.h" 10 #include "chrome/browser/ui/passwords/manage_passwords_bubble.h"
10 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" 11 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h"
11 #include "chrome/browser/ui/passwords/manage_passwords_icon.h" 12 #include "chrome/browser/ui/passwords/manage_passwords_icon.h"
12 #include "chrome/browser/ui/passwords/manage_passwords_icon_mock.h" 13 #include "chrome/browser/ui/passwords/manage_passwords_icon_mock.h"
13 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h" 14 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h"
14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 15 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
15 #include "chrome/test/base/testing_profile.h" 16 #include "chrome/test/base/testing_profile.h"
16 #include "components/autofill/core/common/password_form.h" 17 #include "components/autofill/core/common/password_form.h"
17 #include "components/password_manager/core/browser/password_form_manager.h" 18 #include "components/password_manager/core/browser/password_form_manager.h"
18 #include "components/password_manager/core/browser/stub_password_manager_client. h" 19 #include "components/password_manager/core/browser/stub_password_manager_client. h"
19 #include "components/password_manager/core/browser/stub_password_manager_driver. h" 20 #include "components/password_manager/core/browser/stub_password_manager_driver. h"
20 #include "components/password_manager/core/common/credential_manager_types.h" 21 #include "components/password_manager/core/common/credential_manager_types.h"
21 #include "components/password_manager/core/common/password_manager_ui.h" 22 #include "components/password_manager/core/common/password_manager_ui.h"
23 #include "components/password_manager/sync/browser/sync_store_result_filter.h"
22 #include "content/public/browser/navigation_details.h" 24 #include "content/public/browser/navigation_details.h"
23 #include "content/public/test/test_browser_thread_bundle.h" 25 #include "content/public/test/test_browser_thread_bundle.h"
24 #include "content/public/test/web_contents_tester.h" 26 #include "content/public/test/web_contents_tester.h"
25 #include "testing/gmock/include/gmock/gmock.h" 27 #include "testing/gmock/include/gmock/gmock.h"
26 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
27 29
28 using ::testing::ElementsAre; 30 using ::testing::ElementsAre;
29 using ::testing::Pointee; 31 using ::testing::Pointee;
30 32
31 namespace { 33 namespace {
32 34
33 const int64 kSlowNavigationDelayInMS = 6000; 35 const int64 kSlowNavigationDelayInMS = 6000;
34 const int64 kQuickNavigationDelayInMS = 500; 36 const int64 kQuickNavigationDelayInMS = 500;
35 37
38 class TestPasswordManagerClient
39 : public password_manager::StubPasswordManagerClient {
40 scoped_ptr<password_manager::StoreResultFilter> CreateStoreResultFilter()
41 const override {
42 return make_scoped_ptr(new password_manager::SyncStoreResultFilter(this));
43 }
44 };
45
36 // This sublass is used to disable some code paths which are not essential for 46 // This sublass is used to disable some code paths which are not essential for
37 // testing. 47 // testing.
38 class TestManagePasswordsUIController : public ManagePasswordsUIController { 48 class TestManagePasswordsUIController : public ManagePasswordsUIController {
39 public: 49 public:
40 TestManagePasswordsUIController( 50 TestManagePasswordsUIController(
41 content::WebContents* contents, 51 content::WebContents* contents,
42 password_manager::PasswordManagerClient* client); 52 password_manager::PasswordManagerClient* client);
43 ~TestManagePasswordsUIController() override; 53 ~TestManagePasswordsUIController() override;
44 54
45 base::TimeDelta Elapsed() const override; 55 base::TimeDelta Elapsed() const override;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 140
131 TestManagePasswordsUIController* controller() { 141 TestManagePasswordsUIController* controller() {
132 return static_cast<TestManagePasswordsUIController*>( 142 return static_cast<TestManagePasswordsUIController*>(
133 ManagePasswordsUIController::FromWebContents(web_contents())); 143 ManagePasswordsUIController::FromWebContents(web_contents()));
134 } 144 }
135 145
136 void CredentialCallback(const password_manager::CredentialInfo& info) { 146 void CredentialCallback(const password_manager::CredentialInfo& info) {
137 credential_info_.reset(new password_manager::CredentialInfo(info)); 147 credential_info_.reset(new password_manager::CredentialInfo(info));
138 } 148 }
139 149
140 password_manager::StubPasswordManagerClient* client() { 150 TestPasswordManagerClient* client() { return &client_; }
141 return &client_;
142 }
143 151
144 scoped_ptr<password_manager::PasswordFormManager> CreateFormManager(); 152 scoped_ptr<password_manager::PasswordFormManager> CreateFormManager();
145 153
146 private: 154 private:
147 password_manager::StubPasswordManagerClient client_; 155 TestPasswordManagerClient client_;
148 156
149 autofill::PasswordForm test_local_form_; 157 autofill::PasswordForm test_local_form_;
150 autofill::PasswordForm test_federated_form_; 158 autofill::PasswordForm test_federated_form_;
151 scoped_ptr<password_manager::CredentialInfo> credential_info_; 159 scoped_ptr<password_manager::CredentialInfo> credential_info_;
152 }; 160 };
153 161
154 scoped_ptr<password_manager::PasswordFormManager> 162 scoped_ptr<password_manager::PasswordFormManager>
155 ManagePasswordsUIControllerTest::CreateFormManager() { 163 ManagePasswordsUIControllerTest::CreateFormManager() {
156 ScopedVector<autofill::PasswordForm> stored_forms; 164 ScopedVector<autofill::PasswordForm> stored_forms;
157 stored_forms.push_back(new autofill::PasswordForm(test_local_form())); 165 stored_forms.push_back(new autofill::PasswordForm(test_local_form()));
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 autofill::PasswordFormMap map; 553 autofill::PasswordFormMap map;
546 scoped_ptr<autofill::PasswordForm> psl_matched_test_form( 554 scoped_ptr<autofill::PasswordForm> psl_matched_test_form(
547 new autofill::PasswordForm(test_local_form())); 555 new autofill::PasswordForm(test_local_form()));
548 psl_matched_test_form->original_signon_realm = 556 psl_matched_test_form->original_signon_realm =
549 "http://pslmatched.example.com"; 557 "http://pslmatched.example.com";
550 map.insert(kTestUsername, psl_matched_test_form.Pass()); 558 map.insert(kTestUsername, psl_matched_test_form.Pass());
551 controller()->OnPasswordAutofilled(map); 559 controller()->OnPasswordAutofilled(map);
552 560
553 EXPECT_EQ(password_manager::ui::INACTIVE_STATE, controller()->state()); 561 EXPECT_EQ(password_manager::ui::INACTIVE_STATE, controller()->state());
554 } 562 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698