OLD | NEW |
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/test_compositor.h" | |
14 | 13 |
15 namespace aura { | 14 namespace aura { |
16 namespace test { | 15 namespace test { |
17 | 16 |
18 static ui::Compositor* TestCreateCompositor() { | |
19 return new ui::TestCompositor(); | |
20 } | |
21 | |
22 AuraTestBase::AuraTestBase() | 17 AuraTestBase::AuraTestBase() |
23 : setup_called_(false), | 18 : setup_called_(false), |
24 teardown_called_(false) { | 19 teardown_called_(false) { |
25 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
26 OleInitialize(NULL); | 21 OleInitialize(NULL); |
27 #endif | 22 #endif |
28 } | 23 } |
29 | 24 |
30 AuraTestBase::~AuraTestBase() { | 25 AuraTestBase::~AuraTestBase() { |
31 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
32 OleUninitialize(); | 27 OleUninitialize(); |
33 #endif | 28 #endif |
34 CHECK(setup_called_) | 29 CHECK(setup_called_) |
35 << "You have overridden SetUp but never called super class's SetUp"; | 30 << "You have overridden SetUp but never called super class's SetUp"; |
36 CHECK(teardown_called_) | 31 CHECK(teardown_called_) |
37 << "You have overridden TearDown but never called super class's TearDown"; | 32 << "You have overridden TearDown but never called super class's TearDown"; |
38 } | 33 } |
39 | 34 |
40 void AuraTestBase::SetUp() { | 35 void AuraTestBase::SetUp() { |
41 testing::Test::SetUp(); | 36 testing::Test::SetUp(); |
42 setup_called_ = true; | 37 setup_called_ = true; |
43 aura::Desktop::set_compositor_factory_for_testing(&TestCreateCompositor); | |
44 // TestDesktopDelegate is owned by the desktop. | 38 // TestDesktopDelegate is owned by the desktop. |
45 new TestDesktopDelegate(); | 39 new TestDesktopDelegate(); |
46 Desktop::GetInstance()->Show(); | 40 Desktop::GetInstance()->Show(); |
47 Desktop::GetInstance()->SetSize(gfx::Size(600, 600)); | 41 Desktop::GetInstance()->SetSize(gfx::Size(600, 600)); |
48 } | 42 } |
49 | 43 |
50 void AuraTestBase::TearDown() { | 44 void AuraTestBase::TearDown() { |
51 // Flush the message loop because we have pending release tasks | 45 // Flush the message loop because we have pending release tasks |
52 // and these tasks if un-executed would upset Valgrind. | 46 // and these tasks if un-executed would upset Valgrind. |
53 RunPendingMessages(); | 47 RunPendingMessages(); |
54 teardown_called_ = true; | 48 teardown_called_ = true; |
55 testing::Test::TearDown(); | 49 testing::Test::TearDown(); |
56 aura::Desktop::set_compositor_factory_for_testing(NULL); | |
57 } | 50 } |
58 | 51 |
59 } // namespace test | 52 } // namespace test |
60 } // namespace aura | 53 } // namespace aura |
OLD | NEW |