Files
MapLibreParticleLab/render-test/runner.hpp
Thiago Marcos P. Santos 1c138124a6 [render-test] Fix metrics passing when failing
Metrics will now fail, but the tool will return 0 when *ONLY* metrics
fail, to make the bot continue. We will also run ignored tests and
check if they are ignored but passing.
2019-12-16 22:52:01 +02:00

72 lines
1.8 KiB
C++

#pragma once
#include <mbgl/gfx/headless_frontend.hpp>
#include <mbgl/map/map.hpp>
#include "manifest_parser.hpp"
#include <memory>
#include <string>
class TestRunnerMapObserver;
struct TestMetadata;
class TestRunnerMapObserver : public mbgl::MapObserver {
public:
TestRunnerMapObserver() = default;
void onDidFailLoadingMap(mbgl::MapLoadError, const std::string&) override { mapLoadFailure = true; }
void onDidFinishRenderingMap(RenderMode mode) override final {
if (!finishRenderingMap) finishRenderingMap = mode == RenderMode::Full;
}
void onDidBecomeIdle() override final { idle = true; }
void reset() {
mapLoadFailure = false;
finishRenderingMap = false;
idle = false;
}
bool mapLoadFailure;
bool finishRenderingMap;
bool idle;
};
class TestRunner {
public:
enum class UpdateResults { NO, DEFAULT, PLATFORM, METRICS, REBASELINE };
struct TestResults {
bool probeFailed;
bool renderFailed;
};
TestRunner(Manifest, UpdateResults);
TestResults run(TestMetadata&);
void reset();
// Manifest
const Manifest& getManifest() const;
void doShuffle(uint32_t seed);
private:
bool checkQueryTestResults(mbgl::PremultipliedImage&& actualImage,
std::vector<mbgl::Feature>&& features,
TestMetadata&);
bool checkRenderTestResults(mbgl::PremultipliedImage&& image, TestMetadata&);
bool checkProbingResults(TestMetadata&);
struct Impl {
Impl(const TestMetadata&);
~Impl();
std::unique_ptr<TestRunnerMapObserver> observer;
mbgl::HeadlessFrontend frontend;
mbgl::Map map;
};
std::unordered_map<std::string, std::unique_ptr<Impl>> maps;
Manifest manifest;
UpdateResults updateResults;
};