Skip to content

Commit

Permalink
Tests/LibWeb: Restructure Ref and Screenshot test dirs to match others
Browse files Browse the repository at this point in the history
Now each test type has the same directories:
- input
- expected
- data

Also, tests can be in subdirectories within ./input.
  • Loading branch information
AtkinsSJ committed Nov 5, 2024
1 parent 65e83fc commit ece0293
Show file tree
Hide file tree
Showing 360 changed files with 450 additions and 447 deletions.
4 changes: 2 additions & 2 deletions Documentation/Testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ are identical. These are ideal for testing visual effects such as background ima
difficult to recreate the effect in the reference page, (such as for SVG or canvas,) consider using a Screenshot test
instead.

Each Ref test includes a special `<link rel="match" href="reference/my-test-ref.html" />` tag, which the test runner
Each Ref test includes a special `<link rel="match" href="../expected/my-test-ref.html" />` tag, which the test runner
uses to locate the reference page. In this way, multiple tests can use the same reference.

### Screenshot
Expand All @@ -167,5 +167,5 @@ Screenshot tests can be thought of as a subtype of Ref tests, where the referenc
to a screenshot of the expected output. In general, try to avoid using them if a regular Ref test would do, as they are
sensitive to small rendering changes, and won't work on all platforms.

Like Ref tests, they require a `<link rel="match" href="reference/my-test-ref.html" />` tag to indicate the reference
Like Ref tests, they require a `<link rel="match" href="../expected/my-test-ref.html" />` tag to indicate the reference
page to use.
21 changes: 12 additions & 9 deletions Ladybird/Headless/Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,20 @@ static ErrorOr<void> collect_dump_tests(Vector<Test>& tests, StringView path, St
return {};
}

