| 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_capture_client.h" | 11 #include "ui/aura/client/default_capture_client.h" |
| 11 #include "ui/aura/client/focus_client.h" | 12 #include "ui/aura/client/focus_client.h" |
| 12 #include "ui/aura/env.h" | 13 #include "ui/aura/env.h" |
| 13 #include "ui/aura/input_state_lookup.h" | 14 #include "ui/aura/input_state_lookup.h" |
| 14 #include "ui/aura/test/env_test_helper.h" | 15 #include "ui/aura/test/env_test_helper.h" |
| 15 #include "ui/aura/test/test_focus_client.h" | 16 #include "ui/aura/test/test_focus_client.h" |
| 16 #include "ui/aura/test/test_screen.h" | 17 #include "ui/aura/test/test_screen.h" |
| 17 #include "ui/aura/test/test_window_tree_client.h" | 18 #include "ui/aura/test/test_window_tree_client.h" |
| 18 #include "ui/aura/window_event_dispatcher.h" | 19 #include "ui/aura/window_event_dispatcher.h" |
| 19 #include "ui/base/ime/dummy_input_method.h" | 20 #include "ui/base/ime/dummy_input_method.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 64 |
| 64 ui::InitializeInputMethodForTesting(); | 65 ui::InitializeInputMethodForTesting(); |
| 65 | 66 |
| 66 test_screen_.reset(TestScreen::Create()); | 67 test_screen_.reset(TestScreen::Create()); |
| 67 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); | 68 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); |
| 68 host_.reset(test_screen_->CreateHostForPrimaryDisplay()); | 69 host_.reset(test_screen_->CreateHostForPrimaryDisplay()); |
| 69 | 70 |
| 70 focus_client_.reset(new TestFocusClient); | 71 focus_client_.reset(new TestFocusClient); |
| 71 client::SetFocusClient(root_window(), focus_client_.get()); | 72 client::SetFocusClient(root_window(), focus_client_.get()); |
| 72 stacking_client_.reset(new TestWindowTreeClient(root_window())); | 73 stacking_client_.reset(new TestWindowTreeClient(root_window())); |
| 74 activation_client_.reset( |
| 75 new client::DefaultActivationClient(root_window())); |
| 73 capture_client_.reset(new client::DefaultCaptureClient(root_window())); | 76 capture_client_.reset(new client::DefaultCaptureClient(root_window())); |
| 74 test_input_method_.reset(new ui::DummyInputMethod); | 77 test_input_method_.reset(new ui::DummyInputMethod); |
| 75 root_window()->SetProperty( | 78 root_window()->SetProperty( |
| 76 client::kRootWindowInputMethodKey, | 79 client::kRootWindowInputMethodKey, |
| 77 test_input_method_.get()); | 80 test_input_method_.get()); |
| 78 | 81 |
| 79 root_window()->Show(); | 82 root_window()->Show(); |
| 80 // Ensure width != height so tests won't confuse them. | 83 // Ensure width != height so tests won't confuse them. |
| 81 host()->SetBounds(gfx::Rect(800, 600)); | 84 host()->SetBounds(gfx::Rect(800, 600)); |
| 82 } | 85 } |
| 83 | 86 |
| 84 void AuraTestHelper::TearDown() { | 87 void AuraTestHelper::TearDown() { |
| 85 teardown_called_ = true; | 88 teardown_called_ = true; |
| 86 test_input_method_.reset(); | 89 test_input_method_.reset(); |
| 87 stacking_client_.reset(); | 90 stacking_client_.reset(); |
| 91 activation_client_.reset(); |
| 88 capture_client_.reset(); | 92 capture_client_.reset(); |
| 89 focus_client_.reset(); | 93 focus_client_.reset(); |
| 90 client::SetFocusClient(root_window(), NULL); | 94 client::SetFocusClient(root_window(), NULL); |
| 91 host_.reset(); | 95 host_.reset(); |
| 92 ui::GestureRecognizer::Reset(); | 96 ui::GestureRecognizer::Reset(); |
| 93 test_screen_.reset(); | 97 test_screen_.reset(); |
| 94 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL); | 98 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL); |
| 95 | 99 |
| 96 #if defined(USE_X11) | 100 #if defined(USE_X11) |
| 97 ui::ResetXCursorCache(); | 101 ui::ResetXCursorCache(); |
| 98 #endif | 102 #endif |
| 99 | 103 |
| 100 ui::ShutdownInputMethodForTesting(); | 104 ui::ShutdownInputMethodForTesting(); |
| 101 | 105 |
| 102 Env::DeleteInstance(); | 106 Env::DeleteInstance(); |
| 103 } | 107 } |
| 104 | 108 |
| 105 void AuraTestHelper::RunAllPendingInMessageLoop() { | 109 void AuraTestHelper::RunAllPendingInMessageLoop() { |
| 106 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them | 110 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them |
| 107 // use run_loop.QuitClosure(). | 111 // use run_loop.QuitClosure(). |
| 108 base::RunLoop run_loop; | 112 base::RunLoop run_loop; |
| 109 run_loop.RunUntilIdle(); | 113 run_loop.RunUntilIdle(); |
| 110 } | 114 } |
| 111 | 115 |
| 112 } // namespace test | 116 } // namespace test |
| 113 } // namespace aura | 117 } // namespace aura |
| OLD | NEW |