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

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

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 | « chrome/browser/ui/libgtk2ui/select_file_dialog_interactive_uitest.cc ('k') | ui/views/test/widget_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..54257ee2c42f3241f40743a67ab7fe9fd65c70f7 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,29 @@ class TestInitialFocusWidgetDelegate : public TestDesktopWidgetDelegate {
DISALLOW_COPY_AND_ASSIGN(TestInitialFocusWidgetDelegate);
};
+// Use in tests to wait until a Widget's activation change to a particular
+// value. To use create and call Wait().
+class WidgetActivationWaiter : public WidgetObserver {
+ public:
+ WidgetActivationWaiter(Widget* widget, bool active);
+ ~WidgetActivationWaiter() override;
+
+ // Returns when the active status matches that supplied to the constructor. If
+ // the active status does not match that of the constructor a RunLoop is used
+ // until the active status matches, otherwise this returns immediately.
+ 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
« no previous file with comments | « chrome/browser/ui/libgtk2ui/select_file_dialog_interactive_uitest.cc ('k') | ui/views/test/widget_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698