Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify template to create canvas and offscreencanvas tests #31822

Merged
merged 1 commit into from
Dec 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ <h1>2d.color.space.p3.to.p3</h1>
_addTest(function(canvas, ctx) {

var color_style = 'rgb(50, 100, 150)';
var epsilon = 2;
// [0.24304, 0.38818, 0.57227, 1.0] * 255 = [62, 99, 146, 255]
var pixel_expected = [62, 99, 146, 255];
var epsilon = 2;
ctx.fillStyle = color_style;
ctx.fillRect(0, 0, 10, 10);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ <h1>2d.color.space.p3.to.srgb</h1>
_addTest(function(canvas, ctx) {

var color_style = 'rgb(50, 100, 150)';
var epsilon = 2;
var pixel_expected = [50, 100, 150, 255];
var epsilon = 2;
ctx.fillStyle = color_style;
ctx.fillRect(0, 0, 10, 10);

Expand Down
6 changes: 4 additions & 2 deletions html/canvas/tools/gentest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from gentestutils import genTestUtils
from gentestutilsunion import genTestUtils_union

genTestUtils('../element', '../element', 'templates.yaml', 'name2dir.yaml', False)
genTestUtils('../offscreen', '../offscreen', 'templates-offscreen.yaml', 'name2dir-offscreen.yaml', True)
genTestUtils('../element', '../element', 'templates.yaml', 'name2dir-canvas.yaml', False)
genTestUtils('../offscreen', '../offscreen', 'templates.yaml', 'name2dir-offscreen.yaml', True)
genTestUtils_union('templates-new.yaml', 'name2dir-canvas.yaml')
3 changes: 3 additions & 0 deletions html/canvas/tools/gentest_union.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from gentestutilsunion import genTestUtils_union

genTestUtils_union('templates-new.yaml', 'name2dir-canvas.yaml')
8 changes: 5 additions & 3 deletions html/canvas/tools/gentestutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,15 @@ def expand_test_code(code):
'fallback':fallback, 'attributes':attributes,
'context_args': context_args
}

f = codecs.open('%s/%s%s.html' % (TESTOUTPUTDIR, mapped_name, name_variant), 'w', 'utf-8')
f.write(templates['w3c'] % template_params)
if ISOFFSCREENCANVAS:
f = codecs.open('%s/%s%s.html' % (TESTOUTPUTDIR, mapped_name, name_variant), 'w', 'utf-8')
f.write(templates['w3coffscreencanvas'] % template_params)
timeout = '// META: timeout=%s\n' % test['timeout'] if 'timeout' in test else ''
template_params['timeout'] = timeout
f = codecs.open('%s/%s%s.worker.js' % (TESTOUTPUTDIR, mapped_name, name_variant), 'w', 'utf-8')
f.write(templates['w3cworker'] % template_params)
else:
f = codecs.open('%s/%s%s.html' % (TESTOUTPUTDIR, mapped_name, name_variant), 'w', 'utf-8')
f.write(templates['w3ccanvas'] % template_params)

print()
Loading