Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: ui/views/test/widget_test.h

Issue 1782773002: MacViews: Fix ViewTest.HandleAccelerator by faking window activation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Faked activations for everyone! Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/test/views_test_helper_mac.mm ('k') | ui/views/test/widget_test_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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_
OLDNEW
« no previous file with comments | « ui/views/test/views_test_helper_mac.mm ('k') | ui/views/test/widget_test_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698