aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Arve Sæther <jan-arve.saether@qt.io>2019-05-22 15:40:06 +0200
committerJan Arve Sæther <jan-arve.saether@qt.io>2019-05-22 15:41:56 +0200
commitbb88d84475f7c4bb69528da5096f4d2c91667a3c (patch)
treeed9e12ba4ae3c10e9a21275accfe783ad9541043
parent188773bd1383883cd7247b6ded0d0b1a41689155 (diff)
Add a test for having a ShaderEffect as a delegate
Change-Id: If4f3dca99638015b479509e4aa73e0190b1182ac Task-number: QTBUG-67343 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--tests/auto/controls/data/tst_combobox.qml58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml
index 0d266e1a..f8f06679 100644
--- a/tests/auto/controls/data/tst_combobox.qml
+++ b/tests/auto/controls/data/tst_combobox.qml
@@ -96,6 +96,45 @@ TestCase {
}
}
+ Component {
+ id: comboBoxWithShaderEffect
+ ComboBox {
+ delegate: Rectangle {
+ Text {
+ id: txt
+ anchors.centerIn: parent
+ text: "item" + index
+ font.pixelSize: 20
+ color: "red"
+ }
+ id: rect
+ objectName: "rect"
+ width: parent.width
+ height: txt.implicitHeight
+ gradient: Gradient {
+ GradientStop { color: "lightsteelblue"; position: 0.0 }
+ GradientStop { color: "blue"; position: 1.0 }
+ }
+ layer.enabled: true
+ layer.effect: ShaderEffect {
+ objectName: "ShaderFX"
+ width: rect.width
+ height: rect.height
+ fragmentShader: "
+ uniform lowp sampler2D source; // this item
+ uniform lowp float qt_Opacity; // inherited opacity of this item
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ lowp vec4 p = texture2D(source, qt_TexCoord0);
+ lowp float g = dot(p.xyz, vec3(0.344, 0.5, 0.156));
+ gl_FragColor = vec4(g, g, g, p.a) * qt_Opacity;
+ }"
+
+ }
+ }
+ }
+ }
+
function init() {
// QTBUG-61225: Move the mouse away to avoid QQuickWindowPrivate::flushFrameSynchronousEvents()
// delivering interfering hover events based on the last mouse position from earlier tests. For
@@ -1731,4 +1770,23 @@ TestCase {
closedSpy.wait()
compare(closedSpy.count, 1)
}
+
+ function test_comboBoxWithShaderEffect() {
+ var control = createTemporaryObject(comboBoxWithShaderEffect, testCase, {model: 9})
+ verify(control)
+ waitForRendering(control)
+ control.forceActiveFocus()
+ var openedSpy = signalSpy.createObject(control, {target: control.popup, signalName: "opened"})
+ verify(openedSpy.valid)
+
+ var closedSpy = signalSpy.createObject(control, {target: control.popup, signalName: "closed"})
+ verify(closedSpy.valid)
+
+ control.popup.open()
+ openedSpy.wait()
+ compare(openedSpy.count, 1)
+ control.popup.close()
+ closedSpy.wait()
+ compare(closedSpy.count, 1)
+ }
}