Chromium Code Reviews| 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/env.h" | 11 #include "ui/aura/env.h" |
| 12 #include "ui/aura/focus_manager.h" | 12 #include "ui/aura/focus_manager.h" |
| 13 #include "ui/aura/display_manager.h" | |
| 14 #include "ui/aura/root_window.h" | 13 #include "ui/aura/root_window.h" |
| 15 #include "ui/aura/single_display_manager.h" | |
| 16 #include "ui/aura/test/test_activation_client.h" | 14 #include "ui/aura/test/test_activation_client.h" |
| 17 #include "ui/aura/test/test_screen.h" | 15 #include "ui/aura/test/test_screen.h" |
| 18 #include "ui/aura/test/test_stacking_client.h" | 16 #include "ui/aura/test/test_stacking_client.h" |
| 19 #include "ui/aura/ui_controls_aura.h" | 17 #include "ui/aura/ui_controls_aura.h" |
| 20 #include "ui/base/test/dummy_input_method.h" | 18 #include "ui/base/test/dummy_input_method.h" |
| 21 #include "ui/compositor/layer_animator.h" | 19 #include "ui/compositor/layer_animator.h" |
| 22 #include "ui/gfx/screen.h" | 20 #include "ui/gfx/screen.h" |
| 23 #include "ui/ui_controls/ui_controls.h" | 21 #include "ui/ui_controls/ui_controls.h" |
| 24 | 22 |
| 25 namespace aura { | 23 namespace aura { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 37 | 35 |
| 38 AuraTestHelper::~AuraTestHelper() { | 36 AuraTestHelper::~AuraTestHelper() { |
| 39 CHECK(setup_called_) | 37 CHECK(setup_called_) |
| 40 << "You have overridden SetUp but never called super class's SetUp"; | 38 << "You have overridden SetUp but never called super class's SetUp"; |
| 41 CHECK(teardown_called_) | 39 CHECK(teardown_called_) |
| 42 << "You have overridden TearDown but never called super class's TearDown"; | 40 << "You have overridden TearDown but never called super class's TearDown"; |
| 43 } | 41 } |
| 44 | 42 |
| 45 void AuraTestHelper::SetUp() { | 43 void AuraTestHelper::SetUp() { |
| 46 setup_called_ = true; | 44 setup_called_ = true; |
| 47 Env::GetInstance()->SetDisplayManager(new SingleDisplayManager); | 45 aura::Env::GetInstance(); |
| 48 root_window_.reset(aura::DisplayManager::CreateRootWindowForPrimaryDisplay()); | 46 test_screen_.reset(new TestScreen()); |
| 49 test_screen_.reset(new aura::TestScreen(root_window_.get())); | |
| 50 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); | 47 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); |
|
ananta
2012/11/09 18:39:51
This four line pattern has been repeated multiple
oshima
2012/11/09 18:53:49
I'd rather change other files to use AuraTestHelpe
| |
| 48 root_window_.reset(test_screen_->CreateRootWindowForPrimaryDisplay()); | |
| 51 ui_controls::InstallUIControlsAura(CreateUIControlsAura(root_window_.get())); | 49 ui_controls::InstallUIControlsAura(CreateUIControlsAura(root_window_.get())); |
| 52 | 50 |
| 53 focus_manager_.reset(new FocusManager); | 51 focus_manager_.reset(new FocusManager); |
| 54 root_window_->set_focus_manager(focus_manager_.get()); | 52 root_window_->set_focus_manager(focus_manager_.get()); |
| 55 stacking_client_.reset(new TestStackingClient(root_window_.get())); | 53 stacking_client_.reset(new TestStackingClient(root_window_.get())); |
| 56 test_activation_client_.reset( | 54 test_activation_client_.reset( |
| 57 new test::TestActivationClient(root_window_.get())); | 55 new test::TestActivationClient(root_window_.get())); |
| 58 capture_client_.reset(new client::DefaultCaptureClient(root_window_.get())); | 56 capture_client_.reset(new client::DefaultCaptureClient(root_window_.get())); |
| 59 test_input_method_.reset(new ui::test::DummyInputMethod); | 57 test_input_method_.reset(new ui::test::DummyInputMethod); |
| 60 root_window_->SetProperty( | 58 root_window_->SetProperty( |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 83 #if !defined(OS_MACOSX) | 81 #if !defined(OS_MACOSX) |
| 84 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them | 82 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them |
| 85 // use run_loop.QuitClosure(). | 83 // use run_loop.QuitClosure(). |
| 86 base::RunLoop run_loop(Env::GetInstance()->GetDispatcher()); | 84 base::RunLoop run_loop(Env::GetInstance()->GetDispatcher()); |
| 87 run_loop.RunUntilIdle(); | 85 run_loop.RunUntilIdle(); |
| 88 #endif | 86 #endif |
| 89 } | 87 } |
| 90 | 88 |
| 91 } // namespace test | 89 } // namespace test |
| 92 } // namespace aura | 90 } // namespace aura |
| OLD | NEW |