Skip to content

Commit

Permalink
Fix final nits on linux_views
Browse files Browse the repository at this point in the history
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
  • Loading branch information
erg@google.com committed Mar 10, 2011
1 parent aa35163 commit 99c49f6
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 39 deletions.
9 changes: 9 additions & 0 deletions views/examples/examples_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
}
Expand Down
6 changes: 3 additions & 3 deletions views/examples/examples_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
29 changes: 29 additions & 0 deletions views/test/test_views_delegate.cc
Original file line number Diff line number Diff line change
@@ -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;
}
26 changes: 10 additions & 16 deletions views/test/test_views_delegate.h
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -12,32 +15,22 @@ 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,
bool maximized) {
}
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(
Expand All @@ -60,3 +53,4 @@ class TestViewsDelegate : public views::ViewsDelegate {
DISALLOW_COPY_AND_ASSIGN(TestViewsDelegate);
};

#endif // VIEWS_TEST_TEST_VIEWS_DELEGATE_H_
31 changes: 31 additions & 0 deletions views/test/views_test_base.cc
Original file line number Diff line number Diff line change
@@ -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
24 changes: 4 additions & 20 deletions views/test/views_test_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions views/views.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 99c49f6

Please sign in to comment.