diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-08-08 08:38:32 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-08-08 08:38:32 +0200 |
commit | 628df3881fbb3d3bd1ee4316b47df5871c6dad73 (patch) | |
tree | 89226f86cde26330b1e63d2f9e9e59faf1ad9d5c /tests | |
parent | f6e2de9d75ebd6c782fcb20e48375c9ac80d9d25 (diff) | |
parent | 4865136be9c61aab50c8f30942996bba58a59c3b (diff) |
Merge remote-tracking branch 'origin/5.11' into dev
Conflicts:
.qmake.conf
Change-Id: I483081703594a8398d51a23c6d2266ac0ae9dfb0
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qquickiconimage/data/translucentColors.qml | 67 | ||||
-rw-r--r-- | tests/auto/qquickiconimage/tst_qquickiconimage.cpp | 33 |
2 files changed, 99 insertions, 1 deletions
diff --git a/tests/auto/qquickiconimage/data/translucentColors.qml b/tests/auto/qquickiconimage/data/translucentColors.qml new file mode 100644 index 00000000..49178d76 --- /dev/null +++ b/tests/auto/qquickiconimage/data/translucentColors.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.10 +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 + +ApplicationWindow { + width: 500 + height: 500 + visible: true + + IconImage { + width: Math.min(250, parent.width) + height: Math.min(250, parent.height) + source: "qrc:/icons/testtheme/22x22/actions/color-test-original.png" + sourceSize: Qt.size(250, 0) + color: Qt.rgba(0, 0, 0, 0.5) + } +} diff --git a/tests/auto/qquickiconimage/tst_qquickiconimage.cpp b/tests/auto/qquickiconimage/tst_qquickiconimage.cpp index 1dab0784..bc24c4fb 100644 --- a/tests/auto/qquickiconimage/tst_qquickiconimage.cpp +++ b/tests/auto/qquickiconimage/tst_qquickiconimage.cpp @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ @@ -30,6 +30,7 @@ #include <QtTest/qsignalspy.h> #include <QtCore/qmath.h> +#include <QtQml/qqmlapplicationengine.h> #include <QtQml/qqmlengine.h> #include <QtQml/qqmlcomponent.h> #include <QtQml/qqmlfileselector.h> @@ -69,6 +70,7 @@ private slots: void color(); void fileSelectors(); void imageProvider(); + void translucentColors(); private: void setTheme(); @@ -528,6 +530,35 @@ void tst_qquickiconimage::imageProvider() QCOMPARE(image.pixelColor(image.width() / 2, image.height() / 2), QColor(Qt::red)); } +/* + QQuickIconImage::componentComplete() calls QQuickIconImagePrivate::updateIcon(), + which loads the icon's image via QQuickImageBase::load(). That eventually calls + QQuickImageBase::requestFinished(), which calls QQuickIconImage::pixmapChange(). + That then calls QQuickIconImagePrivate::updateFillMode(), which can in turn + cause QQuickIconImage::pixmapChange() to be called again, causing recursion. + + This was a problem because it resulted in icon.color being applied twice. + + This test checks that that doesn't happen. +*/ +void tst_qquickiconimage::translucentColors() +{ + if (QGuiApplication::platformName() == QLatin1String("offscreen")) + QSKIP("grabToImage() doesn't work on the \"offscreen\" platform plugin (QTBUG-63185)"); + + // Doesn't reproduce with QQuickView. + QQmlApplicationEngine engine; + engine.load(testFileUrl("translucentColors.qml")); + QQuickWindow *window = qobject_cast<QQuickWindow*>(engine.rootObjects().first()); + + QQuickIconImage *iconImage = qobject_cast<QQuickIconImage*>(window->findChild<QQuickIconImage*>()); + QVERIFY(iconImage); + + const QImage image = grabItemToImage(iconImage); + QVERIFY(!image.isNull()); + QCOMPARE(image.pixelColor(image.width() / 2, image.height() / 2), QColor::fromRgba(0x80000000)); +} + int main(int argc, char *argv[]) { QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); |