From 99c49f669269d90bdfe4610fa7179d140edd55d9 Mon Sep 17 00:00:00 2001 From: "erg@google.com" Date: Thu, 10 Mar 2011 01:50:41 +0000 Subject: Fix final nits on linux_views BUG=carnitas TEST=compiles Review URL: http://codereview.chromium.org/6612047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77584 0039d316-1c4b-4281-b951-d872f2087c98 --- views/test/test_views_delegate.cc | 29 +++++++++++++++++++++++++++++ views/test/test_views_delegate.h | 26 ++++++++++---------------- views/test/views_test_base.cc | 31 +++++++++++++++++++++++++++++++ views/test/views_test_base.h | 24 ++++-------------------- 4 files changed, 74 insertions(+), 36 deletions(-) create mode 100644 views/test/test_views_delegate.cc create mode 100644 views/test/views_test_base.cc (limited to 'views/test') 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 +#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 -#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(); -- cgit v1.1