ladybird/Tests/LibWeb/test-web/TestWeb.h
Jelle Raaijmakers 0d856a8fa7 Tests: Implement fuzzy screenshot comparisons in test-web
We now read WPT's `<meta name="fuzzy">` tags if present in tests and
apply them while comparing screenshots.
2025-07-17 12:59:11 +01:00

71 lines
1.3 KiB
C++

/*
* Copyright (c) 2024-2025, Tim Flynn <trflynn89@ladybird.org>
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include "Fuzzy.h"
#include <AK/ByteString.h>
#include <AK/RefPtr.h>
#include <AK/String.h>
#include <AK/Time.h>
#include <AK/Vector.h>
#include <LibCore/Promise.h>
#include <LibGfx/Forward.h>
namespace TestWeb {
enum class TestMode {
Layout,
Text,
Ref,
Crash,
};
enum class TestResult {
Pass,
Fail,
Skipped,
Timeout,
Crashed,
};
enum class RefTestExpectationType {
Match,
Mismatch,
};
struct Test {
TestMode mode;
ByteString input_path {};
ByteString expectation_path {};
ByteString relative_path {};
UnixDateTime start_time {};
UnixDateTime end_time {};
size_t index { 0 };
String text {};
bool did_finish_test { false };
bool did_finish_loading { false };
Optional<RefTestExpectationType> ref_test_expectation_type {};
Vector<FuzzyMatch> fuzzy_matches {};
RefPtr<Gfx::Bitmap const> actual_screenshot {};
RefPtr<Gfx::Bitmap const> expectation_screenshot {};
};
struct TestCompletion {
Test& test;
TestResult result;
};
using TestPromise = Core::Promise<TestCompletion>;
}