diff options
author | Constantin Shalnev <c.shalnev@corp.mail.ru> | 2016-02-03 16:14:12 +0300 |
---|---|---|
committer | Sergey Yershov <yershov@corp.mail.ru> | 2016-03-23 16:21:37 +0300 |
commit | 2a6fe823e26739c5cc298848519d9b9931f24de6 (patch) | |
tree | ed189a6267614cce07731d21020c6b784f981669 /storage/storage_integration_tests | |
parent | 706e9279cde965837c212a110e6b119790523579 (diff) |
[new downloader] fixed notes
Diffstat (limited to 'storage/storage_integration_tests')
-rw-r--r-- | storage/storage_integration_tests/storage_downloading_tests.cpp | 45 | ||||
-rw-r--r-- | storage/storage_integration_tests/storage_update_tests.cpp | 2 |
2 files changed, 27 insertions, 20 deletions
diff --git a/storage/storage_integration_tests/storage_downloading_tests.cpp b/storage/storage_integration_tests/storage_downloading_tests.cpp index f9ec57f381..2f906e2530 100644 --- a/storage/storage_integration_tests/storage_downloading_tests.cpp +++ b/storage/storage_integration_tests/storage_downloading_tests.cpp @@ -14,6 +14,7 @@ #include "base/string_utils.hpp" #include "base/thread.hpp" +#include "std/bind.hpp" #include "std/exception.hpp" #include "std/string.hpp" @@ -29,12 +30,29 @@ string const kTestWebServer = "http://new-search.mapswithme.com/"; string const kMapTestDir = "map-tests"; +class InterruptException : public exception {}; + void Update(LocalCountryFile const & localCountryFile) { TEST_EQUAL(localCountryFile.GetCountryName(), kCountryId, ()); } -class InterruptException : public exception {}; +void ChangeCountry(Storage & storage, TCountryId const & countryId) +{ + TEST_EQUAL(countryId, kCountryId, ()); + + if (!storage.IsDownloadInProgress()) + testing::StopEventLoop(); +} + +void InitStorage(Storage & storage, Storage::TProgressFunction const & onProgressFn) +{ + storage.Init(Update); + storage.RegisterAllLocalMaps(); + storage.RestoreDownloadQueue(); + storage.Subscribe(bind(&ChangeCountry, ref(storage), _1), onProgressFn); + storage.SetDownloadingUrlsForTesting({kTestWebServer}); +} } // namespace @@ -43,6 +61,7 @@ UNIT_TEST(SmallMwms_InterruptDownloadResumeDownload_Test) WritableDirChanger writableDirChanger(kMapTestDir); // Start download but interrupt it + try { Storage storage(COUNTRIES_MIGRATE_FILE); @@ -50,20 +69,14 @@ UNIT_TEST(SmallMwms_InterruptDownloadResumeDownload_Test) auto onProgressFn = [](TCountryId const & countryId, LocalAndRemoteSizeT const & mapSize) { + TEST_EQUAL(countryId, kCountryId, ()); // Interrupt download throw InterruptException(); }; - auto onChangeCountryFn = [&](TCountryId const & countryId) - { - if (!storage.IsDownloadInProgress()) - testing::StopEventLoop(); - }; + InitStorage(storage, onProgressFn); - storage.Init(Update); - storage.RegisterAllLocalMaps(); - storage.Subscribe(onChangeCountryFn, onProgressFn); - storage.SetDownloadingUrlsForTesting({kTestWebServer}); + TEST(!storage.IsDownloadInProgress(), ()); storage.DownloadNode(kCountryId); testing::RunEventLoop(); @@ -77,18 +90,12 @@ UNIT_TEST(SmallMwms_InterruptDownloadResumeDownload_Test) Storage storage(COUNTRIES_MIGRATE_FILE); - auto onProgressFn = [](TCountryId const & countryId, LocalAndRemoteSizeT const & mapSize) {}; - auto onChangeCountryFn = [&](TCountryId const & countryId) + auto onProgressFn = [](TCountryId const & countryId, LocalAndRemoteSizeT const & mapSize) { - if (!storage.IsDownloadInProgress()) - testing::StopEventLoop(); + TEST_EQUAL(countryId, kCountryId, ()); }; - storage.Init(Update); - storage.RegisterAllLocalMaps(); - storage.RestoreDownloadQueue(); - storage.Subscribe(onChangeCountryFn, onProgressFn); - storage.SetDownloadingUrlsForTesting({kTestWebServer}); + InitStorage(storage, onProgressFn); TEST(storage.IsDownloadInProgress(), ()); diff --git a/storage/storage_integration_tests/storage_update_tests.cpp b/storage/storage_integration_tests/storage_update_tests.cpp index b27b19c984..ccabab6dcc 100644 --- a/storage/storage_integration_tests/storage_update_tests.cpp +++ b/storage/storage_integration_tests/storage_update_tests.cpp @@ -65,7 +65,7 @@ string GetCountriesTxtWebUrl(string const version) string GetCountriesTxtFilePath() { - return GetPlatform().WritableDir() + "countries.txt"; + return my::JoinFoldersToPath(GetPlatform().WritableDir(), "countries.txt"); } string GetMwmFilePath(string const & version, TCountryId const & countryId) |