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

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

Issue 2409423003: Move WidgetActivationWaiter to a common place (Closed)
Patch Set: based on comments Created 4 years, 2 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
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 "base/run_loop.h"
9 #include "build/build_config.h" 10 #include "build/build_config.h"
10 #include "ui/gfx/native_widget_types.h" 11 #include "ui/gfx/native_widget_types.h"
11 #include "ui/views/test/views_test_base.h" 12 #include "ui/views/test/views_test_base.h"
12 #include "ui/views/widget/widget_delegate.h" 13 #include "ui/views/widget/widget_delegate.h"
14 #include "ui/views/widget/widget_observer.h"
13 15
14 namespace ui { 16 namespace ui {
15 namespace internal { 17 namespace internal {
16 class InputMethodDelegate; 18 class InputMethodDelegate;
17 } 19 }
18 class EventProcessor; 20 class EventProcessor;
19 } 21 }
20 22
21 namespace views { 23 namespace views {
22 24
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 148
147 // WidgetDelegate override: 149 // WidgetDelegate override:
148 View* GetInitiallyFocusedView() override; 150 View* GetInitiallyFocusedView() override;
149 151
150 private: 152 private:
151 View* view_; 153 View* view_;
152 154
153 DISALLOW_COPY_AND_ASSIGN(TestInitialFocusWidgetDelegate); 155 DISALLOW_COPY_AND_ASSIGN(TestInitialFocusWidgetDelegate);
154 }; 156 };
155 157
158 // Use in tests to wait until a Widget's activation change to a particular
159 // value. To use create and call Wait().
160 class WidgetActivationWaiter : public WidgetObserver {
161 public:
162 WidgetActivationWaiter(Widget* widget, bool active);
163 ~WidgetActivationWaiter() override;
164
165 // Returns when the active status matches that supplied to the constructor. If
166 // the active status does not match that of the constructor a RunLoop is used
167 // until the active status matches, otherwise this returns immediately.
168 void Wait();
169
170 private:
171 // views::WidgetObserver override:
172 void OnWidgetActivationChanged(Widget* widget, bool active) override;
173
174 base::RunLoop run_loop_;
175 bool observed_;
176 bool active_;
177
178 DISALLOW_COPY_AND_ASSIGN(WidgetActivationWaiter);
179 };
180
156 } // namespace test 181 } // namespace test
157 } // namespace views 182 } // namespace views
158 183
159 #endif // UI_VIEWS_TEST_WIDGET_TEST_H_ 184 #endif // UI_VIEWS_TEST_WIDGET_TEST_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/libgtk2ui/select_file_dialog_interactive_uitest.cc ('k') | ui/views/test/widget_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698