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

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

Issue 2409423003: Move WidgetActivationWaiter to a common place (Closed)
Patch Set: remove run_loop include 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
Index: ui/views/test/widget_test.h
diff --git a/ui/views/test/widget_test.h b/ui/views/test/widget_test.h
index fe04891ec8648d1d735c5df4fd84a656257d21b3..5b02be7805dc395d01d73f464c26e7902963a0b4 100644
--- a/ui/views/test/widget_test.h
+++ b/ui/views/test/widget_test.h
@@ -6,10 +6,12 @@
#define UI_VIEWS_TEST_WIDGET_TEST_H_
#include "base/macros.h"
+#include "base/run_loop.h"
#include "build/build_config.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/widget/widget_delegate.h"
+#include "ui/views/widget/widget_observer.h"
namespace ui {
namespace internal {
@@ -153,6 +155,25 @@ class TestInitialFocusWidgetDelegate : public TestDesktopWidgetDelegate {
DISALLOW_COPY_AND_ASSIGN(TestInitialFocusWidgetDelegate);
};
+// Spins a run loop until a Widget's activation reaches the desired state.
+class WidgetActivationWaiter : public WidgetObserver {
+ public:
+ WidgetActivationWaiter(Widget* widget, bool active);
+ ~WidgetActivationWaiter() override;
+
+ void Wait();
sky 2016/10/12 16:05:43 Document what this does.
Qiang(Joe) Xu 2016/10/12 16:55:58 Done.
+
+ private:
+ // views::WidgetObserver override:
+ void OnWidgetActivationChanged(Widget* widget, bool active) override;
+
+ base::RunLoop run_loop_;
+ bool observed_;
+ bool active_;
+
+ DISALLOW_COPY_AND_ASSIGN(WidgetActivationWaiter);
+};
+
} // namespace test
} // namespace views

Powered by Google App Engine
This is Rietveld 408576698