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

2DContext: Set up tests for new signature of imageData functions #5180

Merged
merged 1 commit into from
Mar 22, 2017
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
@@ -1,28 +1,30 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see an update to this tool. Am I missing something or is this direct modification of these tests the wrong way to go?

Copy link
Member

@gsnedders gsnedders Mar 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they come from the tests2d.yaml files

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also note we'd get a CI failure if it was modifying only the generated files

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

<title>Canvas test: 2d.imageData.create2.round</title>
<title>Canvas test: 2d.imageData.create2.double</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">

<h1>2d.imageData.create2.round</h1>
<p class="desc">createImageData(w, h) is rounded the same as getImageData(0, 0, w, h)</p>
<h1>2d.imageData.create2.double</h1>
<p class="desc">createImageData(w, h) double is converted to long</p>


<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>

<ul id="d"></ul>
<script>
var t = async_test("createImageData(w, h) is rounded the same as getImageData(0, 0, w, h)");
var t = async_test("createImageData(w, h) double is converted to long");
_addTest(function(canvas, ctx) {

var imgdata1 = ctx.createImageData(10.01, 10.99);
var imgdata2 = ctx.getImageData(0, 0, 10.01, 10.99);
_assertSame(imgdata1.width, imgdata2.width, "imgdata1.width", "imgdata2.width");
_assertSame(imgdata1.height, imgdata2.height, "imgdata1.height", "imgdata2.height");
var imgdata2 = ctx.createImageData(-10.01, -10.99);
_assertSame(imgdata1.width, 10, "imgdata1.width", "10");
_assertSame(imgdata1.height, 10, "imgdata1.height", "10");
_assertSame(imgdata2.width, 10, "imgdata2.width", "10");
_assertSame(imgdata2.height, 10, "imgdata2.height", "10");


});
Expand Down
35 changes: 0 additions & 35 deletions 2dcontext/pixel-manipulation/2d.imageData.create2.tiny.html

This file was deleted.

2 changes: 2 additions & 0 deletions 2dcontext/pixel-manipulation/2d.imageData.create2.zero.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ <h1>2d.imageData.create2.zero</h1>
assert_throws("INDEX_SIZE_ERR", function() { ctx.createImageData(10, 0); });
assert_throws("INDEX_SIZE_ERR", function() { ctx.createImageData(0, 10); });
assert_throws("INDEX_SIZE_ERR", function() { ctx.createImageData(0, 0); });
assert_throws("INDEX_SIZE_ERR", function() { ctx.createImageData(0.99, 10); });
assert_throws("INDEX_SIZE_ERR", function() { ctx.createImageData(10, 0.1); });


});
Expand Down
32 changes: 32 additions & 0 deletions 2dcontext/pixel-manipulation/2d.imageData.get.double.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by tools/gentest.py. -->
<title>Canvas test: 2d.imageData.get.double</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body class="show_output">

<h1>2d.imageData.get.double</h1>
<p class="desc">createImageData(w, h) double is converted to long</p>


<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>

<ul id="d"></ul>
<script>
var t = async_test("createImageData(w, h) double is converted to long");
_addTest(function(canvas, ctx) {

var imgdata1 = ctx.getImageData(0, 0, 10.01, 10.99);
var imgdata2 = ctx.getImageData(0, 0, -10.01, -10.99);
_assertSame(imgdata1.width, 10, "imgdata1.width", "10");
_assertSame(imgdata1.height, 10, "imgdata1.height", "10");
_assertSame(imgdata2.width, 10, "imgdata2.width", "10");
_assertSame(imgdata2.height, 10, "imgdata2.height", "10");


});
</script>

30 changes: 0 additions & 30 deletions 2dcontext/pixel-manipulation/2d.imageData.get.tiny.html

This file was deleted.

4 changes: 4 additions & 0 deletions 2dcontext/pixel-manipulation/2d.imageData.get.zero.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ <h1>2d.imageData.get.zero</h1>
assert_throws("INDEX_SIZE_ERR", function() { ctx.getImageData(1, 1, 10, 0); });
assert_throws("INDEX_SIZE_ERR", function() { ctx.getImageData(1, 1, 0, 10); });
assert_throws("INDEX_SIZE_ERR", function() { ctx.getImageData(1, 1, 0, 0); });
assert_throws("INDEX_SIZE_ERR", function() { ctx.getImageData(1, 1, 0.1, 10); });
assert_throws("INDEX_SIZE_ERR", function() { ctx.getImageData(1, 1, 10, 0.99); });
assert_throws("INDEX_SIZE_ERR", function() { ctx.getImageData(1, 1, -0.1, 10); });
assert_throws("INDEX_SIZE_ERR", function() { ctx.getImageData(1, 1, 10, -0.99); });


});
Expand Down
52 changes: 23 additions & 29 deletions 2dcontext/tools/tests2d.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9276,22 +9276,6 @@
isTransparentBlack = false;
@assert isTransparentBlack;

