diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-09 21:42:35 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-09 21:42:35 +0000 |
commit | dc904a636d578e2134e5911c98b7e00831be5bd8 (patch) | |
tree | 8341a71bcb4138695f1a79437ae3be93ea8f2611 /ui | |
parent | 3159ca547dd7af238e0f18c1a33c1b3f6e830d22 (diff) | |
download | chromium_src-dc904a636d578e2134e5911c98b7e00831be5bd8.zip chromium_src-dc904a636d578e2134e5911c98b7e00831be5bd8.tar.gz chromium_src-dc904a636d578e2134e5911c98b7e00831be5bd8.tar.bz2 |
More work to make ash_unittests pass when we require context.
With the context checking DCHECK, ash_unittests and unit_tests now run on chromeos.
BUG=161882
Review URL: https://chromiumcodereview.appspot.com/11801027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175892 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/oak/oak.h | 2 | ||||
-rw-r--r-- | ui/oak/oak_window.cc | 9 | ||||
-rw-r--r-- | ui/views/controls/table/table_view_unittest.cc | 19 | ||||
-rw-r--r-- | ui/views/test/views_test_base.cc | 8 | ||||
-rw-r--r-- | ui/views/test/views_test_base.h | 4 | ||||
-rw-r--r-- | ui/views/widget/widget.cc | 12 | ||||
-rw-r--r-- | ui/views/widget/widget.h | 14 |
7 files changed, 46 insertions, 22 deletions
diff --git a/ui/oak/oak.h b/ui/oak/oak.h index 98afcc8..0ffdc85 100644 --- a/ui/oak/oak.h +++ b/ui/oak/oak.h @@ -10,7 +10,7 @@ namespace oak { // Shows the Oak window. Refocuses an existing one. -OAK_EXPORT void ShowOakWindow(); +OAK_EXPORT void ShowOakWindowWithContext(gfx::NativeView context); } // namespace oak diff --git a/ui/oak/oak_window.cc b/ui/oak/oak_window.cc index 7bcf202..832a7a9 100644 --- a/ui/oak/oak_window.cc +++ b/ui/oak/oak_window.cc @@ -146,11 +146,14 @@ void OakWindow::Init() { } // namespace internal -void ShowOakWindow() { +void ShowOakWindowWithContext(gfx::NativeView context) { if (!internal::OakWindow::instance) { + // TODO(erg): Do we want to reuse this window in times with a different + // context? For now, this is OK, but if we ever use Oak outside of the ash + // shell, we run into crbug.com/165759. internal::OakWindow::instance = - views::Widget::CreateWindowWithBounds(new internal::OakWindow, - gfx::Rect(10, 10, 500, 500)); + views::Widget::CreateWindowWithContextAndBounds( + new internal::OakWindow, context, gfx::Rect(10, 10, 500, 500)); } internal::OakWindow::instance->Show(); } diff --git a/ui/views/controls/table/table_view_unittest.cc b/ui/views/controls/table/table_view_unittest.cc index 797674f..5b14c5a 100644 --- a/ui/views/controls/table/table_view_unittest.cc +++ b/ui/views/controls/table/table_view_unittest.cc @@ -17,8 +17,8 @@ #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/models/table_model.h" #include "ui/base/models/table_model_observer.h" -#include "ui/base/win/scoped_ole_initializer.h" #include "ui/views/controls/table/table_view.h" +#include "ui/views/test/views_test_base.h" #include "ui/views/widget/widget.h" #include "ui/views/widget/widget_delegate.h" @@ -133,7 +133,7 @@ int TestTableModel::CompareValues(int row1, int row2, int column_id) { // TableViewTest --------------------------------------------------------------- -class TableViewTest : public testing::Test, views::WidgetDelegate { +class TableViewTest : public ViewsTestBase, views::WidgetDelegate { public: virtual void SetUp() OVERRIDE; virtual void TearDown() OVERRIDE; @@ -173,28 +173,29 @@ class TableViewTest : public testing::Test, views::WidgetDelegate { TableView* table_; private: - MessageLoopForUI message_loop_; views::Widget* window_; - ui::ScopedOleInitializer ole_initializer_; }; void TableViewTest::SetUp() { + ViewsTestBase::SetUp(); + model_.reset(CreateModel()); std::vector<ui::TableColumn> columns; columns.resize(2); columns[0].id = 0; columns[1].id = 1; + + // TODO(erg): This crashes on windows. Try making this derive from ViewsTests. table_ = new TableView(model_.get(), columns, views::ICON_AND_TEXT, false, false, false); - window_ = views::Widget::CreateWindowWithBounds( - this, - gfx::Rect(100, 100, 512, 512)); + window_ = views::Widget::CreateWindowWithContextAndBounds( + this, GetContext(), gfx::Rect(100, 100, 512, 512)); } void TableViewTest::TearDown() { window_->Close(); - // Temporary workaround to avoid leak of RootView::pending_paint_task_. - message_loop_.RunUntilIdle(); + + ViewsTestBase::TearDown(); } void TableViewTest::VerifyViewOrder(int first, ...) { diff --git a/ui/views/test/views_test_base.cc b/ui/views/test/views_test_base.cc index 494434b..d4c3dba 100644 --- a/ui/views/test/views_test_base.cc +++ b/ui/views/test/views_test_base.cc @@ -69,4 +69,12 @@ Widget::InitParams ViewsTestBase::CreateParams( return params; } +gfx::NativeView ViewsTestBase::GetContext() { +#if defined(USE_AURA) + return aura_test_helper_->root_window(); +#else + return NULL; +#endif +} + } // namespace views diff --git a/ui/views/test/views_test_base.h b/ui/views/test/views_test_base.h index f348a62..b59ffef 100644 --- a/ui/views/test/views_test_base.h +++ b/ui/views/test/views_test_base.h @@ -48,6 +48,10 @@ class ViewsTestBase : public testing::Test { // cross-platform tests. Widget::InitParams CreateParams(Widget::InitParams::Type type); + // Returns a context view. In aura builds, this will be the + // RootWindow. Everywhere else, NULL. + gfx::NativeView GetContext(); + private: MessageLoopForUI message_loop_; scoped_ptr<TestViewsDelegate> views_delegate_; diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc index 8aaa88a..9712cba 100644 --- a/ui/views/widget/widget.cc +++ b/ui/views/widget/widget.cc @@ -230,18 +230,18 @@ Widget* Widget::CreateWindow(WidgetDelegate* delegate) { } // static -Widget* Widget::CreateWindowWithParent(WidgetDelegate* delegate, - gfx::NativeWindow parent) { - return CreateWindowWithParentAndBounds(delegate, parent, gfx::Rect()); -} - -// static Widget* Widget::CreateWindowWithBounds(WidgetDelegate* delegate, const gfx::Rect& bounds) { return CreateWindowWithParentAndBounds(delegate, NULL, bounds); } // static +Widget* Widget::CreateWindowWithParent(WidgetDelegate* delegate, + gfx::NativeWindow parent) { + return CreateWindowWithParentAndBounds(delegate, parent, gfx::Rect()); +} + +// static Widget* Widget::CreateWindowWithParentAndBounds(WidgetDelegate* delegate, gfx::NativeWindow parent, const gfx::Rect& bounds) { diff --git a/ui/views/widget/widget.h b/ui/views/widget/widget.h index 0eaa78a..ac98e76 100644 --- a/ui/views/widget/widget.h +++ b/ui/views/widget/widget.h @@ -207,12 +207,20 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, Widget(); virtual ~Widget(); - // Creates a decorated window Widget with the specified properties. + // Creates a toplevel window with no context. These methods should only be + // used in cases where there is no contextual information because we're + // creating a toplevel window connected to no other event. + // + // If you have any parenting or context information, or can pass that + // information, prefer the WithParent or WithContext versions of these + // methods. static Widget* CreateWindow(WidgetDelegate* delegate); - static Widget* CreateWindowWithParent(WidgetDelegate* delegate, - gfx::NativeWindow parent); static Widget* CreateWindowWithBounds(WidgetDelegate* delegate, const gfx::Rect& bounds); + + // Creates a decorated window Widget with the specified properties. + static Widget* CreateWindowWithParent(WidgetDelegate* delegate, + gfx::NativeWindow parent); static Widget* CreateWindowWithParentAndBounds(WidgetDelegate* delegate, gfx::NativeWindow parent, const gfx::Rect& bounds); |