Commit d1908438 authored by Shawn Gallea's avatar Shawn Gallea Committed by Commit Bot

EXO: Added FullscreenShellSurface

Created FullscreenShellSurface class, similar to ShellSurface but without
any ash dependencies, to be used with fullscreen wayland protocol
to allow EXO use on other platforms.

Added unit test for FullscreenShellSurface for cast.

Bug: 896710
Test: Compiled on ChromeOS
Change-Id: I542c9b0729b847f4cde2fa67d727143e18f4a2a5
Reviewed-on: https://chromium-review.googlesource.com/c/1298172
Commit-Queue: Shawn Gallea <sagallea@google.com>
Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607237}
parent a5d0ab06
...@@ -113,20 +113,18 @@ source_set("exo") { ...@@ -113,20 +113,18 @@ source_set("exo") {
"xdg_shell_surface.h", "xdg_shell_surface.h",
] ]
} }
if (is_chromecast) {
sources += [
"fullscreen_shell_surface.cc",
"fullscreen_shell_surface.h",
]
}
} }
source_set("test_support") { source_set("test_support") {
testonly = true testonly = true
sources = [
"test/exo_test_base.cc",
"test/exo_test_base.h",
"test/exo_test_helper.cc",
"test/exo_test_helper.h",
"test/test_client_controlled_state_delegate.cc",
"test/test_client_controlled_state_delegate.h",
]
deps = [ deps = [
":exo", ":exo",
"//base", "//base",
...@@ -141,37 +139,31 @@ source_set("test_support") { ...@@ -141,37 +139,31 @@ source_set("test_support") {
] ]
if (is_chromeos) { if (is_chromeos) {
sources = [
"test/exo_test_base.cc",
"test/exo_test_base.h",
"test/exo_test_helper.cc",
"test/exo_test_helper.h",
"test/test_client_controlled_state_delegate.cc",
"test/test_client_controlled_state_delegate.h",
]
deps += [ deps += [
"//ash:test_support_without_content", "//ash:test_support_without_content",
"//ash/public/cpp", "//ash/public/cpp",
] ]
} }
if (is_chromecast) {
sources = [
"test/exo_test_base_cast.cc",
"test/exo_test_base_cast.h",
]
}
} }
source_set("unit_tests") { source_set("unit_tests") {
testonly = true testonly = true
sources = [
"../../ui/events/ozone/gamepad/gamepad_event.cc",
"buffer_unittest.cc",
"client_controlled_shell_surface_unittest.cc",
"data_device_unittest.cc",
"data_offer_unittest.cc",
"data_source_unittest.cc",
"display_unittest.cc",
"gaming_seat_unittest.cc",
"keyboard_unittest.cc",
"notification_unittest.cc",
"pointer_unittest.cc",
"seat_unittest.cc",
"shared_memory_unittest.cc",
"shell_surface_unittest.cc",
"sub_surface_unittest.cc",
"surface_unittest.cc",
"text_input_unittest.cc",
"touch_unittest.cc",
]
deps = [ deps = [
":exo", ":exo",
":test_support", ":test_support",
...@@ -204,6 +196,27 @@ source_set("unit_tests") { ...@@ -204,6 +196,27 @@ source_set("unit_tests") {
} }
if (is_chromeos) { if (is_chromeos) {
sources = [
"../../ui/events/ozone/gamepad/gamepad_event.cc",
"buffer_unittest.cc",
"client_controlled_shell_surface_unittest.cc",
"data_device_unittest.cc",
"data_offer_unittest.cc",
"data_source_unittest.cc",
"display_unittest.cc",
"gaming_seat_unittest.cc",
"keyboard_unittest.cc",
"notification_unittest.cc",
"pointer_unittest.cc",
"seat_unittest.cc",
"shared_memory_unittest.cc",
"shell_surface_unittest.cc",
"sub_surface_unittest.cc",
"surface_unittest.cc",
"text_input_unittest.cc",
"touch_unittest.cc",
]
deps += [ deps += [
"//ash", "//ash",
"//ash:test_support_without_content", "//ash:test_support_without_content",
...@@ -211,6 +224,12 @@ source_set("unit_tests") { ...@@ -211,6 +224,12 @@ source_set("unit_tests") {
"//ui/keyboard", "//ui/keyboard",
] ]
} }
if (is_chromecast) {
sources = [
"fullscreen_shell_surface_unittest.cc",
]
}
} }
test("exo_unittests") { test("exo_unittests") {
......
// Copyright 2018 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 "components/exo/fullscreen_shell_surface.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/trace_event_argument.h"
#include "components/exo/surface.h"
#include "components/exo/wm_helper.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
#include "ui/aura/window_targeter.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/dip_util.h"
#include "ui/gfx/path.h"
#include "ui/views/widget/widget.h"
#include "ui/wm/core/window_util.h"
namespace exo {
namespace {
// Main surface key
DEFINE_LOCAL_UI_CLASS_PROPERTY_KEY(Surface*, kMainSurfaceKey, nullptr)
// Application Id set by the client.
DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(std::string, kApplicationIdKey, nullptr);
// Application Id set by the client.
DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(std::string, kStartupIdKey, nullptr);
} // namespace
FullscreenShellSurface::FullscreenShellSurface(Surface* surface)
: SurfaceTreeHost("FullscreenShellSurfaceHost") {
surface->AddSurfaceObserver(this);
SetRootSurface(surface);
host_window()->Show();
set_owned_by_client();
CreateFullscreenShellSurfaceWidget(ui::SHOW_STATE_FULLSCREEN);
widget_->SetFullscreen(true);
}
FullscreenShellSurface::~FullscreenShellSurface() {
if (widget_) {
widget_->GetNativeWindow()->RemoveObserver(this);
// Remove transient children so they are not automatically destroyed.
for (auto* child : wm::GetTransientChildren(widget_->GetNativeWindow()))
wm::RemoveTransientChild(widget_->GetNativeWindow(), child);
if (widget_->IsVisible())
widget_->Hide();
widget_->CloseNow();
}
if (parent_)
parent_->RemoveObserver(this);
if (root_surface())
root_surface()->RemoveSurfaceObserver(this);
}
// static
void FullscreenShellSurface::SetStartupId(
aura::Window* window,
const base::Optional<std::string>& id) {
TRACE_EVENT1("exo", "FullscreenShellSurface::SetStartupId", "startup_id",
id ? *id : "null");
if (id)
window->SetProperty(kStartupIdKey, new std::string(*id));
else
window->ClearProperty(kStartupIdKey);
}
// static
void FullscreenShellSurface::SetStartupId(const char* startup_id) {
// Store the value in |startup_id_| in case the window does not exist yet.
if (startup_id)
startup_id_ = std::string(startup_id);
else
startup_id_.reset();
if (widget_ && widget_->GetNativeWindow())
SetStartupId(widget_->GetNativeWindow(), startup_id_);
}
// static
std::string* FullscreenShellSurface::GetStartupId(aura::Window* window) {
return window->GetProperty(kStartupIdKey);
}
void FullscreenShellSurface::SetApplicationId(
aura::Window* window,
const base::Optional<std::string>& id) {
TRACE_EVENT1("exo", "ShellSurfaceBase::SetApplicationId", "application_id",
id ? *id : "null");
if (id)
window->SetProperty(kApplicationIdKey, new std::string(*id));
else
window->ClearProperty(kApplicationIdKey);
}
// static
std::string* FullscreenShellSurface::GetApplicationId(aura::Window* window) {
return window->GetProperty(kApplicationIdKey);
}
void FullscreenShellSurface::SetApplicationId(const char* application_id) {
// Store the value in |application_id_| in case the window does not exist yet.
if (application_id)
application_id_ = std::string(application_id);
else
application_id_.reset();
if (widget_ && widget_->GetNativeWindow())
SetApplicationId(widget_->GetNativeWindow(), application_id_);
}
// static
void FullscreenShellSurface::SetMainSurface(aura::Window* window,
Surface* surface) {
window->SetProperty(kMainSurfaceKey, surface);
}
// static
Surface* FullscreenShellSurface::GetMainSurface(aura::Window* window) {
return window->GetProperty(kMainSurfaceKey);
}
void FullscreenShellSurface::Maximize() {
if (!widget_)
return;
widget_->Maximize();
}
void FullscreenShellSurface::Minimize() {
if (!widget_)
return;
widget_->Minimize();
}
void FullscreenShellSurface::Close() {
if (!close_callback_.is_null())
close_callback_.Run();
}
void FullscreenShellSurface::OnSurfaceCommit() {
SurfaceTreeHost::OnSurfaceCommit();
if (!OnPreWidgetCommit())
return;
CommitWidget();
SubmitCompositorFrame();
}
bool FullscreenShellSurface::IsInputEnabled(Surface*) const {
return true;
}
void FullscreenShellSurface::OnSetFrame(SurfaceFrameType frame_type) {}
void FullscreenShellSurface::OnSetFrameColors(SkColor active_color,
SkColor inactive_color) {}
void FullscreenShellSurface::OnSetStartupId(const char* startup_id) {
SetStartupId(startup_id);
}
void FullscreenShellSurface::OnSetApplicationId(const char* application_id) {
SetApplicationId(application_id);
}
void FullscreenShellSurface::OnSurfaceDestroying(Surface* surface) {
DCHECK_EQ(root_surface(), surface);
surface->RemoveSurfaceObserver(this);
SetRootSurface(nullptr);
if (widget_)
SetMainSurface(widget_->GetNativeWindow(), nullptr);
// Hide widget before surface is destroyed. This allows hide animations to
// run using the current surface contents.
if (widget_) {
// Remove transient children so they are not automatically hidden.
for (auto* child : wm::GetTransientChildren(widget_->GetNativeWindow()))
wm::RemoveTransientChild(widget_->GetNativeWindow(), child);
widget_->Hide();
}
// Note: In its use in the Wayland server implementation, the surface
// destroyed callback may destroy the ShellSurface instance. This call needs
// to be last so that the instance can be destroyed.
std::move(surface_destroyed_callback_).Run();
}
bool FullscreenShellSurface::CanResize() const {
return false;
}
bool FullscreenShellSurface::CanMaximize() const {
return true;
}
bool FullscreenShellSurface::CanMinimize() const {
return true;
}
bool FullscreenShellSurface::ShouldShowWindowTitle() const {
return false;
}
void FullscreenShellSurface::WindowClosing() {
SetEnabled(false);
widget_ = nullptr;
}
views::Widget* FullscreenShellSurface::GetWidget() {
return widget_;
}
const views::Widget* FullscreenShellSurface::GetWidget() const {
return widget_;
}
views::View* FullscreenShellSurface::GetContentsView() {
return this;
}
bool FullscreenShellSurface::WidgetHasHitTestMask() const {
return true;
}
void FullscreenShellSurface::GetWidgetHitTestMask(gfx::Path* mask) const {
GetHitTestMask(mask);
gfx::Point origin = host_window()->bounds().origin();
SkMatrix matrix;
// TODO (sagallea) acquire scale from display
float scale = 1.f;
matrix.setScaleTranslate(
SkFloatToScalar(1.0f / scale), SkFloatToScalar(1.0f / scale),
SkIntToScalar(origin.x()), SkIntToScalar(origin.y()));
mask->transform(matrix);
}
void FullscreenShellSurface::OnWindowDestroying(aura::Window* window) {
if (window == parent_) {
parent_ = nullptr;
// |parent_| being set to null effects the ability to maximize the window.
if (widget_)
widget_->OnSizeConstraintsChanged();
}
window->RemoveObserver(this);
}
void FullscreenShellSurface::CreateFullscreenShellSurfaceWidget(
ui::WindowShowState show_state) {
DCHECK(enabled());
DCHECK(!widget_);
views::Widget::InitParams params;
params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS;
params.ownership = views::Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET;
params.delegate = this;
params.shadow_type = views::Widget::InitParams::SHADOW_TYPE_NONE;
params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
params.show_state = show_state;
params.activatable = views::Widget::InitParams::ACTIVATABLE_YES;
params.parent = WMHelper::GetInstance()->GetRootWindowForNewWindows();
widget_ = new views::Widget();
widget_->Init(params);
aura::Window* window = widget_->GetNativeWindow();
window->SetName("FullscreenShellSurface");
window->AddChild(host_window());
SetApplicationId(window, application_id_);
SetStartupId(window, startup_id_);
SetMainSurface(window, root_surface());
window->AddObserver(this);
}
void FullscreenShellSurface::CommitWidget() {
if (!widget_)
return;
// Show widget if needed.
if (!widget_->IsVisible()) {
DCHECK(!widget_->IsClosed());
widget_->Show();
}
}
bool FullscreenShellSurface::OnPreWidgetCommit() {
if (!widget_ && enabled() && host_window()->bounds().IsEmpty())
return false;
return true;
}
} // namespace exo
// Copyright 2018 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 COMPONENTS_EXO_FULLSCREEN_SHELL_SURFACE_H_
#define COMPONENTS_EXO_FULLSCREEN_SHELL_SURFACE_H_
#include "components/exo/surface_observer.h"
#include "components/exo/surface_tree_host.h"
#include "ui/aura/window_observer.h"
#include "ui/views/widget/widget_delegate.h"
namespace exo {
class Surface;
// This class implements a toplevel fullscreen surface for which position
// and state are managed by the shell.
class FullscreenShellSurface : public SurfaceTreeHost,
public SurfaceObserver,
public aura::WindowObserver,
public views::WidgetDelegate,
public views::View {
public:
explicit FullscreenShellSurface(Surface* surface);
~FullscreenShellSurface() override;
// Set the callback to run when the user wants the shell surface to be closed.
// The receiver can chose to not close the window on this signal.
void set_close_callback(const base::RepeatingClosure& close_callback) {
close_callback_ = close_callback;
}
// Set the callback to run when the surface is destroyed.
void set_surface_destroyed_callback(
base::OnceClosure surface_destroyed_callback) {
surface_destroyed_callback_ = std::move(surface_destroyed_callback);
}
// Sets the application ID for the window. The application ID identifies the
// general class of applications to which the window belongs.
static void SetApplicationId(aura::Window* window,
const base::Optional<std::string>& id);
// Gets the application ID for the window. The application ID identifies the
// general class of applications to which the window belongs.
static std::string* GetApplicationId(aura::Window* window);
// Set the application ID for the surface
void SetApplicationId(const char* startup_id);
// Sets the startup ID for the window. The startup ID identifies the
// application using startup notification protocol.
static void SetStartupId(aura::Window* window,
const base::Optional<std::string>& id);
// Gets the startup ID for the window. The startup ID identifies the
// application using startup notification protocol.
static std::string* GetStartupId(aura::Window* window);
// Set the startup ID for the surface.
void SetStartupId(const char* startup_id);
// Sets the main surface for the window.
static void SetMainSurface(aura::Window* window, Surface* surface);
static Surface* GetMainSurface(aura::Window* window);
void Maximize();
void Minimize();
void Close();
// Overridden from SurfaceDelegate:
void OnSurfaceCommit() override;
bool IsInputEnabled(Surface* surface) const override;
void OnSetFrame(SurfaceFrameType type) override;
void OnSetFrameColors(SkColor active_color, SkColor inactive_color) override;
void OnSetStartupId(const char* startup_id) override;
void OnSetApplicationId(const char* application_id) override;
// Overridden from SurfaceObserver:
void OnSurfaceDestroying(Surface* surface) override;
// Overridden from views::WidgetDelegate:
bool CanResize() const override;
bool CanMaximize() const override;
bool CanMinimize() const override;
bool ShouldShowWindowTitle() const override;
void WindowClosing() override;
views::Widget* GetWidget() override;
const views::Widget* GetWidget() const override;
views::View* GetContentsView() override;
bool WidgetHasHitTestMask() const override;
void GetWidgetHitTestMask(gfx::Path* mask) const override;
// Overridden from aura::WindowObserver:
void OnWindowDestroying(aura::Window* window) override;
private:
void CreateFullscreenShellSurfaceWidget(ui::WindowShowState show_state);
void CommitWidget();
bool OnPreWidgetCommit();
views::Widget* widget_ = nullptr;
aura::Window* parent_ = nullptr;
base::Optional<std::string> application_id_;
base::Optional<std::string> startup_id_;
base::RepeatingClosure close_callback_;
base::OnceClosure surface_destroyed_callback_;
DISALLOW_COPY_AND_ASSIGN(FullscreenShellSurface);
};
} // namespace exo
#endif // COMPONENTS_EXO_FULLSCREEN_SHELL_SURFACE_H
// Copyright 2018 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 "components/exo/fullscreen_shell_surface.h"
#include "components/exo/buffer.h"
#include "components/exo/surface.h"
#include "components/exo/test/exo_test_base_cast.h"
#include "components/exo/wm_helper.h"
#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/compositor/compositor.h"
#include "ui/gfx/buffer_types.h"
#include "ui/views/widget/widget.h"
namespace exo {
namespace {
using FullscreenShellSurfaceTest = test::ExoTestBaseCast;
std::unique_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBuffer(
const gfx::Size& size,
gfx::BufferFormat format) {
return WMHelper::GetInstance()
->env()
->context_factory()
->GetGpuMemoryBufferManager()
->CreateGpuMemoryBuffer(size, format, gfx::BufferUsage::GPU_READ,
gpu::kNullSurfaceHandle);
}
void DestroyFullscreenShellSurface(
std::unique_ptr<FullscreenShellSurface>* fullscreen_surface) {
fullscreen_surface->reset();
}
void Close(int* close_call_count) {
(*close_call_count)++;
}
TEST_F(FullscreenShellSurfaceTest, SurfaceDestroyedCallback) {
std::unique_ptr<Surface> surface(new Surface);
std::unique_ptr<FullscreenShellSurface> fullscreen_surface(
new FullscreenShellSurface(surface.get()));
fullscreen_surface->set_surface_destroyed_callback(base::BindOnce(
&DestroyFullscreenShellSurface, base::Unretained(&fullscreen_surface)));
surface->Commit();
EXPECT_TRUE(fullscreen_surface.get());
surface.reset();
EXPECT_FALSE(fullscreen_surface.get());
}
TEST_F(FullscreenShellSurfaceTest, CloseCallback) {
gfx::Size buffer_size(64, 64);
std::unique_ptr<Buffer> buffer(new Buffer(
CreateGpuMemoryBuffer(buffer_size, gfx::BufferFormat::RGBA_8888)));
std::unique_ptr<Surface> surface(new Surface);
std::unique_ptr<FullscreenShellSurface> fullscreen_surface(
new FullscreenShellSurface(surface.get()));
int close_call_count = 0;
fullscreen_surface->set_close_callback(
base::Bind(&Close, base::Unretained(&close_call_count)));
surface->Attach(buffer.get());
surface->Commit();
EXPECT_EQ(0, close_call_count);
fullscreen_surface->Close();
EXPECT_EQ(1, close_call_count);
}
TEST_F(FullscreenShellSurfaceTest, ShouldShowWindowTitle) {
std::unique_ptr<Surface> surface(new Surface);
std::unique_ptr<FullscreenShellSurface> fullscreen_surface(
new FullscreenShellSurface(surface.get()));
EXPECT_FALSE(fullscreen_surface->ShouldShowWindowTitle());
}
TEST_F(FullscreenShellSurfaceTest, SetApplicationId) {
gfx::Size buffer_size(64, 64);
std::unique_ptr<Buffer> buffer(new Buffer(
CreateGpuMemoryBuffer(buffer_size, gfx::BufferFormat::RGBA_8888)));
std::unique_ptr<Surface> surface(new Surface);
std::unique_ptr<FullscreenShellSurface> fullscreen_surface(
new FullscreenShellSurface(surface.get()));
EXPECT_TRUE(fullscreen_surface->GetWidget());
fullscreen_surface->SetApplicationId("test-id");
surface->Attach(buffer.get());
surface->Commit();
aura::Window* window = fullscreen_surface->GetWidget()->GetNativeWindow();
EXPECT_EQ("test-id", *FullscreenShellSurface::GetApplicationId(window));
fullscreen_surface->SetApplicationId("test");
EXPECT_EQ("test", *FullscreenShellSurface::GetApplicationId(window));
fullscreen_surface->SetApplicationId(nullptr);
EXPECT_EQ(nullptr, FullscreenShellSurface::GetApplicationId(window));
}
TEST_F(FullscreenShellSurfaceTest, SetStartupId) {
gfx::Size buffer_size(64, 64);
std::unique_ptr<Buffer> buffer(new Buffer(
CreateGpuMemoryBuffer(buffer_size, gfx::BufferFormat::RGBA_8888)));
std::unique_ptr<Surface> surface(new Surface);
std::unique_ptr<FullscreenShellSurface> fullscreen_surface(
new FullscreenShellSurface(surface.get()));
EXPECT_TRUE(fullscreen_surface->GetWidget());
fullscreen_surface->SetStartupId("test-id");
surface->Attach(buffer.get());
surface->Commit();
aura::Window* window = fullscreen_surface->GetWidget()->GetNativeWindow();
EXPECT_EQ("test-id", *FullscreenShellSurface::GetStartupId(window));
fullscreen_surface->SetStartupId("test");
EXPECT_EQ("test", *FullscreenShellSurface::GetStartupId(window));
fullscreen_surface->SetStartupId(nullptr);
EXPECT_EQ(nullptr, FullscreenShellSurface::GetStartupId(window));
}
TEST_F(FullscreenShellSurfaceTest, Maximize) {
gfx::Size buffer_size(64, 64);
std::unique_ptr<Buffer> buffer(new Buffer(
CreateGpuMemoryBuffer(buffer_size, gfx::BufferFormat::RGBA_8888)));
std::unique_ptr<Surface> surface(new Surface);
std::unique_ptr<FullscreenShellSurface> fullscreen_surface(
new FullscreenShellSurface(surface.get()));
surface->Attach(buffer.get());
surface->Commit();
fullscreen_surface->Maximize();
EXPECT_TRUE(fullscreen_surface->GetWidget()->IsMaximized());
}
TEST_F(FullscreenShellSurfaceTest, Minimize) {
gfx::Size buffer_size(64, 64);
std::unique_ptr<Buffer> buffer(new Buffer(
CreateGpuMemoryBuffer(buffer_size, gfx::BufferFormat::RGBA_8888)));
std::unique_ptr<Surface> surface(new Surface);
std::unique_ptr<FullscreenShellSurface> fullscreen_surface(
new FullscreenShellSurface(surface.get()));
surface->Attach(buffer.get());
surface->Commit();
fullscreen_surface->Minimize();
EXPECT_TRUE(fullscreen_surface->GetWidget()->IsMinimized());
}
} // namespace
} // namespace exo
// Copyright 2018 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 "components/exo/test/exo_test_base_cast.h"
#include "components/exo/wm_helper.h"
#include "ui/base/ime/input_method_factory.h"
#include "ui/compositor/test/context_factories_for_test.h"
#include "ui/display/manager/managed_display_info.h"
#include "ui/wm/core/default_activation_client.h"
#include "ui/wm/core/wm_core_switches.h"
namespace exo {
namespace test {
namespace {
class WMHelperTester : public WMHelper {
public:
WMHelperTester(aura::Env* env, aura::Window* root_window)
: env_(env), root_window_(root_window) {}
~WMHelperTester() override {}
// Overridden from WMHelper
aura::Env* env() override { return env_; }
void AddActivationObserver(wm::ActivationChangeObserver* observer) override {}
void RemoveActivationObserver(
wm::ActivationChangeObserver* observer) override {}
void AddFocusObserver(aura::client::FocusChangeObserver* observer) override {}
void RemoveFocusObserver(
aura::client::FocusChangeObserver* observer) override {}
void AddDragDropObserver(DragDropObserver* observer) override {}
void RemoveDragDropObserver(DragDropObserver* observer) override {}
void SetDragDropDelegate(aura::Window*) override {}
void ResetDragDropDelegate(aura::Window*) override {}
void AddVSyncObserver(
ui::CompositorVSyncManager::Observer* observer) override {}
void RemoveVSyncObserver(
ui::CompositorVSyncManager::Observer* observer) override {}
const display::ManagedDisplayInfo& GetDisplayInfo(
int64_t display_id) const override {
static display::ManagedDisplayInfo md;
return md;
}
const std::vector<uint8_t>& GetDisplayIdentificationData(
int64_t display_id) const override {
static std::vector<uint8_t> no_data;
return no_data;
}
aura::Window* GetPrimaryDisplayContainer(int container_id) override {
return root_window_;
}
aura::Window* GetActiveWindow() const override { return nullptr; }
aura::Window* GetFocusedWindow() const override { return nullptr; }
aura::Window* GetRootWindowForNewWindows() const override {
return root_window_;
}
aura::client::CursorClient* GetCursorClient() override { return nullptr; }
void AddPreTargetHandler(ui::EventHandler* handler) override {}
void PrependPreTargetHandler(ui::EventHandler* handler) override {}
void RemovePreTargetHandler(ui::EventHandler* handler) override {}
void AddPostTargetHandler(ui::EventHandler* handler) override {}
void RemovePostTargetHandler(ui::EventHandler* handler) override {}
bool IsTabletModeWindowManagerEnabled() const override { return false; }
double GetDefaultDeviceScaleFactor() const override { return 1.0; }
// Overridden from aura::client::DragDropDelegate:
void OnDragEntered(const ui::DropTargetEvent& event) override {}
int OnDragUpdated(const ui::DropTargetEvent& event) override { return 0; }
void OnDragExited() override {}
int OnPerformDrop(const ui::DropTargetEvent& event) override { return 0; }
private:
aura::Env* const env_;
aura::Window* root_window_;
DISALLOW_COPY_AND_ASSIGN(WMHelperTester);
};
} // namespace
ExoTestBaseCast::ExoTestBaseCast() {}
ExoTestBaseCast::~ExoTestBaseCast() {}
void ExoTestBaseCast::SetUp() {
aura::test::AuraTestBase::SetUp();
// Takes care of its own lifetime.
new wm::DefaultActivationClient(root_window());
wm_helper_ =
std::make_unique<WMHelperTester>(aura::Env::GetInstance(), root_window());
WMHelper::SetInstance(wm_helper_.get());
}
void ExoTestBaseCast::TearDown() {
WMHelper::SetInstance(nullptr);
wm_helper_.reset();
aura::test::AuraTestBase::TearDown();
}
} // namespace test
} // namespace exo
// Copyright 2018 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 COMPONENTS_EXO_TEST_EXO_TEST_BASE_CAST_H_
#define COMPONENTS_EXO_TEST_EXO_TEST_BASE_CAST_H_
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/test/aura_test_base.h"
namespace exo {
class WMHelper;
namespace test {
// Basic implementation of ExoTestBase without
// ash dependencies
class ExoTestBaseCast : public aura::test::AuraTestBase {
public:
ExoTestBaseCast();
~ExoTestBaseCast() override;
// Overridden from test::Test.
void SetUp() override;
void TearDown() override;
private:
std::unique_ptr<WMHelper> wm_helper_;
};
} // namespace test
} // namespace exo
#endif // COMPONENTS_EXO_TEST_EXO_TEST_BASE_CAST_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment