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

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

Issue 1254963010: [Views] Move modality tests from widget_unittest.cc to desktop_native_widget_aura_unittest.cc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 5 years, 5 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/test_views.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 41a2647b7a65e11dcfa43f2306866d1a041079d5..fc7d0b5aacb6b80d6e3ee78ac8e2d72366d7cab8 100644
--- a/ui/views/test/widget_test.h
+++ b/ui/views/test/widget_test.h
@@ -7,6 +7,7 @@
#include "ui/gfx/native_widget_types.h"
#include "ui/views/test/views_test_base.h"
+#include "ui/views/widget/widget_delegate.h"
#if defined(USE_AURA)
#include "ui/views/widget/native_widget_aura.h"
@@ -145,6 +146,45 @@ class WidgetTest : public ViewsTestBase {
DISALLOW_COPY_AND_ASSIGN(WidgetTest);
};
+// A helper WidgetDelegate for tests that require hooks into WidgetDelegate
+// calls, and removes some of the boilerplate for initializing a Widget. Calls
+// Widget::CloseNow() when destroyed if it hasn't already been done.
+class TestDesktopWidgetDelegate : public WidgetDelegate {
+ public:
+ TestDesktopWidgetDelegate();
+ ~TestDesktopWidgetDelegate() override;
+
+ // Initialize the Widget, adding some meaningful default InitParams.
+ void InitWidget(Widget::InitParams init_params);
+
+ // Set the contents view to be used during Widget initialization. For Widgets
+ // that use non-client views, this will be the contents_view used to
+ // initialize the ClientView in WidgetDelegate::CreateClientView(). Otherwise,
+ // it is the ContentsView of the Widget's RootView. Ownership passes to the
+ // view hierarchy during InitWidget().
+ void set_contents_view(View* contents_view) {
+ contents_view_ = contents_view;
+ }
+
+ int window_closing_count() const { return window_closing_count_; }
+ const gfx::Rect& initial_bounds() { return initial_bounds_; }
+
+ // WidgetDelegate overrides:
+ void WindowClosing() override;
+ Widget* GetWidget() override;
+ const Widget* GetWidget() const override;
+ View* GetContentsView() override;
+ bool ShouldAdvanceFocusToTopLevelWidget() const override;
+
+ private:
+ Widget* widget_;
+ View* contents_view_ = nullptr;
+ int window_closing_count_ = 0;
+ gfx::Rect initial_bounds_ = gfx::Rect(100, 100, 200, 200);
+
+ DISALLOW_COPY_AND_ASSIGN(TestDesktopWidgetDelegate);
+};
+
} // namespace test
} // namespace views
« no previous file with comments | « ui/views/test/test_views.cc ('k') | ui/views/test/widget_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698