| 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 "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 namespace internal { | 26 namespace internal { |
| 27 | 27 |
| 28 class RootView; | 28 class RootView; |
| 29 | 29 |
| 30 } // namespace internal | 30 } // namespace internal |
| 31 | 31 |
| 32 namespace test { | 32 namespace test { |
| 33 | 33 |
| 34 class WidgetTest : public ViewsTestBase { | 34 class WidgetTest : public ViewsTestBase { |
| 35 public: | 35 public: |
| 36 // Scoped handle that fakes all widgets into claiming they are active. This | |
| 37 // allows a test to assume active status does not get stolen by a test that | |
| 38 // may be running in parallel. It shouldn't be used in tests that create | |
| 39 // multiple widgets. | |
| 40 class FakeActivation { | |
| 41 public: | |
| 42 virtual ~FakeActivation() {} | |
| 43 | |
| 44 protected: | |
| 45 FakeActivation() {} | |
| 46 | |
| 47 private: | |
| 48 DISALLOW_COPY_AND_ASSIGN(FakeActivation); | |
| 49 }; | |
| 50 | |
| 51 WidgetTest(); | 36 WidgetTest(); |
| 52 ~WidgetTest() override; | 37 ~WidgetTest() override; |
| 53 | 38 |
| 54 // Create Widgets with |native_widget| in InitParams set to an instance of | 39 // Create Widgets with |native_widget| in InitParams set to an instance of |
| 55 // platform specific widget type that has stubbled capture calls. | 40 // platform specific widget type that has stubbled capture calls. |
| 56 Widget* CreateTopLevelPlatformWidget(); | 41 Widget* CreateTopLevelPlatformWidget(); |
| 57 Widget* CreateTopLevelFramelessPlatformWidget(); | 42 Widget* CreateTopLevelFramelessPlatformWidget(); |
| 58 Widget* CreateChildPlatformWidget(gfx::NativeView parent_native_view); | 43 Widget* CreateChildPlatformWidget(gfx::NativeView parent_native_view); |
| 59 | 44 |
| 60 // Create Widgets initialized without a |native_widget| set in InitParams. | 45 // Create Widgets initialized without a |native_widget| set in InitParams. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 82 |
| 98 // Return the event processor for |widget|. On aura platforms, this is an | 83 // Return the event processor for |widget|. On aura platforms, this is an |
| 99 // aura::WindowEventDispatcher. Otherwise, it is a bridge to the OS event | 84 // aura::WindowEventDispatcher. Otherwise, it is a bridge to the OS event |
| 100 // processor. | 85 // processor. |
| 101 static ui::EventProcessor* GetEventProcessor(Widget* widget); | 86 static ui::EventProcessor* GetEventProcessor(Widget* widget); |
| 102 | 87 |
| 103 // Get the InputMethodDelegate, for setting on a Mock InputMethod in tests. | 88 // Get the InputMethodDelegate, for setting on a Mock InputMethod in tests. |
| 104 static ui::internal::InputMethodDelegate* GetInputMethodDelegateForWidget( | 89 static ui::internal::InputMethodDelegate* GetInputMethodDelegateForWidget( |
| 105 Widget* widget); | 90 Widget* widget); |
| 106 | 91 |
| 107 #if defined(OS_MACOSX) | |
| 108 static scoped_ptr<FakeActivation> FakeWidgetIsActiveAlways(); | |
| 109 #endif | |
| 110 | |
| 111 private: | 92 private: |
| 112 DISALLOW_COPY_AND_ASSIGN(WidgetTest); | 93 DISALLOW_COPY_AND_ASSIGN(WidgetTest); |
| 113 }; | 94 }; |
| 114 | 95 |
| 115 // A helper WidgetDelegate for tests that require hooks into WidgetDelegate | 96 // A helper WidgetDelegate for tests that require hooks into WidgetDelegate |
| 116 // calls, and removes some of the boilerplate for initializing a Widget. Calls | 97 // calls, and removes some of the boilerplate for initializing a Widget. Calls |
| 117 // Widget::CloseNow() when destroyed if it hasn't already been done. | 98 // Widget::CloseNow() when destroyed if it hasn't already been done. |
| 118 class TestDesktopWidgetDelegate : public WidgetDelegate { | 99 class TestDesktopWidgetDelegate : public WidgetDelegate { |
| 119 public: | 100 public: |
| 120 TestDesktopWidgetDelegate(); | 101 TestDesktopWidgetDelegate(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 148 int window_closing_count_ = 0; | 129 int window_closing_count_ = 0; |
| 149 gfx::Rect initial_bounds_ = gfx::Rect(100, 100, 200, 200); | 130 gfx::Rect initial_bounds_ = gfx::Rect(100, 100, 200, 200); |
| 150 | 131 |
| 151 DISALLOW_COPY_AND_ASSIGN(TestDesktopWidgetDelegate); | 132 DISALLOW_COPY_AND_ASSIGN(TestDesktopWidgetDelegate); |
| 152 }; | 133 }; |
| 153 | 134 |
| 154 } // namespace test | 135 } // namespace test |
| 155 } // namespace views | 136 } // namespace views |
| 156 | 137 |
| 157 #endif // UI_VIEWS_TEST_WIDGET_TEST_H_ | 138 #endif // UI_VIEWS_TEST_WIDGET_TEST_H_ |
| OLD | NEW |