diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-07 21:40:35 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-07 21:40:35 +0000 |
commit | a2e6af1853d23b82a87b4ae6554424cc6e5393fb (patch) | |
tree | ce0517e27e276e014f7cbec6ecc662c6f064a83d /ash/extended_desktop_unittest.cc | |
parent | 7a97aa864a3f602b4c032d3088df79528d69454f (diff) | |
download | chromium_src-a2e6af1853d23b82a87b4ae6554424cc6e5393fb.zip chromium_src-a2e6af1853d23b82a87b4ae6554424cc6e5393fb.tar.gz chromium_src-a2e6af1853d23b82a87b4ae6554424cc6e5393fb.tar.bz2 |
Continue threading context through unit tests.
- views_unittest now passes with the assert that checks that we have context.
- ash_unittest...is making progress towards that and this patch is already big.
BUG=161882
Review URL: https://codereview.chromium.org/11795004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175389 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/extended_desktop_unittest.cc')
-rw-r--r-- | ash/extended_desktop_unittest.cc | 58 |
1 files changed, 35 insertions, 23 deletions
diff --git a/ash/extended_desktop_unittest.cc b/ash/extended_desktop_unittest.cc index 29f8b88..5517f3c 100644 --- a/ash/extended_desktop_unittest.cc +++ b/ash/extended_desktop_unittest.cc @@ -33,24 +33,6 @@ namespace ash { namespace { -views::Widget* CreateTestWidgetWithParent(views::Widget* parent, - const gfx::Rect& bounds, - bool child) { - views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); - if (parent) - params.parent = parent->GetNativeView(); - params.bounds = bounds; - params.child = child; - views::Widget* widget = new views::Widget; - widget->Init(params); - widget->Show(); - return widget; -} - -views::Widget* CreateTestWidget(const gfx::Rect& bounds) { - return CreateTestWidgetWithParent(NULL, bounds, false); -} - void SetSecondaryDisplayLayout(DisplayLayout::Position position) { DisplayController* display_controller = Shell::GetInstance()->display_controller(); @@ -104,7 +86,36 @@ class MoveWindowByClickEventFilter : public ui::EventHandler { } // namespace -typedef test::AshTestBase ExtendedDesktopTest; +class ExtendedDesktopTest : public test::AshTestBase { + public: + views::Widget* CreateTestWidget(const gfx::Rect& bounds) { + return CreateTestWidgetWithParentAndContext( + NULL, CurrentContext(), bounds, false); + } + + views::Widget* CreateTestWidgetWithParent(views::Widget* parent, + const gfx::Rect& bounds, + bool child) { + CHECK(parent); + return CreateTestWidgetWithParentAndContext(parent, NULL, bounds, child); + } + + views::Widget* CreateTestWidgetWithParentAndContext(views::Widget* parent, + gfx::NativeView context, + const gfx::Rect& bounds, + bool child) { + views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); + if (parent) + params.parent = parent->GetNativeView(); + params.context = context; + params.bounds = bounds; + params.child = child; + views::Widget* widget = new views::Widget; + widget->Init(params); + widget->Show(); + return widget; + } +}; // Test conditions that root windows in extended desktop mode // must satisfy. @@ -170,8 +181,10 @@ TEST_F(ExtendedDesktopTest, SystemModal) { EXPECT_EQ(root_windows[0], Shell::GetActiveRootWindow()); // Open system modal. Make sure it's on 2nd root window and active. - views::Widget* modal_widget = views::Widget::CreateWindowWithBounds( - new ModalWidgetDelegate(), gfx::Rect(1200, 100, 100, 100)); + views::Widget* modal_widget = views::Widget::CreateWindowWithContextAndBounds( + new ModalWidgetDelegate(), + CurrentContext(), + gfx::Rect(1200, 100, 100, 100)); modal_widget->Show(); EXPECT_TRUE(wm::IsActiveWindow(modal_widget->GetNativeView())); EXPECT_EQ(root_windows[1], modal_widget->GetNativeView()->GetRootWindow()); @@ -608,8 +621,7 @@ TEST_F(ExtendedDesktopTest, OpenSystemTray) { TEST_F(ExtendedDesktopTest, StayInSameRootWindow) { UpdateDisplay("100x100,200x200"); Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); - views::Widget* w1 = CreateTestWidgetWithParent( - NULL, gfx::Rect(10, 10, 50, 50), false); + views::Widget* w1 = CreateTestWidget(gfx::Rect(10, 10, 50, 50)); EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow()); w1->SetBounds(gfx::Rect(150, 10, 50, 50)); EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow()); |