diff options
-rw-r--r-- | views/examples/examples_main.cc | 9 | ||||
-rw-r--r-- | views/examples/examples_main.h | 6 | ||||
-rw-r--r-- | views/test/test_views_delegate.cc | 29 | ||||
-rw-r--r-- | views/test/test_views_delegate.h | 26 | ||||
-rw-r--r-- | views/test/views_test_base.cc | 31 | ||||
-rw-r--r-- | views/test/views_test_base.h | 24 | ||||
-rw-r--r-- | views/views.gyp | 2 |
7 files changed, 88 insertions, 39 deletions
diff --git a/views/examples/examples_main.cc b/views/examples/examples_main.cc index 375390b..7346abc 100644 --- a/views/examples/examples_main.cc +++ b/views/examples/examples_main.cc @@ -39,6 +39,15 @@ namespace examples { +ExamplesMain::ExamplesMain() + : contents_(NULL), status_label_(NULL) {} + +ExamplesMain::~ExamplesMain() {} + +bool ExamplesMain::CanResize() const { + return true; +} + views::View* ExamplesMain::GetContentsView() { return contents_; } diff --git a/views/examples/examples_main.h b/views/examples/examples_main.h index 000d24a..db4b86c 100644 --- a/views/examples/examples_main.h +++ b/views/examples/examples_main.h @@ -21,11 +21,11 @@ namespace examples { // ExamplesMainBase creates all view examples and start event loop. class ExamplesMain : public views::WindowDelegate { public: - ExamplesMain() : contents_(NULL), status_label_(NULL) {} - virtual ~ExamplesMain() {} + ExamplesMain(); + virtual ~ExamplesMain(); // views::WindowDelegate implementation: - virtual bool CanResize() const { return true; } + virtual bool CanResize() const; virtual views::View* GetContentsView(); virtual void WindowClosing(); diff --git a/views/test/test_views_delegate.cc b/views/test/test_views_delegate.cc new file mode 100644 index 0000000..a9f9b58 --- /dev/null +++ b/views/test/test_views_delegate.cc @@ -0,0 +1,29 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "views/test/test_views_delegate.h" + +TestViewsDelegate::TestViewsDelegate() {} +TestViewsDelegate::~TestViewsDelegate() {} + +ui::Clipboard* TestViewsDelegate::GetClipboard() const { + if (!clipboard_.get()) { + // Note that we need a MessageLoop for the next call to work. + clipboard_.reset(new ui::Clipboard); + } + return clipboard_.get(); +} + + +bool TestViewsDelegate::GetSavedWindowBounds(views::Window* window, + const std::wstring& window_name, + gfx::Rect* bounds) const { + return false; +} + +bool TestViewsDelegate::GetSavedMaximizedState(views::Window* window, + const std::wstring& window_name, + bool* maximized) const { + return false; +} diff --git a/views/test/test_views_delegate.h b/views/test/test_views_delegate.h index 2ac03ae..9aaee21 100644 --- a/views/test/test_views_delegate.h +++ b/views/test/test_views_delegate.h @@ -1,7 +1,10 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#ifndef VIEWS_TEST_TEST_VIEWS_DELEGATE_H_ +#define VIEWS_TEST_TEST_VIEWS_DELEGATE_H_ + #include "base/scoped_ptr.h" #include "ui/base/clipboard/clipboard.h" #include "views/views_delegate.h" @@ -12,17 +15,11 @@ class Window; class TestViewsDelegate : public views::ViewsDelegate { public: - TestViewsDelegate() {} - virtual ~TestViewsDelegate() {} + TestViewsDelegate(); + virtual ~TestViewsDelegate(); // Overridden from views::ViewsDelegate: - virtual ui::Clipboard* GetClipboard() const { - if (!clipboard_.get()) { - // Note that we need a MessageLoop for the next call to work. - clipboard_.reset(new ui::Clipboard); - } - return clipboard_.get(); - } + virtual ui::Clipboard* GetClipboard() const; virtual void SaveWindowPlacement(views::Window* window, const std::wstring& window_name, const gfx::Rect& bounds, @@ -30,14 +27,10 @@ class TestViewsDelegate : public views::ViewsDelegate { } virtual bool GetSavedWindowBounds(views::Window* window, const std::wstring& window_name, - gfx::Rect* bounds) const { - return false; - } + gfx::Rect* bounds) const; virtual bool GetSavedMaximizedState(views::Window* window, const std::wstring& window_name, - bool* maximized) const { - return false; - } + bool* maximized) const; virtual void NotifyAccessibilityEvent( views::View* view, AccessibilityTypes::Event event_type) {} virtual void NotifyMenuItemFocused( @@ -60,3 +53,4 @@ class TestViewsDelegate : public views::ViewsDelegate { DISALLOW_COPY_AND_ASSIGN(TestViewsDelegate); }; +#endif // VIEWS_TEST_TEST_VIEWS_DELEGATE_H_ diff --git a/views/test/views_test_base.cc b/views/test/views_test_base.cc new file mode 100644 index 0000000..c78bf27 --- /dev/null +++ b/views/test/views_test_base.cc @@ -0,0 +1,31 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "views/test/views_test_base.h" + +#if defined(OS_WIN) +#include <ole2.h> +#endif + +namespace views { + +ViewsTestBase::ViewsTestBase() { +#if defined(OS_WIN) + OleInitialize(NULL); +#endif +} + +ViewsTestBase::~ViewsTestBase() { +#if defined(OS_WIN) + OleUninitialize(); +#endif +} + +void ViewsTestBase::TearDown() { + // Flush the message loop because we have pending release tasks + // and these tasks if un-executed would upset Valgrind. + RunPendingMessages(); +} + +} // namespace views diff --git a/views/test/views_test_base.h b/views/test/views_test_base.h index d66a1d8..7c45c2e 100644 --- a/views/test/views_test_base.h +++ b/views/test/views_test_base.h @@ -10,33 +10,17 @@ #include "base/message_loop.h" -#if defined(OS_WIN) -#include <ole2.h> -#endif - namespace views { // A base class for views unit test. It creates a message loop necessary // to drive UI events and takes care of OLE initialization for windows. class ViewsTestBase : public testing::Test { public: - ViewsTestBase() { -#if defined(OS_WIN) - OleInitialize(NULL); -#endif - } + ViewsTestBase(); + virtual ~ViewsTestBase(); - virtual ~ViewsTestBase() { -#if defined(OS_WIN) - OleUninitialize(); -#endif - } - - virtual void TearDown() { - // Flush the message loop because we have pending release tasks - // and these tasks if un-executed would upset Valgrind. - RunPendingMessages(); - } + // testing::Test: + virtual void TearDown(); void RunPendingMessages() { message_loop_.RunAllPending(); diff --git a/views/views.gyp b/views/views.gyp index 0bda492..e99ee7d 100644 --- a/views/views.gyp +++ b/views/views.gyp @@ -487,8 +487,10 @@ 'focus/focus_manager_unittest.cc', 'layout/grid_layout_unittest.cc', 'layout/box_layout_unittest.cc', + 'test/views_test_base.cc', 'test/views_test_base.h', 'run_all_unittests.cc', + 'test/test_views_delegate.cc', 'test/test_views_delegate.h', 'view_unittest.cc', 'widget/native_widget_test_utils.h', |