OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 weak_ptr_factory_(this) { | 108 weak_ptr_factory_(this) { |
109 Profile* profile = | 109 Profile* profile = |
110 Profile::FromBrowserContext(contents->GetBrowserContext()); | 110 Profile::FromBrowserContext(contents->GetBrowserContext()); |
111 test_manager_.Init( | 111 test_manager_.Init( |
112 NULL, | 112 NULL, |
113 profile->GetPrefs(), | 113 profile->GetPrefs(), |
114 AccountTrackerServiceFactory::GetForProfile(profile), | 114 AccountTrackerServiceFactory::GetForProfile(profile), |
115 false); | 115 false); |
116 } | 116 } |
117 | 117 |
118 virtual ~TestAutofillDialogController() {} | 118 ~TestAutofillDialogController() override {} |
119 | 119 |
120 GURL FakeSignInUrl() const { | 120 GURL FakeSignInUrl() const { |
121 return GURL(chrome::kChromeUIVersionURL); | 121 return GURL(chrome::kChromeUIVersionURL); |
122 } | 122 } |
123 | 123 |
124 virtual void ShowSignIn(const GURL& url) override { | 124 void ShowSignIn(const GURL& url) override { |
125 AutofillDialogControllerImpl::ShowSignIn(FakeSignInUrl()); | 125 AutofillDialogControllerImpl::ShowSignIn(FakeSignInUrl()); |
126 } | 126 } |
127 | 127 |
128 virtual void ViewClosed() override { | 128 void ViewClosed() override { |
129 message_loop_runner_->Quit(); | 129 message_loop_runner_->Quit(); |
130 AutofillDialogControllerImpl::ViewClosed(); | 130 AutofillDialogControllerImpl::ViewClosed(); |
131 } | 131 } |
132 | 132 |
133 virtual base::string16 InputValidityMessage( | 133 base::string16 InputValidityMessage( |
134 DialogSection section, | 134 DialogSection section, |
135 ServerFieldType type, | 135 ServerFieldType type, |
136 const base::string16& value) override { | 136 const base::string16& value) override { |
137 if (!use_validation_) | 137 if (!use_validation_) |
138 return base::string16(); | 138 return base::string16(); |
139 return AutofillDialogControllerImpl::InputValidityMessage( | 139 return AutofillDialogControllerImpl::InputValidityMessage( |
140 section, type, value); | 140 section, type, value); |
141 } | 141 } |
142 | 142 |
143 virtual ValidityMessages InputsAreValid( | 143 ValidityMessages InputsAreValid( |
144 DialogSection section, | 144 DialogSection section, |
145 const FieldValueMap& inputs) override { | 145 const FieldValueMap& inputs) override { |
146 if (!use_validation_) | 146 if (!use_validation_) |
147 return ValidityMessages(); | 147 return ValidityMessages(); |
148 return AutofillDialogControllerImpl::InputsAreValid(section, inputs); | 148 return AutofillDialogControllerImpl::InputsAreValid(section, inputs); |
149 } | 149 } |
150 | 150 |
151 // Saving to Chrome is tested in AutofillDialogControllerImpl unit tests. | 151 // Saving to Chrome is tested in AutofillDialogControllerImpl unit tests. |
152 // TODO(estade): test that the view defaults to saving to Chrome. | 152 // TODO(estade): test that the view defaults to saving to Chrome. |
153 virtual bool ShouldOfferToSaveInChrome() const override { | 153 bool ShouldOfferToSaveInChrome() const override { |
154 return true; | 154 return true; |
155 } | 155 } |
156 | 156 |
157 void ForceFinishSubmit() { | 157 void ForceFinishSubmit() { |
158 DoFinishSubmit(); | 158 DoFinishSubmit(); |
159 } | 159 } |
160 | 160 |
161 // Increase visibility for testing. | 161 // Increase visibility for testing. |
162 using AutofillDialogControllerImpl::view; | 162 using AutofillDialogControllerImpl::view; |
163 using AutofillDialogControllerImpl::popup_input_type; | 163 using AutofillDialogControllerImpl::popup_input_type; |
164 | 164 |
165 MOCK_METHOD0(LoadRiskFingerprintData, void()); | 165 MOCK_METHOD0(LoadRiskFingerprintData, void()); |
166 | 166 |
167 virtual std::vector<DialogNotification> CurrentNotifications() override { | 167 std::vector<DialogNotification> CurrentNotifications() override { |
168 return notifications_; | 168 return notifications_; |
169 } | 169 } |
170 | 170 |
171 void set_notifications(const std::vector<DialogNotification>& notifications) { | 171 void set_notifications(const std::vector<DialogNotification>& notifications) { |
172 notifications_ = notifications; | 172 notifications_ = notifications; |
173 } | 173 } |
174 | 174 |
175 TestPersonalDataManager* GetTestingManager() { | 175 TestPersonalDataManager* GetTestingManager() { |
176 return &test_manager_; | 176 return &test_manager_; |
177 } | 177 } |
(...skipping 21 matching lines...) Expand all Loading... |
199 | 199 |
200 wallet::MockWalletClient* GetTestingWalletClient() { | 200 wallet::MockWalletClient* GetTestingWalletClient() { |
201 return &mock_wallet_client_; | 201 return &mock_wallet_client_; |
202 } | 202 } |
203 | 203 |
204 void set_sign_in_user_index(size_t sign_in_user_index) { | 204 void set_sign_in_user_index(size_t sign_in_user_index) { |
205 sign_in_user_index_ = sign_in_user_index; | 205 sign_in_user_index_ = sign_in_user_index; |
206 } | 206 } |
207 | 207 |
208 protected: | 208 protected: |
209 virtual PersonalDataManager* GetManager() const override { | 209 PersonalDataManager* GetManager() const override { |
210 return &const_cast<TestAutofillDialogController*>(this)->test_manager_; | 210 return &const_cast<TestAutofillDialogController*>(this)->test_manager_; |
211 } | 211 } |
212 | 212 |
213 virtual AddressValidator* GetValidator() override { | 213 AddressValidator* GetValidator() override { |
214 return &mock_validator_; | 214 return &mock_validator_; |
215 } | 215 } |
216 | 216 |
217 virtual wallet::WalletClient* GetWalletClient() override { | 217 wallet::WalletClient* GetWalletClient() override { |
218 return &mock_wallet_client_; | 218 return &mock_wallet_client_; |
219 } | 219 } |
220 | 220 |
221 virtual bool IsSignInContinueUrl(const GURL& url, size_t* user_index) const | 221 bool IsSignInContinueUrl(const GURL& url, size_t* user_index) const override { |
222 override { | |
223 *user_index = sign_in_user_index_; | 222 *user_index = sign_in_user_index_; |
224 return url == wallet::GetSignInContinueUrl(); | 223 return url == wallet::GetSignInContinueUrl(); |
225 } | 224 } |
226 | 225 |
227 private: | 226 private: |
228 TestPersonalDataManager test_manager_; | 227 TestPersonalDataManager test_manager_; |
229 testing::NiceMock<MockAddressValidator> mock_validator_; | 228 testing::NiceMock<MockAddressValidator> mock_validator_; |
230 testing::NiceMock<wallet::MockWalletClient> mock_wallet_client_; | 229 testing::NiceMock<wallet::MockWalletClient> mock_wallet_client_; |
231 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | 230 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
232 bool use_validation_; | 231 bool use_validation_; |
(...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1855 ASSERT_TRUE(content::ExecuteScriptAndExtractString(GetRenderViewHost(), | 1854 ASSERT_TRUE(content::ExecuteScriptAndExtractString(GetRenderViewHost(), |
1856 "navigateFrame();", | 1855 "navigateFrame();", |
1857 &unused)); | 1856 &unused)); |
1858 ExpectDomMessage("iframe loaded"); | 1857 ExpectDomMessage("iframe loaded"); |
1859 ChromeAutofillClient* client = | 1858 ChromeAutofillClient* client = |
1860 ChromeAutofillClient::FromWebContents(GetActiveWebContents()); | 1859 ChromeAutofillClient::FromWebContents(GetActiveWebContents()); |
1861 EXPECT_FALSE(client->GetDialogControllerForTesting()); | 1860 EXPECT_FALSE(client->GetDialogControllerForTesting()); |
1862 } | 1861 } |
1863 | 1862 |
1864 } // namespace autofill | 1863 } // namespace autofill |
OLD | NEW |