diff --git a/platform/platform_tests/CMakeLists.txt b/platform/platform_tests/CMakeLists.txt index 8ced9207a0..7ab06feeb3 100644 --- a/platform/platform_tests/CMakeLists.txt +++ b/platform/platform_tests/CMakeLists.txt @@ -7,6 +7,7 @@ set( apk_test.cpp country_file_tests.cpp downloader_tests/downloader_test.cpp + downloader_utils_tests.cpp get_text_by_id_tests.cpp jansson_test.cpp language_test.cpp diff --git a/platform/platform_tests/downloader_utils_tests.cpp b/platform/platform_tests/downloader_utils_tests.cpp new file mode 100644 index 0000000000..28057758da --- /dev/null +++ b/platform/platform_tests/downloader_utils_tests.cpp @@ -0,0 +1,37 @@ +#include "testing/testing.hpp" + +#include "platform/downloader_utils.hpp" +#include "platform/local_country_file_utils.hpp" +#include "platform/mwm_version.hpp" + +UNIT_TEST(UrlConvertionTest) +{ + { + std::string const mwmName = "Luna"; + int64_t const dataVersion = version::FOR_TESTING_MWM1; + int64_t const diffVersion = 0; + MapFileType const fileType = MapFileType::Map; + + auto const path = + platform::GetFileDownloadPath(dataVersion, platform::CountryFile(mwmName), fileType); + + auto const url = downloader::GetFileDownloadUrl(mwmName, dataVersion, diffVersion); + auto const resultPath = downloader::GetFilePathByUrl(url); + + TEST_EQUAL(path, resultPath, ()); + } + { + std::string const mwmName = "Luna"; + int64_t const dataVersion = version::FOR_TESTING_MWM2; + int64_t const diffVersion = version::FOR_TESTING_MWM1; + MapFileType const fileType = MapFileType::Diff; + + auto const path = + platform::GetFileDownloadPath(dataVersion, platform::CountryFile(mwmName), fileType); + + auto const url = downloader::GetFileDownloadUrl(mwmName, dataVersion, diffVersion); + auto const resultPath = downloader::GetFilePathByUrl(url); + + TEST_EQUAL(path, resultPath, ()); + } +}