Files
MapLibreParticleLab/test/storage/http_other_loop.cpp
John Firebaugh 7a6076ea9d [tests] Test with OnlineFileSource
When we introduce OfflineFileSource, the behavior of existing tests should
not change.
2015-12-23 14:55:12 -08:00

32 lines
892 B
C++

#include "storage.hpp"
#include <mbgl/storage/online_file_source.hpp>
#include <mbgl/util/chrono.hpp>
#include <mbgl/util/run_loop.hpp>
TEST_F(Storage, HTTPOtherLoop) {
SCOPED_TEST(HTTPOtherLoop)
using namespace mbgl;
// This file source launches a separate thread to do the processing.
util::RunLoop loop;
OnlineFileSource fs(nullptr);
std::unique_ptr<FileRequest> req = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/test" },
[&](Response res) {
req.reset();
EXPECT_EQ(nullptr, res.error);
EXPECT_EQ(false, res.stale);
ASSERT_TRUE(res.data.get());
EXPECT_EQ("Hello World!", *res.data);
EXPECT_EQ(Seconds::zero(), res.expires);
EXPECT_EQ(Seconds::zero(), res.modified);
EXPECT_EQ("", res.etag);
loop.stop();
HTTPOtherLoop.finish();
});
loop.run();
}