diff options
author | Charles Yin <charles.yin@nokia.com> | 2012-05-03 15:21:08 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-04 02:39:23 +0200 |
commit | 6318560eca7e3247a63620ce24d2d7e291dd5d84 (patch) | |
tree | a4f09da7a81577994d1d34fd9926257dfb136e64 /tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml | |
parent | 9cc306916bf8bd70e79aa67458759985e9a26c0d (diff) |
Refactor canvas item unit tests
Change-Id: I99ba84889ce360d2def27834f15af43c2bdf29bc
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml')
-rw-r--r-- | tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml b/tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml new file mode 100644 index 0000000000..4aae317a7a --- /dev/null +++ b/tests/auto/quick/qquickcanvasitem/data/CanvasTestCase.qml @@ -0,0 +1,46 @@ +import QtQuick 2.0 +import QtTest 1.0 + +TestCase { + id:testCase + when:windowShown + width:100 + height:100 + property Component component:CanvasComponent{} + function cleanupTestCase() { + wait(100) //wait for a short while to make sure no leaked textures + } + function testData(type) { + if (type === "2d") + return [ + { tag:"image threaded", properties:{width:100, height:100, renderTarget:Canvas.Image, renderStrategy:Canvas.Threaded}} + //TODO: Enable the followings later + //{ tag:"image cooperative", properties:{width:100, height:100, renderTarget:Canvas.Image, renderStrategy:Canvas.Cooperative}}, + //{ tag:"image immediate", properties:{width:100, height:100, renderTarget:Canvas.Image, renderStrategy:Canvas.Immediate}}, + //{ tag:"fbo cooperative", properties:{width:100, height:100, renderTarget:Canvas.FramebufferObject, renderStrategy:Canvas.Cooperative}}, + //{ tag:"fbo immediate", properties:{width:100, height:100, renderTarget:Canvas.FramebufferObject, renderStrategy:Canvas.Immediate}}, + //{ tag:"fbo threaded", properties:{width:100, height:100, renderTarget:Canvas.FramebufferObject, renderStrategy:Canvas.Threaded}} + ]; + return []; + } + + function createCanvasObject(data) { + return component.createObject(testCase, data.properties); + } + + 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); + + var notSame = Math.abs(c[0]-r)>d || Math.abs(c[1]-g)>d || Math.abs(c[2]-b)>d || Math.abs(c[3]-a)>d; + if (notSame) + qtest_fail('Pixel compare fail:\nactual :[' + c[0]+','+c[1]+','+c[2]+','+c[3] + ']\nexpected:['+r+','+g+','+b+','+a+'] +/- '+d, 1); + } + +}
\ No newline at end of file |