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/root_window.h" | 11 #include "ui/aura/root_window.h" |
12 #include "ui/aura/test/test_stacking_client.h" | |
13 | 12 |
14 namespace aura { | 13 namespace aura { |
15 namespace test { | 14 namespace test { |
16 | 15 |
17 AuraTestBase::AuraTestBase() | 16 AuraTestBase::AuraTestBase() |
18 : setup_called_(false), | 17 : setup_called_(false), |
19 teardown_called_(false) { | 18 teardown_called_(false) { |
20 #if defined(OS_WIN) | 19 #if defined(OS_WIN) |
21 OleInitialize(NULL); | 20 OleInitialize(NULL); |
22 #endif | 21 #endif |
23 | 22 |
24 // TestStackingClient is owned by the root window. | |
25 new TestStackingClient(); | |
26 RootWindow::GetInstance()->Show(); | 23 RootWindow::GetInstance()->Show(); |
27 RootWindow::GetInstance()->SetHostSize(gfx::Size(600, 600)); | 24 RootWindow::GetInstance()->SetHostSize(gfx::Size(600, 600)); |
28 } | 25 } |
29 | 26 |
30 AuraTestBase::~AuraTestBase() { | 27 AuraTestBase::~AuraTestBase() { |
31 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
32 OleUninitialize(); | 29 OleUninitialize(); |
33 #endif | 30 #endif |
34 CHECK(setup_called_) | 31 CHECK(setup_called_) |
35 << "You have overridden SetUp but never called super class's SetUp"; | 32 << "You have overridden SetUp but never called super class's SetUp"; |
36 CHECK(teardown_called_) | 33 CHECK(teardown_called_) |
37 << "You have overridden TearDown but never called super class's TearDown"; | 34 << "You have overridden TearDown but never called super class's TearDown"; |
38 | 35 |
39 // Flush the message loop because we have pending release tasks | 36 // Flush the message loop because we have pending release tasks |
40 // and these tasks if un-executed would upset Valgrind. | 37 // and these tasks if un-executed would upset Valgrind. |
41 RunAllPendingInMessageLoop(); | 38 RunAllPendingInMessageLoop(); |
42 | 39 |
43 // Ensure that we don't use the previously-allocated static RootWindow object | 40 // Ensure that we don't use the previously-allocated static RootWindow object |
44 // later -- on Linux, it holds a reference to our message loop's X connection. | 41 // later -- on Linux, it holds a reference to our message loop's X connection. |
45 aura::RootWindow::DeleteInstance(); | 42 aura::RootWindow::DeleteInstance(); |
46 } | 43 } |
47 | 44 |
48 TestStackingClient* AuraTestBase::GetTestStackingClient() { | |
49 return static_cast<TestStackingClient*>( | |
50 aura::RootWindow::GetInstance()->stacking_client()); | |
51 } | |
52 | |
53 void AuraTestBase::SetUp() { | 45 void AuraTestBase::SetUp() { |
54 testing::Test::SetUp(); | 46 testing::Test::SetUp(); |
55 setup_called_ = true; | 47 setup_called_ = true; |
56 } | 48 } |
57 | 49 |
58 void AuraTestBase::TearDown() { | 50 void AuraTestBase::TearDown() { |
59 teardown_called_ = true; | 51 teardown_called_ = true; |
60 testing::Test::TearDown(); | 52 testing::Test::TearDown(); |
61 } | 53 } |
62 | 54 |
63 void AuraTestBase::RunAllPendingInMessageLoop() { | 55 void AuraTestBase::RunAllPendingInMessageLoop() { |
64 message_loop_.RunAllPendingWithDispatcher( | 56 message_loop_.RunAllPendingWithDispatcher( |
65 RootWindow::GetInstance()->GetDispatcher()); | 57 RootWindow::GetInstance()->GetDispatcher()); |
66 } | 58 } |
67 | 59 |
68 } // namespace test | 60 } // namespace test |
69 } // namespace aura | 61 } // namespace aura |
OLD | NEW |