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 "ash/test/ash_test_base.h" | 5 #include "ash/test/ash_test_base.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/test/test_shell_delegate.h" | 8 #include "ash/test/test_shell_delegate.h" |
9 #include "ui/aura/root_window.h" | 9 #include "ui/aura/root_window.h" |
10 #include "ui/gfx/compositor/layer_animator.h" | 10 #include "ui/gfx/compositor/layer_animator.h" |
11 | 11 |
12 namespace ash { | 12 namespace ash { |
13 namespace test { | 13 namespace test { |
14 | 14 |
15 AshTestBase::AshTestBase() { | 15 AshTestBase::AshTestBase() { |
| 16 helper_.InitRootWindow(Shell::GetRootWindow()); |
16 } | 17 } |
17 | 18 |
18 AshTestBase::~AshTestBase() { | 19 AshTestBase::~AshTestBase() { |
| 20 // Ensure that we don't use the previously-allocated static RootWindow object |
| 21 // later -- on Linux, it holds a reference to our message loop's X connection. |
| 22 aura::RootWindow::DeleteInstance(); |
19 } | 23 } |
20 | 24 |
21 void AshTestBase::SetUp() { | 25 void AshTestBase::SetUp() { |
| 26 helper_.SetUp(); |
| 27 |
22 // Creates Shell and hook with Desktop. | 28 // Creates Shell and hook with Desktop. |
23 TestShellDelegate* delegate = new TestShellDelegate; | 29 TestShellDelegate* delegate = new TestShellDelegate; |
24 Shell::WindowMode window_mode = Shell::MODE_OVERLAPPING; | 30 Shell::WindowMode window_mode = Shell::MODE_OVERLAPPING; |
25 if (GetOverrideWindowMode(&window_mode)) | 31 if (GetOverrideWindowMode(&window_mode)) |
26 delegate->SetOverrideWindowMode(window_mode); | 32 delegate->SetOverrideWindowMode(window_mode); |
27 ash::Shell::CreateInstance(delegate); | 33 ash::Shell::CreateInstance(delegate); |
28 | 34 |
29 helper_.SetUp(); | |
30 helper_.InitRootWindow(Shell::GetRootWindow()); | |
31 | |
32 // Disable animations during tests. | 35 // Disable animations during tests. |
33 ui::LayerAnimator::set_disable_animations_for_test(true); | 36 ui::LayerAnimator::set_disable_animations_for_test(true); |
34 } | 37 } |
35 | 38 |
36 void AshTestBase::TearDown() { | 39 void AshTestBase::TearDown() { |
37 // Flush the message loop to finish pending release tasks. | 40 // Flush the message loop to finish pending release tasks. |
38 RunAllPendingInMessageLoop(); | 41 RunAllPendingInMessageLoop(); |
39 | 42 |
40 helper_.TearDown(); | |
41 | |
42 // Tear down the shell. | 43 // Tear down the shell. |
43 Shell::DeleteInstance(); | 44 Shell::DeleteInstance(); |
| 45 |
| 46 helper_.TearDown(); |
44 } | 47 } |
45 | 48 |
46 bool AshTestBase::GetOverrideWindowMode(Shell::WindowMode* window_mode) { | 49 bool AshTestBase::GetOverrideWindowMode(Shell::WindowMode* window_mode) { |
47 return false; | 50 return false; |
48 } | 51 } |
49 | 52 |
50 void AshTestBase::RunAllPendingInMessageLoop() { | 53 void AshTestBase::RunAllPendingInMessageLoop() { |
51 helper_.RunAllPendingInMessageLoop(Shell::GetRootWindow()); | 54 helper_.RunAllPendingInMessageLoop(Shell::GetRootWindow()); |
52 } | 55 } |
53 | 56 |
54 } // namespace test | 57 } // namespace test |
55 } // namespace ash | 58 } // namespace ash |
OLD | NEW |