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 "chrome/browser/ui/views/autofill/autofill_dialog_views.h" | 5 #include "chrome/browser/ui/views/autofill/autofill_dialog_views.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/browser/ui/autofill/mock_autofill_dialog_view_delegate.h" | 10 #include "chrome/browser/ui/autofill/mock_autofill_dialog_view_delegate.h" |
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
12 #include "chrome/browser/ui/views/autofill/decorated_textfield.h" | 12 #include "chrome/browser/ui/views/autofill/decorated_textfield.h" |
13 #include "chrome/browser/ui/views/frame/browser_view.h" | 13 #include "chrome/browser/ui/views/frame/browser_view.h" |
14 #include "chrome/browser/ui/views/frame/test_with_browser_view.h" | 14 #include "chrome/browser/ui/views/frame/test_with_browser_view.h" |
| 15 #include "components/autofill/content/browser/wallet/wallet_service_url.h" |
15 #include "components/web_modal/test_web_contents_modal_dialog_host.h" | 16 #include "components/web_modal/test_web_contents_modal_dialog_host.h" |
16 #include "components/web_modal/test_web_contents_modal_dialog_manager_delegate.h
" | 17 #include "components/web_modal/test_web_contents_modal_dialog_manager_delegate.h
" |
17 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 18 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
18 #include "content/public/common/url_constants.h" | 19 #include "content/public/common/url_constants.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "ui/views/controls/webview/webview.h" | 22 #include "ui/views/controls/webview/webview.h" |
22 #include "ui/views/widget/widget.h" | 23 #include "ui/views/widget/widget.h" |
23 | 24 |
24 namespace autofill { | 25 namespace autofill { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } | 118 } |
118 | 119 |
119 TEST_F(AutofillDialogViewsTest, SignInFocus) { | 120 TEST_F(AutofillDialogViewsTest, SignInFocus) { |
120 SetSectionsFocusable(); | 121 SetSectionsFocusable(); |
121 | 122 |
122 views::View* loading_shield = dialog()->GetLoadingShieldForTesting(); | 123 views::View* loading_shield = dialog()->GetLoadingShieldForTesting(); |
123 views::View* sign_in_web_view = dialog()->GetSignInWebViewForTesting(); | 124 views::View* sign_in_web_view = dialog()->GetSignInWebViewForTesting(); |
124 views::View* notification_area = dialog()->GetNotificationAreaForTesting(); | 125 views::View* notification_area = dialog()->GetNotificationAreaForTesting(); |
125 views::View* scrollable_area = dialog()->GetScrollableAreaForTesting(); | 126 views::View* scrollable_area = dialog()->GetScrollableAreaForTesting(); |
126 | 127 |
127 dialog()->ShowSignIn(); | 128 dialog()->ShowSignIn(wallet::GetAddAccountUrl()); |
128 | 129 |
129 // The sign in view should be the only showing and focusable view. | 130 // The sign in view should be the only showing and focusable view. |
130 EXPECT_TRUE(sign_in_web_view->IsFocusable()); | 131 EXPECT_TRUE(sign_in_web_view->IsFocusable()); |
131 EXPECT_FALSE(loading_shield->IsFocusable()); | 132 EXPECT_FALSE(loading_shield->IsFocusable()); |
132 EXPECT_FALSE(notification_area->IsFocusable()); | 133 EXPECT_FALSE(notification_area->IsFocusable()); |
133 EXPECT_FALSE(scrollable_area->IsFocusable()); | 134 EXPECT_FALSE(scrollable_area->IsFocusable()); |
134 | 135 |
135 EXPECT_CALL(*delegate(), ShouldShowSpinner()).WillRepeatedly(Return(false)); | 136 EXPECT_CALL(*delegate(), ShouldShowSpinner()).WillRepeatedly(Return(false)); |
136 dialog()->HideSignIn(); | 137 dialog()->HideSignIn(); |
137 | 138 |
138 // Hide sign in while not loading Wallet items as if the user clicked "Back". | 139 // Hide sign in while not loading Wallet items as if the user clicked "Back". |
139 EXPECT_TRUE(notification_area->IsFocusable()); | 140 EXPECT_TRUE(notification_area->IsFocusable()); |
140 EXPECT_TRUE(scrollable_area->IsFocusable()); | 141 EXPECT_TRUE(scrollable_area->IsFocusable()); |
141 EXPECT_FALSE(loading_shield->IsFocusable()); | 142 EXPECT_FALSE(loading_shield->IsFocusable()); |
142 EXPECT_FALSE(sign_in_web_view->IsFocusable()); | 143 EXPECT_FALSE(sign_in_web_view->IsFocusable()); |
143 | 144 |
144 dialog()->ShowSignIn(); | 145 dialog()->ShowSignIn(wallet::GetAddAccountUrl()); |
145 | 146 |
146 EXPECT_TRUE(sign_in_web_view->IsFocusable()); | 147 EXPECT_TRUE(sign_in_web_view->IsFocusable()); |
147 EXPECT_FALSE(loading_shield->IsFocusable()); | 148 EXPECT_FALSE(loading_shield->IsFocusable()); |
148 EXPECT_FALSE(notification_area->IsFocusable()); | 149 EXPECT_FALSE(notification_area->IsFocusable()); |
149 EXPECT_FALSE(scrollable_area->IsFocusable()); | 150 EXPECT_FALSE(scrollable_area->IsFocusable()); |
150 | 151 |
151 EXPECT_CALL(*delegate(), ShouldShowSpinner()).WillRepeatedly(Return(true)); | 152 EXPECT_CALL(*delegate(), ShouldShowSpinner()).WillRepeatedly(Return(true)); |
152 dialog()->HideSignIn(); | 153 dialog()->HideSignIn(); |
153 | 154 |
154 // Hide sign in while pretending to load Wallet data. | 155 // Hide sign in while pretending to load Wallet data. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 views::FocusManager* focus_manager = dialog()->GetWidget()->GetFocusManager(); | 191 views::FocusManager* focus_manager = dialog()->GetWidget()->GetFocusManager(); |
191 views::View* focused_view = focus_manager->GetFocusedView(); | 192 views::View* focused_view = focus_manager->GetFocusedView(); |
192 ASSERT_STREQ(DecoratedTextfield::kViewClassName, | 193 ASSERT_STREQ(DecoratedTextfield::kViewClassName, |
193 focused_view->GetClassName()); | 194 focused_view->GetClassName()); |
194 EXPECT_FALSE(dialog()->HandleKeyEvent( | 195 EXPECT_FALSE(dialog()->HandleKeyEvent( |
195 static_cast<views::Textfield*>(focused_view), | 196 static_cast<views::Textfield*>(focused_view), |
196 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE))); | 197 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE))); |
197 } | 198 } |
198 | 199 |
199 } // namespace autofill | 200 } // namespace autofill |
OLD | NEW |