diff --git a/platform/platform_tests_support/scoped_mwm.cpp b/platform/platform_tests_support/scoped_mwm.cpp index fce8ee80df..b8f7dc3743 100644 --- a/platform/platform_tests_support/scoped_mwm.cpp +++ b/platform/platform_tests_support/scoped_mwm.cpp @@ -6,8 +6,6 @@ #include "platform/mwm_version.hpp" -#include "testing/testing.hpp" - #include "coding/file_writer.hpp" #include "coding/file_container.hpp" #include "coding/internal/file_data.hpp" @@ -17,38 +15,21 @@ namespace platform { namespace tests_support { -ScopedMwm::ScopedMwm(string const & fullPath) : m_fullPath(fullPath), m_reset(false) +ScopedMwm::ScopedMwm(string const & relativePath) : m_file(relativePath, "") { + DataHeader header; { - DataHeader header; + FilesContainerW container(m_file.GetFullPath()); + + // Each writer must be in it's own scope to avoid conflicts on the final write. { - FilesContainerW container(GetFullPath()); - - //Each writer must be in it's own scope to avoid conflicts on the final write. - { - FileWriter versionWriter =container.GetWriter(VERSION_FILE_TAG); - version::WriteVersion(versionWriter); - } - { - FileWriter w = container.GetWriter(HEADER_FILE_TAG); - header.Save(w); - } + FileWriter versionWriter = container.GetWriter(VERSION_FILE_TAG); + version::WriteVersion(versionWriter); } - } - TEST(Exists(), ("Can't create test file", GetFullPath())); -} -ScopedMwm::~ScopedMwm() -{ - if (m_reset) - return; - if (!Exists()) - { - LOG(LWARNING, ("File", GetFullPath(), "was deleted before dtor of ScopedMwm.")); - return; + FileWriter w = container.GetWriter(HEADER_FILE_TAG); + header.Save(w); } - if (!my::DeleteFileX(GetFullPath())) - LOG(LWARNING, ("Can't remove test file:", GetFullPath())); } } // namespace tests_support } // namespace platfotm diff --git a/platform/platform_tests_support/scoped_mwm.hpp b/platform/platform_tests_support/scoped_mwm.hpp index d4e2d39c08..0197c6304a 100644 --- a/platform/platform_tests_support/scoped_mwm.hpp +++ b/platform/platform_tests_support/scoped_mwm.hpp @@ -1,6 +1,6 @@ #pragma once -#include "platform/platform.hpp" +#include "scoped_file.hpp" #include "base/macros.hpp" @@ -15,19 +15,9 @@ class ScopedFile; class ScopedMwm { public: - ScopedMwm(string const & fullPath); - - inline string const & GetFullPath() const { return m_fullPath; } - - inline void Reset() { m_reset = true; } - - inline bool Exists() const { return GetPlatform().IsFileExistsByFullPath(GetFullPath()); } - - ~ScopedMwm(); - + ScopedMwm(string const & relativePath); private: - string const m_fullPath; - bool m_reset; + ScopedFile m_file; DISALLOW_COPY_AND_MOVE(ScopedMwm); }; diff --git a/routing/routing_tests/osrm_router_test.cpp b/routing/routing_tests/osrm_router_test.cpp index 9d36d02bed..e05f7f271d 100644 --- a/routing/routing_tests/osrm_router_test.cpp +++ b/routing/routing_tests/osrm_router_test.cpp @@ -59,7 +59,8 @@ void TestMapping(InputDataT const & data, platform::CountryFile country("TestCountry"); platform::LocalCountryFile localFile(GetPlatform().WritableDir(), country, 0 /* version */); localFile.SyncWithDisk(); - platform::tests_support::ScopedMwm mapMwm(localFile.GetPath(MapOptions::Map)); + platform::tests_support::ScopedMwm mapMwm( + localFile.GetCountryFile().GetNameWithExt(MapOptions::Map)); static char const ftSegsPath[] = "test1.tmp"; platform::CountryIndexes::PreparePlaceOnDisk(localFile);