- name: 2d.imageData.create2.tiny
desc: createImageData(sw, sh) works for sizes smaller than one pixel
testing:
- 2d.imageData.create2.size
- 2d.imageData.one
code: |
var imgdata = ctx.createImageData(0.0001, 0.0001);
@assert imgdata.data.length === imgdata.width*imgdata.height*4;
@assert imgdata.width === 1;
@assert imgdata.height === 1;
var isTransparentBlack = true;
for (var i = 0; i < imgdata.data.length; ++i)
if (imgdata.data[i] !== 0)
isTransparentBlack = false;
@assert isTransparentBlack;

- name: 2d.imageData.create2.negative
desc: createImageData(sw, sh) takes the absolute magnitude of the size arguments
testing:
Expand All @@ -9313,6 +9297,8 @@
@assert throws INDEX_SIZE_ERR ctx.createImageData(10, 0);
@assert throws INDEX_SIZE_ERR ctx.createImageData(0, 10);
@assert throws INDEX_SIZE_ERR ctx.createImageData(0, 0);
@assert throws INDEX_SIZE_ERR ctx.createImageData(0.99, 10);
@assert throws INDEX_SIZE_ERR ctx.createImageData(10, 0.1);

- name: 2d.imageData.create2.nonfinite
desc: createImageData() throws TypeError if arguments are not finite
Expand All @@ -9333,15 +9319,17 @@
code: |
@assert throws TypeError ctx.createImageData(null);

- name: 2d.imageData.create2.round
desc: createImageData(w, h) is rounded the same as getImageData(0, 0, w, h)
- name: 2d.imageData.create2.double
desc: createImageData(w, h) double is converted to long
testing:
- 2d.imageData.createround
- 2d.imageData.create2.size
code: |
var imgdata1 = ctx.createImageData(10.01, 10.99);
var imgdata2 = ctx.getImageData(0, 0, 10.01, 10.99);
@assert imgdata1.width === imgdata2.width;
@assert imgdata1.height === imgdata2.height;
var imgdata2 = ctx.createImageData(-10.01, -10.99);
@assert imgdata1.width === 10;
@assert imgdata1.height === 10;
@assert imgdata2.width === 10;
@assert imgdata2.height === 10;

- name: 2d.imageData.get.basic
desc: getImageData() exists and returns something
Expand Down Expand Up @@ -9371,6 +9359,10 @@
@assert throws INDEX_SIZE_ERR ctx.getImageData(1, 1, 10, 0);
@assert throws INDEX_SIZE_ERR ctx.getImageData(1, 1, 0, 10);
@assert throws INDEX_SIZE_ERR ctx.getImageData(1, 1, 0, 0);
@assert throws INDEX_SIZE_ERR ctx.getImageData(1, 1, 0.1, 10);
@assert throws INDEX_SIZE_ERR ctx.getImageData(1, 1, 10, 0.99);
@assert throws INDEX_SIZE_ERR ctx.getImageData(1, 1, -0.1, 10);
@assert throws INDEX_SIZE_ERR ctx.getImageData(1, 1, 10, -0.99);

- name: 2d.imageData.get.nonfinite
desc: getImageData() throws TypeError if arguments are not finite
Expand Down Expand Up @@ -9488,15 +9480,17 @@
@assert imgdata2.width > imgdata1.width;
@assert imgdata2.height > imgdata1.height;

- name: 2d.imageData.get.tiny
desc: getImageData() works for sizes smaller than one pixel
- name: 2d.imageData.get.double
desc: createImageData(w, h) double is converted to long
testing:
- 2d.imageData.one
- 2d.imageData.get.basic
code: |
var imgdata = ctx.getImageData(0, 0, 0.0001, 0.0001);
@assert imgdata.data.length === imgdata.width*imgdata.height*4;
@assert imgdata.width === 1;
@assert imgdata.height === 1;
var imgdata1 = ctx.getImageData(0, 0, 10.01, 10.99);
var imgdata2 = ctx.getImageData(0, 0, -10.01, -10.99);
@assert imgdata1.width === 10;
@assert imgdata1.height === 10;
@assert imgdata2.width === 10;
@assert imgdata2.height === 10;

- name: 2d.imageData.get.nonpremul
desc: getImageData() returns non-premultiplied colours
Expand Down
32 changes: 0 additions & 32 deletions offscreen-canvas/pixel-manipulation/2d.imageData.create2.tiny.html

This file was deleted.

This file was deleted.

16 changes: 0 additions & 16 deletions offscreen-canvas/tools/tests2d.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4936,22 +4936,6 @@
isTransparentBlack = false;
@assert isTransparentBlack;

- name: 2d.imageData.create2.tiny
desc: createImageData(sw, sh) works for sizes smaller than one pixel
testing:
- 2d.imageData.create2.size
- 2d.imageData.one
code: |
var imgdata = ctx.createImageData(0.0001, 0.0001);
@assert imgdata.data.length === imgdata.width*imgdata.height*4;
@assert imgdata.width === 1;
@assert imgdata.height === 1;
var isTransparentBlack = true;
for (var i = 0; i < imgdata.data.length; ++i)
if (imgdata.data[i] !== 0)
isTransparentBlack = false;
@assert isTransparentBlack;

- name: 2d.imageData.create2.negative
desc: createImageData(sw, sh) takes the absolute magnitude of the size arguments
testing:
Expand Down