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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h" | 12 #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h" |
13 #include "chrome/browser/ui/autofill/test_generated_credit_card_bubble_controlle
r.h" | 13 #include "chrome/browser/ui/autofill/test_generated_credit_card_bubble_controlle
r.h" |
14 #include "chrome/browser/ui/autofill/test_generated_credit_card_bubble_view.h" | 14 #include "chrome/browser/ui/autofill/test_generated_credit_card_bubble_view.h" |
15 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
16 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
17 #include "components/autofill/core/browser/autofill_test_utils.h" | 17 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 18 #include "content/public/browser/navigation_details.h" |
| 19 #include "content/public/browser/navigation_entry.h" |
18 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
19 #include "content/public/test/test_browser_thread_bundle.h" | 21 #include "content/public/test/test_browser_thread_bundle.h" |
20 #include "content/public/test/web_contents_tester.h" | 22 #include "content/public/test/web_contents_tester.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
22 #include "ui/base/page_transition_types.h" | 24 #include "ui/base/page_transition_types.h" |
23 #include "ui/gfx/range/range.h" | 25 #include "ui/gfx/range/range.h" |
24 | 26 |
25 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
26 #include "ui/base/win/scoped_ole_initializer.h" | 28 #include "ui/base/win/scoped_ole_initializer.h" |
27 #endif | 29 #endif |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 ::prefs::kAutofillGeneratedCardBubbleTimesShown); | 71 ::prefs::kAutofillGeneratedCardBubbleTimesShown); |
70 } | 72 } |
71 | 73 |
72 void Show() { | 74 void Show() { |
73 ASSERT_TRUE(controller()->IsInstalled()); | 75 ASSERT_TRUE(controller()->IsInstalled()); |
74 TestGeneratedCreditCardBubbleController::Show(test_web_contents_.get(), | 76 TestGeneratedCreditCardBubbleController::Show(test_web_contents_.get(), |
75 FrontingCard(), | 77 FrontingCard(), |
76 BackingCard()); | 78 BackingCard()); |
77 } | 79 } |
78 | 80 |
79 void NavigateWithTransition(ui::PageTransition trans) { | 81 void NavigateWithTransition(ui::PageTransition transition) { |
80 content::WebContentsTester::For(test_web_contents_.get())->TestDidNavigate( | 82 content::LoadCommittedDetails details; |
81 test_web_contents_->GetMainFrame(), 1, GURL("about:blank"), trans); | 83 content::FrameNavigateParams params; |
| 84 |
| 85 // The transition is in two places; fill in both. |
| 86 scoped_ptr<content::NavigationEntry> navigation_entry( |
| 87 content::NavigationEntry::Create()); |
| 88 navigation_entry->SetTransitionType(transition); |
| 89 params.transition = transition; |
| 90 details.entry = navigation_entry.get(); |
| 91 |
| 92 ASSERT_NE(nullptr, controller()); |
| 93 controller()->DidNavigateMainFrame(details, params); |
82 } | 94 } |
83 | 95 |
84 private: | 96 private: |
85 content::TestBrowserThreadBundle thread_bundle_; | 97 content::TestBrowserThreadBundle thread_bundle_; |
86 #if defined(OS_WIN) | 98 #if defined(OS_WIN) |
87 // Without this there will be drag and drop failures. http://crbug.com/227221 | 99 // Without this there will be drag and drop failures. http://crbug.com/227221 |
88 ui::ScopedOleInitializer ole_initializer_; | 100 ui::ScopedOleInitializer ole_initializer_; |
89 #endif | 101 #endif |
90 TestingProfile profile_; | 102 TestingProfile profile_; |
91 scoped_ptr<content::WebContents> test_web_contents_; | 103 scoped_ptr<content::WebContents> test_web_contents_; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 179 |
168 // If the user reloads or the page redirects or submits a form, the bubble | 180 // If the user reloads or the page redirects or submits a form, the bubble |
169 // should stay showing. | 181 // should stay showing. |
170 NavigateWithTransition(ui::PAGE_TRANSITION_CLIENT_REDIRECT); | 182 NavigateWithTransition(ui::PAGE_TRANSITION_CLIENT_REDIRECT); |
171 NavigateWithTransition(ui::PAGE_TRANSITION_FORM_SUBMIT); | 183 NavigateWithTransition(ui::PAGE_TRANSITION_FORM_SUBMIT); |
172 NavigateWithTransition(ui::PAGE_TRANSITION_RELOAD); | 184 NavigateWithTransition(ui::PAGE_TRANSITION_RELOAD); |
173 EXPECT_TRUE(controller()->GetTestingBubble()->showing()); | 185 EXPECT_TRUE(controller()->GetTestingBubble()->showing()); |
174 } | 186 } |
175 | 187 |
176 } // namespace autofill | 188 } // namespace autofill |
OLD | NEW |