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

Unified Diff: ui/views/test/widget_test.cc

Issue 2875513003: cleanup: make WidgetClosingObserver as test support (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/test/widget_test.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/test/widget_test.cc
diff --git a/ui/views/test/widget_test.cc b/ui/views/test/widget_test.cc
index 457a63da806ba5eb6446b3b1e701611b12c4dc10..a96a9db970a7e626486ba275afa1d43365fe2a1d 100644
--- a/ui/views/test/widget_test.cc
+++ b/ui/views/test/widget_test.cc
@@ -68,7 +68,7 @@ Widget* WidgetTest::CreateChildNativeWidgetWithParent(Widget* parent) {
}
Widget* WidgetTest::CreateChildNativeWidget() {
- return CreateChildNativeWidgetWithParent(NULL);
+ return CreateChildNativeWidgetWithParent(nullptr);
}
Widget* WidgetTest::CreateNativeDesktopWidget() {
@@ -177,5 +177,20 @@ void WidgetActivationWaiter::OnWidgetActivationChanged(Widget* widget,
run_loop_.Quit();
}
+WidgetClosingObserver::WidgetClosingObserver(Widget* widget) : widget_(widget) {
+ widget_->AddObserver(this);
+}
+
+WidgetClosingObserver::~WidgetClosingObserver() {
+ if (widget_)
+ widget_->RemoveObserver(this);
+}
+
+void WidgetClosingObserver::OnWidgetClosing(Widget* widget) {
+ DCHECK_EQ(widget_, widget);
+ widget_->RemoveObserver(this);
+ widget_ = nullptr;
+}
+
} // namespace test
} // namespace views
« no previous file with comments | « ui/views/test/widget_test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698