rearrange tests and make more robust
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
13
test/storage/storage.cpp
Normal file
13
test/storage/storage.cpp
Normal file
@@ -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);
|
||||
}
|
||||
16
test/storage/storage.hpp
Normal file
16
test/storage/storage.hpp
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user