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

Side by Side Diff: ui/views/widget/widget_unittest.cc

Issue 1898633004: Views: Add new SetFocusBehavior method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 4 years, 7 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
« no previous file with comments | « ui/views/widget/widget_interactive_uitest.cc ('k') | ui/views/window/dialog_client_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 toplevel->OnKeyEvent(&backspace_r); 1210 toplevel->OnKeyEvent(&backspace_r);
1211 EXPECT_FALSE(backspace_r.handled()); 1211 EXPECT_FALSE(backspace_r.handled());
1212 } 1212 }
1213 1213
1214 // Verifies bubbles result in a focus lost when shown. 1214 // Verifies bubbles result in a focus lost when shown.
1215 // TODO(msw): this tests relies on focus, it needs to be in 1215 // TODO(msw): this tests relies on focus, it needs to be in
1216 // interactive_ui_tests. 1216 // interactive_ui_tests.
1217 TEST_F(WidgetTest, DISABLED_FocusChangesOnBubble) { 1217 TEST_F(WidgetTest, DISABLED_FocusChangesOnBubble) {
1218 // Create a widget, show and activate it and focus the contents view. 1218 // Create a widget, show and activate it and focus the contents view.
1219 View* contents_view = new View; 1219 View* contents_view = new View;
1220 contents_view->SetFocusable(true); 1220 contents_view->SetFocusBehavior(View::FocusBehavior::ALWAYS);
1221 Widget widget; 1221 Widget widget;
1222 Widget::InitParams init_params = 1222 Widget::InitParams init_params =
1223 CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS); 1223 CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
1224 init_params.bounds = gfx::Rect(0, 0, 200, 200); 1224 init_params.bounds = gfx::Rect(0, 0, 200, 200);
1225 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 1225 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
1226 #if !defined(OS_CHROMEOS) 1226 #if !defined(OS_CHROMEOS)
1227 init_params.native_widget = 1227 init_params.native_widget =
1228 CreatePlatformDesktopNativeWidgetImpl(init_params, &widget, nullptr); 1228 CreatePlatformDesktopNativeWidgetImpl(init_params, &widget, nullptr);
1229 #endif 1229 #endif
1230 widget.Init(init_params); 1230 widget.Init(init_params);
1231 widget.SetContentsView(contents_view); 1231 widget.SetContentsView(contents_view);
1232 widget.Show(); 1232 widget.Show();
1233 widget.Activate(); 1233 widget.Activate();
1234 contents_view->RequestFocus(); 1234 contents_view->RequestFocus();
1235 EXPECT_TRUE(contents_view->HasFocus()); 1235 EXPECT_TRUE(contents_view->HasFocus());
1236 1236
1237 // Show a bubble. 1237 // Show a bubble.
1238 BubbleDialogDelegateView* bubble_delegate_view = 1238 BubbleDialogDelegateView* bubble_delegate_view =
1239 new TestBubbleDialogDelegateView(contents_view); 1239 new TestBubbleDialogDelegateView(contents_view);
1240 bubble_delegate_view->SetFocusable(true); 1240 bubble_delegate_view->SetFocusBehavior(View::FocusBehavior::ALWAYS);
1241 BubbleDialogDelegateView::CreateBubble(bubble_delegate_view)->Show(); 1241 BubbleDialogDelegateView::CreateBubble(bubble_delegate_view)->Show();
1242 bubble_delegate_view->RequestFocus(); 1242 bubble_delegate_view->RequestFocus();
1243 1243
1244 // |contents_view_| should no longer have focus. 1244 // |contents_view_| should no longer have focus.
1245 EXPECT_FALSE(contents_view->HasFocus()); 1245 EXPECT_FALSE(contents_view->HasFocus());
1246 EXPECT_TRUE(bubble_delegate_view->HasFocus()); 1246 EXPECT_TRUE(bubble_delegate_view->HasFocus());
1247 1247
1248 bubble_delegate_view->GetWidget()->CloseNow(); 1248 bubble_delegate_view->GetWidget()->CloseNow();
1249 1249
1250 // Closing the bubble should result in focus going back to the contents view. 1250 // Closing the bubble should result in focus going back to the contents view.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 }; 1357 };
1358 1358
1359 void DesktopAuraTestValidPaintWidget::InitForTest(InitParams init_params) { 1359 void DesktopAuraTestValidPaintWidget::InitForTest(InitParams init_params) {
1360 init_params.bounds = gfx::Rect(0, 0, 200, 200); 1360 init_params.bounds = gfx::Rect(0, 0, 200, 200);
1361 init_params.ownership = InitParams::WIDGET_OWNS_NATIVE_WIDGET; 1361 init_params.ownership = InitParams::WIDGET_OWNS_NATIVE_WIDGET;
1362 init_params.native_widget = 1362 init_params.native_widget =
1363 CreatePlatformDesktopNativeWidgetImpl(init_params, this, nullptr); 1363 CreatePlatformDesktopNativeWidgetImpl(init_params, this, nullptr);
1364 Init(init_params); 1364 Init(init_params);
1365 1365
1366 View* contents_view = new View; 1366 View* contents_view = new View;
1367 contents_view->SetFocusable(true); 1367 contents_view->SetFocusBehavior(View::FocusBehavior::ALWAYS);
1368 SetContentsView(contents_view); 1368 SetContentsView(contents_view);
1369 1369
1370 Show(); 1370 Show();
1371 Activate(); 1371 Activate();
1372 } 1372 }
1373 1373
1374 #if defined(OS_LINUX) 1374 #if defined(OS_LINUX)
1375 // Flaky on Linux rel ng: https://crbug.com/596039. 1375 // Flaky on Linux rel ng: https://crbug.com/596039.
1376 #define MAYBE_DesktopNativeWidgetNoPaintAfterCloseTest DISABLED_DesktopNativeWid getNoPaintAfterCloseTest 1376 #define MAYBE_DesktopNativeWidgetNoPaintAfterCloseTest DISABLED_DesktopNativeWid getNoPaintAfterCloseTest
1377 #else 1377 #else
(...skipping 2137 matching lines...) Expand 10 before | Expand all | Expand 10 after
3515 // Moving the child to a different widget should call the removals observer. 3515 // Moving the child to a different widget should call the removals observer.
3516 WidgetAutoclosePtr widget2(CreateTopLevelPlatformWidget()); 3516 WidgetAutoclosePtr widget2(CreateTopLevelPlatformWidget());
3517 widget2->client_view()->AddChildView(child); 3517 widget2->client_view()->AddChildView(child);
3518 EXPECT_TRUE(removals_observer.DidRemoveView(child)); 3518 EXPECT_TRUE(removals_observer.DidRemoveView(child));
3519 3519
3520 widget->RemoveRemovalsObserver(&removals_observer); 3520 widget->RemoveRemovalsObserver(&removals_observer);
3521 } 3521 }
3522 3522
3523 } // namespace test 3523 } // namespace test
3524 } // namespace views 3524 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/widget_interactive_uitest.cc ('k') | ui/views/window/dialog_client_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698