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 "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 DISALLOW_COPY_AND_ASSIGN(WidgetActivationWaiter); | 177 DISALLOW_COPY_AND_ASSIGN(WidgetActivationWaiter); |
178 }; | 178 }; |
179 | 179 |
180 // Use in tests to provide functionality to observe the widget passed in the | 180 // Use in tests to provide functionality to observe the widget passed in the |
181 // constructor for the widget closing event. | 181 // constructor for the widget closing event. |
182 class WidgetClosingObserver : public WidgetObserver { | 182 class WidgetClosingObserver : public WidgetObserver { |
183 public: | 183 public: |
184 explicit WidgetClosingObserver(Widget* widget); | 184 explicit WidgetClosingObserver(Widget* widget); |
185 ~WidgetClosingObserver() override; | 185 ~WidgetClosingObserver() override; |
186 | 186 |
| 187 // Returns immediately when |widget_| becomes NULL, otherwise a RunLoop is |
| 188 // used until widget closing event is received. |
| 189 void Wait(); |
| 190 |
187 bool widget_closed() const { return !widget_; } | 191 bool widget_closed() const { return !widget_; } |
188 | 192 |
189 private: | 193 private: |
190 // views::WidgetObserver override: | 194 // views::WidgetObserver override: |
191 void OnWidgetClosing(Widget* widget) override; | 195 void OnWidgetClosing(Widget* widget) override; |
192 | 196 |
193 Widget* widget_; | 197 Widget* widget_; |
| 198 base::RunLoop run_loop_; |
194 | 199 |
195 DISALLOW_COPY_AND_ASSIGN(WidgetClosingObserver); | 200 DISALLOW_COPY_AND_ASSIGN(WidgetClosingObserver); |
196 }; | 201 }; |
197 | 202 |
198 } // namespace test | 203 } // namespace test |
199 } // namespace views | 204 } // namespace views |
200 | 205 |
201 #endif // UI_VIEWS_TEST_WIDGET_TEST_H_ | 206 #endif // UI_VIEWS_TEST_WIDGET_TEST_H_ |
OLD | NEW |