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

Side by Side Diff: ui/aura/test/aura_test_base.cc

Issue 8240006: Use a mocked compositor for unit tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: missed views_test_base.cc 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/aura/test/aura_test_base.h" 5 #include "ui/aura/test/aura_test_base.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <ole2.h> 8 #include <ole2.h>
9 #endif 9 #endif
10 10
11 #include "ui/aura/desktop.h" 11 #include "ui/aura/desktop.h"
12 #include "ui/aura/test/test_desktop_delegate.h" 12 #include "ui/aura/test/test_desktop_delegate.h"
13 #include "ui/gfx/compositor/compositor.h"
13 #include "ui/gfx/compositor/test_compositor.h" 14 #include "ui/gfx/compositor/test_compositor.h"
14 15
15 namespace aura { 16 namespace aura {
16 namespace test { 17 namespace test {
17 18
18 static ui::Compositor* TestCreateCompositor() { 19 static ui::Compositor* TestCreateCompositor(ui::CompositorDelegate* owner) {
19 return new ui::TestCompositor(); 20 return new ui::TestCompositor(owner);
20 } 21 }
21 22
22 AuraTestBase::AuraTestBase() 23 AuraTestBase::AuraTestBase()
23 : setup_called_(false), 24 : setup_called_(false),
24 teardown_called_(false) { 25 teardown_called_(false) {
25 #if defined(OS_WIN) 26 #if defined(OS_WIN)
26 OleInitialize(NULL); 27 OleInitialize(NULL);
27 #endif 28 #endif
28 } 29 }
29 30
30 AuraTestBase::~AuraTestBase() { 31 AuraTestBase::~AuraTestBase() {
31 #if defined(OS_WIN) 32 #if defined(OS_WIN)
32 OleUninitialize(); 33 OleUninitialize();
33 #endif 34 #endif
34 CHECK(setup_called_) 35 CHECK(setup_called_)
35 << "You have overridden SetUp but never called super class's SetUp"; 36 << "You have overridden SetUp but never called super class's SetUp";
36 CHECK(teardown_called_) 37 CHECK(teardown_called_)
37 << "You have overridden TearDown but never called super class's TearDown"; 38 << "You have overridden TearDown but never called super class's TearDown";
38 } 39 }
39 40
40 void AuraTestBase::SetUp() { 41 void AuraTestBase::SetUp() {
41 testing::Test::SetUp(); 42 testing::Test::SetUp();
42 setup_called_ = true; 43 setup_called_ = true;
43 aura::Desktop::set_compositor_factory_for_testing(&TestCreateCompositor); 44 ui::Compositor::set_compositor_factory_for_testing(&TestCreateCompositor);
44 // TestDesktopDelegate is owned by the desktop. 45 // TestDesktopDelegate is owned by the desktop.
45 new TestDesktopDelegate(); 46 new TestDesktopDelegate();
46 Desktop::GetInstance()->Show(); 47 Desktop::GetInstance()->Show();
47 Desktop::GetInstance()->SetSize(gfx::Size(600, 600)); 48 Desktop::GetInstance()->SetSize(gfx::Size(600, 600));
48 } 49 }
49 50
50 void AuraTestBase::TearDown() { 51 void AuraTestBase::TearDown() {
51 // Flush the message loop because we have pending release tasks 52 // Flush the message loop because we have pending release tasks
52 // and these tasks if un-executed would upset Valgrind. 53 // and these tasks if un-executed would upset Valgrind.
53 RunPendingMessages(); 54 RunPendingMessages();
54 teardown_called_ = true; 55 teardown_called_ = true;
55 testing::Test::TearDown(); 56 testing::Test::TearDown();
56 aura::Desktop::set_compositor_factory_for_testing(NULL); 57 ui::Compositor::set_compositor_factory_for_testing(NULL);
57 } 58 }
58 59
59 } // namespace test 60 } // namespace test
60 } // namespace aura 61 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698