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 16:22:48 +0300
committervng <viktor.govako@gmail.com>2015-09-25 17:17:52 +0300
commit25aaa05cefa9ecdd4ce6e7893786b4bf0eec5366 (patch)
tree1a988724f19463c79b18cbfa738bed7f5c7e26c8 /map
parentc56f4c20b946bf62831e917a695d4e6c7861fdd9 (diff)
[mwm set] Handle file system exceptions when building feature offsets index.
Diffstat (limited to 'map')
-rw-r--r--map/map_tests/map_tests.pro1
-rw-r--r--map/map_tests/mwm_set_test.cpp49
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