0

[FreezeCast] Update notification strings

This change updates the notification message strings used in the
ChromeOS cast notification, to match the most recent mocks.

Bug: b:282239494
Change-Id: Ia8065d944f4c6e4250e40b051d52e0d2c190e3d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4537688
Commit-Queue: Benjamin Zielinski <bzielinski@google.com>
Reviewed-by: Takumi Fujimoto <takumif@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1145698}
This commit is contained in:
Benjamin Zielinski
2023-05-17 23:34:59 +00:00
committed by Chromium LUCI CQ
parent d71d73df0b
commit c58b6dea0c
9 changed files with 109 additions and 47 deletions

@ -559,10 +559,7 @@ Style notes:
Stop casting screen to <ph name="RECEIVER_NAME">$1<ex>Living Room</ex></ph>
</message>
<message name="IDS_ASH_STATUS_TRAY_CAST_CAST_DESKTOP_NOTIFICATION_MESSAGE" desc="The notification message to tell the user we are casting the desktop.">
You are currently casting screen.
</message>
<message name="IDS_ASH_STATUS_TRAY_CAST_CAST_PAUSED" desc="The notification message to tell the user that casting is paused.">
Casting is paused
You are currently casting your screen.
</message>
<message name="IDS_ASH_STATUS_TRAY_CAST_CAST_TAB" desc="The title label used in the tray popup to tell the user we are casting a tab.">
<ph name="ROUTE_TITLE">$1<ex>YouTube</ex></ph> on <ph name="RECEIVER_NAME">$2<ex>Living Room</ex></ph>
@ -579,6 +576,18 @@ Style notes:
<message name="IDS_ASH_STATUS_TRAY_CAST_DESKTOP" desc="The label used in the tray popup to notify that desktop may be cast.">
Cast devices available
</message>
<message name="IDS_ASH_STATUS_TRAY_CAST_NOTIFICATION_MESSAGE_PAUSED" desc="The notification message to tell the user that casting is paused.">
Casting is currently paused. You can resume casting or stop casting at any time.
</message>
<message name="IDS_ASH_STATUS_TRAY_CAST_NOTIFICATION_MESSAGE_SCREEN_CAN_PAUSE" desc="Notification message to tell the user that we are casting the desktop screen, and that the casting session may be paused.">
You are casting your screen. You can pause or stop casting your screen at any time.
</message>
<message name="IDS_ASH_STATUS_TRAY_CAST_NOTIFICATION_MESSAGE_SCREEN_PAUSED" desc="Notification message to tell the user that we are casting the desktop screen, and that the casting session is currently paused.">
Casting is currently paused. You can resume casting or stop casting your screen at any time.
</message>
<message name="IDS_ASH_STATUS_TRAY_CAST_NOTIFICATION_MESSAGE_TAB_CAN_PAUSE" desc="Notification message to tell the user that we are casting a tab, and that the casting session may be paused.">
You are casting a tab. You can pause or stop casting at any time.
</message>
<message name="IDS_ASH_STATUS_TRAY_CAST_STOP" desc="The label used in the tray popup to stop casting.">
Stop
</message>

@ -0,0 +1 @@
f0190bf661e776bd79d84daf91064adc2317145a

@ -1 +0,0 @@
c3d822add74c1ce4b7d3ccf0046681f80f6a2927

@ -0,0 +1 @@
77ecfe482867dd967df11234df6e2a2394bfb8fd

@ -0,0 +1 @@
5201eef9af754085570250ae1509cff227e90ac0

@ -0,0 +1 @@
f0190bf661e776bd79d84daf91064adc2317145a

@ -0,0 +1 @@
7e01b794e901147bb270195f5c36315ab6561930

