- add sources.
[platform/framework/web/crosswalk.git] / src / ui / views / test / widget_test.h
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.
4
5 #ifndef UI_VIEWS_TEST_WIDGET_TEST_H_
6 #define UI_VIEWS_TEST_WIDGET_TEST_H_
7
8 #include "ui/gfx/native_widget_types.h"
9 #include "ui/views/test/views_test_base.h"
10
11 #if defined(USE_AURA)
12 #include "ui/views/widget/native_widget_aura.h"
13 #elif defined(OS_WIN)
14 #include "ui/views/widget/native_widget_win.h"
15 #endif
16
17 namespace views {
18
19 class NativeWidget;
20 class Widget;
21
22 namespace internal {
23
24 class RootView;
25
26 }  // namespace internal
27
28 namespace test {
29
30 #if defined(USE_AURA)
31 // A typedef that inserts our mock-capture NativeWidget implementation for
32 // relevant platforms.
33 typedef NativeWidgetAura NativeWidgetPlatform;
34
35 // A widget that assumes mouse capture always works. It won't on Aura in
36 // testing, so we mock it.
37 class NativeWidgetCapture : public NativeWidgetPlatform {
38  public:
39   explicit NativeWidgetCapture(internal::NativeWidgetDelegate* delegate);
40   virtual ~NativeWidgetCapture();
41
42   virtual void SetCapture() OVERRIDE;
43   virtual void ReleaseCapture() OVERRIDE;
44   virtual bool HasCapture() const OVERRIDE;
45
46  private:
47   bool mouse_capture_;
48
49   DISALLOW_COPY_AND_ASSIGN(NativeWidgetCapture);
50 };
51
52 // A generic typedef to pick up relevant NativeWidget implementations.
53 typedef NativeWidgetCapture NativeWidgetPlatformForTest;
54 #elif defined(OS_WIN)
55 typedef NativeWidgetWin NativeWidgetPlatform;
56 typedef NativeWidgetWin NativeWidgetPlatformForTest;
57 #endif
58
59 class WidgetTest : public ViewsTestBase {
60  public:
61   WidgetTest();
62   virtual ~WidgetTest();
63
64   NativeWidget* CreatePlatformNativeWidget(
65       internal::NativeWidgetDelegate* delegate);
66
67   Widget* CreateTopLevelPlatformWidget();
68
69   Widget* CreateTopLevelFramelessPlatformWidget();
70
71   Widget* CreateChildPlatformWidget(gfx::NativeView parent_native_view);
72
73 #if defined(OS_WIN) && !defined(USE_AURA)
74   // On Windows, it is possible for us to have a child window that is
75   // TYPE_POPUP.
76   Widget* CreateChildPopupPlatformWidget(gfx::NativeView parent_native_view);
77 #endif
78
79   Widget* CreateTopLevelNativeWidget();
80
81   Widget* CreateChildNativeWidgetWithParent(Widget* parent);
82
83   Widget* CreateChildNativeWidget();
84
85   View* GetMousePressedHandler(internal::RootView* root_view);
86
87   View* GetMouseMoveHandler(internal::RootView* root_view);
88
89   View* GetGestureHandler(internal::RootView* root_view);
90
91  private:
92   DISALLOW_COPY_AND_ASSIGN(WidgetTest);
93 };
94
95 }  // namespace test
96 }  // namespace views
97
98 #endif  // UI_VIEWS_TEST_WIDGET_TEST_H_