summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-02-09 11:16:55 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-02-10 15:40:20 -0800
commit591012401072e63b89071787d90bf5ae4362dca1 (patch)
tree829857bd6e188215c4cb19af4db17b5199d34e12 /test
parentff15bd51b94c96f169f0b3800fa04a368c5834c6 (diff)
downloadqtlocation-mapboxgl-591012401072e63b89071787d90bf5ae4362dca1.tar.gz
[core] Reset SQLite statements after use in order to release locks
Diffstat (limited to 'test')
-rw-r--r--test/storage/offline_database.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/storage/offline_database.cpp b/test/storage/offline_database.cpp
index 2018f6a40b..4af262deb1 100644
--- a/test/storage/offline_database.cpp
+++ b/test/storage/offline_database.cpp
@@ -7,6 +7,7 @@
#include <gtest/gtest.h>
#include <sqlite3.h>
+#include <thread>
namespace {
@@ -448,3 +449,34 @@ TEST(OfflineDatabase, CreateRegionInfiniteMaxZoom) {
EXPECT_EQ(0, region.getDefinition().minZoom);
EXPECT_EQ(INFINITY, region.getDefinition().maxZoom);
}
+
+TEST(OfflineDatabase, ConcurrentUse) {
+ using namespace mbgl;
+
+ createDir("test/fixtures/database");
+ deleteFile("test/fixtures/database/offline.db");
+
+ OfflineDatabase db1("test/fixtures/database/offline.db");
+ OfflineDatabase db2("test/fixtures/database/offline.db");
+
+ Resource resource { Resource::Style, "http://example.com/" };
+ Response response;
+ response.noContent = true;
+
+ std::thread thread1([&] {
+ for (auto i = 0; i < 100; i++) {
+ db1.put(resource, response);
+ EXPECT_TRUE(bool(db1.get(resource)));
+ }
+ });
+
+ std::thread thread2([&] {
+ for (auto i = 0; i < 100; i++) {
+ db2.put(resource, response);
+ EXPECT_TRUE(bool(db2.get(resource)));
+ }
+ });
+
+ thread1.join();
+ thread2.join();
+}