diff options
author | Gabriel de Dietrich <gabriel.dietrich-de@nokia.com> | 2009-09-21 13:32:51 (GMT) |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dietrich-de@nokia.com> | 2009-09-21 14:00:27 (GMT) |
commit | 423cbcf1a26ce208d5440ffa0c7cd150ccfd8b3a (patch) | |
tree | fe3827e865c3bee03c41287d99ffffc474223cb6 /tests/auto | |
parent | 5759ee3ef9eea0a1ea06efd4c349ef7ecc35ab5e (diff) | |
download | Qt-423cbcf1a26ce208d5440ffa0c7cd150ccfd8b3a.zip Qt-423cbcf1a26ce208d5440ffa0c7cd150ccfd8b3a.tar.gz Qt-423cbcf1a26ce208d5440ffa0c7cd150ccfd8b3a.tar.bz2 |
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')
-rw-r--r-- | tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp index 360e433..e7d804a 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" |