diff options
author | Aleksey Belouosv <aleksey@maps.me> | 2018-08-09 14:59:10 +0300 |
---|---|---|
committer | Aleksey Belousov <beloal@users.noreply.github.com> | 2018-08-10 20:16:14 +0300 |
commit | 0a662f745c23e74efe9212cfc2857a8f14ad6a8a (patch) | |
tree | ee7e0f1ec9f280f5a636bf6a6ce0db8b4f061b6d /map | |
parent | cea09e06f06295ecd55ee75fe4842d20dd080648 (diff) |
add catalog deeplink tests
Diffstat (limited to 'map')
-rw-r--r-- | map/map_tests/mwm_url_tests.cpp | 27 | ||||
-rw-r--r-- | map/mwm_url.cpp | 3 |
2 files changed, 30 insertions, 0 deletions
diff --git a/map/map_tests/mwm_url_tests.cpp b/map/map_tests/mwm_url_tests.cpp index 5c05a794b9..9477fff791 100644 --- a/map/map_tests/mwm_url_tests.cpp +++ b/map/map_tests/mwm_url_tests.cpp @@ -55,6 +55,7 @@ public: return m_m->GetUserMarkIds(type).size(); } + CatalogItem const & GetCatalogItem() const { return m_api.GetCatalogItem(); } vector<RoutePoint> GetRoutePoints() const { return m_api.GetRoutePoints(); } url_scheme::SearchRequest const & GetSearchRequest() const { return m_api.GetSearchRequest(); } string const & GetGlobalBackUrl() const { return m_api.GetGlobalBackUrl(); } @@ -139,6 +140,32 @@ UNIT_TEST(RouteApiSmoke) TEST(test.TestRouteType("vehicle"), ()); } +UNIT_TEST(CatalogueApiSmoke) +{ + string const uriString = "mapsme://catalogue?id=440f02e5-ff38-45ed-95c0-44587c9a5fc7&name=CatalogGroupName"; + TEST(Uri(uriString).IsValid(), ()); + + ApiTest test(uriString); + TEST(test.IsValid(), ()); + + auto const & catalogItem = test.GetCatalogItem(); + TEST_EQUAL(catalogItem.m_id, "440f02e5-ff38-45ed-95c0-44587c9a5fc7", ()); + TEST_EQUAL(catalogItem.m_name, "CatalogGroupName", ()); +} + +UNIT_TEST(CatalogueApiInvalidUrl) +{ + Framework f(kFrameworkParams); + TEST(!IsValid(f, "mapsme://catalogue?"), ("id parameter is required")); + TEST(IsValid(f, "mapsme://catalogue?id=440f02e5-ff38-45ed-95c0-44587c9a5fc7"), ("Name is optional")); + TEST(IsValid(f, "mapsme://catalogue?id=440f02e5-ff38-45ed-95c0-44587c9a5fc7&name=CatalogGroupName&otherExtraParam=xyz"), + ("We shouldn't fail on extra params")); + TEST(IsValid(f, "mapsme://catalogue?name=CatalogGroupName&id=440f02e5-ff38-45ed-95c0-44587c9a5fc7"), + ("parameter position doesn't matter")); + TEST(!IsValid(f, "mapsme://catalogue?ID=440f02e5-ff38-45ed-95c0-44587c9a5fc7"), + ("The parser is case sensitive")); +} + UNIT_TEST(SearchApiSmoke) { string const uriString = "mapsme://search?query=fff&cll=1,1&locale=ru&map"; diff --git a/map/mwm_url.cpp b/map/mwm_url.cpp index 393cbd94aa..258f00829a 100644 --- a/map/mwm_url.cpp +++ b/map/mwm_url.cpp @@ -278,6 +278,9 @@ ParsedMapApi::ParsingResult ParsedMapApi::Parse(Uri const & uri) if (!result) return ParsingResult::Incorrect; + if (item.m_id.empty()) + return ParsingResult::Incorrect; + m_catalogItem = item; return ParsingResult::Catalogue; } |