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

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

Issue 1982963002: Reland: mus: Add views_mus_interactive_ui_tests target (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix size_t to int warning on Windows 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/test/views_test_base.cc ('k') | no next file » | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 } 271 }
272 272
273 } // namespace 273 } // namespace
274 274
275 class WidgetTestInteractive : public WidgetTest { 275 class WidgetTestInteractive : public WidgetTest {
276 public: 276 public:
277 WidgetTestInteractive() {} 277 WidgetTestInteractive() {}
278 ~WidgetTestInteractive() override {} 278 ~WidgetTestInteractive() override {}
279 279
280 void SetUp() override { 280 void SetUp() override {
281 gfx::GLSurfaceTestSupport::InitializeOneOff(); 281 // On mus these tests run as part of views::ViewTestSuite which already does
282 ui::RegisterPathProvider(); 282 // this initialization.
283 base::FilePath ui_test_pak_path; 283 if (!IsMus()) {
284 ASSERT_TRUE(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path)); 284 gfx::GLSurfaceTestSupport::InitializeOneOff();
285 ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path); 285 ui::RegisterPathProvider();
286 base::FilePath ui_test_pak_path;
287 ASSERT_TRUE(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path));
288 ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
289 }
286 WidgetTest::SetUp(); 290 WidgetTest::SetUp();
287 } 291 }
288 292
289 protected: 293 protected:
290 #if defined(USE_AURA) 294 #if defined(USE_AURA)
291 static void ShowQuickMenuImmediately( 295 static void ShowQuickMenuImmediately(
292 TouchSelectionControllerImpl* controller) { 296 TouchSelectionControllerImpl* controller) {
293 DCHECK(controller); 297 DCHECK(controller);
294 if (controller->quick_menu_timer_.IsRunning()) { 298 if (controller->quick_menu_timer_.IsRunning()) {
295 controller->quick_menu_timer_.Stop(); 299 controller->quick_menu_timer_.Stop();
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 widget1->CloseNow(); 646 widget1->CloseNow();
643 widget2->CloseNow(); 647 widget2->CloseNow();
644 } 648 }
645 649
646 #if defined(OS_WIN) 650 #if defined(OS_WIN)
647 651
648 // Test view focus retention when a widget's HWND is disabled and re-enabled. 652 // Test view focus retention when a widget's HWND is disabled and re-enabled.
649 TEST_F(WidgetTestInteractive, ViewFocusOnHWNDEnabledChanges) { 653 TEST_F(WidgetTestInteractive, ViewFocusOnHWNDEnabledChanges) {
650 Widget* widget = CreateTopLevelFramelessPlatformWidget(); 654 Widget* widget = CreateTopLevelFramelessPlatformWidget();
651 widget->SetContentsView(new View); 655 widget->SetContentsView(new View);
652 for (size_t i = 0; i < 2; ++i) { 656 for (int i = 0; i < 2; ++i) {
653 widget->GetContentsView()->AddChildView(new View); 657 widget->GetContentsView()->AddChildView(new View);
654 widget->GetContentsView()->child_at(i)->SetFocusBehavior( 658 widget->GetContentsView()->child_at(i)->SetFocusBehavior(
655 View::FocusBehavior::ALWAYS); 659 View::FocusBehavior::ALWAYS);
656 } 660 }
657 661
658 widget->Show(); 662 widget->Show();
659 widget->GetNativeWindow()->GetHost()->Show(); 663 widget->GetNativeWindow()->GetHost()->Show();
660 const HWND hwnd = HWNDForWidget(widget); 664 const HWND hwnd = HWNDForWidget(widget);
661 EXPECT_TRUE(::IsWindow(hwnd)); 665 EXPECT_TRUE(::IsWindow(hwnd));
662 EXPECT_TRUE(::IsWindowEnabled(hwnd)); 666 EXPECT_TRUE(::IsWindowEnabled(hwnd));
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 874
871 private: 875 private:
872 ui::ModalType type_; 876 ui::ModalType type_;
873 877
874 DISALLOW_COPY_AND_ASSIGN(ModalDialogDelegate); 878 DISALLOW_COPY_AND_ASSIGN(ModalDialogDelegate);
875 }; 879 };
876 880
877 // Tests whether the focused window is set correctly when a modal window is 881 // Tests whether the focused window is set correctly when a modal window is
878 // created and destroyed. When it is destroyed it should focus the owner window. 882 // created and destroyed. When it is destroyed it should focus the owner window.
879 TEST_F(WidgetTestInteractive, WindowModalWindowDestroyedActivationTest) { 883 TEST_F(WidgetTestInteractive, WindowModalWindowDestroyedActivationTest) {
884 // Fails on mus due to focus issues. http://crbug.com/611601
885 if (IsMus())
886 return;
887
880 TestWidgetFocusChangeListener focus_listener; 888 TestWidgetFocusChangeListener focus_listener;
881 WidgetFocusManager::GetInstance()->AddFocusChangeListener(&focus_listener); 889 WidgetFocusManager::GetInstance()->AddFocusChangeListener(&focus_listener);
882 const std::vector<gfx::NativeView>& focus_changes = 890 const std::vector<gfx::NativeView>& focus_changes =
883 focus_listener.focus_changes(); 891 focus_listener.focus_changes();
884 892
885 // Create a top level widget. 893 // Create a top level widget.
886 Widget top_level_widget; 894 Widget top_level_widget;
887 Widget::InitParams init_params = 895 Widget::InitParams init_params =
888 CreateParams(Widget::InitParams::TYPE_WINDOW); 896 CreateParams(Widget::InitParams::TYPE_WINDOW);
889 init_params.show_state = ui::SHOW_STATE_NORMAL; 897 init_params.show_state = ui::SHOW_STATE_NORMAL;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 // those. 949 // those.
942 #if defined(OS_MACOSX) && !defined(USE_AURA) 950 #if defined(OS_MACOSX) && !defined(USE_AURA)
943 #define MAYBE_SystemModalWindowReleasesCapture \ 951 #define MAYBE_SystemModalWindowReleasesCapture \
944 DISABLED_SystemModalWindowReleasesCapture 952 DISABLED_SystemModalWindowReleasesCapture
945 #else 953 #else
946 #define MAYBE_SystemModalWindowReleasesCapture SystemModalWindowReleasesCapture 954 #define MAYBE_SystemModalWindowReleasesCapture SystemModalWindowReleasesCapture
947 #endif 955 #endif
948 956
949 // Test that when opening a system-modal window, capture is released. 957 // Test that when opening a system-modal window, capture is released.
950 TEST_F(WidgetTestInteractive, MAYBE_SystemModalWindowReleasesCapture) { 958 TEST_F(WidgetTestInteractive, MAYBE_SystemModalWindowReleasesCapture) {
959 // Crashes on mus due to capture issue. http://crbug.com/611764
960 if (IsMus())
961 return;
962
951 TestWidgetFocusChangeListener focus_listener; 963 TestWidgetFocusChangeListener focus_listener;
952 WidgetFocusManager::GetInstance()->AddFocusChangeListener(&focus_listener); 964 WidgetFocusManager::GetInstance()->AddFocusChangeListener(&focus_listener);
953 965
954 // Create a top level widget. 966 // Create a top level widget.
955 Widget top_level_widget; 967 Widget top_level_widget;
956 Widget::InitParams init_params = 968 Widget::InitParams init_params =
957 CreateParams(Widget::InitParams::TYPE_WINDOW); 969 CreateParams(Widget::InitParams::TYPE_WINDOW);
958 init_params.show_state = ui::SHOW_STATE_NORMAL; 970 init_params.show_state = ui::SHOW_STATE_NORMAL;
959 gfx::Rect initial_bounds(0, 0, 500, 500); 971 gfx::Rect initial_bounds(0, 0, 500, 500);
960 init_params.bounds = initial_bounds; 972 init_params.bounds = initial_bounds;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 CreatePlatformDesktopNativeWidgetImpl(init_params, &widget, nullptr); 1013 CreatePlatformDesktopNativeWidgetImpl(init_params, &widget, nullptr);
1002 widget.Init(init_params); 1014 widget.Init(init_params);
1003 1015
1004 widget.Show(); 1016 widget.Show();
1005 EXPECT_FALSE(widget.IsActive()); 1017 EXPECT_FALSE(widget.IsActive());
1006 } 1018 }
1007 1019
1008 #if defined(USE_AURA) 1020 #if defined(USE_AURA)
1009 // Test that touch selection quick menu is not activated when opened. 1021 // Test that touch selection quick menu is not activated when opened.
1010 TEST_F(WidgetTestInteractive, TouchSelectionQuickMenuIsNotActivated) { 1022 TEST_F(WidgetTestInteractive, TouchSelectionQuickMenuIsNotActivated) {
1023 // Fails on mus because the USER_PRIVATE window container is not visible by
1024 // default. See http://crbug.com/611601
1025 if (IsMus())
1026 return;
1027
1011 #if defined(OS_WIN) 1028 #if defined(OS_WIN)
1012 views_delegate()->set_use_desktop_native_widgets(true); 1029 views_delegate()->set_use_desktop_native_widgets(true);
1013 #endif // !defined(OS_WIN) 1030 #endif // !defined(OS_WIN)
1014 1031
1015 Widget* widget = CreateWidget(); 1032 Widget* widget = CreateWidget();
1016 1033
1017 Textfield* textfield = new Textfield; 1034 Textfield* textfield = new Textfield;
1018 textfield->SetBounds(0, 0, 200, 20); 1035 textfield->SetBounds(0, 0, 200, 20);
1019 textfield->SetText(base::ASCIIToUTF16("some text")); 1036 textfield->SetText(base::ASCIIToUTF16("some text"));
1020 widget->GetRootView()->AddChildView(textfield); 1037 widget->GetRootView()->AddChildView(textfield);
(...skipping 11 matching lines...) Expand all
1032 textfield_test_api.touch_selection_controller())); 1049 textfield_test_api.touch_selection_controller()));
1033 1050
1034 EXPECT_TRUE(textfield->HasFocus()); 1051 EXPECT_TRUE(textfield->HasFocus());
1035 EXPECT_TRUE(widget->IsActive()); 1052 EXPECT_TRUE(widget->IsActive());
1036 EXPECT_TRUE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); 1053 EXPECT_TRUE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
1037 widget->CloseNow(); 1054 widget->CloseNow();
1038 } 1055 }
1039 #endif // defined(USE_AURA) 1056 #endif // defined(USE_AURA)
1040 1057
1041 TEST_F(WidgetTestInteractive, DisableViewDoesNotActivateWidget) { 1058 TEST_F(WidgetTestInteractive, DisableViewDoesNotActivateWidget) {
1059 // Fails on mus because the USER_PRIVATE window container is not visible by
1060 // default. See http://crbug.com/611601
1061 if (IsMus())
1062 return;
1063
1042 #if defined(OS_WIN) 1064 #if defined(OS_WIN)
1043 views_delegate()->set_use_desktop_native_widgets(true); 1065 views_delegate()->set_use_desktop_native_widgets(true);
1044 #endif // !defined(OS_WIN) 1066 #endif // !defined(OS_WIN)
1045 1067
1046 // Create first widget and view, activate the widget, and focus the view. 1068 // Create first widget and view, activate the widget, and focus the view.
1047 Widget widget1; 1069 Widget widget1;
1048 Widget::InitParams params1 = CreateParams(Widget::InitParams::TYPE_POPUP); 1070 Widget::InitParams params1 = CreateParams(Widget::InitParams::TYPE_POPUP);
1049 params1.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 1071 params1.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
1050 params1.activatable = Widget::InitParams::ACTIVATABLE_YES; 1072 params1.activatable = Widget::InitParams::ACTIVATABLE_YES;
1051 widget1.Init(params1); 1073 widget1.Init(params1);
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 } // namespace 1300 } // namespace
1279 1301
1280 class WidgetCaptureTest : public ViewsTestBase { 1302 class WidgetCaptureTest : public ViewsTestBase {
1281 public: 1303 public:
1282 WidgetCaptureTest() { 1304 WidgetCaptureTest() {
1283 } 1305 }
1284 1306
1285 ~WidgetCaptureTest() override {} 1307 ~WidgetCaptureTest() override {}
1286 1308
1287 void SetUp() override { 1309 void SetUp() override {
1288 gfx::GLSurfaceTestSupport::InitializeOneOff(); 1310 // On mus these tests run as part of views::ViewTestSuite which already does
1289 ui::RegisterPathProvider(); 1311 // this initialization.
1290 base::FilePath ui_test_pak_path; 1312 if (!IsMus()) {
1291 ASSERT_TRUE(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path)); 1313 gfx::GLSurfaceTestSupport::InitializeOneOff();
1292 ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path); 1314 ui::RegisterPathProvider();
1315 base::FilePath ui_test_pak_path;
1316 ASSERT_TRUE(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path));
1317 ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
1318 }
1293 ViewsTestBase::SetUp(); 1319 ViewsTestBase::SetUp();
1294 } 1320 }
1295 1321
1296 // Verifies Widget::SetCapture() results in updating native capture along with 1322 // Verifies Widget::SetCapture() results in updating native capture along with
1297 // invoking the right Widget function. 1323 // invoking the right Widget function.
1298 void TestCapture(bool use_desktop_native_widget) { 1324 void TestCapture(bool use_desktop_native_widget) {
1299 CaptureLostTrackingWidget widget1; 1325 CaptureLostTrackingWidget widget1;
1300 Widget::InitParams params1 = 1326 Widget::InitParams params1 =
1301 CreateParams(views::Widget::InitParams::TYPE_WINDOW); 1327 CreateParams(views::Widget::InitParams::TYPE_WINDOW);
1302 params1.native_widget = 1328 params1.native_widget =
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 }; 1375 };
1350 1376
1351 // See description in TestCapture(). 1377 // See description in TestCapture().
1352 TEST_F(WidgetCaptureTest, Capture) { 1378 TEST_F(WidgetCaptureTest, Capture) {
1353 TestCapture(false); 1379 TestCapture(false);
1354 } 1380 }
1355 1381
1356 #if !defined(OS_CHROMEOS) 1382 #if !defined(OS_CHROMEOS)
1357 // See description in TestCapture(). Creates DesktopNativeWidget. 1383 // See description in TestCapture(). Creates DesktopNativeWidget.
1358 TEST_F(WidgetCaptureTest, CaptureDesktopNativeWidget) { 1384 TEST_F(WidgetCaptureTest, CaptureDesktopNativeWidget) {
1385 // Fails on mus. http://crbug.com/611764
1386 if (IsMus())
1387 return;
1388
1359 TestCapture(true); 1389 TestCapture(true);
1360 } 1390 }
1361 #endif 1391 #endif
1362 1392
1363 // Test that no state is set if capture fails. 1393 // Test that no state is set if capture fails.
1364 TEST_F(WidgetCaptureTest, FailedCaptureRequestIsNoop) { 1394 TEST_F(WidgetCaptureTest, FailedCaptureRequestIsNoop) {
1395 // Fails on mus. http://crbug.com/611764
1396 if (IsMus())
1397 return;
1398
1365 Widget widget; 1399 Widget widget;
1366 Widget::InitParams params = 1400 Widget::InitParams params =
1367 CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS); 1401 CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
1368 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 1402 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
1369 params.bounds = gfx::Rect(400, 400); 1403 params.bounds = gfx::Rect(400, 400);
1370 widget.Init(params); 1404 widget.Init(params);
1371 1405
1372 MouseView* mouse_view1 = new MouseView; 1406 MouseView* mouse_view1 = new MouseView;
1373 MouseView* mouse_view2 = new MouseView; 1407 MouseView* mouse_view2 = new MouseView;
1374 View* contents_view = new View; 1408 View* contents_view = new View;
(...skipping 22 matching lines...) Expand all
1397 // TODO(tapted): Investigate for toolkit-views on Mac http;//crbug.com/441064. 1431 // TODO(tapted): Investigate for toolkit-views on Mac http;//crbug.com/441064.
1398 #if defined(OS_CHROMEOS) || defined(OS_WIN) || defined(OS_MACOSX) 1432 #if defined(OS_CHROMEOS) || defined(OS_WIN) || defined(OS_MACOSX)
1399 #define MAYBE_MouseExitOnCaptureGrab DISABLED_MouseExitOnCaptureGrab 1433 #define MAYBE_MouseExitOnCaptureGrab DISABLED_MouseExitOnCaptureGrab
1400 #else 1434 #else
1401 #define MAYBE_MouseExitOnCaptureGrab MouseExitOnCaptureGrab 1435 #define MAYBE_MouseExitOnCaptureGrab MouseExitOnCaptureGrab
1402 #endif 1436 #endif
1403 1437
1404 // Test that a synthetic mouse exit is sent to the widget which was handling 1438 // Test that a synthetic mouse exit is sent to the widget which was handling
1405 // mouse events when a different widget grabs capture. 1439 // mouse events when a different widget grabs capture.
1406 TEST_F(WidgetCaptureTest, MAYBE_MouseExitOnCaptureGrab) { 1440 TEST_F(WidgetCaptureTest, MAYBE_MouseExitOnCaptureGrab) {
1441 // Fails on mus. http://crbug.com/611764
1442 if (IsMus())
1443 return;
1444
1407 Widget widget1; 1445 Widget widget1;
1408 Widget::InitParams params1 = 1446 Widget::InitParams params1 =
1409 CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS); 1447 CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
1410 params1.native_widget = CreateNativeWidget(params1, true, &widget1); 1448 params1.native_widget = CreateNativeWidget(params1, true, &widget1);
1411 params1.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 1449 params1.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
1412 widget1.Init(params1); 1450 widget1.Init(params1);
1413 MouseView* mouse_view1 = new MouseView; 1451 MouseView* mouse_view1 = new MouseView;
1414 widget1.SetContentsView(mouse_view1); 1452 widget1.SetContentsView(mouse_view1);
1415 widget1.Show(); 1453 widget1.Show();
1416 widget1.SetBounds(gfx::Rect(300, 300)); 1454 widget1.SetBounds(gfx::Rect(300, 300));
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 EXPECT_TRUE(widget->IsActive()); 1690 EXPECT_TRUE(widget->IsActive());
1653 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, 1691 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT,
1654 widget->GetInputMethod()->GetTextInputType()); 1692 widget->GetInputMethod()->GetTextInputType());
1655 #endif 1693 #endif
1656 widget->CloseNow(); 1694 widget->CloseNow();
1657 } 1695 }
1658 1696
1659 // Test input method focus changes affected by focus changes cross 2 windows 1697 // Test input method focus changes affected by focus changes cross 2 windows
1660 // which shares the same top window. 1698 // which shares the same top window.
1661 TEST_F(WidgetInputMethodInteractiveTest, TwoWindows) { 1699 TEST_F(WidgetInputMethodInteractiveTest, TwoWindows) {
1700 // Fails on mus. http://crbug.com/611766
1701 if (IsMus())
1702 return;
1703
1662 Widget* parent = CreateWidget(); 1704 Widget* parent = CreateWidget();
1663 parent->SetBounds(gfx::Rect(100, 100, 100, 100)); 1705 parent->SetBounds(gfx::Rect(100, 100, 100, 100));
1664 1706
1665 Widget* child = CreateChildNativeWidgetWithParent(parent); 1707 Widget* child = CreateChildNativeWidgetWithParent(parent);
1666 child->SetBounds(gfx::Rect(0, 0, 50, 50)); 1708 child->SetBounds(gfx::Rect(0, 0, 50, 50));
1667 child->Show(); 1709 child->Show();
1668 1710
1669 Textfield* textfield_parent = new Textfield; 1711 Textfield* textfield_parent = new Textfield;
1670 Textfield* textfield_child = new Textfield; 1712 Textfield* textfield_child = new Textfield;
1671 textfield_parent->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 1713 textfield_parent->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1758 1800
1759 ui::KeyEvent key_event2(key_event); 1801 ui::KeyEvent key_event2(key_event);
1760 widget->OnKeyEvent(&key_event2); 1802 widget->OnKeyEvent(&key_event2);
1761 EXPECT_FALSE(key_event2.stopped_propagation()); 1803 EXPECT_FALSE(key_event2.stopped_propagation());
1762 1804
1763 widget->CloseNow(); 1805 widget->CloseNow();
1764 } 1806 }
1765 1807
1766 } // namespace test 1808 } // namespace test
1767 } // namespace views 1809 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/test/views_test_base.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698