tst_QStyleSheetStyle: use QString() instead of ""
Change-Id: I3bb375108b57059c4fb4f10342f532e20e78c152 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
parent
b472e73b02
commit
ccb396b401
@ -159,7 +159,7 @@ void tst_QStyleSheetStyle::numinstances()
|
||||
QCOMPARE(QStyleSheetStyle::numinstances, 0);
|
||||
qApp->setStyleSheet("* { color: red; }");
|
||||
QCOMPARE(QStyleSheetStyle::numinstances, 1);
|
||||
qApp->setStyleSheet("");
|
||||
qApp->setStyleSheet(QString());
|
||||
QCOMPARE(QStyleSheetStyle::numinstances, 0);
|
||||
|
||||
// set and unset application stylesheet+widget
|
||||
@ -168,9 +168,9 @@ void tst_QStyleSheetStyle::numinstances()
|
||||
QCOMPARE(QStyleSheetStyle::numinstances, 2);
|
||||
w.setStyle(style);
|
||||
QCOMPARE(QStyleSheetStyle::numinstances, 2);
|
||||
qApp->setStyleSheet("");
|
||||
qApp->setStyleSheet(QString());
|
||||
QCOMPARE(QStyleSheetStyle::numinstances, 1);
|
||||
w.setStyleSheet("");
|
||||
w.setStyleSheet(QString());
|
||||
QCOMPARE(QStyleSheetStyle::numinstances, 0);
|
||||
|
||||
// set and unset widget stylesheet
|
||||
@ -179,7 +179,7 @@ void tst_QStyleSheetStyle::numinstances()
|
||||
QCOMPARE(QStyleSheetStyle::numinstances, 1);
|
||||
c.setStyle(style);
|
||||
QCOMPARE(QStyleSheetStyle::numinstances, 2);
|
||||
w.setStyleSheet("");
|
||||
w.setStyleSheet(QString());
|
||||
QCOMPARE(QStyleSheetStyle::numinstances, 0);
|
||||
}
|
||||
|
||||
@ -192,9 +192,9 @@ void tst_QStyleSheetStyle::widgetsBeforeAppStyleSheet()
|
||||
QCOMPARE(COLOR(w1), red);
|
||||
w1.setStyleSheet("color: white");
|
||||
QCOMPARE(COLOR(w1), white);
|
||||
qApp->setStyleSheet("");
|
||||
qApp->setStyleSheet(QString());
|
||||
QCOMPARE(COLOR(w1), white);
|
||||
w1.setStyleSheet("");
|
||||
w1.setStyleSheet(QString());
|
||||
QCOMPARE(COLOR(w1), APPCOLOR(w1));
|
||||
}
|
||||
|
||||
@ -217,17 +217,17 @@ void tst_QStyleSheetStyle::widgetsAfterAppStyleSheet()
|
||||
QCOMPARE(COLOR(w1), white);
|
||||
QCOMPARE(COLOR(spin), red);
|
||||
QCOMPARE(COLOR(*spin.lineEdit()), red);
|
||||
w1.setStyleSheet("");
|
||||
w1.setStyleSheet(QString());
|
||||
QCOMPARE(COLOR(w1), red);
|
||||
QCOMPARE(COLOR(spin), red);
|
||||
QCOMPARE(COLOR(*spin.lineEdit()), red);
|
||||
w1.setStyleSheet("color: white");
|
||||
QCOMPARE(COLOR(w1), white);
|
||||
qApp->setStyleSheet("");
|
||||
qApp->setStyleSheet(QString());
|
||||
QCOMPARE(COLOR(w1), white);
|
||||
QCOMPARE(COLOR(spin), APPCOLOR(spin));
|
||||
QCOMPARE(COLOR(*spin.lineEdit()), APPCOLOR(*spin.lineEdit()));
|
||||
w1.setStyleSheet("");
|
||||
w1.setStyleSheet(QString());
|
||||
QCOMPARE(COLOR(w1), APPCOLOR(w1));
|
||||
// QCOMPARE(FONTSIZE(w1), APPFONTSIZE(w1)); //### task 244261
|
||||
QCOMPARE(FONTSIZE(spin), APPFONTSIZE(spin));
|
||||
@ -243,7 +243,7 @@ void tst_QStyleSheetStyle::applicationStyleSheet()
|
||||
QCOMPARE(COLOR(w1), red);
|
||||
qApp->setStyleSheet("* { color: white; }");
|
||||
QCOMPARE(COLOR(w1), white);
|
||||
qApp->setStyleSheet("");
|
||||
qApp->setStyleSheet(QString());
|
||||
QCOMPARE(COLOR(w1), APPCOLOR(w1));
|
||||
qApp->setStyleSheet("* { color: red }");
|
||||
QCOMPARE(COLOR(w1), red);
|
||||
@ -254,21 +254,21 @@ void tst_QStyleSheetStyle::windowStyleSheet()
|
||||
const QColor red(Qt::red);
|
||||
const QColor white(Qt::white);
|
||||
QPushButton w1;
|
||||
qApp->setStyleSheet("");
|
||||
qApp->setStyleSheet(QString());
|
||||
w1.setStyleSheet("* { color: red; }");
|
||||
QCOMPARE(COLOR(w1), red);
|
||||
w1.setStyleSheet("* { color: white; }");
|
||||
QCOMPARE(COLOR(w1), white);
|
||||
w1.setStyleSheet("");
|
||||
w1.setStyleSheet(QString());
|
||||
QCOMPARE(COLOR(w1), APPCOLOR(w1));
|
||||
w1.setStyleSheet("* { color: red }");
|
||||
QCOMPARE(COLOR(w1), red);
|
||||
|
||||
qApp->setStyleSheet("* { color: green }");
|
||||
QCOMPARE(COLOR(w1), red);
|
||||
w1.setStyleSheet("");
|
||||
w1.setStyleSheet(QString());
|
||||
QCOMPARE(COLOR(w1), QColor("green"));
|
||||
qApp->setStyleSheet("");
|
||||
qApp->setStyleSheet(QString());
|
||||
QCOMPARE(COLOR(w1), APPCOLOR(w1));
|
||||
}
|
||||
|
||||
@ -281,7 +281,7 @@ void tst_QStyleSheetStyle::widgetStyleSheet()
|
||||
QPushButton *pb = new QPushButton(&w1);
|
||||
QPushButton &w2 = *pb;
|
||||
|
||||
qApp->setStyleSheet("");
|
||||
qApp->setStyleSheet(QString());
|
||||
w1.setStyleSheet("* { color: red }");
|
||||
QCOMPARE(COLOR(w1), red);
|
||||
QCOMPARE(COLOR(w2), red);
|
||||
@ -293,11 +293,11 @@ void tst_QStyleSheetStyle::widgetStyleSheet()
|
||||
QCOMPARE(COLOR(w1), blue);
|
||||
QCOMPARE(COLOR(w2), white);
|
||||
|
||||
w1.setStyleSheet("");
|
||||
w1.setStyleSheet(QString());
|
||||
QCOMPARE(COLOR(w1), APPCOLOR(w1));
|
||||
QCOMPARE(COLOR(w2), white);
|
||||
|
||||
w2.setStyleSheet("");
|
||||
w2.setStyleSheet(QString());
|
||||
QCOMPARE(COLOR(w1), APPCOLOR(w1));
|
||||
QCOMPARE(COLOR(w2), APPCOLOR(w2));
|
||||
}
|
||||
@ -311,7 +311,7 @@ void tst_QStyleSheetStyle::reparentWithNoChildStyleSheet()
|
||||
QPushButton *pb = new QPushButton(&p1);
|
||||
QPushButton &c1 = *pb; // child with no stylesheet
|
||||
|
||||
qApp->setStyleSheet("");
|
||||
qApp->setStyleSheet(QString());
|
||||
p1.setStyleSheet("* { color: red }");
|
||||
QCOMPARE(COLOR(c1), red);
|
||||
c1.setParent(&p2);
|
||||
@ -333,7 +333,7 @@ void tst_QStyleSheetStyle::reparentWithChildStyleSheet()
|
||||
{
|
||||
const QColor gray("gray");
|
||||
const QColor white(Qt::white);
|
||||
qApp->setStyleSheet("");
|
||||
qApp->setStyleSheet(QString());
|
||||
QPushButton p1, p2;
|
||||
QPushButton *pb = new QPushButton(&p1);
|
||||
QPushButton &c1 = *pb;
|
||||
@ -353,7 +353,7 @@ void tst_QStyleSheetStyle::repolish()
|
||||
{
|
||||
const QColor red(Qt::red);
|
||||
const QColor white(Qt::white);
|
||||
qApp->setStyleSheet("");
|
||||
qApp->setStyleSheet(QString());
|
||||
QPushButton p1;
|
||||
p1.setStyleSheet("color: red; background: white");
|
||||
QCOMPARE(BACKGROUND(p1), white);
|
||||
@ -362,14 +362,14 @@ void tst_QStyleSheetStyle::repolish()
|
||||
p1.setStyleSheet("color: red");
|
||||
QCOMPARE(COLOR(p1), red);
|
||||
QCOMPARE(BACKGROUND(p1), APPBACKGROUND(p1));
|
||||
p1.setStyleSheet("");
|
||||
p1.setStyleSheet(QString());
|
||||
QCOMPARE(COLOR(p1), APPCOLOR(p1));
|
||||
QCOMPARE(BACKGROUND(p1), APPBACKGROUND(p1));
|
||||
}
|
||||
|
||||
void tst_QStyleSheetStyle::widgetStyle()
|
||||
{
|
||||
qApp->setStyleSheet("");
|
||||
qApp->setStyleSheet(QString());
|
||||
|
||||
QWidget *window1 = new QWidget;
|
||||
window1->setObjectName("window1");
|
||||
@ -429,7 +429,7 @@ void tst_QStyleSheetStyle::widgetStyle()
|
||||
|
||||
// Remove the stylesheet
|
||||
proxy = (QStyleSheetStyle *)window1->style();
|
||||
window1->setStyleSheet("");
|
||||
window1->setStyleSheet(QString());
|
||||
QVERIFY(proxy.isNull()); // should have disappeared
|
||||
QCOMPARE(window1->style(), style1.data()); // its restored
|
||||
|
||||
@ -457,7 +457,7 @@ void tst_QStyleSheetStyle::widgetStyle()
|
||||
QCOMPARE(proxy->baseStyle(), style1.data());
|
||||
|
||||
// Style Sheet propagation on a child widget with a custom style already set
|
||||
window2->setStyleSheet("");
|
||||
window2->setStyleSheet(QString());
|
||||
QCOMPARE(window2->style(), style2.data());
|
||||
QCOMPARE(widget2->style(), style1.data());
|
||||
widget2->setStyle(0);
|
||||
@ -470,9 +470,9 @@ void tst_QStyleSheetStyle::widgetStyle()
|
||||
|
||||
// clean everything out
|
||||
window1->setStyle(0);
|
||||
window1->setStyleSheet("");
|
||||
window1->setStyleSheet(QString());
|
||||
window2->setStyle(0);
|
||||
window2->setStyleSheet("");
|
||||
window2->setStyleSheet(QString());
|
||||
qApp->setStyle(0);
|
||||
|
||||
qApp->setStyleSheet("may_insanity_prevail { }"); // app has stylesheet
|
||||
@ -489,14 +489,14 @@ void tst_QStyleSheetStyle::widgetStyle()
|
||||
QCOMPARE(proxy->baseStyle(), newStyle); // magic ;) the widget still follows the application
|
||||
QCOMPARE(static_cast<QStyle *>(proxy), widget1->style()); // child still follows...
|
||||
|
||||
window1->setStyleSheet(""); // remove stylesheet
|
||||
window1->setStyleSheet(QString()); // remove stylesheet
|
||||
QCOMPARE(window1->style(), qApp->style()); // is this cool or what
|
||||
QCOMPARE(widget1->style(), qApp->style()); // annoying child follows...
|
||||
QScopedPointer<QStyle> wndStyle(QStyleFactory::create("Windows"));
|
||||
window1->setStyle(wndStyle.data());
|
||||
QCOMPARE(window1->style()->metaObject()->className(), "QStyleSheetStyle"); // auto wraps it
|
||||
QCOMPARE(widget1->style(), window1->style()); // and auto propagates to child
|
||||
qApp->setStyleSheet(""); // remove the app stylesheet
|
||||
qApp->setStyleSheet(QString()); // remove the app stylesheet
|
||||
QCOMPARE(window1->style(), wndStyle.data()); // auto dewrap
|
||||
QCOMPARE(widget1->style(), qApp->style()); // and child state is restored
|
||||
window1->setStyle(0); // let sanity prevail
|
||||
@ -511,7 +511,7 @@ void tst_QStyleSheetStyle::widgetStyle()
|
||||
|
||||
void tst_QStyleSheetStyle::appStyle()
|
||||
{
|
||||
qApp->setStyleSheet("");
|
||||
qApp->setStyleSheet(QString());
|
||||
// qApp style can never be 0
|
||||
QVERIFY(QApplication::style() != 0);
|
||||
QPointer<QStyle> style1 = QStyleFactory::create("Windows");
|
||||
@ -544,11 +544,11 @@ void tst_QStyleSheetStyle::appStyle()
|
||||
QCOMPARE(sss->baseStyle(), style1.data());
|
||||
|
||||
// Revert the stylesheet
|
||||
qApp->setStyleSheet("");
|
||||
qApp->setStyleSheet(QString());
|
||||
QVERIFY(sss.isNull()); // should have disappeared
|
||||
QCOMPARE(QApplication::style(), style1.data());
|
||||
|
||||
qApp->setStyleSheet("");
|
||||
qApp->setStyleSheet(QString());
|
||||
QCOMPARE(QApplication::style(), style1.data());
|
||||
}
|
||||
|
||||
@ -744,7 +744,7 @@ void tst_QStyleSheetStyle::fontPropagation()
|
||||
window.setStyleSheet("* { font-size: 10pt }");
|
||||
pb.setParent(&window);
|
||||
QCOMPARE(FONTSIZE(pb), 10);
|
||||
window.setStyleSheet("");
|
||||
window.setStyleSheet(QString());
|
||||
QCOMPARE(FONTSIZE(pb), buttonFontSize);
|
||||
|
||||
QTabWidget tw;
|
||||
@ -757,7 +757,7 @@ void tst_QStyleSheetStyle::fontPropagation()
|
||||
|
||||
void tst_QStyleSheetStyle::onWidgetDestroyed()
|
||||
{
|
||||
qApp->setStyleSheet("");
|
||||
qApp->setStyleSheet(QString());
|
||||
QLabel *l = new QLabel;
|
||||
l->setStyleSheet("QLabel { color: red }");
|
||||
QPointer<QStyleSheetStyle> ss = (QStyleSheetStyle *) l->style();
|
||||
@ -778,14 +778,14 @@ void tst_QStyleSheetStyle::fontPrecedence()
|
||||
font.setPointSize(16);
|
||||
edit.setFont(font);
|
||||
QCOMPARE(FONTSIZE(edit), 22);
|
||||
edit.setStyleSheet("");
|
||||
edit.setStyleSheet(QString());
|
||||
QCOMPARE(FONTSIZE(edit), 16);
|
||||
font.setPointSize(18);
|
||||
edit.setFont(font);
|
||||
QCOMPARE(FONTSIZE(edit), 18);
|
||||
edit.setStyleSheet("QLineEdit { font-size: 20pt; }");
|
||||
QCOMPARE(FONTSIZE(edit), 20);
|
||||
edit.setStyleSheet("");
|
||||
edit.setStyleSheet(QString());
|
||||
QCOMPARE(FONTSIZE(edit), 18);
|
||||
edit.hide();
|
||||
|
||||
@ -2051,7 +2051,7 @@ void tst_QStyleSheetStyle::styleSheetTargetAttribute()
|
||||
QCOMPARE(lb.testAttribute(Qt::WA_StyleSheetTarget), true);
|
||||
QCOMPARE(pb.testAttribute(Qt::WA_StyleSheetTarget), false);
|
||||
|
||||
qApp->setStyleSheet("");
|
||||
qApp->setStyleSheet(QString());
|
||||
|
||||
gb.ensurePolished(); lb.ensurePolished(); pb.ensurePolished();
|
||||
QCOMPARE(gb.testAttribute(Qt::WA_StyleSheetTarget), false);
|
||||
@ -2066,7 +2066,7 @@ void tst_QStyleSheetStyle::unpolish()
|
||||
w.setStyleSheet("QWidget { min-width: 100; }");
|
||||
w.ensurePolished();
|
||||
QCOMPARE(w.minimumWidth(), 100);
|
||||
w.setStyleSheet("");
|
||||
w.setStyleSheet(QString());
|
||||
QCOMPARE(w.minimumWidth(), 0);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user