summaryrefslogtreecommitdiffstats
path: root/tests/auto/qstylesheetstyle
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2009-09-21 15:32:51 +0200
committerGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2009-09-21 16:00:27 +0200
commit423cbcf1a26ce208d5440ffa0c7cd150ccfd8b3a (patch)
treefe3827e865c3bee03c41287d99ffffc474223cb6 /tests/auto/qstylesheetstyle
parent5759ee3ef9eea0a1ea06efd4c349ef7ecc35ab5e (diff)
When using Plastique style, changing the background style sheet property of a
spinbox wouldn't set the correct background for the embedded line edit. Reviewed-by: Olivier Task-number: 232085 Task-number: QTBUG-3013
Diffstat (limited to 'tests/auto/qstylesheetstyle')
-rw-r--r--tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
index 360e433f13..e7d804abc0 100644
--- a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
+++ b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
@@ -96,6 +96,7 @@ private slots:
void opaquePaintEvent_data();
void opaquePaintEvent();
void task188195_baseBackground();
+ void task232085_spinBoxLineEditBg();
//at the end because it mess with the style.
void widgetStyle();
@@ -1468,6 +1469,56 @@ void tst_QStyleSheetStyle::task188195_baseBackground()
QVERIFY(!testForColors(image, QColor(0xab, 0x12, 0x51)));
}
+void tst_QStyleSheetStyle::task232085_spinBoxLineEditBg()
+{
+ // This test is a simplified version of the focusColors() test above.
+
+ // Tests if colors can be changed by altering the focus of the widget.
+ // To avoid messy pixel-by-pixel comparison, we assume that the goal
+ // is reached if at least ten pixels of the right color can be found in
+ // the image.
+ // For this reason, we use unusual and extremely ugly colors! :-)
+
+ QSpinBox *spinbox = new QSpinBox;
+ spinbox->setValue(8888);
+
+ QDialog frame;
+ QLayout* layout = new QGridLayout;
+
+ QLineEdit* dummy = new QLineEdit; // Avoids initial focus.
+
+ // We only want to test the line edit colors.
+ spinbox->setStyleSheet("QSpinBox:focus { background: #e8ff66; color: #ff0084 } "
+ "QSpinBox::up-button, QSpinBox::down-button { background: black; }");
+
+ layout->addWidget(dummy);
+ layout->addWidget(spinbox);
+ frame.setLayout(layout);
+
+ frame.show();
+ QTest::qWaitForWindowShown(&frame);
+ QApplication::setActiveWindow(&frame);
+ spinbox->setFocus();
+ QApplication::processEvents();
+
+ QImage image(frame.width(), frame.height(), QImage::Format_ARGB32);
+ frame.render(&image);
+ if (image.depth() < 24) {
+ QSKIP("Test doesn't support color depth < 24", SkipAll);
+ }
+
+ QVERIFY2(testForColors(image, QColor(0xe8, 0xff, 0x66)),
+ (QString::fromLatin1(spinbox->metaObject()->className())
+ + " did not contain background color #e8ff66, using style "
+ + QString::fromLatin1(qApp->style()->metaObject()->className()))
+ .toLocal8Bit().constData());
+ QVERIFY2(testForColors(image, QColor(0xff, 0x00, 0x84)),
+ (QString::fromLatin1(spinbox->metaObject()->className())
+ + " did not contain text color #ff0084, using style "
+ + QString::fromLatin1(qApp->style()->metaObject()->className()))
+ .toLocal8Bit().constData());
+}
+
QTEST_MAIN(tst_QStyleSheetStyle)
#include "tst_qstylesheetstyle.moc"