summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/painting
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui/painting')
-rw-r--r--tests/auto/gui/painting/qcolor/tst_qcolor.cpp13
-rw-r--r--tests/auto/gui/painting/qpen/tst_qpen.cpp53
2 files changed, 64 insertions, 2 deletions
diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
index 1b1f5575b1..2e1d55ced4 100644
--- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
+++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
@@ -530,10 +530,19 @@ static const int rgbTblSize = sizeof(rgbTbl) / sizeof(RGBData);
void tst_QColor::setNamedColor()
{
for (int i = 0; i < rgbTblSize; ++i) {
- QColor color;
- color.setNamedColor(QLatin1String(rgbTbl[i].name));
QColor expected;
expected.setRgba(rgbTbl[i].value);
+
+ QColor color;
+ color.setNamedColor(QLatin1String(rgbTbl[i].name));
+ QCOMPARE(color, expected);
+
+ // name should be case insensitive
+ color.setNamedColor(QString(rgbTbl[i].name).toUpper());
+ QCOMPARE(color, expected);
+
+ // spaces should be ignored
+ color.setNamedColor(QString(rgbTbl[i].name).insert(1, ' '));
QCOMPARE(color, expected);
}
}
diff --git a/tests/auto/gui/painting/qpen/tst_qpen.cpp b/tests/auto/gui/painting/qpen/tst_qpen.cpp
index 07c996d026..a373c51710 100644
--- a/tests/auto/gui/painting/qpen/tst_qpen.cpp
+++ b/tests/auto/gui/painting/qpen/tst_qpen.cpp
@@ -57,6 +57,8 @@ public:
private slots:
void getSetCheck();
void swap();
+ void move();
+ void move_assign();
void operator_eq_eq();
void operator_eq_eq_data();
@@ -101,6 +103,57 @@ void tst_QPen::swap()
QCOMPARE(p2.color(), QColor(Qt::black));
}
+void tst_QPen::move()
+{
+ QPen p1(Qt::black);
+
+ // check that moving does the right thing:
+ QPen p2 = qMove(p1); // could be move or copy construction, so don't check p1's state
+ QCOMPARE(p2.color(), QColor(Qt::black));
+
+ // this, executed ehre, would crash:
+ // QVERIFY(p1.style() != Qt::NoPen);
+
+ // check that moved-from QPen p1 can still be safely copied:
+ const QPen p3 = p1;
+
+ // check that moved-from QPen p1 can still be safely assigned to:
+ const QPen p4(Qt::yellow);
+ p1 = p4;
+ QCOMPARE(p1.color(), QColor(Qt::yellow));
+
+ // check that moved-from QPens p2, p3 can still be safely destroyed:
+ QPen p5 = qMove(p2);
+
+ // intentionally no more statements beyond this point
+}
+
+void tst_QPen::move_assign()
+{
+ QPen p1(Qt::black), p2(Qt::white);
+
+ // check that moving does the right thing:
+ p2 = qMove(p1); // could be move or copy assignment, so don't check p1's state
+ QCOMPARE(p2.color(), QColor(Qt::black));
+
+ // check that move-assigned-from QPen p1 can still be used, albeit
+ // with undocumented state (it's p2's original state):
+ QVERIFY(p1.style() != Qt::NoPen);
+
+ // check that moved-from QPen p1 can still be safely copied:
+ const QPen p3 = p1;
+
+ // check that moved-from QPen p1 can still be safely assigned to:
+ const QPen p4(Qt::yellow);
+ p1 = p4;
+ QCOMPARE(p1.color(), QColor(Qt::yellow));
+
+ // check that moved-from QPens p2, p3 can still be safely destroyed:
+ QPen p5;
+ p5 = qMove(p2);
+
+ // intentionally no more statements beyond this point
+}
tst_QPen::tst_QPen()