Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/map
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2015-09-25 18:23:26 +0300
committervng <viktor.govako@gmail.com>2015-09-25 18:23:26 +0300
commitbe305b23f0f85d53473da30e80d460adaeadad7a (patch)
treee5b337704aa09a06b5a4adaaa85834e0da1e2c5d /map
parent5fc4681e5449c00ba25cfc0882cac95155d76a33 (diff)
Review fixes.
Diffstat (limited to 'map')
-rw-r--r--map/feature_vec_model.hpp2
-rw-r--r--map/map_tests/mwm_set_test.cpp19
2 files changed, 15 insertions, 6 deletions
diff --git a/map/feature_vec_model.hpp b/map/feature_vec_model.hpp
index fce5e8b0e4..659a263c17 100644
--- a/map/feature_vec_model.hpp
+++ b/map/feature_vec_model.hpp
@@ -46,7 +46,7 @@ class FeaturesFetcher : public Index::Observer
}
/// Registers a new map.
- WARN_UNUSED_RESULT pair<MwmSet::MwmId, MwmSet::RegResult> RegisterMap(
+ pair<MwmSet::MwmId, MwmSet::RegResult> RegisterMap(
platform::LocalCountryFile const & localFile);
/// Deregisters a map denoted by file from internal records.
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