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

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

Issue 1254963010: [Views] Move modality tests from widget_unittest.cc to desktop_native_widget_aura_unittest.cc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 5 years, 4 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/test_views.cc ('k') | ui/views/test/widget_test.cc » ('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 "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 #include "ui/views/widget/widget_delegate.h"
10 11
11 #if defined(USE_AURA) 12 #if defined(USE_AURA)
12 #include "ui/views/widget/native_widget_aura.h" 13 #include "ui/views/widget/native_widget_aura.h"
13 #if !defined(OS_CHROMEOS) 14 #if !defined(OS_CHROMEOS)
14 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 15 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
15 #endif 16 #endif
16 #elif defined(OS_MACOSX) 17 #elif defined(OS_MACOSX)
17 #include "ui/views/widget/native_widget_mac.h" 18 #include "ui/views/widget/native_widget_mac.h"
18 #endif 19 #endif
19 20
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 Widget* widget); 139 Widget* widget);
139 140
140 #if defined(OS_MACOSX) 141 #if defined(OS_MACOSX)
141 static scoped_ptr<FakeActivation> FakeWidgetIsActiveAlways(); 142 static scoped_ptr<FakeActivation> FakeWidgetIsActiveAlways();
142 #endif 143 #endif
143 144
144 private: 145 private:
145 DISALLOW_COPY_AND_ASSIGN(WidgetTest); 146 DISALLOW_COPY_AND_ASSIGN(WidgetTest);
146 }; 147 };
147 148
149 // A helper WidgetDelegate for tests that require hooks into WidgetDelegate
150 // calls, and removes some of the boilerplate for initializing a Widget. Calls
151 // Widget::CloseNow() when destroyed if it hasn't already been done.
152 class TestDesktopWidgetDelegate : public WidgetDelegate {
153 public:
154 TestDesktopWidgetDelegate();
155 ~TestDesktopWidgetDelegate() override;
156
157 // Initialize the Widget, adding some meaningful default InitParams.
158 void InitWidget(Widget::InitParams init_params);
159
160 // Set the contents view to be used during Widget initialization. For Widgets
161 // that use non-client views, this will be the contents_view used to
162 // initialize the ClientView in WidgetDelegate::CreateClientView(). Otherwise,
163 // it is the ContentsView of the Widget's RootView. Ownership passes to the
164 // view hierarchy during InitWidget().
165 void set_contents_view(View* contents_view) {
166 contents_view_ = contents_view;
167 }
168
169 int window_closing_count() const { return window_closing_count_; }
170 const gfx::Rect& initial_bounds() { return initial_bounds_; }
171
172 // WidgetDelegate overrides:
173 void WindowClosing() override;
174 Widget* GetWidget() override;
175 const Widget* GetWidget() const override;
176 View* GetContentsView() override;
177 bool ShouldAdvanceFocusToTopLevelWidget() const override;
178
179 private:
180 Widget* widget_;
181 View* contents_view_ = nullptr;
182 int window_closing_count_ = 0;
183 gfx::Rect initial_bounds_ = gfx::Rect(100, 100, 200, 200);
184
185 DISALLOW_COPY_AND_ASSIGN(TestDesktopWidgetDelegate);
186 };
187
148 } // namespace test 188 } // namespace test
149 } // namespace views 189 } // namespace views
150 190
151 #endif // UI_VIEWS_TEST_WIDGET_TEST_H_ 191 #endif // UI_VIEWS_TEST_WIDGET_TEST_H_
OLDNEW
« no previous file with comments | « ui/views/test/test_views.cc ('k') | ui/views/test/widget_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698