@ -51,16 +51,39 @@ std::u16string GetNotificationTitle(const CastSink& sink,
std::u16string GetNotificationMessage(const CastRoute& route) {
if (route.freeze_info.is_frozen) {
return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_CAST_CAST_PAUSED);
}
switch (route.content_source) {
case ContentSource::kUnknown:
return std::u16string();
case ContentSource::kTab:
return base::UTF8ToUTF16(route.title);
case ContentSource::kDesktop:
return l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_CAST_CAST_DESKTOP_NOTIFICATION_MESSAGE);
// Casting is paused.
switch (route.content_source) {
case ContentSource::kUnknown:
case ContentSource::kTab:
return l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_CAST_NOTIFICATION_MESSAGE_PAUSED);
case ContentSource::kDesktop:
return l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_CAST_NOTIFICATION_MESSAGE_SCREEN_PAUSED);
}
} else if (route.freeze_info.can_freeze) {
// Casting is not paused, but it is pausable.
switch (route.content_source) {
case ContentSource::kUnknown:
return std::u16string();
case ContentSource::kTab:
return l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_CAST_NOTIFICATION_MESSAGE_TAB_CAN_PAUSE);
case ContentSource::kDesktop:
return l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_CAST_NOTIFICATION_MESSAGE_SCREEN_CAN_PAUSE);
}
} else {
// The cast session is not pausable.
switch (route.content_source) {
case ContentSource::kUnknown:
return std::u16string();
case ContentSource::kTab:
return base::UTF8ToUTF16(route.title);
case ContentSource::kDesktop:
return l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_CAST_CAST_DESKTOP_NOTIFICATION_MESSAGE);
}
}
}

