diff options
author | Sergey Yershov <yershov@corp.mail.ru> | 2016-01-26 17:19:05 +0300 |
---|---|---|
committer | Sergey Yershov <yershov@corp.mail.ru> | 2016-03-23 16:15:32 +0300 |
commit | b3e631d645acf098dd388ca66c9c0205990b3064 (patch) | |
tree | 0a9ab38f789b4d1bea8bf270a475f490780b044c /storage | |
parent | 8fc7f11f97a1721bb65e69c4456e8c060fcfa06d (diff) |
[Old map downloader] Add separates dirictories for tests
Diffstat (limited to 'storage')
-rw-r--r-- | storage/storage_tests/migrate_tests.cpp | 16 | ||||
-rw-r--r-- | storage/storage_tests/storage_tests.pro | 2 | ||||
-rw-r--r-- | storage/storage_tests/write_dir_changer.cpp | 27 | ||||
-rw-r--r-- | storage/storage_tests/write_dir_changer.hpp | 12 |
4 files changed, 48 insertions, 9 deletions
diff --git a/storage/storage_tests/migrate_tests.cpp b/storage/storage_tests/migrate_tests.cpp index 83232f4844..16841cf20e 100644 --- a/storage/storage_tests/migrate_tests.cpp +++ b/storage/storage_tests/migrate_tests.cpp @@ -2,6 +2,8 @@ #include "map/framework.hpp" +#include "write_dir_changer.hpp" + #include <QtCore/QCoreApplication> using namespace platform; @@ -9,13 +11,8 @@ using namespace platform; UNIT_TEST(StorageTest_FastMigrate) { // Set clear state. - { - Settings::Clear(); - Framework f; - auto & s = f.Storage(); - s.DeleteAllLocalMaps(); - Settings::Clear(); - } + string const kMapTestDir = "map-tests"; + WritableDirChanger writableDirChanger(kMapTestDir); Framework f; auto & s = f.Storage(); @@ -29,12 +26,13 @@ UNIT_TEST(StorageTest_FastMigrate) UNIT_TEST(StorageTests_Migrate) { - Settings::Clear(); + string const kMapTestDir = "map-tests"; + WritableDirChanger writableDirChanger(kMapTestDir); + Settings::Set("DisableFastMigrate", true); Framework f; auto & s = f.Storage(); - s.DeleteAllLocalMaps(); auto cleanup = [&]() { diff --git a/storage/storage_tests/storage_tests.pro b/storage/storage_tests/storage_tests.pro index c5576215ef..3fb9cd1e24 100644 --- a/storage/storage_tests/storage_tests.pro +++ b/storage/storage_tests/storage_tests.pro @@ -28,6 +28,7 @@ HEADERS += \ fake_map_files_downloader.hpp \ task_runner.hpp \ test_map_files_downloader.hpp \ + write_dir_changer.hpp \ SOURCES += \ ../../testing/testingmain.cpp \ @@ -39,3 +40,4 @@ SOURCES += \ storage_tests.cpp \ task_runner.cpp \ test_map_files_downloader.cpp \ + write_dir_changer.cpp \ diff --git a/storage/storage_tests/write_dir_changer.cpp b/storage/storage_tests/write_dir_changer.cpp new file mode 100644 index 0000000000..16748894e6 --- /dev/null +++ b/storage/storage_tests/write_dir_changer.cpp @@ -0,0 +1,27 @@ +#include "testing/testing.hpp" + +#include "write_dir_changer.hpp" + +#include "platform/platform.hpp" + +#include "coding/file_name_utils.hpp" +#include "coding/internal/file_data.hpp" + +WritableDirChanger::WritableDirChanger(string testDir) + : m_writableDirBeforeTest(GetPlatform().WritableDir()) + , m_testDirFullPath(m_writableDirBeforeTest + testDir) +{ + Platform & platform = GetPlatform(); + platform.RmDirRecursively(m_testDirFullPath); + TEST(!platform.IsFileExistsByFullPath(m_testDirFullPath), ()); + TEST_EQUAL(Platform::ERR_OK, platform.MkDir(m_testDirFullPath), ()); + platform.SetWritableDirForTests(m_testDirFullPath); +} + +WritableDirChanger::~WritableDirChanger() +{ + Platform & platform = GetPlatform(); + string const writableDirForTest = platform.WritableDir(); + platform.SetWritableDirForTests(m_writableDirBeforeTest); + platform.RmDirRecursively(writableDirForTest); +} diff --git a/storage/storage_tests/write_dir_changer.hpp b/storage/storage_tests/write_dir_changer.hpp new file mode 100644 index 0000000000..78595d45f2 --- /dev/null +++ b/storage/storage_tests/write_dir_changer.hpp @@ -0,0 +1,12 @@ +#include "std/string.hpp" + +class WritableDirChanger +{ +public: + WritableDirChanger(string testDir); + ~WritableDirChanger(); + +private: + string const m_writableDirBeforeTest; + string const m_testDirFullPath; +}; |