diff options
Diffstat (limited to 'tests/auto/gui/text/qcssparser/tst_qcssparser.cpp')
-rw-r--r-- | tests/auto/gui/text/qcssparser/tst_qcssparser.cpp | 70 |
1 files changed, 41 insertions, 29 deletions
diff --git a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp index b1beb0ffd0..847d6e2e2f 100644 --- a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp +++ b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -185,7 +180,7 @@ static void debug(const QVector<QCss::Symbol> &symbols, int index = -1) { qDebug() << "all symbols:"; for (int i = 0; i < symbols.count(); ++i) - qDebug() << "(" << i << "); Token:" << tokenName(symbols.at(i).token) << "; Lexem:" << symbols.at(i).lexem(); + qDebug() << '(' << i << "); Token:" << tokenName(symbols.at(i).token) << "; Lexem:" << symbols.at(i).lexem(); if (index != -1) qDebug() << "failure at index" << index; } @@ -916,21 +911,37 @@ void tst_QCssParser::marginValue_data() int ex = QFontMetrics(f).xHeight(); int em = QFontMetrics(f).height(); + const QString ex1234 = QString::number(ex) + QLatin1Char(' ') + QString::number(2 * ex) + + QLatin1Char(' ') + QString::number(3 * ex) + QLatin1Char(' ') + + QString::number(4 * ex); + const QString em2ex4 = QLatin1String("1 ") + QString::number(2*em) + QLatin1String(" 3 ") + + QString::number(4 * ex); + QTest::newRow("one value") << "margin: 1px" << "1 1 1 1"; QTest::newRow("two values") << "margin: 1px 2px" << "1 2 1 2"; QTest::newRow("three value") << "margin: 1px 2px 3px" << "1 2 3 2"; QTest::newRow("four values") << "margin: 1px 2px 3px 4px" << "1 2 3 4"; QTest::newRow("default px") << "margin: 1 2 3 4" << "1 2 3 4"; QTest::newRow("no unit") << "margin: 1 2 3 4" << "1 2 3 4"; - QTest::newRow("em") << "margin: 1ex 2ex 3ex 4ex" << QString("%1 %2 %3 %4").arg(ex).arg(2*ex).arg(3*ex).arg(4*ex); - QTest::newRow("ex") << "margin: 1 2em 3px 4ex" << QString("%1 %2 %3 %4").arg(1).arg(2*em).arg(3).arg(4*ex); + QTest::newRow("em") << "margin: 1ex 2ex 3ex 4ex" + << (QString::number(ex) + QLatin1Char(' ') + QString::number(2 * ex) + + QLatin1Char(' ') + QString::number(3 * ex) + QLatin1Char(' ') + + QString::number(4 * ex)); + QTest::newRow("ex") << "margin: 1 2em 3px 4ex" + << (QLatin1String("1 ") + QString::number(2 * em) + QLatin1String(" 3 ") + + QString::number(4 * ex)); f.setPointSize(20); f.setBold(true); ex = QFontMetrics(f).xHeight(); em = QFontMetrics(f).height(); - QTest::newRow("em2") << "font: bold 20pt; margin: 1ex 2ex 3ex 4ex" << QString("%1 %2 %3 %4").arg(ex).arg(2*ex).arg(3*ex).arg(4*ex); - QTest::newRow("ex2") << "margin: 1 2em 3px 4ex; font-size: 20pt; font-weight: bold;" << QString("%1 %2 %3 %4").arg(1).arg(2*em).arg(3).arg(4*ex); + QTest::newRow("em2") << "font: bold 20pt; margin: 1ex 2ex 3ex 4ex" + << (QString::number(ex) + QLatin1Char(' ') + QString::number(2 * ex) + + QLatin1Char(' ') + QString::number(3 * ex) + QLatin1Char(' ') + + QString::number(4 * ex)); + QTest::newRow("ex2") << "margin: 1 2em 3px 4ex; font-size: 20pt; font-weight: bold;" + << (QLatin1String("1 ") + QString::number(2 * em) + QLatin1String(" 3 ") + + QString::number(4 * ex)); QTest::newRow("crap") << "margin: crap" << "0 0 0 0"; } @@ -963,7 +974,8 @@ void tst_QCssParser::marginValue() int p[4]; int spacing; v.extractBox(m, p, &spacing); - QString str = QString("%1 %2 %3 %4").arg(m[0]).arg(m[1]).arg(m[2]).arg(m[3]); + QString str = QString::number(m[0]) + QLatin1Char(' ') + QString::number(m[1]) + + QLatin1Char(' ') + QString::number(m[2]) + QLatin1Char(' ') + QString::number(m[3]); QCOMPARE(str, expectedMargin); } } @@ -1090,7 +1102,7 @@ void tst_QCssParser::styleSelector() QFETCH(QString, xml); QFETCH(QString, elementToCheck); - QString css = QString("%1 { background-color: green }").arg(selector); + const QString css = selector + QLatin1String(" { background-color: green }"); QCss::Parser parser(css); QCss::StyleSheet sheet; QVERIFY(parser.parse(&sheet)); @@ -1154,7 +1166,7 @@ void tst_QCssParser::specificity() { QFETCH(QString, selector); - QString css = QString("%1 { }").arg(selector); + QString css = selector + QLatin1String(" { }"); QCss::Parser parser(css); QCss::StyleSheet sheet; QVERIFY(parser.parse(&sheet)); @@ -1340,7 +1352,7 @@ void tst_QCssParser::shorthandBackgroundProperty() QVERIFY(doc.setContent(QLatin1String("<!DOCTYPE test><test> <dummy/> </test>"))); css.prepend("dummy {"); - css.append("}"); + css.append(QLatin1Char('}')); QCss::Parser parser(css); QCss::StyleSheet sheet; @@ -1500,7 +1512,7 @@ void tst_QCssParser::gradient() QVERIFY(doc.setContent(QLatin1String("<!DOCTYPE test><test> <dummy/> </test>"))); css.prepend("dummy {"); - css.append("}"); + css.append(QLatin1Char('}')); QCss::Parser parser(css); QCss::StyleSheet sheet; @@ -1560,7 +1572,7 @@ void tst_QCssParser::extractFontFamily() { QFETCH(QString, css); css.prepend("dummy {"); - css.append("}"); + css.append(QLatin1Char('}')); QCss::Parser parser(css); QCss::StyleSheet sheet; @@ -1618,7 +1630,7 @@ void tst_QCssParser::extractBorder() QFETCH(QColor, expectedTopColor); css.prepend("dummy {"); - css.append("}"); + css.append(QLatin1Char('}')); QCss::Parser parser(css); QCss::StyleSheet sheet; |