summaryrefslogtreecommitdiff
path: root/test/src
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-07-21 16:36:31 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-07-26 09:50:38 -0700
commit32bd1d54fa777035920b58e653905e4592ef187c (patch)
tree3f6fa84d6c9369bdd312ba630538a0c7504fce3a /test/src
parent11933f6ab81248a884db3b1f69be714a60b6a86c (diff)
downloadqtlocation-mapboxgl-32bd1d54fa777035920b58e653905e4592ef187c.tar.gz
[node, tests] Consolidate headless rendering logic in HeadlessFrontend
Diffstat (limited to 'test/src')
-rw-r--r--test/src/mbgl/test/stub_renderer_frontend.cpp52
-rw-r--r--test/src/mbgl/test/stub_renderer_frontend.hpp44
-rw-r--r--test/src/mbgl/test/util.cpp17
-rw-r--r--test/src/mbgl/test/util.hpp7
4 files changed, 0 insertions, 120 deletions
diff --git a/test/src/mbgl/test/stub_renderer_frontend.cpp b/test/src/mbgl/test/stub_renderer_frontend.cpp
deleted file mode 100644
index 7edcfd397e..0000000000
--- a/test/src/mbgl/test/stub_renderer_frontend.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-#include <mbgl/test/stub_renderer_frontend.hpp>
-
-#include <mbgl/map/view.hpp>
-#include <mbgl/renderer/renderer.hpp>
-
-namespace mbgl {
-
-StubRendererFrontend::StubRendererFrontend(std::unique_ptr<Renderer> renderer_, InvalidateCallback invalidate)
- : renderer(std::move(renderer_))
- , asyncInvalidate([this, invalidate=std::move(invalidate)]() {
- invalidate(*this);
- }) {
-}
-
-StubRendererFrontend::StubRendererFrontend(std::unique_ptr<Renderer> renderer_, View& view)
- : renderer(std::move(renderer_))
- , asyncInvalidate([&]() {
- this->render(view);
- }) {
-}
-
-StubRendererFrontend::~StubRendererFrontend() {
- reset();
-}
-
-void StubRendererFrontend::reset() {
- if (renderer) {
- renderer.reset();
- }
-}
-
-void StubRendererFrontend::setObserver(RendererObserver& observer) {
- if (!renderer) return;
- renderer->setObserver(&observer);
-}
-
-void StubRendererFrontend::update(std::shared_ptr<UpdateParameters> params) {
- updateParameters = std::move(params);
- asyncInvalidate.send();
-}
-
-void StubRendererFrontend::render(View& view) {
- if (!updateParameters || !renderer) return;
- renderer->render(view, *updateParameters);
-}
-
-Renderer* StubRendererFrontend::getRenderer() {
- return renderer.get();
-}
-
-} // namespace mbgl
-
diff --git a/test/src/mbgl/test/stub_renderer_frontend.hpp b/test/src/mbgl/test/stub_renderer_frontend.hpp
deleted file mode 100644
index f6dd1d0472..0000000000
--- a/test/src/mbgl/test/stub_renderer_frontend.hpp
+++ /dev/null
@@ -1,44 +0,0 @@
-
-#pragma once
-
-#include <mbgl/renderer/renderer_frontend.hpp>
-#include <mbgl/util/async_task.hpp>
-#include <mbgl/util/geo.hpp>
-#include <mbgl/util/feature.hpp>
-#include <mbgl/renderer/query.hpp>
-
-#include <functional>
-#include <memory>
-
-namespace mbgl {
-
-class Renderer;
-class View;
-
-class StubRendererFrontend : public RendererFrontend {
-public:
- // Calls the provided callback when it's time to render
- using InvalidateCallback = std::function<void (StubRendererFrontend&)>;
- StubRendererFrontend(std::unique_ptr<Renderer>, InvalidateCallback);
-
- // Will render async
- StubRendererFrontend(std::unique_ptr<Renderer>, View&);
-
- ~StubRendererFrontend() override;
-
- void reset() override;
-
- void setObserver(RendererObserver&) override;
-
- void update(std::shared_ptr<UpdateParameters>) override;
- void render(View& view);
-
- Renderer* getRenderer();
-
-private:
- std::unique_ptr<Renderer> renderer;
- std::shared_ptr<UpdateParameters> updateParameters;
- util::AsyncTask asyncInvalidate;
-};
-
-} // namespace mbgl
diff --git a/test/src/mbgl/test/util.cpp b/test/src/mbgl/test/util.cpp
index 0b1034e315..028a0a9d51 100644
--- a/test/src/mbgl/test/util.cpp
+++ b/test/src/mbgl/test/util.cpp
@@ -1,12 +1,8 @@
#include <mbgl/test/util.hpp>
-#include <mbgl/map/map.hpp>
-#include <mbgl/gl/offscreen_view.hpp>
#include <mbgl/util/logging.hpp>
#include <mbgl/util/image.hpp>
#include <mbgl/util/io.hpp>
-#include <mbgl/util/chrono.hpp>
-#include <mbgl/util/run_loop.hpp>
#include <mapbox/pixelmatch.hpp>
@@ -98,19 +94,6 @@ Server::~Server() {
}
}
-PremultipliedImage render(Map& map, OffscreenView& view) {
- PremultipliedImage result;
- map.renderStill([&](std::exception_ptr) {
- result = view.readStillImage();
- });
-
- while (!result.valid()) {
- util::RunLoop::Get()->runOnce();
- }
-
- return result;
-}
-
void checkImage(const std::string& base,
const PremultipliedImage& actual,
double imageThreshold,
diff --git a/test/src/mbgl/test/util.hpp b/test/src/mbgl/test/util.hpp
index 9c015f1641..7a8d78897e 100644
--- a/test/src/mbgl/test/util.hpp
+++ b/test/src/mbgl/test/util.hpp
@@ -54,11 +54,6 @@
#include <gtest/gtest.h>
namespace mbgl {
-
-class Map;
-class OffscreenView;
-class HeadlessDisplay;
-
namespace test {
class Server {
@@ -70,8 +65,6 @@ private:
int fd = -1;
};
-PremultipliedImage render(Map&, OffscreenView&);
-
void checkImage(const std::string& base,
const PremultipliedImage& actual,
double imageThreshold = 0,