summaryrefslogtreecommitdiff
path: root/test/storage
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-01-22 12:24:00 +0100
committerKonstantin Käfer <mail@kkaefer.com>2015-02-04 10:49:06 +0100
commitaa09aa321b24981bf0f8f2dec97ac100727266a5 (patch)
tree9291597f54e8d86357a285f9ffd426ff435f9387 /test/storage
parent8a1fce547e9ad0bf750418c844c9b23a3ee6d8dd (diff)
downloadqtlocation-mapboxgl-aa09aa321b24981bf0f8f2dec97ac100727266a5.tar.gz
rearrange tests and make more robust
Diffstat (limited to 'test/storage')
-rw-r--r--test/storage/cache_response.cpp4
-rw-r--r--test/storage/cache_revalidate.cpp4
-rw-r--r--test/storage/directory_reading.cpp7
-rw-r--r--test/storage/file_reading.cpp12
-rw-r--r--test/storage/http_cancel.cpp6
-rw-r--r--test/storage/http_coalescing.cpp4
-rw-r--r--test/storage/http_error.cpp4
-rw-r--r--test/storage/http_header_parsing.cpp4
-rw-r--r--test/storage/http_load.cpp6
-rw-r--r--test/storage/http_noloop.cpp4
-rw-r--r--test/storage/http_other_loop.cpp4
-rw-r--r--test/storage/http_reading.cpp4
-rwxr-xr-xtest/storage/server.js2
-rw-r--r--test/storage/storage.cpp13
-rw-r--r--test/storage/storage.hpp16
15 files changed, 62 insertions, 32 deletions
diff --git a/test/storage/cache_response.cpp b/test/storage/cache_response.cpp
index c775647f77..57aa8a5e16 100644
--- a/test/storage/cache_response.cpp
+++ b/test/storage/cache_response.cpp
@@ -1,11 +1,11 @@
-#include "../util.hpp"
+#include "storage.hpp"
#include <uv.h>
#include <mbgl/storage/default/default_file_source.hpp>
#include <mbgl/storage/default/sqlite_cache.hpp>
-TEST(Storage, CacheResponse) {
+TEST_F(Storage, CacheResponse) {
SCOPED_TEST(CacheResponse);
using namespace mbgl;
diff --git a/test/storage/cache_revalidate.cpp b/test/storage/cache_revalidate.cpp
index c2bbcbc2a4..1c8653f183 100644
--- a/test/storage/cache_revalidate.cpp
+++ b/test/storage/cache_revalidate.cpp
@@ -1,11 +1,11 @@
-#include "../util.hpp"
+#include "storage.hpp"
#include <uv.h>
#include <mbgl/storage/default/default_file_source.hpp>
#include <mbgl/storage/default/sqlite_cache.hpp>
-TEST(Storage, CacheRevalidate) {
+TEST_F(Storage, CacheRevalidate) {
SCOPED_TEST(CacheRevalidateSame)
SCOPED_TEST(CacheRevalidateModified)
SCOPED_TEST(CacheRevalidateEtag)
diff --git a/test/storage/directory_reading.cpp b/test/storage/directory_reading.cpp
index 66d0f8f9e7..90b7846fdd 100644
--- a/test/storage/directory_reading.cpp
+++ b/test/storage/directory_reading.cpp
@@ -1,17 +1,18 @@
-#include "../util.hpp"
+#include "storage.hpp"
#include <uv.h>
#include <mbgl/storage/default/default_file_source.hpp>
-TEST(Storage, ReadDirectory) {
+TEST_F(Storage, ReadDirectory) {
SCOPED_TEST(ReadDirectory)
using namespace mbgl;
DefaultFileSource fs(nullptr, uv_default_loop());
- fs.request({ Resource::Unknown, "asset://test/fixtures/storage" }, uv_default_loop(), [&](const Response &res) {
+ const auto dir = std::string { "asset://" } + mbgl::test::getBaseDirectory() + "/fixtures/storage";
+ fs.request({ Resource::Unknown, dir }, uv_default_loop(), [&](const Response &res) {
EXPECT_EQ(res.status, Response::Error);
EXPECT_EQ(res.data.size(), 0ul);
EXPECT_EQ(res.expires, 0);
diff --git a/test/storage/file_reading.cpp b/test/storage/file_reading.cpp
index 273b58218e..93c119d44f 100644
--- a/test/storage/file_reading.cpp
+++ b/test/storage/file_reading.cpp
@@ -1,17 +1,18 @@
-#include "../util.hpp"
+#include "storage.hpp"
#include <uv.h>
#include <mbgl/storage/default/default_file_source.hpp>
-TEST(Storage, EmptyFile) {
+TEST_F(Storage, EmptyFile) {
SCOPED_TEST(EmptyFile)
using namespace mbgl;
DefaultFileSource fs(nullptr, uv_default_loop());
- fs.request({ Resource::Unknown, "asset://test/fixtures/storage/empty" }, uv_default_loop(), [&](const Response &res) {
+ const auto file = std::string { "asset://" } + mbgl::test::getBaseDirectory() + "/fixtures/storage/empty";
+ fs.request({ Resource::Unknown, file }, uv_default_loop(), [&](const Response &res) {
EXPECT_EQ(res.status, Response::Successful);
EXPECT_EQ(res.data.size(), 0ul);
EXPECT_EQ(res.expires, 0);
@@ -24,14 +25,15 @@ TEST(Storage, EmptyFile) {
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
}
-TEST(Storage, NonExistentFile) {
+TEST_F(Storage, NonExistentFile) {
SCOPED_TEST(NonExistentFile)
using namespace mbgl;
DefaultFileSource fs(nullptr, uv_default_loop());
- fs.request({ Resource::Unknown, "asset://test/fixtures/storage/does_not_exist" }, uv_default_loop(), [&](const Response &res) {
+ const auto file = std::string { "asset://" } + mbgl::test::getBaseDirectory() + "/fixtures/storage/does_not_exist";
+ fs.request({ Resource::Unknown, file }, uv_default_loop(), [&](const Response &res) {
EXPECT_EQ(res.status, Response::Error);
EXPECT_EQ(res.data.size(), 0ul);
EXPECT_EQ(res.expires, 0);
diff --git a/test/storage/http_cancel.cpp b/test/storage/http_cancel.cpp
index 4da70b965b..948fab8de0 100644
--- a/test/storage/http_cancel.cpp
+++ b/test/storage/http_cancel.cpp
@@ -1,4 +1,4 @@
-#include "../util.hpp"
+#include "storage.hpp"
#include <uv.h>
@@ -7,7 +7,7 @@
#include <cmath>
-TEST(Storage, HTTPCancel) {
+TEST_F(Storage, HTTPCancel) {
SCOPED_TEST(HTTPCancel)
using namespace mbgl;
@@ -24,7 +24,7 @@ TEST(Storage, HTTPCancel) {
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
}
-TEST(Storage, HTTPCancelMultiple) {
+TEST_F(Storage, HTTPCancelMultiple) {
SCOPED_TEST(HTTPCancelMultiple)
using namespace mbgl;
diff --git a/test/storage/http_coalescing.cpp b/test/storage/http_coalescing.cpp
index 2a82abba2e..0224b2444d 100644
--- a/test/storage/http_coalescing.cpp
+++ b/test/storage/http_coalescing.cpp
@@ -1,10 +1,10 @@
-#include "../util.hpp"
+#include "storage.hpp"
#include <uv.h>
#include <mbgl/storage/default/default_file_source.hpp>
-TEST(Storage, HTTPCoalescing) {
+TEST_F(Storage, HTTPCoalescing) {
SCOPED_TEST(HTTPCoalescing)
static int counter = 0;
diff --git a/test/storage/http_error.cpp b/test/storage/http_error.cpp
index 3f4b95a102..274b88fd4a 100644
--- a/test/storage/http_error.cpp
+++ b/test/storage/http_error.cpp
@@ -1,4 +1,4 @@
-#include "../util.hpp"
+#include "storage.hpp"
#include <uv.h>
@@ -7,7 +7,7 @@
#include <cmath>
-TEST(Storage, HTTPError) {
+TEST_F(Storage, HTTPError) {
SCOPED_TEST(HTTPTemporaryError)
SCOPED_TEST(HTTPConnectionError)
diff --git a/test/storage/http_header_parsing.cpp b/test/storage/http_header_parsing.cpp
index 0d169e44c6..0ee78a291a 100644
--- a/test/storage/http_header_parsing.cpp
+++ b/test/storage/http_header_parsing.cpp
@@ -1,4 +1,4 @@
-#include "../util.hpp"
+#include "storage.hpp"
#include <uv.h>
@@ -6,7 +6,7 @@
#include <cmath>
-TEST(Storage, HTTPHeaderParsing) {
+TEST_F(Storage, HTTPHeaderParsing) {
SCOPED_TEST(HTTPExpiresTest)
SCOPED_TEST(HTTPCacheControlTest)
diff --git a/test/storage/http_load.cpp b/test/storage/http_load.cpp
index deefef9135..8ffae05b11 100644
--- a/test/storage/http_load.cpp
+++ b/test/storage/http_load.cpp
@@ -1,12 +1,10 @@
-#include "../util.hpp"
+#include "storage.hpp"
#include <uv.h>
#include <mbgl/storage/default/default_file_source.hpp>
-
-
-TEST(Storage, HTTPLoad) {
+TEST_F(Storage, HTTPLoad) {
SCOPED_TEST(HTTPLoad)
using namespace mbgl;
diff --git a/test/storage/http_noloop.cpp b/test/storage/http_noloop.cpp
index cb2b778aa7..d9d69af5a8 100644
--- a/test/storage/http_noloop.cpp
+++ b/test/storage/http_noloop.cpp
@@ -1,11 +1,11 @@
-#include "../util.hpp"
+#include "storage.hpp"
#include <uv.h>
#include <mbgl/storage/default/default_file_source.hpp>
#include <mbgl/util/uv.hpp>
-TEST(Storage, HTTPNoLoop) {
+TEST_F(Storage, HTTPNoLoop) {
SCOPED_TEST(HTTPNoLoop)
using namespace mbgl;
diff --git a/test/storage/http_other_loop.cpp b/test/storage/http_other_loop.cpp
index 01779453d5..d455250393 100644
--- a/test/storage/http_other_loop.cpp
+++ b/test/storage/http_other_loop.cpp
@@ -1,10 +1,10 @@
-#include "../util.hpp"
+#include "storage.hpp"
#include <uv.h>
#include <mbgl/storage/default/default_file_source.hpp>
-TEST(Storage, HTTPOtherLoop) {
+TEST_F(Storage, HTTPOtherLoop) {
SCOPED_TEST(HTTPOtherLoop)
using namespace mbgl;
diff --git a/test/storage/http_reading.cpp b/test/storage/http_reading.cpp
index 0fbabf57f9..7130e13c6b 100644
--- a/test/storage/http_reading.cpp
+++ b/test/storage/http_reading.cpp
@@ -1,10 +1,10 @@
-#include "../util.hpp"
+#include "storage.hpp"
#include <uv.h>
#include <mbgl/storage/default/default_file_source.hpp>
-TEST(Storage, HTTPReading) {
+TEST_F(Storage, HTTPReading) {
SCOPED_TEST(HTTPTest)
SCOPED_TEST(HTTP404)
diff --git a/test/storage/server.js b/test/storage/server.js
index b55d70ae71..33d5a82985 100755
--- a/test/storage/server.js
+++ b/test/storage/server.js
@@ -92,7 +92,7 @@ app.get('/load/:number(\\d+)', function(req, res) {
var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;
- console.log('Test server listening at http://%s:%s', host, port);
+ console.warn('Storage test server listening at http://%s:%s', host, port);
if (process.argv[2]) {
// Allow the test to continue running.
diff --git a/test/storage/storage.cpp b/test/storage/storage.cpp
new file mode 100644
index 0000000000..30f632d193
--- /dev/null
+++ b/test/storage/storage.cpp
@@ -0,0 +1,13 @@
+#include "storage.hpp"
+
+pid_t Storage::pid = 0;
+
+void Storage::SetUpTestCase() {
+ const auto server = mbgl::test::getBaseDirectory() + "/storage/server.js";
+ fprintf(stderr, "server: %s\n", server.c_str());
+ pid = mbgl::test::startServer(server.c_str());
+}
+
+void Storage::TearDownTestCase() {
+ mbgl::test::stopServer(pid);
+} \ No newline at end of file
diff --git a/test/storage/storage.hpp b/test/storage/storage.hpp
new file mode 100644
index 0000000000..d2402166a0
--- /dev/null
+++ b/test/storage/storage.hpp
@@ -0,0 +1,16 @@
+#ifndef MBGL_TEST_STORAGE_STORAGE
+#define MBGL_TEST_STORAGE_STORAGE
+
+#include "../fixtures/util.hpp"
+#include <uv.h>
+
+class Storage : public testing::Test {
+public:
+ static void SetUpTestCase();
+ static void TearDownTestCase();
+
+protected:
+ static pid_t pid;
+};
+
+#endif