OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef UI_VIEWS_TEST_WIDGET_TEST_H_ | 5 #ifndef UI_VIEWS_TEST_WIDGET_TEST_H_ |
6 #define UI_VIEWS_TEST_WIDGET_TEST_H_ | 6 #define UI_VIEWS_TEST_WIDGET_TEST_H_ |
7 | 7 |
8 #include "ui/gfx/native_widget_types.h" | 8 #include "ui/gfx/native_widget_types.h" |
9 #include "ui/views/test/views_test_base.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" | 10 #include "ui/views/widget/native_widget_aura.h" |
13 #endif | |
14 | 11 |
15 namespace views { | 12 namespace views { |
16 | 13 |
17 class NativeWidget; | 14 class NativeWidget; |
18 class Widget; | 15 class Widget; |
19 | 16 |
20 namespace internal { | 17 namespace internal { |
21 | 18 |
22 class RootView; | 19 class RootView; |
23 | 20 |
24 } // namespace internal | 21 } // namespace internal |
25 | 22 |
26 namespace test { | 23 namespace test { |
27 | 24 |
28 #if defined(USE_AURA) | |
29 // A typedef that inserts our mock-capture NativeWidget implementation for | |
30 // relevant platforms. | |
31 typedef NativeWidgetAura NativeWidgetPlatform; | |
32 | |
33 // A widget that assumes mouse capture always works. It won't on Aura in | 25 // A widget that assumes mouse capture always works. It won't on Aura in |
34 // testing, so we mock it. | 26 // testing, so we mock it. |
35 class NativeWidgetCapture : public NativeWidgetPlatform { | 27 class NativeWidgetCapture : public NativeWidgetAura { |
36 public: | 28 public: |
37 explicit NativeWidgetCapture(internal::NativeWidgetDelegate* delegate); | 29 explicit NativeWidgetCapture(internal::NativeWidgetDelegate* delegate); |
38 virtual ~NativeWidgetCapture(); | 30 virtual ~NativeWidgetCapture(); |
39 | 31 |
40 virtual void SetCapture() OVERRIDE; | 32 virtual void SetCapture() OVERRIDE; |
41 virtual void ReleaseCapture() OVERRIDE; | 33 virtual void ReleaseCapture() OVERRIDE; |
42 virtual bool HasCapture() const OVERRIDE; | 34 virtual bool HasCapture() const OVERRIDE; |
43 | 35 |
44 private: | 36 private: |
45 bool mouse_capture_; | 37 bool mouse_capture_; |
46 | 38 |
47 DISALLOW_COPY_AND_ASSIGN(NativeWidgetCapture); | 39 DISALLOW_COPY_AND_ASSIGN(NativeWidgetCapture); |
48 }; | 40 }; |
49 | 41 |
50 // A generic typedef to pick up relevant NativeWidget implementations. | |
51 typedef NativeWidgetCapture NativeWidgetPlatformForTest; | |
52 #endif | |
53 | |
54 class WidgetTest : public ViewsTestBase { | 42 class WidgetTest : public ViewsTestBase { |
55 public: | 43 public: |
56 WidgetTest(); | 44 WidgetTest(); |
57 virtual ~WidgetTest(); | 45 virtual ~WidgetTest(); |
58 | 46 |
59 NativeWidget* CreatePlatformNativeWidget( | 47 NativeWidget* CreatePlatformNativeWidget( |
60 internal::NativeWidgetDelegate* delegate); | 48 internal::NativeWidgetDelegate* delegate); |
61 | 49 |
62 Widget* CreateTopLevelPlatformWidget(); | 50 Widget* CreateTopLevelPlatformWidget(); |
63 | 51 |
(...skipping 14 matching lines...) Expand all Loading... |
78 View* GetGestureHandler(internal::RootView* root_view); | 66 View* GetGestureHandler(internal::RootView* root_view); |
79 | 67 |
80 private: | 68 private: |
81 DISALLOW_COPY_AND_ASSIGN(WidgetTest); | 69 DISALLOW_COPY_AND_ASSIGN(WidgetTest); |
82 }; | 70 }; |
83 | 71 |
84 } // namespace test | 72 } // namespace test |
85 } // namespace views | 73 } // namespace views |
86 | 74 |
87 #endif // UI_VIEWS_TEST_WIDGET_TEST_H_ | 75 #endif // UI_VIEWS_TEST_WIDGET_TEST_H_ |
OLD | NEW |