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()); | |
17 } | 16 } |
18 | 17 |
19 AshTestBase::~AshTestBase() { | 18 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(); | |
23 } | 19 } |
24 | 20 |
25 void AshTestBase::SetUp() { | 21 void AshTestBase::SetUp() { |
26 helper_.SetUp(); | |
27 | |
28 // Creates Shell and hook with Desktop. | 22 // Creates Shell and hook with Desktop. |
29 TestShellDelegate* delegate = new TestShellDelegate; | 23 TestShellDelegate* delegate = new TestShellDelegate; |
30 Shell::WindowMode window_mode = Shell::MODE_OVERLAPPING; | 24 Shell::WindowMode window_mode = Shell::MODE_OVERLAPPING; |
31 if (GetOverrideWindowMode(&window_mode)) | 25 if (GetOverrideWindowMode(&window_mode)) |
32 delegate->SetOverrideWindowMode(window_mode); | 26 delegate->SetOverrideWindowMode(window_mode); |
33 ash::Shell::CreateInstance(delegate); | 27 ash::Shell::CreateInstance(delegate); |
34 | 28 |
| 29 helper_.SetUp(); |
| 30 helper_.InitRootWindow(Shell::GetRootWindow()); |
| 31 |
35 // Disable animations during tests. | 32 // Disable animations during tests. |
36 ui::LayerAnimator::set_disable_animations_for_test(true); | 33 ui::LayerAnimator::set_disable_animations_for_test(true); |
37 } | 34 } |
38 | 35 |
39 void AshTestBase::TearDown() { | 36 void AshTestBase::TearDown() { |
40 // Flush the message loop to finish pending release tasks. | 37 // Flush the message loop to finish pending release tasks. |
41 RunAllPendingInMessageLoop(); | 38 RunAllPendingInMessageLoop(); |
42 | 39 |
| 40 helper_.TearDown(); |
| 41 |
43 // Tear down the shell. | 42 // Tear down the shell. |
44 Shell::DeleteInstance(); | 43 Shell::DeleteInstance(); |
45 | |
46 helper_.TearDown(); | |
47 } | 44 } |
48 | 45 |
49 bool AshTestBase::GetOverrideWindowMode(Shell::WindowMode* window_mode) { | 46 bool AshTestBase::GetOverrideWindowMode(Shell::WindowMode* window_mode) { |
50 return false; | 47 return false; |
51 } | 48 } |
52 | 49 |
53 void AshTestBase::RunAllPendingInMessageLoop() { | 50 void AshTestBase::RunAllPendingInMessageLoop() { |
54 helper_.RunAllPendingInMessageLoop(Shell::GetRootWindow()); | 51 helper_.RunAllPendingInMessageLoop(Shell::GetRootWindow()); |
55 } | 52 } |
56 | 53 |
57 } // namespace test | 54 } // namespace test |
58 } // namespace ash | 55 } // namespace ash |
OLD | NEW |