From 8b75ae4b82ae689dd8f9cf6db16cd7a8d2f402a1 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 26 Jul 2014 21:41:34 +0200 Subject: 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 --- tests/auto/gui/kernel/qpalette/tst_qpalette.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/auto') 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 -- cgit v1.2.3