| Index: ui/aura/mus/window_tree_host_mus_unittest.cc
|
| diff --git a/ui/aura/mus/window_tree_host_mus_unittest.cc b/ui/aura/mus/window_tree_host_mus_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..7e69dc9253ba7ae5a09bf33d0d371abb137c1621
|
| --- /dev/null
|
| +++ b/ui/aura/mus/window_tree_host_mus_unittest.cc
|
| @@ -0,0 +1,133 @@
|
| +// Copyright 2016 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/aura/mus/window_tree_host_mus.h"
|
| +
|
| +#include "base/message_loop/message_loop.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +#include "ui/aura/client/default_capture_client.h"
|
| +#include "ui/aura/client/focus_client.h"
|
| +#include "ui/aura/env.h"
|
| +#include "ui/aura/mus/property_converter.h"
|
| +#include "ui/aura/mus/window_port_mus.h"
|
| +#include "ui/aura/mus/window_tree_client_delegate.h"
|
| +#include "ui/aura/mus/window_tree_host_mus.h"
|
| +#include "ui/aura/test/env_test_helper.h"
|
| +#include "ui/aura/test/mus/test_window_tree.h"
|
| +#include "ui/aura/test/mus/test_window_tree_client_setup.h"
|
| +#include "ui/aura/test/test_focus_client.h"
|
| +#include "ui/aura/test/test_screen.h"
|
| +#include "ui/aura/window_port_local.h"
|
| +#include "ui/compositor/test/context_factories_for_test.h"
|
| +#include "ui/wm/core/wm_state.h"
|
| +
|
| +namespace aura {
|
| +
|
| +// AuraMusClientTestBase doesn't appear to be going through the
|
| +// WindowTreeHostMus path at all. So instead, we create a minimal environment
|
| +// where we build our own TestWindowTree and Window.
|
| +class WindowTreeHostMusTest : public testing::Test,
|
| + public aura::WindowTreeClientDelegate {
|
| + public:
|
| + WindowTreeHostMusTest() {}
|
| + ~WindowTreeHostMusTest() override {}
|
| +
|
| + void SetUp() override {
|
| + Test::SetUp();
|
| + wm_state_ = base::MakeUnique<wm::WMState>();
|
| + focus_client_ = base::MakeUnique<test::TestFocusClient>();
|
| + capture_client_ = base::MakeUnique<client::DefaultCaptureClient>();
|
| + property_converter_ = base::MakeUnique<aura::PropertyConverter>();
|
| +
|
| + // The ContextFactory must exist before any Compositors are created.
|
| + bool enable_pixel_output = false;
|
| + ui::ContextFactory* context_factory =
|
| + ui::InitializeContextFactoryForTests(enable_pixel_output);
|
| +
|
| + if (!Env::GetInstanceDontCreate())
|
| + env_ = Env::CreateInstance(Env::Mode::MUS);
|
| + Env::GetInstance()->set_context_factory(context_factory);
|
| +
|
| + window_tree_client_setup_ = base::MakeUnique<TestWindowTreeClientSetup>();
|
| + window_tree_client_setup_->Init(this);
|
| +
|
| + test_screen_.reset(TestScreen::Create(gfx::Size(800, 600)));
|
| + display::Screen::SetScreenInstance(test_screen_.get());
|
| +
|
| + window_tree_host_mus_ =
|
| + base::MakeUnique<WindowTreeHostMus>(window_tree_client());
|
| + }
|
| +
|
| + void TearDown() override {
|
| + window_tree_host_mus_.reset();
|
| + if (display::Screen::GetScreen() == test_screen_.get())
|
| + display::Screen::SetScreenInstance(nullptr);
|
| + window_tree_client_setup_.reset();
|
| +
|
| + ui::TerminateContextFactoryForTests();
|
| + Test::TearDown();
|
| + }
|
| +
|
| + WindowTreeHostMus* window_tree_host_mus() {
|
| + return window_tree_host_mus_.get();
|
| + }
|
| +
|
| + TestWindowTree* test_window_tree() {
|
| + return window_tree_client_setup_->window_tree();
|
| + }
|
| +
|
| + WindowTreeClient* window_tree_client() {
|
| + return window_tree_client_setup_->window_tree_client();
|
| + }
|
| +
|
| + private:
|
| + // WindowTreeClientDelegate:
|
| + void OnEmbed(
|
| + std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) override {}
|
| + void OnLostConnection(aura::WindowTreeClient* client) override {}
|
| + void OnEmbedRootDestroyed(aura::Window* root) override {}
|
| + void OnPointerEventObserved(const ui::PointerEvent& event,
|
| + aura::Window* target) override {}
|
| + aura::client::CaptureClient* GetCaptureClient() override {
|
| + return capture_client_.get();
|
| + }
|
| + aura::PropertyConverter* GetPropertyConverter() override {
|
| + return property_converter_.get();
|
| + }
|
| +
|
| + // Needed by the compositor.
|
| + base::MessageLoopForUI message_loop_;
|
| +
|
| + std::unique_ptr<aura::Env> env_;
|
| +
|
| + std::unique_ptr<wm::WMState> wm_state_;
|
| + std::unique_ptr<client::DefaultCaptureClient> capture_client_;
|
| + std::unique_ptr<client::FocusClient> focus_client_;
|
| + std::unique_ptr<aura::PropertyConverter> property_converter_;
|
| + std::unique_ptr<TestWindowTreeClientSetup> window_tree_client_setup_;
|
| + std::unique_ptr<TestScreen> test_screen_;
|
| +
|
| + std::unique_ptr<aura::WindowTreeHostMus> window_tree_host_mus_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(WindowTreeHostMusTest);
|
| +};
|
| +
|
| +TEST_F(WindowTreeHostMusTest, UpdateClientArea) {
|
| + gfx::Insets new_insets(10, 11, 12, 13);
|
| + window_tree_host_mus()->SetClientArea(new_insets);
|
| + EXPECT_EQ(new_insets, test_window_tree()->last_client_area());
|
| +}
|
| +
|
| +TEST_F(WindowTreeHostMusTest, SetHitTestMask) {
|
| + EXPECT_FALSE(test_window_tree()->last_hit_test_mask().has_value());
|
| + gfx::Rect mask(10, 10, 10, 10);
|
| + window_tree_host_mus()->SetHitTestMask(mask);
|
| + ASSERT_TRUE(test_window_tree()->last_hit_test_mask().has_value());
|
| + EXPECT_EQ(mask, test_window_tree()->last_hit_test_mask());
|
| +
|
| + window_tree_host_mus()->ClearHitTestMask();
|
| + ASSERT_FALSE(test_window_tree()->last_hit_test_mask().has_value());
|
| +}
|
| +
|
| +} // namespace aura
|
|
|