OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "ui/aura/root_window.h" | 7 #include "ui/aura/root_window.h" |
8 #include "ui/aura/test/test_stacking_client.h" | 8 #include "ui/aura/test/test_stacking_client.h" |
9 | 9 |
10 namespace aura { | 10 namespace aura { |
11 namespace test { | 11 namespace test { |
12 | 12 |
13 AuraTestBase::AuraTestBase() { | 13 AuraTestBase::AuraTestBase() : root_window_(RootWindow::GetInstance()) { |
| 14 helper_.InitRootWindow(root_window_); |
14 } | 15 } |
15 | 16 |
16 AuraTestBase::~AuraTestBase() { | 17 AuraTestBase::~AuraTestBase() { |
| 18 // Flush the message loop because we have pending release tasks |
| 19 // and these tasks if un-executed would upset Valgrind. |
| 20 helper_.RunAllPendingInMessageLoop(root_window_); |
| 21 |
| 22 // Ensure that we don't use the previously-allocated static RootWindow object |
| 23 // later -- on Linux, it holds a reference to our message loop's X connection. |
| 24 RootWindow::DeleteInstance(); |
17 } | 25 } |
18 | 26 |
19 void AuraTestBase::SetUp() { | 27 void AuraTestBase::SetUp() { |
20 testing::Test::SetUp(); | 28 testing::Test::SetUp(); |
21 root_window_.reset(new aura::RootWindow); | |
22 helper_.InitRootWindow(root_window()); | |
23 helper_.SetUp(); | 29 helper_.SetUp(); |
24 stacking_client_.reset(new TestStackingClient(root_window())); | 30 stacking_client_.reset(new TestStackingClient(root_window())); |
25 } | 31 } |
26 | 32 |
27 void AuraTestBase::TearDown() { | 33 void AuraTestBase::TearDown() { |
28 // Flush the message loop because we have pending release tasks | |
29 // and these tasks if un-executed would upset Valgrind. | |
30 RunAllPendingInMessageLoop(); | |
31 | |
32 stacking_client_.reset(); | 34 stacking_client_.reset(); |
33 helper_.TearDown(); | 35 helper_.TearDown(); |
34 root_window_.reset(); | |
35 testing::Test::TearDown(); | 36 testing::Test::TearDown(); |
36 } | 37 } |
37 | 38 |
38 void AuraTestBase::RunAllPendingInMessageLoop() { | 39 void AuraTestBase::RunAllPendingInMessageLoop() { |
39 helper_.RunAllPendingInMessageLoop(root_window()); | 40 helper_.RunAllPendingInMessageLoop(root_window_); |
40 } | 41 } |
41 | 42 |
42 } // namespace test | 43 } // namespace test |
43 } // namespace aura | 44 } // namespace aura |
OLD | NEW |