Commit 6374eaa6 authored by Mike Wasserman's avatar Mike Wasserman Committed by Commit Bot

Make views_mus_unittests and views_mus_interactive_ui_tests use ws2

Make test_ws implement ServiceFactory and package the ui service.
Bind a ws2::WindowService instance to requests for the ui service.
Bind test WindowTreeHostFactory requests in WindowService's registry.
Have the test suites use test_ws + ui services instead of test_wm.

Add a TestGpuInterfaceInterfaceProvider with stub binding functions.
(that and an EventInjector registration placeholder prevent crashes)

Move shadow elevation property registration to ws2::WindowService.

Disable some broken mus-only tests, early return if IsMus from some others.
Remove the old ws service_unittests (catalog conflict packaging ui service)

Bug: 855609
Test: Automated, no regressions.
Change-Id: I58f65551c9c0e1c734ed4ac752b5219ecbead0db
Reviewed-on: https://chromium-review.googlesource.com/1138749
Commit-Queue: Michael Wasserman <msw@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576310}
parent f25560d5
......@@ -19,7 +19,6 @@
#include "ui/gfx/color_palette.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/wm/core/shadow_types.h"
DEFINE_EXPORTED_UI_CLASS_PROPERTY_TYPE(ASH_PUBLIC_EXPORT,
ash::mojom::WindowPinType)
......@@ -76,14 +75,6 @@ void RegisterWindowProperties(aura::PropertyConverter* property_converter) {
kRenderTitleAreaProperty,
ui::mojom::WindowManager::kRenderParentTitleArea_Property,
aura::PropertyConverter::CreateAcceptAnyValueCallback());
// This property is already registered by MusClient in Chrome, but not in Ash.
if (!property_converter->IsTransportNameRegistered(
ui::mojom::WindowManager::kShadowElevation_Property)) {
property_converter->RegisterPrimitiveProperty(
::wm::kShadowElevationKey,
ui::mojom::WindowManager::kShadowElevation_Property,
aura::PropertyConverter::CreateAcceptAnyValueCallback());
}
property_converter->RegisterPrimitiveProperty(
kShelfItemTypeKey, ui::mojom::WindowManager::kShelfItemType_Property,
base::BindRepeating(&IsValidShelfItemType));
......
......@@ -55,10 +55,6 @@ service_test("services_unittests") {
if (is_linux && !is_chromeos) {
deps += [ "//services/ui/demo:tests" ]
}
if (use_ozone || (!is_chromeos && !is_mac && !is_ios)) {
deps += [ "//services/ui/ws:tests" ]
}
}
if (is_android) {
......@@ -125,10 +121,6 @@ catalog("services_unittests_catalog") {
if (is_linux && !is_chromeos) {
catalog_deps += [ "//services/ui/demo:tests_catalog" ]
}
if (use_ozone || (!is_chromeos && !is_ios)) {
catalog_deps += [ "//services/ui/ws:tests_catalog" ]
}
}
}
......
......@@ -9,12 +9,15 @@ service("test_ws") {
testonly = true
sources = [
"test_gpu_interface_provider.cc",
"test_gpu_interface_provider.h",
"test_ws.cc",
]
deps = [
"//base",
"//services/service_manager/public/cpp",
"//services/service_manager/public/mojom",
"//services/ui/public/cpp",
"//services/ui/public/interfaces",
"//services/ui/ws2:lib",
......@@ -28,4 +31,5 @@ service("test_ws") {
service_manifest("manifest") {
name = "test_ws"
source = "manifest.json"
packaged_services = [ "//services/ui:manifest" ]
}
......@@ -5,11 +5,8 @@
"interface_provider_specs": {
"service_manager:connector": {
"provides": {
"app": [
"ui.mojom.WindowTreeFactory"
],
"window_tree_host_factory": [
"ui.mojom.WindowTreeHostFactory"
"service_manager:service_factory": [
"service_manager.mojom.ServiceFactory"
]
}
}
......
// 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 "services/ui/test_ws/test_gpu_interface_provider.h"
#include "base/bind.h"
#include "components/discardable_memory/public/interfaces/discardable_shared_memory_manager.mojom.h"
#include "services/service_manager/public/cpp/binder_registry.h"
#include "services/ui/public/interfaces/gpu.mojom.h"
namespace {
// A placeholder to prevent test crashes on unbound requests.
void BindGpuRequest(ui::mojom::GpuRequest request) {
NOTIMPLEMENTED_LOG_ONCE();
}
// A placeholder to prevent test crashes on unbound requests.
void BindDiscardableSharedMemoryManagerRequest(
discardable_memory::mojom::DiscardableSharedMemoryManagerRequest request) {
NOTIMPLEMENTED_LOG_ONCE();
}
} // namespace
namespace ui {
namespace test {
TestGpuInterfaceProvider::TestGpuInterfaceProvider() = default;
TestGpuInterfaceProvider::~TestGpuInterfaceProvider() = default;
void TestGpuInterfaceProvider::RegisterGpuInterfaces(
service_manager::BinderRegistry* registry) {
registry->AddInterface(
base::BindRepeating(&BindDiscardableSharedMemoryManagerRequest));
registry->AddInterface(base::BindRepeating(BindGpuRequest));
}
#if defined(USE_OZONE)
void TestGpuInterfaceProvider::RegisterOzoneGpuInterfaces(
service_manager::BinderRegistry* registry) {}
#endif
} // namespace test
} // namespace ui
// 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 SERVICES_UI_TEST_WS_TEST_GPU_INTERFACE_PROVIDER_H_
#define SERVICES_UI_TEST_WS_TEST_GPU_INTERFACE_PROVIDER_H_
#include "services/ui/ws2/gpu_interface_provider.h"
namespace ui {
namespace test {
// TestGpuInterfaceProvider binds Gpu and DiscardableSharedMemoryManager
// requests with no-op stub functions to avoid test crashes.
class TestGpuInterfaceProvider : public ui::ws2::GpuInterfaceProvider {
public:
TestGpuInterfaceProvider();
~TestGpuInterfaceProvider() override;
// ui::ws2::GpuInterfaceProvider:
void RegisterGpuInterfaces(
service_manager::BinderRegistry* registry) override;
#if defined(USE_OZONE)
void RegisterOzoneGpuInterfaces(
service_manager::BinderRegistry* registry) override;
#endif
private:
DISALLOW_COPY_AND_ASSIGN(TestGpuInterfaceProvider);
};
} // namespace test
} // namespace ui
#endif // SERVICES_UI_TEST_WS_TEST_GPU_INTERFACE_PROVIDER_H_
......@@ -15,8 +15,10 @@
#include "services/service_manager/public/cpp/service.h"
#include "services/service_manager/public/cpp/service_context.h"
#include "services/service_manager/public/cpp/service_runner.h"
#include "services/service_manager/public/mojom/service_factory.mojom.h"
#include "services/ui/public/interfaces/constants.mojom.h"
#include "services/ui/public/interfaces/window_tree_host_factory.mojom.h"
#include "services/ui/ws2/gpu_interface_provider.h"
#include "services/ui/test_ws/test_gpu_interface_provider.h"
#include "services/ui/ws2/window_service.h"
#include "services/ui/ws2/window_service_delegate.h"
#include "services/ui/ws2/window_tree.h"
......@@ -107,13 +109,14 @@ class WindowTreeHostFactory : public mojom::WindowTreeHostFactory {
// WindowTreeHostFactory to service requests for connections to the Window
// Service.
class TestWindowService : public service_manager::Service,
public service_manager::mojom::ServiceFactory,
public ws2::WindowServiceDelegate {
public:
TestWindowService() = default;
~TestWindowService() override {
// Has dependencies upon Screen, which is owned by AuraTestHelper.
window_service_.reset();
// WindowService depends upon Screen, which is owned by AuraTestHelper.
service_context_.reset();
// AuraTestHelper expects TearDown() to be called.
aura_test_helper_->TearDown();
aura_test_helper_.reset();
......@@ -152,14 +155,9 @@ class TestWindowService : public service_manager::Service,
&context_factory_private);
aura_test_helper_ = std::make_unique<aura::test::AuraTestHelper>();
aura_test_helper_->SetUp(context_factory, context_factory_private);
window_service_ = std::make_unique<ws2::WindowService>(
this, nullptr, aura_test_helper_->focus_client());
window_tree_host_factory_ = std::make_unique<WindowTreeHostFactory>(
window_service_.get(), aura_test_helper_->root_window());
registry_.AddInterface<mojom::WindowTreeHostFactory>(
base::BindRepeating(&WindowTreeHostFactory::AddBinding,
base::Unretained(window_tree_host_factory_.get())));
registry_.AddInterface(base::BindRepeating(
&TestWindowService::BindServiceFactory, base::Unretained(this)));
}
void OnBindInterface(const service_manager::BindSourceInfo& source_info,
const std::string& interface_name,
......@@ -167,13 +165,46 @@ class TestWindowService : public service_manager::Service,
registry_.BindInterface(interface_name, std::move(interface_pipe));
}
// service_manager::mojom::ServiceFactory:
void CreateService(
service_manager::mojom::ServiceRequest request,
const std::string& name,
service_manager::mojom::PIDReceiverPtr pid_receiver) override {
DCHECK_EQ(name, ui::mojom::kServiceName);
DCHECK(!ui_service_created_);
ui_service_created_ = true;
auto window_service = std::make_unique<ws2::WindowService>(
this, std::make_unique<TestGpuInterfaceProvider>(),
aura_test_helper_->focus_client());
window_tree_host_factory_ = std::make_unique<WindowTreeHostFactory>(
window_service.get(), aura_test_helper_->root_window());
window_service->registry()->AddInterface(
base::BindRepeating(&WindowTreeHostFactory::AddBinding,
base::Unretained(window_tree_host_factory_.get())));
service_context_ = std::make_unique<service_manager::ServiceContext>(
std::move(window_service), std::move(request));
pid_receiver->SetPID(base::GetCurrentProcId());
}
void BindServiceFactory(
service_manager::mojom::ServiceFactoryRequest request) {
service_factory_bindings_.AddBinding(this, std::move(request));
}
service_manager::BinderRegistry registry_;
mojo::BindingSet<service_manager::mojom::ServiceFactory>
service_factory_bindings_;
// Handles the ServiceRequest. Owns the WindowService instance.
std::unique_ptr<service_manager::ServiceContext> service_context_;
std::unique_ptr<aura::test::AuraTestHelper> aura_test_helper_;
std::unique_ptr<ws2::WindowService> window_service_;
std::unique_ptr<WindowTreeHostFactory> window_tree_host_factory_;
bool started_ = false;
bool ui_service_created_ = false;
DISALLOW_COPY_AND_ASSIGN(TestWindowService);
};
......
......@@ -11,10 +11,7 @@
"requires": {
"*": [ "app" ],
"ui_ws2_service_unittests": [ "ui:window_tree_client" ],
"test_ws": [
"app",
"window_tree_host_factory"
],
"ui": [ "window_tree_host_factory" ],
"viz": [ "viz_host" ]
}
}
......
......@@ -10,6 +10,7 @@
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "services/service_manager/public/cpp/bind_source_info.h"
#include "services/ui/common/switches.h"
#include "services/ui/public/interfaces/event_injector.mojom.h"
#include "services/ui/ws2/gpu_interface_provider.h"
#include "services/ui/ws2/screen_provider.h"
#include "services/ui/ws2/server_window.h"
......@@ -20,10 +21,20 @@
#include "services/ui/ws2/window_tree_factory.h"
#include "ui/aura/env.h"
#include "ui/base/mojo/clipboard_host.h"
#include "ui/wm/core/shadow_types.h"
namespace ui {
namespace ws2 {
namespace {
// A placeholder to prevent test crashes on unbound requests.
void BindEventInjectorRequest(ui::mojom::EventInjectorRequest request) {
NOTIMPLEMENTED_LOG_ONCE();
}
} // namespace
WindowService::WindowService(
WindowServiceDelegate* delegate,
std::unique_ptr<GpuInterfaceProvider> gpu_interface_provider,
......@@ -44,6 +55,13 @@ WindowService::WindowService(
aura::Env::GetInstance()->CreateMouseLocationManager();
input_device_server_.RegisterAsObserver();
// This property should be registered by the PropertyConverter constructor,
// but that would create a dependency cycle between ui/wm and ui/aura.
property_converter_.RegisterPrimitiveProperty(
::wm::kShadowElevationKey,
ui::mojom::WindowManager::kShadowElevation_Property,
aura::PropertyConverter::CreateAcceptAnyValueCallback());
}
WindowService::~WindowService() {
......@@ -141,6 +159,9 @@ void WindowService::OnStart() {
base::BindRepeating(&WindowService::BindWindowTreeFactoryRequest,
base::Unretained(this)));
// Placeholder to prevent test crashes on unbound requests.
registry_.AddInterface(base::BindRepeating(&BindEventInjectorRequest));
// |gpu_interface_provider_| may be null in tests.
if (gpu_interface_provider_) {
gpu_interface_provider_->RegisterGpuInterfaces(&registry_);
......
......@@ -678,7 +678,7 @@ class WindowTreeClientTest2 : public WindowServerServiceTestBase {
mojom::WindowTreeHostFactoryPtr factory;
// TODO: figure out better way to isolate this!
connector()->BindInterface("test_ws", &factory);
connector()->BindInterface("ui", &factory);
mojom::WindowTreeClientPtr tree_client_ptr;
wt_client1_ = std::make_unique<TestWindowTreeClient2>();
......
......@@ -203,7 +203,7 @@ test("views_mus_unittests") {
data_deps = [
":views_mus_tests_catalog_copy",
"//services/ui/ime/test_ime_driver",
"//services/ui/test_wm",
"//services/ui/test_ws",
]
if (is_win) {
......@@ -269,7 +269,7 @@ test("views_mus_interactive_ui_tests") {
data_deps = [
":views_mus_tests_catalog_copy",
"//services/ui/test_wm",
"//services/ui/test_ws",
]
if (is_win) {
......@@ -305,8 +305,7 @@ catalog("views_mus_tests_catalog") {
]
standalone_services = [
"//services/ui:manifest",
"//services/ui/test_wm:manifest",
"//services/ui/test_ws:manifest",
"//services/ui/ime/test_ime_driver:manifest",
]
}
......
......@@ -158,7 +158,8 @@ TEST_F(DesktopWindowTreeHostMusTest, Capture) {
->capture_window());
}
TEST_F(DesktopWindowTreeHostMusTest, Deactivate) {
// TODO(http://crbug.com/864614): Fails flakily in mus with ws2.
TEST_F(DesktopWindowTreeHostMusTest, DISABLED_Deactivate) {
std::unique_ptr<Widget> widget1(CreateWidget());
widget1->Show();
......@@ -281,7 +282,8 @@ TEST_F(DesktopWindowTreeHostMusTest, StackAtTopAlreadyOnTop) {
waiter.Wait();
}
TEST_F(DesktopWindowTreeHostMusTest, StackAbove) {
// TODO(http://crbug.com/864615): Fails consistently in mus with ws2.
TEST_F(DesktopWindowTreeHostMusTest, DISABLED_StackAbove) {
std::unique_ptr<Widget> widget1(CreateWidget(nullptr));
widget1->Show();
......
......@@ -145,7 +145,8 @@ void DragTest_Part1(int64_t display_id,
base::BindOnce(&DragTest_Part2, display_id, quit_closure));
}
TEST_F(DragTestInteractive, DragTest) {
// TODO(http://crbug.com/864616): Hangs indefinitely in mus with ws2.
TEST_F(DragTestInteractive, DISABLED_DragTest) {
Widget* source_widget = CreateTopLevelFramelessPlatformWidget();
View* source_view = new DraggableView;
source_widget->SetContentsView(source_view);
......
......@@ -104,6 +104,7 @@ class ServiceManagerConnection {
params.connector = GetConnector();
params.identity = service_manager_identity_;
params.bind_test_ws_interfaces = true;
params.wtc_config = aura::WindowTreeClient::Config::kMus2;
return std::make_unique<MusClient>(params);
}
......@@ -136,11 +137,7 @@ class ServiceManagerConnection {
service_manager::Identity(
GetTestName(), service_manager::mojom::kRootUserID),
std::move(service), nullptr);
// ui/views/mus requires a WindowManager running, so launch test_wm.
service_manager::Connector* connector = context_->connector();
connector->StartService("test_wm");
service_manager_connector_ = connector->Clone();
service_manager_connector_ = context_->connector()->Clone();
service_manager_identity_ = context_->identity();
wait->Signal();
}
......@@ -150,14 +147,13 @@ class ServiceManagerConnection {
wait->Signal();
}
// Returns the name of the test executable, e.g.
// "views_mus_unittests".
// Returns the name of the test executable, e.g. "views_mus_unittests".
std::string GetTestName() {
base::FilePath executable = base::CommandLine::ForCurrentProcess()
->GetProgram()
.BaseName()
.RemoveExtension();
return std::string("") + executable.MaybeAsASCII();
return executable.MaybeAsASCII();
}
base::Thread thread_;
......@@ -249,9 +245,9 @@ void ViewsMusTestSuite::Initialize() {
// NOTE: this has to be after ViewsTestSuite::Initialize() as
// TestSuite::Initialize() resets kEnableFeatures and the command line.
feature_list_.InitAndEnableFeature(features::kMashDeprecated);
feature_list_.InitAndEnableFeature(features::kMash);
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kEnableFeatures, features::kMashDeprecated.name);
switches::kEnableFeatures, features::kMash.name);
PlatformTestHelper::set_factory(base::Bind(&CreatePlatformTestHelper));
}
......
......@@ -621,6 +621,10 @@ TEST_F(WidgetTestInteractive, DISABLED_GrabUngrab) {
// Tests mouse move outside of the window into the "resize controller" and back
// will still generate an OnMouseEntered and OnMouseExited event..
TEST_F(WidgetTestInteractive, CheckResizeControllerEvents) {
// TODO(http://crbug.com/864787): Crashes flakily in mus with ws2.
if (IsMus())
return;
Widget* toplevel = CreateTopLevelPlatformWidget();
toplevel->SetBounds(gfx::Rect(0, 0, 100, 100));
......@@ -1337,6 +1341,10 @@ TEST_F(WidgetTestInteractive, InactiveWidgetDoesNotGrabActivation) {
// Test that window state is not changed after getting out of full screen.
TEST_F(WidgetTestInteractive, MAYBE_ExitFullscreenRestoreState) {
// TODO(http://crbug.com/864618): Fails flakily in mus with ws2.
if (IsMus())
return;
Widget* toplevel = CreateTopLevelPlatformWidget();
toplevel->Show();
......
......@@ -741,6 +741,10 @@ class WidgetObserverTest : public WidgetTest, public WidgetObserver {
#endif
TEST_F(WidgetObserverTest, MAYBE_ActivationChange) {
// TODO(http://crbug.com/864800): Fails flakily in mus with ws2.
if (IsMus())
return;
WidgetAutoclosePtr toplevel(CreateTopLevelPlatformWidget());
WidgetAutoclosePtr toplevel1(NewWidget());
WidgetAutoclosePtr toplevel2(NewWidget());
......
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