diff options
Diffstat (limited to 'map/map_tests')
-rw-r--r-- | map/map_tests/map_tests.pro | 1 | ||||
-rw-r--r-- | map/map_tests/mwm_set_test.cpp | 49 |
2 files changed, 50 insertions, 0 deletions
diff --git a/map/map_tests/map_tests.pro b/map/map_tests/map_tests.pro index 17df03d4dc..50d789ea1a 100644 --- a/map/map_tests/map_tests.pro +++ b/map/map_tests/map_tests.pro @@ -36,6 +36,7 @@ SOURCES += \ kmz_unarchive_test.cpp \ mwm_url_tests.cpp \ navigator_test.cpp \ + mwm_set_test.cpp \ !linux* { SOURCES += working_time_tests.cpp \ diff --git a/map/map_tests/mwm_set_test.cpp b/map/map_tests/mwm_set_test.cpp new file mode 100644 index 0000000000..3ea80b0536 --- /dev/null +++ b/map/map_tests/mwm_set_test.cpp @@ -0,0 +1,49 @@ +#include "testing/testing.hpp" + +#include "indexer/index.hpp" + +#include "platform/local_country_file_utils.hpp" +#include "platform/platform.hpp" + +#ifndef OMIM_OS_WINDOWS +#include <sys/stat.h> +#endif + + +using namespace platform; +using namespace my; + +#ifndef OMIM_OS_WINDOWS +UNIT_TEST(MwmSet_FileSystemErrors) +{ + string const dir = GetPlatform().WritableDir(); + + CountryFile file("minsk-pass"); + LocalCountryFile localFile(dir, file, 0); + TEST(CountryIndexes::DeleteFromDisk(localFile), ()); + + LogLevel oldLevel = g_LogAbortLevel; + g_LogAbortLevel = LCRITICAL; + + // Remove writable permission. + int const readOnlyMode = S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH; + TEST_EQUAL(chmod(dir.c_str(), readOnlyMode), 0, ()); + + Index index; + auto p = index.RegisterMap(localFile); + TEST_EQUAL(p.second, Index::RegResult::Success, ()); + + TEST(index.GetMwmIdByCountryFile(file) != Index::MwmId(), ()); + + TEST(!index.GetMwmHandleById(p.first).IsAlive(), ()); + + vector<shared_ptr<MwmInfo>> infos; + index.GetMwmsInfo(infos); + TEST(infos.empty(), ()); + + // Restore writable permission. + TEST_EQUAL(chmod(dir.c_str(), readOnlyMode | S_IWUSR), 0, ()); + + g_LogAbortLevel = oldLevel; +} +#endif |