summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorVitaly Fanaskov <vitaly.fanaskov@qt.io>2020-01-16 17:21:15 +0100
committerVitaly Fanaskov <vitaly.fanaskov@qt.io>2020-01-17 02:22:22 +0100
commit63b0b857f3cc84315a10c9b6d988bd657e7ce998 (patch)
treec2e221ed7fd2ba5ef094d1172efa9a1b21a311d1 /tests/auto
parent983432effdae888a372d814ff9516abbcb7a3c29 (diff)
QPalette: fix function swap and move operator
Additional data should also be taken into account when using move operator and function swap. This is already implemented for move constructor. Task-number: QTBUG-78544 Change-Id: I24ba34b0957a8fba7e15a934f2d08222dc95650f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/gui/kernel/qpalette/tst_qpalette.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp
index a4764a47c0..04343727bb 100644
--- a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp
+++ b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp
@@ -124,23 +124,35 @@ void tst_QPalette::resolve()
QVERIFY(p2ResolvedTo1 != p2);
}
+
+static void compareAllPaletteData(const QPalette &firstPalette, const QPalette &secondPalette)
+{
+ QCOMPARE(firstPalette, secondPalette);
+
+ // For historical reasons, operator== compares only brushes, but it's not enough for proper
+ // comparison after move/copy, because some additional data can also be moved/copied.
+ // Let's compare this data here.
+ QCOMPARE(firstPalette.resolve(), secondPalette.resolve());
+ QCOMPARE(firstPalette.currentColorGroup(), secondPalette.currentColorGroup());
+}
+
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);
+ compareAllPaletteData(src, control);
QVERIFY(src.isCopyOf(control));
dst = src; // copy assignment
- QCOMPARE(dst, src);
- QCOMPARE(dst, control);
+ compareAllPaletteData(dst, src);
+ compareAllPaletteData(dst, control);
QVERIFY(dst.isCopyOf(src));
dst = QPalette(Qt::green);
QVERIFY(dst != src);
QVERIFY(dst != control);
- QCOMPARE(src, control);
+ compareAllPaletteData(src, control);
QVERIFY(!dst.isCopyOf(src));
QVERIFY(src.isCopyOf(control));
}
@@ -150,13 +162,13 @@ void tst_QPalette::moveSemantics()
QPalette src(Qt::red), dst;
const QPalette control = src;
QVERIFY(src != dst);
- QCOMPARE(src, control);
+ compareAllPaletteData(src, control);
QVERIFY(!dst.isCopyOf(src));
QVERIFY(!dst.isCopyOf(control));
dst = std::move(src); // move assignment
QVERIFY(!dst.isCopyOf(src)); // isCopyOf() works on moved-from palettes, too
QVERIFY(dst.isCopyOf(control));
- QCOMPARE(dst, control);
+ compareAllPaletteData(dst, control);
src = control; // check moved-from 'src' can still be assigned to (doesn't crash)
QVERIFY(src.isCopyOf(dst));
QVERIFY(src.isCopyOf(control));
@@ -164,7 +176,7 @@ void tst_QPalette::moveSemantics()
QVERIFY(!src.isCopyOf(dst));
QVERIFY(!src.isCopyOf(dst2));
QVERIFY(!src.isCopyOf(control));
- QCOMPARE(dst2, control);
+ compareAllPaletteData(dst2, control);
QVERIFY(dst2.isCopyOf(dst));
QVERIFY(dst2.isCopyOf(control));
// check moved-from 'src' can still be destroyed (doesn't crash)