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 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 // testing::Test implementation: | 301 // testing::Test implementation: |
302 virtual void SetUp() OVERRIDE { | 302 virtual void SetUp() OVERRIDE { |
303 profile()->CreateRequestContext(); | 303 profile()->CreateRequestContext(); |
304 test_web_contents_.reset( | 304 test_web_contents_.reset( |
305 content::WebContentsTester::CreateTestWebContents(profile(), NULL)); | 305 content::WebContentsTester::CreateTestWebContents(profile(), NULL)); |
306 | 306 |
307 SetUpControllerWithFormData(DefaultFormData()); | 307 SetUpControllerWithFormData(DefaultFormData()); |
308 } | 308 } |
309 | 309 |
310 virtual void TearDown() OVERRIDE { | 310 virtual void TearDown() OVERRIDE { |
311 if (controller_) | 311 if (controller_.get()) |
312 controller_->ViewClosed(); | 312 controller_->ViewClosed(); |
313 } | 313 } |
314 | 314 |
315 protected: | 315 protected: |
316 FormData DefaultFormData() { | 316 FormData DefaultFormData() { |
317 FormData form_data; | 317 FormData form_data; |
318 for (size_t i = 0; i < arraysize(kFieldsFromPage); ++i) { | 318 for (size_t i = 0; i < arraysize(kFieldsFromPage); ++i) { |
319 FormFieldData field; | 319 FormFieldData field; |
320 field.autocomplete_attribute = kFieldsFromPage[i]; | 320 field.autocomplete_attribute = kFieldsFromPage[i]; |
321 form_data.fields.push_back(field); | 321 form_data.fields.push_back(field); |
322 } | 322 } |
323 return form_data; | 323 return form_data; |
324 } | 324 } |
325 | 325 |
326 void SetUpControllerWithFormData(const FormData& form_data) { | 326 void SetUpControllerWithFormData(const FormData& form_data) { |
327 if (controller_) | 327 if (controller_.get()) |
328 controller_->ViewClosed(); | 328 controller_->ViewClosed(); |
329 | 329 |
330 base::Callback<void(const FormStructure*, const std::string&)> callback = | 330 base::Callback<void(const FormStructure*, const std::string&)> callback = |
331 base::Bind(&AutofillDialogControllerTest::FinishedCallback, | 331 base::Bind(&AutofillDialogControllerTest::FinishedCallback, |
332 base::Unretained(this)); | 332 base::Unretained(this)); |
333 controller_ = (new testing::NiceMock<TestAutofillDialogController>( | 333 controller_ = (new testing::NiceMock<TestAutofillDialogController>( |
334 test_web_contents_.get(), | 334 test_web_contents_.get(), |
335 form_data, | 335 form_data, |
336 GURL(), | 336 GURL(), |
337 metric_logger_, | 337 metric_logger_, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 } | 375 } |
376 | 376 |
377 void SimulateSigninError() { | 377 void SimulateSigninError() { |
378 controller_->SimulateSigninError(); | 378 controller_->SimulateSigninError(); |
379 } | 379 } |
380 | 380 |
381 void UseBillingForShipping() { | 381 void UseBillingForShipping() { |
382 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(0); | 382 controller()->MenuModelForSection(SECTION_SHIPPING)->ActivatedAt(0); |
383 } | 383 } |
384 | 384 |
385 TestAutofillDialogController* controller() { return controller_; } | 385 TestAutofillDialogController* controller() { return controller_.get(); } |
386 | 386 |
387 TestingProfile* profile() { return &profile_; } | 387 TestingProfile* profile() { return &profile_; } |
388 | 388 |
389 const FormStructure* form_structure() { return form_structure_; } | 389 const FormStructure* form_structure() { return form_structure_; } |
390 | 390 |
391 private: | 391 private: |
392 void FinishedCallback(const FormStructure* form_structure, | 392 void FinishedCallback(const FormStructure* form_structure, |
393 const std::string& google_transaction_id) { | 393 const std::string& google_transaction_id) { |
394 form_structure_ = form_structure; | 394 form_structure_ = form_structure; |
395 } | 395 } |
(...skipping 1488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1884 controller()->GetTestingManager()->AddTestingProfile(&full_profile); | 1884 controller()->GetTestingManager()->AddTestingProfile(&full_profile); |
1885 SetUpControllerWithFormData(form_data); | 1885 SetUpControllerWithFormData(form_data); |
1886 EXPECT_FALSE(controller()->SectionIsActive(SECTION_SHIPPING)); | 1886 EXPECT_FALSE(controller()->SectionIsActive(SECTION_SHIPPING)); |
1887 | 1887 |
1888 FillCreditCardInputs(); | 1888 FillCreditCardInputs(); |
1889 controller()->OnAccept(); | 1889 controller()->OnAccept(); |
1890 EXPECT_TRUE(form_structure()); | 1890 EXPECT_TRUE(form_structure()); |
1891 } | 1891 } |
1892 | 1892 |
1893 } // namespace autofill | 1893 } // namespace autofill |
OLD | NEW |