@ -80,6 +80,8 @@ class CastNotificationControllerTest : public AshTestBase {
void SetUp() override {
AshTestBase::SetUp();
notification_controller_ = std::make_unique<CastNotificationController>();
cast_config_.set_has_sinks_and_routes(true);
cast_config_.set_has_active_route(true);
}
message_center::Notification* GetNotification() {
@ -101,6 +103,9 @@ class CastNotificationControllerTest : public AshTestBase {
};
TEST_F(CastNotificationControllerTest, Notification) {
cast_config_.set_has_sinks_and_routes(false);
cast_config_.set_has_active_route(false);
// There should be no cast notification to start with.
EXPECT_FALSE(GetNotification());
@ -126,8 +131,6 @@ TEST_F(CastNotificationControllerTest, Notification) {
TEST_F(CastNotificationControllerTest, StopCasting) {
// Create notification.
cast_config_.set_has_sinks_and_routes(true);
cast_config_.set_has_active_route(true);
SinkAndRoute device = CreateDeviceLocalRoute();
notification_controller_->OnDevicesUpdated({device});
EXPECT_TRUE(GetNotification()->pinned());
@ -145,8 +148,6 @@ TEST_F(CastNotificationControllerTest, StopCasting) {
TEST_F(CastNotificationControllerTest, FreezeUi) {
// Create notification.
cast_config_.set_has_sinks_and_routes(true);
cast_config_.set_has_active_route(true);
SinkAndRoute device = CreateDeviceLocalRoute();
// Make the device "freezable" so the freeze (pause) button appears.
device.route.freeze_info.can_freeze = true;
@ -189,8 +190,6 @@ TEST_F(CastNotificationControllerTest, FreezeUi) {
TEST_F(CastNotificationControllerTest, FreezeWithTrayOpen) {
// Create notification.
cast_config_.set_has_sinks_and_routes(true);
cast_config_.set_has_active_route(true);
SinkAndRoute device = CreateDeviceLocalRoute();
// Make the device "freezable" so the freeze (pause) button appears.
device.route.freeze_info.can_freeze = true;
@ -211,42 +210,69 @@ TEST_F(CastNotificationControllerTest, FreezeWithTrayOpen) {
EXPECT_EQ(cast_config_.freeze_route_count(), 1u);
}
TEST_F(CastNotificationControllerTest, NotificationMessage) {
cast_config_.set_has_sinks_and_routes(true);
cast_config_.set_has_active_route(true);
// Create notification for a tab casting route.
SinkAndRoute device1 = CreateDeviceLocalRoute();
notification_controller_->OnDevicesUpdated({device1});
TEST_F(CastNotificationControllerTest,
NotificationMessage_CastingTab_CannotPause) {
// Create a tab casting route that cannot be paused.
SinkAndRoute device = CreateDeviceLocalRoute();
notification_controller_->OnDevicesUpdated({device});
EXPECT_EQ(GetNotification()->message(),
base::UTF8ToUTF16(device1.route.title));
// Create notification for a desktop route.
SinkAndRoute device2 = CreateDeviceLocalRouteDesktop();
notification_controller_->OnDevicesUpdated({device2});
base::UTF8ToUTF16(device.route.title));
}
TEST_F(CastNotificationControllerTest,
NotificationMessage_CastingScreen_CannotPause) {
// Create a screen casting route that cannot be paused.
SinkAndRoute device = CreateDeviceLocalRouteDesktop();
notification_controller_->OnDevicesUpdated({device});
std::u16string desktop_casting_message = l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_CAST_CAST_DESKTOP_NOTIFICATION_MESSAGE);
EXPECT_EQ(GetNotification()->message(), desktop_casting_message);
}
TEST_F(CastNotificationControllerTest,
NotificationMessage_CastingTab_CanPause) {
// Create a tab casting route that can be paused.
SinkAndRoute device = CreateDeviceLocalRoute();
device.route.freeze_info.can_freeze = true;
notification_controller_->OnDevicesUpdated({device});
std::u16string tab_casting_can_pause_message = l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_CAST_NOTIFICATION_MESSAGE_TAB_CAN_PAUSE);
EXPECT_EQ(GetNotification()->message(), tab_casting_can_pause_message);
}
TEST_F(CastNotificationControllerTest,
NotificationMessage_CastingScreen_CanPause) {
// Create a screen casting route that can be paused.
SinkAndRoute device = CreateDeviceLocalRouteDesktop();
device.route.freeze_info.can_freeze = true;
notification_controller_->OnDevicesUpdated({device});
std::u16string screen_casting_can_pause_message = l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_CAST_NOTIFICATION_MESSAGE_SCREEN_CAN_PAUSE);
EXPECT_EQ(GetNotification()->message(), screen_casting_can_pause_message);
}
TEST_F(CastNotificationControllerTest, NotificationMessage_CastingTab_Paused) {
// Create a tab casting route that is paused,
SinkAndRoute device = CreateDeviceLocalRoute();
device.route.freeze_info.can_freeze = true;
device.route.freeze_info.is_frozen = true;
notification_controller_->OnDevicesUpdated({device});
std::u16string tab_casting_paused_message = l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_CAST_NOTIFICATION_MESSAGE_PAUSED);
EXPECT_EQ(GetNotification()->message(), tab_casting_paused_message);
}
// Create notification for a paused route.
SinkAndRoute device3 = CreateDeviceLocalRoute();
device3.route.freeze_info.is_frozen = true;
notification_controller_->OnDevicesUpdated({device3});
std::u16string casting_paused_message =
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_CAST_CAST_PAUSED);
EXPECT_EQ(GetNotification()->message(), casting_paused_message);
SinkAndRoute device4 = CreateDeviceLocalRouteDesktop();
device4.route.freeze_info.is_frozen = true;
notification_controller_->OnDevicesUpdated({device4});
EXPECT_EQ(GetNotification()->message(), casting_paused_message);
TEST_F(CastNotificationControllerTest,
NotificationMessage_CastingScreen_Paused) {
// Create a screen casting route that is paused,
SinkAndRoute device = CreateDeviceLocalRouteDesktop();
device.route.freeze_info.can_freeze = true;
device.route.freeze_info.is_frozen = true;
notification_controller_->OnDevicesUpdated({device});
std::u16string screen_casting_paused_message = l10n_util::GetStringUTF16(
IDS_ASH_STATUS_TRAY_CAST_NOTIFICATION_MESSAGE_SCREEN_PAUSED);
EXPECT_EQ(GetNotification()->message(), screen_casting_paused_message);
}
// Regression test for b/280864232
TEST_F(CastNotificationControllerTest, NewRouteStop) {
// Create notification.
cast_config_.set_has_sinks_and_routes(true);
cast_config_.set_has_active_route(true);
SinkAndRoute device = CreateDeviceLocalRoute();
// Make the device "freezable" so the freeze (pause) button appears.
device.route.freeze_info.can_freeze = true;