| 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/desktop_ui_controls.h" | 
| 11 #include "ui/aura/env.h" | 12 #include "ui/aura/env.h" | 
| 12 #include "ui/aura/focus_manager.h" | 13 #include "ui/aura/focus_manager.h" | 
| 13 #include "ui/aura/root_window.h" | 14 #include "ui/aura/root_window.h" | 
| 14 #include "ui/aura/test/test_activation_client.h" | 15 #include "ui/aura/test/test_activation_client.h" | 
| 15 #include "ui/aura/test/test_screen.h" | 16 #include "ui/aura/test/test_screen.h" | 
| 16 #include "ui/aura/test/test_stacking_client.h" | 17 #include "ui/aura/test/test_stacking_client.h" | 
| 17 #include "ui/aura/ui_controls_aura.h" |  | 
| 18 #include "ui/base/test/dummy_input_method.h" | 18 #include "ui/base/test/dummy_input_method.h" | 
| 19 #include "ui/compositor/layer_animator.h" | 19 #include "ui/compositor/layer_animator.h" | 
| 20 #include "ui/gfx/screen.h" | 20 #include "ui/gfx/screen.h" | 
| 21 #include "ui/ui_controls/ui_controls.h" | 21 #include "ui/ui_controls/ui_controls.h" | 
| 22 | 22 | 
| 23 namespace aura { | 23 namespace aura { | 
| 24 namespace test { | 24 namespace test { | 
| 25 | 25 | 
| 26 AuraTestHelper::AuraTestHelper(MessageLoopForUI* message_loop) | 26 AuraTestHelper::AuraTestHelper(MessageLoopForUI* message_loop) | 
| 27     : setup_called_(false), | 27     : setup_called_(false), | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 39   CHECK(teardown_called_) | 39   CHECK(teardown_called_) | 
| 40       << "You have overridden TearDown but never called super class's TearDown"; | 40       << "You have overridden TearDown but never called super class's TearDown"; | 
| 41 } | 41 } | 
| 42 | 42 | 
| 43 void AuraTestHelper::SetUp() { | 43 void AuraTestHelper::SetUp() { | 
| 44   setup_called_ = true; | 44   setup_called_ = true; | 
| 45   aura::Env::GetInstance(); | 45   aura::Env::GetInstance(); | 
| 46   test_screen_.reset(new TestScreen()); | 46   test_screen_.reset(new TestScreen()); | 
| 47   gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); | 47   gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); | 
| 48   root_window_.reset(test_screen_->CreateRootWindowForPrimaryDisplay()); | 48   root_window_.reset(test_screen_->CreateRootWindowForPrimaryDisplay()); | 
| 49   ui_controls::InstallUIControlsAura(CreateUIControlsAura(root_window_.get())); | 49   ui_controls::UIControls::SetUIControlsInstance( | 
|  | 50       ui_controls::UI_CONTROLS_TYPE_NATIVE, | 
|  | 51       CreateDesktopUIControls(root_window_.get())); | 
| 50 | 52 | 
| 51   focus_manager_.reset(new FocusManager); | 53   focus_manager_.reset(new FocusManager); | 
| 52   root_window_->set_focus_manager(focus_manager_.get()); | 54   root_window_->set_focus_manager(focus_manager_.get()); | 
| 53   stacking_client_.reset(new TestStackingClient(root_window_.get())); | 55   stacking_client_.reset(new TestStackingClient(root_window_.get())); | 
| 54   test_activation_client_.reset( | 56   test_activation_client_.reset( | 
| 55       new test::TestActivationClient(root_window_.get())); | 57       new test::TestActivationClient(root_window_.get())); | 
| 56   capture_client_.reset(new client::DefaultCaptureClient(root_window_.get())); | 58   capture_client_.reset(new client::DefaultCaptureClient(root_window_.get())); | 
| 57   test_input_method_.reset(new ui::test::DummyInputMethod); | 59   test_input_method_.reset(new ui::test::DummyInputMethod); | 
| 58   root_window_->SetProperty( | 60   root_window_->SetProperty( | 
| 59       aura::client::kRootWindowInputMethodKey, | 61       aura::client::kRootWindowInputMethodKey, | 
| 60       test_input_method_.get()); | 62       test_input_method_.get()); | 
| 61 | 63 | 
| 62   root_window_->Show(); | 64   root_window_->Show(); | 
| 63   // Ensure width != height so tests won't confuse them. | 65   // Ensure width != height so tests won't confuse them. | 
| 64   root_window_->SetHostSize(gfx::Size(800, 600)); | 66   root_window_->SetHostSize(gfx::Size(800, 600)); | 
| 65 } | 67 } | 
| 66 | 68 | 
| 67 void AuraTestHelper::TearDown() { | 69 void AuraTestHelper::TearDown() { | 
| 68   teardown_called_ = true; | 70   teardown_called_ = true; | 
| 69   test_input_method_.reset(); | 71   test_input_method_.reset(); | 
| 70   stacking_client_.reset(); | 72   stacking_client_.reset(); | 
| 71   test_activation_client_.reset(); | 73   test_activation_client_.reset(); | 
| 72   capture_client_.reset(); | 74   capture_client_.reset(); | 
| 73   focus_manager_.reset(); | 75   focus_manager_.reset(); | 
| 74   root_window_.reset(); | 76   root_window_.reset(); | 
| 75   test_screen_.reset(); | 77   test_screen_.reset(); | 
| 76   gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL); | 78   gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL); | 
|  | 79   ui_controls::UIControls::SetUIControlsInstance( | 
|  | 80       ui_controls::UI_CONTROLS_TYPE_NATIVE, NULL); | 
| 77   aura::Env::DeleteInstance(); | 81   aura::Env::DeleteInstance(); | 
| 78 } | 82 } | 
| 79 | 83 | 
| 80 void AuraTestHelper::RunAllPendingInMessageLoop() { | 84 void AuraTestHelper::RunAllPendingInMessageLoop() { | 
| 81 #if !defined(OS_MACOSX) | 85 #if !defined(OS_MACOSX) | 
| 82   // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them | 86   // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them | 
| 83   //              use run_loop.QuitClosure(). | 87   //              use run_loop.QuitClosure(). | 
| 84   base::RunLoop run_loop(Env::GetInstance()->GetDispatcher()); | 88   base::RunLoop run_loop(Env::GetInstance()->GetDispatcher()); | 
| 85   run_loop.RunUntilIdle(); | 89   run_loop.RunUntilIdle(); | 
| 86 #endif | 90 #endif | 
| 87 } | 91 } | 
| 88 | 92 | 
| 89 }  // namespace test | 93 }  // namespace test | 
| 90 }  // namespace aura | 94 }  // namespace aura | 
| OLD | NEW | 
|---|