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

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

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/test/widget_test.h ('k') | ui/views/widget/widget_interactive_uitest.cc » ('j') | 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 d67e951ce23eeba26abce4340ca8c3ce1216a796..457a63da806ba5eb6446b3b1e701611b12c4dc10 100644
--- a/ui/views/test/widget_test.cc
+++ b/ui/views/test/widget_test.cc
@@ -150,5 +150,32 @@ View* TestInitialFocusWidgetDelegate::GetInitiallyFocusedView() {
return view_;
}
+WidgetActivationWaiter::WidgetActivationWaiter(Widget* widget, bool active)
+ : observed_(false), active_(active) {
+ if (active == widget->IsActive()) {
+ observed_ = true;
+ return;
+ }
+ widget->AddObserver(this);
+}
+
+WidgetActivationWaiter::~WidgetActivationWaiter() {}
+
+void WidgetActivationWaiter::Wait() {
+ if (!observed_)
+ run_loop_.Run();
+}
+
+void WidgetActivationWaiter::OnWidgetActivationChanged(Widget* widget,
+ bool active) {
+ if (active_ != active)
+ return;
+
+ observed_ = true;
+ widget->RemoveObserver(this);
+ if (run_loop_.running())
+ run_loop_.Quit();
+}
+
} // namespace test
} // namespace views
« no previous file with comments | « ui/views/test/widget_test.h ('k') | ui/views/widget/widget_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698