Chromium Code Reviews| 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..02b7c8b6be62e193e37c01eb61b265f2f112c056 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,26 @@ class TestInitialFocusWidgetDelegate : public TestDesktopWidgetDelegate { |
| DISALLOW_COPY_AND_ASSIGN(TestInitialFocusWidgetDelegate); |
| }; |
| +// Spins a run loop until a Widget's activation reaches the desired state. |
|
sky
2016/10/12 19:23:53
How about:
// Use in tests to wait until a Widget'
Qiang(Joe) Xu
2016/10/12 20:25:16
Done.
|
| +class WidgetActivationWaiter : public WidgetObserver { |
| + public: |
| + WidgetActivationWaiter(Widget* widget, bool active); |
| + ~WidgetActivationWaiter() override; |
| + |
| + // Called to spin the run loop until widget activation changed is observed. |
|
sky
2016/10/12 19:23:53
How about:
Returns when the active status matches
Qiang(Joe) Xu
2016/10/12 20:25:16
done. tks.
|
| + void Wait(); |
| + |
| + 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 |