Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / ui / views / test / widget_test.h
blob6d1169e620658ef9e500e849396a41af1fb92091
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"
11 #if defined(USE_AURA)
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"
15 #endif
16 #elif defined(OS_MACOSX)
17 #include "ui/views/widget/native_widget_mac.h"
18 #endif
20 namespace ui {
21 class EventProcessor;
24 namespace views {
26 class NativeWidget;
27 class Widget;
29 #if defined(USE_AURA)
30 typedef NativeWidgetAura PlatformNativeWidget;
31 #if !defined(OS_CHROMEOS)
32 typedef DesktopNativeWidgetAura PlatformDesktopNativeWidget;
33 #endif
34 #elif defined(OS_MACOSX)
35 typedef NativeWidgetMac PlatformNativeWidget;
36 typedef NativeWidgetMac PlatformDesktopNativeWidget;
37 #endif
39 namespace internal {
41 class RootView;
43 } // namespace internal
45 namespace test {
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 {
50 public:
51 explicit NativeWidgetCapture(internal::NativeWidgetDelegate* delegate);
52 ~NativeWidgetCapture() override;
54 void SetCapture() override;
55 void ReleaseCapture() override;
56 bool HasCapture() const override;
58 private:
59 bool mouse_capture_;
61 DISALLOW_COPY_AND_ASSIGN(NativeWidgetCapture);
64 class WidgetTest : public ViewsTestBase {
65 public:
66 // Scoped handle that fakes all widgets into claiming they are active. This
67 // allows a test to assume active status does not get stolen by a test that
68 // may be running in parallel. It shouldn't be used in tests that create
69 // multiple widgets.
70 class FakeActivation {
71 public:
72 virtual ~FakeActivation() {}
74 protected:
75 FakeActivation() {}
77 private:
78 DISALLOW_COPY_AND_ASSIGN(FakeActivation);
81 WidgetTest();
82 ~WidgetTest() override;
84 // Create Widgets with |native_widget| in InitParams set to an instance of
85 // test::NativeWidgetCapture.
86 Widget* CreateTopLevelPlatformWidget();
87 Widget* CreateTopLevelFramelessPlatformWidget();
88 Widget* CreateChildPlatformWidget(gfx::NativeView parent_native_view);
90 // Create Widgets initialized without a |native_widget| set in InitParams.
91 // Depending on the test environment, ViewsDelegate::OnBeforeWidgetInit() may
92 // still provide one.
93 Widget* CreateTopLevelNativeWidget();
94 Widget* CreateChildNativeWidgetWithParent(Widget* parent);
95 Widget* CreateChildNativeWidget();
97 // Create a top-level Widget with |native_widget| in InitParams set to an
98 // instance of the "native desktop" type. This is a PlatformNativeWidget on
99 // ChromeOS, and a PlatformDesktopNativeWidget everywhere else.
100 Widget* CreateNativeDesktopWidget();
102 View* GetMousePressedHandler(internal::RootView* root_view);
104 View* GetMouseMoveHandler(internal::RootView* root_view);
106 View* GetGestureHandler(internal::RootView* root_view);
108 // Simulate a OS-level destruction of the native widget held by |widget|.
109 static void SimulateNativeDestroy(Widget* widget);
111 // Return true if |window| is visible according to the native platform.
112 static bool IsNativeWindowVisible(gfx::NativeWindow window);
114 // Return true if |above| is higher than |below| in the native window Z-order.
115 // Both windows must be visible.
116 static bool IsWindowStackedAbove(Widget* above, Widget* below);
118 // Query the native window system for the minimum size configured for user
119 // initiated window resizes.
120 static gfx::Size GetNativeWidgetMinimumContentSize(Widget* widget);
122 // Return the event processor for |widget|. On aura platforms, this is an
123 // aura::WindowEventDispatcher. Otherwise, it is a bridge to the OS event
124 // processor.
125 static ui::EventProcessor* GetEventProcessor(Widget* widget);
127 #if defined(OS_MACOSX)
128 static scoped_ptr<FakeActivation> FakeWidgetIsActiveAlways();
129 #endif
131 private:
132 DISALLOW_COPY_AND_ASSIGN(WidgetTest);
135 } // namespace test
136 } // namespace views
138 #endif // UI_VIEWS_TEST_WIDGET_TEST_H_