Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2016-03-30 17:03:26 +0300
committerVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2016-04-04 14:36:06 +0300
commit62e42c52ddb9a2d57b5c8ed2458f4cddade1d916 (patch)
tree30d80f0ca3389b9e5fccba505388c7d63925ced4 /storage/storage_integration_tests
parenta1b7e6df7cbddd2796b0c637318c63563b4db25c (diff)
Storage integration test on downloading and grouping disputed territories.
Diffstat (limited to 'storage/storage_integration_tests')
-rw-r--r--storage/storage_integration_tests/storage_http_tests.cpp125
-rw-r--r--storage/storage_integration_tests/storage_integration_tests.pro2
2 files changed, 106 insertions, 21 deletions
diff --git a/storage/storage_integration_tests/storage_http_tests.cpp b/storage/storage_integration_tests/storage_http_tests.cpp
index b24b15ad85..3f208c7c5f 100644
--- a/storage/storage_integration_tests/storage_http_tests.cpp
+++ b/storage/storage_integration_tests/storage_http_tests.cpp
@@ -24,22 +24,44 @@ using namespace storage;
namespace
{
string const kCountryId = "Angola";
+string const kDisputedCountryId1 = "Jerusalem";
+string const kDisputedCountryId2 = "Crimea";
+string const kDisputedCountryId3 = "Campo de Hielo Sur";
+string const kUndisputedCountryId = "Argentina_Buenos Aires_North";
-void Update(TCountryId const &, storage::Storage::TLocalFilePtr const localCountryFile)
+void Update(TCountryId const &, Storage::TLocalFilePtr const localCountryFile)
{
TEST_EQUAL(localCountryFile->GetCountryName(), kCountryId, ());
}
-} // namespace
+void UpdateWithoutChecks(TCountryId const &, Storage::TLocalFilePtr const /* localCountryFile */)
+{
+}
-UNIT_TEST(StorageDownloadNodeAndDeleteNodeTests)
+string const GetMwmFullPath(string const & countryId, string const & version)
{
- WritableDirChanger writableDirChanger(kMapTestDir);
+ return my::JoinFoldersToPath({GetPlatform().WritableDir(), version},
+ countryId + DATA_FILE_EXTENSION);
+}
- Storage storage(COUNTRIES_FILE);
+string const GetDownloadingFullPath(string const & countryId, string const & version)
+{
+ return my::JoinFoldersToPath({GetPlatform().WritableDir(), version},
+ kCountryId + DATA_FILE_EXTENSION READY_FILE_EXTENSION DOWNLOADING_FILE_EXTENSION);
+}
+
+string const GetResumeFullPath(string const & countryId, string const & version)
+{
+ return my::JoinFoldersToPath({GetPlatform().WritableDir(), version},
+ kCountryId + DATA_FILE_EXTENSION READY_FILE_EXTENSION RESUME_FILE_EXTENSION);
+}
+
+void InitStorage(Storage & storage, Storage::TUpdateCallback const & didDownload,
+ Storage::TProgressFunction const & progress)
+{
TEST(version::IsSingleMwm(storage.GetCurrentDataVersion()), ());
- auto ChangeCountryFunction = [&](TCountryId const & countryId)
+ auto const changeCountryFunction = [&](TCountryId const & /* countryId */)
{
if (!storage.IsDownloadInProgress())
{
@@ -48,7 +70,20 @@ UNIT_TEST(StorageDownloadNodeAndDeleteNodeTests)
}
};
- auto ProgressFunction = [&storage](TCountryId const & countryId, TLocalAndRemoteSize const & mapSize)
+ storage.Init(didDownload, [](TCountryId const &, Storage::TLocalFilePtr const){return false;});
+ storage.RegisterAllLocalMaps();
+ storage.Subscribe(changeCountryFunction, progress);
+ storage.SetDownloadingUrlsForTesting({kTestWebServer});
+}
+} // namespace
+
+UNIT_TEST(StorageDownloadNodeAndDeleteNodeTests)
+{
+ WritableDirChanger writableDirChanger(kMapTestDir);
+
+ Storage storage(COUNTRIES_FILE);
+
+ auto const progressFunction = [&storage](TCountryId const & countryId, TLocalAndRemoteSize const & mapSize)
{
NodeAttrs nodeAttrs;
storage.GetNodeAttrs(countryId, nodeAttrs);
@@ -58,28 +93,21 @@ UNIT_TEST(StorageDownloadNodeAndDeleteNodeTests)
TEST_EQUAL(countryId, kCountryId, (countryId));
};
- storage.Init(Update, [](TCountryId const &, storage::Storage::TLocalFilePtr const){return false;});
- storage.RegisterAllLocalMaps();
- storage.Subscribe(ChangeCountryFunction, ProgressFunction);
- storage.SetDownloadingUrlsForTesting({kTestWebServer});
+ InitStorage(storage, Update, progressFunction);
+
string const version = strings::to_string(storage.GetCurrentDataVersion());
tests_support::ScopedDir cleanupVersionDir(version);
- string const mwmFullPath = my::JoinFoldersToPath({GetPlatform().WritableDir(), version},
- kCountryId + DATA_FILE_EXTENSION);
- string const downloadingFullPath = my::JoinFoldersToPath(
- {GetPlatform().WritableDir(), version},
- kCountryId + DATA_FILE_EXTENSION READY_FILE_EXTENSION DOWNLOADING_FILE_EXTENSION);
- string const resumeFullPath = my::JoinFoldersToPath(
- {GetPlatform().WritableDir(), version},
- kCountryId + DATA_FILE_EXTENSION READY_FILE_EXTENSION RESUME_FILE_EXTENSION);
- Platform & platform = GetPlatform();
+ string const mwmFullPath = GetMwmFullPath(kCountryId, version);
+ string const downloadingFullPath = GetDownloadingFullPath(kCountryId, version);
+ string const resumeFullPath = GetResumeFullPath(kCountryId, version);
// Downloading to an empty directory.
storage.DownloadNode(kCountryId);
// Wait for downloading complete.
testing::RunEventLoop();
+ Platform & platform = GetPlatform();
TEST(platform.IsFileExistsByFullPath(mwmFullPath), ());
TEST(!platform.IsFileExistsByFullPath(downloadingFullPath), ());
TEST(!platform.IsFileExistsByFullPath(resumeFullPath), ());
@@ -94,3 +122,60 @@ UNIT_TEST(StorageDownloadNodeAndDeleteNodeTests)
storage.DeleteNode(kCountryId);
TEST(!platform.IsFileExistsByFullPath(mwmFullPath), ());
}
+
+UNIT_TEST(StorageDownloadAndDeleteDisputedNodeTests)
+{
+ WritableDirChanger writableDirChanger(kMapTestDir);
+
+ Storage storage(COUNTRIES_FILE);
+ auto const progressFunction = [&storage](TCountryId const & countryId,
+ TLocalAndRemoteSize const & mapSize)
+ {
+ NodeAttrs nodeAttrs;
+ storage.GetNodeAttrs(countryId, nodeAttrs);
+
+ TEST_EQUAL(mapSize.first, nodeAttrs.m_downloadingProgress.first, (countryId));
+ TEST_EQUAL(mapSize.second, nodeAttrs.m_downloadingProgress.second, (countryId));
+ };
+
+ InitStorage(storage, UpdateWithoutChecks, progressFunction);
+
+ string const version = strings::to_string(storage.GetCurrentDataVersion());
+ tests_support::ScopedDir cleanupVersionDir(version);
+
+ string const mwmFullPath1 = GetMwmFullPath(kDisputedCountryId1, version);
+ string const mwmFullPath2 = GetMwmFullPath(kDisputedCountryId2, version);
+ string const mwmFullPath3 = GetMwmFullPath(kDisputedCountryId3, version);
+ string const mwmFullPathUndisputed = GetMwmFullPath(kUndisputedCountryId, version);
+
+ // Downloading to an empty directory.
+ storage.DownloadNode(kDisputedCountryId1);
+ storage.DownloadNode(kDisputedCountryId2);
+ storage.DownloadNode(kDisputedCountryId3);
+ storage.DownloadNode(kUndisputedCountryId);
+ // Wait for downloading complete.
+ testing::RunEventLoop();
+
+ Platform & platform = GetPlatform();
+ TEST(platform.IsFileExistsByFullPath(mwmFullPath1), ());
+ TEST(platform.IsFileExistsByFullPath(mwmFullPath2), ());
+ TEST(platform.IsFileExistsByFullPath(mwmFullPath3), ());
+ TEST(platform.IsFileExistsByFullPath(mwmFullPathUndisputed), ());
+
+ TCountriesVec downloadedChildren;
+ TCountriesVec availChildren;
+ storage.GetChildrenInGroups(storage.GetRootId(), downloadedChildren, availChildren);
+
+ TCountriesVec const expectedDownloadedChildren = {"Argentina", kDisputedCountryId2, kDisputedCountryId1};
+ TEST_EQUAL(downloadedChildren, expectedDownloadedChildren, ());
+ TEST_EQUAL(availChildren.size(), 221, ());
+
+ storage.DeleteNode(kDisputedCountryId1);
+ storage.DeleteNode(kDisputedCountryId2);
+ storage.DeleteNode(kDisputedCountryId3);
+ storage.DeleteNode(kUndisputedCountryId);
+ TEST(!platform.IsFileExistsByFullPath(mwmFullPath1), ());
+ TEST(!platform.IsFileExistsByFullPath(mwmFullPath2), ());
+ TEST(!platform.IsFileExistsByFullPath(mwmFullPath3), ());
+ TEST(!platform.IsFileExistsByFullPath(mwmFullPathUndisputed), ());
+}
diff --git a/storage/storage_integration_tests/storage_integration_tests.pro b/storage/storage_integration_tests/storage_integration_tests.pro
index d1a60c60fd..d038ad45e4 100644
--- a/storage/storage_integration_tests/storage_integration_tests.pro
+++ b/storage/storage_integration_tests/storage_integration_tests.pro
@@ -35,4 +35,4 @@ SOURCES += \
storage_group_download_tests.cpp \
storage_http_tests.cpp \
storage_update_tests.cpp \
- test_defines.cpp
+ test_defines.cpp \