forked from organicmaps/organicmaps
[Old map downloader] Add separates dirictories for tests
This commit is contained in:
parent
8fc7f11f97
commit
b3e631d645
4 changed files with 48 additions and 9 deletions
|
@ -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 = [&]()
|
||||
{
|
||||
|
|
|
@ -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 \
|
||||
|
|
27
storage/storage_tests/write_dir_changer.cpp
Normal file
27
storage/storage_tests/write_dir_changer.cpp
Normal file
|
@ -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);
|
||||
}
|
12
storage/storage_tests/write_dir_changer.hpp
Normal file
12
storage/storage_tests/write_dir_changer.hpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include "std/string.hpp"
|
||||
|
||||
class WritableDirChanger
|
||||
{
|
||||
public:
|
||||
WritableDirChanger(string testDir);
|
||||
~WritableDirChanger();
|
||||
|
||||
private:
|
||||
string const m_writableDirBeforeTest;
|
||||
string const m_testDirFullPath;
|
||||
};
|
Loading…
Add table
Reference in a new issue