diff options
Diffstat (limited to 'tests/auto/gui/kernel/qpalette/tst_qpalette.cpp')
-rw-r--r-- | tests/auto/gui/kernel/qpalette/tst_qpalette.cpp | 61 |
1 files changed, 24 insertions, 37 deletions
diff --git a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp index f9da7de0d6..b2c0ff979c 100644 --- a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp +++ b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp @@ -46,47 +46,13 @@ class tst_QPalette : public QObject { -Q_OBJECT - -public: - tst_QPalette(); - virtual ~tst_QPalette(); - -public slots: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - -private slots: + Q_OBJECT +private Q_SLOTS: void roleValues_data(); void roleValues(); + void moveSemantics(); }; -tst_QPalette::tst_QPalette() -{ -} - -tst_QPalette::~tst_QPalette() -{ -} - -void tst_QPalette::initTestCase() -{ -} - -void tst_QPalette::cleanupTestCase() -{ -} - -void tst_QPalette::init() -{ -} - -void tst_QPalette::cleanup() -{ -} - void tst_QPalette::roleValues_data() { QTest::addColumn<int>("role"); @@ -124,5 +90,26 @@ void tst_QPalette::roleValues() QCOMPARE(role, value); } +void tst_QPalette::moveSemantics() +{ +#ifdef Q_COMPILER_RVALUE_REFS + QPalette src(Qt::red), dst; + const QPalette control = src; + QVERIFY(src != dst); + QCOMPARE(src, control); + QVERIFY(!dst.isCopyOf(src)); + QVERIFY(!dst.isCopyOf(control)); + dst = qMove(src); // move assignment + QVERIFY(!dst.isCopyOf(src)); // isCopyOf() works on moved-from palettes, too + QVERIFY(dst.isCopyOf(control)); + QCOMPARE(dst, control); + src = control; // check moved-from 'src' can still be assigned to (doesn't crash) + QVERIFY(src.isCopyOf(dst)); + QVERIFY(src.isCopyOf(control)); +#else + QSKIP("Compiler doesn't support C++11 move semantics"); +#endif +} + QTEST_MAIN(tst_QPalette) #include "tst_qpalette.moc" |