1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_VIEWS_TEST_WIDGET_TEST_H_
6 #define UI_VIEWS_TEST_WIDGET_TEST_H_
8 #include "ui/gfx/native_widget_types.h"
9 #include "ui/views/test/views_test_base.h"
12 #include "ui/views/widget/native_widget_aura.h"
13 #if !defined(OS_CHROMEOS)
14 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
16 #elif defined(OS_MACOSX)
17 #include "ui/views/widget/native_widget_mac.h"
30 typedef NativeWidgetAura PlatformNativeWidget
;
31 #if !defined(OS_CHROMEOS)
32 typedef DesktopNativeWidgetAura PlatformDesktopNativeWidget
;
34 #elif defined(OS_MACOSX)
35 typedef NativeWidgetMac PlatformNativeWidget
;
36 typedef NativeWidgetMac PlatformDesktopNativeWidget
;
43 } // namespace internal
47 // A widget that assumes mouse capture always works. It won't on Aura in
48 // testing, so we mock it.
49 class NativeWidgetCapture
: public PlatformNativeWidget
{
51 explicit NativeWidgetCapture(internal::NativeWidgetDelegate
* delegate
);
52 ~NativeWidgetCapture() override
;
54 void SetCapture() override
;
55 void ReleaseCapture() override
;
56 bool HasCapture() const override
;
61 DISALLOW_COPY_AND_ASSIGN(NativeWidgetCapture
);
64 class WidgetTest
: public ViewsTestBase
{
67 ~WidgetTest() override
;
69 NativeWidget
* CreatePlatformNativeWidget(
70 internal::NativeWidgetDelegate
* delegate
);
72 Widget
* CreateTopLevelPlatformWidget();
74 Widget
* CreateTopLevelFramelessPlatformWidget();
76 Widget
* CreateChildPlatformWidget(gfx::NativeView parent_native_view
);
78 Widget
* CreateTopLevelNativeWidget();
80 Widget
* CreateChildNativeWidgetWithParent(Widget
* parent
);
82 Widget
* CreateChildNativeWidget();
84 View
* GetMousePressedHandler(internal::RootView
* root_view
);
86 View
* GetMouseMoveHandler(internal::RootView
* root_view
);
88 View
* GetGestureHandler(internal::RootView
* root_view
);
90 // Simulate a OS-level destruction of the native widget held by |widget|.
91 static void SimulateNativeDestroy(Widget
* widget
);
93 // Return true if |window| is visible according to the native platform.
94 static bool IsNativeWindowVisible(gfx::NativeWindow window
);
96 // Return the event processor for |widget|. On aura platforms, this is an
97 // aura::WindowEventDispatcher. Otherwise, it is a bridge to the OS event
99 static ui::EventProcessor
* GetEventProcessor(Widget
* widget
);
102 DISALLOW_COPY_AND_ASSIGN(WidgetTest
);
108 #endif // UI_VIEWS_TEST_WIDGET_TEST_H_