diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-16 01:04:30 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-16 01:04:30 +0000 |
commit | de6831b6677d817f76387c0e489c9c4781e21260 (patch) | |
tree | e0cf6f69152f70b38a152e68681993d8b2ed8f80 /ui/wm/test | |
parent | 8d63476bdb13647553723fcbd8e486786f12bbac (diff) | |
download | chromium_src-de6831b6677d817f76387c0e489c9c4781e21260.zip chromium_src-de6831b6677d817f76387c0e489c9c4781e21260.tar.gz chromium_src-de6831b6677d817f76387c0e489c9c4781e21260.tar.bz2 |
Introduce ui/wm/ directory.
This starts by moving ui/shell into ui/wm/test/ directory and stabilish
a wm.gyp to hold all the targets for wm.
BUG=308710
TEST=None
R=ben@chromium.org
Review URL: https://codereview.chromium.org/74183002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235481 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/wm/test')
-rw-r--r-- | ui/wm/test/DEPS | 4 | ||||
-rw-r--r-- | ui/wm/test/minimal_shell.cc | 56 | ||||
-rw-r--r-- | ui/wm/test/minimal_shell.h | 67 |
3 files changed, 127 insertions, 0 deletions
diff --git a/ui/wm/test/DEPS b/ui/wm/test/DEPS new file mode 100644 index 0000000..78adcc9 --- /dev/null +++ b/ui/wm/test/DEPS @@ -0,0 +1,4 @@ +include_rules = [ + "+ui/aura", + "+ui/views", +] diff --git a/ui/wm/test/minimal_shell.cc b/ui/wm/test/minimal_shell.cc new file mode 100644 index 0000000..d2c289e --- /dev/null +++ b/ui/wm/test/minimal_shell.cc @@ -0,0 +1,56 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/wm/test/minimal_shell.h" + +#include "ui/aura/client/default_activation_client.h" +#include "ui/aura/client/default_capture_client.h" +#include "ui/aura/env.h" +#include "ui/aura/root_window.h" +#include "ui/aura/test/test_focus_client.h" +#include "ui/views/corewm/compound_event_filter.h" +#include "ui/views/corewm/input_method_event_filter.h" + +namespace wm { + +MinimalShell::MinimalShell(const gfx::Size& default_window_size) { + aura::Env::CreateInstance(); + root_window_.reset(new aura::RootWindow( + aura::RootWindow::CreateParams( + gfx::Rect(default_window_size)))); + root_window_->Init(); + aura::client::SetWindowTreeClient(root_window_->window(), this); + + focus_client_.reset(new aura::test::TestFocusClient); + aura::client::SetFocusClient(root_window_->window(), focus_client_.get()); + + root_window_event_filter_ = new views::corewm::CompoundEventFilter; + // Pass ownership of the filter to the root_window. + root_window_->window()->SetEventFilter(root_window_event_filter_); + + input_method_filter_.reset(new views::corewm::InputMethodEventFilter( + root_window_->host()->GetAcceleratedWidget())); + input_method_filter_->SetInputMethodPropertyInRootWindow( + root_window_->window()); + root_window_event_filter_->AddHandler(input_method_filter_.get()); + + activation_client_.reset( + new aura::client::DefaultActivationClient(root_window_->window())); + + capture_client_.reset( + new aura::client::DefaultCaptureClient(root_window_->window())); +} + +MinimalShell::~MinimalShell() { + root_window_event_filter_->RemoveHandler(input_method_filter_.get()); +} + +aura::Window* MinimalShell::GetDefaultParent( + aura::Window* context, + aura::Window* window, + const gfx::Rect& bounds) { + return root_window_->window(); +} + +} // namespace wm diff --git a/ui/wm/test/minimal_shell.h b/ui/wm/test/minimal_shell.h new file mode 100644 index 0000000..71cfb8b --- /dev/null +++ b/ui/wm/test/minimal_shell.h @@ -0,0 +1,67 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_WM_TEST_MINIMAL_SHELL_H_ +#define UI_WM_TEST_MINIMAL_SHELL_H_ + +#include "base/compiler_specific.h" +#include "base/memory/scoped_ptr.h" +#include "ui/aura/client/window_tree_client.h" + +namespace aura { +class RootWindow; +class Window; +namespace client { +class DefaultActivationClient; +class DefaultCaptureClient; +class FocusClient; +} // class client +} // class aura + +namespace gfx { +class Rect; +class Size; +} // class gfx + +namespace views { +namespace corewm { +class CompoundEventFilter; +class InputMethodEventFilter; +} // corewm +} // views + +namespace wm { + +// Creates a minimal environment for running the shell. We can't pull in all of +// ash here, but we can create attach several of the same things we'd find in +// the ash parts of the code. +class MinimalShell : public aura::client::WindowTreeClient { + public: + explicit MinimalShell(const gfx::Size& default_window_size); + virtual ~MinimalShell(); + + aura::RootWindow* root_window() { return root_window_.get(); } + + // Overridden from client::WindowTreeClient: + virtual aura::Window* GetDefaultParent(aura::Window* context, + aura::Window* window, + const gfx::Rect& bounds) OVERRIDE; + + private: + scoped_ptr<aura::RootWindow> root_window_; + + // Owned by RootWindow + views::corewm::CompoundEventFilter* root_window_event_filter_; + + scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; + scoped_ptr<views::corewm::InputMethodEventFilter> input_method_filter_; + scoped_ptr<aura::client::DefaultActivationClient> activation_client_; + scoped_ptr<aura::client::FocusClient> focus_client_; + + DISALLOW_COPY_AND_ASSIGN(MinimalShell); +}; + +} // namespace wm + +#endif // UI_WM_TEST_MINIMAL_SHELL_H_ |