Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: chrome/browser/ui/autofill/generated_credit_card_bubble_controller_unittest.cc

Issue 562603002: Move PageTransition from //content/public/common to //ui/base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/web_contents.h" 18 #include "content/public/browser/web_contents.h"
19 #include "content/public/common/page_transition_types.h"
20 #include "content/public/test/test_browser_thread_bundle.h" 19 #include "content/public/test/test_browser_thread_bundle.h"
21 #include "content/public/test/web_contents_tester.h" 20 #include "content/public/test/web_contents_tester.h"
22 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 #include "ui/base/page_transition_types.h"
23 #include "ui/gfx/range/range.h" 23 #include "ui/gfx/range/range.h"
24 24
25 #if defined(OS_WIN) 25 #if defined(OS_WIN)
26 #include "ui/base/win/scoped_ole_initializer.h" 26 #include "ui/base/win/scoped_ole_initializer.h"
27 #endif 27 #endif
28 28
29 namespace autofill { 29 namespace autofill {
30 30
31 namespace { 31 namespace {
32 32
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 ::prefs::kAutofillGeneratedCardBubbleTimesShown); 69 ::prefs::kAutofillGeneratedCardBubbleTimesShown);
70 } 70 }
71 71
72 void Show() { 72 void Show() {
73 ASSERT_TRUE(controller()->IsInstalled()); 73 ASSERT_TRUE(controller()->IsInstalled());
74 TestGeneratedCreditCardBubbleController::Show(test_web_contents_.get(), 74 TestGeneratedCreditCardBubbleController::Show(test_web_contents_.get(),
75 FrontingCard(), 75 FrontingCard(),
76 BackingCard()); 76 BackingCard());
77 } 77 }
78 78
79 void NavigateWithTransition(content::PageTransition trans) { 79 void NavigateWithTransition(ui::PageTransition trans) {
80 content::WebContentsTester::For(test_web_contents_.get())->TestDidNavigate( 80 content::WebContentsTester::For(test_web_contents_.get())->TestDidNavigate(
81 test_web_contents_->GetMainFrame(), 1, GURL("about:blank"), trans); 81 test_web_contents_->GetMainFrame(), 1, GURL("about:blank"), trans);
82 } 82 }
83 83
84 private: 84 private:
85 content::TestBrowserThreadBundle thread_bundle_; 85 content::TestBrowserThreadBundle thread_bundle_;
86 #if defined(OS_WIN) 86 #if defined(OS_WIN)
87 // Without this there will be drag and drop failures. http://crbug.com/227221 87 // Without this there will be drag and drop failures. http://crbug.com/227221
88 ui::ScopedOleInitializer ole_initializer_; 88 ui::ScopedOleInitializer ole_initializer_;
89 #endif 89 #endif
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 Show(); 149 Show();
150 EXPECT_FALSE(controller()->AnchorIcon().IsEmpty()); 150 EXPECT_FALSE(controller()->AnchorIcon().IsEmpty());
151 } 151 }
152 152
153 TEST_F(GeneratedCreditCardBubbleControllerTest, HideOnLinkClick) { 153 TEST_F(GeneratedCreditCardBubbleControllerTest, HideOnLinkClick) {
154 EXPECT_FALSE(controller()->GetTestingBubble()); 154 EXPECT_FALSE(controller()->GetTestingBubble());
155 Show(); 155 Show();
156 EXPECT_TRUE(controller()->GetTestingBubble()->showing()); 156 EXPECT_TRUE(controller()->GetTestingBubble()->showing());
157 157
158 // However, if the user clicks a link the bubble should hide. 158 // However, if the user clicks a link the bubble should hide.
159 NavigateWithTransition(content::PAGE_TRANSITION_LINK); 159 NavigateWithTransition(ui::PAGE_TRANSITION_LINK);
160 EXPECT_FALSE(controller()); 160 EXPECT_FALSE(controller());
161 } 161 }
162 162
163 TEST_F(GeneratedCreditCardBubbleControllerTest, StayOnSomeNavigations) { 163 TEST_F(GeneratedCreditCardBubbleControllerTest, StayOnSomeNavigations) {
164 EXPECT_FALSE(controller()->GetTestingBubble()); 164 EXPECT_FALSE(controller()->GetTestingBubble());
165 Show(); 165 Show();
166 EXPECT_TRUE(controller()->GetTestingBubble()->showing()); 166 EXPECT_TRUE(controller()->GetTestingBubble()->showing());
167 167
168 // If the user reloads or the page redirects or submits a form, the bubble 168 // If the user reloads or the page redirects or submits a form, the bubble
169 // should stay showing. 169 // should stay showing.
170 NavigateWithTransition(content::PAGE_TRANSITION_CLIENT_REDIRECT); 170 NavigateWithTransition(ui::PAGE_TRANSITION_CLIENT_REDIRECT);
171 NavigateWithTransition(content::PAGE_TRANSITION_FORM_SUBMIT); 171 NavigateWithTransition(ui::PAGE_TRANSITION_FORM_SUBMIT);
172 NavigateWithTransition(content::PAGE_TRANSITION_RELOAD); 172 NavigateWithTransition(ui::PAGE_TRANSITION_RELOAD);
173 EXPECT_TRUE(controller()->GetTestingBubble()->showing()); 173 EXPECT_TRUE(controller()->GetTestingBubble()->showing());
174 } 174 }
175 175
176 } // namespace autofill 176 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698