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:
-rw-r--r--storage/storage_integration_tests/storage_downloading_tests.cpp45
-rw-r--r--storage/storage_integration_tests/storage_update_tests.cpp2
-rw-r--r--testing/testing.hpp6
-rw-r--r--testing/testingmain.cpp12
4 files changed, 34 insertions, 31 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)
diff --git a/testing/testing.hpp b/testing/testing.hpp
index 6bbfe3b0ef..c8110f15d0 100644
--- a/testing/testing.hpp
+++ b/testing/testing.hpp
@@ -42,9 +42,9 @@ namespace my
namespace testing
{
- void RunEventLoop();
- void StopEventLoop();
-} // namespace testing
+void RunEventLoop();
+void StopEventLoop();
+} // namespace testing
// This struct contains parsed command line options. It may contain pointers to argc contents.
struct CommandLineOptions
diff --git a/testing/testingmain.cpp b/testing/testingmain.cpp
index 1d081b1b94..4b66b99847 100644
--- a/testing/testingmain.cpp
+++ b/testing/testingmain.cpp
@@ -37,23 +37,19 @@ namespace testing
void RunEventLoop()
{
-#ifdef OMIM_OS_IPHONE_DEVICE
+#if defined(OMIM_OS_IPHONE_DEVICE)
CFRunLoopRun();
-#else
-# ifdef QAPP
+#elif defined (QAPP)
QAPP::exec();
-# endif
#endif
}
void StopEventLoop()
{
-#ifdef OMIM_OS_IPHONE_DEVICE
+#if defined(OMIM_OS_IPHONE_DEVICE)
CFRunLoopStop(CFRunLoopGetMain());
-#else
-# ifdef QAPP
+#elif defined(QAPP)
QAPP::exit();
-# endif
#endif
}