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