mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
Ladybird+Tests/LibWeb: Add very basic text-only test harness
This allows us to create "text tests" in addition to "layout tests". Text tests work the same as layout tests, but dump the document content as text and exit upon receiving the window "load" event.
This commit is contained in:
parent
3389eed59c
commit
edbc732785
Notes:
sideshowbarker
2024-07-17 07:20:57 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/edbc732785 Pull-request: https://github.com/SerenityOS/serenity/pull/19082
@ -170,4 +170,10 @@ if (BUILD_TESTING)
|
||||
COMMAND ${SERENITY_SOURCE_DIR}/Tests/LibWeb/Layout/layout_test.sh ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
set_tests_properties(Layout PROPERTIES ENVIRONMENT QT_QPA_PLATFORM=offscreen)
|
||||
|
||||
add_test(
|
||||
NAME LibWebText
|
||||
COMMAND ${SERENITY_SOURCE_DIR}/Tests/LibWeb/Text/text_test.sh ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
set_tests_properties(LibWebText PROPERTIES ENVIRONMENT QT_QPA_PLATFORM=offscreen)
|
||||
endif()
|
||||
|
2
Tests/LibWeb/Text/expected/basic.txt
Normal file
2
Tests/LibWeb/Text/expected/basic.txt
Normal file
@ -0,0 +1,2 @@
|
||||
Well hello
|
||||
friends!
|
9
Tests/LibWeb/Text/input/basic.html
Normal file
9
Tests/LibWeb/Text/input/basic.html
Normal file
@ -0,0 +1,9 @@
|
||||
<div id="out"></div><script>
|
||||
function println(s) {
|
||||
const out = document.getElementById("out");
|
||||
out.appendChild(document.createTextNode(s + "\n"))
|
||||
}
|
||||
|
||||
println("Well hello")
|
||||
println("friends!")
|
||||
</script>
|
28
Tests/LibWeb/Text/text_test.sh
Executable file
28
Tests/LibWeb/Text/text_test.sh
Executable file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd -P -- "$(dirname -- "${0}")" && pwd -P)"
|
||||
LADYBIRD_BUILD_DIR="${1}"
|
||||
|
||||
if [[ -z "${LADYBIRD_BUILD_DIR}" ]] ; then
|
||||
echo "Provide path to the Ladybird build directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BROWSER_BINARY="./headless-browser"
|
||||
|
||||
find "${SCRIPT_DIR}/input/" -type f -name "*.html" -print0 | while IFS= read -r -d '' input_html_path; do
|
||||
input_html_file=${input_html_path/${SCRIPT_DIR}"/input/"/}
|
||||
input_html_file=${input_html_file/".html"/}
|
||||
|
||||
output_text_dump=$(cd "${LADYBIRD_BUILD_DIR}"; timeout 300s "${BROWSER_BINARY}" --dump-text "${input_html_path}")
|
||||
expected_text_dump_path="${SCRIPT_DIR}/expected/${input_html_file}.txt"
|
||||
|
||||
if cmp <(echo "${output_text_dump}") "${expected_text_dump_path}"; then
|
||||
echo "${input_html_file} PASSED"
|
||||
else
|
||||
echo "${input_html_file} FAILED"
|
||||
diff -u "${expected_text_dump_path}" <(echo "${output_text_dump}")
|
||||
fi
|
||||
done
|
Loading…
Reference in New Issue
Block a user