OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "base/tuple.h" | 8 #include "base/tuple.h" |
9 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 9 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
10 #include "chrome/test/base/testing_profile.h" | |
11 #include "components/autofill/content/browser/autocheckout_manager.h" | 10 #include "components/autofill/content/browser/autocheckout_manager.h" |
12 #include "components/autofill/core/browser/autofill_common_test.h" | 11 #include "components/autofill/core/browser/autofill_common_test.h" |
13 #include "components/autofill/core/browser/autofill_manager.h" | 12 #include "components/autofill/core/browser/autofill_manager.h" |
14 #include "components/autofill/core/browser/autofill_metrics.h" | 13 #include "components/autofill/core/browser/autofill_metrics.h" |
15 #include "components/autofill/core/browser/form_structure.h" | 14 #include "components/autofill/core/browser/form_structure.h" |
16 #include "components/autofill/core/browser/test_autofill_driver.h" | 15 #include "components/autofill/core/browser/test_autofill_driver.h" |
17 #include "components/autofill/core/browser/test_autofill_manager_delegate.h" | 16 #include "components/autofill/core/browser/test_autofill_manager_delegate.h" |
18 #include "components/autofill/core/common/autofill_messages.h" | 17 #include "components/autofill/core/common/autofill_messages.h" |
19 #include "components/autofill/core/common/form_data.h" | 18 #include "components/autofill/core/common/form_data.h" |
20 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 using AutocheckoutManager::ReturnAutocheckoutData; | 409 using AutocheckoutManager::ReturnAutocheckoutData; |
411 }; | 410 }; |
412 | 411 |
413 } // namespace | 412 } // namespace |
414 | 413 |
415 class AutocheckoutManagerTest : public ChromeRenderViewHostTestHarness { | 414 class AutocheckoutManagerTest : public ChromeRenderViewHostTestHarness { |
416 protected: | 415 protected: |
417 virtual void SetUp() OVERRIDE { | 416 virtual void SetUp() OVERRIDE { |
418 SetThreadBundleOptions(content::TestBrowserThreadBundle::REAL_IO_THREAD); | 417 SetThreadBundleOptions(content::TestBrowserThreadBundle::REAL_IO_THREAD); |
419 ChromeRenderViewHostTestHarness::SetUp(); | 418 ChromeRenderViewHostTestHarness::SetUp(); |
420 profile()->CreateRequestContext(); | |
421 autofill_manager_delegate_.reset(new MockAutofillManagerDelegate()); | 419 autofill_manager_delegate_.reset(new MockAutofillManagerDelegate()); |
422 autofill_driver_.reset(new TestAutofillDriver(web_contents())); | 420 autofill_driver_.reset(new TestAutofillDriver(web_contents())); |
423 autofill_manager_.reset(new TestAutofillManager( | 421 autofill_manager_.reset(new TestAutofillManager( |
424 autofill_driver_.get(), | 422 autofill_driver_.get(), |
425 autofill_manager_delegate_.get())); | 423 autofill_manager_delegate_.get())); |
426 autocheckout_manager_.reset( | 424 autocheckout_manager_.reset( |
427 new TestAutocheckoutManager(autofill_manager_.get())); | 425 new TestAutocheckoutManager(autofill_manager_.get())); |
428 } | 426 } |
429 | 427 |
430 virtual void TearDown() OVERRIDE { | 428 virtual void TearDown() OVERRIDE { |
431 autocheckout_manager_.reset(); | 429 autocheckout_manager_.reset(); |
432 autofill_manager_delegate_.reset(); | 430 autofill_manager_delegate_.reset(); |
433 autofill_manager_.reset(); | 431 autofill_manager_.reset(); |
434 autofill_driver_.reset(); | 432 autofill_driver_.reset(); |
435 profile()->ResetRequestContext(); | |
436 ChromeRenderViewHostTestHarness::TearDown(); | 433 ChromeRenderViewHostTestHarness::TearDown(); |
437 } | 434 } |
438 | 435 |
439 std::vector<FormData> ReadFilledForms() { | 436 std::vector<FormData> ReadFilledForms() { |
440 uint32 kMsgID = AutofillMsg_FillFormsAndClick::ID; | 437 uint32 kMsgID = AutofillMsg_FillFormsAndClick::ID; |
441 const IPC::Message* message = | 438 const IPC::Message* message = |
442 process()->sink().GetFirstMessageMatching(kMsgID); | 439 process()->sink().GetFirstMessageMatching(kMsgID); |
443 AutofillParam autofill_param; | 440 AutofillParam autofill_param; |
444 AutofillMsg_FillFormsAndClick::Read(message, &autofill_param); | 441 AutofillMsg_FillFormsAndClick::Read(message, &autofill_param); |
445 return autofill_param.a; | 442 return autofill_param.a; |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 frame_url, | 933 frame_url, |
937 AUTOCHECKOUT_BUBBLE_CANCELED); | 934 AUTOCHECKOUT_BUBBLE_CANCELED); |
938 EXPECT_FALSE(autocheckout_manager_->is_autocheckout_bubble_showing()); | 935 EXPECT_FALSE(autocheckout_manager_->is_autocheckout_bubble_showing()); |
939 EXPECT_FALSE(autocheckout_manager_->should_show_bubble()); | 936 EXPECT_FALSE(autocheckout_manager_->should_show_bubble()); |
940 | 937 |
941 autocheckout_manager_->MaybeShowAutocheckoutBubble(frame_url, bounding_box); | 938 autocheckout_manager_->MaybeShowAutocheckoutBubble(frame_url, bounding_box); |
942 EXPECT_FALSE(autocheckout_manager_->is_autocheckout_bubble_showing()); | 939 EXPECT_FALSE(autocheckout_manager_->is_autocheckout_bubble_showing()); |
943 } | 940 } |
944 | 941 |
945 } // namespace autofill | 942 } // namespace autofill |
OLD | NEW |