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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 if (active_ != active) | 171 if (active_ != active) |
172 return; | 172 return; |
173 | 173 |
174 observed_ = true; | 174 observed_ = true; |
175 widget->RemoveObserver(this); | 175 widget->RemoveObserver(this); |
176 if (run_loop_.running()) | 176 if (run_loop_.running()) |
177 run_loop_.Quit(); | 177 run_loop_.Quit(); |
178 } | 178 } |
179 | 179 |
180 WidgetClosingObserver::WidgetClosingObserver(Widget* widget) : widget_(widget) { | 180 WidgetClosingObserver::WidgetClosingObserver(Widget* widget) : widget_(widget) { |
181 if (!widget) | |
182 return; | |
xiyuan
2017/05/12 22:29:57
DCHECK(widget) or just get rid of it to let it cra
Qiang(Joe) Xu
2017/05/12 22:39:33
done by removing
| |
181 widget_->AddObserver(this); | 183 widget_->AddObserver(this); |
182 } | 184 } |
183 | 185 |
184 WidgetClosingObserver::~WidgetClosingObserver() { | 186 WidgetClosingObserver::~WidgetClosingObserver() { |
185 if (widget_) | 187 if (widget_) |
186 widget_->RemoveObserver(this); | 188 widget_->RemoveObserver(this); |
187 } | 189 } |
188 | 190 |
191 void WidgetClosingObserver::Wait() { | |
192 if (widget_) | |
193 run_loop_.Run(); | |
194 } | |
195 | |
189 void WidgetClosingObserver::OnWidgetClosing(Widget* widget) { | 196 void WidgetClosingObserver::OnWidgetClosing(Widget* widget) { |
190 DCHECK_EQ(widget_, widget); | 197 DCHECK_EQ(widget_, widget); |
191 widget_->RemoveObserver(this); | 198 widget_->RemoveObserver(this); |
192 widget_ = nullptr; | 199 widget_ = nullptr; |
200 if (run_loop_.running()) | |
201 run_loop_.Quit(); | |
193 } | 202 } |
194 | 203 |
195 } // namespace test | 204 } // namespace test |
196 } // namespace views | 205 } // namespace views |
OLD | NEW |