Fix test fails related to QTBUG-22237
[profile/ivi/qtdeclarative.git] / tests / auto / declarative / qsgcanvasitem / data / tst_drawimage.qml
1 import QtQuick 2.0
2 import QtTest 1.0
3 import "testhelper.js" as Helper
4 Canvas {
5    id:canvas; width:100;height:50; renderTarget: Canvas.Image
6    Component.onCompleted: {
7        canvas.loadImage('green.png');
8        canvas.loadImage('red.png');
9        canvas.loadImage('rgrg-256x256.png');
10        canvas.loadImage('ggrr-256x256.png');
11        canvas.loadImage('broken.png');
12    }
13
14    TestCase {
15        //TODO
16        name: "image"; when: windowShown
17        function test_3args() {
18            //make sure all images are loaded
19            wait(200);
20            var ctx = canvas.getContext('2d');
21            ctx.reset();
22            ctx.drawImage('green.png', 0, 0);
23            ctx.drawImage('red.png', -100, 0);
24            ctx.drawImage('red.png', 100, 0);
25            ctx.drawImage('red.png', 0, -50);
26            ctx.drawImage('red.png', 0, 50);
27
28            verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2));
29            verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2));
30            verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2));
31            verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2));
32
33       }
34        function test_5args() {
35            var ctx = canvas.getContext('2d');
36            ctx.reset();
37            ctx.fillStyle = '#f00';
38            ctx.fillRect(0, 0, 100, 50);
39            ctx.drawImage('green.png', 50, 0, 50, 50);
40            ctx.drawImage('red.png', 0, 0, 50, 50);
41            ctx.fillStyle = '#0f0';
42            ctx.fillRect(0, 0, 50, 50);
43
44            verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2));
45            verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2));
46            verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2));
47            verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2));
48
49       }
50        function test_9args() {
51            var ctx = canvas.getContext('2d');
52            ctx.reset();
53            ctx.fillStyle = '#f00';
54            ctx.fillRect(0, 0, 100, 50);
55            ctx.drawImage('green.png', 0, 0, 100, 50, 0, 0, 100, 50);
56            verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2));
57            verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2));
58            verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2));
59            verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2));
60
61            ctx.reset();
62
63            ctx.fillStyle = '#f00';
64            ctx.fillRect(0, 0, 100, 50);
65            ctx.drawImage('green.png', 0, 0, 100, 50, 0, 0, 100, 50);
66            ctx.drawImage('red.png', 0, 0, 100, 50, -100, 0, 100, 50);
67            ctx.drawImage('red.png', 0, 0, 100, 50, 100, 0, 100, 50);
68            ctx.drawImage('red.png', 0, 0, 100, 50, 0, -50, 100, 50);
69            ctx.drawImage('red.png', 0, 0, 100, 50, 0, 50, 100, 50);
70            verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2));
71            verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2));
72            verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2));
73            verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2));
74
75
76            ctx.fillStyle = '#f00';
77            ctx.fillRect(0, 0, 100, 50);
78            ctx.drawImage('green.png', 1, 1, 1, 1, 0, 0, 100, 50);
79            ctx.drawImage('red.png', 0, 0, 100, 50, -50, 0, 50, 50);
80            ctx.drawImage('red.png', 0, 0, 100, 50, 100, 0, 50, 50);
81            ctx.drawImage('red.png', 0, 0, 100, 50, 0, -25, 100, 25);
82            ctx.drawImage('red.png', 0, 0, 100, 50, 0, 50, 100, 25);
83            verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2));
84            verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2));
85            verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2));
86            verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2));
87
88            ctx.fillStyle = '#f00';
89            ctx.fillRect(0, 0, 100, 50);
90            ctx.drawImage('rgrg-256x256.png', 140, 20, 100, 50, 0, 0, 100, 50);
91            verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2));
92            verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2));
93            verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2));
94            verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2));
95
96            ctx.fillStyle = '#f00';
97            ctx.fillRect(0, 0, 100, 50);
98            ctx.drawImage('rgrg-256x256.png', 0, 0, 256, 256, 0, 0, 100, 50);
99            ctx.fillStyle = '#0f0';
100            ctx.fillRect(0, 0, 51, 26);
101            ctx.fillRect(49, 24, 51, 26);
102            verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2));
103            verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2));
104            verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2));
105            verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2));
106            verify(Helper.comparePixel(ctx, 20,20, 0,255,0,255,2));
107            verify(Helper.comparePixel(ctx, 80,20, 0,255,0,255,2));
108            verify(Helper.comparePixel(ctx, 20,30, 0,255,0,255,2));
109            verify(Helper.comparePixel(ctx, 80,30, 0,255,0,255,2));
110
111        }
112        function test_animated() {
113            var ctx = canvas.getContext('2d');
114            ctx.reset();
115            //should animated image be supported at all?
116       }
117        function test_clip() {
118            var ctx = canvas.getContext('2d');
119            ctx.reset();
120            ctx.fillStyle = '#0f0';
121            ctx.fillRect(0, 0, 100, 50);
122            ctx.rect(-10, -10, 1, 1);
123            ctx.clip();
124            ctx.drawImage('red.png', 0, 0);
125            verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255,2));
126
127
128       }
129        function test_self() {
130            var ctx = canvas.getContext('2d');
131            ctx.reset();
132
133            ctx.fillStyle = '#0f0';
134            ctx.fillRect(0, 0, 50, 50);
135            ctx.fillStyle = '#f00';
136            ctx.fillRect(50, 0, 50, 50);
137            ctx.drawImage(canvas, 50, 0);
138
139            verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2));
140            verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2));
141            verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2));
142            verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2));
143
144            ctx.reset();
145            ctx.fillStyle = '#0f0';
146            ctx.fillRect(0, 1, 100, 49);
147            ctx.fillStyle = '#f00';
148            ctx.fillRect(0, 0, 100, 1);
149            ctx.drawImage(canvas, 0, 1);
150            ctx.fillStyle = '#0f0';
151            ctx.fillRect(0, 0, 100, 2);
152
153            verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2));
154            verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2));
155            verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2));
156            verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2));
157
158
159        }
160
161        function test_outsidesource() {
162            var ctx = canvas.getContext('2d');
163            ctx.reset();
164
165            ctx.drawImage('green.png', 10.5, 10.5, 89.5, 39.5, 0, 0, 100, 50);
166            ctx.drawImage('green.png', 5.5, 5.5, -5.5, -5.5, 0, 0, 100, 50);
167            ctx.drawImage('green.png', 100, 50, -5, -5, 0, 0, 100, 50);
168            try { var err = false;
169              ctx.drawImage('red.png', -0.001, 0, 100, 50, 0, 0, 100, 50);
170            } 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)"); }
171            try { var err = false;
172              ctx.drawImage('red.png', 0, -0.001, 100, 50, 0, 0, 100, 50);
173            } 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)"); }
174            try { var err = false;
175              ctx.drawImage('red.png', 0, 0, 100.001, 50, 0, 0, 100, 50);
176            } 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)"); }
177            try { var err = false;
178              ctx.drawImage('red.png', 0, 0, 100, 50.001, 0, 0, 100, 50);
179            } 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)"); }
180            try { var err = false;
181              ctx.drawImage('red.png', 50, 0, 50.001, 50, 0, 0, 100, 50);
182            } 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)"); }
183            try { var err = false;
184              ctx.drawImage('red.png', 0, 0, -5, 5, 0, 0, 100, 50);
185            } 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)"); }
186            try { var err = false;
187              ctx.drawImage('red.png', 0, 0, 5, -5, 0, 0, 100, 50);
188            } 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)"); }
189 //           try { var err = false;
190 //             ctx.drawImage('red.png', 110, 60, -20, -20, 0, 0, 100, 50);
191 //           } 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)"); }
192 //           verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255,2));
193
194        }
195
196        function test_null() {
197            var ctx = canvas.getContext('2d');
198            ctx.reset();
199
200            try { var err = false;
201              ctx.drawImage(null, 0, 0);
202            } 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)"); }
203
204        }
205
206        function test_composite() {
207            var ctx = canvas.getContext('2d');
208            ctx.reset();
209            ctx.fillStyle = '#0f0';
210            ctx.fillRect(0, 0, 100, 50);
211            ctx.globalCompositeOperation = 'destination-over';
212            ctx.drawImage('red.png', 0, 0);
213            verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255,2));
214
215       }
216        function test_path() {
217            var ctx = canvas.getContext('2d');
218            ctx.reset();
219       }
220        function test_transform() {
221            var ctx = canvas.getContext('2d');
222            ctx.reset();
223            ctx.fillStyle = '#0f0';
224            ctx.fillRect(0, 0, 100, 50);
225            ctx.translate(100, 0);
226            ctx.drawImage('red.png', 0, 0);
227            verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255,2));
228
229       }
230
231        function test_imageitem() {
232            var ctx = canvas.getContext('2d');
233            ctx.reset();
234            //TODO
235        }
236
237        function test_imageData() {
238            var ctx = canvas.getContext('2d');
239            ctx.reset();
240            //TODO
241        }
242
243        function test_wrongtype() {
244            var ctx = canvas.getContext('2d');
245            ctx.reset();
246
247            try { var err = false;
248              ctx.drawImage(undefined, 0, 0);
249            } 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)"); }
250            try { var err = false;
251              ctx.drawImage(0, 0, 0);
252            } 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)"); }
253            try { var err = false;
254              ctx.drawImage("", 0, 0);
255            } 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)"); }
256        }
257
258        function test_nonfinite() {
259            var ctx = canvas.getContext('2d');
260            ctx.reset();
261
262            ctx.fillStyle = '#0f0';
263            ctx.fillRect(0, 0, 100, 50);
264            var red = 'red.png';
265            ctx.drawImage(red, Infinity, 0);
266            ctx.drawImage(red, -Infinity, 0);
267            ctx.drawImage(red, NaN, 0);
268            ctx.drawImage(red, 0, Infinity);
269            ctx.drawImage(red, 0, -Infinity);
270            ctx.drawImage(red, 0, NaN);
271            ctx.drawImage(red, Infinity, Infinity);
272            ctx.drawImage(red, Infinity, 0, 100, 50);
273            ctx.drawImage(red, -Infinity, 0, 100, 50);
274            ctx.drawImage(red, NaN, 0, 100, 50);
275            ctx.drawImage(red, 0, Infinity, 100, 50);
276            ctx.drawImage(red, 0, -Infinity, 100, 50);
277            ctx.drawImage(red, 0, NaN, 100, 50);
278            ctx.drawImage(red, 0, 0, Infinity, 50);
279            ctx.drawImage(red, 0, 0, -Infinity, 50);
280            ctx.drawImage(red, 0, 0, NaN, 50);
281            ctx.drawImage(red, 0, 0, 100, Infinity);
282            ctx.drawImage(red, 0, 0, 100, -Infinity);
283            ctx.drawImage(red, 0, 0, 100, NaN);
284            ctx.drawImage(red, Infinity, Infinity, 100, 50);
285            ctx.drawImage(red, Infinity, Infinity, Infinity, 50);
286            ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity);
287            ctx.drawImage(red, Infinity, Infinity, 100, Infinity);
288            ctx.drawImage(red, Infinity, 0, Infinity, 50);
289            ctx.drawImage(red, Infinity, 0, Infinity, Infinity);
290            ctx.drawImage(red, Infinity, 0, 100, Infinity);
291            ctx.drawImage(red, 0, Infinity, Infinity, 50);
292            ctx.drawImage(red, 0, Infinity, Infinity, Infinity);
293            ctx.drawImage(red, 0, Infinity, 100, Infinity);
294            ctx.drawImage(red, 0, 0, Infinity, Infinity);
295            ctx.drawImage(red, Infinity, 0, 100, 50, 0, 0, 100, 50);
296            ctx.drawImage(red, -Infinity, 0, 100, 50, 0, 0, 100, 50);
297            ctx.drawImage(red, NaN, 0, 100, 50, 0, 0, 100, 50);
298            ctx.drawImage(red, 0, Infinity, 100, 50, 0, 0, 100, 50);
299            ctx.drawImage(red, 0, -Infinity, 100, 50, 0, 0, 100, 50);
300            ctx.drawImage(red, 0, NaN, 100, 50, 0, 0, 100, 50);
301            ctx.drawImage(red, 0, 0, Infinity, 50, 0, 0, 100, 50);
302            ctx.drawImage(red, 0, 0, -Infinity, 50, 0, 0, 100, 50);
303            ctx.drawImage(red, 0, 0, NaN, 50, 0, 0, 100, 50);
304            ctx.drawImage(red, 0, 0, 100, Infinity, 0, 0, 100, 50);
305            ctx.drawImage(red, 0, 0, 100, -Infinity, 0, 0, 100, 50);
306            ctx.drawImage(red, 0, 0, 100, NaN, 0, 0, 100, 50);
307            ctx.drawImage(red, 0, 0, 100, 50, Infinity, 0, 100, 50);
308            ctx.drawImage(red, 0, 0, 100, 50, -Infinity, 0, 100, 50);
309            ctx.drawImage(red, 0, 0, 100, 50, NaN, 0, 100, 50);
310            ctx.drawImage(red, 0, 0, 100, 50, 0, Infinity, 100, 50);
311            ctx.drawImage(red, 0, 0, 100, 50, 0, -Infinity, 100, 50);
312            ctx.drawImage(red, 0, 0, 100, 50, 0, NaN, 100, 50);
313            ctx.drawImage(red, 0, 0, 100, 50, 0, 0, Infinity, 50);
314            ctx.drawImage(red, 0, 0, 100, 50, 0, 0, -Infinity, 50);
315            ctx.drawImage(red, 0, 0, 100, 50, 0, 0, NaN, 50);
316            ctx.drawImage(red, 0, 0, 100, 50, 0, 0, 100, Infinity);
317            ctx.drawImage(red, 0, 0, 100, 50, 0, 0, 100, -Infinity);
318            ctx.drawImage(red, 0, 0, 100, 50, 0, 0, 100, NaN);
319            ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, 0, 100, 50);
320            ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, 0, 100, 50);
321            ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, 0, 100, 50);
322            ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, 0, 100, 50);
323            ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 100, 50);
324            ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 50);
325            ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity);
326            ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 100, Infinity);
327            ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 50);
328            ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity);
329            ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, 0, 100, Infinity);
330            ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 100, 50);
331            ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity, 50);
332            ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity, Infinity);
333            ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 100, Infinity);
334            ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, 0, Infinity, 50);
335            ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, 0, Infinity, Infinity);
336            ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, 0, 100, Infinity);
337            ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, 0, 100, 50);
338            ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, Infinity, 100, 50);
339            ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, Infinity, Infinity, 50);
340            ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, Infinity, Infinity, Infinity);
341            ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, Infinity, 100, Infinity);
342            ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, 0, Infinity, 50);
343            ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, 0, Infinity, Infinity);
344            ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, 0, 100, Infinity);
345            ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, Infinity, 100, 50);
346            ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, Infinity, Infinity, 50);
347            ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, Infinity, Infinity, Infinity);
348            ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, Infinity, 100, Infinity);
349            ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, 0, Infinity, 50);
350            ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, 0, Infinity, Infinity);
351            ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, 0, 100, Infinity);
352            ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, 0, 100, 50);
353            ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, 0, 100, 50);
354            ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, Infinity, 100, 50);
355            ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, Infinity, Infinity, 50);
356            ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, Infinity, Infinity, Infinity);
357            ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, Infinity, 100, Infinity);
358            ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, 0, Infinity, 50);
359            ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, 0, Infinity, Infinity);
360            ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, 0, 100, Infinity);
361            ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, Infinity, 100, 50);
362            ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, Infinity, Infinity, 50);
363            ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, Infinity, Infinity, Infinity);
364            ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, Infinity, 100, Infinity);
365            ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, 0, Infinity, 50);
366            ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, 0, Infinity, Infinity);
367            ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, 0, 100, Infinity);
368            ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, 0, 100, 50);
369            ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, Infinity, 100, 50);
370            ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, Infinity, Infinity, 50);
371            ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, Infinity, Infinity, Infinity);
372            ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, Infinity, 100, Infinity);
373            ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, 0, Infinity, 50);
374            ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, 0, Infinity, Infinity);
375            ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, 0, 100, Infinity);
376            ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, Infinity, 100, 50);
377            ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, Infinity, Infinity, 50);
378            ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, Infinity, Infinity, Infinity);
379            ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, Infinity, 100, Infinity);
380            ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, 0, Infinity, 50);
381            ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, 0, Infinity, Infinity);
382            ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, 0, 100, Infinity);
383            ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, 0, 100, 50);
384            ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, 0, 100, 50);
385            ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, 0, 100, 50);
386            ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, Infinity, 100, 50);
387            ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 50);
388            ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity);
389            ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, Infinity, 100, Infinity);
390            ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, 0, Infinity, 50);
391            ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity);
392            ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, 0, 100, Infinity);
393            ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, Infinity, 100, 50);
394            ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, Infinity, Infinity, 50);
395            ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, Infinity, Infinity, Infinity);
396            ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, Infinity, 100, Infinity);
397            ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, 0, Infinity, 50);
398            ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, 0, Infinity, Infinity);
399            ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, 0, 100, Infinity);
400            ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, 0, 100, 50);
401            ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, Infinity, 100, 50);
402            ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, Infinity, Infinity, 50);
403            ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, Infinity, Infinity, Infinity);
404            ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, Infinity, 100, Infinity);
405            ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, 0, Infinity, 50);
406            ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, 0, Infinity, Infinity);
407            ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, 0, 100, Infinity);
408            ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, Infinity, 100, 50);
409            ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, Infinity, Infinity, 50);
410            ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, Infinity, Infinity, Infinity);
411            ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, Infinity, 100, Infinity);
412            ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, 0, Infinity, 50);
413            ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, 0, Infinity, Infinity);
414            ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, 0, 100, Infinity);
415            ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, 0, 100, 50);
416            ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, 0, 100, 50);
417            ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, Infinity, 100, 50);
418            ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, Infinity, Infinity, 50);
419            ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, Infinity, Infinity, Infinity);
420            ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, Infinity, 100, Infinity);
421            ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, 0, Infinity, 50);
422            ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, 0, Infinity, Infinity);
423            ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, 0, 100, Infinity);
424            ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, Infinity, 100, 50);
425            ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, Infinity, Infinity, 50);
426            ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, Infinity, Infinity, Infinity);
427            ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, Infinity, 100, Infinity);
428            ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, 0, Infinity, 50);
429            ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, 0, Infinity, Infinity);
430            ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, 0, 100, Infinity);
431            ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, 0, 100, 50);
432            ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, Infinity, 100, 50);
433            ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, Infinity, Infinity, 50);
434            ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, Infinity, Infinity, Infinity);
435            ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, Infinity, 100, Infinity);
436            ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, 0, Infinity, 50);
437            ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, 0, Infinity, Infinity);
438            ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, 0, 100, Infinity);
439            ctx.drawImage(red, Infinity, 0, 100, 50, 0, Infinity, 100, 50);
440            ctx.drawImage(red, Infinity, 0, 100, 50, 0, Infinity, Infinity, 50);
441            ctx.drawImage(red, Infinity, 0, 100, 50, 0, Infinity, Infinity, Infinity);
442            ctx.drawImage(red, Infinity, 0, 100, 50, 0, Infinity, 100, Infinity);
443            ctx.drawImage(red, Infinity, 0, 100, 50, 0, 0, Infinity, 50);
444            ctx.drawImage(red, Infinity, 0, 100, 50, 0, 0, Infinity, Infinity);
445            ctx.drawImage(red, Infinity, 0, 100, 50, 0, 0, 100, Infinity);
446            ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, 0, 100, 50);
447            ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, 0, 100, 50);
448            ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, 0, 100, 50);
449            ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 100, 50);
450            ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 50);
451            ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity);
452            ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 100, Infinity);
453            ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 50);
454            ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity);
455            ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, 0, 100, Infinity);
456            ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, Infinity, 100, 50);
457            ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity, 50);
458            ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity, Infinity);
459            ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, Infinity, 100, Infinity);
460            ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, 0, Infinity, 50);
461            ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, 0, Infinity, Infinity);
462            ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, 0, 100, Infinity);
463            ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, 0, 100, 50);
464            ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, Infinity, 100, 50);
465            ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, Infinity, Infinity, 50);
466            ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, Infinity, Infinity, Infinity);
467            ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, Infinity, 100, Infinity);
468            ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, 0, Infinity, 50);
469            ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, 0, Infinity, Infinity);
470            ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, 0, 100, Infinity);
471            ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, Infinity, 100, 50);
472            ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, Infinity, Infinity, 50);
473            ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, Infinity, Infinity, Infinity);
474            ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, Infinity, 100, Infinity);
475            ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, 0, Infinity, 50);
476            ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, 0, Infinity, Infinity);
477            ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, 0, 100, Infinity);
478            ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, 0, 100, 50);
479            ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, 0, 100, 50);
480            ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, Infinity, 100, 50);
481            ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, Infinity, Infinity, 50);
482            ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, Infinity, Infinity, Infinity);
483            ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, Infinity, 100, Infinity);
484            ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, 0, Infinity, 50);
485            ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, 0, Infinity, Infinity);
486            ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, 0, 100, Infinity);
487            ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, Infinity, 100, 50);
488            ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, Infinity, Infinity, 50);
489            ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, Infinity, Infinity, Infinity);
490            ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, Infinity, 100, Infinity);
491            ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, 0, Infinity, 50);
492            ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, 0, Infinity, Infinity);
493            ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, 0, 100, Infinity);
494            ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, 0, 100, 50);
495            ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, Infinity, 100, 50);
496            ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, Infinity, Infinity, 50);
497            ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, Infinity, Infinity, Infinity);
498            ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, Infinity, 100, Infinity);
499            ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, 0, Infinity, 50);
500            ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, 0, Infinity, Infinity);
501            ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, 0, 100, Infinity);
502            ctx.drawImage(red, 0, Infinity, 100, 50, 0, Infinity, 100, 50);
503            ctx.drawImage(red, 0, Infinity, 100, 50, 0, Infinity, Infinity, 50);
504            ctx.drawImage(red, 0, Infinity, 100, 50, 0, Infinity, Infinity, Infinity);
505            ctx.drawImage(red, 0, Infinity, 100, 50, 0, Infinity, 100, Infinity);
506            ctx.drawImage(red, 0, Infinity, 100, 50, 0, 0, Infinity, 50);
507            ctx.drawImage(red, 0, Infinity, 100, 50, 0, 0, Infinity, Infinity);
508            ctx.drawImage(red, 0, Infinity, 100, 50, 0, 0, 100, Infinity);
509            ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, 0, 100, 50);
510            ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, 0, 100, 50);
511            ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, Infinity, 100, 50);
512            ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 50);
513            ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity);
514            ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, Infinity, 100, Infinity);
515            ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, 0, Infinity, 50);
516            ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity);
517            ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, 0, 100, Infinity);
518            ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, Infinity, 100, 50);
519            ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, Infinity, Infinity, 50);
520            ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, Infinity, Infinity, Infinity);
521            ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, Infinity, 100, Infinity);
522            ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, 0, Infinity, 50);
523            ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, 0, Infinity, Infinity);
524            ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, 0, 100, Infinity);
525            ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, 0, 100, 50);
526            ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, Infinity, 100, 50);
527            ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, Infinity, Infinity, 50);
528            ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, Infinity, Infinity, Infinity);
529            ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, Infinity, 100, Infinity);
530            ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, 0, Infinity, 50);
531            ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, 0, Infinity, Infinity);
532            ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, 0, 100, Infinity);
533            ctx.drawImage(red, 0, 0, Infinity, 50, 0, Infinity, 100, 50);
534            ctx.drawImage(red, 0, 0, Infinity, 50, 0, Infinity, Infinity, 50);
535            ctx.drawImage(red, 0, 0, Infinity, 50, 0, Infinity, Infinity, Infinity);
536            ctx.drawImage(red, 0, 0, Infinity, 50, 0, Infinity, 100, Infinity);
537            ctx.drawImage(red, 0, 0, Infinity, 50, 0, 0, Infinity, 50);
538            ctx.drawImage(red, 0, 0, Infinity, 50, 0, 0, Infinity, Infinity);
539            ctx.drawImage(red, 0, 0, Infinity, 50, 0, 0, 100, Infinity);
540            ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, 0, 100, 50);
541            ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, Infinity, 100, 50);
542            ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, Infinity, Infinity, 50);
543            ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, Infinity, Infinity, Infinity);
544            ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, Infinity, 100, Infinity);
545            ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, 0, Infinity, 50);
546            ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, 0, Infinity, Infinity);
547            ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, 0, 100, Infinity);
548            ctx.drawImage(red, 0, 0, 100, Infinity, 0, Infinity, 100, 50);
549            ctx.drawImage(red, 0, 0, 100, Infinity, 0, Infinity, Infinity, 50);
550            ctx.drawImage(red, 0, 0, 100, Infinity, 0, Infinity, Infinity, Infinity);
551            ctx.drawImage(red, 0, 0, 100, Infinity, 0, Infinity, 100, Infinity);
552            ctx.drawImage(red, 0, 0, 100, Infinity, 0, 0, Infinity, 50);
553            ctx.drawImage(red, 0, 0, 100, Infinity, 0, 0, Infinity, Infinity);
554            ctx.drawImage(red, 0, 0, 100, Infinity, 0, 0, 100, Infinity);
555            ctx.drawImage(red, 0, 0, 100, 50, Infinity, Infinity, 100, 50);
556            ctx.drawImage(red, 0, 0, 100, 50, Infinity, Infinity, Infinity, 50);
557            ctx.drawImage(red, 0, 0, 100, 50, Infinity, Infinity, Infinity, Infinity);
558            ctx.drawImage(red, 0, 0, 100, 50, Infinity, Infinity, 100, Infinity);
559            ctx.drawImage(red, 0, 0, 100, 50, Infinity, 0, Infinity, 50);
560            ctx.drawImage(red, 0, 0, 100, 50, Infinity, 0, Infinity, Infinity);
561            ctx.drawImage(red, 0, 0, 100, 50, Infinity, 0, 100, Infinity);
562            ctx.drawImage(red, 0, 0, 100, 50, 0, Infinity, Infinity, 50);
563            ctx.drawImage(red, 0, 0, 100, 50, 0, Infinity, Infinity, Infinity);
564            ctx.drawImage(red, 0, 0, 100, 50, 0, Infinity, 100, Infinity);
565            ctx.drawImage(red, 0, 0, 100, 50, 0, 0, Infinity, Infinity);
566            verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255));
567
568        }
569
570        function test_negative() {
571            var ctx = canvas.getContext('2d');
572            ctx.reset();
573
574            ctx.fillStyle = '#f00';
575            ctx.fillRect(0, 0, 100, 50);
576            ctx.drawImage('ggrr-256x256.png', 100, 78, 50, 50, 0, 50, 50, -50);
577            ctx.drawImage('ggrr-256x256.png', 100, 128, 50, -50, 100, 50, -50, -50);
578 //           verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255,2));
579 //           verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255,2));
580 //           verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255,2));
581 //           verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255,2));
582 //           verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255,2));
583 //           verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255,2));
584 //           verify(Helper.comparePixel(ctx, 51,1, 0,255,0,255,2));
585 //           verify(Helper.comparePixel(ctx, 51,48, 0,255,0,255,2));
586 //           verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255,2));
587 //           verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255,2));
588
589            ctx.reset();
590            ctx.fillStyle = '#f00';
591            ctx.fillRect(0, 0, 100, 50);
592            ctx.drawImage('ggrr-256x256.png', 0, 178, 50, -100, 0, 0, 50, 100);
593            ctx.drawImage('ggrr-256x256.png', 0, 78, 50, 100, 50, 100, 50, -100);
594 //           verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255,2));
595 //           verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255,2));
596 //           verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255,2));
597 //           verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255,2));
598 //           verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255,2));
599 //           verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255,2));
600 //           verify(Helper.comparePixel(ctx, 51,1, 0,255,0,255,2));
601 //           verify(Helper.comparePixel(ctx, 51,48, 0,255,0,255,2));
602 //           verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255,2));
603 //           verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255,2));
604
605            ctx.reset();
606            ctx.fillStyle = '#f00';
607            ctx.fillRect(0, 0, 100, 50);
608            ctx.drawImage('ggrr-256x256.png', 100, 78, -100, 50, 0, 0, 50, 50);
609            ctx.drawImage('ggrr-256x256.png', 100, 128, -100, -50, 50, 0, 50, 50);
610 //           verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255,2));
611 //           verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255,2));
612 //           verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255,2));
613 //           verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255,2));
614 //           verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255,2));
615 //           verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255,2));
616 //           verify(Helper.comparePixel(ctx, 51,1, 0,255,0,255,2));
617 //           verify(Helper.comparePixel(ctx, 51,48, 0,255,0,255,2));
618 //           verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255,2));
619 //           verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255,2));
620
621        }
622
623        function test_canvas() {
624            var ctx = canvas.getContext('2d');
625            ctx.reset();
626            var canvas2 = Qt.createQmlObject("import QtQuick 2.0; Canvas{renderTarget:Canvas.Image}", canvas);
627            canvas2.width = 100;
628            canvas2.height = 50;
629            var ctx2 = canvas2.getContext('2d');
630            ctx2.fillStyle = '#0f0';
631            ctx2.fillRect(0, 0, 100, 50);
632
633            ctx.fillStyle = '#f00';
634            ctx.drawImage(canvas2, 0, 0);
635
636            //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2));
637            //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2));
638            //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2));
639            //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2));
640
641        }
642
643        function test_broken() {
644            var ctx = canvas.getContext('2d');
645            ctx.reset();
646            var img = 'broken.png';
647            verify(!img.complete);
648            ctx.drawImage(img, 0, 0);
649        }
650
651        function test_alpha() {
652            var ctx=canvas.getContext('2d');
653            ctx.reset();
654            ctx.fillStyle = '#0f0';
655            ctx.fillRect(0, 0, 100, 50);
656            ctx.globalAlpha = 0;
657            ctx.drawImage('red.png', 0, 0);
658            verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255, 2));
659
660        }
661    }
662 }