aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKim Motoyoshi Kalland <kim.kalland@nokia.com>2012-01-17 17:06:08 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-07 14:04:37 +0100
commit5cc1870d2084f4f9a291d92d3ccd99f2c18d6fca (patch)
treeb135d347d1349a79926f98e1a9c89450708fd616 /tests
parentb057ac0a3f1bae9620f238363310a262b247e291 (diff)
Allow Item components to be assigned to Item.layer.effect.
Some complex effects are easier to implement as Items using ShaderEffects internally rather than with a top-level ShaderEffect. Auto-tests added. Change-Id: I4b99811b87e7ca5054bf119b99207b7f5a7c666e Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qtquick2/qquickitemlayer/data/ItemEffect.qml23
-rw-r--r--tests/auto/qtquick2/qquickitemlayer/data/RectangleEffect.qml22
-rw-r--r--tests/auto/qtquick2/qquickitemlayer/qquickitemlayer.pro4
-rw-r--r--tests/auto/qtquick2/qquickitemlayer/tst_qquickitemlayer.cpp28
4 files changed, 76 insertions, 1 deletions
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/ItemEffect.qml b/tests/auto/qtquick2/qquickitemlayer/data/ItemEffect.qml
new file mode 100644
index 0000000000..2f17d78efd
--- /dev/null
+++ b/tests/auto/qtquick2/qquickitemlayer/data/ItemEffect.qml
@@ -0,0 +1,23 @@
+import QtQuick 2.0
+
+Item {
+ width: 200
+ height: 200
+ Rectangle {
+ anchors.fill: parent
+ anchors.margins: 99
+ gradient: Gradient {
+ GradientStop { position: 0.3; color: "red" }
+ GradientStop { position: 0.7; color: "blue" }
+ }
+ layer.enabled: true
+ layer.effect: Item {
+ property variant source
+ ShaderEffect {
+ anchors.fill: parent
+ anchors.margins: -99
+ property variant source: parent.source
+ }
+ }
+ }
+}
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/RectangleEffect.qml b/tests/auto/qtquick2/qquickitemlayer/data/RectangleEffect.qml
new file mode 100644
index 0000000000..94c43f2caf
--- /dev/null
+++ b/tests/auto/qtquick2/qquickitemlayer/data/RectangleEffect.qml
@@ -0,0 +1,22 @@
+import QtQuick 2.0
+
+Item {
+ width: 200
+ height: 200
+ Rectangle {
+ width: 100
+ height: 100
+ x: 50
+ y: 50
+ scale: 1.5
+ z: 1
+ rotation: 45
+ color: "#ff0000"
+ layer.enabled: true
+ layer.effect: Rectangle { color: "#0000ff" }
+ }
+ Rectangle {
+ anchors.fill: parent
+ color: "#00ff00"
+ }
+}
diff --git a/tests/auto/qtquick2/qquickitemlayer/qquickitemlayer.pro b/tests/auto/qtquick2/qquickitemlayer/qquickitemlayer.pro
index 5c34decdcd..557e23d150 100644
--- a/tests/auto/qtquick2/qquickitemlayer/qquickitemlayer.pro
+++ b/tests/auto/qtquick2/qquickitemlayer/qquickitemlayer.pro
@@ -25,7 +25,9 @@ OTHER_FILES += \
data/ZOrderChange.qml \
data/ToggleLayerAndEffect.qml \
data/DisableLayer.qml \
- data/SamplerNameChange.qml
+ data/SamplerNameChange.qml \
+ data/ItemEffect.qml \
+ data/RectangleEffect.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/tst_qquickitemlayer.cpp b/tests/auto/qtquick2/qquickitemlayer/tst_qquickitemlayer.cpp
index 1e55924f86..2a856707ba 100644
--- a/tests/auto/qtquick2/qquickitemlayer/tst_qquickitemlayer.cpp
+++ b/tests/auto/qtquick2/qquickitemlayer/tst_qquickitemlayer.cpp
@@ -86,6 +86,8 @@ private slots:
void toggleLayerAndEffect();
void disableLayer();
void changeSamplerName();
+ void itemEffect();
+ void rectangleEffect();
private:
bool m_isMesaSoftwareRasterizer;
@@ -403,6 +405,32 @@ void tst_QQuickItemLayer::changeSamplerName()
QCOMPARE(fb.pixel(0, 0), qRgb(0, 0, 0xff));
}
+void tst_QQuickItemLayer::itemEffect()
+{
+ if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
+ QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
+ QImage fb = runTest(testFile("ItemEffect.qml"));
+ QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
+ QCOMPARE(fb.pixel(199, 0), qRgb(0xff, 0, 0));
+ QCOMPARE(fb.pixel(0, 199), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(199, 199), qRgb(0, 0, 0xff));
+}
+
+void tst_QQuickItemLayer::rectangleEffect()
+{
+ QImage fb = runTest(testFile("RectangleEffect.qml"));
+ QCOMPARE(fb.pixel(0, 0), qRgb(0, 0xff, 0));
+ QCOMPARE(fb.pixel(199, 0), qRgb(0, 0xff, 0));
+ QCOMPARE(fb.pixel(0, 199), qRgb(0, 0xff, 0));
+ QCOMPARE(fb.pixel(199, 199), qRgb(0, 0xff, 0));
+
+ QCOMPARE(fb.pixel(100, 0), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(199, 100), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(100, 199), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(0, 100), qRgb(0, 0, 0xff));
+}
+
+
QTEST_MAIN(tst_QQuickItemLayer)
#include "tst_qquickitemlayer.moc"