Commit f3bc4512 authored by Sadrul Habib Chowdhury's avatar Sadrul Habib Chowdhury Committed by Commit Bot

mus/ash: Notify the client about AcceleratedWidget in tests.

Send the AcceleratedWidget to the client on init, so that the
compositor can be correctly initialized.

BUG=786453

Change-Id: Iad74feb8d669abf2470702fad890f33c2fe11f91
Reviewed-on: https://chromium-review.googlesource.com/810210
Commit-Queue: Sadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522027}
parent 579cef05
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include "ui/base/material_design/material_design_controller.h" #include "ui/base/material_design/material_design_controller.h"
#include "ui/base/platform_window_defaults.h" #include "ui/base/platform_window_defaults.h"
#include "ui/base/test/material_design_controller_test_api.h" #include "ui/base/test/material_design_controller_test_api.h"
#include "ui/base/ui_base_switches_util.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h" #include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/compositor/test/context_factories_for_test.h" #include "ui/compositor/test/context_factories_for_test.h"
#include "ui/display/display.h" #include "ui/display/display.h"
...@@ -286,6 +287,8 @@ void AshTestHelper::CreateMashWindowManager() { ...@@ -286,6 +287,8 @@ void AshTestHelper::CreateMashWindowManager() {
window_tree_client_private_ = window_tree_client_private_ =
std::make_unique<aura::WindowTreeClientPrivate>(window_tree_client); std::make_unique<aura::WindowTreeClientPrivate>(window_tree_client);
window_tree_client_private_->CallOnConnect(); window_tree_client_private_->CallOnConnect();
if (!::switches::IsMusHostingViz())
window_tree_client_setup_.NotifyClientAboutAcceleratedWidget();
} }
void AshTestHelper::CreateShell() { void AshTestHelper::CreateShell() {
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "ui/aura/test/mus/test_window_tree.h" #include "ui/aura/test/mus/test_window_tree.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace aura { namespace aura {
...@@ -37,6 +38,20 @@ TestWindowTree::GetLastNewWindowProperties() { ...@@ -37,6 +38,20 @@ TestWindowTree::GetLastNewWindowProperties() {
return std::move(last_new_window_properties_); return std::move(last_new_window_properties_);
} }
void TestWindowTree::NotifyClientAboutAcceleratedWidget() {
// This magic value comes from managed_display_info.cc
const int64_t kSynthesizedDisplayIdStart = 2200000000LL;
#if defined(OS_WIN)
const gfx::AcceleratedWidget kSynthesizedAcceleratedWidget =
reinterpret_cast<gfx::AcceleratedWidget>(1);
#else
const gfx::AcceleratedWidget kSynthesizedAcceleratedWidget =
static_cast<gfx::AcceleratedWidget>(1);
#endif
window_manager_->WmOnAcceleratedWidgetForDisplay(
kSynthesizedDisplayIdStart, kSynthesizedAcceleratedWidget);
}
void TestWindowTree::AckAllChanges() { void TestWindowTree::AckAllChanges() {
while (!changes_.empty()) { while (!changes_.empty()) {
client_->OnChangeCompleted(changes_[0].id, true); client_->OnChangeCompleted(changes_[0].id, true);
......
...@@ -48,6 +48,9 @@ class TestWindowTree : public ui::mojom::WindowTree { ...@@ -48,6 +48,9 @@ class TestWindowTree : public ui::mojom::WindowTree {
~TestWindowTree() override; ~TestWindowTree() override;
void set_client(ui::mojom::WindowTreeClient* client) { client_ = client; } void set_client(ui::mojom::WindowTreeClient* client) { client_ = client; }
void set_window_manager(ui::mojom::WindowManager* window_manager) {
window_manager_ = window_manager;
}
uint32_t window_id() const { return window_id_; } uint32_t window_id() const { return window_id_; }
...@@ -67,6 +70,10 @@ class TestWindowTree : public ui::mojom::WindowTree { ...@@ -67,6 +70,10 @@ class TestWindowTree : public ui::mojom::WindowTree {
size_t number_of_changes() const { return changes_.size(); } size_t number_of_changes() const { return changes_.size(); }
// Notifies the client about the accelerated widget when mus is not hosting
// viz.
void NotifyClientAboutAcceleratedWidget();
// Acks all changes with a value of true. // Acks all changes with a value of true.
void AckAllChanges(); void AckAllChanges();
...@@ -242,6 +249,7 @@ class TestWindowTree : public ui::mojom::WindowTree { ...@@ -242,6 +249,7 @@ class TestWindowTree : public ui::mojom::WindowTree {
std::vector<Change> changes_; std::vector<Change> changes_;
ui::mojom::WindowTreeClient* client_; ui::mojom::WindowTreeClient* client_;
ui::mojom::WindowManager* window_manager_ = nullptr;
base::Optional<std::unordered_map<std::string, std::vector<uint8_t>>> base::Optional<std::unordered_map<std::string, std::vector<uint8_t>>>
last_new_window_properties_; last_new_window_properties_;
......
...@@ -31,6 +31,7 @@ void TestWindowTreeClientSetup::InitForWindowManager( ...@@ -31,6 +31,7 @@ void TestWindowTreeClientSetup::InitForWindowManager(
CommonInit(window_tree_delegate, window_manager_delegate); CommonInit(window_tree_delegate, window_manager_delegate);
WindowTreeClientPrivate window_tree_client_private(window_tree_client_.get()); WindowTreeClientPrivate window_tree_client_private(window_tree_client_.get());
window_tree_client_private.SetTree(window_tree_.get()); window_tree_client_private.SetTree(window_tree_.get());
window_tree_->set_window_manager(window_tree_client_.get());
window_tree_client_private.SetWindowManagerClient( window_tree_client_private.SetWindowManagerClient(
test_window_manager_client_.get()); test_window_manager_client_.get());
} }
...@@ -42,6 +43,10 @@ void TestWindowTreeClientSetup::InitWithoutEmbed( ...@@ -42,6 +43,10 @@ void TestWindowTreeClientSetup::InitWithoutEmbed(
.SetTree(window_tree_.get()); .SetTree(window_tree_.get());
} }
void TestWindowTreeClientSetup::NotifyClientAboutAcceleratedWidget() {
window_tree_->NotifyClientAboutAcceleratedWidget();
}
std::unique_ptr<WindowTreeClient> std::unique_ptr<WindowTreeClient>
TestWindowTreeClientSetup::OwnWindowTreeClient() { TestWindowTreeClientSetup::OwnWindowTreeClient() {
DCHECK(window_tree_client_); DCHECK(window_tree_client_);
......
...@@ -34,6 +34,10 @@ class TestWindowTreeClientSetup { ...@@ -34,6 +34,10 @@ class TestWindowTreeClientSetup {
// The WindowTree that WindowTreeClient talks to. // The WindowTree that WindowTreeClient talks to.
TestWindowTree* window_tree() { return window_tree_.get(); } TestWindowTree* window_tree() { return window_tree_.get(); }
// Notifies the client about the accelerated widget when mus is not hosting
// viz.
void NotifyClientAboutAcceleratedWidget();
// Returns ownership of WindowTreeClient to the caller. // Returns ownership of WindowTreeClient to the caller.
std::unique_ptr<WindowTreeClient> OwnWindowTreeClient(); std::unique_ptr<WindowTreeClient> OwnWindowTreeClient();
......
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