summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-07 21:23:56 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-07 21:23:56 +0000
commit9187d22dee40a8ed4f98ae6fae510e18ebe1c4d8 (patch)
tree07f57f95e3f0fe102ea030d724ad13a4289c93dc /ui
parentaf11c4aa1717b2b7cc23cad104ef18429c7bf496 (diff)
downloadchromium_src-9187d22dee40a8ed4f98ae6fae510e18ebe1c4d8.zip
chromium_src-9187d22dee40a8ed4f98ae6fae510e18ebe1c4d8.tar.gz
chromium_src-9187d22dee40a8ed4f98ae6fae510e18ebe1c4d8.tar.bz2
Fixes aura build on windows. Makes all tests use the test compositor
as the bots don't have the right libraries yet. BUG=none TEST=none R=ben@chromium.org Review URL: http://codereview.chromium.org/8202014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104566 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura/aura.gyp8
-rw-r--r--ui/aura/aura_test_base.cc58
-rw-r--r--ui/aura/aura_test_base.h40
-rw-r--r--ui/aura/window_unittest.cc27
-rw-r--r--ui/gfx/compositor/layer_unittest.cc14
5 files changed, 120 insertions, 27 deletions
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp
index 683fe6b..2be11e8 100644
--- a/ui/aura/aura.gyp
+++ b/ui/aura/aura.gyp
@@ -91,12 +91,18 @@
'..',
],
'sources': [
- 'window_unittest.cc',
+ 'aura_test_base.cc',
+ 'aura_test_base.h',
'run_all_unittests.cc',
'test_desktop_delegate.cc',
'test_desktop_delegate.h',
'test_suite.cc',
'test_suite.h',
+ 'window_unittest.cc',
+ '../gfx/compositor/test_compositor.cc',
+ '../gfx/compositor/test_compositor.h',
+ '../gfx/compositor/test_texture.cc',
+ '../gfx/compositor/test_texture.h',
'<(SHARED_INTERMEDIATE_DIR)/ui/gfx/gfx_resources.rc',
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources/ui_resources.rc',
],
diff --git a/ui/aura/aura_test_base.cc b/ui/aura/aura_test_base.cc
new file mode 100644
index 0000000..aefeea1
--- /dev/null
+++ b/ui/aura/aura_test_base.cc
@@ -0,0 +1,58 @@
+// 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 "ui/aura/aura_test_base.h"
+
+#if defined(OS_WIN)
+#include <ole2.h>
+#endif
+
+#include "ui/aura/desktop.h"
+#include "ui/aura/test_desktop_delegate.h"
+#include "ui/gfx/compositor/test_compositor.h"
+
+namespace aura {
+
+static ui::Compositor* TestCreateCompositor() {
+ return new ui::TestCompositor();
+}
+
+AuraTestBase::AuraTestBase()
+ : setup_called_(false),
+ teardown_called_(false) {
+#if defined(OS_WIN)
+ OleInitialize(NULL);
+#endif
+}
+
+AuraTestBase::~AuraTestBase() {
+#if defined(OS_WIN)
+ OleUninitialize();
+#endif
+ CHECK(setup_called_)
+ << "You have overridden SetUp but never called super class's SetUp";
+ CHECK(teardown_called_)
+ << "You have overrideen TearDown but never called super class's TearDown";
+}
+
+void AuraTestBase::SetUp() {
+ testing::Test::SetUp();
+ setup_called_ = true;
+ aura::Desktop::set_compositor_factory_for_testing(&TestCreateCompositor);
+ // TestDesktopDelegate is owned by the desktop.
+ new TestDesktopDelegate();
+ Desktop::GetInstance()->Show();
+ Desktop::GetInstance()->SetSize(gfx::Size(500, 500));
+}
+
+void AuraTestBase::TearDown() {
+ // Flush the message loop because we have pending release tasks
+ // and these tasks if un-executed would upset Valgrind.
+ RunPendingMessages();
+ teardown_called_ = true;
+ testing::Test::TearDown();
+ aura::Desktop::set_compositor_factory_for_testing(NULL);
+}
+
+} // namespace aura
diff --git a/ui/aura/aura_test_base.h b/ui/aura/aura_test_base.h
new file mode 100644
index 0000000..f6ad225
--- /dev/null
+++ b/ui/aura/aura_test_base.h
@@ -0,0 +1,40 @@
+// 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 UI_AURA_TEST_BASE_H_
+#define UI_AURA_TEST_BASE_H_
+#pragma once
+
+#include "base/compiler_specific.h"
+#include "base/basictypes.h"
+#include "base/message_loop.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace aura {
+
+// A base class for aura unit tests.
+class AuraTestBase : public testing::Test {
+ public:
+ AuraTestBase();
+ virtual ~AuraTestBase();
+
+ void RunPendingMessages() {
+ message_loop_.RunAllPending();
+ }
+
+ // testing::Test:
+ virtual void SetUp() OVERRIDE;
+ virtual void TearDown() OVERRIDE;
+
+ private:
+ MessageLoopForUI message_loop_;
+ bool setup_called_;
+ bool teardown_called_;
+
+ DISALLOW_COPY_AND_ASSIGN(AuraTestBase);
+};
+
+} // namespace aura
+
+#endif // UI_AURA_TEST_BASE_H_
diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc
index ebb2cdf..fbb83c4 100644
--- a/ui/aura/window_unittest.cc
+++ b/ui/aura/window_unittest.cc
@@ -4,8 +4,8 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
-#include "base/message_loop.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/aura/aura_test_base.h"
#include "ui/aura/desktop.h"
#include "ui/aura/event.h"
#include "ui/aura/focus_manager.h"
@@ -173,23 +173,11 @@ class TestWindowDelegate : public WindowDelegateImpl {
DISALLOW_COPY_AND_ASSIGN(TestWindowDelegate);
};
-class WindowTest : public testing::Test {
+class WindowTest : public AuraTestBase {
public:
- WindowTest()
- : main_message_loop(MessageLoop::TYPE_UI),
- desktop_delegate_(new TestDesktopDelegate) {
- Desktop::GetInstance()->Show();
- Desktop::GetInstance()->SetSize(gfx::Size(500, 500));
- }
+ WindowTest() {}
virtual ~WindowTest() {}
- // Overridden from testing::Test:
- virtual void SetUp() OVERRIDE {
- }
-
- virtual void TearDown() OVERRIDE {
- }
-
Window* CreateTestWindowWithId(int id, Window* parent) {
return CreateTestWindowWithDelegate(NULL, id, gfx::Rect(), parent);
}
@@ -215,15 +203,7 @@ class WindowTest : public testing::Test {
return window;
}
- protected:
- Window* toplevel_container() {
- return desktop_delegate_->default_container();
- }
-
private:
- MessageLoop main_message_loop;
- TestDesktopDelegate* desktop_delegate_;
-
DISALLOW_COPY_AND_ASSIGN(WindowTest);
};
@@ -273,7 +253,6 @@ TEST_F(WindowTest, GetEventHandlerForPoint) {
CreateTestWindow(SK_ColorGRAY, 13, gfx::Rect(5, 470, 50, 50), w1.get()));
Window* desktop = Desktop::GetInstance()->window();
- toplevel_container()->SetBounds(gfx::Rect(500, 500));
EXPECT_EQ(NULL, desktop->GetEventHandlerForPoint(gfx::Point(5, 5)));
EXPECT_EQ(w1.get(), desktop->GetEventHandlerForPoint(gfx::Point(11, 11)));
EXPECT_EQ(w11.get(), desktop->GetEventHandlerForPoint(gfx::Point(16, 16)));
diff --git a/ui/gfx/compositor/layer_unittest.cc b/ui/gfx/compositor/layer_unittest.cc
index 953eaba..5521cf2 100644
--- a/ui/gfx/compositor/layer_unittest.cc
+++ b/ui/gfx/compositor/layer_unittest.cc
@@ -167,7 +167,17 @@ class NullLayerDelegate : public LayerDelegate {
}
-TEST_F(LayerWithRealCompositorTest, Draw) {
+#if defined(OS_WIN)
+// These are disabled on windows as they don't run correctly on the buildbot.
+// Reenable once we move to the real compositor.
+#define MAYBE_Draw DISABLED_Draw
+#define MAYBE_Hierarchy DISABLED_Hierarchy
+#else
+#define MAYBE_Draw Draw
+#define MAYBE_Hierarchy Hierarchy
+#endif
+
+TEST_F(LayerWithRealCompositorTest, MAYBE_Draw) {
scoped_ptr<Layer> layer(CreateColorLayer(SK_ColorRED,
gfx::Rect(20, 20, 50, 50)));
DrawTree(layer.get());
@@ -179,7 +189,7 @@ TEST_F(LayerWithRealCompositorTest, Draw) {
// | +-- L3 - yellow
// +-- L4 - magenta
//
-TEST_F(LayerWithRealCompositorTest, Hierarchy) {
+TEST_F(LayerWithRealCompositorTest, MAYBE_Hierarchy) {
scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED,
gfx::Rect(20, 20, 400, 400)));
scoped_ptr<Layer> l2(CreateColorLayer(SK_ColorBLUE,