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 <map> | 5 #include <map> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 | 139 |
140 bool HasUnsureError(const ValidityMessages& messages, ServerFieldType field) { | 140 bool HasUnsureError(const ValidityMessages& messages, ServerFieldType field) { |
141 const ValidityMessage& message = messages.GetMessageOrDefault(field); | 141 const ValidityMessage& message = messages.GetMessageOrDefault(field); |
142 return !message.text.empty() && !message.sure; | 142 return !message.text.empty() && !message.sure; |
143 } | 143 } |
144 | 144 |
145 class TestAutofillDialogView : public AutofillDialogView { | 145 class TestAutofillDialogView : public AutofillDialogView { |
146 public: | 146 public: |
147 TestAutofillDialogView() | 147 TestAutofillDialogView() |
148 : updates_started_(0), save_details_locally_checked_(true) {} | 148 : updates_started_(0), save_details_locally_checked_(true) {} |
149 virtual ~TestAutofillDialogView() {} | 149 ~TestAutofillDialogView() override {} |
150 | 150 |
151 virtual void Show() override {} | 151 void Show() override {} |
152 virtual void Hide() override {} | 152 void Hide() override {} |
153 | 153 |
154 virtual void UpdatesStarted() override { | 154 void UpdatesStarted() override { |
155 updates_started_++; | 155 updates_started_++; |
156 } | 156 } |
157 | 157 |
158 virtual void UpdatesFinished() override { | 158 void UpdatesFinished() override { |
159 updates_started_--; | 159 updates_started_--; |
160 EXPECT_GE(updates_started_, 0); | 160 EXPECT_GE(updates_started_, 0); |
161 } | 161 } |
162 | 162 |
163 virtual void UpdateNotificationArea() override { | 163 void UpdateNotificationArea() override { |
164 EXPECT_GE(updates_started_, 1); | 164 EXPECT_GE(updates_started_, 1); |
165 } | 165 } |
166 | 166 |
167 virtual void UpdateAccountChooser() override { | 167 void UpdateAccountChooser() override { |
168 EXPECT_GE(updates_started_, 1); | 168 EXPECT_GE(updates_started_, 1); |
169 } | 169 } |
170 | 170 |
171 virtual void UpdateButtonStrip() override { | 171 void UpdateButtonStrip() override { |
172 EXPECT_GE(updates_started_, 1); | 172 EXPECT_GE(updates_started_, 1); |
173 } | 173 } |
174 | 174 |
175 virtual void UpdateOverlay() override { | 175 void UpdateOverlay() override { |
176 EXPECT_GE(updates_started_, 1); | 176 EXPECT_GE(updates_started_, 1); |
177 } | 177 } |
178 | 178 |
179 virtual void UpdateDetailArea() override { | 179 void UpdateDetailArea() override { |
180 EXPECT_GE(updates_started_, 1); | 180 EXPECT_GE(updates_started_, 1); |
181 } | 181 } |
182 | 182 |
183 virtual void UpdateSection(DialogSection section) override { | 183 void UpdateSection(DialogSection section) override { |
184 section_updates_[section]++; | 184 section_updates_[section]++; |
185 EXPECT_GE(updates_started_, 1); | 185 EXPECT_GE(updates_started_, 1); |
186 } | 186 } |
187 | 187 |
188 virtual void UpdateErrorBubble() override { | 188 void UpdateErrorBubble() override { |
189 EXPECT_GE(updates_started_, 1); | 189 EXPECT_GE(updates_started_, 1); |
190 } | 190 } |
191 | 191 |
192 virtual void FillSection(DialogSection section, | 192 void FillSection(DialogSection section, |
193 ServerFieldType originating_type) override {} | 193 ServerFieldType originating_type) override {} |
194 virtual void GetUserInput(DialogSection section, FieldValueMap* output) | 194 void GetUserInput(DialogSection section, FieldValueMap* output) override { |
195 override { | |
196 *output = outputs_[section]; | 195 *output = outputs_[section]; |
197 } | 196 } |
198 | 197 |
199 virtual base::string16 GetCvc() override { return base::string16(); } | 198 base::string16 GetCvc() override { return base::string16(); } |
200 | 199 |
201 virtual bool SaveDetailsLocally() override { | 200 bool SaveDetailsLocally() override { return save_details_locally_checked_; } |
202 return save_details_locally_checked_; | |
203 } | |
204 | 201 |
205 virtual const content::NavigationController* ShowSignIn(const GURL& url) | 202 const content::NavigationController* ShowSignIn(const GURL& url) override { |
206 override { | |
207 return NULL; | 203 return NULL; |
208 } | 204 } |
209 virtual void HideSignIn() override {} | 205 void HideSignIn() override {} |
210 | 206 |
211 MOCK_METHOD0(ModelChanged, void()); | 207 MOCK_METHOD0(ModelChanged, void()); |
212 MOCK_METHOD0(UpdateForErrors, void()); | 208 MOCK_METHOD0(UpdateForErrors, void()); |
213 | 209 |
214 virtual void OnSignInResize(const gfx::Size& pref_size) override {} | 210 void OnSignInResize(const gfx::Size& pref_size) override {} |
215 virtual void ValidateSection(DialogSection) override {} | 211 void ValidateSection(DialogSection) override {} |
216 | 212 |
217 void SetUserInput(DialogSection section, const FieldValueMap& map) { | 213 void SetUserInput(DialogSection section, const FieldValueMap& map) { |
218 outputs_[section] = map; | 214 outputs_[section] = map; |
219 } | 215 } |
220 | 216 |
221 void CheckSaveDetailsLocallyCheckbox(bool checked) { | 217 void CheckSaveDetailsLocallyCheckbox(bool checked) { |
222 save_details_locally_checked_ = checked; | 218 save_details_locally_checked_ = checked; |
223 } | 219 } |
224 | 220 |
225 void ClearSectionUpdates() { | 221 void ClearSectionUpdates() { |
(...skipping 29 matching lines...) Expand all Loading... |
255 source_url, | 251 source_url, |
256 callback), | 252 callback), |
257 mock_wallet_client_( | 253 mock_wallet_client_( |
258 Profile::FromBrowserContext(contents->GetBrowserContext()) | 254 Profile::FromBrowserContext(contents->GetBrowserContext()) |
259 ->GetRequestContext(), | 255 ->GetRequestContext(), |
260 this, | 256 this, |
261 source_url), | 257 source_url), |
262 mock_new_card_bubble_controller_(mock_new_card_bubble_controller), | 258 mock_new_card_bubble_controller_(mock_new_card_bubble_controller), |
263 submit_button_delay_count_(0) {} | 259 submit_button_delay_count_(0) {} |
264 | 260 |
265 virtual ~TestAutofillDialogController() {} | 261 ~TestAutofillDialogController() override {} |
266 | 262 |
267 virtual AutofillDialogView* CreateView() override { | 263 AutofillDialogView* CreateView() override { |
268 return new testing::NiceMock<TestAutofillDialogView>(); | 264 return new testing::NiceMock<TestAutofillDialogView>(); |
269 } | 265 } |
270 | 266 |
271 void Init(content::BrowserContext* browser_context) { | 267 void Init(content::BrowserContext* browser_context) { |
272 Profile* profile = Profile::FromBrowserContext(browser_context); | 268 Profile* profile = Profile::FromBrowserContext(browser_context); |
273 test_manager_.Init(WebDataServiceFactory::GetAutofillWebDataForProfile( | 269 test_manager_.Init(WebDataServiceFactory::GetAutofillWebDataForProfile( |
274 profile, | 270 profile, |
275 ServiceAccessType::EXPLICIT_ACCESS), | 271 ServiceAccessType::EXPLICIT_ACCESS), |
276 user_prefs::UserPrefs::Get(browser_context), | 272 user_prefs::UserPrefs::Get(browser_context), |
277 AccountTrackerServiceFactory::GetForProfile(profile), | 273 AccountTrackerServiceFactory::GetForProfile(profile), |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 using AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData; | 322 using AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData; |
327 using AutofillDialogControllerImpl::IsEditingExistingData; | 323 using AutofillDialogControllerImpl::IsEditingExistingData; |
328 using AutofillDialogControllerImpl::IsManuallyEditingSection; | 324 using AutofillDialogControllerImpl::IsManuallyEditingSection; |
329 using AutofillDialogControllerImpl::IsPayingWithWallet; | 325 using AutofillDialogControllerImpl::IsPayingWithWallet; |
330 using AutofillDialogControllerImpl::IsSubmitPausedOn; | 326 using AutofillDialogControllerImpl::IsSubmitPausedOn; |
331 using AutofillDialogControllerImpl::NOT_CHECKED; | 327 using AutofillDialogControllerImpl::NOT_CHECKED; |
332 using AutofillDialogControllerImpl::popup_input_type; | 328 using AutofillDialogControllerImpl::popup_input_type; |
333 using AutofillDialogControllerImpl::SignedInState; | 329 using AutofillDialogControllerImpl::SignedInState; |
334 | 330 |
335 protected: | 331 protected: |
336 virtual PersonalDataManager* GetManager() const override { | 332 PersonalDataManager* GetManager() const override { |
337 return const_cast<TestAutofillDialogController*>(this)-> | 333 return const_cast<TestAutofillDialogController*>(this)-> |
338 GetTestingManager(); | 334 GetTestingManager(); |
339 } | 335 } |
340 | 336 |
341 virtual AddressValidator* GetValidator() override { | 337 AddressValidator* GetValidator() override { |
342 return &mock_validator_; | 338 return &mock_validator_; |
343 } | 339 } |
344 | 340 |
345 virtual wallet::WalletClient* GetWalletClient() override { | 341 wallet::WalletClient* GetWalletClient() override { |
346 return &mock_wallet_client_; | 342 return &mock_wallet_client_; |
347 } | 343 } |
348 | 344 |
349 virtual void OpenTabWithUrl(const GURL& url) override { | 345 void OpenTabWithUrl(const GURL& url) override { |
350 open_tab_url_ = url; | 346 open_tab_url_ = url; |
351 } | 347 } |
352 | 348 |
353 virtual void ShowNewCreditCardBubble( | 349 void ShowNewCreditCardBubble( |
354 scoped_ptr<CreditCard> new_card, | 350 scoped_ptr<CreditCard> new_card, |
355 scoped_ptr<AutofillProfile> billing_profile) override { | 351 scoped_ptr<AutofillProfile> billing_profile) override { |
356 mock_new_card_bubble_controller_->Show(new_card.Pass(), | 352 mock_new_card_bubble_controller_->Show(new_card.Pass(), |
357 billing_profile.Pass()); | 353 billing_profile.Pass()); |
358 } | 354 } |
359 | 355 |
360 // AutofillDialogControllerImpl calls this method before showing the dialog | 356 // AutofillDialogControllerImpl calls this method before showing the dialog |
361 // window. | 357 // window. |
362 virtual void SubmitButtonDelayBegin() override { | 358 void SubmitButtonDelayBegin() override { |
363 // Do not delay enabling the submit button in testing. | 359 // Do not delay enabling the submit button in testing. |
364 submit_button_delay_count_++; | 360 submit_button_delay_count_++; |
365 } | 361 } |
366 | 362 |
367 private: | 363 private: |
368 TestPersonalDataManager test_manager_; | 364 TestPersonalDataManager test_manager_; |
369 testing::NiceMock<wallet::MockWalletClient> mock_wallet_client_; | 365 testing::NiceMock<wallet::MockWalletClient> mock_wallet_client_; |
370 | 366 |
371 // A mock validator object to prevent network requests and track when | 367 // A mock validator object to prevent network requests and track when |
372 // validation rules are loaded or validation attempts occur. | 368 // validation rules are loaded or validation attempts occur. |
(...skipping 3268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3641 EXPECT_EQ(ASCIIToUTF16("United States"), form_structure()->field(2)->value); | 3637 EXPECT_EQ(ASCIIToUTF16("United States"), form_structure()->field(2)->value); |
3642 EXPECT_EQ(ADDRESS_HOME_COUNTRY, | 3638 EXPECT_EQ(ADDRESS_HOME_COUNTRY, |
3643 form_structure()->field(3)->Type().GetStorableType()); | 3639 form_structure()->field(3)->Type().GetStorableType()); |
3644 EXPECT_EQ(ASCIIToUTF16("US"), form_structure()->field(3)->value); | 3640 EXPECT_EQ(ASCIIToUTF16("US"), form_structure()->field(3)->value); |
3645 EXPECT_EQ(ADDRESS_HOME_COUNTRY, | 3641 EXPECT_EQ(ADDRESS_HOME_COUNTRY, |
3646 form_structure()->field(4)->Type().GetStorableType()); | 3642 form_structure()->field(4)->Type().GetStorableType()); |
3647 EXPECT_EQ(ASCIIToUTF16("United States"), form_structure()->field(4)->value); | 3643 EXPECT_EQ(ASCIIToUTF16("United States"), form_structure()->field(4)->value); |
3648 } | 3644 } |
3649 | 3645 |
3650 } // namespace autofill | 3646 } // namespace autofill |
OLD | NEW |