| 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/message_loop.h" | 7 #include "base/message_loop/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_activation_client.h" | 10 #include "ui/aura/client/default_activation_client.h" |
| 11 #include "ui/aura/client/default_capture_client.h" | 11 #include "ui/aura/client/default_capture_client.h" |
| 12 #include "ui/aura/client/focus_client.h" | 12 #include "ui/aura/client/focus_client.h" |
| 13 #include "ui/aura/env.h" | 13 #include "ui/aura/env.h" |
| 14 #include "ui/aura/input_state_lookup.h" | 14 #include "ui/aura/input_state_lookup.h" |
| 15 #include "ui/aura/root_window.h" | 15 #include "ui/aura/root_window.h" |
| 16 #include "ui/aura/test/env_test_helper.h" | 16 #include "ui/aura/test/env_test_helper.h" |
| 17 #include "ui/aura/test/test_focus_client.h" | 17 #include "ui/aura/test/test_focus_client.h" |
| 18 #include "ui/aura/test/test_screen.h" | 18 #include "ui/aura/test/test_screen.h" |
| 19 #include "ui/aura/test/test_window_tree_client.h" | 19 #include "ui/aura/test/test_window_tree_client.h" |
| 20 #include "ui/base/ime/dummy_input_method.h" | 20 #include "ui/base/ime/dummy_input_method.h" |
| 21 #include "ui/base/ime/input_method_initializer.h" | 21 #include "ui/base/ime/input_method_initializer.h" |
| 22 #include "ui/compositor/compositor.h" | 22 #include "ui/compositor/compositor.h" |
| 23 #include "ui/compositor/layer_animator.h" | 23 #include "ui/compositor/layer_animator.h" |
| 24 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 24 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 25 #include "ui/compositor/test/context_factories_for_test.h" |
| 25 #include "ui/gfx/screen.h" | 26 #include "ui/gfx/screen.h" |
| 26 | 27 |
| 27 #if defined(USE_X11) | 28 #if defined(USE_X11) |
| 28 #include "ui/aura/root_window_host_x11.h" | 29 #include "ui/aura/root_window_host_x11.h" |
| 29 #include "ui/base/x/x11_util.h" | 30 #include "ui/base/x/x11_util.h" |
| 30 #endif | 31 #endif |
| 31 | 32 |
| 32 #if defined(USE_OZONE) | 33 #if defined(USE_OZONE) |
| 33 #include "ui/gfx/ozone/surface_factory_ozone.h" | 34 #include "ui/gfx/ozone/surface_factory_ozone.h" |
| 34 #endif | 35 #endif |
| (...skipping 24 matching lines...) Expand all Loading... |
| 59 << "AuraTestHelper::SetUp() never called."; | 60 << "AuraTestHelper::SetUp() never called."; |
| 60 CHECK(teardown_called_) | 61 CHECK(teardown_called_) |
| 61 << "AuraTestHelper::TearDown() never called."; | 62 << "AuraTestHelper::TearDown() never called."; |
| 62 } | 63 } |
| 63 | 64 |
| 64 void AuraTestHelper::SetUp() { | 65 void AuraTestHelper::SetUp() { |
| 65 setup_called_ = true; | 66 setup_called_ = true; |
| 66 | 67 |
| 67 // The ContextFactory must exist before any Compositors are created. | 68 // The ContextFactory must exist before any Compositors are created. |
| 68 bool allow_test_contexts = true; | 69 bool allow_test_contexts = true; |
| 69 ui::Compositor::InitializeContextFactoryForTests(allow_test_contexts); | 70 ui::InitializeContextFactoryForTests(allow_test_contexts); |
| 70 | 71 |
| 71 Env::CreateInstance(); | 72 Env::CreateInstance(); |
| 72 // Unit tests generally don't want to query the system, rather use the state | 73 // Unit tests generally don't want to query the system, rather use the state |
| 73 // from RootWindow. | 74 // from RootWindow. |
| 74 EnvTestHelper(Env::GetInstance()).SetInputStateLookup( | 75 EnvTestHelper(Env::GetInstance()).SetInputStateLookup( |
| 75 scoped_ptr<InputStateLookup>()); | 76 scoped_ptr<InputStateLookup>()); |
| 76 | 77 |
| 77 ui::InitializeInputMethodForTesting(); | 78 ui::InitializeInputMethodForTesting(); |
| 78 | 79 |
| 79 test_screen_.reset(TestScreen::Create()); | 80 test_screen_.reset(TestScreen::Create()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 108 test_screen_.reset(); | 109 test_screen_.reset(); |
| 109 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL); | 110 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL); |
| 110 | 111 |
| 111 #if defined(USE_X11) | 112 #if defined(USE_X11) |
| 112 ui::ResetXCursorCache(); | 113 ui::ResetXCursorCache(); |
| 113 #endif | 114 #endif |
| 114 | 115 |
| 115 ui::ShutdownInputMethodForTesting(); | 116 ui::ShutdownInputMethodForTesting(); |
| 116 | 117 |
| 117 Env::DeleteInstance(); | 118 Env::DeleteInstance(); |
| 119 |
| 120 ui::TerminateContextFactoryForTests(); |
| 118 } | 121 } |
| 119 | 122 |
| 120 void AuraTestHelper::RunAllPendingInMessageLoop() { | 123 void AuraTestHelper::RunAllPendingInMessageLoop() { |
| 121 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them | 124 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them |
| 122 // use run_loop.QuitClosure(). | 125 // use run_loop.QuitClosure(). |
| 123 base::RunLoop run_loop(Env::GetInstance()->GetDispatcher()); | 126 base::RunLoop run_loop(Env::GetInstance()->GetDispatcher()); |
| 124 run_loop.RunUntilIdle(); | 127 run_loop.RunUntilIdle(); |
| 125 } | 128 } |
| 126 | 129 |
| 127 } // namespace test | 130 } // namespace test |
| 128 } // namespace aura | 131 } // namespace aura |
| OLD | NEW |