aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorCharles Yin <charles.yin@nokia.com>2011-10-06 14:08:37 +1000
committerQt by Nokia <qt-info@nokia.com>2011-10-06 10:44:27 +0200
commit4e06807baf317709562d0a5283efc24fdcbd14a3 (patch)
treeef18eabbaf30c6b806876ff5e749df97db0db11c /tests
parent0db214e51ac36d5ce5499c52cf4054b81e910bbb (diff)
add canvas drawImage unit tests
Change-Id: I772bf58bead4b536cc632983846743e0d576bedd Reviewed-on: http://codereview.qt-project.org/6100 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Charles Yin <charles.yin@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qsgcanvasitem/data/anim-gr.gifbin0 -> 241 bytes
-rw-r--r--tests/auto/declarative/qsgcanvasitem/data/anim-gr.pngbin0 -> 460 bytes
-rw-r--r--tests/auto/declarative/qsgcanvasitem/data/anim-poster-gr.pngbin0 -> 422 bytes
-rw-r--r--tests/auto/declarative/qsgcanvasitem/data/background.pngbin0 -> 86 bytes
-rw-r--r--tests/auto/declarative/qsgcanvasitem/data/broken.pngbin0 -> 87 bytes
-rw-r--r--tests/auto/declarative/qsgcanvasitem/data/ggrr-256x256.pngbin0 -> 120 bytes
-rw-r--r--tests/auto/declarative/qsgcanvasitem/data/green-16x16.pngbin0 -> 92 bytes
-rw-r--r--tests/auto/declarative/qsgcanvasitem/data/green-1x1.pngbin0 -> 82 bytes
-rw-r--r--tests/auto/declarative/qsgcanvasitem/data/green-256x256.pngbin0 -> 103 bytes
-rw-r--r--tests/auto/declarative/qsgcanvasitem/data/green-2x2.pngbin0 -> 118 bytes
-rw-r--r--tests/auto/declarative/qsgcanvasitem/data/green.pngbin0 -> 87 bytes
-rw-r--r--tests/auto/declarative/qsgcanvasitem/data/grgr-256x256.pngbin0 -> 130 bytes
-rw-r--r--tests/auto/declarative/qsgcanvasitem/data/qt-logo.pngbin23519 -> 0 bytes
-rw-r--r--tests/auto/declarative/qsgcanvasitem/data/red-16x16.pngbin0 -> 130 bytes
-rw-r--r--tests/auto/declarative/qsgcanvasitem/data/red.pngbin0 -> 87 bytes
-rw-r--r--tests/auto/declarative/qsgcanvasitem/data/redtransparent.pngbin0 -> 109 bytes
-rw-r--r--tests/auto/declarative/qsgcanvasitem/data/rgrg-256x256.pngbin0 -> 131 bytes
-rw-r--r--tests/auto/declarative/qsgcanvasitem/data/rrgg-256x256.pngbin0 -> 120 bytes
-rw-r--r--tests/auto/declarative/qsgcanvasitem/data/transparent.pngbin0 -> 100 bytes
-rw-r--r--tests/auto/declarative/qsgcanvasitem/data/transparent50.pngbin0 -> 155 bytes
-rw-r--r--tests/auto/declarative/qsgcanvasitem/data/tst_canvas.qml18
-rw-r--r--tests/auto/declarative/qsgcanvasitem/data/tst_drawimage.qml622
-rw-r--r--tests/auto/declarative/qsgcanvasitem/data/yellow.pngbin0 -> 95 bytes
-rw-r--r--tests/auto/declarative/qsgcanvasitem/data/yellow75.pngbin0 -> 150 bytes
24 files changed, 630 insertions, 10 deletions
diff --git a/tests/auto/declarative/qsgcanvasitem/data/anim-gr.gif b/tests/auto/declarative/qsgcanvasitem/data/anim-gr.gif
new file mode 100644
index 0000000000..45263e0afb
--- /dev/null
+++ b/tests/auto/declarative/qsgcanvasitem/data/anim-gr.gif
Binary files differ
diff --git a/tests/auto/declarative/qsgcanvasitem/data/anim-gr.png b/tests/auto/declarative/qsgcanvasitem/data/anim-gr.png
new file mode 100644
index 0000000000..925e2efc9a
--- /dev/null
+++ b/tests/auto/declarative/qsgcanvasitem/data/anim-gr.png
Binary files differ
diff --git a/tests/auto/declarative/qsgcanvasitem/data/anim-poster-gr.png b/tests/auto/declarative/qsgcanvasitem/data/anim-poster-gr.png
new file mode 100644
index 0000000000..6941207373
--- /dev/null
+++ b/tests/auto/declarative/qsgcanvasitem/data/anim-poster-gr.png
Binary files differ
diff --git a/tests/auto/declarative/qsgcanvasitem/data/background.png b/tests/auto/declarative/qsgcanvasitem/data/background.png
new file mode 100644
index 0000000000..6db6c6b1b9
--- /dev/null
+++ b/tests/auto/declarative/qsgcanvasitem/data/background.png
Binary files differ
diff --git a/tests/auto/declarative/qsgcanvasitem/data/broken.png b/tests/auto/declarative/qsgcanvasitem/data/broken.png
new file mode 100644
index 0000000000..f2581017b4
--- /dev/null
+++ b/tests/auto/declarative/qsgcanvasitem/data/broken.png
Binary files differ
diff --git a/tests/auto/declarative/qsgcanvasitem/data/ggrr-256x256.png b/tests/auto/declarative/qsgcanvasitem/data/ggrr-256x256.png
new file mode 100644
index 0000000000..0342e4a384
--- /dev/null
+++ b/tests/auto/declarative/qsgcanvasitem/data/ggrr-256x256.png
Binary files differ
diff --git a/tests/auto/declarative/qsgcanvasitem/data/green-16x16.png b/tests/auto/declarative/qsgcanvasitem/data/green-16x16.png
new file mode 100644
index 0000000000..e19a3ffddd
--- /dev/null
+++ b/tests/auto/declarative/qsgcanvasitem/data/green-16x16.png
Binary files differ
diff --git a/tests/auto/declarative/qsgcanvasitem/data/green-1x1.png b/tests/auto/declarative/qsgcanvasitem/data/green-1x1.png
new file mode 100644
index 0000000000..862d1dd10c
--- /dev/null
+++ b/tests/auto/declarative/qsgcanvasitem/data/green-1x1.png
Binary files differ
diff --git a/tests/auto/declarative/qsgcanvasitem/data/green-256x256.png b/tests/auto/declarative/qsgcanvasitem/data/green-256x256.png
new file mode 100644
index 0000000000..b06945c310
--- /dev/null
+++ b/tests/auto/declarative/qsgcanvasitem/data/green-256x256.png
Binary files differ
diff --git a/tests/auto/declarative/qsgcanvasitem/data/green-2x2.png b/tests/auto/declarative/qsgcanvasitem/data/green-2x2.png
new file mode 100644
index 0000000000..adc059449c
--- /dev/null
+++ b/tests/auto/declarative/qsgcanvasitem/data/green-2x2.png
Binary files differ
diff --git a/tests/auto/declarative/qsgcanvasitem/data/green.png b/tests/auto/declarative/qsgcanvasitem/data/green.png
new file mode 100644
index 0000000000..28a1faab37
--- /dev/null
+++ b/tests/auto/declarative/qsgcanvasitem/data/green.png
Binary files differ
diff --git a/tests/auto/declarative/qsgcanvasitem/data/grgr-256x256.png b/tests/auto/declarative/qsgcanvasitem/data/grgr-256x256.png
new file mode 100644
index 0000000000..b8c7189d62
--- /dev/null
+++ b/tests/auto/declarative/qsgcanvasitem/data/grgr-256x256.png
Binary files differ
diff --git a/tests/auto/declarative/qsgcanvasitem/data/qt-logo.png b/tests/auto/declarative/qsgcanvasitem/data/qt-logo.png
deleted file mode 100644
index 5ab3a1b0c4..0000000000
--- a/tests/auto/declarative/qsgcanvasitem/data/qt-logo.png
+++ /dev/null
Binary files differ
diff --git a/tests/auto/declarative/qsgcanvasitem/data/red-16x16.png b/tests/auto/declarative/qsgcanvasitem/data/red-16x16.png
new file mode 100644
index 0000000000..9038fef784
--- /dev/null
+++ b/tests/auto/declarative/qsgcanvasitem/data/red-16x16.png
Binary files differ
diff --git a/tests/auto/declarative/qsgcanvasitem/data/red.png b/tests/auto/declarative/qsgcanvasitem/data/red.png
new file mode 100644
index 0000000000..a6e195d59c
--- /dev/null
+++ b/tests/auto/declarative/qsgcanvasitem/data/red.png
Binary files differ
diff --git a/tests/auto/declarative/qsgcanvasitem/data/redtransparent.png b/tests/auto/declarative/qsgcanvasitem/data/redtransparent.png
new file mode 100644
index 0000000000..75da08c3d6
--- /dev/null
+++ b/tests/auto/declarative/qsgcanvasitem/data/redtransparent.png
Binary files differ
diff --git a/tests/auto/declarative/qsgcanvasitem/data/rgrg-256x256.png b/tests/auto/declarative/qsgcanvasitem/data/rgrg-256x256.png
new file mode 100644
index 0000000000..e6fba3daa5
--- /dev/null
+++ b/tests/auto/declarative/qsgcanvasitem/data/rgrg-256x256.png
Binary files differ
diff --git a/tests/auto/declarative/qsgcanvasitem/data/rrgg-256x256.png b/tests/auto/declarative/qsgcanvasitem/data/rrgg-256x256.png
new file mode 100644
index 0000000000..7f63515654
--- /dev/null
+++ b/tests/auto/declarative/qsgcanvasitem/data/rrgg-256x256.png
Binary files differ
diff --git a/tests/auto/declarative/qsgcanvasitem/data/transparent.png b/tests/auto/declarative/qsgcanvasitem/data/transparent.png
new file mode 100644
index 0000000000..2b498699a8
--- /dev/null
+++ b/tests/auto/declarative/qsgcanvasitem/data/transparent.png
Binary files differ
diff --git a/tests/auto/declarative/qsgcanvasitem/data/transparent50.png b/tests/auto/declarative/qsgcanvasitem/data/transparent50.png
new file mode 100644
index 0000000000..55f8e69325
--- /dev/null
+++ b/tests/auto/declarative/qsgcanvasitem/data/transparent50.png
Binary files differ
diff --git a/tests/auto/declarative/qsgcanvasitem/data/tst_canvas.qml b/tests/auto/declarative/qsgcanvasitem/data/tst_canvas.qml
index 65649df76f..b6621d813f 100644
--- a/tests/auto/declarative/qsgcanvasitem/data/tst_canvas.qml
+++ b/tests/auto/declarative/qsgcanvasitem/data/tst_canvas.qml
@@ -234,17 +234,17 @@ Rectangle {
var c = canvas.createObject();
verify(c);
- c.loadImage("qt-logo.png");
+ c.loadImage("red.png");
wait(200);
compare(c.imageLoadedCount, 1);
- verify(c.isImageLoaded("qt-logo.png"));
- verify(!c.isImageLoading("qt-logo.png"));
- verify(!c.isImageError("qt-logo.png"));
-
- c.unloadImage("qt-logo.png");
- verify(!c.isImageLoaded("qt-logo.png"));
- verify(!c.isImageLoading("qt-logo.png"));
- verify(!c.isImageError("qt-logo.png"));
+ verify(c.isImageLoaded("red.png"));
+ verify(!c.isImageLoading("red.png"));
+ verify(!c.isImageError("red.png"));
+
+ c.unloadImage("red.png");
+ verify(!c.isImageLoaded("red.png"));
+ verify(!c.isImageLoading("red.png"));
+ verify(!c.isImageError("red.png"));
c.destroy();
}
diff --git a/tests/auto/declarative/qsgcanvasitem/data/tst_drawimage.qml b/tests/auto/declarative/qsgcanvasitem/data/tst_drawimage.qml
index 2f10501041..3752f528be 100644
--- a/tests/auto/declarative/qsgcanvasitem/data/tst_drawimage.qml
+++ b/tests/auto/declarative/qsgcanvasitem/data/tst_drawimage.qml
@@ -3,32 +3,215 @@ import QtTest 1.0
import "testhelper.js" as Helper
Canvas {
id:canvas; width:100;height:50; renderTarget: Canvas.Image
+ Component.onCompleted: {
+ canvas.loadImage('green.png');
+ canvas.loadImage('red.png');
+ canvas.loadImage('rgrg-256x256.png');
+ canvas.loadImage('ggrr-256x256.png');
+ canvas.loadImage('broken.png');
+ }
+
TestCase {
//TODO
name: "image"; when: windowShown
function test_3args() {
+ //make sure all images are loaded
+ wait(200);
var ctx = canvas.getContext('2d');
ctx.reset();
+ ctx.drawImage('green.png', 0, 0);
+ ctx.drawImage('red.png', -100, 0);
+ ctx.drawImage('red.png', 100, 0);
+ ctx.drawImage('red.png', 0, -50);
+ ctx.drawImage('red.png', 0, 50);
+
+ verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2));
+
}
function test_5args() {
var ctx = canvas.getContext('2d');
ctx.reset();
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.drawImage('green.png', 50, 0, 50, 50);
+ ctx.drawImage('red.png', 0, 0, 50, 50);
+ ctx.fillStyle = '#0f0';
+ ctx.fillRect(0, 0, 50, 50);
+
+ verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2));
+
}
function test_9args() {
var ctx = canvas.getContext('2d');
ctx.reset();
- }
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.drawImage('green.png', 0, 0, 100, 50, 0, 0, 100, 50);
+ verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2));
+
+ ctx.reset();
+
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.drawImage('green.png', 0, 0, 100, 50, 0, 0, 100, 50);
+ ctx.drawImage('red.png', 0, 0, 100, 50, -100, 0, 100, 50);
+ ctx.drawImage('red.png', 0, 0, 100, 50, 100, 0, 100, 50);
+ ctx.drawImage('red.png', 0, 0, 100, 50, 0, -50, 100, 50);
+ ctx.drawImage('red.png', 0, 0, 100, 50, 0, 50, 100, 50);
+ verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2));
+
+
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.drawImage('green.png', 1, 1, 1, 1, 0, 0, 100, 50);
+ ctx.drawImage('red.png', 0, 0, 100, 50, -50, 0, 50, 50);
+ ctx.drawImage('red.png', 0, 0, 100, 50, 100, 0, 50, 50);
+ ctx.drawImage('red.png', 0, 0, 100, 50, 0, -25, 100, 25);
+ ctx.drawImage('red.png', 0, 0, 100, 50, 0, 50, 100, 25);
+ verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2));
+
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.drawImage('rgrg-256x256.png', 140, 20, 100, 50, 0, 0, 100, 50);
+ verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2));
+
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.drawImage('rgrg-256x256.png', 0, 0, 256, 256, 0, 0, 100, 50);
+ ctx.fillStyle = '#0f0';
+ ctx.fillRect(0, 0, 51, 26);
+ ctx.fillRect(49, 24, 51, 26);
+ verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 20,20, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 80,20, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 20,30, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 80,30, 0,255,0,255,2));
+
+ }
function test_animated() {
var ctx = canvas.getContext('2d');
ctx.reset();
+ //should animated image be supported at all?
}
function test_clip() {
var ctx = canvas.getContext('2d');
ctx.reset();
+ ctx.fillStyle = '#0f0';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.rect(-10, -10, 1, 1);
+ ctx.clip();
+ ctx.drawImage('red.png', 0, 0);
+ verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255,2));
+
+
}
+ function test_self() {
+ var ctx = canvas.getContext('2d');
+ ctx.reset();
+
+ ctx.fillStyle = '#0f0';
+ ctx.fillRect(0, 0, 50, 50);
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(50, 0, 50, 50);
+ ctx.drawImage(canvas, 50, 0);
+
+ verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2));
+
+ ctx.reset();
+ ctx.fillStyle = '#0f0';
+ ctx.fillRect(0, 1, 100, 49);
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 1);
+ ctx.drawImage(canvas, 0, 1);
+ ctx.fillStyle = '#0f0';
+ ctx.fillRect(0, 0, 100, 2);
+
+ verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2));
+ verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2));
+
+
+ }
+
+ function test_outsidesource() {
+ var ctx = canvas.getContext('2d');
+ ctx.reset();
+
+ ctx.drawImage('green.png', 10.5, 10.5, 89.5, 39.5, 0, 0, 100, 50);
+ ctx.drawImage('green.png', 5.5, 5.5, -5.5, -5.5, 0, 0, 100, 50);
+ ctx.drawImage('green.png', 100, 50, -5, -5, 0, 0, 100, 50);
+ try { var err = false;
+ ctx.drawImage('red.png', -0.001, 0, 100, 50, 0, 0, 100, 50);
+ } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.drawImage('red.png', -0.001, 0, 100, 50, 0, 0, 100, 50)"); }
+ try { var err = false;
+ ctx.drawImage('red.png', 0, -0.001, 100, 50, 0, 0, 100, 50);
+ } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.drawImage('red.png', 0, -0.001, 100, 50, 0, 0, 100, 50)"); }
+ try { var err = false;
+ ctx.drawImage('red.png', 0, 0, 100.001, 50, 0, 0, 100, 50);
+ } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.drawImage('red.png', 0, 0, 100.001, 50, 0, 0, 100, 50)"); }
+ try { var err = false;
+ ctx.drawImage('red.png', 0, 0, 100, 50.001, 0, 0, 100, 50);
+ } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.drawImage('red.png', 0, 0, 100, 50.001, 0, 0, 100, 50)"); }
+ try { var err = false;
+ ctx.drawImage('red.png', 50, 0, 50.001, 50, 0, 0, 100, 50);
+ } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.drawImage('red.png', 50, 0, 50.001, 50, 0, 0, 100, 50)"); }
+ try { var err = false;
+ ctx.drawImage('red.png', 0, 0, -5, 5, 0, 0, 100, 50);
+ } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.drawImage('red.png', 0, 0, -5, 5, 0, 0, 100, 50)"); }
+ try { var err = false;
+ ctx.drawImage('red.png', 0, 0, 5, -5, 0, 0, 100, 50);
+ } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.drawImage('red.png', 0, 0, 5, -5, 0, 0, 100, 50)"); }
+// try { var err = false;
+// ctx.drawImage('red.png', 110, 60, -20, -20, 0, 0, 100, 50);
+// } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.drawImage('red.png', 110, 60, -20, -20, 0, 0, 100, 50)"); }
+// verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255,2));
+
+ }
+
+ function test_null() {
+ var ctx = canvas.getContext('2d');
+ ctx.reset();
+
+ try { var err = false;
+ ctx.drawImage(null, 0, 0);
+ } catch (e) { if (e.code != DOMException.TYPE_MISMATCH_ERR) fail("Failed assertion: expected exception of type TYPE_MISMATCH_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type TYPE_MISMATCH_ERR: ctx.drawImage(null, 0, 0)"); }
+
+ }
+
function test_composite() {
var ctx = canvas.getContext('2d');
ctx.reset();
+ ctx.fillStyle = '#0f0';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.globalCompositeOperation = 'destination-over';
+ ctx.drawImage('red.png', 0, 0);
+ verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255,2));
+
}
function test_path() {
var ctx = canvas.getContext('2d');
@@ -37,6 +220,443 @@ Canvas {
function test_transform() {
var ctx = canvas.getContext('2d');
ctx.reset();
+ ctx.fillStyle = '#0f0';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.translate(100, 0);
+ ctx.drawImage('red.png', 0, 0);
+ verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255,2));
+
}
+
+ function test_imageitem() {
+ var ctx = canvas.getContext('2d');
+ ctx.reset();
+ //TODO
+ }
+
+ function test_imageData() {
+ var ctx = canvas.getContext('2d');
+ ctx.reset();
+ //TODO
+ }
+
+ function test_wrongtype() {
+ var ctx = canvas.getContext('2d');
+ ctx.reset();
+
+ try { var err = false;
+ ctx.drawImage(undefined, 0, 0);
+ } catch (e) { if (e.code != DOMException.TYPE_MISMATCH_ERR) fail("Failed assertion: expected exception of type TYPE_MISMATCH_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type TYPE_MISMATCH_ERR: ctx.drawImage(undefined, 0, 0)"); }
+ try { var err = false;
+ ctx.drawImage(0, 0, 0);
+ } catch (e) { if (e.code != DOMException.TYPE_MISMATCH_ERR) fail("Failed assertion: expected exception of type TYPE_MISMATCH_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type TYPE_MISMATCH_ERR: ctx.drawImage(0, 0, 0)"); }
+ try { var err = false;
+ ctx.drawImage("", 0, 0);
+ } catch (e) { if (e.code != DOMException.TYPE_MISMATCH_ERR) fail("Failed assertion: expected exception of type TYPE_MISMATCH_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type TYPE_MISMATCH_ERR: ctx.drawImage(\"\", 0, 0)"); }
+ }
+
+ function test_nonfinite() {
+ var ctx = canvas.getContext('2d');
+ ctx.reset();
+
+ ctx.fillStyle = '#0f0';
+ ctx.fillRect(0, 0, 100, 50);
+ var red = 'red.png';
+ ctx.drawImage(red, Infinity, 0);
+ ctx.drawImage(red, -Infinity, 0);
+ ctx.drawImage(red, NaN, 0);
+ ctx.drawImage(red, 0, Infinity);
+ ctx.drawImage(red, 0, -Infinity);
+ ctx.drawImage(red, 0, NaN);
+ ctx.drawImage(red, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, 0, 100, 50);
+ ctx.drawImage(red, -Infinity, 0, 100, 50);
+ ctx.drawImage(red, NaN, 0, 100, 50);
+ ctx.drawImage(red, 0, Infinity, 100, 50);
+ ctx.drawImage(red, 0, -Infinity, 100, 50);
+ ctx.drawImage(red, 0, NaN, 100, 50);
+ ctx.drawImage(red, 0, 0, Infinity, 50);
+ ctx.drawImage(red, 0, 0, -Infinity, 50);
+ ctx.drawImage(red, 0, 0, NaN, 50);
+ ctx.drawImage(red, 0, 0, 100, Infinity);
+ ctx.drawImage(red, 0, 0, 100, -Infinity);
+ ctx.drawImage(red, 0, 0, 100, NaN);
+ ctx.drawImage(red, Infinity, Infinity, 100, 50);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, 50);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, 100, Infinity);
+ ctx.drawImage(red, Infinity, 0, Infinity, 50);
+ ctx.drawImage(red, Infinity, 0, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, 0, 100, Infinity);
+ ctx.drawImage(red, 0, Infinity, Infinity, 50);
+ ctx.drawImage(red, 0, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, 0, Infinity, 100, Infinity);
+ ctx.drawImage(red, 0, 0, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, 0, 100, 50, 0, 0, 100, 50);
+ ctx.drawImage(red, -Infinity, 0, 100, 50, 0, 0, 100, 50);
+ ctx.drawImage(red, NaN, 0, 100, 50, 0, 0, 100, 50);
+ ctx.drawImage(red, 0, Infinity, 100, 50, 0, 0, 100, 50);
+ ctx.drawImage(red, 0, -Infinity, 100, 50, 0, 0, 100, 50);
+ ctx.drawImage(red, 0, NaN, 100, 50, 0, 0, 100, 50);
+ ctx.drawImage(red, 0, 0, Infinity, 50, 0, 0, 100, 50);
+ ctx.drawImage(red, 0, 0, -Infinity, 50, 0, 0, 100, 50);
+ ctx.drawImage(red, 0, 0, NaN, 50, 0, 0, 100, 50);
+ ctx.drawImage(red, 0, 0, 100, Infinity, 0, 0, 100, 50);
+ ctx.drawImage(red, 0, 0, 100, -Infinity, 0, 0, 100, 50);
+ ctx.drawImage(red, 0, 0, 100, NaN, 0, 0, 100, 50);
+ ctx.drawImage(red, 0, 0, 100, 50, Infinity, 0, 100, 50);
+ ctx.drawImage(red, 0, 0, 100, 50, -Infinity, 0, 100, 50);
+ ctx.drawImage(red, 0, 0, 100, 50, NaN, 0, 100, 50);
+ ctx.drawImage(red, 0, 0, 100, 50, 0, Infinity, 100, 50);
+ ctx.drawImage(red, 0, 0, 100, 50, 0, -Infinity, 100, 50);
+ ctx.drawImage(red, 0, 0, 100, 50, 0, NaN, 100, 50);
+ ctx.drawImage(red, 0, 0, 100, 50, 0, 0, Infinity, 50);
+ ctx.drawImage(red, 0, 0, 100, 50, 0, 0, -Infinity, 50);
+ ctx.drawImage(red, 0, 0, 100, 50, 0, 0, NaN, 50);
+ ctx.drawImage(red, 0, 0, 100, 50, 0, 0, 100, Infinity);
+ ctx.drawImage(red, 0, 0, 100, 50, 0, 0, 100, -Infinity);
+ ctx.drawImage(red, 0, 0, 100, 50, 0, 0, 100, NaN);
+ ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, 0, 100, 50);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, 0, 100, 50);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, 0, 100, 50);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, 0, 100, 50);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 100, 50);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 50);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 100, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 50);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, 0, 100, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 100, 50);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity, 50);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 100, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, 0, Infinity, 50);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, 0, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, 0, 100, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, 0, 100, 50);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, Infinity, 100, 50);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, Infinity, Infinity, 50);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, Infinity, 100, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, 0, Infinity, 50);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, 0, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, 0, 100, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, Infinity, 100, 50);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, Infinity, Infinity, 50);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, Infinity, 100, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, 0, Infinity, 50);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, 0, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, 0, 100, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, 0, 100, 50);
+ ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, 0, 100, 50);
+ ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, Infinity, 100, 50);
+ ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, Infinity, Infinity, 50);
+ ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, Infinity, 100, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, 0, Infinity, 50);
+ ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, 0, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, 0, 100, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, Infinity, 100, 50);
+ ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, Infinity, Infinity, 50);
+ ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, Infinity, 100, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, 0, Infinity, 50);
+ ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, 0, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, 0, 100, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, 0, 100, 50);
+ ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, Infinity, 100, 50);
+ ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, Infinity, Infinity, 50);
+ ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, Infinity, 100, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, 0, Infinity, 50);
+ ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, 0, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, 0, 100, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, Infinity, 100, 50);
+ ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, Infinity, Infinity, 50);
+ ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, Infinity, 100, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, 0, Infinity, 50);
+ ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, 0, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, 0, 100, Infinity);
+ ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, 0, 100, 50);
+ ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, 0, 100, 50);
+ ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, 0, 100, 50);
+ ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, Infinity, 100, 50);
+ ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 50);
+ ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, Infinity, 100, Infinity);
+ ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, 0, Infinity, 50);
+ ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, 0, 100, Infinity);
+ ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, Infinity, 100, 50);
+ ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, Infinity, Infinity, 50);
+ ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, Infinity, 100, Infinity);
+ ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, 0, Infinity, 50);
+ ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, 0, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, 0, 100, Infinity);
+ ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, 0, 100, 50);
+ ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, Infinity, 100, 50);
+ ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, Infinity, Infinity, 50);
+ ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, Infinity, 100, Infinity);
+ ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, 0, Infinity, 50);
+ ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, 0, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, 0, 100, Infinity);
+ ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, Infinity, 100, 50);
+ ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, Infinity, Infinity, 50);
+ ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, Infinity, 100, Infinity);
+ ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, 0, Infinity, 50);
+ ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, 0, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, 0, 100, Infinity);
+ ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, 0, 100, 50);
+ ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, 0, 100, 50);
+ ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, Infinity, 100, 50);
+ ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, Infinity, Infinity, 50);
+ ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, Infinity, 100, Infinity);
+ ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, 0, Infinity, 50);
+ ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, 0, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, 0, 100, Infinity);
+ ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, Infinity, 100, 50);
+ ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, Infinity, Infinity, 50);
+ ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, Infinity, 100, Infinity);
+ ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, 0, Infinity, 50);
+ ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, 0, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, 0, 100, Infinity);
+ ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, 0, 100, 50);
+ ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, Infinity, 100, 50);
+ ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, Infinity, Infinity, 50);
+ ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, Infinity, 100, Infinity);
+ ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, 0, Infinity, 50);
+ ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, 0, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, 0, 100, Infinity);
+ ctx.drawImage(red, Infinity, 0, 100, 50, 0, Infinity, 100, 50);
+ ctx.drawImage(red, Infinity, 0, 100, 50, 0, Infinity, Infinity, 50);
+ ctx.drawImage(red, Infinity, 0, 100, 50, 0, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, 0, 100, 50, 0, Infinity, 100, Infinity);
+ ctx.drawImage(red, Infinity, 0, 100, 50, 0, 0, Infinity, 50);
+ ctx.drawImage(red, Infinity, 0, 100, 50, 0, 0, Infinity, Infinity);
+ ctx.drawImage(red, Infinity, 0, 100, 50, 0, 0, 100, Infinity);
+ ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, 0, 100, 50);
+ ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, 0, 100, 50);
+ ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, 0, 100, 50);
+ ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 100, 50);
+ ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 50);
+ ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 100, Infinity);
+ ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 50);
+ ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity);
+ ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, 0, 100, Infinity);
+ ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, Infinity, 100, 50);
+ ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity, 50);
+ ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, Infinity, 100, Infinity);
+ ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, 0, Infinity, 50);
+ ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, 0, Infinity, Infinity);
+ ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, 0, 100, Infinity);
+ ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, 0, 100, 50);
+ ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, Infinity, 100, 50);
+ ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, Infinity, Infinity, 50);
+ ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, Infinity, 100, Infinity);
+ ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, 0, Infinity, 50);
+ ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, 0, Infinity, Infinity);
+ ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, 0, 100, Infinity);
+ ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, Infinity, 100, 50);
+ ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, Infinity, Infinity, 50);
+ ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, Infinity, 100, Infinity);
+ ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, 0, Infinity, 50);
+ ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, 0, Infinity, Infinity);
+ ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, 0, 100, Infinity);
+ ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, 0, 100, 50);
+ ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, 0, 100, 50);
+ ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, Infinity, 100, 50);
+ ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, Infinity, Infinity, 50);
+ ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, Infinity, 100, Infinity);
+ ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, 0, Infinity, 50);
+ ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, 0, Infinity, Infinity);
+ ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, 0, 100, Infinity);
+ ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, Infinity, 100, 50);
+ ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, Infinity, Infinity, 50);
+ ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, Infinity, 100, Infinity);
+ ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, 0, Infinity, 50);
+ ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, 0, Infinity, Infinity);
+ ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, 0, 100, Infinity);
+ ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, 0, 100, 50);
+ ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, Infinity, 100, 50);
+ ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, Infinity, Infinity, 50);
+ ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, Infinity, 100, Infinity);
+ ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, 0, Infinity, 50);
+ ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, 0, Infinity, Infinity);
+ ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, 0, 100, Infinity);
+ ctx.drawImage(red, 0, Infinity, 100, 50, 0, Infinity, 100, 50);
+ ctx.drawImage(red, 0, Infinity, 100, 50, 0, Infinity, Infinity, 50);
+ ctx.drawImage(red, 0, Infinity, 100, 50, 0, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, 0, Infinity, 100, 50, 0, Infinity, 100, Infinity);
+ ctx.drawImage(red, 0, Infinity, 100, 50, 0, 0, Infinity, 50);
+ ctx.drawImage(red, 0, Infinity, 100, 50, 0, 0, Infinity, Infinity);
+ ctx.drawImage(red, 0, Infinity, 100, 50, 0, 0, 100, Infinity);
+ ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, 0, 100, 50);
+ ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, 0, 100, 50);
+ ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, Infinity, 100, 50);
+ ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 50);
+ ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, Infinity, 100, Infinity);
+ ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, 0, Infinity, 50);
+ ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity);
+ ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, 0, 100, Infinity);
+ ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, Infinity, 100, 50);
+ ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, Infinity, Infinity, 50);
+ ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, Infinity, 100, Infinity);
+ ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, 0, Infinity, 50);
+ ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, 0, Infinity, Infinity);
+ ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, 0, 100, Infinity);
+ ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, 0, 100, 50);
+ ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, Infinity, 100, 50);
+ ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, Infinity, Infinity, 50);
+ ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, Infinity, 100, Infinity);
+ ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, 0, Infinity, 50);
+ ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, 0, Infinity, Infinity);
+ ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, 0, 100, Infinity);
+ ctx.drawImage(red, 0, 0, Infinity, 50, 0, Infinity, 100, 50);
+ ctx.drawImage(red, 0, 0, Infinity, 50, 0, Infinity, Infinity, 50);
+ ctx.drawImage(red, 0, 0, Infinity, 50, 0, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, 0, 0, Infinity, 50, 0, Infinity, 100, Infinity);
+ ctx.drawImage(red, 0, 0, Infinity, 50, 0, 0, Infinity, 50);
+ ctx.drawImage(red, 0, 0, Infinity, 50, 0, 0, Infinity, Infinity);
+ ctx.drawImage(red, 0, 0, Infinity, 50, 0, 0, 100, Infinity);
+ ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, 0, 100, 50);
+ ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, Infinity, 100, 50);
+ ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, Infinity, Infinity, 50);
+ ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, Infinity, 100, Infinity);
+ ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, 0, Infinity, 50);
+ ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, 0, Infinity, Infinity);
+ ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, 0, 100, Infinity);
+ ctx.drawImage(red, 0, 0, 100, Infinity, 0, Infinity, 100, 50);
+ ctx.drawImage(red, 0, 0, 100, Infinity, 0, Infinity, Infinity, 50);
+ ctx.drawImage(red, 0, 0, 100, Infinity, 0, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, 0, 0, 100, Infinity, 0, Infinity, 100, Infinity);
+ ctx.drawImage(red, 0, 0, 100, Infinity, 0, 0, Infinity, 50);
+ ctx.drawImage(red, 0, 0, 100, Infinity, 0, 0, Infinity, Infinity);
+ ctx.drawImage(red, 0, 0, 100, Infinity, 0, 0, 100, Infinity);
+ ctx.drawImage(red, 0, 0, 100, 50, Infinity, Infinity, 100, 50);
+ ctx.drawImage(red, 0, 0, 100, 50, Infinity, Infinity, Infinity, 50);
+ ctx.drawImage(red, 0, 0, 100, 50, Infinity, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, 0, 0, 100, 50, Infinity, Infinity, 100, Infinity);
+ ctx.drawImage(red, 0, 0, 100, 50, Infinity, 0, Infinity, 50);
+ ctx.drawImage(red, 0, 0, 100, 50, Infinity, 0, Infinity, Infinity);
+ ctx.drawImage(red, 0, 0, 100, 50, Infinity, 0, 100, Infinity);
+ ctx.drawImage(red, 0, 0, 100, 50, 0, Infinity, Infinity, 50);
+ ctx.drawImage(red, 0, 0, 100, 50, 0, Infinity, Infinity, Infinity);
+ ctx.drawImage(red, 0, 0, 100, 50, 0, Infinity, 100, Infinity);
+ ctx.drawImage(red, 0, 0, 100, 50, 0, 0, Infinity, Infinity);
+ verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255));
+
+ }
+
+ function test_negative() {
+ var ctx = canvas.getContext('2d');
+ ctx.reset();
+
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.drawImage('ggrr-256x256.png', 100, 78, 50, 50, 0, 50, 50, -50);
+ ctx.drawImage('ggrr-256x256.png', 100, 128, 50, -50, 100, 50, -50, -50);
+// verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 51,1, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 51,48, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255,2));
+
+ ctx.reset();
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.drawImage('ggrr-256x256.png', 0, 178, 50, -100, 0, 0, 50, 100);
+ ctx.drawImage('ggrr-256x256.png', 0, 78, 50, 100, 50, 100, 50, -100);
+// verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 51,1, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 51,48, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255,2));
+
+ ctx.reset();
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.drawImage('ggrr-256x256.png', 100, 78, -100, 50, 0, 0, 50, 50);
+ ctx.drawImage('ggrr-256x256.png', 100, 128, -100, -50, 50, 0, 50, 50);
+// verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 51,1, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 51,48, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255,2));
+// verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255,2));
+
+ }
+
+ function test_canvas() {
+ var ctx = canvas.getContext('2d');
+ ctx.reset();
+ var canvas2 = Qt.createQmlObject("import QtQuick 2.0; Canvas{renderTarget:Canvas.Image}", canvas);
+ canvas2.width = 100;
+ canvas2.height = 50;
+ var ctx2 = canvas2.getContext('2d');
+ ctx2.fillStyle = '#0f0';
+ ctx2.fillRect(0, 0, 100, 50);
+
+ ctx.fillStyle = '#f00';
+ ctx.drawImage(canvas2, 0, 0);
+
+ //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2));
+ //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2));
+ //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2));
+ //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2));
+
+ }
+
+ function test_broken() {
+ var ctx = canvas.getContext('2d');
+ ctx.reset();
+ var img = 'broken.png';
+ verify(!img.complete);
+ ctx.drawImage(img, 0, 0);
+ }
+
+ function test_alpha() {
+ var ctx=canvas.getContext('2d');
+ ctx.reset();
+ ctx.fillStyle = '#0f0';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.globalAlpha = 0;
+ ctx.drawImage('red.png', 0, 0);
+ verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255, 2));
+
+ }
}
}
diff --git a/tests/auto/declarative/qsgcanvasitem/data/yellow.png b/tests/auto/declarative/qsgcanvasitem/data/yellow.png
new file mode 100644
index 0000000000..51e8aaf38c
--- /dev/null
+++ b/tests/auto/declarative/qsgcanvasitem/data/yellow.png
Binary files differ
diff --git a/tests/auto/declarative/qsgcanvasitem/data/yellow75.png b/tests/auto/declarative/qsgcanvasitem/data/yellow75.png
new file mode 100644
index 0000000000..2bb82c9834
--- /dev/null
+++ b/tests/auto/declarative/qsgcanvasitem/data/yellow75.png
Binary files differ