Commit 7aec5f84 authored by Mike Wasserman's avatar Mike Wasserman Committed by Commit Bot

ws: Add property support to WindowServiceClient::NewTopLevelWindow

Call CreateAndParentTopLevelWindow from WindowServiceDelegateImpl.
Get the window type like ui/aura/mus/window_tree_client.cc
Pass PropertyConverter, etc. args to avoid ash::WindowManager.
Check access to possibly null WindowManager[Client], etc. ptrs.

Add a unit test, apply properties to windows in test delegates.

Bug: 837695
Change-Id: I9f474c4b2701efc110b0738ae56fb5334d2fa641
Reviewed-on: https://chromium-review.googlesource.com/1055658
Commit-Queue: Michael Wasserman <msw@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558018}
parent ca6c2430
......@@ -8,9 +8,9 @@
#include "ash/frame/caption_buttons/caption_button_model.h"
#include "ash/frame/header_view.h"
#include "ash/window_manager.h"
#include "ash/wm/property_util.h"
#include "ash/wm/window_state.h"
#include "services/ui/public/interfaces/window_manager_constants.mojom.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/transient_window_client.h"
#include "ui/aura/mus/property_converter.h"
......@@ -93,8 +93,8 @@ DetachedTitleAreaRendererForInternal::~DetachedTitleAreaRendererForInternal() =
DetachedTitleAreaRendererForClient::DetachedTitleAreaRendererForClient(
aura::Window* parent,
std::map<std::string, std::vector<uint8_t>>* properties,
WindowManager* window_manager)
aura::PropertyConverter* property_converter,
std::map<std::string, std::vector<uint8_t>>* properties)
: widget_(new views::Widget) {
std::unique_ptr<views::Widget::InitParams> params =
CreateInitParams("DetachedTitleAreaRendererForClient");
......@@ -104,8 +104,8 @@ DetachedTitleAreaRendererForClient::DetachedTitleAreaRendererForClient(
aura::client::kEmbedType, aura::client::WindowEmbedType::TOP_LEVEL_IN_WM);
aura::SetWindowType(native_widget->GetNativeWindow(),
ui::mojom::WindowType::POPUP);
ApplyProperties(native_widget->GetNativeWindow(),
window_manager->property_converter(), *properties);
ApplyProperties(native_widget->GetNativeWindow(), property_converter,
*properties);
native_widget->GetNativeView()->SetProperty(kDetachedTitleAreaRendererKey,
this);
params->delegate = this;
......
......@@ -15,13 +15,12 @@
#include "ui/views/widget/widget_delegate.h"
namespace aura {
class PropertyConverter;
class Window;
}
namespace ash {
class WindowManager;
// This class is used to support immersive fullscreen mode.
//
// Immersive fullscreen is a specialized fullscreen mode. In it the user can
......@@ -77,8 +76,8 @@ class DetachedTitleAreaRendererForClient : public views::WidgetDelegate {
public:
DetachedTitleAreaRendererForClient(
aura::Window* parent,
std::map<std::string, std::vector<uint8_t>>* properties,
WindowManager* window_manager);
aura::PropertyConverter* property_converter,
std::map<std::string, std::vector<uint8_t>>* properties);
static DetachedTitleAreaRendererForClient* ForWindow(aura::Window* window);
......
......@@ -281,7 +281,8 @@ std::unique_ptr<aura::Window> AshTestBase::CreateTestWindow(
WindowManager* window_manager =
ash_test_helper_->window_manager_service()->window_manager();
aura::Window* window = CreateAndParentTopLevelWindow(
window_manager, mus_window_type, &properties);
window_manager, mus_window_type, window_manager->property_converter(),
&properties);
window->set_id(shell_window_id);
window->Show();
return base::WrapUnique<aura::Window>(window);
......
......@@ -364,7 +364,8 @@ aura::Window* WindowManager::OnWmCreateTopLevelWindow(
return nullptr;
}
return CreateAndParentTopLevelWindow(this, window_type, properties);
return CreateAndParentTopLevelWindow(this, window_type,
property_converter_.get(), properties);
}
void WindowManager::OnWmClientJankinessChanged(
......
......@@ -116,7 +116,9 @@ WorkspaceEventHandlerMash* MoveEventHandler::GetWorkspaceEventHandlerMash() {
void MoveEventHandler::OnMouseEvent(ui::MouseEvent* event) {
toplevel_window_event_handler_.OnMouseEvent(event, window_);
// TODO(crbug.com/842295): Add support for window-service as a library.
if (!toplevel_window_event_handler_.is_drag_in_progress() &&
window_manager_client_ &&
(event->type() == ui::ET_POINTER_MOVED ||
event->type() == ui::ET_MOUSE_MOVED)) {
const int hit_test_location =
......
......@@ -16,7 +16,6 @@
#include "ash/public/cpp/ash_constants.h"
#include "ash/public/cpp/immersive/immersive_fullscreen_controller_delegate.h"
#include "ash/public/cpp/window_properties.h"
#include "ash/window_manager.h"
#include "ash/wm/move_event_handler.h"
#include "ash/wm/panels/panel_frame_view.h"
#include "ash/wm/property_util.h"
......@@ -262,8 +261,11 @@ class ClientViewMus : public views::ClientView {
// views::ClientView:
bool CanClose() override {
if (!frame_controller_->window())
// TODO(crbug.com/842298): Add support for window-service as a library.
if (!frame_controller_->window() ||
!frame_controller_->window_manager_client()) {
return true;
}
frame_controller_->window_manager_client()->RequestClose(
frame_controller_->window());
......@@ -283,9 +285,10 @@ NonClientFrameController::NonClientFrameController(
aura::Window* context,
const gfx::Rect& bounds,
ui::mojom::WindowType window_type,
aura::PropertyConverter* property_converter,
std::map<std::string, std::vector<uint8_t>>* properties,
WindowManager* window_manager)
: window_manager_client_(window_manager->window_manager_client()),
aura::WindowManagerClient* window_manager_client)
: window_manager_client_(window_manager_client),
widget_(new views::Widget),
window_(nullptr) {
// To simplify things this code creates a Widget. While a Widget is created
......@@ -318,8 +321,6 @@ NonClientFrameController::NonClientFrameController(
window_->AddObserver(this);
params.native_widget = native_widget;
aura::SetWindowType(window_, window_type);
aura::PropertyConverter* property_converter =
window_manager->property_converter();
for (auto& property_pair : *properties) {
property_converter->SetPropertyFromTransportValue(
window_, property_pair.first, &property_pair.second);
......
......@@ -21,6 +21,7 @@
#include "ui/views/widget/widget_delegate.h"
namespace aura {
class PropertyConverter;
class Window;
class WindowManagerClient;
} // namespace aura
......@@ -37,8 +38,6 @@ enum class WindowType;
namespace ash {
class WindowManager;
// Provides the non-client frame for mus Windows.
class ASH_EXPORT NonClientFrameController
: public views::WidgetDelegateView,
......@@ -48,15 +47,17 @@ class ASH_EXPORT NonClientFrameController
// Creates a new NonClientFrameController and window to render the non-client
// frame decorations. This deletes itself when |window| is destroyed. |parent|
// is the parent to place the newly created window in, and may be null. If
// |parent| is null |context| is used to determine the parent Window. One of
// |parent| or |context| must be non-null.
// |parent| is null, |context| is used to determine the parent Window. One of
// |parent| or |context| must be non-null. |window_manager_client| may be
// null for now.
NonClientFrameController(
aura::Window* parent,
aura::Window* context,
const gfx::Rect& bounds,
ui::mojom::WindowType window_type,
aura::PropertyConverter* property_converter,
std::map<std::string, std::vector<uint8_t>>* properties,
WindowManager* window_manager);
aura::WindowManagerClient* window_manager_client);
// Returns the NonClientFrameController for the specified window, null if
// one was not created.
......
......@@ -7,6 +7,7 @@
#include "ash/ash_layout_constants.h"
#include "ash/test/ash_test_base.h"
#include "ash/test/ash_test_helper.h"
#include "ash/window_manager.h"
#include "ash/window_manager_service.h"
#include "ash/wm/top_level_window_factory.h"
#include "cc/base/math_util.h"
......@@ -105,9 +106,11 @@ class NonClientFrameControllerTest : public AshTestBase {
TEST_F(NonClientFrameControllerTest, ContentRegionNotDrawnForClient) {
std::map<std::string, std::vector<uint8_t>> properties;
auto* window_manager =
ash_test_helper()->window_manager_service()->window_manager();
std::unique_ptr<aura::Window> window(CreateAndParentTopLevelWindow(
ash_test_helper()->window_manager_service()->window_manager(),
ui::mojom::WindowType::WINDOW, &properties));
window_manager, ui::mojom::WindowType::WINDOW,
window_manager->property_converter(), &properties));
ASSERT_TRUE(window);
NonClientFrameController* controller =
......
......@@ -77,9 +77,9 @@ RootWindowController* GetRootWindowControllerForNewTopLevelWindow(
// Returns the bounds for the new window.
gfx::Rect CalculateDefaultBounds(
WindowManager* window_manager,
RootWindowController* root_window_controller,
aura::Window* container_window,
aura::PropertyConverter* property_converter,
const std::map<std::string, std::vector<uint8_t>>* properties) {
gfx::Rect requested_bounds;
if (GetInitialBounds(*properties, &requested_bounds))
......@@ -90,8 +90,7 @@ gfx::Rect CalculateDefaultBounds(
auto show_state_iter =
properties->find(ui::mojom::WindowManager::kShowState_Property);
if (show_state_iter != properties->end()) {
if (IsFullscreen(window_manager->property_converter(),
show_state_iter->second)) {
if (IsFullscreen(property_converter, show_state_iter->second)) {
gfx::Rect bounds(root_size);
if (!container_window) {
const display::Display display =
......@@ -121,9 +120,10 @@ gfx::Rect CalculateDefaultBounds(
// Does the real work of CreateAndParentTopLevelWindow() once the appropriate
// RootWindowController was found.
aura::Window* CreateAndParentTopLevelWindowInRoot(
WindowManager* window_manager,
aura::WindowManagerClient* window_manager_client,
RootWindowController* root_window_controller,
ui::mojom::WindowType window_type,
aura::PropertyConverter* property_converter,
std::map<std::string, std::vector<uint8_t>>* properties) {
// TODO(sky): constrain and validate properties.
......@@ -138,7 +138,7 @@ aura::Window* CreateAndParentTopLevelWindowInRoot(
}
gfx::Rect bounds = CalculateDefaultBounds(
window_manager, root_window_controller, container_window, properties);
root_window_controller, container_window, property_converter, properties);
const bool provide_non_client_frame =
window_type == ui::mojom::WindowType::WINDOW ||
......@@ -147,13 +147,11 @@ aura::Window* CreateAndParentTopLevelWindowInRoot(
// See NonClientFrameController for details on lifetime.
NonClientFrameController* non_client_frame_controller =
new NonClientFrameController(container_window, context, bounds,
window_type, properties, window_manager);
window_type, property_converter,
properties, window_manager_client);
return non_client_frame_controller->window();
}
aura::PropertyConverter* property_converter =
window_manager->property_converter();
if (window_type == ui::mojom::WindowType::POPUP &&
ShouldRenderTitleArea(property_converter, *properties)) {
// Pick a parent so display information is obtained. Will pick the real one
......@@ -164,7 +162,7 @@ aura::Window* CreateAndParentTopLevelWindowInRoot(
// DetachedTitleAreaRendererForClient is owned by the client.
DetachedTitleAreaRendererForClient* renderer =
new DetachedTitleAreaRendererForClient(unparented_control_container,
properties, window_manager);
property_converter, properties);
return renderer->widget()->GetNativeView();
}
......@@ -197,11 +195,13 @@ aura::Window* CreateAndParentTopLevelWindowInRoot(
aura::Window* CreateAndParentTopLevelWindow(
WindowManager* window_manager,
ui::mojom::WindowType window_type,
aura::PropertyConverter* property_converter,
std::map<std::string, std::vector<uint8_t>>* properties) {
RootWindowController* root_window_controller =
GetRootWindowControllerForNewTopLevelWindow(properties);
aura::Window* window = CreateAndParentTopLevelWindowInRoot(
window_manager, root_window_controller, window_type, properties);
window_manager ? window_manager->window_manager_client() : nullptr,
root_window_controller, window_type, property_converter, properties);
DisconnectedAppHandler::Create(window);
auto ignored_by_shelf_iter = properties->find(
......@@ -218,6 +218,8 @@ aura::Window* CreateAndParentTopLevelWindow(
properties->find(ui::mojom::WindowManager::kFocusable_InitProperty);
if (focusable_iter != properties->end()) {
bool can_focus = mojo::ConvertTo<bool>(focusable_iter->second);
// TODO(crbug.com/842301): Add support for window-service as a library.
if (window_manager)
window_manager->window_tree_client()->SetCanFocus(window, can_focus);
NonClientFrameController* non_client_frame_controller =
NonClientFrameController::Get(window);
......
......@@ -14,6 +14,7 @@
#include "ash/ash_export.h"
namespace aura {
class PropertyConverter;
class Window;
}
......@@ -29,9 +30,11 @@ class WindowManager;
// Creates and parents a new top-level window and returns it. The returned
// aura::Window is owned by its parent.
// TODO(ws): Refine this for the Window Service as-a-library (no WindowManager).
ASH_EXPORT aura::Window* CreateAndParentTopLevelWindow(
WindowManager* window_manager,
ui::mojom::WindowType window_type,
aura::PropertyConverter* property_converter,
std::map<std::string, std::vector<uint8_t>>* properties);
} // namespace ash
......
......@@ -44,7 +44,8 @@ aura::Window* CreateFullscreenTestWindow(WindowManager* window_manager,
mojo::ConvertTo<std::vector<uint8_t>>(display_id);
}
aura::Window* window = CreateAndParentTopLevelWindow(
window_manager, ui::mojom::WindowType::WINDOW, &properties);
window_manager, ui::mojom::WindowType::WINDOW,
window_manager->property_converter(), &properties);
window->Show();
return window;
}
......@@ -84,9 +85,11 @@ using TopLevelWindowFactoryAshTest = AshTestBase;
TEST_F(TopLevelWindowFactoryAshTest, TopLevelNotShownOnCreate) {
std::map<std::string, std::vector<uint8_t>> properties;
auto* window_manager =
ash_test_helper()->window_manager_service()->window_manager();
std::unique_ptr<aura::Window> window(CreateAndParentTopLevelWindow(
ash_test_helper()->window_manager_service()->window_manager(),
ui::mojom::WindowType::WINDOW, &properties));
window_manager, ui::mojom::WindowType::WINDOW,
window_manager->property_converter(), &properties));
ASSERT_TRUE(window);
EXPECT_FALSE(window->IsVisible());
}
......@@ -106,7 +109,8 @@ TEST_F(TopLevelWindowFactoryAshTest, CreateTopLevelWindow) {
ash_test_helper()->window_manager_service()->window_manager();
// |window| is owned by its parent.
aura::Window* window = CreateAndParentTopLevelWindow(
window_manager, ui::mojom::WindowType::WINDOW, &properties);
window_manager, ui::mojom::WindowType::WINDOW,
window_manager->property_converter(), &properties);
ASSERT_TRUE(window->parent());
EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
EXPECT_EQ(bounds, window->bounds());
......
......@@ -5,6 +5,11 @@
#include "ash/ws/window_service_delegate_impl.h"
#include "ash/wm/container_finder.h"
#include "ash/wm/top_level_window_factory.h"
#include "mojo/public/cpp/bindings/map.h"
#include "services/ui/public/cpp/property_type_converters.h"
#include "services/ui/public/interfaces/window_manager.mojom.h"
#include "services/ui/public/interfaces/window_manager_constants.mojom.h"
#include "ui/aura/window.h"
namespace ash {
......@@ -14,15 +19,22 @@ WindowServiceDelegateImpl::WindowServiceDelegateImpl() = default;
WindowServiceDelegateImpl::~WindowServiceDelegateImpl() = default;
std::unique_ptr<aura::Window> WindowServiceDelegateImpl::NewTopLevel(
aura::PropertyConverter* property_converter,
const base::flat_map<std::string, std::vector<uint8_t>>& properties) {
// TODO: this needs to call CreateAndParentTopLevelWindow();
std::unique_ptr<aura::Window> window =
std::make_unique<aura::Window>(nullptr);
window->SetType(aura::client::WINDOW_TYPE_NORMAL);
window->Init(ui::LAYER_NOT_DRAWN);
ash::wm::GetDefaultParent(window.get(), gfx::Rect())->AddChild(window.get());
// TODO(crbug.com/837695): Apply |properties|.
return window;
std::map<std::string, std::vector<uint8_t>> property_map =
mojo::FlatMapToMap(properties);
ui::mojom::WindowType window_type = ui::mojom::WindowType::UNKNOWN;
auto type_iter =
property_map.find(ui::mojom::WindowManager::kWindowType_InitProperty);
if (type_iter != property_map.end()) {
window_type = static_cast<ui::mojom::WindowType>(
mojo::ConvertTo<int32_t>(type_iter->second));
}
auto* window =
CreateAndParentTopLevelWindow(nullptr /* window_manager */, window_type,
property_converter, &property_map);
return base::WrapUnique<aura::Window>(window);
}
} // namespace ash
......@@ -18,6 +18,7 @@ class WindowServiceDelegateImpl : public ui::ws2::WindowServiceDelegate {
// ui::ws2::WindowServiceDelegate:
std::unique_ptr<aura::Window> NewTopLevel(
aura::PropertyConverter* property_converter,
const base::flat_map<std::string, std::vector<uint8_t>>& properties)
override;
......
......@@ -122,11 +122,16 @@ class TestWindowService : public service_manager::Service,
private:
// WindowServiceDelegate:
std::unique_ptr<aura::Window> NewTopLevel(
aura::PropertyConverter* property_converter,
const base::flat_map<std::string, std::vector<uint8_t>>& properties)
override {
std::unique_ptr<aura::Window> top_level =
std::make_unique<aura::Window>(nullptr);
top_level->Init(LAYER_NOT_DRAWN);
for (auto property : properties) {
property_converter->SetPropertyFromTransportValue(
top_level.get(), property.first, &property.second);
}
return top_level;
}
......
......@@ -4,6 +4,7 @@
#include "services/ui/ws2/test_window_service_delegate.h"
#include "ui/aura/mus/property_converter.h"
#include "ui/aura/window.h"
namespace ui {
......@@ -16,12 +17,17 @@ TestWindowServiceDelegate::TestWindowServiceDelegate(
TestWindowServiceDelegate::~TestWindowServiceDelegate() = default;
std::unique_ptr<aura::Window> TestWindowServiceDelegate::NewTopLevel(
aura::PropertyConverter* property_converter,
const base::flat_map<std::string, std::vector<uint8_t>>& properties) {
std::unique_ptr<aura::Window> window =
std::make_unique<aura::Window>(nullptr);
window->Init(LAYER_NOT_DRAWN);
if (top_level_parent_)
top_level_parent_->AddChild(window.get());
for (auto property : properties) {
property_converter->SetPropertyFromTransportValue(
window.get(), property.first, &property.second);
}
return window;
}
......
......@@ -24,6 +24,7 @@ class TestWindowServiceDelegate : public WindowServiceDelegate {
// WindowServiceDelegate:
std::unique_ptr<aura::Window> NewTopLevel(
aura::PropertyConverter* property_converter,
const base::flat_map<std::string, std::vector<uint8_t>>& properties)
override;
......
......@@ -697,7 +697,8 @@ void WindowServiceClient::NewTopLevelWindow(
return;
}
std::unique_ptr<aura::Window> top_level_ptr =
window_service_->delegate()->NewTopLevel(properties);
window_service_->delegate()->NewTopLevel(
window_service_->property_converter(), properties);
if (!top_level_ptr) {
DVLOG(1) << "NewTopLevelWindow failed (delegate window creation failed)";
window_tree_client_->OnChangeCompleted(change_id, false);
......
......@@ -20,8 +20,8 @@ mojom::WindowTree* WindowServiceClientTestHelper::window_tree() {
}
aura::Window* WindowServiceClientTestHelper::NewTopLevelWindow(
Id transport_window_id) {
base::flat_map<std::string, std::vector<uint8_t>> properties;
Id transport_window_id,
base::flat_map<std::string, std::vector<uint8_t>> properties) {
const uint32_t change_id = 1u;
window_service_client_->NewTopLevelWindow(change_id, transport_window_id,
properties);
......
......@@ -5,8 +5,10 @@
#ifndef SERVICES_UI_WS2_WINDOW_SERVICE_CLIENT_TEST_HELPER_H_
#define SERVICES_UI_WS2_WINDOW_SERVICE_CLIENT_TEST_HELPER_H_
#include <string>
#include <vector>
#include "base/containers/flat_map.h"
#include "base/macros.h"
#include "services/ui/ws2/ids.h"
......@@ -39,7 +41,9 @@ class WindowServiceClientTestHelper {
mojom::WindowTree* window_tree();
aura::Window* NewTopLevelWindow(Id transport_window_id);
aura::Window* NewTopLevelWindow(
Id transport_window_id,
base::flat_map<std::string, std::vector<uint8_t>> properties = {});
void SetWindowBounds(aura::Window* window,
const gfx::Rect& bounds,
uint32_t change_id = 1);
......
......@@ -66,13 +66,12 @@ class WindowServiceTestHelper {
aura::Window* root() { return aura_test_helper_.root_window(); }
TestWindowServiceDelegate* delegate() { return &delegate_; }
TestWindowTreeClient* window_tree_client() { return &window_tree_client_; }
WindowServiceClientTestHelper* helper() { return helper_.get(); }
std::vector<Change>* changes() {
return window_tree_client_.tracker()->changes();
}
std::unique_ptr<WindowServiceClientTestHelper> helper_;
private:
base::test::ScopedTaskEnvironment task_environment_{
base::test::ScopedTaskEnvironment::MainThreadType::UI};
......@@ -81,6 +80,7 @@ class WindowServiceTestHelper {
std::unique_ptr<WindowService> service_;
TestWindowTreeClient window_tree_client_;
std::unique_ptr<WindowServiceClient> window_service_client_;
std::unique_ptr<WindowServiceClientTestHelper> helper_;
DISALLOW_COPY_AND_ASSIGN(WindowServiceTestHelper);
};
......@@ -118,20 +118,34 @@ class TestLayoutManager : public aura::LayoutManager {
TEST(WindowServiceClientTest, CreateTopLevel) {
WindowServiceTestHelper helper;
EXPECT_TRUE(helper.changes()->empty());
aura::Window* top_level = helper.helper_->NewTopLevelWindow(1);
aura::Window* top_level = helper.helper()->NewTopLevelWindow(1);
ASSERT_TRUE(top_level);
EXPECT_EQ("TopLevelCreated id=1 window_id=0,1 drawn=false",
SingleChangeToDescription(*helper.changes()));
helper.changes()->clear();
}
TEST(WindowServiceClientTest, CreateTopLevelWithProperties) {
WindowServiceTestHelper helper;
EXPECT_TRUE(helper.changes()->empty());
aura::PropertyConverter::PrimitiveType value = true;
std::vector<uint8_t> transport = mojo::ConvertTo<std::vector<uint8_t>>(value);
aura::Window* top_level = helper.helper()->NewTopLevelWindow(
1, {{ui::mojom::WindowManager::kAlwaysOnTop_Property, transport}});
ASSERT_TRUE(top_level);
EXPECT_EQ("TopLevelCreated id=1 window_id=0,1 drawn=false",
SingleChangeToDescription(*helper.changes()));
EXPECT_TRUE(top_level->GetProperty(aura::client::kAlwaysOnTopKey));
helper.changes()->clear();
}
TEST(WindowServiceClientTest, SetBounds) {
WindowServiceTestHelper helper;
aura::Window* top_level = helper.helper_->NewTopLevelWindow(1);
aura::Window* top_level = helper.helper()->NewTopLevelWindow(1);
helper.changes()->clear();
const gfx::Rect bounds_from_client = gfx::Rect(1, 2, 300, 400);
helper.helper_->SetWindowBounds(top_level, bounds_from_client, 2);
helper.helper()->SetWindowBounds(top_level, bounds_from_client, 2);
EXPECT_EQ(bounds_from_client, top_level->bounds());
EXPECT_EQ("ChangeCompleted id=2 sucess=true",
SingleChangeToDescription(*helper.changes()));
......@@ -151,7 +165,7 @@ TEST(WindowServiceClientTest, SetBounds) {
const gfx::Rect restricted_bounds = gfx::Rect(401, 405, 406, 407);
layout_manager->set_next_bounds(restricted_bounds);
top_level->parent()->SetLayoutManager(layout_manager);
helper.helper_->SetWindowBounds(top_level, bounds_from_client, 3);
helper.helper()->SetWindowBounds(top_level, bounds_from_client, 3);
ASSERT_EQ(2u, helper.changes()->size());
// The layout manager changes the bounds to a different value than the client
// requested, so the client should get OnWindowBoundsChanged() with
......@@ -167,13 +181,13 @@ TEST(WindowServiceClientTest, SetBounds) {
TEST(WindowServiceClientTest, SetProperty) {
WindowServiceTestHelper helper;
aura::Window* top_level = helper.helper_->NewTopLevelWindow(1);
aura::Window* top_level = helper.helper()->NewTopLevelWindow(1);
helper.changes()->clear();
EXPECT_FALSE(top_level->GetProperty(aura::client::kAlwaysOnTopKey));
aura::PropertyConverter::PrimitiveType value = true;
std::vector<uint8_t> transport = mojo::ConvertTo<std::vector<uint8_t>>(value);
helper.helper_->SetWindowProperty(
helper.helper()->SetWindowProperty(
top_level, ui::mojom::WindowManager::kAlwaysOnTop_Property, transport, 2);
EXPECT_EQ("ChangeCompleted id=2 sucess=true",
SingleChangeToDescription(*helper.changes()));
......@@ -184,14 +198,14 @@ TEST(WindowServiceClientTest, SetProperty) {
TEST(WindowServiceClientTest, PointerWatcher) {
WindowServiceTestHelper helper;
TestWindowTreeClient* window_tree_client = helper.window_tree_client();
aura::Window* top_level = helper.helper_->NewTopLevelWindow(1);
aura::Window* top_level = helper.helper()->NewTopLevelWindow(1);
ASSERT_TRUE(top_level);
helper.helper_->SetEventTargetingPolicy(top_level,
helper.helper()->SetEventTargetingPolicy(top_level,
mojom::EventTargetingPolicy::NONE);
EXPECT_EQ(mojom::EventTargetingPolicy::NONE,
top_level->event_targeting_policy());
// Start the pointer watcher only for pointer down/up.
helper.helper_->window_tree()->StartPointerWatcher(false);
helper.helper()->window_tree()->StartPointerWatcher(false);
top_level->Show();
top_level->SetBounds(gfx::Rect(10, 10, 100, 100));
......@@ -222,7 +236,7 @@ TEST(WindowServiceClientTest, PointerWatcher) {
}
// Enable observing move events.
helper.helper_->window_tree()->StartPointerWatcher(true);
helper.helper()->window_tree()->StartPointerWatcher(true);
event_generator.MoveMouseTo(8, 9);
{
ASSERT_EQ(1u, window_tree_client->observed_pointer_events().size());
......
......@@ -15,6 +15,7 @@
#include "base/containers/flat_map.h"
namespace aura {
class PropertyConverter;
class Window;
}
......@@ -28,6 +29,7 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowServiceDelegate {
// new window, parenting it in the appropriate container. Return null to
// reject the request.
virtual std::unique_ptr<aura::Window> NewTopLevel(
aura::PropertyConverter* property_converter,
const base::flat_map<std::string, std::vector<uint8_t>>& properties) = 0;
protected:
......
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