| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/wm/test/wm_test_helper.h" | 5 #include "ui/wm/test/wm_test_helper.h" |
| 6 | 6 |
| 7 #include "ui/aura/client/default_capture_client.h" | 7 #include "ui/aura/client/default_capture_client.h" |
| 8 #include "ui/aura/env.h" | 8 #include "ui/aura/env.h" |
| 9 #include "ui/aura/test/test_focus_client.h" | 9 #include "ui/aura/test/test_focus_client.h" |
| 10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
| 11 #include "ui/base/ime/text_input_focus_manager.h" | |
| 12 #include "ui/wm/core/compound_event_filter.h" | 11 #include "ui/wm/core/compound_event_filter.h" |
| 13 #include "ui/wm/core/default_activation_client.h" | 12 #include "ui/wm/core/default_activation_client.h" |
| 14 #include "ui/wm/core/input_method_event_filter.h" | 13 #include "ui/wm/core/input_method_event_filter.h" |
| 15 | 14 |
| 16 namespace wm { | 15 namespace wm { |
| 17 | 16 |
| 18 WMTestHelper::WMTestHelper(const gfx::Size& default_window_size, | 17 WMTestHelper::WMTestHelper(const gfx::Size& default_window_size, |
| 19 ui::ContextFactory* context_factory) { | 18 ui::ContextFactory* context_factory) { |
| 20 ui::TextInputFocusManager::GetInstance()->FocusTextInputClient(NULL); | |
| 21 aura::Env::CreateInstance(true); | 19 aura::Env::CreateInstance(true); |
| 22 aura::Env::GetInstance()->set_context_factory(context_factory); | 20 aura::Env::GetInstance()->set_context_factory(context_factory); |
| 23 host_.reset(aura::WindowTreeHost::Create(gfx::Rect(default_window_size))); | 21 host_.reset(aura::WindowTreeHost::Create(gfx::Rect(default_window_size))); |
| 24 host_->InitHost(); | 22 host_->InitHost(); |
| 25 aura::client::SetWindowTreeClient(host_->window(), this); | 23 aura::client::SetWindowTreeClient(host_->window(), this); |
| 26 | 24 |
| 27 focus_client_.reset(new aura::test::TestFocusClient); | 25 focus_client_.reset(new aura::test::TestFocusClient); |
| 28 aura::client::SetFocusClient(host_->window(), focus_client_.get()); | 26 aura::client::SetFocusClient(host_->window(), focus_client_.get()); |
| 29 | 27 |
| 30 root_window_event_filter_.reset(new wm::CompoundEventFilter); | 28 root_window_event_filter_.reset(new wm::CompoundEventFilter); |
| 31 host_->window()->AddPreTargetHandler(root_window_event_filter_.get()); | 29 host_->window()->AddPreTargetHandler(root_window_event_filter_.get()); |
| 32 | 30 |
| 33 input_method_filter_.reset(new wm::InputMethodEventFilter( | 31 input_method_filter_.reset(new wm::InputMethodEventFilter( |
| 34 host_->GetAcceleratedWidget())); | 32 host_->GetAcceleratedWidget())); |
| 35 input_method_filter_->SetInputMethodPropertyInRootWindow(host_->window()); | 33 input_method_filter_->SetInputMethodPropertyInRootWindow(host_->window()); |
| 36 root_window_event_filter_->AddHandler(input_method_filter_.get()); | 34 root_window_event_filter_->AddHandler(input_method_filter_.get()); |
| 37 | 35 |
| 38 new wm::DefaultActivationClient(host_->window()); | 36 new wm::DefaultActivationClient(host_->window()); |
| 39 | 37 |
| 40 capture_client_.reset( | 38 capture_client_.reset( |
| 41 new aura::client::DefaultCaptureClient(host_->window())); | 39 new aura::client::DefaultCaptureClient(host_->window())); |
| 42 } | 40 } |
| 43 | 41 |
| 44 WMTestHelper::~WMTestHelper() { | 42 WMTestHelper::~WMTestHelper() { |
| 45 root_window_event_filter_->RemoveHandler(input_method_filter_.get()); | 43 root_window_event_filter_->RemoveHandler(input_method_filter_.get()); |
| 46 ui::TextInputFocusManager::GetInstance()->FocusTextInputClient(NULL); | |
| 47 } | 44 } |
| 48 | 45 |
| 49 aura::Window* WMTestHelper::GetDefaultParent(aura::Window* context, | 46 aura::Window* WMTestHelper::GetDefaultParent(aura::Window* context, |
| 50 aura::Window* window, | 47 aura::Window* window, |
| 51 const gfx::Rect& bounds) { | 48 const gfx::Rect& bounds) { |
| 52 return host_->window(); | 49 return host_->window(); |
| 53 } | 50 } |
| 54 | 51 |
| 55 } // namespace wm | 52 } // namespace wm |
| OLD | NEW |