Split auto test palettePropagation2()
palettePropagation was a fairly long test function and was testing more than one thing at once. Split palettePropagation2() in two, creating the new auto test palettePropagation3() that verify if the text color propagation is correctly being ignored when setting a new palette for buttons. This was previously tested in palettePropagation2(). palettePropagation2() now only tests if colors are propagated correctly. Both function are now shorter, easier to understand and maintain. Change-Id: Icdad272d4cdc437595c0a31ab231d134cb3b5d86 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
parent
54d47f8390
commit
c316712fb8
@ -163,6 +163,7 @@ private slots:
|
||||
void fontPropagationDynamic();
|
||||
void palettePropagation();
|
||||
void palettePropagation2();
|
||||
void palettePropagation3();
|
||||
void palettePropagationDynamic();
|
||||
void enabledPropagation();
|
||||
void ignoreKeyEventsWhenDisabled_QTBUG27417();
|
||||
@ -1142,7 +1143,6 @@ void tst_QWidget::palettePropagation2()
|
||||
static constexpr QColor sysPalToolTipBase(12, 13, 14);
|
||||
static constexpr QColor overridePalText(42, 43, 44);
|
||||
static constexpr QColor overridePalToolTipBase(45, 46, 47);
|
||||
static constexpr QColor sysPalButton(99, 98, 97);
|
||||
|
||||
// Check that only the application fonts apply.
|
||||
const QPalette &appPal = QApplication::palette();
|
||||
@ -1179,6 +1179,37 @@ void tst_QWidget::palettePropagation2()
|
||||
else if (i <= 5)
|
||||
QCOMPARE(children.at(i)->palette().color(QPalette::ToolTipBase), overridePalToolTipBase);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QWidget::palettePropagation3() {
|
||||
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
|
||||
QSKIP("Wayland: This fails. Figure out why.");
|
||||
|
||||
QWidget root;
|
||||
root.setObjectName(QTest::currentTestFunction());
|
||||
root.setWindowTitle(root.objectName());
|
||||
root.resize(200, 200);
|
||||
|
||||
QWidget *parent = &root;
|
||||
static constexpr int propagationIndex = 2;
|
||||
QWidgetList children;
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
QWidget *w = (propagationIndex == i) ? new QPropagationTestWidget(parent) : new QWidget(parent);
|
||||
w->setObjectName(QString("Widget-%1").arg(i));
|
||||
children << w;
|
||||
parent = w;
|
||||
}
|
||||
|
||||
root.show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&root));
|
||||
|
||||
// These colors are unlikely to be imposed on the default palette of
|
||||
// QWidget ;-).
|
||||
static constexpr QColor overridePalText(42, 43, 44);
|
||||
static constexpr QColor overridePalToolTipBase(45, 46, 47);
|
||||
static constexpr QColor sysPalButton(99, 98, 97);
|
||||
|
||||
const QPalette &appPal = QApplication::palette();
|
||||
|
||||
// Replace the app palette for child2. Button should propagate but Text
|
||||
// should still be ignored. The previous ToolTipBase setting is gone.
|
||||
@ -1190,6 +1221,14 @@ void tst_QWidget::palettePropagation2()
|
||||
waitForPolished(children);
|
||||
QCOMPARE(root.palette(), appPal);
|
||||
|
||||
// Set children.at(0)'s Text, and set ToolTipBase on children.at(4).
|
||||
QPalette textPalette;
|
||||
textPalette.setColor(QPalette::Text, overridePalText);
|
||||
children.at(0)->setPalette(textPalette);
|
||||
QPalette toolTipPalette;
|
||||
toolTipPalette.setColor(QPalette::ToolTipBase, overridePalToolTipBase);
|
||||
children.at(4)->setPalette(toolTipPalette);
|
||||
|
||||
for (int i = 0; i < children.count(); i++) {
|
||||
QCOMPARE(children.at(i)->palette().color(QPalette::Text), overridePalText);
|
||||
if (i <= 1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user