summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2020-01-27 11:58:50 +0200
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2020-01-27 12:00:45 +0200
commitfcf1be65b4e45191f1aaa910b3452cc2f14ea75e (patch)
treed3954831552037c3feb6c52f2154c80ee77452d5
parent7d0f5c8996816b09d26d66603746a354f8ad332d (diff)
downloadqtlocation-mapboxgl-upstream/alexshalamov_dbfs_pause_resume.tar.gz
[core] Add unit test for pausing & resuming database fsupstream/alexshalamov_dbfs_pause_resume
-rw-r--r--next/test/CMakeLists.txt1
-rw-r--r--test/storage/database_file_source.test.cpp25
-rw-r--r--test/test-files.json1
3 files changed, 27 insertions, 0 deletions
diff --git a/next/test/CMakeLists.txt b/next/test/CMakeLists.txt
index 11d108bf3d..cb0519ade9 100644
--- a/next/test/CMakeLists.txt
+++ b/next/test/CMakeLists.txt
@@ -35,6 +35,7 @@ add_library(
${MBGL_ROOT}/test/src/mbgl/test/test.cpp
${MBGL_ROOT}/test/src/mbgl/test/util.cpp
${MBGL_ROOT}/test/storage/asset_file_source.test.cpp
+ ${MBGL_ROOT}/test/storage/database_file_source.test.cpp
${MBGL_ROOT}/test/storage/headers.test.cpp
${MBGL_ROOT}/test/storage/http_file_source.test.cpp
${MBGL_ROOT}/test/storage/local_file_source.test.cpp
diff --git a/test/storage/database_file_source.test.cpp b/test/storage/database_file_source.test.cpp
new file mode 100644
index 0000000000..579e9a8c57
--- /dev/null
+++ b/test/storage/database_file_source.test.cpp
@@ -0,0 +1,25 @@
+#include <mbgl/storage/file_source_manager.hpp>
+#include <mbgl/storage/resource.hpp>
+#include <mbgl/storage/resource_options.hpp>
+#include <mbgl/test/util.hpp>
+#include <mbgl/util/run_loop.hpp>
+#include <mbgl/util/timer.hpp>
+
+#include <gtest/gtest.h>
+
+using namespace mbgl;
+
+TEST(DatabaseFileSource, PauseResume) {
+ util::RunLoop loop;
+
+ auto dbfs = FileSourceManager::get()->getFileSource(FileSourceType::Database, ResourceOptions{});
+ dbfs->pause();
+
+ const Resource res{Resource::Unknown, "http://127.0.0.1:3000/test", {}, Resource::LoadingMethod::CacheOnly};
+ auto req = dbfs->request(res, [&](const Response&) { loop.stop(); });
+
+ util::Timer resumeTimer;
+ resumeTimer.start(Milliseconds(5), Duration::zero(), [dbfs] { dbfs->resume(); });
+
+ loop.run();
+} \ No newline at end of file
diff --git a/test/test-files.json b/test/test-files.json
index 8691583765..3a4ad95722 100644
--- a/test/test-files.json
+++ b/test/test-files.json
@@ -36,6 +36,7 @@
"test/src/mbgl/test/test.cpp",
"test/src/mbgl/test/util.cpp",
"test/storage/asset_file_source.test.cpp",
+ "test/storage/database_file_source.test.cpp",
"test/storage/headers.test.cpp",
"test/storage/http_file_source.test.cpp",
"test/storage/local_file_source.test.cpp",