mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-22 10:19:20 +00:00
headless-browser: Define the test-related structures earlier
And re-order the Test fields to have the test mode first. No functional change - this is just to reduce diff noise a bit in an upcoming patch.
This commit is contained in:
parent
e6975ec76a
commit
08426efebc
Notes:
github-actions[bot]
2024-10-06 17:25:31 +00:00
Author: https://github.com/trflynn89
Commit: 08426efebc
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1627
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/shannonbooth
1 changed files with 37 additions and 37 deletions
|
@ -48,6 +48,41 @@
|
||||||
|
|
||||||
constexpr int DEFAULT_TIMEOUT_MS = 30000; // 30sec
|
constexpr int DEFAULT_TIMEOUT_MS = 30000; // 30sec
|
||||||
|
|
||||||
|
enum class TestMode {
|
||||||
|
Layout,
|
||||||
|
Text,
|
||||||
|
Ref,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class TestResult {
|
||||||
|
Pass,
|
||||||
|
Fail,
|
||||||
|
Skipped,
|
||||||
|
Timeout,
|
||||||
|
};
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
VERIFY_NOT_REACHED();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Test {
|
||||||
|
TestMode mode;
|
||||||
|
ByteString input_path;
|
||||||
|
ByteString expectation_path;
|
||||||
|
Optional<TestResult> result;
|
||||||
|
};
|
||||||
|
|
||||||
class HeadlessWebContentView;
|
class HeadlessWebContentView;
|
||||||
|
|
||||||
class Application : public WebView::Application {
|
class Application : public WebView::Application {
|
||||||
|
@ -242,34 +277,6 @@ static ErrorOr<NonnullRefPtr<Core::Timer>> load_page_for_screenshot_and_exit(Cor
|
||||||
return timer;
|
return timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class TestMode {
|
|
||||||
Layout,
|
|
||||||
Text,
|
|
||||||
Ref,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class TestResult {
|
|
||||||
Pass,
|
|
||||||
Fail,
|
|
||||||
Skipped,
|
|
||||||
Timeout,
|
|
||||||
};
|
|
||||||
|
|
||||||
static 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;
|
|
||||||
}
|
|
||||||
VERIFY_NOT_REACHED();
|
|
||||||
}
|
|
||||||
|
|
||||||
static ErrorOr<TestResult> run_dump_test(HeadlessWebContentView& view, URL::URL const& url, StringView expectation_path, TestMode mode, int timeout_in_milliseconds = DEFAULT_TIMEOUT_MS)
|
static ErrorOr<TestResult> run_dump_test(HeadlessWebContentView& view, URL::URL const& url, StringView expectation_path, TestMode mode, int timeout_in_milliseconds = DEFAULT_TIMEOUT_MS)
|
||||||
{
|
{
|
||||||
Core::EventLoop loop;
|
Core::EventLoop loop;
|
||||||
|
@ -503,13 +510,6 @@ static ErrorOr<TestResult> run_test(HeadlessWebContentView& view, StringView inp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Test {
|
|
||||||
ByteString input_path;
|
|
||||||
ByteString expectation_path;
|
|
||||||
TestMode mode;
|
|
||||||
Optional<TestResult> result;
|
|
||||||
};
|
|
||||||
|
|
||||||
static Vector<ByteString> s_skipped_tests;
|
static Vector<ByteString> s_skipped_tests;
|
||||||
|
|
||||||
static ErrorOr<void> load_test_config(StringView test_root_path)
|
static ErrorOr<void> load_test_config(StringView test_root_path)
|
||||||
|
@ -552,7 +552,7 @@ static ErrorOr<void> collect_dump_tests(Vector<Test>& tests, StringView path, St
|
||||||
auto basename = LexicalPath::title(name);
|
auto basename = LexicalPath::title(name);
|
||||||
auto expectation_path = ByteString::formatted("{}/expected/{}/{}.txt", path, trail, basename);
|
auto expectation_path = ByteString::formatted("{}/expected/{}/{}.txt", path, trail, basename);
|
||||||
|
|
||||||
tests.append({ input_path, move(expectation_path), mode, {} });
|
tests.append({ mode, input_path, move(expectation_path), {} });
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -563,7 +563,7 @@ static ErrorOr<void> collect_ref_tests(Vector<Test>& tests, StringView path)
|
||||||
if (entry.type == Core::DirectoryEntry::Type::Directory)
|
if (entry.type == Core::DirectoryEntry::Type::Directory)
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
auto input_path = TRY(FileSystem::real_path(ByteString::formatted("{}/{}", path, entry.name)));
|
auto input_path = TRY(FileSystem::real_path(ByteString::formatted("{}/{}", path, entry.name)));
|
||||||
tests.append({ input_path, {}, TestMode::Ref, {} });
|
tests.append({ TestMode::Ref, input_path, {}, {} });
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue