diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/css/css-text-decor/tools/generate-text-emphasis-ruby-tests.py | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-text-decor/tools/generate-text-emphasis-ruby-tests.py')
-rw-r--r-- | testing/web-platform/tests/css/css-text-decor/tools/generate-text-emphasis-ruby-tests.py | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-text-decor/tools/generate-text-emphasis-ruby-tests.py b/testing/web-platform/tests/css/css-text-decor/tools/generate-text-emphasis-ruby-tests.py new file mode 100644 index 0000000000..f1158f5f84 --- /dev/null +++ b/testing/web-platform/tests/css/css-text-decor/tools/generate-text-emphasis-ruby-tests.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python +# - * - coding: UTF-8 - * - + +""" +This script generates tests text-emphasis-ruby-001 ~ 004 which tests +emphasis marks with ruby in four directions. It outputs a list of all +tests it generated in the format of Mozilla reftest.list to the stdout. +""" + +TEST_FILE = 'text-emphasis-ruby-{:03}{}.html' +TEST_TEMPLATE = '''<!DOCTYPE html> +<meta charset="utf-8"> +<!-- This file was generated automatically by the script + ./support/generate-text-emphasis-ruby-tests.py --> +<title>CSS Test: text-emphasis and ruby, {wm}, {pos}</title> +<link rel="author" title="Xidorn Quan" href="https://www.upsuper.org"> +<link rel="author" title="Mozilla" href="https://www.mozilla.org"> +<link rel="help" href="https://drafts.csswg.org/css-text-decor-3/#text-emphasis-position-property"> +<meta name="assert" content="emphasis marks are drawn outside the ruby"> +<link rel="match" href="text-emphasis-ruby-{index:03}-ref.html"> +<p>Pass if the emphasis marks are outside the ruby:</p> +<div lang="ja" style="line-height: 5; writing-mode: {wm}; ruby-position: {ruby_pos}; text-emphasis-position: {posval}">ルビ<span style="text-emphasis: circle">と<ruby>圏<rt>けん</rt>点<rt>てん</rt></ruby>を</span>同時</div> +''' + +REF_FILE = 'text-emphasis-ruby-{:03}-ref.html' +REF_TEMPLATE = '''<!DOCTYPE html> +<meta charset="utf-8"> +<!-- This file was generated automatically by the script + ./support/generate-text-emphasis-ruby-tests.py --> +<title>CSS Reference: text-emphasis and ruby, {wm}, {pos}</title> +<link rel="author" title="Xidorn Quan" href="https://www.upsuper.org"> +<link rel="author" title="Mozilla" href="https://www.mozilla.org"> +<style> rtc {{ font-variant-east-asian: inherit; }} </style> +<p>Pass if the emphasis marks are outside the ruby:</p> +<div lang="ja" style="line-height: 5; writing-mode: {wm}; ruby-position: {posval}">ルビ<ruby>と<rtc>●</rtc>圏<rt>けん</rt><rtc>●</rtc>点<rt>てん</rt><rtc>●</rtc>を<rtc>●</rtc></ruby>同時</div> +''' + +TEST_CASES = [ + ('top', 'horizontal-tb', 'over', [ + ('horizontal-tb', 'over right')]), + ('bottom', 'horizontal-tb', 'under', [ + ('horizontal-tb', 'under right')]), + ('right', 'vertical-rl', 'over', [ + ('vertical-rl', 'over right'), + ('vertical-lr', 'over right')]), + ('left', 'vertical-rl', 'under', [ + ('vertical-rl', 'over left'), + ('vertical-lr', 'over left')]), + ] + +SUFFIXES = ['', 'a'] + +def write_file(filename, content): + with open(filename, 'wb') as f: + f.write(content.encode('UTF-8')) + +print("# START tests from {}".format(__file__)) +idx = 0 +for pos, ref_wm, ruby_pos, subtests in TEST_CASES: + idx += 1 + ref_file = REF_FILE.format(idx) + ref_content = REF_TEMPLATE.format(pos=pos, wm=ref_wm, posval=ruby_pos) + write_file(ref_file, ref_content) + suffix = iter(SUFFIXES) + for wm, posval in subtests: + test_file = TEST_FILE.format(idx, next(suffix)) + test_content = TEST_TEMPLATE.format( + wm=wm, pos=pos, index=idx, ruby_pos=ruby_pos, posval=posval) + write_file(test_file, test_content) + print("== {} {}".format(test_file, ref_file)) +print("# END tests from {}".format(__file__)) |