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

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

Issue 993253002: MacViews: Implement Window-modal dialogs using sheets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update isolate Created 5 years, 9 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
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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 class WidgetTestInteractive : public WidgetTest { 227 class WidgetTestInteractive : public WidgetTest {
228 public: 228 public:
229 WidgetTestInteractive() {} 229 WidgetTestInteractive() {}
230 ~WidgetTestInteractive() override {} 230 ~WidgetTestInteractive() override {}
231 231
232 void SetUp() override { 232 void SetUp() override {
233 gfx::GLSurface::InitializeOneOffForTests(); 233 gfx::GLSurface::InitializeOneOffForTests();
234 ui::RegisterPathProvider(); 234 ui::RegisterPathProvider();
235 base::FilePath ui_test_pak_path; 235 base::FilePath ui_test_pak_path;
236 ASSERT_TRUE(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path)); 236 ASSERT_TRUE(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path));
237 ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path); 237 ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
tapted 2015/03/17 10:39:48 (note)
238 WidgetTest::SetUp(); 238 WidgetTest::SetUp();
239 } 239 }
240 240
241 protected: 241 protected:
242 static void ShowQuickMenuImmediately( 242 static void ShowQuickMenuImmediately(
243 TouchSelectionControllerImpl* controller) { 243 TouchSelectionControllerImpl* controller) {
244 DCHECK(controller); 244 DCHECK(controller);
245 if (controller->context_menu_timer_.IsRunning()) { 245 if (controller->context_menu_timer_.IsRunning()) {
246 controller->context_menu_timer_.Stop(); 246 controller->context_menu_timer_.Stop();
247 // TODO(tapted): Enable this when porting ui/views/touchui to Mac. 247 // TODO(tapted): Enable this when porting ui/views/touchui to Mac.
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 Widget top_level_widget; 734 Widget top_level_widget;
735 Widget::InitParams init_params = 735 Widget::InitParams init_params =
736 CreateParams(Widget::InitParams::TYPE_WINDOW); 736 CreateParams(Widget::InitParams::TYPE_WINDOW);
737 init_params.show_state = ui::SHOW_STATE_NORMAL; 737 init_params.show_state = ui::SHOW_STATE_NORMAL;
738 gfx::Rect initial_bounds(0, 0, 500, 500); 738 gfx::Rect initial_bounds(0, 0, 500, 500);
739 init_params.bounds = initial_bounds; 739 init_params.bounds = initial_bounds;
740 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 740 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
741 init_params.native_widget = 741 init_params.native_widget =
742 new PlatformDesktopNativeWidget(&top_level_widget); 742 new PlatformDesktopNativeWidget(&top_level_widget);
743 top_level_widget.Init(init_params); 743 top_level_widget.Init(init_params);
744 top_level_widget.Show(); 744 ShowSync(&top_level_widget);
745 745
746 gfx::NativeView top_level_native_view = top_level_widget.GetNativeView(); 746 gfx::NativeView top_level_native_view = top_level_widget.GetNativeView();
747 ASSERT_FALSE(focus_listener.focus_changes().empty()); 747 ASSERT_FALSE(focus_listener.focus_changes().empty());
748 EXPECT_EQ(1u, focus_changes.size()); 748 EXPECT_EQ(1u, focus_changes.size());
749 EXPECT_EQ(top_level_native_view, focus_changes[0]); 749 EXPECT_EQ(top_level_native_view, focus_changes[0]);
750 750
751 // Create a modal dialog. 751 // Create a modal dialog.
752 // This instance will be destroyed when the dialog is destroyed. 752 // This instance will be destroyed when the dialog is destroyed.
753 ModalDialogDelegate* dialog_delegate = 753 ModalDialogDelegate* dialog_delegate =
754 new ModalDialogDelegate(ui::MODAL_TYPE_WINDOW); 754 new ModalDialogDelegate(ui::MODAL_TYPE_WINDOW);
755 755
756 Widget* modal_dialog_widget = views::DialogDelegate::CreateDialogWidget( 756 Widget* modal_dialog_widget = views::DialogDelegate::CreateDialogWidget(
757 dialog_delegate, NULL, top_level_widget.GetNativeView()); 757 dialog_delegate, NULL, top_level_widget.GetNativeView());
758 modal_dialog_widget->SetBounds(gfx::Rect(100, 100, 200, 200)); 758 modal_dialog_widget->SetBounds(gfx::Rect(100, 100, 200, 200));
759
760 // Note the dialog widget doesn't need a ShowSync. Since it is modal, it gains
761 // active status synchronously, even on Mac.
759 modal_dialog_widget->Show(); 762 modal_dialog_widget->Show();
760 763
761 gfx::NativeView modal_native_view = modal_dialog_widget->GetNativeView(); 764 gfx::NativeView modal_native_view = modal_dialog_widget->GetNativeView();
762 EXPECT_EQ(3u, focus_changes.size()); 765 EXPECT_EQ(3u, focus_changes.size());
763 EXPECT_EQ(nullptr, focus_changes[1]); 766 EXPECT_EQ(nullptr, focus_changes[1]);
764 EXPECT_EQ(modal_native_view, focus_changes[2]); 767 EXPECT_EQ(modal_native_view, focus_changes[2]);
765 768
769 #if defined(OS_MACOSX)
770 // Window modal dialogs on Mac are "sheets", which animate to close before
771 // activating their parent widget.
772 WidgetActivationWaiter waiter(&top_level_widget, true);
773 modal_dialog_widget->Close();
774 waiter.Wait();
775 #else
766 modal_dialog_widget->CloseNow(); 776 modal_dialog_widget->CloseNow();
777 #endif
767 778
768 EXPECT_EQ(5u, focus_changes.size()); 779 EXPECT_EQ(5u, focus_changes.size());
769 EXPECT_EQ(nullptr, focus_changes[3]); 780 EXPECT_EQ(nullptr, focus_changes[3]);
770 EXPECT_EQ(top_level_native_view, focus_changes[4]); 781 EXPECT_EQ(top_level_native_view, focus_changes[4]);
771 782
772 top_level_widget.CloseNow(); 783 top_level_widget.CloseNow();
773 WidgetFocusManager::GetInstance()->RemoveFocusChangeListener(&focus_listener); 784 WidgetFocusManager::GetInstance()->RemoveFocusChangeListener(&focus_listener);
774 } 785 }
775 786
787 // Disabled on Mac. Desktop Mac doesn't have system modal windows since Carbon
788 // was deprecated. It does have application modal windows, but only Ash requests
789 // those.
790 #if defined(OS_MACOSX) && !defined(USE_AURA)
791 #define MAYBE_SystemModalWindowReleasesCapture \
792 DISABLED_SystemModalWindowReleasesCapture
793 #else
794 #define MAYBE_SystemModalWindowReleasesCapture SystemModalWindowReleasesCapture
795 #endif
796
776 // Test that when opening a system-modal window, capture is released. 797 // Test that when opening a system-modal window, capture is released.
777 TEST_F(WidgetTestInteractive, SystemModalWindowReleasesCapture) { 798 TEST_F(WidgetTestInteractive, MAYBE_SystemModalWindowReleasesCapture) {
778 TestWidgetFocusChangeListener focus_listener; 799 TestWidgetFocusChangeListener focus_listener;
779 WidgetFocusManager::GetInstance()->AddFocusChangeListener(&focus_listener); 800 WidgetFocusManager::GetInstance()->AddFocusChangeListener(&focus_listener);
780 801
781 // Create a top level widget. 802 // Create a top level widget.
782 Widget top_level_widget; 803 Widget top_level_widget;
783 Widget::InitParams init_params = 804 Widget::InitParams init_params =
784 CreateParams(Widget::InitParams::TYPE_WINDOW); 805 CreateParams(Widget::InitParams::TYPE_WINDOW);
785 init_params.show_state = ui::SHOW_STATE_NORMAL; 806 init_params.show_state = ui::SHOW_STATE_NORMAL;
786 gfx::Rect initial_bounds(0, 0, 500, 500); 807 gfx::Rect initial_bounds(0, 0, 500, 500);
787 init_params.bounds = initial_bounds; 808 init_params.bounds = initial_bounds;
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 ui::EventDispatchDetails details = widget1.GetNativeWindow()-> 1399 ui::EventDispatchDetails details = widget1.GetNativeWindow()->
1379 GetHost()->event_processor()->OnEventFromSource(&mouse_event); 1400 GetHost()->event_processor()->OnEventFromSource(&mouse_event);
1380 ASSERT_FALSE(details.dispatcher_destroyed); 1401 ASSERT_FALSE(details.dispatcher_destroyed);
1381 EXPECT_TRUE(widget1.GetAndClearGotMouseEvent()); 1402 EXPECT_TRUE(widget1.GetAndClearGotMouseEvent());
1382 EXPECT_FALSE(widget2.GetAndClearGotMouseEvent()); 1403 EXPECT_FALSE(widget2.GetAndClearGotMouseEvent());
1383 } 1404 }
1384 #endif // defined(OS_WIN) 1405 #endif // defined(OS_WIN)
1385 1406
1386 } // namespace test 1407 } // namespace test
1387 } // namespace views 1408 } // namespace views
OLDNEW
« chrome/interactive_ui_tests.isolate ('K') | « ui/views/widget/native_widget_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698