2024-10-10 15:56:27 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2024, Tim Flynn <trflynn89@ladybird.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/Assertions.h>
|
|
|
|
#include <AK/ByteString.h>
|
|
|
|
#include <AK/Error.h>
|
|
|
|
#include <AK/RefPtr.h>
|
|
|
|
#include <AK/String.h>
|
|
|
|
#include <AK/StringView.h>
|
2024-10-13 13:23:27 +00:00
|
|
|
#include <AK/Time.h>
|
2024-10-10 15:56:27 +00:00
|
|
|
#include <LibCore/Forward.h>
|
|
|
|
#include <LibCore/Promise.h>
|
|
|
|
#include <LibGfx/Forward.h>
|
|
|
|
#include <LibURL/Forward.h>
|
2024-11-12 15:36:53 +00:00
|
|
|
#include <LibWeb/PixelUnits.h>
|
2024-10-10 15:56:27 +00:00
|
|
|
|
|
|
|
namespace Ladybird {
|
|
|
|
|
|
|
|
class HeadlessWebView;
|
|
|
|
|
|
|
|
enum class TestMode {
|
|
|
|
Layout,
|
|
|
|
Text,
|
|
|
|
Ref,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class TestResult {
|
|
|
|
Pass,
|
|
|
|
Fail,
|
|
|
|
Skipped,
|
|
|
|
Timeout,
|
2024-11-12 13:50:54 +00:00
|
|
|
Crashed,
|
2024-10-10 15:56:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static constexpr StringView test_result_to_string(TestResult result)
|
|
|
|
{
|
|
|
|
switch (result) {
|
|
|
|
case TestResult::Pass:
|
|
|
|
return "Pass"sv;
|
|
|
|
case TestResult::Fail:
|
|
|
|
return "Fail"sv;
|
|
|
|
case TestResult::Skipped:
|
|
|
|
return "Skipped"sv;
|
|
|
|
case TestResult::Timeout:
|
|
|
|
return "Timeout"sv;
|
2024-11-12 13:50:54 +00:00
|
|
|
case TestResult::Crashed:
|
|
|
|
return "Crashed"sv;
|
2024-10-10 15:56:27 +00:00
|
|
|
}
|
|
|
|
VERIFY_NOT_REACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Test {
|
|
|
|
TestMode mode;
|
|
|
|
|
|
|
|
ByteString input_path {};
|
|
|
|
ByteString expectation_path {};
|
|
|
|
|
2024-10-13 13:23:27 +00:00
|
|
|
UnixDateTime start_time {};
|
|
|
|
UnixDateTime end_time {};
|
|
|
|
|
2024-10-10 15:56:27 +00:00
|
|
|
String text {};
|
|
|
|
bool did_finish_test { false };
|
|
|
|
bool did_finish_loading { false };
|
|
|
|
|
|
|
|
RefPtr<Gfx::Bitmap> actual_screenshot {};
|
|
|
|
RefPtr<Gfx::Bitmap> expectation_screenshot {};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TestCompletion {
|
|
|
|
Test& test;
|
|
|
|
TestResult result;
|
|
|
|
};
|
|
|
|
|
|
|
|
using TestPromise = Core::Promise<TestCompletion>;
|
|
|
|
|
2024-11-12 15:36:53 +00:00
|
|
|
ErrorOr<void> run_tests(Core::AnonymousBuffer const& theme, Web::DevicePixelSize window_size);
|
2024-10-26 16:22:18 +00:00
|
|
|
void run_dump_test(HeadlessWebView&, Test&, URL::URL const&, int timeout_in_milliseconds);
|
2024-10-10 15:56:27 +00:00
|
|
|
|
|
|
|
}
|