From 66f740c5e7ea74e00808d8f1b73570726eeda5a0 Mon Sep 17 00:00:00 2001 From: Justin McPherson Date: Thu, 9 Feb 2012 15:46:09 +1000 Subject: Refactor Canvas rendering paths. Refactor Canvas rendering paths to enable different drawing contexts. Change-Id: If0e00a14baa673fca6b999a787b4e89885bb1e51 Reviewed-by: Yunqiao Yin --- .../qtquick2/qquickcanvasitem/data/tst_context.qml | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/tst_context.qml (limited to 'tests/auto/qtquick2/qquickcanvasitem/data/tst_context.qml') diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_context.qml b/tests/auto/qtquick2/qquickcanvasitem/data/tst_context.qml new file mode 100644 index 0000000000..b72e755ed9 --- /dev/null +++ b/tests/auto/qtquick2/qquickcanvasitem/data/tst_context.qml @@ -0,0 +1,73 @@ + +import QtQuick 2.0 +import QtTest 1.0 + +Canvas { + id: canvas + width: 1 + height: 1 + contextType: "2d" + + property var contextInPaint + + SignalSpy { + id: paintedSpy + target: canvas + signalName: "paint" + } + + SignalSpy { + id: contextSpy + target: canvas + signalName: "contextChanged" + } + + onPaint: { + contextInPaint = context; + } + + TestCase { + name: "ContextTypeStored" + when: windowShown + + function test_contextType() { + compare(canvas.contextType, "2d"); + } + } + + TestCase { + name: "ContextValidWhenTypePredefined" + when: canvas.available + + function test_context() { + // Wait for the context to become active + wait(100); + compare(contextSpy.count, 1); + + // Context is available + verify(canvas.context) + } + + function test_contextIsConsistent() { + // Wait for the context to become active + wait(100); + compare(contextSpy.count, 1); + + // getContext("2d") is the same as the context property + compare(canvas.getContext("2d"), canvas.context); + } + + function test_paintHadContext() { + // Make there was a paint signal + wait(100); + verify(paintedSpy.count, 1) + + // Paint was called with a valid context when contextType is + // specified + verify(canvas.contextInPaint) + + // paints context was the correct one + compare(canvas.contextInPaint, canvas.getContext("2d")); + } + } +} -- cgit v1.2.3