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