From b3694d12959900270b3aea2af594df379f1db092 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 24 Jul 2012 10:52:53 +0200 Subject: Split the QGuiVariant test from the Core one. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes development on the meta type system easier because only QtCore must be re-built to run most of the tests. The existing QGuiVariant test needs to be run before pushing anyway, but not so frequently. Change-Id: I1fa66edbd790c957e1a232226847dd550227a477 Reviewed-by: Olivier Goffart Reviewed-by: Jędrzej Nowacki --- .../gui/kernel/qguivariant/no_application/main.cpp | 72 +++ .../qguivariant/no_application/no_application.pro | 5 + tests/auto/gui/kernel/qguivariant/qguivariant.pro | 8 +- .../qguivariant/test/stream/qt4.9/qbitmap.bin | Bin 0 -> 27 bytes .../qguivariant/test/stream/qt4.9/qbrush.bin | Bin 0 -> 105 bytes .../qguivariant/test/stream/qt4.9/qcolor.bin | Bin 0 -> 32 bytes .../qguivariant/test/stream/qt4.9/qcursor.bin | Bin 0 -> 25 bytes .../qguivariant/test/stream/qt4.9/qeasingcurve.bin | Bin 0 -> 43 bytes .../kernel/qguivariant/test/stream/qt4.9/qfont.bin | Bin 0 -> 73 bytes .../kernel/qguivariant/test/stream/qt4.9/qicon.bin | Bin 0 -> 23 bytes .../qguivariant/test/stream/qt4.9/qimage.bin | Bin 0 -> 25 bytes .../qguivariant/test/stream/qt4.9/qkeysequence.bin | Bin 0 -> 41 bytes .../qguivariant/test/stream/qt4.9/qmatrix.bin | Bin 0 -> 71 bytes .../qguivariant/test/stream/qt4.9/qmatrix4x4.bin | Bin 0 -> 157 bytes .../qguivariant/test/stream/qt4.9/qpalette.bin | Bin 0 -> 5065 bytes .../kernel/qguivariant/test/stream/qt4.9/qpen.bin | Bin 0 -> 132 bytes .../qguivariant/test/stream/qt4.9/qpixmap.bin | Bin 0 -> 27 bytes .../qguivariant/test/stream/qt4.9/qpolygon.bin | Bin 0 -> 29 bytes .../qguivariant/test/stream/qt4.9/qpolygonf.bin | Bin 0 -> 31 bytes .../qguivariant/test/stream/qt4.9/qquaternion.bin | Bin 0 -> 63 bytes .../qguivariant/test/stream/qt4.9/qregion.bin | Bin 0 -> 27 bytes .../qguivariant/test/stream/qt4.9/qtextformat.bin | Bin 0 -> 39 bytes .../qguivariant/test/stream/qt4.9/qtextlength.bin | Bin 0 -> 43 bytes .../qguivariant/test/stream/qt4.9/qtransform.bin | Bin 0 -> 101 bytes .../qguivariant/test/stream/qt4.9/qvector2d.bin | Bin 0 -> 43 bytes .../qguivariant/test/stream/qt4.9/qvector3d.bin | Bin 0 -> 51 bytes .../qguivariant/test/stream/qt4.9/qvector4d.bin | Bin 0 -> 59 bytes .../qguivariant/test/stream/qt5.0/qbitmap.bin | Bin 0 -> 27 bytes .../qguivariant/test/stream/qt5.0/qbrush.bin | Bin 0 -> 105 bytes .../qguivariant/test/stream/qt5.0/qcolor.bin | Bin 0 -> 32 bytes .../qguivariant/test/stream/qt5.0/qcursor.bin | Bin 0 -> 25 bytes .../qguivariant/test/stream/qt5.0/qeasingcurve.bin | Bin 0 -> 43 bytes .../kernel/qguivariant/test/stream/qt5.0/qfont.bin | Bin 0 -> 71 bytes .../kernel/qguivariant/test/stream/qt5.0/qicon.bin | Bin 0 -> 23 bytes .../qguivariant/test/stream/qt5.0/qimage.bin | Bin 0 -> 25 bytes .../qguivariant/test/stream/qt5.0/qkeysequence.bin | Bin 0 -> 41 bytes .../qguivariant/test/stream/qt5.0/qmatrix.bin | Bin 0 -> 71 bytes .../qguivariant/test/stream/qt5.0/qmatrix4x4.bin | Bin 0 -> 157 bytes .../qguivariant/test/stream/qt5.0/qpalette.bin | Bin 0 -> 5065 bytes .../kernel/qguivariant/test/stream/qt5.0/qpen.bin | Bin 0 -> 132 bytes .../qguivariant/test/stream/qt5.0/qpixmap.bin | Bin 0 -> 27 bytes .../qguivariant/test/stream/qt5.0/qpolygon.bin | Bin 0 -> 29 bytes .../qguivariant/test/stream/qt5.0/qquaternion.bin | Bin 0 -> 63 bytes .../qguivariant/test/stream/qt5.0/qregion.bin | Bin 0 -> 27 bytes .../qguivariant/test/stream/qt5.0/qtextformat.bin | Bin 0 -> 39 bytes .../qguivariant/test/stream/qt5.0/qtextlength.bin | Bin 0 -> 43 bytes .../qguivariant/test/stream/qt5.0/qtransform.bin | Bin 0 -> 101 bytes .../qguivariant/test/stream/qt5.0/qvector2d.bin | Bin 0 -> 43 bytes .../qguivariant/test/stream/qt5.0/qvector3d.bin | Bin 0 -> 51 bytes .../qguivariant/test/stream/qt5.0/qvector4d.bin | Bin 0 -> 59 bytes tests/auto/gui/kernel/qguivariant/test/test.pro | 6 + .../kernel/qguivariant/test/tst_qguivariant.cpp | 646 +++++++++++++++++++++ .../gui/kernel/qguivariant/tst_qguivariant.cpp | 72 --- 53 files changed, 731 insertions(+), 78 deletions(-) create mode 100644 tests/auto/gui/kernel/qguivariant/no_application/main.cpp create mode 100644 tests/auto/gui/kernel/qguivariant/no_application/no_application.pro create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qbitmap.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qbrush.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qcolor.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qcursor.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qeasingcurve.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qfont.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qicon.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qimage.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qkeysequence.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qmatrix.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qmatrix4x4.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qpalette.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qpen.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qpixmap.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qpolygon.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qpolygonf.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qquaternion.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qregion.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qtextformat.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qtextlength.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qtransform.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qvector2d.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qvector3d.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qvector4d.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qbitmap.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qbrush.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qcolor.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qcursor.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qeasingcurve.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qfont.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qicon.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qimage.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qkeysequence.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qmatrix.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qmatrix4x4.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qpalette.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qpen.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qpixmap.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qpolygon.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qquaternion.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qregion.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qtextformat.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qtextlength.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qtransform.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qvector2d.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qvector3d.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qvector4d.bin create mode 100644 tests/auto/gui/kernel/qguivariant/test/test.pro create mode 100644 tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp delete mode 100644 tests/auto/gui/kernel/qguivariant/tst_qguivariant.cpp (limited to 'tests/auto/gui') diff --git a/tests/auto/gui/kernel/qguivariant/no_application/main.cpp b/tests/auto/gui/kernel/qguivariant/no_application/main.cpp new file mode 100644 index 0000000000..d72f3e8ae5 --- /dev/null +++ b/tests/auto/gui/kernel/qguivariant/no_application/main.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include + +#include + + + +class tst_QGuiVariantNoApplication : public QObject +{ + Q_OBJECT + +public: + tst_QGuiVariantNoApplication(); + +private slots: + void variantWithoutApplication(); +}; + +tst_QGuiVariantNoApplication::tst_QGuiVariantNoApplication() +{} + +void tst_QGuiVariantNoApplication::variantWithoutApplication() +{ + QVariant v = QString("red"); + + QVERIFY(qvariant_cast(v) == QColor(Qt::red)); +} + + +QTEST_APPLESS_MAIN(tst_QGuiVariantNoApplication) +#include "main.moc" diff --git a/tests/auto/gui/kernel/qguivariant/no_application/no_application.pro b/tests/auto/gui/kernel/qguivariant/no_application/no_application.pro new file mode 100644 index 0000000000..cc72c225a3 --- /dev/null +++ b/tests/auto/gui/kernel/qguivariant/no_application/no_application.pro @@ -0,0 +1,5 @@ +CONFIG += testcase +CONFIG += parallel_test +TARGET = no_application +SOURCES += main.cpp +QT += testlib diff --git a/tests/auto/gui/kernel/qguivariant/qguivariant.pro b/tests/auto/gui/kernel/qguivariant/qguivariant.pro index 13e86665fe..115da945a5 100644 --- a/tests/auto/gui/kernel/qguivariant/qguivariant.pro +++ b/tests/auto/gui/kernel/qguivariant/qguivariant.pro @@ -1,6 +1,2 @@ -CONFIG += testcase -CONFIG += parallel_test -TARGET = tst_qguivariant -SOURCES += tst_qguivariant.cpp -QT += testlib - +TEMPLATE = subdirs +SUBDIRS = test no_application diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qbitmap.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qbitmap.bin new file mode 100644 index 0000000000..13f4dc374d Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qbitmap.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qbrush.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qbrush.bin new file mode 100644 index 0000000000..60ea8a2b08 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qbrush.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qcolor.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qcolor.bin new file mode 100644 index 0000000000..ba1c332e14 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qcolor.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qcursor.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qcursor.bin new file mode 100644 index 0000000000..545fa96a1f Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qcursor.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qeasingcurve.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qeasingcurve.bin new file mode 100644 index 0000000000..b9b9ea633b Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qeasingcurve.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qfont.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qfont.bin new file mode 100644 index 0000000000..76bc5d932f Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qfont.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qicon.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qicon.bin new file mode 100644 index 0000000000..2f8713244c Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qicon.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qimage.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qimage.bin new file mode 100644 index 0000000000..0ab1cbf6fa Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qimage.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qkeysequence.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qkeysequence.bin new file mode 100644 index 0000000000..03db168e93 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qkeysequence.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qmatrix.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qmatrix.bin new file mode 100644 index 0000000000..fc88e2564a Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qmatrix.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qmatrix4x4.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qmatrix4x4.bin new file mode 100644 index 0000000000..3a8b664a69 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qmatrix4x4.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qpalette.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qpalette.bin new file mode 100644 index 0000000000..1ad94631bd Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qpalette.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qpen.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qpen.bin new file mode 100644 index 0000000000..1eff5c83ad Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qpen.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qpixmap.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qpixmap.bin new file mode 100644 index 0000000000..ce9cb8c434 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qpixmap.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qpolygon.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qpolygon.bin new file mode 100644 index 0000000000..fbdab8fffc Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qpolygon.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qpolygonf.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qpolygonf.bin new file mode 100644 index 0000000000..c4b5f652b3 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qpolygonf.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qquaternion.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qquaternion.bin new file mode 100644 index 0000000000..01ee6dcdbc Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qquaternion.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qregion.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qregion.bin new file mode 100644 index 0000000000..27eec8c4d5 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qregion.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qtextformat.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qtextformat.bin new file mode 100644 index 0000000000..91382db9c4 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qtextformat.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qtextlength.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qtextlength.bin new file mode 100644 index 0000000000..945dfc0ba9 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qtextlength.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qtransform.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qtransform.bin new file mode 100644 index 0000000000..53c4db55f2 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qtransform.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qvector2d.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qvector2d.bin new file mode 100644 index 0000000000..a219ab66dd Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qvector2d.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qvector3d.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qvector3d.bin new file mode 100644 index 0000000000..4444fb6236 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qvector3d.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qvector4d.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qvector4d.bin new file mode 100644 index 0000000000..46bcc26f13 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt4.9/qvector4d.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qbitmap.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qbitmap.bin new file mode 100644 index 0000000000..13f4dc374d Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qbitmap.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qbrush.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qbrush.bin new file mode 100644 index 0000000000..60ea8a2b08 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qbrush.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qcolor.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qcolor.bin new file mode 100644 index 0000000000..ba1c332e14 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qcolor.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qcursor.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qcursor.bin new file mode 100644 index 0000000000..545fa96a1f Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qcursor.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qeasingcurve.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qeasingcurve.bin new file mode 100644 index 0000000000..b3fce0db6d Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qeasingcurve.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qfont.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qfont.bin new file mode 100644 index 0000000000..ce31032451 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qfont.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qicon.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qicon.bin new file mode 100644 index 0000000000..2f8713244c Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qicon.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qimage.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qimage.bin new file mode 100644 index 0000000000..0ab1cbf6fa Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qimage.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qkeysequence.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qkeysequence.bin new file mode 100644 index 0000000000..ec82cc2871 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qkeysequence.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qmatrix.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qmatrix.bin new file mode 100644 index 0000000000..24bf570968 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qmatrix.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qmatrix4x4.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qmatrix4x4.bin new file mode 100644 index 0000000000..e4fc8054f9 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qmatrix4x4.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qpalette.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qpalette.bin new file mode 100644 index 0000000000..b3caa096cb Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qpalette.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qpen.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qpen.bin new file mode 100644 index 0000000000..964eaa4ee2 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qpen.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qpixmap.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qpixmap.bin new file mode 100644 index 0000000000..ce9cb8c434 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qpixmap.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qpolygon.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qpolygon.bin new file mode 100644 index 0000000000..fbdab8fffc Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qpolygon.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qquaternion.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qquaternion.bin new file mode 100644 index 0000000000..558767a6b4 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qquaternion.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qregion.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qregion.bin new file mode 100644 index 0000000000..27eec8c4d5 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qregion.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qtextformat.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qtextformat.bin new file mode 100644 index 0000000000..0d91130d62 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qtextformat.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qtextlength.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qtextlength.bin new file mode 100644 index 0000000000..640abfba00 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qtextlength.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qtransform.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qtransform.bin new file mode 100644 index 0000000000..86a7aaf1ed Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qtransform.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qvector2d.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qvector2d.bin new file mode 100644 index 0000000000..9fe7d9f936 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qvector2d.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qvector3d.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qvector3d.bin new file mode 100644 index 0000000000..b3c502f546 Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qvector3d.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qvector4d.bin b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qvector4d.bin new file mode 100644 index 0000000000..2db479c9ce Binary files /dev/null and b/tests/auto/gui/kernel/qguivariant/test/stream/qt5.0/qvector4d.bin differ diff --git a/tests/auto/gui/kernel/qguivariant/test/test.pro b/tests/auto/gui/kernel/qguivariant/test/test.pro new file mode 100644 index 0000000000..d47cf7bf6f --- /dev/null +++ b/tests/auto/gui/kernel/qguivariant/test/test.pro @@ -0,0 +1,6 @@ +CONFIG += testcase +CONFIG += parallel_test +TARGET = tst_qguivariant +SOURCES += tst_qguivariant.cpp +INCLUDEPATH += $$PWD/../../../../other/qvariant_common +QT += testlib diff --git a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp new file mode 100644 index 0000000000..301d8891bb --- /dev/null +++ b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp @@ -0,0 +1,646 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "tst_qvariant_common.h" + + +class tst_QGuiVariant : public QObject +{ + Q_OBJECT + +private slots: + void constructor_invalid_data(); + void constructor_invalid(); + + void canConvert_data(); + void canConvert(); + + void toInt_data(); + void toInt(); + + void toFont_data(); + void toFont(); + + void toKeySequence_data(); + void toKeySequence(); + + void toString_data(); + void toString(); + + void toColor_data(); + void toColor(); + + void toPixmap_data(); + void toPixmap(); + + void toImage_data(); + void toImage(); + + void toBrush_data(); + void toBrush(); + + void matrix(); + + void transform(); + + void matrix4x4(); + void vector2D(); + void vector3D(); + void vector4D(); + void quaternion(); + + void writeToReadFromDataStream_data(); + void writeToReadFromDataStream(); + + void colorInteger(); + void invalidQColor(); + + void debugStream_data(); + void debugStream(); + + void guiVariantAtExit(); +}; + +void tst_QGuiVariant::constructor_invalid_data() +{ + QTest::addColumn("typeId"); + + QTest::newRow("LastGuiType + 1") << uint(QMetaType::LastGuiType + 1); + QVERIFY(!QMetaType::isRegistered(QMetaType::LastGuiType + 1)); + QTest::newRow("LastWidgetsType + 1") << uint(QMetaType::LastWidgetsType + 1); + QVERIFY(!QMetaType::isRegistered(QMetaType::LastWidgetsType + 1)); +} + +void tst_QGuiVariant::constructor_invalid() +{ + + QFETCH(uint, typeId); + { + MessageHandlerInvalidType msg; + QVariant variant(static_cast(typeId)); + QVERIFY(!variant.isValid()); + QVERIFY(variant.userType() == QMetaType::UnknownType); + QVERIFY(msg.ok); + } + { + MessageHandlerInvalidType msg; + QVariant variant(typeId, /* copy */ 0); + QVERIFY(!variant.isValid()); + QVERIFY(variant.userType() == QMetaType::UnknownType); + QVERIFY(msg.ok); + } +} + +void tst_QGuiVariant::canConvert_data() +{ + TST_QVARIANT_CANCONVERT_DATATABLE_HEADERS + +#ifdef Y +#undef Y +#endif +#ifdef N +#undef N +#endif +#define Y true +#define N false + + QVariant var; + + // bita bitm bool brsh byta col curs date dt dbl font img int inv kseq list ll map pal pen pix pnt rect reg size sp str strl time uint ull + + + var = QVariant::fromValue(QBitmap()); + QTest::newRow("Bitmap") + << var << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N; + var = QVariant::fromValue(QBrush()); + QTest::newRow("Brush") + << var << N << N << N << Y << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N; + var = QVariant::fromValue(QColor()); + QTest::newRow("Color") + << var << N << N << N << Y << Y << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N; +#ifndef QT_NO_CURSOR + var = QVariant::fromValue(QCursor()); + QTest::newRow("Cursor") + << var << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N; +#endif + var = QVariant::fromValue(QFont()); + QTest::newRow("Font") + << var << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N; + var = QVariant::fromValue(QIcon()); + QTest::newRow("Icon") + << var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N; + var = QVariant::fromValue(QImage()); + QTest::newRow("Image") + << var << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N; + var = QVariant::fromValue(QKeySequence()); + QTest::newRow("KeySequence") + << var << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << Y << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N; + var = QVariant::fromValue(QPalette()); + QTest::newRow("Palette") + << var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N << N; + var = QVariant::fromValue(QPen()); + QTest::newRow("Pen") + << var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N; + var = QVariant::fromValue(QPixmap()); + QTest::newRow("Pixmap") + << var << N << Y << N << Y << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N; + var = QVariant::fromValue(QPolygon()); + QTest::newRow("PointArray") + << var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N; + var = QVariant::fromValue(QRegion()); + QTest::newRow("Region") + << var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N; + +#undef N +#undef Y +} + +void tst_QGuiVariant::canConvert() +{ + TST_QVARIANT_CANCONVERT_FETCH_DATA + + TST_QVARIANT_CANCONVERT_COMPARE_DATA +} + +void tst_QGuiVariant::toInt_data() +{ + QTest::addColumn("value"); + QTest::addColumn("result"); + QTest::addColumn("valueOK"); + + QTest::newRow( "keysequence" ) << QVariant::fromValue( QKeySequence( Qt::Key_A ) ) << 65 << true; +} + +void tst_QGuiVariant::toInt() +{ + QFETCH( QVariant, value ); + QFETCH( int, result ); + QFETCH( bool, valueOK ); + QVERIFY( value.isValid() == value.canConvert( QVariant::Int ) ); + bool ok; + int i = value.toInt( &ok ); + QCOMPARE( i, result ); + QVERIFY( ok == valueOK ); +} + +void tst_QGuiVariant::toColor_data() +{ + QTest::addColumn("value"); + QTest::addColumn("result"); + + QColor c("red"); + QTest::newRow( "string" ) << QVariant( QString( "red" ) ) << c; + QTest::newRow( "solid brush" ) << QVariant( QBrush(c) ) << c; +} + +void tst_QGuiVariant::toColor() +{ + QFETCH( QVariant, value ); + QFETCH( QColor, result ); + QVERIFY( value.isValid() ); + QVERIFY( value.canConvert( QVariant::Color ) ); + QColor d = qvariant_cast(value); + QCOMPARE( d, result ); +} + +void tst_QGuiVariant::toPixmap_data() +{ + QTest::addColumn("value"); + QTest::addColumn("result"); + + QPixmap pm(30, 30); + pm.fill(Qt::red); + QTest::newRow( "image" ) << QVariant( pm ) << pm; + + QBitmap bm(30, 30); + bm.fill(Qt::color1); + QTest::newRow( "bitmap" ) << QVariant( bm ) << QPixmap(bm); +} + +void tst_QGuiVariant::toPixmap() +{ + QFETCH( QVariant, value ); + QFETCH( QPixmap, result ); + QVERIFY( value.isValid() ); + QVERIFY( value.canConvert( QVariant::Pixmap ) ); + QPixmap d = qvariant_cast(value); + QCOMPARE( d, result ); +} + +void tst_QGuiVariant::toImage_data() +{ + QTest::addColumn("value"); + QTest::addColumn("result"); + + QImage im(30, 30, QImage::Format_ARGB32); + im.fill(0x7fff0000); + QTest::newRow( "image" ) << QVariant( im ) << im; +} + +void tst_QGuiVariant::toImage() +{ + QFETCH( QVariant, value ); + QFETCH( QImage, result ); + QVERIFY( value.isValid() ); + QVERIFY( value.canConvert( QVariant::Image ) ); + QImage d = qvariant_cast(value); + QCOMPARE( d, result ); +} + +void tst_QGuiVariant::toBrush_data() +{ + QTest::addColumn("value"); + QTest::addColumn("result"); + + QColor c(Qt::red); + QTest::newRow( "color" ) << QVariant( c ) << QBrush(c); + QPixmap pm(30, 30); + pm.fill(c); + QTest::newRow( "pixmap" ) << QVariant( pm ) << QBrush(pm); +} + +void tst_QGuiVariant::toBrush() +{ + QFETCH( QVariant, value ); + QFETCH( QBrush, result ); + QVERIFY( value.isValid() ); + QVERIFY( value.canConvert( QVariant::Brush ) ); + QBrush d = qvariant_cast(value); + QCOMPARE( d, result ); +} + +void tst_QGuiVariant::toFont_data() +{ + QTest::addColumn("value"); + QTest::addColumn("result"); + + QFont f("times",12,-1,false); + QTest::newRow( "string" ) << QVariant( QString( "times,12,-1,5,50,0,0,0,0,0" ) ) << f; +} + +void tst_QGuiVariant::toFont() +{ + QFETCH( QVariant, value ); + QFETCH( QFont, result ); + QVERIFY( value.isValid() ); + QVERIFY( value.canConvert( QVariant::Font ) ); + QFont d = qvariant_cast(value); + QCOMPARE( d, result ); +} + +void tst_QGuiVariant::toKeySequence_data() +{ + QTest::addColumn("value"); + QTest::addColumn("result"); + + + QTest::newRow( "int" ) << QVariant( 67108929 ) << QKeySequence( Qt::CTRL + Qt::Key_A ); + + + QTest::newRow( "qstring" ) + << QVariant( QString( "Ctrl+A" ) ) + << QKeySequence( Qt::CTRL + Qt::Key_A ); +} + +void tst_QGuiVariant::toKeySequence() +{ + QFETCH( QVariant, value ); + QFETCH( QKeySequence, result ); + QVERIFY( value.isValid() ); + QVERIFY( value.canConvert( QVariant::KeySequence ) ); + QKeySequence d = qvariant_cast(value); + QCOMPARE( d, result ); +} + +void tst_QGuiVariant::toString_data() +{ + QTest::addColumn("value"); + QTest::addColumn("result"); + + QTest::newRow( "qkeysequence" ) << QVariant::fromValue( QKeySequence( Qt::CTRL + Qt::Key_A ) ) +#ifndef Q_OS_MAC + << QString( "Ctrl+A" ); +#else + << QString(QChar(0x2318)) + "A"; +#endif + + QFont font( "times", 12 ); + QTest::newRow( "qfont" ) << QVariant::fromValue( font ) << QString("times,12,-1,5,50,0,0,0,0,0"); + QTest::newRow( "qcolor" ) << QVariant::fromValue( QColor( 10, 10, 10 ) ) << QString( "#0a0a0a" ); +} + +void tst_QGuiVariant::toString() +{ + QFETCH( QVariant, value ); + QFETCH( QString, result ); + QVERIFY( value.isValid() ); + QVERIFY( value.canConvert( QVariant::String ) ); + QString str = value.toString(); + QCOMPARE( str, result ); +} + +void tst_QGuiVariant::matrix() +{ + QVariant variant; + QMatrix matrix = qvariant_cast(variant); + QVERIFY(matrix.isIdentity()); + variant.setValue(QMatrix().rotate(90)); + QCOMPARE(QMatrix().rotate(90), qvariant_cast(variant)); + + void *mmatrix = QMetaType::create(QVariant::Matrix, 0); + QVERIFY(mmatrix); + QMetaType::destroy(QVariant::Matrix, mmatrix); +} + +void tst_QGuiVariant::matrix4x4() +{ + QVariant variant; + QMatrix4x4 matrix = qvariant_cast(variant); + QVERIFY(matrix.isIdentity()); + QMatrix4x4 m; + m.scale(2.0f); + variant.setValue(m); + QCOMPARE(m, qvariant_cast(variant)); + + void *mmatrix = QMetaType::create(QVariant::Matrix4x4, 0); + QVERIFY(mmatrix); + QMetaType::destroy(QVariant::Matrix4x4, mmatrix); +} + +void tst_QGuiVariant::transform() +{ + QVariant variant; + QTransform matrix = qvariant_cast(variant); + QVERIFY(matrix.isIdentity()); + variant.setValue(QTransform().rotate(90)); + QCOMPARE(QTransform().rotate(90), qvariant_cast(variant)); + + void *mmatrix = QMetaType::create(QVariant::Transform, 0); + QVERIFY(mmatrix); + QMetaType::destroy(QVariant::Transform, mmatrix); +} + + +void tst_QGuiVariant::vector2D() +{ + QVariant variant; + QVector2D vector = qvariant_cast(variant); + QVERIFY(vector.isNull()); + variant.setValue(QVector2D(0.1, 0.2)); + QCOMPARE(QVector2D(0.1, 0.2), qvariant_cast(variant)); + + void *pvector = QMetaType::create(QVariant::Vector2D, 0); + QVERIFY(pvector); + QMetaType::destroy(QVariant::Vector2D, pvector); +} + +void tst_QGuiVariant::vector3D() +{ + QVariant variant; + QVector3D vector = qvariant_cast(variant); + QVERIFY(vector.isNull()); + variant.setValue(QVector3D(0.1, 0.2, 0.3)); + QCOMPARE(QVector3D(0.1, 0.2, 0.3), qvariant_cast(variant)); + + void *pvector = QMetaType::create(QVariant::Vector3D, 0); + QVERIFY(pvector); + QMetaType::destroy(QVariant::Vector3D, pvector); +} + +void tst_QGuiVariant::vector4D() +{ + QVariant variant; + QVector4D vector = qvariant_cast(variant); + QVERIFY(vector.isNull()); + variant.setValue(QVector4D(0.1, 0.2, 0.3, 0.4)); + QCOMPARE(QVector4D(0.1, 0.2, 0.3, 0.4), qvariant_cast(variant)); + + void *pvector = QMetaType::create(QVariant::Vector4D, 0); + QVERIFY(pvector); + QMetaType::destroy(QVariant::Vector4D, pvector); +} + +void tst_QGuiVariant::quaternion() +{ + QVariant variant; + QQuaternion quaternion = qvariant_cast(variant); + QVERIFY(quaternion.isIdentity()); + variant.setValue(QQuaternion(0.1, 0.2, 0.3, 0.4)); + QCOMPARE(QQuaternion(0.1, 0.2, 0.3, 0.4), qvariant_cast(variant)); + + void *pquaternion = QMetaType::create(QVariant::Quaternion, 0); + QVERIFY(pquaternion); + QMetaType::destroy(QVariant::Quaternion, pquaternion); +} + +void tst_QGuiVariant::writeToReadFromDataStream_data() +{ + QTest::addColumn("writeVariant"); + QTest::addColumn("isNull"); + + QTest::newRow( "bitmap_invalid" ) << QVariant::fromValue( QBitmap() ) << true; + QBitmap bitmap( 10, 10 ); + bitmap.fill( Qt::red ); + QTest::newRow( "bitmap_valid" ) << QVariant::fromValue( bitmap ) << false; + QTest::newRow( "brush_valid" ) << QVariant::fromValue( QBrush( Qt::red ) ) << false; + QTest::newRow( "color_valid" ) << QVariant::fromValue( QColor( Qt::red ) ) << false; +#ifndef QT_NO_CURSOR + QTest::newRow( "cursor_valid" ) << QVariant::fromValue( QCursor( Qt::PointingHandCursor ) ) << false; +#endif + QTest::newRow( "font_valid" ) << QVariant::fromValue( QFont( "times", 12 ) ) << false; + QTest::newRow( "pixmap_invalid" ) << QVariant::fromValue( QPixmap() ) << true; + QPixmap pixmap( 10, 10 ); + pixmap.fill( Qt::red ); + QTest::newRow( "pixmap_valid" ) << QVariant::fromValue( pixmap ) << false; + QTest::newRow( "image_invalid" ) << QVariant::fromValue( QImage() ) << true; + QTest::newRow( "keysequence_valid" ) << QVariant::fromValue( QKeySequence( Qt::CTRL + Qt::Key_A ) ) << false; + QTest::newRow( "palette_valid" ) << QVariant::fromValue(QPalette(QColor("turquoise"))) << false; + QTest::newRow( "pen_valid" ) << QVariant::fromValue( QPen( Qt::red ) ) << false; + QTest::newRow( "pointarray_invalid" ) << QVariant::fromValue( QPolygon() ) << true; + QTest::newRow( "pointarray_valid" ) << QVariant::fromValue( QPolygon( QRect( 10, 10, 20, 20 ) ) ) << false; + QTest::newRow( "region_invalid" ) << QVariant::fromValue( QRegion() ) << true; + QTest::newRow( "region_valid" ) << QVariant::fromValue( QRegion( 10, 10, 20, 20 ) ) << false; +} + +void tst_QGuiVariant::invalidQColor() +{ + QVariant va("An invalid QColor::name() value."); + QVERIFY(va.canConvert(QVariant::Color)); + + QVERIFY(!va.convert(QVariant::Color)); + + QVERIFY(!qvariant_cast(va).isValid()); +} + +void tst_QGuiVariant::colorInteger() +{ + QVariant v = QColor(Qt::red); + QCOMPARE(v.type(), QVariant::Color); + QCOMPARE(v.value(), QColor(Qt::red)); + + v.setValue(1000); + QCOMPARE(v.type(), QVariant::Int); + QCOMPARE(v.toInt(), 1000); + + v.setValue(QColor(Qt::yellow)); + QCOMPARE(v.type(), QVariant::Color); + QCOMPARE(v.value(), QColor(Qt::yellow)); +} + +void tst_QGuiVariant::writeToReadFromDataStream() +{ + QFETCH( QVariant, writeVariant ); + QFETCH( bool, isNull ); + QByteArray data; + + QDataStream writeStream( &data, QIODevice::WriteOnly ); + writeStream << writeVariant; + + QVariant readVariant; + QDataStream readStream( &data, QIODevice::ReadOnly ); + readStream >> readVariant; + QVERIFY( readVariant.isNull() == isNull ); + // Best way to confirm the readVariant contains the same data? + // Since only a few won't match since the serial numbers are different + // I won't bother adding another bool in the data test. + const int writeType = writeVariant.userType(); + if ( writeType != QVariant::Invalid && writeType != QVariant::Bitmap && writeType != QVariant::Pixmap + && writeType != QVariant::Image) { + switch (writeType) { + default: + QCOMPARE( readVariant, writeVariant ); + break; + + // compare types know by QMetaType but not QVariant (QVariant::operator==() knows nothing about them) + case QMetaType::Long: + QCOMPARE(qvariant_cast(readVariant), qvariant_cast(writeVariant)); + break; + case QMetaType::ULong: + QCOMPARE(qvariant_cast(readVariant), qvariant_cast(writeVariant)); + break; + case QMetaType::Short: + QCOMPARE(qvariant_cast(readVariant), qvariant_cast(writeVariant)); + break; + case QMetaType::UShort: + QCOMPARE(qvariant_cast(readVariant), qvariant_cast(writeVariant)); + break; + case QMetaType::Char: + QCOMPARE(qvariant_cast(readVariant), qvariant_cast(writeVariant)); + break; + case QMetaType::UChar: + QCOMPARE(qvariant_cast(readVariant), qvariant_cast(writeVariant)); + break; + case QMetaType::Float: + { + // the uninitialized float can be NaN (observed on Windows Mobile 5 ARMv4i) + float readFloat = qvariant_cast(readVariant); + float writtenFloat = qvariant_cast(writeVariant); + QVERIFY(qIsNaN(readFloat) == qIsNaN(writtenFloat)); + if (!qIsNaN(readFloat)) + QVERIFY(readFloat == writtenFloat); + } + break; + } + } +} + +void tst_QGuiVariant::debugStream_data() +{ + QTest::addColumn("variant"); + QTest::addColumn("typeId"); + for (int id = QMetaType::FirstGuiType; id <= QMetaType::LastGuiType; ++id) { + const char *tagName = QMetaType::typeName(id); + if (!tagName) + continue; + QTest::newRow(tagName) << QVariant(static_cast(id)) << id; + } +} + +void tst_QGuiVariant::debugStream() +{ + QFETCH(QVariant, variant); + QFETCH(int, typeId); + + MessageHandler msgHandler(typeId); + qDebug() << variant; + QVERIFY(msgHandler.testPassed()); +} + +void tst_QGuiVariant::guiVariantAtExit() +{ + // crash test, it should not crash at QGuiApplication exit + static QVariant cursor = QCursor(); + static QVariant point = QPoint(); + static QVariant icon = QIcon(); + static QVariant image = QImage(); + static QVariant palette = QPalette(); + Q_UNUSED(cursor); + Q_UNUSED(point); + Q_UNUSED(icon); + Q_UNUSED(image); + Q_UNUSED(palette); + QVERIFY(true); +} + +QTEST_MAIN(tst_QGuiVariant) +#include "tst_qguivariant.moc" diff --git a/tests/auto/gui/kernel/qguivariant/tst_qguivariant.cpp b/tests/auto/gui/kernel/qguivariant/tst_qguivariant.cpp deleted file mode 100644 index 90984eb9f9..0000000000 --- a/tests/auto/gui/kernel/qguivariant/tst_qguivariant.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include - -#include - - - -class tst_QGuiVariant : public QObject -{ - Q_OBJECT - -public: - tst_QGuiVariant(); - -private slots: - void variantWithoutApplication(); -}; - -tst_QGuiVariant::tst_QGuiVariant() -{} - -void tst_QGuiVariant::variantWithoutApplication() -{ - QVariant v = QString("red"); - - QVERIFY(qvariant_cast(v) == QColor(Qt::red)); -} - - -QTEST_APPLESS_MAIN(tst_QGuiVariant) -#include "tst_qguivariant.moc" -- cgit v1.2.3