diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2011-10-14 10:51:42 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-21 11:53:26 +0200 |
commit | bfb3c424abc7c839dc44de0e36024ede99ece736 (patch) | |
tree | b6814d0238bead8518b23c078beb818432de6ce4 /tests/auto/declarative/qquickcanvasitem/data/tst_arcto.qml | |
parent | 2d119a137f1bc0c8b1113cd6c58413a1b89a4c1c (diff) |
Rename Qt Quick-specific classes to QQuick*
The QSG (SceneGraph) prefix is too generic for
Qt Quick(2)-specific classes.
All the classes and files in the declarative/items
directory have been renamed.
In particular, for classes that are currently public,
the renaming is as follows:
QSGView --> QQuickView
QSGCanvas --> QQuickCanvas
QSGItem --> QQuickItem
QSGPaintedItem --> QQuickPaintedItem
The header files have been renamed accordingly
(e.g. qsgview.h --> qquickview.h).
Change-Id: Iac937fff81db20bb639486a793c3aeb5230b038c
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
Diffstat (limited to 'tests/auto/declarative/qquickcanvasitem/data/tst_arcto.qml')
-rw-r--r-- | tests/auto/declarative/qquickcanvasitem/data/tst_arcto.qml | 410 |
1 files changed, 410 insertions, 0 deletions
diff --git a/tests/auto/declarative/qquickcanvasitem/data/tst_arcto.qml b/tests/auto/declarative/qquickcanvasitem/data/tst_arcto.qml new file mode 100644 index 0000000000..cc1d88672b --- /dev/null +++ b/tests/auto/declarative/qquickcanvasitem/data/tst_arcto.qml @@ -0,0 +1,410 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper + +Canvas { + id:canvas; width:100;height:50; renderTarget: Canvas.Image + TestCase { + name: "arcTo"; when: windowShown + function test_coincide() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arcTo(0, 25, 50, 1000, 1); + ctx.lineTo(100, 25); + ctx.stroke(); + + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(50, 25); + ctx.arcTo(50, 25, 100, 25, 1); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arcTo(100, 25, 100, 25, 1); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + function test_collinear() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arcTo(100, 25, 200, 25, 1); + ctx.stroke(); + + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(-100, 25); + ctx.arcTo(0, 25, 100, 25, 1); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arcTo(100, 25, 10, 25, 1); + ctx.stroke(); + + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(100, 25); + ctx.arcTo(200, 25, 110, 25, 1); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arcTo(100, 25, -100, 25, 1); + ctx.stroke(); + + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(100, 25); + ctx.arcTo(200, 25, 0, 25, 1); + ctx.stroke(); + + ctx.beginPath(); + ctx.moveTo(-100, 25); + ctx.arcTo(0, 25, -200, 25, 1); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + function test_subpath() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.arcTo(100, 50, 200, 50, 0.1); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.arcTo(0, 25, 50, 250, 0.1); + ctx.lineTo(100, 25); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + + function test_negative() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + try { var err = false; + ctx.arcTo(0, 0, 0, 0, -1); + } catch (e) { + if (e.code != DOMException.INDEX_SIZE_ERR) + fail("expectes INDEX_SIZE_ERR, got: "+e.message); + err = true; + } + finally { + verify(err, "should throw INDEX_SIZE_ERR: ctx.arcTo(0, 0, 0, 0, -1)"); + } + } + + function test_nonfinite() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + skip("FIXME"); + + ctx.moveTo(0, 0); + ctx.lineTo(100, 0); + ctx.arcTo(Infinity, 50, 0, 50, 0); + ctx.arcTo(-Infinity, 50, 0, 50, 0); + ctx.arcTo(NaN, 50, 0, 50, 0); + ctx.arcTo(0, Infinity, 0, 50, 0); + ctx.arcTo(0, -Infinity, 0, 50, 0); + ctx.arcTo(0, NaN, 0, 50, 0); + ctx.arcTo(0, 50, Infinity, 50, 0); + ctx.arcTo(0, 50, -Infinity, 50, 0); + ctx.arcTo(0, 50, NaN, 50, 0); + ctx.arcTo(0, 50, 0, Infinity, 0); + ctx.arcTo(0, 50, 0, -Infinity, 0); + ctx.arcTo(0, 50, 0, NaN, 0); + ctx.arcTo(0, 50, 0, 50, Infinity); + ctx.arcTo(0, 50, 0, 50, -Infinity); + ctx.arcTo(0, 50, 0, 50, NaN); + ctx.arcTo(Infinity, Infinity, 0, 50, 0); + ctx.arcTo(Infinity, Infinity, Infinity, 50, 0); + ctx.arcTo(Infinity, Infinity, Infinity, Infinity, 0); + ctx.arcTo(Infinity, Infinity, Infinity, Infinity, Infinity); + ctx.arcTo(Infinity, Infinity, Infinity, 50, Infinity); + ctx.arcTo(Infinity, Infinity, 0, Infinity, 0); + ctx.arcTo(Infinity, Infinity, 0, Infinity, Infinity); + ctx.arcTo(Infinity, Infinity, 0, 50, Infinity); + ctx.arcTo(Infinity, 50, Infinity, 50, 0); + ctx.arcTo(Infinity, 50, Infinity, Infinity, 0); + ctx.arcTo(Infinity, 50, Infinity, Infinity, Infinity); + ctx.arcTo(Infinity, 50, Infinity, 50, Infinity); + ctx.arcTo(Infinity, 50, 0, Infinity, 0); + ctx.arcTo(Infinity, 50, 0, Infinity, Infinity); + ctx.arcTo(Infinity, 50, 0, 50, Infinity); + ctx.arcTo(0, Infinity, Infinity, 50, 0); + ctx.arcTo(0, Infinity, Infinity, Infinity, 0); + ctx.arcTo(0, Infinity, Infinity, Infinity, Infinity); + ctx.arcTo(0, Infinity, Infinity, 50, Infinity); + ctx.arcTo(0, Infinity, 0, Infinity, 0); + ctx.arcTo(0, Infinity, 0, Infinity, Infinity); + ctx.arcTo(0, Infinity, 0, 50, Infinity); + ctx.arcTo(0, 50, Infinity, Infinity, 0); + ctx.arcTo(0, 50, Infinity, Infinity, Infinity); + ctx.arcTo(0, 50, Infinity, 50, Infinity); + ctx.arcTo(0, 50, 0, Infinity, Infinity); + ctx.lineTo(100, 50); + ctx.lineTo(0, 50); + ctx.fillStyle = '#0f0'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 90,45, 0,255,0,255)); + + } + function test_scale() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 50); + ctx.translate(100, 0); + ctx.scale(0.1, 1); + ctx.arcTo(50, 50, 50, 0, 50); + ctx.lineTo(-1000, 0); + ctx.fill(); + + skip("FIXME"); + //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); + } + + function test_shape() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + var tol = 1.5; // tolerance to avoid antialiasing artifacts + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 10; + ctx.beginPath(); + ctx.moveTo(10, 25); + ctx.arcTo(75, 25, 75, 60, 20); + ctx.stroke(); + + ctx.fillStyle = '#0f0'; + ctx.beginPath(); + ctx.rect(10, 20, 45, 10); + ctx.moveTo(80, 45); + ctx.arc(55, 45, 25+tol, 0, -Math.PI/2, true); + ctx.arc(55, 45, 15-tol, -Math.PI/2, 0, false); + ctx.fill(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 55,19, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 55,20, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 55,21, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 64,22, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 65,21, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 72,28, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 73,27, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 78,36, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 79,35, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 80,44, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 80,45, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 80,46, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 65,45, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#f00'; + ctx.beginPath(); + ctx.rect(10, 20, 45, 10); + ctx.moveTo(80, 45); + ctx.arc(55, 45, 25-tol, 0, -Math.PI/2, true); + ctx.arc(55, 45, 15+tol, -Math.PI/2, 0, false); + ctx.fill(); + + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 10; + ctx.beginPath(); + ctx.moveTo(10, 25); + ctx.arcTo(75, 25, 75, 60, 20); + ctx.stroke(); + + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 55,19, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 55,20, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 55,21, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 64,22, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 65,21, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 72,28, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 73,27, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 78,36, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 79,35, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 80,44, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 80,45, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 80,46, 0,255,0,255)); + ctx.reset(); + + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.moveTo(-100, -100); + ctx.arcTo(-100, 25, 200, 25, 10); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arcTo(200, 25, 200, 50, 10); + ctx.stroke(); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + } + + function test_transform() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 50); + ctx.translate(100, 0); + ctx.arcTo(50, 50, 50, 0, 50); + ctx.lineTo(-100, 0); + ctx.fill(); + + skip("FIXME"); + //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); + } + function test_zero() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arcTo(100, 25, 100, 100, 0); + ctx.stroke(); + + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(0, -25); + ctx.arcTo(50, -25, 50, 50, 0); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arcTo(100, 25, -100, 25, 0); + ctx.stroke(); + + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(100, 25); + ctx.arcTo(200, 25, 50, 25, 0); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + } + } +} |