diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2014-07-26 21:41:34 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2014-08-06 13:52:30 +0200 |
commit | 8b75ae4b82ae689dd8f9cf6db16cd7a8d2f402a1 (patch) | |
tree | a33b619da8d8206b022b2c8e6a13450c754ad78d /tests | |
parent | de8a9dee5aa7c8db3b390c9a19f65c919d201c3c (diff) |
Add a test for some copy semantics to QPalette
It isn't a thorough check of all the mutable methods for detaching, but a start.
Change-Id: I523fd30d3459186654e12fd25c384ed990ab7a00
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/gui/kernel/qpalette/tst_qpalette.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp index 662e35dfaf..c3c1fc6ea6 100644 --- a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp +++ b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp @@ -50,6 +50,7 @@ class tst_QPalette : public QObject private Q_SLOTS: void roleValues_data(); void roleValues(); + void copySemantics(); void moveSemantics(); }; @@ -90,6 +91,27 @@ void tst_QPalette::roleValues() QCOMPARE(role, value); } +void tst_QPalette::copySemantics() +{ + QPalette src(Qt::red), dst; + const QPalette control = src; // copy construction + QVERIFY(src != dst); + QVERIFY(!src.isCopyOf(dst)); + QCOMPARE(src, control); + QVERIFY(src.isCopyOf(control)); + dst = src; // copy assignment + QCOMPARE(dst, src); + QCOMPARE(dst, control); + QVERIFY(dst.isCopyOf(src)); + + dst = QPalette(Qt::green); + QVERIFY(dst != src); + QVERIFY(dst != control); + QCOMPARE(src, control); + QVERIFY(!dst.isCopyOf(src)); + QVERIFY(src.isCopyOf(control)); +} + void tst_QPalette::moveSemantics() { #ifdef Q_COMPILER_RVALUE_REFS |