diff options
author | vng <viktor.govako@gmail.com> | 2015-09-25 18:23:26 +0300 |
---|---|---|
committer | vng <viktor.govako@gmail.com> | 2015-09-25 18:23:26 +0300 |
commit | be305b23f0f85d53473da30e80d460adaeadad7a (patch) | |
tree | e5b337704aa09a06b5a4adaaa85834e0da1e2c5d /map/map_tests | |
parent | 5fc4681e5449c00ba25cfc0882cac95155d76a33 (diff) |
Review fixes.
Diffstat (limited to 'map/map_tests')
-rw-r--r-- | map/map_tests/mwm_set_test.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/map/map_tests/mwm_set_test.cpp b/map/map_tests/mwm_set_test.cpp index 3ea80b0536..d3919c19c8 100644 --- a/map/map_tests/mwm_set_test.cpp +++ b/map/map_tests/mwm_set_test.cpp @@ -5,6 +5,8 @@ #include "platform/local_country_file_utils.hpp" #include "platform/platform.hpp" +#include "base/scope_guard.hpp" + #ifndef OMIM_OS_WINDOWS #include <sys/stat.h> #endif @@ -22,6 +24,7 @@ UNIT_TEST(MwmSet_FileSystemErrors) LocalCountryFile localFile(dir, file, 0); TEST(CountryIndexes::DeleteFromDisk(localFile), ()); + // Maximum level to check exception handling logic. LogLevel oldLevel = g_LogAbortLevel; g_LogAbortLevel = LCRITICAL; @@ -29,21 +32,27 @@ UNIT_TEST(MwmSet_FileSystemErrors) int const readOnlyMode = S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH; TEST_EQUAL(chmod(dir.c_str(), readOnlyMode), 0, ()); + auto restoreFn = [oldLevel, &dir, readOnlyMode] () + { + g_LogAbortLevel = oldLevel; + TEST_EQUAL(chmod(dir.c_str(), readOnlyMode | S_IWUSR), 0, ()); + }; + MY_SCOPE_GUARD(restoreGuard, restoreFn); + Index index; auto p = index.RegisterMap(localFile); TEST_EQUAL(p.second, Index::RegResult::Success, ()); + // Registering should pass ok. TEST(index.GetMwmIdByCountryFile(file) != Index::MwmId(), ()); + // Getting handle causes feature offsets index building which should fail + // because of write permissions. TEST(!index.GetMwmHandleById(p.first).IsAlive(), ()); + // Map is automatically deregistered after the fail. 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 |