Commit 70b40e51 authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

Get rid of status_area_widget_test_api.test-mojom

This CL removes status_area_widget_test_api.test-mojom and related mojo
code since ash lives in the browser process, not a separate process and
it is the remains of previous efforts to run ash in a separate process.

It moves TapSelectToSpeakTray from StatusAreaWidgetTestApi to
SystemTrayTestApi and removes StatusAreaWidgetTestApi.

Bug: 955171
Change-Id: I1f4ffeda30102de64a988708963c6515b5d0d52c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1933681Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Julie Kim <jkim@igalia.com>
Cr-Commit-Position: refs/heads/master@{#721309}
parent b3282bbc
......@@ -1604,7 +1604,6 @@ static_library("ash_shell_lib_with_content") {
"//ash/components/shortcut_viewer",
"//ash/public/cpp",
"//ash/public/cpp:manifest",
"//ash/public/cpp:manifest_for_tests",
"//base:i18n",
"//chrome:packed_resources",
......@@ -2033,7 +2032,6 @@ test("ash_unittests") {
"//ash/keyboard/ui:test_support",
"//ash/public/cpp",
"//ash/public/cpp:manifest",
"//ash/public/cpp:manifest_for_tests",
"//ash/public/cpp:test_support",
"//ash/public/cpp:unit_tests",
"//ash/public/cpp/vector_icons",
......@@ -2275,8 +2273,6 @@ static_library("test_support") {
"metrics/task_switch_time_tracker_test_api.h",
"metrics/user_metrics_recorder_test_api.cc",
"metrics/user_metrics_recorder_test_api.h",
"mojo_test_interface_factory.cc",
"mojo_test_interface_factory.h",
"public/cpp/shelf_test_api.cc",
"public/cpp/test/shell_test_api.h",
"rotator/screen_rotation_animator_test_api.cc",
......@@ -2310,8 +2306,6 @@ static_library("test_support") {
"system/power/power_button_test_base.h",
"system/power/power_event_observer_test_api.cc",
"system/power/power_event_observer_test_api.h",
"system/status_area_widget_test_api.cc",
"system/status_area_widget_test_api.h",
"system/status_area_widget_test_helper.cc",
"system/status_area_widget_test_helper.h",
"system/unified/unified_system_tray_test_api.cc",
......@@ -2383,7 +2377,6 @@ static_library("test_support") {
"//ash/components/fast_ink",
"//ash/public/cpp",
"//ash/public/cpp:test_support",
"//ash/public/mojom:test_interfaces",
"//base",
"//base:i18n",
"//base/test:test_support",
......
// Copyright 2017 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 "ash/mojo_test_interface_factory.h"
#include <utility>
#include "ash/public/mojom/status_area_widget_test_api.test-mojom.h"
#include "ash/system/status_area_widget_test_api.h"
#include "base/bind.h"
#include "base/single_thread_task_runner.h"
namespace ash {
namespace mojo_test_interface_factory {
namespace {
// These functions aren't strictly necessary, but exist to make threading and
// arguments clearer.
void BindStatusAreaWidgetTestApiOnMainThread(
mojom::StatusAreaWidgetTestApiRequest request) {
StatusAreaWidgetTestApi::BindRequest(std::move(request));
}
} // namespace
void RegisterInterfaces(
service_manager::BinderRegistry* registry,
scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner) {
registry->AddInterface(
base::BindRepeating(&BindStatusAreaWidgetTestApiOnMainThread),
main_thread_task_runner);
}
} // namespace mojo_test_interface_factory
} // namespace ash
// Copyright 2017 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 ASH_MOJO_TEST_INTERFACE_FACTORY_H_
#define ASH_MOJO_TEST_INTERFACE_FACTORY_H_
#include "ash/ash_export.h"
#include "base/memory/ref_counted.h"
#include "services/service_manager/public/cpp/binder_registry.h"
namespace base {
class SingleThreadTaskRunner;
}
namespace ash {
namespace mojo_test_interface_factory {
// Registers all mojo test interfaces provided by ash. May be called on IO
// thread (when running ash in-process in chrome) or on the main thread (when
// running in mash).
ASH_EXPORT void RegisterInterfaces(
service_manager::BinderRegistry* registry,
scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner);
} // namespace mojo_test_interface_factory
} // namespace ash
#endif // ASH_MOJO_TEST_INTERFACE_FACTORY_H_
......@@ -282,23 +282,6 @@ source_set("manifest") {
]
}
source_set("manifest_for_tests") {
testonly = true
sources = [
"test_manifest.cc",
"test_manifest.h",
]
deps = [
":manifest",
"//ash/public/mojom:test_interfaces",
"//base",
"//services/service_manager/public/cpp",
"//services/service_manager/public/mojom",
]
}
source_set("unit_tests") {
testonly = true
sources = [
......
......@@ -50,6 +50,9 @@ class ASH_EXPORT SystemTrayTestApi {
// Returns true if the clock is using 24 hour time.
virtual bool Is24HourClock() = 0;
// Taps on the Select-to-Speak tray.
virtual void TapSelectToSpeakTray() = 0;
protected:
SystemTrayTestApi() {}
};
......
// Copyright 2019 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 "ash/public/cpp/test_manifest.h"
#include "ash/public/mojom/status_area_widget_test_api.test-mojom.h"
#include "base/no_destructor.h"
#include "services/service_manager/public/cpp/manifest_builder.h"
namespace ash {
const service_manager::Manifest& GetManifestOverlayForTesting() {
static base::NoDestructor<service_manager::Manifest> manifest{
service_manager::ManifestBuilder()
.ExposeCapability("test", service_manager::Manifest::InterfaceList<
mojom::StatusAreaWidgetTestApi>())
.Build()};
return *manifest;
}
} // namespace ash
// Copyright 2019 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 ASH_PUBLIC_CPP_TEST_MANIFEST_H_
#define ASH_PUBLIC_CPP_TEST_MANIFEST_H_
#include "services/service_manager/public/cpp/manifest.h"
namespace ash {
// A manifest for the ash service with additional capabilities exposed for
// testing APIs. This can be amended to the normal manifest by passing it to
// ash::AmendManifestForTesting (in manifest.h) in a test environment before
// initializing the Service Manager, or by explicitly a mending a copy of the
// normal manifest (in e.g. unit tests using TestServiceManager).
const service_manager::Manifest& GetManifestOverlayForTesting();
} // namespace ash
#endif // ASH_PUBLIC_CPP_MANIFEST_H_
......@@ -41,17 +41,3 @@ mojom("mojom") {
export_define = "ASH_PUBLIC_IMPLEMENTATION=1"
export_header = "ash/public/cpp/ash_public_export.h"
}
mojom("test_interfaces") {
testonly = true
disable_variants = true
sources = [
"status_area_widget_test_api.test-mojom",
]
deps = [
":mojom",
"//components/account_id/mojom",
"//mojo/public/mojom/base",
"//ui/gfx/geometry/mojom",
]
}
// 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.
module ash.mojom;
import "mojo/public/mojom/base/string16.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
// All methods operate on the status area tray on the primary display.
interface StatusAreaWidgetTestApi {
// Taps on the Select-to-Speak tray and then runs the callback.
TapSelectToSpeakTray() => ();
};
\ No newline at end of file
......@@ -120,10 +120,11 @@ class ASH_EXPORT StatusAreaWidget : public views::Widget,
}
CollapseState collapse_state() const { return collapse_state_; }
void set_collapse_state_for_test(CollapseState state) {
collapse_state_ = state;
}
private:
friend class StatusAreaWidgetTestApi;
// views::Widget:
void OnMouseEvent(ui::MouseEvent* event) override;
void OnGestureEvent(ui::GestureEvent* event) override;
......
// 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 "ash/system/status_area_widget_test_api.h"
#include "ash/root_window_controller.h"
#include "ash/shell.h"
#include "ash/system/accessibility/select_to_speak_tray.h"
#include "base/run_loop.h"
#include "base/strings/string16.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "ui/events/event.h"
#include "ui/events/event_constants.h"
#include "ui/gfx/geometry/point.h"
#include "ui/views/controls/label.h"
#include "ui/views/view.h"
namespace ash {
StatusAreaWidgetTestApi::StatusAreaWidgetTestApi(StatusAreaWidget* widget)
: widget_(widget) {}
StatusAreaWidgetTestApi::~StatusAreaWidgetTestApi() = default;
// static
void StatusAreaWidgetTestApi::BindRequest(
mojom::StatusAreaWidgetTestApiRequest request) {
StatusAreaWidget* widget =
Shell::Get()->GetPrimaryRootWindowController()->GetStatusAreaWidget();
mojo::MakeStrongBinding(std::make_unique<StatusAreaWidgetTestApi>(widget),
std::move(request));
}
void StatusAreaWidgetTestApi::TapSelectToSpeakTray(
TapSelectToSpeakTrayCallback callback) {
// The Select-to-Speak tray doesn't actually use the event, so construct
// a bare bones event to perform the action.
ui::TouchEvent event(
ui::ET_TOUCH_PRESSED, gfx::Point(), base::TimeTicks::Now(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH), 0);
widget_->select_to_speak_tray_->PerformAction(event);
std::move(callback).Run();
}
void StatusAreaWidgetTestApi::SetCollapseState(
StatusAreaWidget::CollapseState collapse_state) {
widget_->collapse_state_ = collapse_state;
}
} // namespace ash
// 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 ASH_SYSTEM_STATUS_AREA_WIDGET_TEST_API_H_
#define ASH_SYSTEM_STATUS_AREA_WIDGET_TEST_API_H_
#include <memory>
#include "ash/public/mojom/status_area_widget_test_api.test-mojom.h"
#include "ash/system/status_area_widget.h"
#include "base/macros.h"
namespace ash {
class StatusAreaWidgetTestApi : public mojom::StatusAreaWidgetTestApi {
public:
explicit StatusAreaWidgetTestApi(StatusAreaWidget* widget);
~StatusAreaWidgetTestApi() override;
// Creates and binds an instance from a remote request (e.g. from chrome).
static void BindRequest(mojom::StatusAreaWidgetTestApiRequest request);
// mojom::StatusAreaWidgetTestApi:
void TapSelectToSpeakTray(TapSelectToSpeakTrayCallback callback) override;
void SetCollapseState(StatusAreaWidget::CollapseState collapse_state);
private:
StatusAreaWidget* const widget_;
DISALLOW_COPY_AND_ASSIGN(StatusAreaWidgetTestApi);
};
} // namespace ash
#endif // ASH_SYSTEM_STATUS_AREA_WIDGET_TEST_API_H_
......@@ -22,7 +22,6 @@
#include "ash/system/overview/overview_button_tray.h"
#include "ash/system/palette/palette_tray.h"
#include "ash/system/session/logout_button_tray.h"
#include "ash/system/status_area_widget_test_api.h"
#include "ash/system/status_area_widget_test_helper.h"
#include "ash/system/tray/status_area_overflow_button_tray.h"
#include "ash/system/tray/system_tray_notifier.h"
......@@ -383,8 +382,7 @@ class StatusAreaWidgetCollapseStateTest : public AshTestBase {
}
void SetCollapseState(StatusAreaWidget::CollapseState collapse_state) {
StatusAreaWidgetTestApi test_api(status_area_);
test_api.SetCollapseState(collapse_state);
status_area_->set_collapse_state_for_test(collapse_state);
virtual_keyboard_->UpdateAfterStatusAreaCollapseChange();
ime_menu_->UpdateAfterStatusAreaCollapseChange();
......
......@@ -6,6 +6,7 @@
#include "ash/root_window_controller.h"
#include "ash/shell.h"
#include "ash/system/accessibility/select_to_speak_tray.h"
#include "ash/system/status_area_widget.h"
#include "ash/system/time/time_tray_item_view.h"
#include "ash/system/time/time_view.h"
......@@ -84,6 +85,18 @@ bool UnifiedSystemTrayTestApi::Is24HourClock() {
return type == base::k24HourClock;
}
void UnifiedSystemTrayTestApi::TapSelectToSpeakTray() {
// The Select-to-Speak tray doesn't actually use the event, so construct
// a bare bones event to perform the action.
ui::TouchEvent event(
ui::ET_TOUCH_PRESSED, gfx::Point(), base::TimeTicks::Now(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH), 0);
StatusAreaWidget* status_area_widget =
RootWindowController::ForWindow(tray_->GetWidget()->GetNativeWindow())
->GetStatusAreaWidget();
status_area_widget->select_to_speak_tray()->PerformAction(event);
}
message_center::MessagePopupView*
UnifiedSystemTrayTestApi::GetPopupViewForNotificationID(
const std::string& notification_id) {
......
......@@ -44,6 +44,7 @@ class UnifiedSystemTrayTestApi : public SystemTrayTestApi {
void ClickBubbleView(int view_id) override;
base::string16 GetBubbleViewTooltip(int view_id) override;
bool Is24HourClock() override;
void TapSelectToSpeakTray() override;
message_center::MessagePopupView* GetPopupViewForNotificationID(
const std::string& notification_id);
......
......@@ -16,7 +16,6 @@
#include "ash/display/screen_ash.h"
#include "ash/keyboard/keyboard_controller_impl.h"
#include "ash/keyboard/test_keyboard_ui.h"
#include "ash/mojo_test_interface_factory.h"
#include "ash/public/cpp/ash_prefs.h"
#include "ash/public/cpp/ash_switches.h"
#include "ash/public/cpp/test/test_keyboard_controller_observer.h"
......
......@@ -8,9 +8,8 @@
#include "ash/accessibility/accessibility_focus_ring_controller_impl.h"
#include "ash/accessibility/accessibility_focus_ring_layer.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/system_tray_test_api.h"
#include "ash/public/mojom/constants.mojom.h"
#include "ash/public/mojom/status_area_widget_test_api.test-mojom-test-utils.h"
#include "ash/public/mojom/status_area_widget_test_api.test-mojom.h"
#include "ash/root_window_controller.h"
#include "ash/shell.h"
#include "ash/system/status_area_widget.h"
......@@ -62,10 +61,7 @@ class SelectToSpeakTest : public InProcessBrowserTest {
void SetUpOnMainThread() override {
ASSERT_FALSE(AccessibilityManager::Get()->IsSelectToSpeakEnabled());
// Connect to the ash test interface for the StatusAreaWidget.
content::GetSystemConnector()->BindInterface(ash::mojom::kServiceName,
&status_area_widget_test_api_);
tray_test_api_ = ash::SystemTrayTestApi::Create();
content::WindowedNotificationObserver extension_load_waiter(
extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD,
content::NotificationService::AllSources());
......@@ -113,10 +109,8 @@ class SelectToSpeakTest : public InProcessBrowserTest {
}
void TapSelectToSpeakTray() {
ash::mojom::StatusAreaWidgetTestApiAsyncWaiter status_area(
status_area_widget_test_api_.get());
PrepareToWaitForSelectToSpeakStatusChanged();
status_area.TapSelectToSpeakTray();
tray_test_api_->TapSelectToSpeakTray();
WaitForSelectToSpeakStatusChanged();
}
......@@ -151,7 +145,7 @@ class SelectToSpeakTest : public InProcessBrowserTest {
}
private:
ash::mojom::StatusAreaWidgetTestApiPtr status_area_widget_test_api_;
std::unique_ptr<ash::SystemTrayTestApi> tray_test_api_;
scoped_refptr<content::MessageLoopRunner> loop_runner_;
scoped_refptr<content::MessageLoopRunner> tray_loop_runner_;
base::WeakPtrFactory<SelectToSpeakTest> weak_ptr_factory_{this};
......
......@@ -324,7 +324,6 @@ static_library("test_support") {
"//ash",
"//ash:test_support",
"//ash/public/cpp:manifest",
"//ash/public/cpp:manifest_for_tests",
"//components/ownership",
"//components/user_manager:test_support",
"//ui/aura",
......@@ -1446,7 +1445,6 @@ if (!is_android) {
deps += [
"//ash:test_support",
"//ash/keyboard/ui:test_support",
"//ash/public/mojom:test_interfaces",
"//chrome/browser/chromeos:arc_test_support",
"//chrome/browser/chromeos:test_support",
"//chrome/browser/media/router:test_support",
......
......@@ -46,14 +46,6 @@
#include "ui/base/test/ui_controls_aura.h"
#endif
#if defined(OS_CHROMEOS)
#include "ash/mojo_interface_factory.h"
#include "ash/mojo_test_interface_factory.h"
#include "ash/public/cpp/manifest.h"
#include "ash/public/cpp/test_manifest.h"
#include "ash/test/ui_controls_factory_ash.h"
#endif
#if defined(OS_LINUX) || defined(OS_ANDROID)
#include "chrome/app/chrome_crash_reporter_client.h"
#endif
......@@ -243,14 +235,6 @@ int LaunchChromeTests(size_t parallel_jobs,
network_service_test_helper.get()));
}
#if defined(OS_CHROMEOS)
// Inject the test interfaces for ash. Use a callback to avoid linking test
// interface support into production code.
ash::AmendManifestForTesting(ash::GetManifestOverlayForTesting());
ash::mojo_interface_factory::SetRegisterInterfacesCallback(
base::Bind(&ash::mojo_test_interface_factory::RegisterInterfaces));
#endif
#if defined(OS_WIN) || defined(OS_MACOSX) || \
(defined(OS_LINUX) && !defined(OS_CHROMEOS))
// Cause a test failure for any test that triggers an unexpected relaunch.
......
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