From 8af3500125a03a54dddb8c46ee709b7b8d257f27 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 27 Apr 2009 17:34:50 +0200 Subject: Fixes QLabel:hover{color:...} for simple text (This was only working if the QLabel had a QTextControl) Also rename the QStyleSheetStyle::focusPalette to ...::styleSheetPalette Reviewed-by: Jens Bache-Wiig --- .../auto/qstylesheetstyle/tst_qstylesheetstyle.cpp | 54 +++++++++++++++++++++- 1 file changed, 52 insertions(+), 2 deletions(-) (limited to 'tests/auto/qstylesheetstyle') diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp index aa63753d88..33f85d5576 100644 --- a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -81,6 +81,7 @@ private slots: void onWidgetDestroyed(); void fontPrecedence(); void focusColors(); + void hoverColors(); void background(); void tabAlignement(); void attributesList(); @@ -759,6 +760,7 @@ void tst_QStyleSheetStyle::focusColors() combobox->setEditable(true); combobox->addItems(QStringList() << "TESTING"); widgets << combobox; + widgets << new QLabel("TESTING"); #ifdef Q_WS_QWS // QWS has its own special focus logic which is slightly different @@ -808,6 +810,56 @@ void tst_QStyleSheetStyle::focusColors() // } } + +void tst_QStyleSheetStyle::hoverColors() +{ + QList widgets; + widgets << new QPushButton("TESTING"); + widgets << new QLineEdit("TESTING"); + widgets << new QLabel("TESTING"); + QSpinBox *spinbox = new QSpinBox; + spinbox->setValue(8888); + widgets << spinbox; + QComboBox *combobox = new QComboBox; + combobox->setEditable(true); + combobox->addItems(QStringList() << "TESTING"); + widgets << combobox; + widgets << new QLabel("TESTING"); + + foreach (QWidget *widget, widgets) { + QDialog frame; + QLayout* layout = new QGridLayout; + + QLineEdit* dummy = new QLineEdit; + + widget->setStyleSheet("*:hover { border:none; background: #e8ff66; color: #ff0084 }"); + + layout->addWidget(dummy); + layout->addWidget(widget); + frame.setLayout(layout); + + frame.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&frame); +#endif + QApplication::setActiveWindow(&frame); + QTest::qWait(60); + QTest::mouseMove ( widget, QPoint(5,5)); + QTest::qWait(60); + + QImage image(frame.width(), frame.height(), QImage::Format_ARGB32); + frame.render(&image); + + QVERIFY2(testForColors(image, QColor(0xe8, 0xff, 0x66)), + (QString::fromLatin1(widget->metaObject()->className()) + + " did not contain background color #e8ff66").toLocal8Bit().constData()); + QVERIFY2(testForColors(image, QColor(0xff, 0x00, 0x84)), + (QString::fromLatin1(widget->metaObject()->className()) + + " did not contain text color #ff0084").toLocal8Bit().constData()); + } + +} + class SingleInheritanceDialog : public QDialog { Q_OBJECT @@ -1377,8 +1429,6 @@ void tst_QStyleSheetStyle::task188195_baseBackground() QVERIFY(!testForColors(image, QColor(0xab, 0x12, 0x51))); } - - QTEST_MAIN(tst_QStyleSheetStyle) #include "tst_qstylesheetstyle.moc" -- cgit v1.2.1