Commit 627b834e authored by Sebastien Lalancette's avatar Sebastien Lalancette Committed by Commit Bot

[iOS] Add More Context Menu Icons

Updated icons and unit tests.

Bug: 1093302
Change-Id: I686d1ff0be31ade4260cb5955f937f01632ddc45
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2346846
Commit-Queue: Sebastien Lalancette <seblalancette@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796830}
parent 7d018e30
...@@ -13,6 +13,13 @@ source_set("menu") { ...@@ -13,6 +13,13 @@ source_set("menu") {
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
deps = [ deps = [
"resources:copy_link_url", "resources:copy_link_url",
"resources:delete",
"resources:edit",
"resources:open_in_incognito",
"resources:open_in_new_tab",
"resources:open_new_window",
"resources:remove",
"resources:share",
"//base", "//base",
"//ios/chrome/app/strings", "//ios/chrome/app/strings",
"//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/commands",
...@@ -32,6 +39,13 @@ source_set("unit_tests") { ...@@ -32,6 +39,13 @@ source_set("unit_tests") {
deps = [ deps = [
":menu", ":menu",
"resources:copy_link_url", "resources:copy_link_url",
"resources:delete",
"resources:edit",
"resources:open_in_incognito",
"resources:open_in_new_tab",
"resources:open_new_window",
"resources:remove",
"resources:share",
"//base", "//base",
"//base/test:test_support", "//base/test:test_support",
"//ios/chrome/app/strings", "//ios/chrome/app/strings",
......
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
- (UIAction*)actionToShareWithBlock:(ProceduralBlock)block { - (UIAction*)actionToShareWithBlock:(ProceduralBlock)block {
return return
[self actionWithTitle:l10n_util::GetNSString(IDS_IOS_SHARE_BUTTON_LABEL) [self actionWithTitle:l10n_util::GetNSString(IDS_IOS_SHARE_BUTTON_LABEL)
image:[UIImage systemImageNamed:@"square.and.arrow.up"] image:[UIImage imageNamed:@"share"]
type:MenuActionType::Share type:MenuActionType::Share
block:block]; block:block];
} }
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
- (UIAction*)actionToDeleteWithBlock:(ProceduralBlock)block { - (UIAction*)actionToDeleteWithBlock:(ProceduralBlock)block {
UIAction* action = UIAction* action =
[self actionWithTitle:l10n_util::GetNSString(IDS_IOS_DELETE_ACTION_TITLE) [self actionWithTitle:l10n_util::GetNSString(IDS_IOS_DELETE_ACTION_TITLE)
image:[UIImage systemImageNamed:@"trash"] image:[UIImage imageNamed:@"delete"]
type:MenuActionType::Delete type:MenuActionType::Delete
block:block]; block:block];
action.attributes = UIMenuElementAttributesDestructive; action.attributes = UIMenuElementAttributesDestructive;
...@@ -102,7 +102,7 @@ ...@@ -102,7 +102,7 @@
- (UIAction*)actionToOpenInNewTabWithBlock:(ProceduralBlock)block { - (UIAction*)actionToOpenInNewTabWithBlock:(ProceduralBlock)block {
return [self actionWithTitle:l10n_util::GetNSString( return [self actionWithTitle:l10n_util::GetNSString(
IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB) IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB)
image:[UIImage systemImageNamed:@"plus"] image:[UIImage imageNamed:@"open_in_new_tab"]
type:MenuActionType::OpenInNewTab type:MenuActionType::OpenInNewTab
block:block]; block:block];
} }
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
- (UIAction*)actionToOpenInNewIncognitoTabWithBlock:(ProceduralBlock)block { - (UIAction*)actionToOpenInNewIncognitoTabWithBlock:(ProceduralBlock)block {
return [self actionWithTitle:l10n_util::GetNSString( return [self actionWithTitle:l10n_util::GetNSString(
IDS_IOS_OPEN_IN_INCOGNITO_ACTION_TITLE) IDS_IOS_OPEN_IN_INCOGNITO_ACTION_TITLE)
image:nil image:[UIImage imageNamed:@"open_in_incognito"]
type:MenuActionType::OpenInNewIncognitoTab type:MenuActionType::OpenInNewIncognitoTab
block:block]; block:block];
} }
...@@ -137,7 +137,7 @@ ...@@ -137,7 +137,7 @@
NSUserActivity* activity = ActivityToLoadURL(activityOrigin, URL); NSUserActivity* activity = ActivityToLoadURL(activityOrigin, URL);
return [self actionWithTitle:l10n_util::GetNSString( return [self actionWithTitle:l10n_util::GetNSString(
IDS_IOS_CONTENT_CONTEXT_OPENINNEWWINDOW) IDS_IOS_CONTENT_CONTEXT_OPENINNEWWINDOW)
image:[UIImage systemImageNamed:@"plus.square"] image:[UIImage imageNamed:@"open_new_window"]
type:MenuActionType::OpenInNewWindow type:MenuActionType::OpenInNewWindow
block:^{ block:^{
[windowOpener openNewWindowWithActivity:activity]; [windowOpener openNewWindowWithActivity:activity];
...@@ -150,7 +150,7 @@ ...@@ -150,7 +150,7 @@
- (UIAction*)actionToRemoveWithBlock:(ProceduralBlock)block { - (UIAction*)actionToRemoveWithBlock:(ProceduralBlock)block {
UIAction* action = UIAction* action =
[self actionWithTitle:l10n_util::GetNSString(IDS_IOS_REMOVE_ACTION_TITLE) [self actionWithTitle:l10n_util::GetNSString(IDS_IOS_REMOVE_ACTION_TITLE)
image:[UIImage systemImageNamed:@"trash"] image:[UIImage imageNamed:@"remove"]
type:MenuActionType::Remove type:MenuActionType::Remove
block:block]; block:block];
action.attributes = UIMenuElementAttributesDestructive; action.attributes = UIMenuElementAttributesDestructive;
...@@ -159,7 +159,7 @@ ...@@ -159,7 +159,7 @@
- (UIAction*)actionToEditWithBlock:(ProceduralBlock)block { - (UIAction*)actionToEditWithBlock:(ProceduralBlock)block {
return [self actionWithTitle:l10n_util::GetNSString(IDS_IOS_EDIT_ACTION_TITLE) return [self actionWithTitle:l10n_util::GetNSString(IDS_IOS_EDIT_ACTION_TITLE)
image:nil image:[UIImage imageNamed:@"edit"]
type:MenuActionType::Edit type:MenuActionType::Edit
block:block]; block:block];
} }
......
...@@ -116,7 +116,7 @@ TEST_F(ActionFactoryTest, ShareAction) { ...@@ -116,7 +116,7 @@ TEST_F(ActionFactoryTest, ShareAction) {
[[ActionFactory alloc] initWithBrowser:test_browser_.get() [[ActionFactory alloc] initWithBrowser:test_browser_.get()
scenario:kTestMenuScenario]; scenario:kTestMenuScenario];
UIImage* expectedImage = [UIImage systemImageNamed:@"square.and.arrow.up"]; UIImage* expectedImage = [UIImage imageNamed:@"share"];
NSString* expectedTitle = NSString* expectedTitle =
l10n_util::GetNSString(IDS_IOS_SHARE_BUTTON_LABEL); l10n_util::GetNSString(IDS_IOS_SHARE_BUTTON_LABEL);
...@@ -135,7 +135,7 @@ TEST_F(ActionFactoryTest, DeleteAction) { ...@@ -135,7 +135,7 @@ TEST_F(ActionFactoryTest, DeleteAction) {
[[ActionFactory alloc] initWithBrowser:test_browser_.get() [[ActionFactory alloc] initWithBrowser:test_browser_.get()
scenario:kTestMenuScenario]; scenario:kTestMenuScenario];
UIImage* expectedImage = [UIImage systemImageNamed:@"trash"]; UIImage* expectedImage = [UIImage imageNamed:@"delete"];
NSString* expectedTitle = NSString* expectedTitle =
l10n_util::GetNSString(IDS_IOS_DELETE_ACTION_TITLE); l10n_util::GetNSString(IDS_IOS_DELETE_ACTION_TITLE);
...@@ -157,7 +157,7 @@ TEST_F(ActionFactoryTest, OpenInNewTabAction_URL) { ...@@ -157,7 +157,7 @@ TEST_F(ActionFactoryTest, OpenInNewTabAction_URL) {
GURL testURL = GURL("https://example.com"); GURL testURL = GURL("https://example.com");
UIImage* expectedImage = [UIImage systemImageNamed:@"plus"]; UIImage* expectedImage = [UIImage imageNamed:@"open_in_new_tab"];
NSString* expectedTitle = NSString* expectedTitle =
l10n_util::GetNSString(IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB); l10n_util::GetNSString(IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB);
...@@ -182,18 +182,19 @@ TEST_F(ActionFactoryTest, OpenInNewIncognitoTabAction_URL) { ...@@ -182,18 +182,19 @@ TEST_F(ActionFactoryTest, OpenInNewIncognitoTabAction_URL) {
GURL testURL = GURL("https://example.com"); GURL testURL = GURL("https://example.com");
UIImage* expectedImage = [UIImage imageNamed:@"open_in_incognito"];
NSString* expectedTitle = NSString* expectedTitle =
l10n_util::GetNSString(IDS_IOS_OPEN_IN_INCOGNITO_ACTION_TITLE); l10n_util::GetNSString(IDS_IOS_OPEN_IN_INCOGNITO_ACTION_TITLE);
UIAction* actionWithURL = UIAction* actionWithURL =
[factory actionToOpenInNewIncognitoTabWithURL:testURL completion:nil]; [factory actionToOpenInNewIncognitoTabWithURL:testURL completion:nil];
EXPECT_TRUE([expectedTitle isEqualToString:actionWithURL.title]); EXPECT_TRUE([expectedTitle isEqualToString:actionWithURL.title]);
EXPECT_FALSE(!!actionWithURL.image); EXPECT_EQ(expectedImage, actionWithURL.image);
UIAction* actionWithBlock = UIAction* actionWithBlock =
[factory actionToOpenInNewIncognitoTabWithBlock:nil]; [factory actionToOpenInNewIncognitoTabWithBlock:nil];
EXPECT_TRUE([expectedTitle isEqualToString:actionWithBlock.title]); EXPECT_TRUE([expectedTitle isEqualToString:actionWithBlock.title]);
EXPECT_FALSE(!!actionWithBlock.image); EXPECT_EQ(expectedImage, actionWithBlock.image);
} }
} }
...@@ -206,7 +207,7 @@ TEST_F(ActionFactoryTest, OpenInNewWindowAction) { ...@@ -206,7 +207,7 @@ TEST_F(ActionFactoryTest, OpenInNewWindowAction) {
GURL testURL = GURL("https://example.com"); GURL testURL = GURL("https://example.com");
UIImage* expectedImage = [UIImage systemImageNamed:@"plus.square"]; UIImage* expectedImage = [UIImage imageNamed:@"open_new_window"];
NSString* expectedTitle = NSString* expectedTitle =
l10n_util::GetNSString(IDS_IOS_CONTENT_CONTEXT_OPENINNEWWINDOW); l10n_util::GetNSString(IDS_IOS_CONTENT_CONTEXT_OPENINNEWWINDOW);
...@@ -220,6 +221,25 @@ TEST_F(ActionFactoryTest, OpenInNewWindowAction) { ...@@ -220,6 +221,25 @@ TEST_F(ActionFactoryTest, OpenInNewWindowAction) {
} }
} }
// Tests that the remove action has the right title and image.
TEST_F(ActionFactoryTest, RemoveAction) {
if (@available(iOS 13.0, *)) {
ActionFactory* factory =
[[ActionFactory alloc] initWithBrowser:test_browser_.get()
scenario:kTestMenuScenario];
UIImage* expectedImage = [UIImage imageNamed:@"remove"];
NSString* expectedTitle =
l10n_util::GetNSString(IDS_IOS_REMOVE_ACTION_TITLE);
UIAction* action = [factory actionToRemoveWithBlock:^{
}];
EXPECT_TRUE([expectedTitle isEqualToString:action.title]);
EXPECT_EQ(expectedImage, action.image);
}
}
// Tests that the edit action has the right title and image. // Tests that the edit action has the right title and image.
TEST_F(ActionFactoryTest, EditAction) { TEST_F(ActionFactoryTest, EditAction) {
if (@available(iOS 13.0, *)) { if (@available(iOS 13.0, *)) {
...@@ -227,13 +247,14 @@ TEST_F(ActionFactoryTest, EditAction) { ...@@ -227,13 +247,14 @@ TEST_F(ActionFactoryTest, EditAction) {
[[ActionFactory alloc] initWithBrowser:test_browser_.get() [[ActionFactory alloc] initWithBrowser:test_browser_.get()
scenario:kTestMenuScenario]; scenario:kTestMenuScenario];
UIImage* expectedImage = [UIImage imageNamed:@"edit"];
NSString* expectedTitle = l10n_util::GetNSString(IDS_IOS_EDIT_ACTION_TITLE); NSString* expectedTitle = l10n_util::GetNSString(IDS_IOS_EDIT_ACTION_TITLE);
UIAction* action = [factory actionToEditWithBlock:^{ UIAction* action = [factory actionToEditWithBlock:^{
}]; }];
EXPECT_TRUE([expectedTitle isEqualToString:action.title]); EXPECT_TRUE([expectedTitle isEqualToString:action.title]);
EXPECT_EQ(nil, action.image); EXPECT_EQ(expectedImage, action.image);
} }
} }
......
...@@ -11,3 +11,59 @@ imageset("copy_link_url") { ...@@ -11,3 +11,59 @@ imageset("copy_link_url") {
"copy_link_url.imageset/copy_link_url@3x.png", "copy_link_url.imageset/copy_link_url@3x.png",
] ]
} }
imageset("delete") {
sources = [
"delete.imageset/Contents.json",
"delete.imageset/delete@2x.png",
"delete.imageset/delete@3x.png",
]
}
imageset("edit") {
sources = [
"edit.imageset/Contents.json",
"edit.imageset/edit@2x.png",
"edit.imageset/edit@3x.png",
]
}
imageset("open_in_incognito") {
sources = [
"open_in_incognito.imageset/Contents.json",
"open_in_incognito.imageset/open_in_incognito@2x.png",
"open_in_incognito.imageset/open_in_incognito@3x.png",
]
}
imageset("open_in_new_tab") {
sources = [
"open_in_new_tab.imageset/Contents.json",
"open_in_new_tab.imageset/open_in_new_tab@2x.png",
"open_in_new_tab.imageset/open_in_new_tab@3x.png",
]
}
imageset("open_new_window") {
sources = [
"open_new_window.imageset/Contents.json",
"open_new_window.imageset/open_new_window@2x.png",
"open_new_window.imageset/open_new_window@3x.png",
]
}
imageset("remove") {
sources = [
"remove.imageset/Contents.json",
"remove.imageset/remove@2x.png",
"remove.imageset/remove@3x.png",
]
}
imageset("share") {
sources = [
"share.imageset/Contents.json",
"share.imageset/share@2x.png",
"share.imageset/share@3x.png",
]
}
{
"images" : [
{
"idiom" : "universal",
"filename" : "delete@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "delete@3x.png",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent": "template"
}
}
{
"images" : [
{
"idiom" : "universal",
"filename" : "edit@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "edit@3x.png",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent": "template"
}
}
{
"images" : [
{
"idiom" : "universal",
"filename" : "open_in_incognito@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "open_in_incognito@3x.png",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent": "template"
}
}
{
"images" : [
{
"idiom" : "universal",
"filename" : "open_in_new_tab@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "open_in_new_tab@3x.png",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent": "template"
}
}
{
"images" : [
{
"idiom" : "universal",
"filename" : "open_new_window@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "open_new_window@3x.png",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent": "template"
}
}
{
"images" : [
{
"idiom" : "universal",
"filename" : "remove@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "remove@3x.png",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent": "template"
}
}
{
"images" : [
{
"idiom" : "universal",
"filename" : "share@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "share@3x.png",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent": "template"
}
}
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