| 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_helper.h" | 5 #include "ui/aura/test/aura_test_helper.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
| 10 #include "ui/aura/client/default_capture_client.h" |
| 10 #include "ui/aura/env.h" | 11 #include "ui/aura/env.h" |
| 11 #include "ui/aura/focus_manager.h" | 12 #include "ui/aura/focus_manager.h" |
| 12 #include "ui/aura/display_manager.h" | 13 #include "ui/aura/display_manager.h" |
| 13 #include "ui/aura/root_window.h" | 14 #include "ui/aura/root_window.h" |
| 14 #include "ui/aura/shared/root_window_capture_client.h" | |
| 15 #include "ui/aura/single_display_manager.h" | 15 #include "ui/aura/single_display_manager.h" |
| 16 #include "ui/aura/test/test_activation_client.h" | 16 #include "ui/aura/test/test_activation_client.h" |
| 17 #include "ui/aura/test/test_screen.h" | 17 #include "ui/aura/test/test_screen.h" |
| 18 #include "ui/aura/test/test_stacking_client.h" | 18 #include "ui/aura/test/test_stacking_client.h" |
| 19 #include "ui/aura/ui_controls_aura.h" | 19 #include "ui/aura/ui_controls_aura.h" |
| 20 #include "ui/base/test/dummy_input_method.h" | 20 #include "ui/base/test/dummy_input_method.h" |
| 21 #include "ui/compositor/layer_animator.h" | 21 #include "ui/compositor/layer_animator.h" |
| 22 #include "ui/gfx/screen.h" | 22 #include "ui/gfx/screen.h" |
| 23 #include "ui/ui_controls/ui_controls.h" | 23 #include "ui/ui_controls/ui_controls.h" |
| 24 | 24 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 48 root_window_.reset(aura::DisplayManager::CreateRootWindowForPrimaryDisplay()); | 48 root_window_.reset(aura::DisplayManager::CreateRootWindowForPrimaryDisplay()); |
| 49 test_screen_.reset(new aura::TestScreen(root_window_.get())); | 49 test_screen_.reset(new aura::TestScreen(root_window_.get())); |
| 50 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); | 50 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); |
| 51 ui_controls::InstallUIControlsAura(CreateUIControlsAura(root_window_.get())); | 51 ui_controls::InstallUIControlsAura(CreateUIControlsAura(root_window_.get())); |
| 52 | 52 |
| 53 focus_manager_.reset(new FocusManager); | 53 focus_manager_.reset(new FocusManager); |
| 54 root_window_->set_focus_manager(focus_manager_.get()); | 54 root_window_->set_focus_manager(focus_manager_.get()); |
| 55 stacking_client_.reset(new TestStackingClient(root_window_.get())); | 55 stacking_client_.reset(new TestStackingClient(root_window_.get())); |
| 56 test_activation_client_.reset( | 56 test_activation_client_.reset( |
| 57 new test::TestActivationClient(root_window_.get())); | 57 new test::TestActivationClient(root_window_.get())); |
| 58 root_window_capture_client_.reset( | 58 capture_client_.reset(new client::DefaultCaptureClient(root_window_.get())); |
| 59 new shared::RootWindowCaptureClient(root_window_.get())); | |
| 60 test_input_method_.reset(new ui::test::DummyInputMethod); | 59 test_input_method_.reset(new ui::test::DummyInputMethod); |
| 61 root_window_->SetProperty( | 60 root_window_->SetProperty( |
| 62 aura::client::kRootWindowInputMethodKey, | 61 aura::client::kRootWindowInputMethodKey, |
| 63 test_input_method_.get()); | 62 test_input_method_.get()); |
| 64 | 63 |
| 65 root_window_->Show(); | 64 root_window_->Show(); |
| 66 // Ensure width != height so tests won't confuse them. | 65 // Ensure width != height so tests won't confuse them. |
| 67 root_window_->SetHostSize(gfx::Size(800, 600)); | 66 root_window_->SetHostSize(gfx::Size(800, 600)); |
| 68 } | 67 } |
| 69 | 68 |
| 70 void AuraTestHelper::TearDown() { | 69 void AuraTestHelper::TearDown() { |
| 71 teardown_called_ = true; | 70 teardown_called_ = true; |
| 72 test_input_method_.reset(); | 71 test_input_method_.reset(); |
| 73 stacking_client_.reset(); | 72 stacking_client_.reset(); |
| 74 test_activation_client_.reset(); | 73 test_activation_client_.reset(); |
| 75 root_window_capture_client_.reset(); | 74 capture_client_.reset(); |
| 76 focus_manager_.reset(); | 75 focus_manager_.reset(); |
| 77 root_window_.reset(); | 76 root_window_.reset(); |
| 78 test_screen_.reset(); | 77 test_screen_.reset(); |
| 79 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL); | 78 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL); |
| 80 aura::Env::DeleteInstance(); | 79 aura::Env::DeleteInstance(); |
| 81 } | 80 } |
| 82 | 81 |
| 83 void AuraTestHelper::RunAllPendingInMessageLoop() { | 82 void AuraTestHelper::RunAllPendingInMessageLoop() { |
| 84 #if !defined(OS_MACOSX) | 83 #if !defined(OS_MACOSX) |
| 85 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them | 84 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them |
| 86 // use run_loop.QuitClosure(). | 85 // use run_loop.QuitClosure(). |
| 87 base::RunLoop run_loop(Env::GetInstance()->GetDispatcher()); | 86 base::RunLoop run_loop(Env::GetInstance()->GetDispatcher()); |
| 88 run_loop.RunUntilIdle(); | 87 run_loop.RunUntilIdle(); |
| 89 #endif | 88 #endif |
| 90 } | 89 } |
| 91 | 90 |
| 92 } // namespace test | 91 } // namespace test |
| 93 } // namespace aura | 92 } // namespace aura |
| OLD | NEW |