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 #include "ui/views/test/widget_test.h" | 5 #include "ui/views/test/widget_test.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "ui/gfx/native_widget_types.h" | 8 #include "ui/gfx/native_widget_types.h" |
9 #include "ui/views/test/native_widget_factory.h" | 9 #include "ui/views/test/native_widget_factory.h" |
10 #include "ui/views/widget/root_view.h" | 10 #include "ui/views/widget/root_view.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 179 |
180 WidgetClosingObserver::WidgetClosingObserver(Widget* widget) : widget_(widget) { | 180 WidgetClosingObserver::WidgetClosingObserver(Widget* widget) : widget_(widget) { |
181 widget_->AddObserver(this); | 181 widget_->AddObserver(this); |
182 } | 182 } |
183 | 183 |
184 WidgetClosingObserver::~WidgetClosingObserver() { | 184 WidgetClosingObserver::~WidgetClosingObserver() { |
185 if (widget_) | 185 if (widget_) |
186 widget_->RemoveObserver(this); | 186 widget_->RemoveObserver(this); |
187 } | 187 } |
188 | 188 |
| 189 void WidgetClosingObserver::Wait() { |
| 190 if (widget_) |
| 191 run_loop_.Run(); |
| 192 } |
| 193 |
189 void WidgetClosingObserver::OnWidgetClosing(Widget* widget) { | 194 void WidgetClosingObserver::OnWidgetClosing(Widget* widget) { |
190 DCHECK_EQ(widget_, widget); | 195 DCHECK_EQ(widget_, widget); |
191 widget_->RemoveObserver(this); | 196 widget_->RemoveObserver(this); |
192 widget_ = nullptr; | 197 widget_ = nullptr; |
| 198 if (run_loop_.running()) |
| 199 run_loop_.Quit(); |
193 } | 200 } |
194 | 201 |
195 } // namespace test | 202 } // namespace test |
196 } // namespace views | 203 } // namespace views |
OLD | NEW |