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 <algorithm> | 5 #include <algorithm> |
6 #include <memory> | 6 #include <memory> |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 toplevel->OnKeyEvent(&backspace_r); | 1182 toplevel->OnKeyEvent(&backspace_r); |
1183 EXPECT_FALSE(backspace_r.handled()); | 1183 EXPECT_FALSE(backspace_r.handled()); |
1184 } | 1184 } |
1185 | 1185 |
1186 // Verifies bubbles result in a focus lost when shown. | 1186 // Verifies bubbles result in a focus lost when shown. |
1187 // TODO(msw): this tests relies on focus, it needs to be in | 1187 // TODO(msw): this tests relies on focus, it needs to be in |
1188 // interactive_ui_tests. | 1188 // interactive_ui_tests. |
1189 TEST_F(WidgetTest, DISABLED_FocusChangesOnBubble) { | 1189 TEST_F(WidgetTest, DISABLED_FocusChangesOnBubble) { |
1190 // Create a widget, show and activate it and focus the contents view. | 1190 // Create a widget, show and activate it and focus the contents view. |
1191 View* contents_view = new View; | 1191 View* contents_view = new View; |
1192 contents_view->SetFocusable(true); | 1192 contents_view->SetFocusBehavior(views::View::FocusBehavior::ALWAYS); |
1193 Widget widget; | 1193 Widget widget; |
1194 Widget::InitParams init_params = | 1194 Widget::InitParams init_params = |
1195 CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 1195 CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
1196 init_params.bounds = gfx::Rect(0, 0, 200, 200); | 1196 init_params.bounds = gfx::Rect(0, 0, 200, 200); |
1197 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 1197 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
1198 #if !defined(OS_CHROMEOS) | 1198 #if !defined(OS_CHROMEOS) |
1199 init_params.native_widget = | 1199 init_params.native_widget = |
1200 CreatePlatformDesktopNativeWidgetImpl(init_params, &widget, nullptr); | 1200 CreatePlatformDesktopNativeWidgetImpl(init_params, &widget, nullptr); |
1201 #endif | 1201 #endif |
1202 widget.Init(init_params); | 1202 widget.Init(init_params); |
1203 widget.SetContentsView(contents_view); | 1203 widget.SetContentsView(contents_view); |
1204 widget.Show(); | 1204 widget.Show(); |
1205 widget.Activate(); | 1205 widget.Activate(); |
1206 contents_view->RequestFocus(); | 1206 contents_view->RequestFocus(); |
1207 EXPECT_TRUE(contents_view->HasFocus()); | 1207 EXPECT_TRUE(contents_view->HasFocus()); |
1208 | 1208 |
1209 // Show a bubble. | 1209 // Show a bubble. |
1210 BubbleDelegateView* bubble_delegate_view = | 1210 BubbleDelegateView* bubble_delegate_view = |
1211 new BubbleDelegateView(contents_view, BubbleBorder::TOP_LEFT); | 1211 new BubbleDelegateView(contents_view, BubbleBorder::TOP_LEFT); |
1212 bubble_delegate_view->SetFocusable(true); | 1212 bubble_delegate_view->SetFocusBehavior(views::View::FocusBehavior::ALWAYS); |
1213 BubbleDelegateView::CreateBubble(bubble_delegate_view)->Show(); | 1213 BubbleDelegateView::CreateBubble(bubble_delegate_view)->Show(); |
1214 bubble_delegate_view->RequestFocus(); | 1214 bubble_delegate_view->RequestFocus(); |
1215 | 1215 |
1216 // |contents_view_| should no longer have focus. | 1216 // |contents_view_| should no longer have focus. |
1217 EXPECT_FALSE(contents_view->HasFocus()); | 1217 EXPECT_FALSE(contents_view->HasFocus()); |
1218 EXPECT_TRUE(bubble_delegate_view->HasFocus()); | 1218 EXPECT_TRUE(bubble_delegate_view->HasFocus()); |
1219 | 1219 |
1220 bubble_delegate_view->GetWidget()->CloseNow(); | 1220 bubble_delegate_view->GetWidget()->CloseNow(); |
1221 | 1221 |
1222 // Closing the bubble should result in focus going back to the contents view. | 1222 // Closing the bubble should result in focus going back to the contents view. |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1344 }; | 1344 }; |
1345 | 1345 |
1346 void DesktopAuraTestValidPaintWidget::InitForTest(InitParams init_params) { | 1346 void DesktopAuraTestValidPaintWidget::InitForTest(InitParams init_params) { |
1347 init_params.bounds = gfx::Rect(0, 0, 200, 200); | 1347 init_params.bounds = gfx::Rect(0, 0, 200, 200); |
1348 init_params.ownership = InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 1348 init_params.ownership = InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
1349 init_params.native_widget = | 1349 init_params.native_widget = |
1350 CreatePlatformDesktopNativeWidgetImpl(init_params, this, nullptr); | 1350 CreatePlatformDesktopNativeWidgetImpl(init_params, this, nullptr); |
1351 Init(init_params); | 1351 Init(init_params); |
1352 | 1352 |
1353 View* contents_view = new View; | 1353 View* contents_view = new View; |
1354 contents_view->SetFocusable(true); | 1354 contents_view->SetFocusBehavior(views::View::FocusBehavior::ALWAYS); |
1355 SetContentsView(contents_view); | 1355 SetContentsView(contents_view); |
1356 | 1356 |
1357 Show(); | 1357 Show(); |
1358 Activate(); | 1358 Activate(); |
1359 } | 1359 } |
1360 | 1360 |
1361 #if defined(OS_LINUX) | 1361 #if defined(OS_LINUX) |
1362 // Flaky on Linux rel ng: https://crbug.com/596039. | 1362 // Flaky on Linux rel ng: https://crbug.com/596039. |
1363 #define MAYBE_DesktopNativeWidgetNoPaintAfterCloseTest DISABLED_DesktopNativeWid
getNoPaintAfterCloseTest | 1363 #define MAYBE_DesktopNativeWidgetNoPaintAfterCloseTest DISABLED_DesktopNativeWid
getNoPaintAfterCloseTest |
1364 #else | 1364 #else |
(...skipping 2137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3502 // Moving the child to a different widget should call the removals observer. | 3502 // Moving the child to a different widget should call the removals observer. |
3503 WidgetAutoclosePtr widget2(CreateTopLevelPlatformWidget()); | 3503 WidgetAutoclosePtr widget2(CreateTopLevelPlatformWidget()); |
3504 widget2->client_view()->AddChildView(child); | 3504 widget2->client_view()->AddChildView(child); |
3505 EXPECT_TRUE(removals_observer.DidRemoveView(child)); | 3505 EXPECT_TRUE(removals_observer.DidRemoveView(child)); |
3506 | 3506 |
3507 widget->RemoveRemovalsObserver(&removals_observer); | 3507 widget->RemoveRemovalsObserver(&removals_observer); |
3508 } | 3508 } |
3509 | 3509 |
3510 } // namespace test | 3510 } // namespace test |
3511 } // namespace views | 3511 } // namespace views |
OLD | NEW |