aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qquickcanvasitem/data/testhelper.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative/qquickcanvasitem/data/testhelper.js')
-rw-r--r--tests/auto/declarative/qquickcanvasitem/data/testhelper.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/declarative/qquickcanvasitem/data/testhelper.js b/tests/auto/declarative/qquickcanvasitem/data/testhelper.js
new file mode 100644
index 0000000000..bac0210e16
--- /dev/null
+++ b/tests/auto/declarative/qquickcanvasitem/data/testhelper.js
@@ -0,0 +1,18 @@
+function comparePixel(ctx,x,y,r,g,b,a, d)
+{
+ var c = ctx.getImageData(x,y,1,1).data;
+ if (d === undefined)
+ d = 0;
+ r = Math.round(r);
+ g = Math.round(g);
+ b = Math.round(b);
+ a = Math.round(a);
+
+ if (Math.abs(c[0]-r)>d || Math.abs(c[1]-g)>d || Math.abs(c[2]-b)>d || Math.abs(c[3]-a)>d) {
+ console.log('Pixel compare fail:\nactual :[' + c[0]+','+c[1]+','+c[2]+','+c[3] + ']\nexpected:['+r+','+g+','+b+','+a+'] +/- '+d);
+ return false;
+ }
+ return true;
+}
+
+