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
3 // found in the LICENSE file.
5 #include "ui/wm/test/wm_test_helper.h"
7 #include "ui/aura/client/default_capture_client.h"
8 #include "ui/aura/env.h"
9 #include "ui/aura/test/test_focus_client.h"
10 #include "ui/aura/window.h"
11 #include "ui/wm/core/compound_event_filter.h"
12 #include "ui/wm/core/default_activation_client.h"
16 WMTestHelper::WMTestHelper(const gfx::Size
& default_window_size
,
17 ui::ContextFactory
* context_factory
) {
18 aura::Env::CreateInstance(true);
19 aura::Env::GetInstance()->set_context_factory(context_factory
);
20 host_
.reset(aura::WindowTreeHost::Create(gfx::Rect(default_window_size
)));
22 aura::client::SetWindowTreeClient(host_
->window(), this);
24 focus_client_
.reset(new aura::test::TestFocusClient
);
25 aura::client::SetFocusClient(host_
->window(), focus_client_
.get());
27 root_window_event_filter_
.reset(new wm::CompoundEventFilter
);
28 host_
->window()->AddPreTargetHandler(root_window_event_filter_
.get());
30 new wm::DefaultActivationClient(host_
->window());
32 capture_client_
.reset(
33 new aura::client::DefaultCaptureClient(host_
->window()));
36 WMTestHelper::~WMTestHelper() {
39 aura::Window
* WMTestHelper::GetDefaultParent(aura::Window
* context
,
41 const gfx::Rect
& bounds
) {
42 return host_
->window();