Tests: Add LibWeb layout tests

This commit is contained in:
Aliaksandr Kalenik 2023-01-29 03:07:16 +03:00 committed by Linus Groh
parent c05fcd54bb
commit 78b503946c
4 changed files with 91 additions and 0 deletions

57
.github/workflows/libweb-layout.yml vendored Normal file
View file

@ -0,0 +1,57 @@
name: Test LibWeb layout
on: [ push, pull_request ]
env:
SERENITY_SOURCE_DIR: ${{ github.workspace }}
concurrency: libweb-layout
jobs:
build:
runs-on: ubuntu-22.04
if: github.repository == 'SerenityOS/serenity'
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v3
- name: "Install Ubuntu dependencies"
run: |
sudo apt-get update
sudo apt-get install -y ninja-build gcc-12 g++-12 libstdc++-12-dev \
libgl1-mesa-dev qt6-base-dev qt6-tools-dev-tools \
- name: "Create build directories"
run: |
mkdir -p ${{ github.workspace }}/Build/caches/TZDB
mkdir -p ${{ github.workspace }}/Build/caches/UCD
mkdir -p ${{ github.workspace }}/Build/caches/CLDR
- name: "TimeZoneData cache"
uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b
with:
path: ${{ github.workspace }}/Build/caches/TZDB
key: TimeZoneData-${{ hashFiles('Meta/CMake/time_zone_data.cmake') }}
- name: "UnicodeData cache"
uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b
with:
path: ${{ github.workspace }}/Build/caches/UCD
key: UnicodeData-${{ hashFiles('Meta/CMake/unicode_data.cmake') }}
- name: "UnicodeLocale cache"
uses: actions/cache@03e00da99d75a2204924908e1cca7902cafce66b
with:
path: ${{ github.workspace }}/Build/caches/CLDR
key: UnicodeLocale-${{ hashFiles('Meta/CMake/locale_data.cmake') }}
- name: "Create Ladybird build environment"
run: |
cmake -GNinja \
-B ${{ github.workspace }}/Build/ladybird \
-S ${{ github.workspace }}/Ladybird \
-DCMAKE_C_COMPILER=gcc-12 \
-DCMAKE_CXX_COMPILER=g++-12 \
-DSERENITY_CACHE_DIR=${{ github.workspace }}/Build/cachess
- name: "Build Ladybird"
run: |
ninja -C ${{ github.workspace }}/Build/ladybird
- name: "Run layout tests"
run: |
${{ github.workspace }}/Tests/LibWeb/Layout/layout_test.sh
env:
QT_QPA_PLATFORM: "offscreen"

View file

@ -0,0 +1,6 @@
InitialContainingBlock <#document> at (0,0) content-size 0x0 children: not-inline
BlockContainer <html> at (0,0) content-size 0x16 children: not-inline
BlockContainer <(anonymous)> at (0,0) content-size 0x0 children: inline
TextNode <#text>
BlockContainer <body> at (8,8) content-size 0x0 children: inline
TextNode <#text>

View file

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<head>
<title>Blank</title>
</head>
<body>
</body>
</html>

View file

@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -eo pipefail
SCRIPT_DIR="$(dirname "${0}")"
SERENITY_ROOT="$(realpath "${SCRIPT_DIR}"/../../..)"
LADYBIRD_BUILD_DIR="${SERENITY_ROOT}/Build/ladybird"
for filename in "$SCRIPT_DIR"/input/*; do
name=$(basename "$filename" .html)
input_html_path=$(realpath "$SCRIPT_DIR")/input/"$name".html
output_layout_dump=$(cd "$LADYBIRD_BUILD_DIR"; ./ladybird -d "$input_html_path")
expected_layout_dump_path="$(realpath "$SCRIPT_DIR")/expected/$name.txt"
if cmp <(echo "$output_layout_dump") "$expected_layout_dump_path"; then
echo "$name PASSED"
else
echo "$name FAILED"
diff "$expected_layout_dump_path" <(echo "$output_layout_dump")
fi
done