summaryrefslogtreecommitdiff
path: root/test/storage/http_load.cpp
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-01-21 19:30:58 +0100
committerKonstantin Käfer <mail@kkaefer.com>2015-02-04 10:49:05 +0100
commit8a1fce547e9ad0bf750418c844c9b23a3ee6d8dd (patch)
treee3f0e8f4b16071667c6a4fdf706740335500dbc6 /test/storage/http_load.cpp
parent5503aef6907b1fea74d6bdbe696f02b9f016f752 (diff)
downloadqtlocation-mapboxgl-8a1fce547e9ad0bf750418c844c9b23a3ee6d8dd.tar.gz
rearrange tests and add storage tests
Diffstat (limited to 'test/storage/http_load.cpp')
-rw-r--r--test/storage/http_load.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/storage/http_load.cpp b/test/storage/http_load.cpp
new file mode 100644
index 0000000000..deefef9135
--- /dev/null
+++ b/test/storage/http_load.cpp
@@ -0,0 +1,44 @@
+#include "../util.hpp"
+
+#include <uv.h>
+
+#include <mbgl/storage/default/default_file_source.hpp>
+
+
+
+TEST(Storage, HTTPLoad) {
+ SCOPED_TEST(HTTPLoad)
+
+ using namespace mbgl;
+
+ DefaultFileSource fs(nullptr, uv_default_loop());
+
+ const int concurrency = 50;
+ const int max = 10000;
+ int number = 1;
+
+ std::function<void()> req = [&]() {
+ const auto current = number++;
+ fs.request({ Resource::Unknown, std::string("http://127.0.0.1:3000/load/") + std::to_string(current) }, uv_default_loop(), [&, current](const Response &res) {
+ EXPECT_EQ(res.status, Response::Successful);
+ EXPECT_EQ(res.data, std::string("Request ") + std::to_string(current));
+ EXPECT_EQ(res.expires, 0);
+ EXPECT_EQ(res.modified, 0);
+ EXPECT_EQ(res.etag, "");
+ EXPECT_EQ(res.message, "");
+
+ if (number <= max) {
+ req();
+ } else if (current == max) {
+ HTTPLoad.finish();
+ }
+ });
+ };
+
+
+ for (int i = 0; i < concurrency; i++) {
+ req();
+ }
+
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
+}