Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(551)

Unified Diff: ui/aura/aura_test_base.cc

Issue 8202014: Fixes aura build on windows. Makes all tests use the test compositor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tweaks Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura/aura_test_base.h ('k') | ui/aura/window_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/aura_test_base.cc
diff --git a/ui/aura/aura_test_base.cc b/ui/aura/aura_test_base.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bf1c8209980771fa25ef071cdad6ea477ee0a3fa
--- /dev/null
+++ b/ui/aura/aura_test_base.cc
@@ -0,0 +1,57 @@
+// 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/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);
+ if (!aura::Desktop::GetInstance()->default_parent())
+ aura::Desktop::GetInstance()->CreateDefaultParentForTesting();
+ 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
« no previous file with comments | « ui/aura/aura_test_base.h ('k') | ui/aura/window_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698