| 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/client/default_capture_client.h" |
| 11 #include "ui/aura/client/focus_client.h" | 11 #include "ui/aura/client/focus_client.h" |
| 12 #include "ui/aura/env.h" | 12 #include "ui/aura/env.h" |
| 13 #include "ui/aura/focus_manager.h" | 13 #include "ui/aura/focus_manager.h" |
| 14 #include "ui/aura/root_window.h" | 14 #include "ui/aura/root_window.h" |
| 15 #include "ui/aura/test/test_activation_client.h" | 15 #include "ui/aura/test/test_activation_client.h" |
| 16 #include "ui/aura/test/test_screen.h" | 16 #include "ui/aura/test/test_screen.h" |
| 17 #include "ui/aura/test/test_stacking_client.h" | 17 #include "ui/aura/test/test_stacking_client.h" |
| 18 #include "ui/aura/ui_controls_aura.h" | |
| 19 #include "ui/base/test/dummy_input_method.h" | 18 #include "ui/base/test/dummy_input_method.h" |
| 20 #include "ui/compositor/layer_animator.h" | 19 #include "ui/compositor/layer_animator.h" |
| 21 #include "ui/gfx/screen.h" | 20 #include "ui/gfx/screen.h" |
| 22 #include "ui/ui_controls/ui_controls.h" | |
| 23 | 21 |
| 24 namespace aura { | 22 namespace aura { |
| 25 namespace test { | 23 namespace test { |
| 26 | 24 |
| 27 AuraTestHelper::AuraTestHelper(MessageLoopForUI* message_loop) | 25 AuraTestHelper::AuraTestHelper(MessageLoopForUI* message_loop) |
| 28 : setup_called_(false), | 26 : setup_called_(false), |
| 29 teardown_called_(false), | 27 teardown_called_(false), |
| 30 owns_root_window_(false) { | 28 owns_root_window_(false) { |
| 31 DCHECK(message_loop); | 29 DCHECK(message_loop); |
| 32 message_loop_ = message_loop; | 30 message_loop_ = message_loop; |
| 33 // Disable animations during tests. | 31 // Disable animations during tests. |
| 34 ui::LayerAnimator::set_disable_animations_for_test(true); | 32 ui::LayerAnimator::set_disable_animations_for_test(true); |
| 35 } | 33 } |
| 36 | 34 |
| 37 AuraTestHelper::~AuraTestHelper() { | 35 AuraTestHelper::~AuraTestHelper() { |
| 38 CHECK(setup_called_) | 36 CHECK(setup_called_) |
| 39 << "You have overridden SetUp but never called super class's SetUp"; | 37 << "You have overridden SetUp but never called super class's SetUp"; |
| 40 CHECK(teardown_called_) | 38 CHECK(teardown_called_) |
| 41 << "You have overridden TearDown but never called super class's TearDown"; | 39 << "You have overridden TearDown but never called super class's TearDown"; |
| 42 } | 40 } |
| 43 | 41 |
| 44 void AuraTestHelper::SetUp() { | 42 void AuraTestHelper::SetUp() { |
| 45 setup_called_ = true; | 43 setup_called_ = true; |
| 46 Env::GetInstance(); | 44 Env::GetInstance(); |
| 47 test_screen_.reset(new TestScreen()); | 45 test_screen_.reset(new TestScreen()); |
| 48 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); | 46 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); |
| 49 root_window_.reset(test_screen_->CreateRootWindowForPrimaryDisplay()); | 47 root_window_.reset(test_screen_->CreateRootWindowForPrimaryDisplay()); |
| 50 ui_controls::InstallUIControlsAura(CreateUIControlsAura(root_window_.get())); | |
| 51 | 48 |
| 52 focus_client_.reset(new FocusManager); | 49 focus_client_.reset(new FocusManager); |
| 53 client::SetFocusClient(root_window_.get(), focus_client_.get()); | 50 client::SetFocusClient(root_window_.get(), focus_client_.get()); |
| 54 stacking_client_.reset(new TestStackingClient(root_window_.get())); | 51 stacking_client_.reset(new TestStackingClient(root_window_.get())); |
| 55 test_activation_client_.reset( | 52 test_activation_client_.reset( |
| 56 new test::TestActivationClient(root_window_.get())); | 53 new test::TestActivationClient(root_window_.get())); |
| 57 capture_client_.reset(new client::DefaultCaptureClient(root_window_.get())); | 54 capture_client_.reset(new client::DefaultCaptureClient(root_window_.get())); |
| 58 test_input_method_.reset(new ui::test::DummyInputMethod); | 55 test_input_method_.reset(new ui::test::DummyInputMethod); |
| 59 root_window_->SetProperty( | 56 root_window_->SetProperty( |
| 60 client::kRootWindowInputMethodKey, | 57 client::kRootWindowInputMethodKey, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 82 #if !defined(OS_MACOSX) | 79 #if !defined(OS_MACOSX) |
| 83 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them | 80 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them |
| 84 // use run_loop.QuitClosure(). | 81 // use run_loop.QuitClosure(). |
| 85 base::RunLoop run_loop(Env::GetInstance()->GetDispatcher()); | 82 base::RunLoop run_loop(Env::GetInstance()->GetDispatcher()); |
| 86 run_loop.RunUntilIdle(); | 83 run_loop.RunUntilIdle(); |
| 87 #endif | 84 #endif |
| 88 } | 85 } |
| 89 | 86 |
| 90 } // namespace test | 87 } // namespace test |
| 91 } // namespace aura | 88 } // namespace aura |
| OLD | NEW |