static ErrorOr<void> collect_ref_tests(Vector<Test>& tests, StringView path)
static ErrorOr<void> collect_ref_tests(Vector<Test>& tests, StringView path, StringView trail)
{
TRY(Core::Directory::for_each_entry(path, Core::DirIterator::SkipDots, [&](Core::DirectoryEntry const& entry, Core::Directory const&) -> ErrorOr<IterationDecision> {
if (entry.type == Core::DirectoryEntry::Type::Directory)
return IterationDecision::Continue;
Core::DirIterator it(ByteString::formatted("{}/input/{}", path, trail), Core::DirIterator::Flags::SkipDots);
while (it.has_next()) {
auto name = it.next_path();
auto input_path = TRY(FileSystem::real_path(ByteString::formatted("{}/input/{}/{}", path, trail, name)));

auto input_path = TRY(FileSystem::real_path(ByteString::formatted("{}/{}", path, entry.name)));
tests.append({ TestMode::Ref, input_path, {}, {} });
if (FileSystem::is_directory(input_path)) {
TRY(collect_ref_tests(tests, path, ByteString::formatted("{}/{}", trail, name)));
continue;
}

return IterationDecision::Continue;
}));
tests.append({ TestMode::Ref, input_path, {}, {} });
}

return {};
}
Expand Down Expand Up @@ -374,7 +377,7 @@ ErrorOr<void> run_tests(Core::AnonymousBuffer const& theme, Gfx::IntSize window_

TRY(collect_dump_tests(tests, ByteString::formatted("{}/Layout", app.test_root_path), "."sv, TestMode::Layout));
TRY(collect_dump_tests(tests, ByteString::formatted("{}/Text", app.test_root_path), "."sv, TestMode::Text));
TRY(collect_ref_tests(tests, ByteString::formatted("{}/Ref", app.test_root_path)));
TRY(collect_ref_tests(tests, ByteString::formatted("{}/Ref", app.test_root_path), "."sv));
#if !defined(AK_OS_MACOS)
TRY(collect_ref_tests(tests, ByteString::formatted("{}/Screenshot", app.test_root_path)));
#endif
Expand Down
4 changes: 0 additions & 4 deletions Tests/LibWeb/Ref/body-link-attribute.html

This file was deleted.

File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<link rel="match" href="reference/anonymous-wrapper-css-visibility-ref.html" />
<link rel="match" href="../expected/anonymous-wrapper-css-visibility-ref.html" />
<style>
body {
color: transparent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
display: inline-block;
min-width: 12px;
min-height: 12px;
background-image: url("../assets/2x2checkerboard.png");
background-image: url("../data/2x2checkerboard.png");
background-size: calc(max(0.75em, 12px));
}
</style>
</head>
<body><span></span><img src="../assets/2x2checkerboard.png">
<body><span></span><img src="../data/2x2checkerboard.png">
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<link rel="match" href="reference/body-link-attribute.html-ref" />
<link rel="match" href="../expected/body-link-attribute.html-ref" />
<style>
a {
color: #FF0000;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<link rel="match" href="reference/inline-paintable-inside-translated-container-ref.html" />
<link rel="match" href="../expected/inline-paintable-inside-translated-container-ref.html" />
<style>
body {
margin-top: 100px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<link rel="match" href="reference/outlines-ref.html" />
<link rel="match" href="../expected/outlines-ref.html" />
<style>
.border {
width: 100px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<link rel="match" href="reference/overflow-hidden-3-ref.html" />
<link rel="match" href="../expected/overflow-hidden-3-ref.html" />
<style>
.green {
width: 200px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<link rel="match" href="reference/overflow-hidden-4-ref.html" />
<link rel="match" href="../expected/overflow-hidden-4-ref.html" />
<style>
* {
outline: black solid 1px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<head>
<link rel="match" href="reference/overflow-hidden-5-ref.html" />
<link rel="match" href="../expected/overflow-hidden-5-ref.html" />
<style type="text/css">
body {
margin: 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<html>
<link rel="match" href="reference/overflow-hidden-6-ref.html" />
<link rel="match" href="../expected/overflow-hidden-6-ref.html" />
<style>
.box {
width: 100px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<html>
<link rel="match" href="reference/positioned-elements-in-scroll-container-ref.html" />
<link rel="match" href="../expected/positioned-elements-in-scroll-container-ref.html" />
<style>
* {
margin: 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<link rel="match" href="reference/resolve-paint-only-properties-after-layout-ref.html" />
<link rel="match" href="../expected/resolve-paint-only-properties-after-layout-ref.html" />
<style>
#box {
width: 100px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<link rel="match" href="reference/scrollable-content-inside-fixed-position-box-ref.html" />
<link rel="match" href="../expected/scrollable-content-inside-fixed-position-box-ref.html" />
<style>
* {
scrollbar-width: none;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<svg width="200" viewBox="0 0 100 100">
<link rel="match" href="reference/svg-maskContentUnits-ref.html" />
<link rel="match" href="../expected/svg-maskContentUnits-ref.html" />
<clipPath id="myClip1" clipPathUnits="userSpaceOnUse">
<circle cx="50" cy="50" r="35" />
</clipPath>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<link rel="match" href="reference/abspos-escapes-scroll-container-ref.html" />
<link rel="match" href="../expected/abspos-escapes-scroll-container-ref.html" />
<style>
#scrollable-box {
width: 300px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html><link rel="match" href="reference/abspos-z-index-painting-order-ref.html" /><style>
<!doctype html><link rel="match" href="../expected/abspos-z-index-painting-order-ref.html" /><style>
* {
font-size: 60px;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<link rel="match" href="reference/alternative-style-sheets-ref.html" />
<link rel="match" href="../expected/alternative-style-sheets-ref.html" />
<link title="preferred" rel="stylesheet" href="data:text/css,html { background: green }">
<!-- These alternative style sheets shouldn't be applied -->
<link title="alternative" rel="alternate stylesheet" href="data:text/css,html { background: red !important }">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<link rel="match" href="reference/anonymous-wrapper-css-visibility-ref.html" />
<link rel="match" href="../expected/anonymous-wrapper-css-visibility-ref.html" />
<style>
body {
visibility: hidden;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<link rel="match" href="reference/background-clip-text-inside-scrollable-ref.html" />
<link rel="match" href="../expected/background-clip-text-inside-scrollable-ref.html" />
<style>
* {
scrollbar-width: none;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<link rel="match" href="reference/background-clip-text-ref.html" />
<link rel="match" href="../expected/background-clip-text-ref.html" />
<style>
* { outline: 1px solid black; font-size: 100px; }
.overflow-hidden {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<link rel="match" href="reference/background-size-calc-ref.html" />
<link rel="match" href="../expected/background-size-calc-ref.html" />
<style>
span {
display: inline-block;
min-width: 12px;
min-height: 12px;
background-image: url("assets/2x2checkerboard.png");
background-image: url("../data/2x2checkerboard.png");
background-size: calc(max(0.75em, 12px));
}
</style>
</head>
<body><span></span><img src="assets/2x2checkerboard.png">
<body><span></span><img src="../data/2x2checkerboard.png">
4 changes: 4 additions & 0 deletions Tests/LibWeb/Ref/input/body-link-attribute.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!doctype html>
<link rel="match" href="../expected/body-link-attribute-ref.html" />
<body link="#FF0000">
<a href="about:blank">link
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<link rel="match" href="reference/border-radius-shrink-zero-sized-box-ref.html" />
<link rel="match" href="../expected/border-radius-shrink-zero-sized-box-ref.html" />
<style>
#test {
background-color: red;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html><head>
<link rel="match" href="reference/border-radius-with-padding-ref.html" />
<link rel="match" href="../expected/border-radius-with-padding-ref.html" />
<style type="text/css">
div {
border: 1px solid black;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<link rel="match" href="reference/box-with-transform-should-be-above-other-boxes-ref.html" />
<link rel="match" href="../expected/box-with-transform-should-be-above-other-boxes-ref.html" />
<style>
* { outline: 1px solid black; }
body { width: 300px; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<link rel="match" href="reference/box-without-scrollable-overflow-should-not-consume-scroll-events-ref.html" />
<link rel="match" href="../expected/box-without-scrollable-overflow-should-not-consume-scroll-events-ref.html" />
<style>
.item {
width: 100px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<link rel="match" href="reference/button-inside-scroll-container-ref.html" />
<link rel="match" href="../expected/button-inside-scroll-container-ref.html" />
<style>
* {
scrollbar-width: none;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<link rel="match" href="reference/calc-border-radius-ref.html" />
<link rel="match" href="../expected/calc-border-radius-ref.html" />
<style>
.box {
width: 200px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<link rel="match" href="reference/change-opacity-ref.html" />
<link rel="match" href="../expected/change-opacity-ref.html" />
<style>
#box {
width: 100px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<link rel="match" href="reference/clip-abspos-children-ref.html" />
<link rel="match" href="../expected/clip-abspos-children-ref.html" />
<style type="text/css">
* {
background-color: white;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<link rel="match" href="reference/clip-border-radius-with-css-transform-ref.html" />
<link rel="match" href="../expected/clip-border-radius-with-css-transform-ref.html" />
<style>
* {
margin: 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<link rel="match" href="reference/clip-ref.html" />
<link rel="match" href="../expected/clip-ref.html" />
<style type="text/css">
* {
background-color: white;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<link rel="match" href="reference/color-hsl-ref.html" />
<link rel="match" href="../expected/color-hsl-ref.html" />
<style>
div {
width: 200px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<link rel="match" href="reference/color-hwb-ref.html" />
<link rel="match" href="../expected/color-hwb-ref.html" />
<style>
div {
width: 200px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<link rel="match" href="reference/color-oklab-ref.html" />
<link rel="match" href="../expected/color-oklab-ref.html" />
<style>
div {
width: 200px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<link rel="match" href="reference/color-oklch-ref.html" />
<link rel="match" href="../expected/color-oklch-ref.html" />
<style>
div {
width: 200px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<link rel="match" href="reference/color-rgb-ref.html" />
<link rel="match" href="../expected/color-rgb-ref.html" />
<style>
div {
width: 200px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<link rel="match" href="reference/corner-clip-inside-scrollable-ref.html" />
<link rel="match" href="../expected/corner-clip-inside-scrollable-ref.html" />
<style>
* {
scrollbar-width: none;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<link rel="match" href="reference/css-any-link-selector-ref.html" />
<link rel="match" href="../expected/css-any-link-selector-ref.html" />
<style>
:any-link {
color: orange;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<link rel="match" href="reference/text-div.html" />
<link rel="match" href="../expected/text-div.html" />
<style>
.foo::before {
content: attr(bar);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<link rel="match" href="reference/text-div.html" />
<link rel="match" href="../expected/text-div.html" />
<style>
.foo::before {
content: attr(bar, "Well, hello friends!");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<link rel="match" href="reference/css-attr-typed-ref.html" />
<link rel="match" href="../expected/css-attr-typed-ref.html" />
<style>
div {
width: 100px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<link rel="match" href="reference/css-attr-typed-ref.html" />
<link rel="match" href="../expected/css-attr-typed-ref.html" />
<style>
div {
width: 100px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<link rel="match" href="reference/css-case-insensitive-html-attributes-selector-ref.html" />
<link rel="match" href="../expected/css-case-insensitive-html-attributes-selector-ref.html" />
<style>
div[type=one] { /* 'type' is a case-insensitive html attribute */
background: red;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<link rel="match" href="reference/text-div.html" />
<link rel="match" href="../expected/text-div.html" />
<style>
* {
visibility: visible;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<html>
<link rel="match" href="reference/css-gradient-currentcolor-ref.html" />
<link rel="match" href="../expected/css-gradient-currentcolor-ref.html" />
<style>
div {
color: green;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<link rel="match" href="reference/css-has-compound.html" />
<link rel="match" href="../expected/css-has-compound.html" />
<style>
a:has(span.nice > em) {
color: orange;
Expand Down
Loading

0 comments on commit ece0293

Please sign in to comment.