Commit a02e0495 authored by Xiao Yang's avatar Xiao Yang Committed by Commit Bot

Add support for notes and lists deeplinks.

1. Add method to get eid from deeplinks and append to lists&notes
mainview link url.
2. Update lists&notes url.
3. Add deeplink parameter "type" to support shopping list.

Bug: b/145951425
Change-Id: If063962ddd01e13d738e439f00a159249cea4e1f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1990147Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Commit-Queue: Xiao Yang <yanxiao@google.com>
Cr-Commit-Position: refs/heads/master@{#738400}
parent 350d205b
...@@ -27,6 +27,7 @@ constexpr char kActionParamKey[] = "action"; ...@@ -27,6 +27,7 @@ constexpr char kActionParamKey[] = "action";
constexpr char kCategoryParamKey[] = "category"; constexpr char kCategoryParamKey[] = "category";
constexpr char kClientIdParamKey[] = "clientId"; constexpr char kClientIdParamKey[] = "clientId";
constexpr char kDurationMsParamKey[] = "durationMs"; constexpr char kDurationMsParamKey[] = "durationMs";
constexpr char kEidParamKey[] = "eid";
constexpr char kHrefParamKey[] = "href"; constexpr char kHrefParamKey[] = "href";
constexpr char kIdParamKey[] = "id"; constexpr char kIdParamKey[] = "id";
constexpr char kIndexParamKey[] = "index"; constexpr char kIndexParamKey[] = "index";
...@@ -34,6 +35,7 @@ constexpr char kQueryParamKey[] = "q"; ...@@ -34,6 +35,7 @@ constexpr char kQueryParamKey[] = "q";
constexpr char kPageParamKey[] = "page"; constexpr char kPageParamKey[] = "page";
constexpr char kRelaunchParamKey[] = "relaunch"; constexpr char kRelaunchParamKey[] = "relaunch";
constexpr char kSourceParamKey[] = "source"; constexpr char kSourceParamKey[] = "source";
constexpr char kTypeParamKey[] = "type";
constexpr char kVeIdParamKey[] = "veId"; constexpr char kVeIdParamKey[] = "veId";
// Supported alarm/timer action deep link param values. // Supported alarm/timer action deep link param values.
...@@ -154,12 +156,14 @@ base::Optional<std::string> GetDeepLinkParam( ...@@ -154,12 +156,14 @@ base::Optional<std::string> GetDeepLinkParam(
{DeepLinkParam::kCategory, kCategoryParamKey}, {DeepLinkParam::kCategory, kCategoryParamKey},
{DeepLinkParam::kClientId, kClientIdParamKey}, {DeepLinkParam::kClientId, kClientIdParamKey},
{DeepLinkParam::kDurationMs, kDurationMsParamKey}, {DeepLinkParam::kDurationMs, kDurationMsParamKey},
{DeepLinkParam::kEid, kEidParamKey},
{DeepLinkParam::kHref, kHrefParamKey}, {DeepLinkParam::kHref, kHrefParamKey},
{DeepLinkParam::kId, kIdParamKey}, {DeepLinkParam::kId, kIdParamKey},
{DeepLinkParam::kIndex, kIndexParamKey}, {DeepLinkParam::kIndex, kIndexParamKey},
{DeepLinkParam::kPage, kPageParamKey}, {DeepLinkParam::kPage, kPageParamKey},
{DeepLinkParam::kQuery, kQueryParamKey}, {DeepLinkParam::kQuery, kQueryParamKey},
{DeepLinkParam::kRelaunch, kRelaunchParamKey}, {DeepLinkParam::kRelaunch, kRelaunchParamKey},
{DeepLinkParam::kType, kTypeParamKey},
{DeepLinkParam::kVeId, kVeIdParamKey}}; {DeepLinkParam::kVeId, kVeIdParamKey}};
const std::string& key = kDeepLinkParamKeys.at(param); const std::string& key = kDeepLinkParamKeys.at(param);
...@@ -310,17 +314,22 @@ bool IsDeepLinkUrl(const GURL& url) { ...@@ -310,17 +314,22 @@ bool IsDeepLinkUrl(const GURL& url) {
return GetDeepLinkType(url) != DeepLinkType::kUnsupported; return GetDeepLinkType(url) != DeepLinkType::kUnsupported;
} }
base::Optional<GURL> GetAssistantUrl(DeepLinkType type, base::Optional<GURL> GetAssistantUrl(
const base::Optional<std::string>& id) { DeepLinkType type,
const std::map<std::string, std::string>& params) {
std::string top_level_url; std::string top_level_url;
std::string by_id_url; std::string by_id_url;
switch (type) { switch (type) {
case DeepLinkType::kLists: case DeepLinkType::kLists: {
const auto& type = GetDeepLinkParam(params, DeepLinkParam::kType);
top_level_url = top_level_url =
std::string("https://assistant.google.com/lists/mainview"); std::string("https://assistant.google.com/lists/mainview");
by_id_url = std::string("https://assistant.google.com/lists/list/"); by_id_url = (type && type.value().compare("shopping") == 0)
? std::string("https://shoppinglist.google.com/lists/")
: std::string("https://assistant.google.com/lists/list/");
break; break;
}
case DeepLinkType::kNotes: case DeepLinkType::kNotes:
top_level_url = std::string( top_level_url = std::string(
"https://assistant.google.com/lists/mainview?note_tap=true"); "https://assistant.google.com/lists/mainview?note_tap=true");
...@@ -336,13 +345,17 @@ base::Optional<GURL> GetAssistantUrl(DeepLinkType type, ...@@ -336,13 +345,17 @@ base::Optional<GURL> GetAssistantUrl(DeepLinkType type,
return base::nullopt; return base::nullopt;
} }
const std::string url = const auto& id = GetDeepLinkParam(params, DeepLinkParam::kId);
(id && !id.value().empty()) ? (by_id_url + id.value()) : top_level_url; const auto& eid = GetDeepLinkParam(params, DeepLinkParam::kEid);
GURL url = (id && !id.value().empty()) ? GURL(by_id_url + id.value())
: GURL(top_level_url);
if (eid && !eid.value().empty())
url = net::AppendOrReplaceQueryParameter(url, kEidParamKey, eid.value());
// Source is currently assumed to be |Assistant|. If need be, we can make // Source is currently assumed to be |Assistant|. If need be, we can make
// |source| a deep link parameter in the future. // |source| a deep link parameter in the future.
constexpr char kDefaultSource[] = "Assistant"; constexpr char kDefaultSource[] = "Assistant";
return net::AppendOrReplaceQueryParameter(CreateLocalizedGURL(url), return net::AppendOrReplaceQueryParameter(CreateLocalizedGURL(url.spec()),
kSourceParamKey, kDefaultSource); kSourceParamKey, kDefaultSource);
} }
...@@ -379,10 +392,8 @@ base::Optional<GURL> GetWebUrl( ...@@ -379,10 +392,8 @@ base::Optional<GURL> GetWebUrl(
switch (type) { switch (type) {
case DeepLinkType::kLists: case DeepLinkType::kLists:
case DeepLinkType::kNotes: case DeepLinkType::kNotes:
case DeepLinkType::kReminders: { case DeepLinkType::kReminders:
const auto id = GetDeepLinkParam(params, DeepLinkParam::kId); return GetAssistantUrl(type, params);
return GetAssistantUrl(type, id);
}
case DeepLinkType::kSettings: case DeepLinkType::kSettings:
return CreateLocalizedGURL(kAssistantSettingsWebUrl); return CreateLocalizedGURL(kAssistantSettingsWebUrl);
case DeepLinkType::kUnsupported: case DeepLinkType::kUnsupported:
......
...@@ -44,12 +44,14 @@ enum class DeepLinkParam { ...@@ -44,12 +44,14 @@ enum class DeepLinkParam {
kCategory, // ga://proactive-suggestions?category=1 kCategory, // ga://proactive-suggestions?category=1
kClientId, // ga://reminders?action=edit&clientId=1 kClientId, // ga://reminders?action=edit&clientId=1
kDurationMs, // ga://alarm-timer?action=addTimeToTimer&durationMs=60000 kDurationMs, // ga://alarm-timer?action=addTimeToTimer&durationMs=60000
kEid, // ga://lists?eid=1
kHref, // ga://proactive-suggestions?action=cardClick&href=https://g.co/ kHref, // ga://proactive-suggestions?action=cardClick&href=https://g.co/
kIndex, // ga://proactive-suggestions?action=cardClick&index=1 kIndex, // ga://proactive-suggestions?action=cardClick&index=1
kId, // ga://alarm-timer?action=addTimeToTimer&id=1 kId, // ga://alarm-timer?action=addTimeToTimer&id=1
kPage, // ga://settings?page=googleAssistant kPage, // ga://settings?page=googleAssistant
kQuery, // ga://send-query?query=weather kQuery, // ga://send-query?query=weather
kRelaunch, // ga://onboarding?relaunch=true kRelaunch, // ga://onboarding?relaunch=true
kType, // ga://lists?id=1&type=shopping
kVeId, // ga://proactive-suggestions?action=cardClick&veId=1 kVeId, // ga://proactive-suggestions?action=cardClick&veId=1
}; };
...@@ -175,12 +177,13 @@ COMPONENT_EXPORT(ASSISTANT_UTIL) bool IsDeepLinkUrl(const GURL& url); ...@@ -175,12 +177,13 @@ COMPONENT_EXPORT(ASSISTANT_UTIL) bool IsDeepLinkUrl(const GURL& url);
// Returns the Assistant URL for the deep link of the specified |type|. A return // Returns the Assistant URL for the deep link of the specified |type|. A return
// value will only be present if the deep link type is one of {kLists, kNotes, // value will only be present if the deep link type is one of {kLists, kNotes,
// or kReminders}. If |id| is absent, the returned URL will be for the top-level // or kReminders}. If |id| is not contained in |params|, the returned URL will
// Assistant URL. Otherwise, the URL will correspond to the resource identified // be for the top-level Assistant URL. Otherwise, the URL will correspond to
// by |id|. // the resource identified by |id|.
COMPONENT_EXPORT(ASSISTANT_UTIL) COMPONENT_EXPORT(ASSISTANT_UTIL)
base::Optional<GURL> GetAssistantUrl(DeepLinkType type, base::Optional<GURL> GetAssistantUrl(
const base::Optional<std::string>& id); DeepLinkType type,
const std::map<std::string, std::string>& params);
// Returns the URL for the specified Chrome Settings |page|. If page is absent // Returns the URL for the specified Chrome Settings |page|. If page is absent
// or not allowed, the URL will be for top-level Chrome Settings. // or not allowed, the URL will be for top-level Chrome Settings.
......
...@@ -558,95 +558,128 @@ TEST_F(DeepLinkUtilTest, IsDeepLinkUrl) { ...@@ -558,95 +558,128 @@ TEST_F(DeepLinkUtilTest, IsDeepLinkUrl) {
} }
TEST_F(DeepLinkUtilTest, GetAssistantUrl) { TEST_F(DeepLinkUtilTest, GetAssistantUrl) {
using TestCase = std::pair<DeepLinkType, base::Optional<std::string>>; using TestCase = std::pair<DeepLinkType, std::map<std::string, std::string>>;
auto CreateTestCase = [](DeepLinkType type, base::Optional<std::string> id) { auto CreateTestCase = [](DeepLinkType type,
return std::make_pair(type, id); std::map<std::string, std::string> params) {
return std::make_pair(type, params);
}; };
auto CreateIgnoreCase = [](DeepLinkType type, auto CreateIgnoreCase = [](DeepLinkType type,
base::Optional<std::string> id) { std::map<std::string, std::string> params) {
return std::make_pair(std::make_pair(type, id), base::nullopt); return std::make_pair(std::make_pair(type, params), base::nullopt);
}; };
const std::map<TestCase, base::Optional<GURL>> test_cases = { const std::map<TestCase, base::Optional<GURL>> test_cases = {
// OK: Top-level lists. // OK: Top-level lists.
{CreateTestCase(DeepLinkType::kLists, /*id=*/base::nullopt), {CreateTestCase(DeepLinkType::kLists,
/*params=*/{{"eid", "112233"}}),
GURL("https://assistant.google.com/lists/" GURL("https://assistant.google.com/lists/"
"mainview?hl=en-US&source=Assistant")}, "mainview?eid=112233&hl=en-US&source=Assistant")},
{CreateTestCase(DeepLinkType::kLists, /*id=*/std::string()), {CreateTestCase(DeepLinkType::kLists,
/*params=*/{}),
GURL("https://assistant.google.com/lists/" GURL("https://assistant.google.com/lists/"
"mainview?hl=en-US&source=Assistant")}, "mainview?hl=en-US&source=Assistant")},
// OK: List by |id|. // OK: List by |id|.
{CreateTestCase(DeepLinkType::kLists, /*id=*/"123456"), {CreateTestCase(DeepLinkType::kLists,
/*params=*/
{{"eid", "112233"}, {"id", "123456"}}),
GURL("https://assistant.google.com/lists/list/" GURL("https://assistant.google.com/lists/list/"
"123456?hl=en-US&source=Assistant")}, "123456?eid=112233&hl=en-US&source=Assistant")},
// OK: Shoppinglist by |id|.
{CreateTestCase(DeepLinkType::kLists,
/*params=*/
{{"type", "shopping"}, {"id", "123456"}}),
GURL("https://shoppinglist.google.com/lists/123456"
"?hl=en-US&source=Assistant")},
// OK: Top-level notes. // OK: Top-level notes.
{CreateTestCase(DeepLinkType::kNotes, /*id=*/base::nullopt), {CreateTestCase(DeepLinkType::kNotes,
/*params=*/{{"eid", "112233"}}),
GURL("https://assistant.google.com/lists/" GURL("https://assistant.google.com/lists/"
"mainview?note_tap=true&hl=en-US&source=Assistant")}, "mainview?note_tap=true&eid=112233&hl=en-US&source=Assistant")},
{CreateTestCase(DeepLinkType::kNotes, /*id=*/std::string()), {CreateTestCase(DeepLinkType::kNotes,
/*params=*/{}),
GURL("https://assistant.google.com/lists/" GURL("https://assistant.google.com/lists/"
"mainview?note_tap=true&hl=en-US&source=Assistant")}, "mainview?note_tap=true&hl=en-US&source=Assistant")},
// OK: Note by |id|. // OK: Note by |id|.
{CreateTestCase(DeepLinkType::kNotes, /*id=*/"123456"), {CreateTestCase(DeepLinkType::kNotes,
/*params=*/
{{"eid", "112233"}, {"id", "123456"}}),
GURL("https://assistant.google.com/lists/note/" GURL("https://assistant.google.com/lists/note/"
"123456?hl=en-US&source=Assistant")}, "123456?eid=112233&hl=en-US&source=Assistant")},
// OK: Top-level reminders. // OK: Top-level reminders.
{CreateTestCase(DeepLinkType::kReminders, /*id=*/base::nullopt), {CreateTestCase(DeepLinkType::kReminders,
GURL("https://assistant.google.com/reminders/" /*params=*/{}),
"mainview?hl=en-US&source=Assistant")},
{CreateTestCase(DeepLinkType::kReminders, /*id=*/std::string()),
GURL("https://assistant.google.com/reminders/" GURL("https://assistant.google.com/reminders/"
"mainview?hl=en-US&source=Assistant")}, "mainview?hl=en-US&source=Assistant")},
// OK: Reminder by |id|. // OK: Reminder by |id|.
{CreateTestCase(DeepLinkType::kReminders, /*id=*/"123456"), {CreateTestCase(DeepLinkType::kReminders,
/*params=*/{{"id", "123456"}}),
GURL("https://assistant.google.com/reminders/id/" GURL("https://assistant.google.com/reminders/id/"
"123456?hl=en-US&source=Assistant")}, "123456?hl=en-US&source=Assistant")},
// IGNORE: Deep links of other types. // IGNORE: Deep links of other types.
CreateIgnoreCase(DeepLinkType::kUnsupported, /*id=*/base::nullopt), CreateIgnoreCase(DeepLinkType::kUnsupported,
CreateIgnoreCase(DeepLinkType::kUnsupported, /*id=*/std::string()), /*params=*/{}),
CreateIgnoreCase(DeepLinkType::kUnsupported, /*id=*/"123456"), CreateIgnoreCase(DeepLinkType::kUnsupported,
CreateIgnoreCase(DeepLinkType::kChromeSettings, /*id=*/base::nullopt), /*params=*/
CreateIgnoreCase(DeepLinkType::kChromeSettings, /*id=*/std::string()), {{"eid", "112233"}, {"id", "123456"}}),
CreateIgnoreCase(DeepLinkType::kChromeSettings, /*id=*/"123456"), CreateIgnoreCase(DeepLinkType::kChromeSettings,
CreateIgnoreCase(DeepLinkType::kFeedback, /*id=*/base::nullopt), /*params=*/{}),
CreateIgnoreCase(DeepLinkType::kFeedback, /*id=*/std::string()), CreateIgnoreCase(DeepLinkType::kChromeSettings,
CreateIgnoreCase(DeepLinkType::kFeedback, /*id=*/"123456"), /*params=*/
CreateIgnoreCase(DeepLinkType::kOnboarding, /*id=*/base::nullopt), {{"eid", "112233"}, {"id", "123456"}}),
CreateIgnoreCase(DeepLinkType::kOnboarding, /*id=*/std::string()), CreateIgnoreCase(DeepLinkType::kFeedback,
CreateIgnoreCase(DeepLinkType::kOnboarding, /*id=*/"123456"), /*params=*/{}),
CreateIgnoreCase(DeepLinkType::kQuery, /*id=*/base::nullopt), CreateIgnoreCase(DeepLinkType::kFeedback,
CreateIgnoreCase(DeepLinkType::kQuery, /*id=*/std::string()), /*params=*/
CreateIgnoreCase(DeepLinkType::kQuery, /*id=*/"123456"), {{"eid", "112233"}, {"id", "123456"}}),
CreateIgnoreCase(DeepLinkType::kScreenshot, /*id=*/base::nullopt), CreateIgnoreCase(DeepLinkType::kOnboarding,
CreateIgnoreCase(DeepLinkType::kScreenshot, /*id=*/std::string()), /*params=*/{}),
CreateIgnoreCase(DeepLinkType::kScreenshot, /*id=*/"123456"), CreateIgnoreCase(DeepLinkType::kOnboarding,
CreateIgnoreCase(DeepLinkType::kSettings, /*id=*/base::nullopt), /*params=*/
CreateIgnoreCase(DeepLinkType::kSettings, /*id=*/std::string()), {{"eid", "112233"}, {"id", "123456"}}),
CreateIgnoreCase(DeepLinkType::kSettings, /*id=*/"123456"), CreateIgnoreCase(DeepLinkType::kQuery,
CreateIgnoreCase(DeepLinkType::kTaskManager, /*id=*/base::nullopt), /*params=*/{}),
CreateIgnoreCase(DeepLinkType::kTaskManager, /*id=*/std::string()), CreateIgnoreCase(DeepLinkType::kQuery,
CreateIgnoreCase(DeepLinkType::kTaskManager, /*id=*/"123456"), /*params=*/
CreateIgnoreCase(DeepLinkType::kWhatsOnMyScreen, /*id=*/base::nullopt), {{"eid", "112233"}, {"id", "123456"}}),
CreateIgnoreCase(DeepLinkType::kWhatsOnMyScreen, /*id=*/std::string()), CreateIgnoreCase(DeepLinkType::kScreenshot,
CreateIgnoreCase(DeepLinkType::kWhatsOnMyScreen, /*id=*/"123456")}; /*params=*/{}),
CreateIgnoreCase(DeepLinkType::kScreenshot,
/*params=*/
{{"eid", "112233"}, {"id", "123456"}}),
CreateIgnoreCase(DeepLinkType::kSettings,
/*params=*/{}),
CreateIgnoreCase(DeepLinkType::kSettings,
/*params=*/
{{"eid", "112233"}, {"id", "123456"}}),
CreateIgnoreCase(DeepLinkType::kTaskManager,
/*params=*/{}),
CreateIgnoreCase(DeepLinkType::kTaskManager,
/*params=*/
{{"eid", "112233"}, {"id", "123456"}}),
CreateIgnoreCase(DeepLinkType::kWhatsOnMyScreen,
/*params=*/{}),
CreateIgnoreCase(DeepLinkType::kWhatsOnMyScreen,
/*params=*/
{{"eid", "112233"}, {"id", "123456"}})};
// For deep links that are not one of type {kLists, kNotes, kReminders}, we // For deep links that are not one of type {kLists, kNotes, kReminders}, we
// will hit NOTREACHED since this API isn't meant to be used in such cases. // will hit NOTREACHED since this API isn't meant to be used in such cases.
...@@ -660,7 +693,7 @@ TEST_F(DeepLinkUtilTest, GetAssistantUrl) { ...@@ -660,7 +693,7 @@ TEST_F(DeepLinkUtilTest, GetAssistantUrl) {
for (const auto& test_case : test_cases) { for (const auto& test_case : test_cases) {
const base::Optional<GURL>& expected = test_case.second; const base::Optional<GURL>& expected = test_case.second;
const base::Optional<GURL> actual = GetAssistantUrl( const base::Optional<GURL> actual = GetAssistantUrl(
/*type=*/test_case.first.first, /*id=*/test_case.first.second); /*type=*/test_case.first.first, /*params=*/test_case.first.second);
// Assert |has_value| equivalence. // Assert |has_value| equivalence.
ASSERT_EQ(expected, actual); ASSERT_EQ(expected, actual);
...@@ -697,11 +730,12 @@ TEST_F(DeepLinkUtilTest, GetChromeSettingsUrl) { ...@@ -697,11 +730,12 @@ TEST_F(DeepLinkUtilTest, GetChromeSettingsUrl) {
TEST_F(DeepLinkUtilTest, GetWebUrl) { TEST_F(DeepLinkUtilTest, GetWebUrl) {
const std::map<std::string, base::Optional<GURL>> test_cases = { const std::map<std::string, base::Optional<GURL>> test_cases = {
// OK: Supported web deep links. // OK: Supported web deep links.
{"googleassistant://lists", GURL("https://assistant.google.com/lists/" {"googleassistant://lists?eid=123456",
"mainview?hl=en-US&source=Assistant")},
{"googleassistant://notes",
GURL("https://assistant.google.com/lists/" GURL("https://assistant.google.com/lists/"
"mainview?note_tap=true&hl=en-US&source=Assistant")}, "mainview?eid=123456&hl=en-US&source=Assistant")},
{"googleassistant://notes?eid=123456",
GURL("https://assistant.google.com/lists/"
"mainview?note_tap=true&eid=123456&hl=en-US&source=Assistant")},
{"googleassistant://reminders", {"googleassistant://reminders",
GURL("https://assistant.google.com/reminders/" GURL("https://assistant.google.com/reminders/"
"mainview?hl=en-US&source=Assistant")}, "mainview?hl=en-US&source=Assistant")},
...@@ -709,12 +743,15 @@ TEST_F(DeepLinkUtilTest, GetWebUrl) { ...@@ -709,12 +743,15 @@ TEST_F(DeepLinkUtilTest, GetWebUrl) {
GURL("https://assistant.google.com/settings/mainpage?hl=en-US")}, GURL("https://assistant.google.com/settings/mainpage?hl=en-US")},
// OK: Parameterized deep links. // OK: Parameterized deep links.
{"googleassistant://lists?id=123456", {"googleassistant://lists?id=123456&eid=112233",
GURL("https://assistant.google.com/lists/list/" GURL("https://assistant.google.com/lists/list/"
"123456?eid=112233&hl=en-US&source=Assistant")},
{"googleassistant://lists?id=123456&type=shopping",
GURL("https://shoppinglist.google.com/lists/"
"123456?hl=en-US&source=Assistant")}, "123456?hl=en-US&source=Assistant")},
{"googleassistant://notes?id=123456", {"googleassistant://notes?id=123456&eid=112233",
GURL("https://assistant.google.com/lists/note/" GURL("https://assistant.google.com/lists/note/"
"123456?hl=en-US&source=Assistant")}, "123456?eid=112233&hl=en-US&source=Assistant")},
{"googleassistant://reminders?id=123456", {"googleassistant://reminders?id=123456",
GURL("https://assistant.google.com/reminders/id/" GURL("https://assistant.google.com/reminders/id/"
"123456?hl=en-US&source=Assistant")}, "123456?hl=en-US&source=Assistant")},
...@@ -769,6 +806,11 @@ TEST_F(DeepLinkUtilTest, GetWebUrlByType) { ...@@ -769,6 +806,11 @@ TEST_F(DeepLinkUtilTest, GetWebUrlByType) {
return std::make_pair(type, params); return std::make_pair(type, params);
}; };
// Creates a test case with multiple parameter.
auto CreateTestCaseWithParams = [](DeepLinkType type, DeepLinkParams params) {
return std::make_pair(type, params);
};
// Creates a test case with no parameters. // Creates a test case with no parameters.
auto CreateTestCase = [&CreateTestCaseWithParam](DeepLinkType type) { auto CreateTestCase = [&CreateTestCaseWithParam](DeepLinkType type) {
return CreateTestCaseWithParam(type); return CreateTestCaseWithParam(type);
...@@ -776,20 +818,26 @@ TEST_F(DeepLinkUtilTest, GetWebUrlByType) { ...@@ -776,20 +818,26 @@ TEST_F(DeepLinkUtilTest, GetWebUrlByType) {
const std::map<TestCase, base::Optional<GURL>> test_cases = { const std::map<TestCase, base::Optional<GURL>> test_cases = {
// OK: Supported web deep link types. // OK: Supported web deep link types.
{CreateTestCase(DeepLinkType::kLists),
GURL("https://assistant.google.com/lists/"
"mainview?hl=en-US&source=Assistant")},
{CreateTestCaseWithParam(DeepLinkType::kLists, {CreateTestCaseWithParam(DeepLinkType::kLists,
std::make_pair("id", "123456")), std::make_pair("eid", "123456")),
GURL("https://assistant.google.com/lists/"
"mainview?eid=123456&hl=en-US&source=Assistant")},
{CreateTestCaseWithParams(DeepLinkType::kLists,
{{"id", "123456"}, {"eid", "112233"}}),
GURL("https://assistant.google.com/lists/list/" GURL("https://assistant.google.com/lists/list/"
"123456?eid=112233&hl=en-US&source=Assistant")},
{CreateTestCaseWithParams(DeepLinkType::kLists,
{{"id", "123456"}, {"type", "shopping"}}),
GURL("https://shoppinglist.google.com/lists/"
"123456?hl=en-US&source=Assistant")}, "123456?hl=en-US&source=Assistant")},
{CreateTestCase(DeepLinkType::kNotes),
GURL("https://assistant.google.com/lists/"
"mainview?note_tap=true&hl=en-US&source=Assistant")},
{CreateTestCaseWithParam(DeepLinkType::kNotes, {CreateTestCaseWithParam(DeepLinkType::kNotes,
std::make_pair("id", "123456")), std::make_pair("eid", "123456")),
GURL("https://assistant.google.com/lists/"
"mainview?note_tap=true&eid=123456&hl=en-US&source=Assistant")},
{CreateTestCaseWithParams(DeepLinkType::kNotes,
{{"id", "123456"}, {"eid", "112233"}}),
GURL("https://assistant.google.com/lists/note/" GURL("https://assistant.google.com/lists/note/"
"123456?hl=en-US&source=Assistant")}, "123456?eid=112233&hl=en-US&source=Assistant")},
{CreateTestCase(DeepLinkType::kReminders), {CreateTestCase(DeepLinkType::kReminders),
GURL("https://assistant.google.com/reminders/" GURL("https://assistant.google.com/reminders/"
"mainview?hl=en-US&source=Assistant")}, "mainview?hl=en-US&source=Assistant")},
......
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