From 95d127354887425b616a5087c24b6765b7bf907b Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 24 Oct 2016 15:53:06 +0200 Subject: Windows: Don't claim bitmap fonts support all standard sizes We were throwing away important information by claiming that all fonts support all the standard sizes in QFontDatabase on Windows This caused the font dialog to list unsupported sizes for bitmap fonts, unlike the native font dialog. We would also claim to support creating bitmap fonts at unsupported sizes, which would lead to 1. QFontInfo(font).pointSize() would return the requested size, not the actual rendered size. 2. Bitmap fonts created at 64 pixels and higher would be invisible. On Mac, there are no system bitmap fonts, and the use is not very common, but installing some bitmap fonts on the system, it does seem to ignore the sizes supported in the font and just displays the standard list instead, so we keep the current behavior there. [ChangeLog][QtGui][Text] Fixed list of supported sizes for bitmap fonts on Windows. Task-number: QTBUG-56672 Change-Id: Idbec2db9eb3381ab5ddf6259bd2befcba9b93564 Reviewed-by: Lars Knoll --- .../gui/text/qfontdatabase/tst_qfontdatabase.cpp | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests') diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp index c53792da99..8c26f8a91f 100644 --- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp +++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp @@ -67,6 +67,9 @@ private slots: void condensedFontWidth(); void condensedFontMatching(); + void rasterFonts(); + void smoothFonts(); + private: QString m_ledFont; QString m_testFont; @@ -334,5 +337,30 @@ void tst_QFontDatabase::condensedFontMatching() QFontMetrics(tfcBySubfamilyName).width(testString())); } +void tst_QFontDatabase::rasterFonts() +{ + QFont font(QLatin1String("Fixedsys"), 1000); + QFontInfo fontInfo(font); + + if (fontInfo.family() != font.family()) + QSKIP("Fixedsys font not available."); + + QVERIFY(!QFontDatabase().isSmoothlyScalable(font.family())); + QVERIFY(fontInfo.pointSize() != font.pointSize()); +} + +void tst_QFontDatabase::smoothFonts() +{ + QFont font(QLatin1String("Arial"), 1000); + QFontInfo fontInfo(font); + + if (fontInfo.family() != font.family()) + QSKIP("Arial font not available."); + + // Smooth and bitmap scaling are mutually exclusive + QVERIFY(QFontDatabase().isSmoothlyScalable(font.family())); + QVERIFY(!QFontDatabase().isBitmapScalable(font.family())); +} + QTEST_MAIN(tst_QFontDatabase) #include "tst_qfontdatabase.moc" -- cgit v1.2.3 From baebb6aa26799e627bc3be6bf41589cef422bed2 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 27 Sep 2016 11:13:49 +0200 Subject: QVariant to QJsonValue::Null conversion Adds a few missing parts of the conversion from QVariant to QJsonValue after the introduction of the nullptr QVariant. The conversion the other way is already implemented. Change-Id: I8b25dec4b476c4761c5098a60944ff11c36f8bec Reviewed-by: Olivier Goffart (Woboq GmbH) --- tests/auto/corelib/json/tst_qtjson.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 1194260efa..17892b44a2 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -1103,6 +1103,7 @@ void tst_QtJson::fromVariant() jsonObject["string"] = stringValue; jsonObject["array"] = jsonArray_variant; + QCOMPARE(QJsonValue::fromVariant(QVariant::fromValue(nullptr)), QJsonValue(QJsonValue::Null)); QCOMPARE(QJsonValue::fromVariant(QVariant(boolValue)), QJsonValue(boolValue)); QCOMPARE(QJsonValue::fromVariant(QVariant(intValue)), QJsonValue(intValue)); QCOMPARE(QJsonValue::fromVariant(QVariant(uintValue)), QJsonValue(static_cast(uintValue))); @@ -1179,7 +1180,7 @@ void tst_QtJson::toVariantMap() array.append(true); array.append(999.); array.append(QLatin1String("string")); - array.append(QJsonValue()); + array.append(QJsonValue::Null); object.insert("Array", array); map = object.toVariantMap(); @@ -1203,12 +1204,12 @@ void tst_QtJson::toVariantHash() QVERIFY(hash.isEmpty()); object.insert("Key", QString("Value")); - object.insert("null", QJsonValue()); + object.insert("null", QJsonValue::Null); QJsonArray array; array.append(true); array.append(999.); array.append(QLatin1String("string")); - array.append(QJsonValue()); + array.append(QJsonValue::Null); object.insert("Array", array); hash = object.toVariantHash(); -- cgit v1.2.3 From 356f5bbac3a66701e958896f8075bbacc90439df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 25 Oct 2016 08:14:21 +0200 Subject: Cocoa: Make child window cursors work correctly The existing cursor logic had a couple of issues: - It made the faulty assumption that we could not use the NSWindow invalidateCursorRectsForView API for child NSViews. - It used NSWindow invalidateCursorRectsForView and NSView resetCursorRects. This API has been replaced by the more general NSTrackingArea API. - It did not implement falling back to the parent window cursor if the current window has no cursor set. Document that QWindow cursors work the same way as QWidget cursors in that a QWindow with no set cursor will fall back to the parent window cursor. Change the cocoa platform code to use NSTrackingArea exclusively and implement NSView cursorUpdate which sets the cursor. Handle immediate change on QWindow:: setCursor() manually. Add QWindow::effectiveWindowCursor() and applyEffectiveWindowCursor() which finds the correct window cursor. Add a manual test for the child window, child widget, and QWidget::createWindowChild cases. Task-number: QTBUG-33479 Task-number: QTBUG-52023 Change-Id: I0370e11bbadb2da95e8632e61be6228ec2cd5e9d Reviewed-by: Timur Pocheptsov --- tests/manual/qcursor/childwidget/childwidget.pro | 6 + tests/manual/qcursor/childwidget/main.cpp | 92 ++++++++++++++ tests/manual/qcursor/childwindow/childwindow.pro | 5 + tests/manual/qcursor/childwindow/main.cpp | 91 ++++++++++++++ .../childwindowcontainer/childwindowcontainer.pro | 6 + tests/manual/qcursor/childwindowcontainer/main.cpp | 138 +++++++++++++++++++++ tests/manual/qcursor/qcursor.pro | 2 +- 7 files changed, 339 insertions(+), 1 deletion(-) create mode 100644 tests/manual/qcursor/childwidget/childwidget.pro create mode 100644 tests/manual/qcursor/childwidget/main.cpp create mode 100644 tests/manual/qcursor/childwindow/childwindow.pro create mode 100644 tests/manual/qcursor/childwindow/main.cpp create mode 100644 tests/manual/qcursor/childwindowcontainer/childwindowcontainer.pro create mode 100644 tests/manual/qcursor/childwindowcontainer/main.cpp (limited to 'tests') diff --git a/tests/manual/qcursor/childwidget/childwidget.pro b/tests/manual/qcursor/childwidget/childwidget.pro new file mode 100644 index 0000000000..9ca41c5b4f --- /dev/null +++ b/tests/manual/qcursor/childwidget/childwidget.pro @@ -0,0 +1,6 @@ +TEMPLATE = app +TARGET = childwidget +INCLUDEPATH += . +QT += widgets + +SOURCES += main.cpp diff --git a/tests/manual/qcursor/childwidget/main.cpp b/tests/manual/qcursor/childwidget/main.cpp new file mode 100644 index 0000000000..4447c87210 --- /dev/null +++ b/tests/manual/qcursor/childwidget/main.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include + +class CursorWidget : public QWidget +{ +public: + CursorWidget(QCursor cursor, QColor color) + :m_cursor(cursor) + ,m_color(color) + { + if (cursor.shape() == Qt::ArrowCursor) + unsetCursor(); + else + setCursor(cursor); + } + + void paintEvent(QPaintEvent *e) + { + QPainter p(this); + p.fillRect(e->rect(), m_color); + } + + void mousePressEvent(QMouseEvent *) + { + // Toggle cursor + QCursor newCursor = (cursor().shape() == m_cursor.shape()) ? QCursor() : m_cursor; + if (newCursor.shape() == Qt::ArrowCursor) + unsetCursor(); + else + setCursor(newCursor); + } + +private: + QCursor m_cursor; + QColor m_color; +}; + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + // Test child widgets (one of which is native) with set cursors. + // Click window to toggle cursor. + + CursorWidget w1((QCursor(Qt::SizeVerCursor)), QColor(Qt::blue).darker()); + w1.resize(200, 200); + w1.show(); + + CursorWidget w2((QCursor(Qt::OpenHandCursor)), QColor(Qt::red).darker()); + w2.setParent(&w1); + w2.setGeometry(0, 0, 100, 100); + w2.show(); + + CursorWidget w3((QCursor(Qt::IBeamCursor)), QColor(Qt::green).darker()); + w3.winId(); + w3.setParent(&w1); + w3.setGeometry(100, 100, 100, 100); + w3.show(); + + return app.exec(); +} diff --git a/tests/manual/qcursor/childwindow/childwindow.pro b/tests/manual/qcursor/childwindow/childwindow.pro new file mode 100644 index 0000000000..194536a91a --- /dev/null +++ b/tests/manual/qcursor/childwindow/childwindow.pro @@ -0,0 +1,5 @@ +TEMPLATE = app +TARGET = childwindow +INCLUDEPATH += . + +SOURCES += main.cpp diff --git a/tests/manual/qcursor/childwindow/main.cpp b/tests/manual/qcursor/childwindow/main.cpp new file mode 100644 index 0000000000..5fc293dfcf --- /dev/null +++ b/tests/manual/qcursor/childwindow/main.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include + +class CursorWindow : public QRasterWindow +{ +public: + CursorWindow(QCursor cursor, QColor color) + :m_cursor(cursor) + ,m_color(color) + { + if (cursor.shape() == Qt::ArrowCursor) + unsetCursor(); + else + setCursor(cursor); + } + + void paintEvent(QPaintEvent *e) + { + QPainter p(this); + p.fillRect(e->rect(), m_color); + } + + void mousePressEvent(QMouseEvent *) + { + // Toggle cursor + QCursor newCursor = (cursor().shape() == m_cursor.shape()) ? QCursor() : m_cursor; + if (newCursor.shape() == Qt::ArrowCursor) + unsetCursor(); + else + setCursor(newCursor); + } + +private: + QCursor m_cursor; + QColor m_color; +}; + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + // Test child windows with set cursors. Create parent window and + // two child windows. Click window to toggle cursor. + + CursorWindow w1((QCursor(Qt::SizeVerCursor)), QColor(Qt::blue).darker()); + w1.resize(200, 200); + w1.show(); + + CursorWindow w2((QCursor(Qt::OpenHandCursor)), QColor(Qt::red).darker()); + w2.setParent(&w1); + w2.setGeometry(0, 0, 100, 100); + w2.show(); + + CursorWindow w3((QCursor(Qt::IBeamCursor)), QColor(Qt::green).darker()); + w3.setParent(&w1); + w3.setGeometry(100, 100, 100, 100); + w3.show(); + + return app.exec(); +} diff --git a/tests/manual/qcursor/childwindowcontainer/childwindowcontainer.pro b/tests/manual/qcursor/childwindowcontainer/childwindowcontainer.pro new file mode 100644 index 0000000000..2233ce4a63 --- /dev/null +++ b/tests/manual/qcursor/childwindowcontainer/childwindowcontainer.pro @@ -0,0 +1,6 @@ +TEMPLATE = app +TARGET = childwindowcontainer +INCLUDEPATH += . +QT += widgets + +SOURCES += main.cpp diff --git a/tests/manual/qcursor/childwindowcontainer/main.cpp b/tests/manual/qcursor/childwindowcontainer/main.cpp new file mode 100644 index 0000000000..d440133a42 --- /dev/null +++ b/tests/manual/qcursor/childwindowcontainer/main.cpp @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include + +class CursorWindow : public QRasterWindow +{ +public: + CursorWindow(QCursor cursor, QColor color) + :m_cursor(cursor) + ,m_color(color) + { + if (cursor.shape() == Qt::ArrowCursor) + unsetCursor(); + else + setCursor(cursor); + } + + void paintEvent(QPaintEvent *e) + { + QPainter p(this); + p.fillRect(e->rect(), m_color); + } + + void mousePressEvent(QMouseEvent *) + { + // Toggle cursor + QCursor newCursor = (cursor().shape() == m_cursor.shape()) ? QCursor() : m_cursor; + if (newCursor.shape() == Qt::ArrowCursor) + unsetCursor(); + else + setCursor(newCursor); + } + +private: + QCursor m_cursor; + QColor m_color; +}; + +class CursorWidget : public QWidget +{ +public: + CursorWidget(QCursor cursor, QColor color) + :m_cursor(cursor) + ,m_color(color) + { + if (cursor.shape() == Qt::ArrowCursor) + unsetCursor(); + else + setCursor(cursor); + } + + void paintEvent(QPaintEvent *e) + { + QPainter p(this); + p.fillRect(e->rect(), m_color); + } + + void mousePressEvent(QMouseEvent *) + { + // Toggle cursor + QCursor newCursor = (cursor().shape() == m_cursor.shape()) ? QCursor() : m_cursor; + if (newCursor.shape() == Qt::ArrowCursor) + unsetCursor(); + else + setCursor(newCursor); + } + +private: + QCursor m_cursor; + QColor m_color; +}; + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + { + // Create top-level windowContainer with window. Setting the cursor + // for the container should set the cursor for the window as well. + // Setting the cursor for the window overrides the cursor for the + // container. The example starts out with a window cursor; click + // to fall back to the container cursor. + CursorWindow *w1 = new CursorWindow(QCursor(Qt::OpenHandCursor), QColor(Qt::red).darker()); + QWidget* container = QWidget::createWindowContainer(w1); + container->resize(200, 200); + container->setCursor(Qt::PointingHandCursor); + container->show(); + } + + { + // Similar to above, but with a top-level QWiget + CursorWidget *w1 = new CursorWidget(QCursor(Qt::IBeamCursor), QColor(Qt::green).darker()); + w1->resize(200, 200); + + CursorWindow *w2 = new CursorWindow(QCursor(Qt::OpenHandCursor), QColor(Qt::red).darker()); + QWidget* container = QWidget::createWindowContainer(w2); + container->winId(); // must make the container native, otherwise setCursor + // sets the cursor on a QWindowContainerClassWindow which + // is outside the QWindow hierarchy (macOS). + container->setParent(w1); + container->setCursor(Qt::PointingHandCursor); + container->setGeometry(0, 0, 100, 100); + + w1->show(); + } + + return app.exec(); +} diff --git a/tests/manual/qcursor/qcursor.pro b/tests/manual/qcursor/qcursor.pro index 0b5c2b1945..c6617b8e89 100644 --- a/tests/manual/qcursor/qcursor.pro +++ b/tests/manual/qcursor/qcursor.pro @@ -1,3 +1,3 @@ TEMPLATE = subdirs -SUBDIRS = allcursors grab_override qcursorhighdpi +SUBDIRS = allcursors childwidget childwindow childwindowcontainer grab_override qcursorhighdpi -- cgit v1.2.3 From ed7f77071dcca996a8c8147fd66344090666e60c Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 5 Aug 2016 10:12:12 +0200 Subject: Replace custom type traits with std one's Remove most type traits from qtypetraits.h, but keep the custom implementation of is_signed/is_unsigned. This gets rid of BSD-3 licensed code from Google in a public header (hugh!). The custom implementations for is_signed/is_unsigned are kept because the implementations in gcc's standard headers do not work as we expect for enums - both is_signed and is_unsigned always returns false there - see also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59027 [ChangeLog][QtCore][General] Qt now relies on type traits from the C++ standard library. Change-Id: I3f2188b46949f04ca4482a6ac9afd3482103f0e1 Reviewed-by: Thiago Macieira --- tests/auto/corelib/global/qglobal/tst_qglobal.cpp | 5 ++--- tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index 9b92a4ff15..ff0497b69e 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -28,7 +28,6 @@ #include -#include #include #include @@ -376,8 +375,8 @@ void tst_QGlobal::isEnum() #define IS_ENUM_TRUE(x) (Q_IS_ENUM(x) == true) #define IS_ENUM_FALSE(x) (Q_IS_ENUM(x) == false) #else -#define IS_ENUM_TRUE(x) (Q_IS_ENUM(x) == true && QtPrivate::is_enum::value == true) -#define IS_ENUM_FALSE(x) (Q_IS_ENUM(x) == false && QtPrivate::is_enum::value == false) +#define IS_ENUM_TRUE(x) (Q_IS_ENUM(x) == true && std::is_enum::value == true) +#define IS_ENUM_FALSE(x) (Q_IS_ENUM(x) == false && std::is_enum::value == false) #endif QVERIFY(IS_ENUM_TRUE(isEnum_B_Byte)); diff --git a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp index 1a70ac5e75..0c890eafbc 100644 --- a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp +++ b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp @@ -29,7 +29,6 @@ #include #include -#include #include #include @@ -197,7 +196,7 @@ void tst_QHashFunctions::range() { // verify that the input iterator category suffices: std::stringstream sstream; - Q_STATIC_ASSERT((QtPrivate::is_same::iterator_category>::value)); + Q_STATIC_ASSERT((std::is_same::iterator_category>::value)); std::copy(ints, ints + numInts, std::ostream_iterator(sstream, " ")); sstream.seekg(0); std::istream_iterator it(sstream), end; -- cgit v1.2.3 From 9de3b15d07dcf1be5ff7b26e2e7987ed8e91a0ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Vr=C3=A1til?= Date: Mon, 7 Nov 2016 09:40:34 +0100 Subject: QLabel: take DPR of QMovie in account when calculating sizeHint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QLabel already does that for QPixmap, so just do the same for QMovie's current pixmap. Task-number: QTBUG-48157 Change-Id: I7b26460f778e56ff017a5efd433f8929f30e4b41 Reviewed-by: Friedemann Kleint Reviewed-by: Morten Johan Sørvig --- tests/auto/widgets/widgets/qlabel/red@2x.png | Bin 0 -> 105 bytes tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp | 24 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/auto/widgets/widgets/qlabel/red@2x.png (limited to 'tests') diff --git a/tests/auto/widgets/widgets/qlabel/red@2x.png b/tests/auto/widgets/widgets/qlabel/red@2x.png new file mode 100644 index 0000000000..4a843e744f Binary files /dev/null and b/tests/auto/widgets/widgets/qlabel/red@2x.png differ diff --git a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp index d76dbf6b46..2b2756fef3 100644 --- a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp +++ b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp @@ -101,6 +101,9 @@ private Q_SLOTS: void taskQTBUG_7902_contextMenuCrash(); #endif + void taskQTBUG_48157_dprPixmap(); + void taskQTBUG_48157_dprMovie(); + private: QLabel *testWidget; QPointer test_box; @@ -546,5 +549,26 @@ void tst_QLabel::taskQTBUG_7902_contextMenuCrash() } #endif +void tst_QLabel::taskQTBUG_48157_dprPixmap() +{ + QLabel label; + QPixmap pixmap; + pixmap.load(QFINDTESTDATA(QStringLiteral("red@2x.png"))); + QCOMPARE(pixmap.devicePixelRatio(), 2.0); + label.setPixmap(pixmap); + QCOMPARE(label.sizeHint(), pixmap.rect().size() / pixmap.devicePixelRatio()); +} + +void tst_QLabel::taskQTBUG_48157_dprMovie() +{ + QLabel label; + QMovie movie; + movie.setFileName(QFINDTESTDATA(QStringLiteral("red@2x.png"))); + movie.start(); + QCOMPARE(movie.currentPixmap().devicePixelRatio(), 2.0); + label.setMovie(&movie); + QCOMPARE(label.sizeHint(), movie.currentPixmap().size() / movie.currentPixmap().devicePixelRatio()); +} + QTEST_MAIN(tst_QLabel) #include "tst_qlabel.moc" -- cgit v1.2.3 From 5c3b16706ff30c38258df0e98e071bf8ae6a1460 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 8 Aug 2016 09:05:53 +0200 Subject: Remove compiler-specific implementations of Q_IS_ENUM Since the macro is now just a wrapper for std::is_enum, its use is also deprecated. [ChangeLog][QtCore][Global] Q_IS_ENUM is deprecated. Use std::is_enum<>::value instead. Change-Id: I09b9f4559c02c81f338cace927873318f2acafde Reviewed-by: Thiago Macieira --- tests/auto/corelib/global/qglobal/tst_qglobal.cpp | 95 ---------------------- .../corelib/kernel/qmetatype/tst_qmetatype.cpp | 2 +- 2 files changed, 1 insertion(+), 96 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index ff0497b69e..bb6ec1c8e7 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -48,7 +48,6 @@ private slots: void qConstructorFunction(); void qCoreAppStartupFunction(); void qCoreAppStartupFunctionRestart(); - void isEnum(); void qAlignOf(); void integerForSize(); void qprintable(); @@ -365,100 +364,6 @@ public: enum AnEnum {}; }; -#if defined (Q_COMPILER_CLASS_ENUM) -enum class isEnum_G : qint64 {}; -#endif - -void tst_QGlobal::isEnum() -{ -#if defined (Q_CC_MSVC) -#define IS_ENUM_TRUE(x) (Q_IS_ENUM(x) == true) -#define IS_ENUM_FALSE(x) (Q_IS_ENUM(x) == false) -#else -#define IS_ENUM_TRUE(x) (Q_IS_ENUM(x) == true && std::is_enum::value == true) -#define IS_ENUM_FALSE(x) (Q_IS_ENUM(x) == false && std::is_enum::value == false) -#endif - - QVERIFY(IS_ENUM_TRUE(isEnum_B_Byte)); - QVERIFY(IS_ENUM_TRUE(const isEnum_B_Byte)); - QVERIFY(IS_ENUM_TRUE(volatile isEnum_B_Byte)); - QVERIFY(IS_ENUM_TRUE(const volatile isEnum_B_Byte)); - - QVERIFY(IS_ENUM_TRUE(isEnum_B_Short)); - QVERIFY(IS_ENUM_TRUE(const isEnum_B_Short)); - QVERIFY(IS_ENUM_TRUE(volatile isEnum_B_Short)); - QVERIFY(IS_ENUM_TRUE(const volatile isEnum_B_Short)); - - QVERIFY(IS_ENUM_TRUE(isEnum_B_Int)); - QVERIFY(IS_ENUM_TRUE(const isEnum_B_Int)); - QVERIFY(IS_ENUM_TRUE(volatile isEnum_B_Int)); - QVERIFY(IS_ENUM_TRUE(const volatile isEnum_B_Int)); - - QVERIFY(IS_ENUM_TRUE(isEnum_F::AnEnum)); - QVERIFY(IS_ENUM_TRUE(const isEnum_F::AnEnum)); - QVERIFY(IS_ENUM_TRUE(volatile isEnum_F::AnEnum)); - QVERIFY(IS_ENUM_TRUE(const volatile isEnum_F::AnEnum)); - - QVERIFY(IS_ENUM_FALSE(void)); - QVERIFY(IS_ENUM_FALSE(isEnum_B_Byte &)); - QVERIFY(IS_ENUM_FALSE(isEnum_B_Byte[1])); - QVERIFY(IS_ENUM_FALSE(const isEnum_B_Byte[1])); - QVERIFY(IS_ENUM_FALSE(isEnum_B_Byte[])); - QVERIFY(IS_ENUM_FALSE(int)); - QVERIFY(IS_ENUM_FALSE(float)); - QVERIFY(IS_ENUM_FALSE(isEnum_A)); - QVERIFY(IS_ENUM_FALSE(isEnum_A *)); - QVERIFY(IS_ENUM_FALSE(const isEnum_A)); - QVERIFY(IS_ENUM_FALSE(isEnum_C)); - QVERIFY(IS_ENUM_FALSE(isEnum_D)); - QVERIFY(IS_ENUM_FALSE(isEnum_E)); - QVERIFY(IS_ENUM_FALSE(void())); - QVERIFY(IS_ENUM_FALSE(void(*)())); - QVERIFY(IS_ENUM_FALSE(int isEnum_A::*)); - QVERIFY(IS_ENUM_FALSE(void (isEnum_A::*)())); - - QVERIFY(IS_ENUM_FALSE(size_t)); - QVERIFY(IS_ENUM_FALSE(bool)); - QVERIFY(IS_ENUM_FALSE(wchar_t)); - - QVERIFY(IS_ENUM_FALSE(char)); - QVERIFY(IS_ENUM_FALSE(unsigned char)); - QVERIFY(IS_ENUM_FALSE(short)); - QVERIFY(IS_ENUM_FALSE(unsigned short)); - QVERIFY(IS_ENUM_FALSE(int)); - QVERIFY(IS_ENUM_FALSE(unsigned int)); - QVERIFY(IS_ENUM_FALSE(long)); - QVERIFY(IS_ENUM_FALSE(unsigned long)); - - QVERIFY(IS_ENUM_FALSE(qint8)); - QVERIFY(IS_ENUM_FALSE(quint8)); - QVERIFY(IS_ENUM_FALSE(qint16)); - QVERIFY(IS_ENUM_FALSE(quint16)); - QVERIFY(IS_ENUM_FALSE(qint32)); - QVERIFY(IS_ENUM_FALSE(quint32)); - QVERIFY(IS_ENUM_FALSE(qint64)); - QVERIFY(IS_ENUM_FALSE(quint64)); - - QVERIFY(IS_ENUM_FALSE(void *)); - QVERIFY(IS_ENUM_FALSE(int *)); - -#if defined (Q_COMPILER_UNICODE_STRINGS) - QVERIFY(IS_ENUM_FALSE(char16_t)); - QVERIFY(IS_ENUM_FALSE(char32_t)); -#endif - -#if defined (Q_COMPILER_CLASS_ENUM) - // Strongly type class enums are not handled by the - // fallback type traits implementation. Any compiler - // supported by Qt that supports C++0x class enums - // should also support the __is_enum intrinsic. - QVERIFY(Q_IS_ENUM(isEnum_G)); -#endif - -#undef IS_ENUM_TRUE -#undef IS_ENUM_FALSE -} - struct Empty {}; template struct AlignmentInStruct { T dummy; }; diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index caceda86be..7d9f56ef38 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -712,7 +712,7 @@ void tst_QMetaType::flags_data() << bool(!QTypeInfo::isStatic) \ << bool(QTypeInfo::isComplex) \ << bool(QtPrivate::IsPointerToTypeDerivedFromQObject::Value) \ - << bool(Q_IS_ENUM(RealType)); + << bool(std::is_enum::value); QT_FOR_EACH_STATIC_CORE_CLASS(ADD_METATYPE_TEST_ROW) QT_FOR_EACH_STATIC_PRIMITIVE_POINTER(ADD_METATYPE_TEST_ROW) QT_FOR_EACH_STATIC_CORE_POINTER(ADD_METATYPE_TEST_ROW) -- cgit v1.2.3 From 615270a3008cfc1314a3c983b7e69006dc4184b4 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 8 Aug 2016 09:41:57 +0200 Subject: Rename QtPrivate::is_[un]signed to QtPrivate::Is[Un]signedEnum Any other use than for enums should use std::is_[un]signed. Make this explicit by renaming the type traits. Change-Id: I494158563c95c710e710d0d337f4e547006df171 Reviewed-by: Thiago Macieira --- tests/auto/corelib/global/qflags/tst_qflags.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp index 10902b6f55..634d9a2df3 100644 --- a/tests/auto/corelib/global/qflags/tst_qflags.cpp +++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp @@ -134,11 +134,11 @@ void tst_QFlags::signedness() // underlying type is implementation-defined, we need to allow for // a different signedness, so we only check that the relative // signedness of the types matches: - Q_STATIC_ASSERT((QtPrivate::is_unsigned::value == - QtPrivate::is_unsigned::value)); + Q_STATIC_ASSERT((QtPrivate::QIsUnsignedEnum::value == + QtPrivate::QIsUnsignedEnum::value)); - Q_STATIC_ASSERT((QtPrivate::is_signed::value == - QtPrivate::is_signed::value)); + Q_STATIC_ASSERT((QtPrivate::QIsSignedEnum::value == + QtPrivate::QIsSignedEnum::value)); } #if defined(Q_COMPILER_CLASS_ENUM) -- cgit v1.2.3 From 15414257b3719f2c302cca26efe40f2b3caa115b Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 4 Nov 2016 15:52:32 +0100 Subject: Don't count no-break spaces as trailing spaces No-break-spaces should not be counted in the space data, but rather be treated as any other non-breakable character. We were already taking care of this in the loop we reach if the item starts with a character which isn't whitespace, but there is a second loop for items that begin with whitespace characters. The result of this was that in certain circumstances where you gave the nbsp its own format and made the line wrap, the previous line would count an extra trailing space and it would swallow the first character in its following line. [ChangeLog][QtGui][Text] Fixed a bug where a no-break space would sometimes cause the first character of the containing line to not be displayed. Task-number: QTBUG-56714 Change-Id: Idd760a389052e6de70f6cc397122b217987fa5f2 Reviewed-by: Lars Knoll --- .../auto/gui/text/qtextlayout/tst_qtextlayout.cpp | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'tests') diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp index 84d58191c0..22a4276b8e 100644 --- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp @@ -142,6 +142,7 @@ private slots: void xToCursorForLigatures(); void cursorInNonStopChars(); void nbsp(); + void nbspWithFormat(); void noModificationOfInputString(); void superscriptCrash_qtbug53911(); @@ -2266,5 +2267,41 @@ void tst_QTextLayout::superscriptCrash_qtbug53911() qDeleteAll(textLayouts); } +void tst_QTextLayout::nbspWithFormat() +{ + QString s1 = QLatin1String("ABCDEF "); + QString s2 = QLatin1String("GHI"); + QChar nbsp(QChar::Nbsp); + QString s3 = QLatin1String("JKLMNOPQRSTUVWXYZ"); + + QTextLayout layout; + layout.setText(s1 + s2 + nbsp + s3); + + QTextLayout::FormatRange formatRange; + formatRange.start = s1.length() + s2.length(); + formatRange.length = 1; + formatRange.format.setFontUnderline(true); + + QList overrides; + overrides.append(formatRange); + + layout.setAdditionalFormats(overrides); + + layout.beginLayout(); + forever { + QTextLine line = layout.createLine(); + if (!line.isValid()) + break; + line.setLineWidth(1); + } + layout.endLayout(); + + QCOMPARE(layout.lineCount(), 2); + QCOMPARE(layout.lineAt(0).textStart(), 0); + QCOMPARE(layout.lineAt(0).textLength(), s1.length()); + QCOMPARE(layout.lineAt(1).textStart(), s1.length()); + QCOMPARE(layout.lineAt(1).textLength(), s2.length() + 1 + s3.length()); +} + QTEST_MAIN(tst_QTextLayout) #include "tst_qtextlayout.moc" -- cgit v1.2.3 From 5cff7d2b679d48a247b4630cb9e3d5b04fab0b55 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 31 Oct 2016 11:54:51 -0700 Subject: QComboBox: Prioritize the model font for popup items MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Mac, we use QComboMenuDelegate specifically as item delegate for the popup list. It happens that the order of resolving the font for each item individually would prioritize QComboBox's font instead of whatever the assigned model's FontRole would specify. The fix only requires checking whether FontRole is valid before falling back QComboBox's properties. Change-Id: I7208ad1911b30cc52c826c1884a1e19f5acd9fb4 Task-number: QTBUG-56693 Reviewed-by: Morten Johan Sørvig --- .../widgets/widgets/qcombobox/tst_qcombobox.cpp | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 816fe1faba..edaf033678 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -62,6 +62,7 @@ #include #include #include +#include static inline void setFrameless(QWidget *w) { @@ -160,6 +161,7 @@ private slots: void respectChangedOwnershipOfItemView(); void task_QTBUG_39088_inputMethodHints(); void task_QTBUG_49831_scrollerNotActivated(); + void task_QTBUG_56693_itemFontFromModel(); }; class MyAbstractItemDelegate : public QAbstractItemDelegate @@ -3250,5 +3252,77 @@ void tst_QComboBox::task_QTBUG_49831_scrollerNotActivated() } } +class QTBUG_56693_Model : public QStandardItemModel +{ +public: + QTBUG_56693_Model(QObject *parent = Q_NULLPTR) + : QStandardItemModel(parent) + { } + + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override + { + if (role == Qt::FontRole) { + if (index.row() < 5) { + QFont font = QApplication::font(); + font.setItalic(true); + return font; + } else { + return QApplication::font(); + } + } + return QStandardItemModel::data(index, role); + } +}; + +class QTBUG_56693_ProxyStyle : public QProxyStyle +{ +public: + QTBUG_56693_ProxyStyle(QStyle *style) + : QProxyStyle(style), italicItemsNo(0) + { + + } + + void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w = Q_NULLPTR) const override + { + if (element == CE_MenuItem) + if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast(opt)) + if (menuItem->font.italic()) + italicItemsNo++; + + baseStyle()->drawControl(element, opt, p, w); + } + + mutable int italicItemsNo; +}; + +void tst_QComboBox::task_QTBUG_56693_itemFontFromModel() +{ + QComboBox box; + if (!qobject_cast(box.itemDelegate())) + QSKIP("Only for combo boxes using QComboMenuDelegate"); + + QTBUG_56693_Model model; + box.setModel(&model); + + QTBUG_56693_ProxyStyle *proxyStyle = new QTBUG_56693_ProxyStyle(box.style()); + box.setStyle(proxyStyle); + box.setFont(QApplication::font()); + + for (int i = 0; i < 10; i++) + box.addItem(QLatin1String("Item ") + QString::number(i)); + + box.show(); + QTest::qWaitForWindowExposed(&box); + box.showPopup(); + QFrame *container = box.findChild(); + QVERIFY(container); + QTest::qWaitForWindowExposed(container); + + QCOMPARE(proxyStyle->italicItemsNo, 5); + + box.hidePopup(); +} + QTEST_MAIN(tst_QComboBox) #include "tst_qcombobox.moc" -- cgit v1.2.3 From bfaa8925d5cc0a59cec3f747a8d982ca819f026b Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 2 Nov 2016 14:10:47 +0100 Subject: Improve the validation algorithm for binary JSON Add better boundary checks and catch (hopefully all) cases where invalid binary JSON could cause crashes. Change-Id: I206510b7c5e3ba953802a5f46645878e65704ecc Reviewed-by: Edward Welbourne --- tests/auto/corelib/json/invalidBinaryData/10.bjson | Bin 0 -> 544 bytes tests/auto/corelib/json/invalidBinaryData/11.bjson | Bin 0 -> 542 bytes tests/auto/corelib/json/invalidBinaryData/12.bjson | Bin 0 -> 506 bytes tests/auto/corelib/json/invalidBinaryData/13.bjson | Bin 0 -> 544 bytes tests/auto/corelib/json/invalidBinaryData/14.bjson | Bin 0 -> 521 bytes tests/auto/corelib/json/invalidBinaryData/15.bjson | Bin 0 -> 536 bytes tests/auto/corelib/json/invalidBinaryData/16.bjson | Bin 0 -> 874 bytes tests/auto/corelib/json/invalidBinaryData/17.bjson | Bin 0 -> 49 bytes tests/auto/corelib/json/invalidBinaryData/18.bjson | Bin 0 -> 524 bytes tests/auto/corelib/json/invalidBinaryData/19.bjson | Bin 0 -> 524 bytes tests/auto/corelib/json/invalidBinaryData/20.bjson | Bin 0 -> 524 bytes tests/auto/corelib/json/invalidBinaryData/21.bjson | Bin 0 -> 552 bytes tests/auto/corelib/json/invalidBinaryData/22.bjson | Bin 0 -> 524 bytes tests/auto/corelib/json/invalidBinaryData/23.bjson | Bin 0 -> 533 bytes tests/auto/corelib/json/invalidBinaryData/24.bjson | Bin 0 -> 506 bytes tests/auto/corelib/json/invalidBinaryData/25.bjson | Bin 0 -> 542 bytes tests/auto/corelib/json/invalidBinaryData/26.bjson | Bin 0 -> 628 bytes tests/auto/corelib/json/invalidBinaryData/27.bjson | Bin 0 -> 51 bytes tests/auto/corelib/json/invalidBinaryData/28.bjson | Bin 0 -> 542 bytes tests/auto/corelib/json/invalidBinaryData/29.bjson | Bin 0 -> 544 bytes tests/auto/corelib/json/invalidBinaryData/30.bjson | Bin 0 -> 542 bytes tests/auto/corelib/json/invalidBinaryData/31.bjson | Bin 0 -> 553 bytes tests/auto/corelib/json/invalidBinaryData/32.bjson | Bin 0 -> 536 bytes tests/auto/corelib/json/invalidBinaryData/33.bjson | Bin 0 -> 544 bytes tests/auto/corelib/json/invalidBinaryData/34.bjson | Bin 0 -> 524 bytes tests/auto/corelib/json/invalidBinaryData/35.bjson | Bin 0 -> 524 bytes tests/auto/corelib/json/invalidBinaryData/36.bjson | Bin 0 -> 524 bytes tests/auto/corelib/json/invalidBinaryData/37.bjson | Bin 0 -> 536 bytes tests/auto/corelib/json/tst_qtjson.cpp | 16 ++++++++++++++++ 29 files changed, 16 insertions(+) create mode 100644 tests/auto/corelib/json/invalidBinaryData/10.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/11.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/12.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/13.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/14.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/15.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/16.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/17.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/18.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/19.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/20.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/21.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/22.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/23.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/24.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/25.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/26.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/27.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/28.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/29.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/30.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/31.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/32.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/33.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/34.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/35.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/36.bjson create mode 100644 tests/auto/corelib/json/invalidBinaryData/37.bjson (limited to 'tests') diff --git a/tests/auto/corelib/json/invalidBinaryData/10.bjson b/tests/auto/corelib/json/invalidBinaryData/10.bjson new file mode 100644 index 0000000000..12b29b7aa5 Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/10.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/11.bjson b/tests/auto/corelib/json/invalidBinaryData/11.bjson new file mode 100644 index 0000000000..cf2b612111 Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/11.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/12.bjson b/tests/auto/corelib/json/invalidBinaryData/12.bjson new file mode 100644 index 0000000000..9c2403350e Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/12.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/13.bjson b/tests/auto/corelib/json/invalidBinaryData/13.bjson new file mode 100644 index 0000000000..db6308b1fd Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/13.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/14.bjson b/tests/auto/corelib/json/invalidBinaryData/14.bjson new file mode 100644 index 0000000000..347da4572c Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/14.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/15.bjson b/tests/auto/corelib/json/invalidBinaryData/15.bjson new file mode 100644 index 0000000000..c6c5558934 Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/15.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/16.bjson b/tests/auto/corelib/json/invalidBinaryData/16.bjson new file mode 100644 index 0000000000..ae8b57446d Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/16.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/17.bjson b/tests/auto/corelib/json/invalidBinaryData/17.bjson new file mode 100644 index 0000000000..32f0cc0e23 Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/17.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/18.bjson b/tests/auto/corelib/json/invalidBinaryData/18.bjson new file mode 100644 index 0000000000..50c89169eb Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/18.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/19.bjson b/tests/auto/corelib/json/invalidBinaryData/19.bjson new file mode 100644 index 0000000000..b922212f45 Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/19.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/20.bjson b/tests/auto/corelib/json/invalidBinaryData/20.bjson new file mode 100644 index 0000000000..c965a0d294 Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/20.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/21.bjson b/tests/auto/corelib/json/invalidBinaryData/21.bjson new file mode 100644 index 0000000000..98165ee40c Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/21.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/22.bjson b/tests/auto/corelib/json/invalidBinaryData/22.bjson new file mode 100644 index 0000000000..151f773a81 Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/22.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/23.bjson b/tests/auto/corelib/json/invalidBinaryData/23.bjson new file mode 100644 index 0000000000..6eb5269470 Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/23.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/24.bjson b/tests/auto/corelib/json/invalidBinaryData/24.bjson new file mode 100644 index 0000000000..c55a2a3e3b Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/24.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/25.bjson b/tests/auto/corelib/json/invalidBinaryData/25.bjson new file mode 100644 index 0000000000..6c619f2ae1 Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/25.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/26.bjson b/tests/auto/corelib/json/invalidBinaryData/26.bjson new file mode 100644 index 0000000000..3bf303215a Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/26.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/27.bjson b/tests/auto/corelib/json/invalidBinaryData/27.bjson new file mode 100644 index 0000000000..d2656c2287 Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/27.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/28.bjson b/tests/auto/corelib/json/invalidBinaryData/28.bjson new file mode 100644 index 0000000000..6797cf8c40 Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/28.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/29.bjson b/tests/auto/corelib/json/invalidBinaryData/29.bjson new file mode 100644 index 0000000000..0645dfc3b2 Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/29.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/30.bjson b/tests/auto/corelib/json/invalidBinaryData/30.bjson new file mode 100644 index 0000000000..f77fe1efd0 Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/30.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/31.bjson b/tests/auto/corelib/json/invalidBinaryData/31.bjson new file mode 100644 index 0000000000..d9840b6582 Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/31.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/32.bjson b/tests/auto/corelib/json/invalidBinaryData/32.bjson new file mode 100644 index 0000000000..1de4cb829f Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/32.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/33.bjson b/tests/auto/corelib/json/invalidBinaryData/33.bjson new file mode 100644 index 0000000000..532a31dc08 Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/33.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/34.bjson b/tests/auto/corelib/json/invalidBinaryData/34.bjson new file mode 100644 index 0000000000..f498558eff Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/34.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/35.bjson b/tests/auto/corelib/json/invalidBinaryData/35.bjson new file mode 100644 index 0000000000..8701210755 Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/35.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/36.bjson b/tests/auto/corelib/json/invalidBinaryData/36.bjson new file mode 100644 index 0000000000..ef5864e911 Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/36.bjson differ diff --git a/tests/auto/corelib/json/invalidBinaryData/37.bjson b/tests/auto/corelib/json/invalidBinaryData/37.bjson new file mode 100644 index 0000000000..f4dd4ae12f Binary files /dev/null and b/tests/auto/corelib/json/invalidBinaryData/37.bjson differ diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 1665ff696d..f2f9166711 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -103,6 +103,7 @@ private Q_SLOTS: void fromBinary(); void toAndFromBinary_data(); void toAndFromBinary(); + void invalidBinaryData(); void parseNumbers(); void parseStrings(); void parseDuplicateKeys(); @@ -1779,6 +1780,21 @@ void tst_QtJson::toAndFromBinary() QVERIFY(doc == outdoc); } +void tst_QtJson::invalidBinaryData() +{ + QDir dir(testDataDir + "/invalidBinaryData"); + QFileInfoList files = dir.entryInfoList(); + for (int i = 0; i < files.size(); ++i) { + if (!files.at(i).isFile()) + continue; + QFile file(files.at(i).filePath()); + file.open(QIODevice::ReadOnly); + QByteArray bytes = file.readAll(); + QJsonDocument document = QJsonDocument::fromRawData(bytes.constData(), bytes.size()); + QVERIFY(document.isNull()); + } +} + void tst_QtJson::parseNumbers() { { -- cgit v1.2.3 From dffde23a0ae28f05ef2aa9af138f0a82bbfce942 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Wed, 9 Nov 2016 10:32:54 +0100 Subject: Fix writing into application directory Tests are not supposed to write into the build/application directory, but rather should output to the temp directory. Change-Id: Idcdf51226a2d547514aea2fbb2054998d8a3437e Reviewed-by: Friedemann Kleint --- tests/auto/gui/image/qpixmap/tst_qpixmap.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp index 286f00c111..73da5804eb 100644 --- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp @@ -171,6 +171,7 @@ private: const QString m_prefix; const QString m_convertFromImage; const QString m_loadFromData; + const QTemporaryDir m_tempDir; }; static bool lenientCompare(const QPixmap &actual, const QPixmap &expected) @@ -230,11 +231,11 @@ void tst_QPixmap::initTestCase() QVERIFY(!m_prefix.isEmpty()); QVERIFY(!m_convertFromImage.isEmpty()); QVERIFY(!m_loadFromData.isEmpty()); + QVERIFY2(m_tempDir.isValid(), qPrintable(m_tempDir.errorString())); } void tst_QPixmap::cleanupTestCase() { - QFile::remove(QLatin1String("temp_image.png")); } void tst_QPixmap::swap() @@ -1471,18 +1472,18 @@ void tst_QPixmap::preserveDepth() void tst_QPixmap::loadAsBitmapOrPixmap() { QImage tmp(10, 10, QImage::Format_RGB32); - tmp.save("temp_image.png"); + tmp.save(m_tempDir.path() + "/temp_image.png"); bool ok; // Check that we can load the pixmap as a pixmap and that it then turns into a pixmap - QPixmap pixmap("temp_image.png"); + QPixmap pixmap(m_tempDir.path() + "/temp_image.png"); QVERIFY(!pixmap.isNull()); QVERIFY(pixmap.depth() > 1); QVERIFY(!pixmap.isQBitmap()); pixmap = QPixmap(); - ok = pixmap.load("temp_image.png"); + ok = pixmap.load(m_tempDir.path() + "/temp_image.png"); QVERIFY(ok); QVERIFY(!pixmap.isNull()); QVERIFY(pixmap.depth() > 1); @@ -1490,20 +1491,20 @@ void tst_QPixmap::loadAsBitmapOrPixmap() //now we can try to load it without an extension pixmap = QPixmap(); - ok = pixmap.load("temp_image"); + ok = pixmap.load(m_tempDir.path() + "/temp_image"); QVERIFY(ok); QVERIFY(!pixmap.isNull()); QVERIFY(pixmap.depth() > 1); QVERIFY(!pixmap.isQBitmap()); // The do the same check for bitmaps.. - QBitmap bitmap("temp_image.png"); + QBitmap bitmap(m_tempDir.path() + "/temp_image.png"); QVERIFY(!bitmap.isNull()); QCOMPARE(bitmap.depth(), 1); QVERIFY(bitmap.isQBitmap()); bitmap = QBitmap(); - ok = bitmap.load("temp_image.png"); + ok = bitmap.load(m_tempDir.path() + "/temp_image.png"); QVERIFY(ok); QVERIFY(!bitmap.isNull()); QCOMPARE(bitmap.depth(), 1); -- cgit v1.2.3 From 8db556d29919fd0c0ddb23b743cb5e6c218b1ae2 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 9 Nov 2016 13:11:31 +0100 Subject: fix $$section()'s bad argument count error message the autotest was also broken, because it was created by pasting the bogus message into the result ... Change-Id: I02b8663b96c7d96cdb3c19639e2213e49fd2bcec Reviewed-by: Joerg Bornemann --- tests/auto/tools/qmakelib/evaltest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/tools/qmakelib/evaltest.cpp b/tests/auto/tools/qmakelib/evaltest.cpp index 09482d86d9..3c96c6fb7a 100644 --- a/tests/auto/tools/qmakelib/evaltest.cpp +++ b/tests/auto/tools/qmakelib/evaltest.cpp @@ -1125,8 +1125,8 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir) QTest::newRow("$$section(): bad number of arguments") << "VAR = $$section(1, 2) \\\n$$section(1, 2, 3, 4, 5)" << "VAR =" - << "##:1: section(var) section(var, sep, begin, end) requires three or four arguments.\n" - "##:2: section(var) section(var, sep, begin, end) requires three or four arguments." + << "##:1: section(var, sep, begin, end) requires three or four arguments.\n" + "##:2: section(var, sep, begin, end) requires three or four arguments." << true; QTest::newRow("$$find()") -- cgit v1.2.3 From d91bf00c43736940e4139357e288df6432775a3d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 8 Jun 2016 12:06:29 +0200 Subject: tst_QFileSystemModel::specialFiles(): Remove Windows parts The test created a Windows shortcut (.lnk) and checked on its existence. It was not found in the first test since QFileSystemModel returned the resolved file name (linktarget.txt). When fixing this by querying QFileSystemModel::fileInfo()::fileName(), the 2nd test failed since shortcut files are not considered system files. Amends change 3b093034b638a69b4dc91212d1743638864a1337. Task-number: QTBUG-53890 Task-number: QTBUG-20968 Task-number: QTBUG-29403 Change-Id: Iec58b52532b44d12759eaa6c8d63a8a4dc8d1bc3 Reviewed-by: Joerg Bornemann --- .../dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp index af92f0735d..cb0f0b040a 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -1097,6 +1097,10 @@ static QSet fileListUnderIndex(const QFileSystemModel *model, const QMo void tst_QFileSystemModel::specialFiles() { +#ifndef Q_OS_UNIX + QSKIP("Not implemented"); +#endif + QFileSystemModel model; model.setFilter(QDir::AllEntries | QDir::System | QDir::Hidden); @@ -1105,23 +1109,8 @@ void tst_QFileSystemModel::specialFiles() // as it will always return a valid index for existing files, // even if the file is not visible with the given filter. -#if defined(Q_OS_UNIX) const QModelIndex rootIndex = model.setRootPath(QStringLiteral("/dev/")); const QString testFileName = QStringLiteral("null"); -#elif defined(Q_OS_WIN) - const QModelIndex rootIndex = model.setRootPath(flatDirTestPath); - - const QString testFileName = QStringLiteral("linkSource.lnk"); - - QFile file(flatDirTestPath + QLatin1String("/linkTarget.txt")); - QVERIFY(file.open(QIODevice::WriteOnly)); - file.close(); - QVERIFY(file.link(flatDirTestPath + '/' + testFileName)); -#else - QSKIP("Not implemented"); - QModelIndex rootIndex; - QString testFileName; -#endif QTRY_VERIFY(fileListUnderIndex(&model, rootIndex).contains(testFileName)); -- cgit v1.2.3 From 94f9ee79a65636f1bf96671ad11641b1f6c7421a Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 11 Nov 2016 09:13:53 +0100 Subject: Clean up some conditions in our pro files Change qtConfig(opengl(es2)?) to qtConfig(opengl) as that covers the case without any regular expression. Change-Id: I935e3150f87e195e8bd3d0e55b4ed43572b131cf Reviewed-by: Oswald Buddenhagen --- tests/auto/gui/gui.pro | 2 +- tests/auto/gui/kernel/kernel.pro | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/gui/gui.pro b/tests/auto/gui/gui.pro index 8d8a2df393..2fd3024afe 100644 --- a/tests/auto/gui/gui.pro +++ b/tests/auto/gui/gui.pro @@ -13,4 +13,4 @@ SUBDIRS = \ util \ itemmodels \ -!qtConfig(opengl(es2)?): SUBDIRS -= qopengl qopenglconfig +!qtConfig(opengl): SUBDIRS -= qopengl qopenglconfig diff --git a/tests/auto/gui/kernel/kernel.pro b/tests/auto/gui/kernel/kernel.pro index 631962ad34..559395a9ae 100644 --- a/tests/auto/gui/kernel/kernel.pro +++ b/tests/auto/gui/kernel/kernel.pro @@ -34,6 +34,6 @@ win32:!winrt:qtHaveModule(network): SUBDIRS += noqteventloop !qtHaveModule(network): SUBDIRS -= \ qguieventloop -!qtConfig(opengl(es2)?): SUBDIRS -= qopenglwindow +!qtConfig(opengl): SUBDIRS -= qopenglwindow uikit: SUBDIRS -= qclipboard -- cgit v1.2.3 From e133f0cca44181005f19d006d6c896abe59c1b33 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 11 Nov 2016 17:06:19 +0100 Subject: Improve error offset in JSON parsing Do not consume white-space after a token before the token has been parsed, otherwise we end up with misleading offsets. This also fixes a wrong error of illegal number in several cases. Change-Id: I492ca4de0346a1d0ab73b1c23d7a72dba812664c Reviewed-by: Lars Knoll Reviewed-by: Oswald Buddenhagen --- tests/auto/corelib/json/tst_qtjson.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 17892b44a2..4a6584a0f6 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -139,6 +139,9 @@ private Q_SLOTS: void removeNonLatinKey(); void documentFromVariant(); + void parseErrorOffset_data(); + void parseErrorOffset(); + private: QString testDataDir; }; @@ -2830,5 +2833,35 @@ void tst_QtJson::documentFromVariant() QCOMPARE(do1.object(), do2.object()); } +void tst_QtJson::parseErrorOffset_data() +{ + QTest::addColumn("json"); + QTest::addColumn("errorOffset"); + + QTest::newRow("Trailing comma in object") << QByteArray("{ \"value\": false, }") << 19; + QTest::newRow("Trailing comma in object plus whitespace") << QByteArray("{ \"value\": false, } ") << 19; + QTest::newRow("Trailing comma in array") << QByteArray("[ false, ]") << 10; + QTest::newRow("Trailing comma in array plus whitespace") << QByteArray("[ false, ] ") << 10; + QTest::newRow("Missing value in object") << QByteArray("{ \"value\": , } ") << 12; + QTest::newRow("Missing value in array") << QByteArray("[ \"value\" , , ] ") << 13; + QTest::newRow("Leading comma in object") << QByteArray("{ , \"value\": false}") << 3; + QTest::newRow("Leading comma in array") << QByteArray("[ , false]") << 3; + QTest::newRow("Stray ,") << QByteArray(" , ") << 3; + QTest::newRow("Stray [") << QByteArray(" [ ") << 5; + QTest::newRow("Stray }") << QByteArray(" } ") << 3; +} + +void tst_QtJson::parseErrorOffset() +{ + QFETCH(QByteArray, json); + QFETCH(int, errorOffset); + + QJsonParseError error; + QJsonDocument::fromJson(json, &error); + + QVERIFY(error.error != QJsonParseError::NoError); + QCOMPARE(error.offset, errorOffset); +} + QTEST_MAIN(tst_QtJson) #include "tst_qtjson.moc" -- cgit v1.2.3 From 887e260a9370dfd8061754ed47cda7d9e4621711 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 11 Nov 2016 15:22:45 +0100 Subject: Improve QMake JSON error We can not improve the result from JSON parsing without changing API, so instead recalculate the line and column based on input and offset. Change-Id: I54149233f71023aa5d30deff854d6f3406c5c48c Reviewed-by: Oswald Buddenhagen --- tests/auto/tools/qmakelib/evaltest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/tools/qmakelib/evaltest.cpp b/tests/auto/tools/qmakelib/evaltest.cpp index 62fcedddb9..01214b3d38 100644 --- a/tests/auto/tools/qmakelib/evaltest.cpp +++ b/tests/auto/tools/qmakelib/evaltest.cpp @@ -2259,7 +2259,7 @@ void tst_qmakelib::addTestFunctions(const QString &qindir) << "jsontext = not good\n" "parseJson(jsontext, json): OK = 1" << "OK = UNDEF" - << "##:2: Error parsing json at offset 1: illegal value" + << "##:2: Error parsing JSON at 1:1: illegal value" << true; QTest::newRow("parseJson(): bad number of arguments") -- cgit v1.2.3 From 965e861e61ec56c91216d483987d33fb5a508b85 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 11 Nov 2016 20:01:53 +0100 Subject: qmake: let discard_from() discard function definitions as well for completeness. Change-Id: I3ffc14e041408c773e277442828170e3df04ec8d Reviewed-by: Lars Knoll --- tests/auto/tools/qmakelib/evaltest.cpp | 10 ++++++++-- tests/auto/tools/qmakelib/testdata/include/inc.pri | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/tools/qmakelib/evaltest.cpp b/tests/auto/tools/qmakelib/evaltest.cpp index 01214b3d38..614568ee53 100644 --- a/tests/auto/tools/qmakelib/evaltest.cpp +++ b/tests/auto/tools/qmakelib/evaltest.cpp @@ -2326,8 +2326,14 @@ void tst_qmakelib::addTestFunctions(const QString &qindir) << true; QTest::newRow("discard_from()") - << "HERE = 1\nPLUS = one\ninclude(include/inc.pri)\ndiscard_from(include/inc.pri): OK = 1" - << "OK = 1\nHERE = 1\nPLUS = one\nVAR = UNDEF" + << "HERE = 1\nPLUS = one\n" + "defineTest(tfunc) {}\ndefineReplace(rfunc) {}\n" + "include(include/inc.pri)\n" + "discard_from(include/inc.pri): OK = 1\n" + "defined(tfunc, test): TDEF = 1\ndefined(rfunc, replace): RDEF = 1\n" + "defined(func, test): DTDEF = 1\ndefined(func, replace): DRDEF = 1\n" + << "OK = 1\nHERE = 1\nPLUS = one\nVAR = UNDEF\n" + "TDEF = 1\nRDEF = 1\nDTDEF = UNDEF\nDRDEF = UNDEF" << "" << true; diff --git a/tests/auto/tools/qmakelib/testdata/include/inc.pri b/tests/auto/tools/qmakelib/testdata/include/inc.pri index f9a4ec1bfa..5c570f49e5 100644 --- a/tests/auto/tools/qmakelib/testdata/include/inc.pri +++ b/tests/auto/tools/qmakelib/testdata/include/inc.pri @@ -8,3 +8,7 @@ fake-*: MATCH = 1 defineTest(func) { message("say hi!") } + +defineReplace(func) { + return("say hi!") +} -- cgit v1.2.3 From c05f0a83fdb4823604d76f61bb884e206887e704 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 11 Nov 2016 14:45:48 +0100 Subject: qmake: make discard_from() patch up QMAKE_INTERNAL_INCLUDED_FILES as well when the file's effects are discarded, the mention of the file should be as well. Change-Id: I894b7e2b887dd34d18533b197bfa9d0d84d647e7 Reviewed-by: Lars Knoll --- tests/auto/tools/qmakelib/evaltest.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/tools/qmakelib/evaltest.cpp b/tests/auto/tools/qmakelib/evaltest.cpp index 614568ee53..44c82fb376 100644 --- a/tests/auto/tools/qmakelib/evaltest.cpp +++ b/tests/auto/tools/qmakelib/evaltest.cpp @@ -2329,10 +2329,12 @@ void tst_qmakelib::addTestFunctions(const QString &qindir) << "HERE = 1\nPLUS = one\n" "defineTest(tfunc) {}\ndefineReplace(rfunc) {}\n" "include(include/inc.pri)\n" + "contains(QMAKE_INTERNAL_INCLUDED_FILES, .*/include/inc\\\\.pri): PRE = 1\n" "discard_from(include/inc.pri): OK = 1\n" + "!contains(QMAKE_INTERNAL_INCLUDED_FILES, .*/include/inc\\\\.pri): POST = 1\n" "defined(tfunc, test): TDEF = 1\ndefined(rfunc, replace): RDEF = 1\n" "defined(func, test): DTDEF = 1\ndefined(func, replace): DRDEF = 1\n" - << "OK = 1\nHERE = 1\nPLUS = one\nVAR = UNDEF\n" + << "PRE = 1\nPOST = 1\nOK = 1\nHERE = 1\nPLUS = one\nVAR = UNDEF\n" "TDEF = 1\nRDEF = 1\nDTDEF = UNDEF\nDRDEF = UNDEF" << "" << true; -- cgit v1.2.3 From e8a41ed8668437eb6ad406ddabf4141fd66a85d2 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 2 Nov 2016 17:37:43 -0700 Subject: QCocoaMenu: Force NSMenuValidation when syncing items When a menu item's enabled state changes after -[QCocoaMenuDelegate menuWillOpen:] is invoked, i.e., during or after QMenu::aboutToShow() is emitted, that state change may not be taken into account. This is because the automatic menu validation, upon which Qt relies, is not made aware of any such change. By calling -[NSMenu update] when syncing the QPA menu item, we induce Cocoa to invoke -[QCocoaMenuDelegate validateMenuItem:] and ensure that previously synced items, whose state may have changed, will be properly updated. This, however, has a small side effect, namely that menu-holding items will also go through the automatic menu enabling path and may appear disabled since, until now, they were not properly configured. In order to solve this, we set the action on those items as well, and make sure that both of QCocoaMenuDelegate's relevant methods, validateMenuItem: and itemFired:, properly process menu-holding items. Menurama manual test updated accordingly. Change-Id: I62f955538b8be09b8494ea0ce87fca7910148d38 Task-number: QTBUG-56850 Reviewed-by: Timur Pocheptsov --- tests/manual/cocoa/menurama/mainwindow.cpp | 8 +- tests/manual/cocoa/menurama/mainwindow.ui | 98 ++++++++++++---------- .../manual/cocoa/menurama/menuramaapplication.cpp | 16 ++-- tests/manual/cocoa/menurama/menuramaapplication.h | 1 + 4 files changed, 72 insertions(+), 51 deletions(-) (limited to 'tests') diff --git a/tests/manual/cocoa/menurama/mainwindow.cpp b/tests/manual/cocoa/menurama/mainwindow.cpp index db8fdafc21..f7762f57f5 100644 --- a/tests/manual/cocoa/menurama/mainwindow.cpp +++ b/tests/manual/cocoa/menurama/mainwindow.cpp @@ -56,7 +56,13 @@ MainWindow::MainWindow(QWidget *parent) : }); connect(ui->menuDynamic_Stuff, &QMenu::aboutToShow, [=] { - menuApp->addDynMenu(QLatin1String("Added After aboutToShow()"), ui->menuDynamic_Stuff); + menuApp->addDynMenu(QLatin1String("Menu Added After aboutToShow()"), ui->menuDynamic_Stuff); + + const QLatin1String itemTitle = QLatin1String("Disabled Item Added After aboutToShow()"); + if (QAction *a = menuApp->findAction(itemTitle, ui->menuDynamic_Stuff)) + ui->menuDynamic_Stuff->removeAction(a); + QAction *a = ui->menuDynamic_Stuff->addAction(itemTitle); + a->setEnabled(false); }); connect(ui->pushButton, &QPushButton::clicked, [=] { diff --git a/tests/manual/cocoa/menurama/mainwindow.ui b/tests/manual/cocoa/menurama/mainwindow.ui index f73b41b861..d3caa6c608 100644 --- a/tests/manual/cocoa/menurama/mainwindow.ui +++ b/tests/manual/cocoa/menurama/mainwindow.ui @@ -6,63 +6,71 @@ 0 0 - 566 - 300 + 429 + 251 MainWindow - - - - 10 - 40 - 151 - 20 - - - - Enable "Stuff" Menu - - - true - - - - - - 10 - 10 - 321 - 16 - - - - The "Help" menu should NOT be visible. - - - - - - 10 - 80 - 211 - 32 - - - - Populate Dynamic Submenu - - + + + + + 24 + + + + + The "Help" menu should NOT be visible. + +Click on "Dynamic Stuff" then move left and right to other menus. Disabled items should remain that way. + + + false + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + Enable "Stuff" Menu + + + true + + + + + + + + 0 + 0 + + + + Populate Dynamic Submenu + + + + + + 0 0 - 566 + 429 22 diff --git a/tests/manual/cocoa/menurama/menuramaapplication.cpp b/tests/manual/cocoa/menurama/menuramaapplication.cpp index 534d5fa371..13e457d7dd 100644 --- a/tests/manual/cocoa/menurama/menuramaapplication.cpp +++ b/tests/manual/cocoa/menurama/menuramaapplication.cpp @@ -69,13 +69,19 @@ void MenuramaApplication::populateMenu(QMenu *menu, bool clear) void MenuramaApplication::addDynMenu(QLatin1String title, QMenu *parentMenu) { - foreach (QAction *a, parentMenu->actions()) - if (a->text() == title) { - parentMenu->removeAction(a); - break; - } + if (QAction *a = findAction(title, parentMenu)) + parentMenu->removeAction(a); QMenu *subMenu = new QMenu(title, parentMenu); populateMenu(subMenu, false /*clear*/); parentMenu->addMenu(subMenu); } + +QAction *MenuramaApplication::findAction(QLatin1String title, QMenu *parentMenu) +{ + foreach (QAction *a, parentMenu->actions()) + if (a->text() == title) + return a; + + return Q_NULLPTR; +} diff --git a/tests/manual/cocoa/menurama/menuramaapplication.h b/tests/manual/cocoa/menurama/menuramaapplication.h index 07c8da27a1..b0670cc53b 100644 --- a/tests/manual/cocoa/menurama/menuramaapplication.h +++ b/tests/manual/cocoa/menurama/menuramaapplication.h @@ -50,6 +50,7 @@ class MenuramaApplication : public QApplication public: MenuramaApplication(int argc, char **argv); void addDynMenu(QLatin1String title, QMenu *parentMenu); + QAction *findAction(QLatin1String title, QMenu *parentMenu); public slots: void populateMenu(QMenu *menu, bool clear); -- cgit v1.2.3 From 33573bf7eac70e27fa839b890bed2cb6e7fc0793 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 15 Nov 2016 17:26:53 +0100 Subject: Manual Dialog test: Fix compilation against Qt 4 Change-Id: I79a90cd252e99fb94c0429a3f03eb1ddacab1786 Reviewed-by: Oliver Wolff --- tests/manual/dialogs/main.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests') diff --git a/tests/manual/dialogs/main.cpp b/tests/manual/dialogs/main.cpp index f0f4e437e9..3f7b33ee7a 100644 --- a/tests/manual/dialogs/main.cpp +++ b/tests/manual/dialogs/main.cpp @@ -80,12 +80,15 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) int main(int argc, char *argv[]) { +#if QT_VERSION >= 0x050700 for (int a = 1; a < argc; ++a) { if (!qstrcmp(argv[a], "-n")) { qDebug("AA_DontUseNativeDialogs"); QCoreApplication::setAttribute(Qt::AA_DontUseNativeDialogs); } } +#endif // Qt 5 + QApplication a(argc, argv); MainWindow w; w.move(500, 200); -- cgit v1.2.3 From 03c1a6ac717e3c5693653a5e294214056bda970e Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 16 Nov 2016 16:57:24 +0100 Subject: Remove last traces of opengl es 1 support Change-Id: I3f86d4892ec3235003d34fdcf3f093f1513c821f Reviewed-by: Laszlo Agocs --- tests/auto/opengl/qgl/tst_qgl.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/opengl/qgl/tst_qgl.cpp b/tests/auto/opengl/qgl/tst_qgl.cpp index 4dec107f1e..af0248b432 100644 --- a/tests/auto/opengl/qgl/tst_qgl.cpp +++ b/tests/auto/opengl/qgl/tst_qgl.cpp @@ -739,16 +739,14 @@ void tst_QGL::openGLVersionCheck() // However, the complicated parts are in openGLVersionFlags(const QString &versionString) // tested above -#if defined(QT_OPENGL_ES_1) - QVERIFY(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Common_Version_1_0); -#elif defined(QT_OPENGL_ES_2) +#if defined(QT_OPENGL_ES_2) QVERIFY(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0); #else if (QOpenGLContext::currentContext()->isOpenGLES()) QVERIFY(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0); else QVERIFY(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_1); -#endif //defined(QT_OPENGL_ES_1) +#endif //defined(QT_OPENGL_ES_2) } #endif //QT_BUILD_INTERNAL -- cgit v1.2.3