Commit 5c49dde4 authored by Shane Fitzpatrick's avatar Shane Fitzpatrick Committed by Chromium LUCI CQ

[Nearby] Update singular instances of notification strings

In the case where only 1 item is being sent, the spec calls for the
format '<item_type> received...'.  The previous functionality had it as
'1 <item_type> received...'.

This change aligns the strings to the spec.  I opted for separate
capitialized and non-capitialized version to reduce the risk of a
runtime determination being wrong for some locales.

Confirmed with Shiba that this new functionality is as expected.

Fixed: 1158069
Change-Id: I2d12e305aa52b7c52389c71f53c6c5586f13be44
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2643696Reviewed-by: default avatarRyan Hansberry <hansberry@chromium.org>
Commit-Queue: Shane Fitzpatrick <shanefitz@google.com>
Cr-Commit-Position: refs/heads/master@{#846310}
parent eb2394fe
...@@ -155,35 +155,62 @@ ...@@ -155,35 +155,62 @@
<message name="IDS_NEARBY_ERROR_UNSUPPORTED_FILE_TYPE" desc="Notify user that the file chosen can't be shared because of its type, e.g. missing file extension."> <message name="IDS_NEARBY_ERROR_UNSUPPORTED_FILE_TYPE" desc="Notify user that the file chosen can't be shared because of its type, e.g. missing file extension.">
Unsupported file type Unsupported file type
</message> </message>
<message name="IDS_NEARBY_FILE_ATTACHMENTS_APPS" desc="Describes one or more apps being transfered via Nearby Share."> <message name="IDS_NEARBY_FILE_ATTACHMENTS_CAPITALIZED_APPS" desc="Describes one or more apps being transfered via Nearby Share. Singular case is capitalized, e.g. 'App'.">
{COUNT, plural, =1 {1 app} other {# apps}} {COUNT, plural, =1 {App} other {# apps}}
</message> </message>
<message name="IDS_NEARBY_FILE_ATTACHMENTS_IMAGES" desc="Describes one or more images being transfered via Nearby Share."> <message name="IDS_NEARBY_FILE_ATTACHMENTS_NOT_CAPITALIZED_APPS" desc="Describes one or more apps being transfered via Nearby Share. Singular case is not capitalized, e.g. 'app'.">
{COUNT, plural, =1 {1 image} other {# images}} {COUNT, plural, =1 {app} other {# apps}}
</message> </message>
<message name="IDS_NEARBY_FILE_ATTACHMENTS_UNKNOWN" desc="Describes one or more files being transfered via Nearby Share."> <message name="IDS_NEARBY_FILE_ATTACHMENTS_CAPITALIZED_IMAGES" desc="Describes one or more images being transfered via Nearby Share. Singular case is capitalized, e.g. 'Image'.">
{COUNT, plural, =1 {1 file} other {# files}} {COUNT, plural, =1 {Image} other {# images}}
</message> </message>
<message name="IDS_NEARBY_FILE_ATTACHMENTS_VIDEOS" desc="Describes one or more videos being transfered via Nearby Share."> <message name="IDS_NEARBY_FILE_ATTACHMENTS_NOT_CAPITALIZED_IMAGES" desc="Describes one or more images being transfered via Nearby Share. Singular case is not capitalized, e.g. 'image'.">
{COUNT, plural, =1 {1 video} other {# videos}} {COUNT, plural, =1 {image} other {# images}}
</message>
<message name="IDS_NEARBY_FILE_ATTACHMENTS_CAPITALIZED_UNKNOWN" desc="Describes one or more files being transfered via Nearby Share. Singular case is capitalized, e.g. 'File'.">
{COUNT, plural, =1 {File} other {# files}}
</message>
<message name="IDS_NEARBY_FILE_ATTACHMENTS_NOT_CAPITALIZED_UNKNOWN" desc="Describes one or more files being transfered via Nearby Share. Singular case is not capitalized, e.g. 'file'.">
{COUNT, plural, =1 {file} other {# files}}
</message>
<message name="IDS_NEARBY_FILE_ATTACHMENTS_CAPITALIZED_VIDEOS" desc="Describes one or more videos being transfered via Nearby Share. Singular case is capitalized, e.g. 'Video'.">
{COUNT, plural, =1 {Video} other {# videos}}
</message>
<message name="IDS_NEARBY_FILE_ATTACHMENTS_NOT_CAPITALIZED_VIDEOS" desc="Describes one or more videos being transfered via Nearby Share. Singular case is not capitalized, e.g. 'video'.">
{COUNT, plural, =1 {video} other {# videos}}
</message> </message>
<message name="IDS_NEARBY_SECURE_CONNECTION_ID" desc="Description shown on both sender and receiver devices, to remind users to verify/compare tokens on both devices for security before sending/receiving data."> <message name="IDS_NEARBY_SECURE_CONNECTION_ID" desc="Description shown on both sender and receiver devices, to remind users to verify/compare tokens on both devices for security before sending/receiving data.">
Secure connection ID: <ph name="TOKEN">$1<ex>1234</ex></ph> Secure connection ID: <ph name="TOKEN">$1<ex>1234</ex></ph>
</message> </message>
<message name="IDS_NEARBY_TEXT_ATTACHMENTS_ADDRESSES" desc="Describes one or more addresses being transfered via Nearby Share."> <message name="IDS_NEARBY_TEXT_ATTACHMENTS_CAPITALIZED_ADDRESSES" desc="Describes one or more addresses being transfered via Nearby Share. Singular case is capitalized, e.g. 'Address'.">
{COUNT, plural, =1 {1 address} other {# addresses}} {COUNT, plural, =1 {Address} other {# addresses}}
</message>
<message name="IDS_NEARBY_TEXT_ATTACHMENTS_NOT_CAPITALIZED_ADDRESSES" desc="Describes one or more addresses being transfered via Nearby Share. Singular case is not capitalized, e.g. 'address'.">
{COUNT, plural, =1 {address} other {# addresses}}
</message>
<message name="IDS_NEARBY_TEXT_ATTACHMENTS_CAPITALIZED_LINKS" desc="Describes one or more web links being transfered via Nearby Share. Singular case is capitalized, e.g. 'Link'.">
{COUNT, plural, =1 {Link} other {# links}}
</message>
<message name="IDS_NEARBY_TEXT_ATTACHMENTS_NOT_CAPITALIZED_LINKS" desc="Describes one or more web links being transfered via Nearby Share. Singular case is not capitalized, e.g. 'link'.">
{COUNT, plural, =1 {link} other {# links}}
</message>
<message name="IDS_NEARBY_TEXT_ATTACHMENTS_CAPITALIZED_PHONE_NUMBERS" desc="Describes one or more phone numbers being transfered via Nearby Share. Singular case is capitalized, e.g. 'Phone number'.">
{COUNT, plural, =1 {Phone number} other {# phone numbers}}
</message>
<message name="IDS_NEARBY_TEXT_ATTACHMENTS_NOT_CAPITALIZED_PHONE_NUMBERS" desc="Describes one or more phone numbers being transfered via Nearby Share. Singular case is not capitalized, e.g. 'phone number'.">
{COUNT, plural, =1 {phone number} other {# phone numbers}}
</message> </message>
<message name="IDS_NEARBY_TEXT_ATTACHMENTS_LINKS" desc="Describes one or more web links being transfered via Nearby Share."> <message name="IDS_NEARBY_TEXT_ATTACHMENTS_CAPITALIZED_UNKNOWN" desc="Describes one or more pieces of text being transfered via Nearby Share. Singular case is capitalized, e.g. 'Text'.">
{COUNT, plural, =1 {1 link} other {# links}} {COUNT, plural, =1 {Text} other {# texts}}
</message> </message>
<message name="IDS_NEARBY_TEXT_ATTACHMENTS_PHONE_NUMBERS" desc="Describes one or more phone numbers being transfered via Nearby Share."> <message name="IDS_NEARBY_TEXT_ATTACHMENTS_NOT_CAPITALIZED_UNKNOWN" desc="Describes one or more pieces of text being transfered via Nearby Share. Singular case is not capitalized, e.g. 'text'.">
{COUNT, plural, =1 {1 phone number} other {# phone numbers}} {COUNT, plural, =1 {text} other {# texts}}
</message> </message>
<message name="IDS_NEARBY_TEXT_ATTACHMENTS_UNKNOWN" desc="Describes one or more pieces of text being transfered via Nearby Share."> <message name="IDS_NEARBY_CAPITALIZED_UNKNOWN_ATTACHMENTS" desc="Describes one or more items being transfered via Nearby Share. Singular case is capitalized, e.g. 'Item'.">
{COUNT, plural, =1 {1 text} other {# texts}} {COUNT, plural, =1 {Item} other {# items}}
</message> </message>
<message name="IDS_NEARBY_UNKNOWN_ATTACHMENTS" desc="Describes one or more items being transfered via Nearby Share."> <message name="IDS_NEARBY_NOT_CAPITALIZED_UNKNOWN_ATTACHMENTS" desc="Describes one or more items being transfered via Nearby Share. Singular case is not capitalized, e.g. 'item'.">
{COUNT, plural, =1 {1 item} other {# items}} {COUNT, plural, =1 {item} other {# items}}
</message> </message>
<!-- High Visibility Page Strings --> <!-- High Visibility Page Strings -->
......
1ce455c32fe2c9bda6e8704f29aa88d00fbfe1ea
\ No newline at end of file
edd8285791615742b5bfadf28ce9490952149cd4
\ No newline at end of file
fc4469a08c240221046a4714886de64cf0790633
\ No newline at end of file
5582cd343f38e2414dec5579eebbc0c89eb6d77e
\ No newline at end of file
381392488f4839ddf3adf239f08821a8f8546010
\ No newline at end of file
a1ddd7e870476c5b6c8519f73a06001f48fc577e
\ No newline at end of file
12196ddb4dc04ea35b830fabbcc46037ee3f622e
\ No newline at end of file
0d2abbc0f9990eadc2a3f83f35b8379df22cb25b
\ No newline at end of file
067f083ae108de1208a1a48c510c101208beabc8
\ No newline at end of file
...@@ -94,53 +94,101 @@ TextAttachment::Type GetCommonTextAttachmentType( ...@@ -94,53 +94,101 @@ TextAttachment::Type GetCommonTextAttachmentType(
return type; return type;
} }
int GetFileAttachmentsStringId(const std::vector<FileAttachment>& files) { int GetFileAttachmentsCapitalizedStringId(
const std::vector<FileAttachment>& files) {
switch (GetCommonFileAttachmentType(files)) {
case FileAttachment::Type::kApp:
return IDS_NEARBY_FILE_ATTACHMENTS_CAPITALIZED_APPS;
case FileAttachment::Type::kImage:
return IDS_NEARBY_FILE_ATTACHMENTS_CAPITALIZED_IMAGES;
case FileAttachment::Type::kUnknown:
return IDS_NEARBY_FILE_ATTACHMENTS_CAPITALIZED_UNKNOWN;
case FileAttachment::Type::kVideo:
return IDS_NEARBY_FILE_ATTACHMENTS_CAPITALIZED_VIDEOS;
default:
return IDS_NEARBY_CAPITALIZED_UNKNOWN_ATTACHMENTS;
}
}
int GetFileAttachmentsNotCapitalizedStringId(
const std::vector<FileAttachment>& files) {
switch (GetCommonFileAttachmentType(files)) { switch (GetCommonFileAttachmentType(files)) {
case FileAttachment::Type::kApp: case FileAttachment::Type::kApp:
return IDS_NEARBY_FILE_ATTACHMENTS_APPS; return IDS_NEARBY_FILE_ATTACHMENTS_NOT_CAPITALIZED_APPS;
case FileAttachment::Type::kImage: case FileAttachment::Type::kImage:
return IDS_NEARBY_FILE_ATTACHMENTS_IMAGES; return IDS_NEARBY_FILE_ATTACHMENTS_NOT_CAPITALIZED_IMAGES;
case FileAttachment::Type::kUnknown: case FileAttachment::Type::kUnknown:
return IDS_NEARBY_FILE_ATTACHMENTS_UNKNOWN; return IDS_NEARBY_FILE_ATTACHMENTS_NOT_CAPITALIZED_UNKNOWN;
case FileAttachment::Type::kVideo: case FileAttachment::Type::kVideo:
return IDS_NEARBY_FILE_ATTACHMENTS_VIDEOS; return IDS_NEARBY_FILE_ATTACHMENTS_NOT_CAPITALIZED_VIDEOS;
default: default:
return IDS_NEARBY_UNKNOWN_ATTACHMENTS; return IDS_NEARBY_NOT_CAPITALIZED_UNKNOWN_ATTACHMENTS;
} }
} }
int GetTextAttachmentsStringId(const std::vector<TextAttachment>& texts) { int GetTextAttachmentsCapitalizedStringId(
const std::vector<TextAttachment>& texts) {
switch (GetCommonTextAttachmentType(texts)) { switch (GetCommonTextAttachmentType(texts)) {
case TextAttachment::Type::kAddress: case TextAttachment::Type::kAddress:
return IDS_NEARBY_TEXT_ATTACHMENTS_ADDRESSES; return IDS_NEARBY_TEXT_ATTACHMENTS_CAPITALIZED_ADDRESSES;
case TextAttachment::Type::kPhoneNumber: case TextAttachment::Type::kPhoneNumber:
return IDS_NEARBY_TEXT_ATTACHMENTS_PHONE_NUMBERS; return IDS_NEARBY_TEXT_ATTACHMENTS_CAPITALIZED_PHONE_NUMBERS;
case TextAttachment::Type::kText: case TextAttachment::Type::kText:
return IDS_NEARBY_TEXT_ATTACHMENTS_UNKNOWN; return IDS_NEARBY_TEXT_ATTACHMENTS_CAPITALIZED_UNKNOWN;
case TextAttachment::Type::kUrl: case TextAttachment::Type::kUrl:
return IDS_NEARBY_TEXT_ATTACHMENTS_LINKS; return IDS_NEARBY_TEXT_ATTACHMENTS_CAPITALIZED_LINKS;
default: default:
return IDS_NEARBY_TEXT_ATTACHMENTS_UNKNOWN; return IDS_NEARBY_TEXT_ATTACHMENTS_CAPITALIZED_UNKNOWN;
} }
} }
base::string16 GetAttachmentsString(const ShareTarget& share_target) { int GetTextAttachmentsNotCapitalizedStringId(
const std::vector<TextAttachment>& texts) {
switch (GetCommonTextAttachmentType(texts)) {
case TextAttachment::Type::kAddress:
return IDS_NEARBY_TEXT_ATTACHMENTS_NOT_CAPITALIZED_ADDRESSES;
case TextAttachment::Type::kPhoneNumber:
return IDS_NEARBY_TEXT_ATTACHMENTS_NOT_CAPITALIZED_PHONE_NUMBERS;
case TextAttachment::Type::kText:
return IDS_NEARBY_TEXT_ATTACHMENTS_NOT_CAPITALIZED_UNKNOWN;
case TextAttachment::Type::kUrl:
return IDS_NEARBY_TEXT_ATTACHMENTS_NOT_CAPITALIZED_LINKS;
default:
return IDS_NEARBY_TEXT_ATTACHMENTS_NOT_CAPITALIZED_UNKNOWN;
}
}
base::string16 GetAttachmentsString(const ShareTarget& share_target,
bool use_capitalized_attachments) {
size_t file_count = share_target.file_attachments.size(); size_t file_count = share_target.file_attachments.size();
size_t text_count = share_target.text_attachments.size(); size_t text_count = share_target.text_attachments.size();
int resource_id = IDS_NEARBY_UNKNOWN_ATTACHMENTS; int resource_id = use_capitalized_attachments
? IDS_NEARBY_CAPITALIZED_UNKNOWN_ATTACHMENTS
: IDS_NEARBY_NOT_CAPITALIZED_UNKNOWN_ATTACHMENTS;
if (file_count > 0 && text_count == 0) if (file_count > 0 && text_count == 0)
resource_id = GetFileAttachmentsStringId(share_target.file_attachments); resource_id = use_capitalized_attachments
? GetFileAttachmentsCapitalizedStringId(
share_target.file_attachments)
: GetFileAttachmentsNotCapitalizedStringId(
share_target.file_attachments);
if (text_count > 0 && file_count == 0) if (text_count > 0 && file_count == 0)
resource_id = GetTextAttachmentsStringId(share_target.text_attachments); resource_id = use_capitalized_attachments
? GetTextAttachmentsCapitalizedStringId(
share_target.text_attachments)
: GetTextAttachmentsNotCapitalizedStringId(
share_target.text_attachments);
return l10n_util::GetPluralStringFUTF16(resource_id, text_count + file_count); return l10n_util::GetPluralStringFUTF16(resource_id, text_count + file_count);
} }
base::string16 FormatNotificationTitle(const ShareTarget& share_target, base::string16 FormatNotificationTitle(const ShareTarget& share_target,
int resource_id) { int resource_id,
base::string16 attachments = GetAttachmentsString(share_target); bool use_capitalized_attachments) {
base::string16 attachments =
GetAttachmentsString(share_target, use_capitalized_attachments);
base::string16 device_name = base::ASCIIToUTF16(share_target.device_name); base::string16 device_name = base::ASCIIToUTF16(share_target.device_name);
size_t attachment_count = share_target.file_attachments.size() + size_t attachment_count = share_target.file_attachments.size() +
share_target.text_attachments.size(); share_target.text_attachments.size();
...@@ -152,23 +200,26 @@ base::string16 FormatNotificationTitle(const ShareTarget& share_target, ...@@ -152,23 +200,26 @@ base::string16 FormatNotificationTitle(const ShareTarget& share_target,
base::string16 GetProgressNotificationTitle(const ShareTarget& share_target) { base::string16 GetProgressNotificationTitle(const ShareTarget& share_target) {
return FormatNotificationTitle( return FormatNotificationTitle(
share_target, share_target.is_incoming share_target,
? IDS_NEARBY_NOTIFICATION_RECEIVE_PROGRESS_TITLE share_target.is_incoming ? IDS_NEARBY_NOTIFICATION_RECEIVE_PROGRESS_TITLE
: IDS_NEARBY_NOTIFICATION_SEND_PROGRESS_TITLE); : IDS_NEARBY_NOTIFICATION_SEND_PROGRESS_TITLE,
/*use_capitalized_attachments=*/false);
} }
base::string16 GetSuccessNotificationTitle(const ShareTarget& share_target) { base::string16 GetSuccessNotificationTitle(const ShareTarget& share_target) {
return FormatNotificationTitle( return FormatNotificationTitle(
share_target, share_target.is_incoming share_target,
? IDS_NEARBY_NOTIFICATION_RECEIVE_SUCCESS_TITLE share_target.is_incoming ? IDS_NEARBY_NOTIFICATION_RECEIVE_SUCCESS_TITLE
: IDS_NEARBY_NOTIFICATION_SEND_SUCCESS_TITLE); : IDS_NEARBY_NOTIFICATION_SEND_SUCCESS_TITLE,
/*use_capitalized_attachments=*/true);
} }
base::string16 GetFailureNotificationTitle(const ShareTarget& share_target) { base::string16 GetFailureNotificationTitle(const ShareTarget& share_target) {
return FormatNotificationTitle( return FormatNotificationTitle(
share_target, share_target.is_incoming share_target,
? IDS_NEARBY_NOTIFICATION_RECEIVE_FAILURE_TITLE share_target.is_incoming ? IDS_NEARBY_NOTIFICATION_RECEIVE_FAILURE_TITLE
: IDS_NEARBY_NOTIFICATION_SEND_FAILURE_TITLE); : IDS_NEARBY_NOTIFICATION_SEND_FAILURE_TITLE,
/*use_capitalized_attachments=*/false);
} }
base::Optional<base::string16> GetFailureNotificationMessage( base::Optional<base::string16> GetFailureNotificationMessage(
...@@ -188,7 +239,8 @@ base::Optional<base::string16> GetFailureNotificationMessage( ...@@ -188,7 +239,8 @@ base::Optional<base::string16> GetFailureNotificationMessage(
base::string16 GetConnectionRequestNotificationMessage( base::string16 GetConnectionRequestNotificationMessage(
const ShareTarget& share_target, const ShareTarget& share_target,
const TransferMetadata& transfer_metadata) { const TransferMetadata& transfer_metadata) {
base::string16 attachments = GetAttachmentsString(share_target); base::string16 attachments =
GetAttachmentsString(share_target, /*use_capitalized_attachments=*/false);
base::string16 device_name = base::ASCIIToUTF16(share_target.device_name); base::string16 device_name = base::ASCIIToUTF16(share_target.device_name);
size_t attachment_count = share_target.file_attachments.size() + size_t attachment_count = share_target.file_attachments.size() +
......
...@@ -232,45 +232,76 @@ class NearbyNotificationManagerTest : public testing::Test { ...@@ -232,45 +232,76 @@ class NearbyNotificationManagerTest : public testing::Test {
struct AttachmentsTestParamInternal { struct AttachmentsTestParamInternal {
std::vector<TextAttachment::Type> text_attachments; std::vector<TextAttachment::Type> text_attachments;
std::vector<FileAttachment::Type> file_attachments; std::vector<FileAttachment::Type> file_attachments;
int expected_resource_id; int expected_capitalized_resource_id;
int expected_not_capitalized_resource_id;
}; };
AttachmentsTestParamInternal kAttachmentsTestParams[] = { AttachmentsTestParamInternal kAttachmentsTestParams[] = {
// No attachments. // No attachments.
{{}, {}, IDS_NEARBY_UNKNOWN_ATTACHMENTS}, {{},
{},
IDS_NEARBY_CAPITALIZED_UNKNOWN_ATTACHMENTS,
IDS_NEARBY_NOT_CAPITALIZED_UNKNOWN_ATTACHMENTS},
// Mixed attachments. // Mixed attachments.
{{TextAttachment::Type::kText}, {
{TextAttachment::Type::kText},
{FileAttachment::Type::kUnknown}, {FileAttachment::Type::kUnknown},
IDS_NEARBY_UNKNOWN_ATTACHMENTS}, IDS_NEARBY_CAPITALIZED_UNKNOWN_ATTACHMENTS,
IDS_NEARBY_NOT_CAPITALIZED_UNKNOWN_ATTACHMENTS,
},
// Text attachments. // Text attachments.
{{TextAttachment::Type::kUrl}, {}, IDS_NEARBY_TEXT_ATTACHMENTS_LINKS}, {{TextAttachment::Type::kUrl},
{{TextAttachment::Type::kText}, {}, IDS_NEARBY_TEXT_ATTACHMENTS_UNKNOWN}, {},
IDS_NEARBY_TEXT_ATTACHMENTS_CAPITALIZED_LINKS,
IDS_NEARBY_TEXT_ATTACHMENTS_NOT_CAPITALIZED_LINKS},
{{TextAttachment::Type::kText},
{},
IDS_NEARBY_TEXT_ATTACHMENTS_CAPITALIZED_UNKNOWN,
IDS_NEARBY_TEXT_ATTACHMENTS_NOT_CAPITALIZED_UNKNOWN},
{{TextAttachment::Type::kAddress}, {{TextAttachment::Type::kAddress},
{}, {},
IDS_NEARBY_TEXT_ATTACHMENTS_ADDRESSES}, IDS_NEARBY_TEXT_ATTACHMENTS_CAPITALIZED_ADDRESSES,
IDS_NEARBY_TEXT_ATTACHMENTS_NOT_CAPITALIZED_ADDRESSES},
{{TextAttachment::Type::kPhoneNumber}, {{TextAttachment::Type::kPhoneNumber},
{}, {},
IDS_NEARBY_TEXT_ATTACHMENTS_PHONE_NUMBERS}, IDS_NEARBY_TEXT_ATTACHMENTS_CAPITALIZED_PHONE_NUMBERS,
IDS_NEARBY_TEXT_ATTACHMENTS_NOT_CAPITALIZED_PHONE_NUMBERS},
{{TextAttachment::Type::kAddress, TextAttachment::Type::kAddress}, {{TextAttachment::Type::kAddress, TextAttachment::Type::kAddress},
{}, {},
IDS_NEARBY_TEXT_ATTACHMENTS_ADDRESSES}, IDS_NEARBY_TEXT_ATTACHMENTS_CAPITALIZED_ADDRESSES,
IDS_NEARBY_TEXT_ATTACHMENTS_NOT_CAPITALIZED_ADDRESSES},
{{TextAttachment::Type::kAddress, TextAttachment::Type::kUrl}, {{TextAttachment::Type::kAddress, TextAttachment::Type::kUrl},
{}, {},
IDS_NEARBY_TEXT_ATTACHMENTS_UNKNOWN}, IDS_NEARBY_TEXT_ATTACHMENTS_CAPITALIZED_UNKNOWN,
IDS_NEARBY_TEXT_ATTACHMENTS_NOT_CAPITALIZED_UNKNOWN},
// File attachments. // File attachments.
{{}, {FileAttachment::Type::kApp}, IDS_NEARBY_FILE_ATTACHMENTS_APPS}, {{},
{{}, {FileAttachment::Type::kImage}, IDS_NEARBY_FILE_ATTACHMENTS_IMAGES}, {FileAttachment::Type::kApp},
{{}, {FileAttachment::Type::kUnknown}, IDS_NEARBY_FILE_ATTACHMENTS_UNKNOWN}, IDS_NEARBY_FILE_ATTACHMENTS_CAPITALIZED_APPS,
{{}, {FileAttachment::Type::kVideo}, IDS_NEARBY_FILE_ATTACHMENTS_VIDEOS}, IDS_NEARBY_FILE_ATTACHMENTS_NOT_CAPITALIZED_APPS},
{{},
{FileAttachment::Type::kImage},
IDS_NEARBY_FILE_ATTACHMENTS_CAPITALIZED_IMAGES,
IDS_NEARBY_FILE_ATTACHMENTS_NOT_CAPITALIZED_IMAGES},
{{},
{FileAttachment::Type::kUnknown},
IDS_NEARBY_FILE_ATTACHMENTS_CAPITALIZED_UNKNOWN,
IDS_NEARBY_FILE_ATTACHMENTS_NOT_CAPITALIZED_UNKNOWN},
{{},
{FileAttachment::Type::kVideo},
IDS_NEARBY_FILE_ATTACHMENTS_CAPITALIZED_VIDEOS,
IDS_NEARBY_FILE_ATTACHMENTS_NOT_CAPITALIZED_VIDEOS},
{{}, {{},
{FileAttachment::Type::kApp, FileAttachment::Type::kApp}, {FileAttachment::Type::kApp, FileAttachment::Type::kApp},
IDS_NEARBY_FILE_ATTACHMENTS_APPS}, IDS_NEARBY_FILE_ATTACHMENTS_CAPITALIZED_APPS,
IDS_NEARBY_FILE_ATTACHMENTS_NOT_CAPITALIZED_APPS},
{{}, {{},
{FileAttachment::Type::kApp, FileAttachment::Type::kImage}, {FileAttachment::Type::kApp, FileAttachment::Type::kImage},
IDS_NEARBY_FILE_ATTACHMENTS_UNKNOWN}, IDS_NEARBY_FILE_ATTACHMENTS_CAPITALIZED_UNKNOWN,
IDS_NEARBY_FILE_ATTACHMENTS_NOT_CAPITALIZED_UNKNOWN},
}; };
using AttachmentsTestParam = std::tuple<AttachmentsTestParamInternal, bool>; using AttachmentsTestParam = std::tuple<AttachmentsTestParamInternal, bool>;
...@@ -288,11 +319,15 @@ class NearbyNotificationManagerConnectionRequestTest ...@@ -288,11 +319,15 @@ class NearbyNotificationManagerConnectionRequestTest
base::string16 FormatNotificationTitle( base::string16 FormatNotificationTitle(
int resource_id, int resource_id,
const AttachmentsTestParamInternal& param, const AttachmentsTestParamInternal& param,
const std::string& device_name) { const std::string& device_name,
bool use_capitalized_resource) {
size_t total = param.text_attachments.size() + param.file_attachments.size(); size_t total = param.text_attachments.size() + param.file_attachments.size();
int attachments_resource_id =
use_capitalized_resource ? param.expected_capitalized_resource_id
: param.expected_not_capitalized_resource_id;
return base::ReplaceStringPlaceholders( return base::ReplaceStringPlaceholders(
l10n_util::GetPluralStringFUTF16(resource_id, total), l10n_util::GetPluralStringFUTF16(resource_id, total),
{l10n_util::GetPluralStringFUTF16(param.expected_resource_id, total), {l10n_util::GetPluralStringFUTF16(attachments_resource_id, total),
base::ASCIIToUTF16(device_name)}, base::ASCIIToUTF16(device_name)},
/*offsets=*/nullptr); /*offsets=*/nullptr);
} }
...@@ -419,7 +454,7 @@ TEST_P(NearbyNotificationManagerAttachmentsTest, ShowProgress) { ...@@ -419,7 +454,7 @@ TEST_P(NearbyNotificationManagerAttachmentsTest, ShowProgress) {
base::string16 expected = FormatNotificationTitle( base::string16 expected = FormatNotificationTitle(
is_incoming ? IDS_NEARBY_NOTIFICATION_RECEIVE_PROGRESS_TITLE is_incoming ? IDS_NEARBY_NOTIFICATION_RECEIVE_PROGRESS_TITLE
: IDS_NEARBY_NOTIFICATION_SEND_PROGRESS_TITLE, : IDS_NEARBY_NOTIFICATION_SEND_PROGRESS_TITLE,
param, device_name); param, device_name, /*use_capitalized_resource=*/false);
std::vector<message_center::Notification> notifications = std::vector<message_center::Notification> notifications =
GetDisplayedNotifications(); GetDisplayedNotifications();
...@@ -449,7 +484,7 @@ TEST_P(NearbyNotificationManagerAttachmentsTest, ShowSuccess) { ...@@ -449,7 +484,7 @@ TEST_P(NearbyNotificationManagerAttachmentsTest, ShowSuccess) {
base::string16 expected = FormatNotificationTitle( base::string16 expected = FormatNotificationTitle(
is_incoming ? IDS_NEARBY_NOTIFICATION_RECEIVE_SUCCESS_TITLE is_incoming ? IDS_NEARBY_NOTIFICATION_RECEIVE_SUCCESS_TITLE
: IDS_NEARBY_NOTIFICATION_SEND_SUCCESS_TITLE, : IDS_NEARBY_NOTIFICATION_SEND_SUCCESS_TITLE,
param, device_name); param, device_name, /*use_capitalized_resource=*/true);
std::vector<message_center::Notification> notifications = std::vector<message_center::Notification> notifications =
GetDisplayedNotifications(); GetDisplayedNotifications();
...@@ -490,7 +525,7 @@ TEST_P(NearbyNotificationManagerAttachmentsTest, ShowFailure) { ...@@ -490,7 +525,7 @@ TEST_P(NearbyNotificationManagerAttachmentsTest, ShowFailure) {
base::string16 expected_title = FormatNotificationTitle( base::string16 expected_title = FormatNotificationTitle(
is_incoming ? IDS_NEARBY_NOTIFICATION_RECEIVE_FAILURE_TITLE is_incoming ? IDS_NEARBY_NOTIFICATION_RECEIVE_FAILURE_TITLE
: IDS_NEARBY_NOTIFICATION_SEND_FAILURE_TITLE, : IDS_NEARBY_NOTIFICATION_SEND_FAILURE_TITLE,
param, device_name); param, device_name, /*use_capitalized_resource=*/false);
base::string16 expected_message = base::string16 expected_message =
error.second ? l10n_util::GetStringUTF16(error.second) error.second ? l10n_util::GetStringUTF16(error.second)
: base::string16(); : base::string16();
...@@ -550,7 +585,8 @@ TEST_P(NearbyNotificationManagerConnectionRequestTest, ...@@ -550,7 +585,8 @@ TEST_P(NearbyNotificationManagerConnectionRequestTest,
base::string16 expected_message = base::ReplaceStringPlaceholders( base::string16 expected_message = base::ReplaceStringPlaceholders(
plural_message, plural_message,
{base::ASCIIToUTF16(device_name), {base::ASCIIToUTF16(device_name),
l10n_util::GetPluralStringFUTF16(IDS_NEARBY_FILE_ATTACHMENTS_IMAGES, 1)}, l10n_util::GetPluralStringFUTF16(
IDS_NEARBY_FILE_ATTACHMENTS_NOT_CAPITALIZED_IMAGES, 1)},
/*offsets=*/nullptr); /*offsets=*/nullptr);
if (with_token) { if (with_token) {
......
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