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

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

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