From 105da329a34a59eb46eea5ee9ed46bd20e83dc58 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 14 Nov 2013 08:59:30 +0100 Subject: Skip tst_QGraphicsItem::ensureUpdateOnTextItem() on OSX 10.7 Change-Id: Iedb8ed3ac797d11c47f08b92507401e2e1e96c14 Reviewed-by: Iikka Eklund --- tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index b45ce88c83..6c26ddb293 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -6458,6 +6458,12 @@ public: void tst_QGraphicsItem::ensureUpdateOnTextItem() { +#ifdef Q_OS_MAC + if (QSysInfo::MacintoshVersion == QSysInfo::MV_10_7) { + QSKIP("This test is unstable on 10.7 in CI"); + } +#endif + QGraphicsScene scene; QGraphicsView view(&scene); view.show(); -- cgit v1.2.3 From f1053d94f59f053ce4acad9320df14f1fbe4faac Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 11 Nov 2013 14:27:40 +0100 Subject: Fully expand entities to ensure deep or widely nested ones fail parsing With 46a8885ae486e238a39efa5119c2714f328b08e4, we failed when parsing entities whose partially expanded size was greater than 1024 characters. That was not enough, so now we fully expand all entities. Amends 46a8885ae486e238a39efa5119c2714f328b08e4. Change-Id: Ie80720d7e04d825eb4eebf528140eb94806c02b1 Reviewed-by: Richard J. Moore Reviewed-by: Lars Knoll --- tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp index 57d078ba65..ed909946e6 100644 --- a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp +++ b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp @@ -809,7 +809,7 @@ void tst_QXmlSimpleReader::dtdRecursionLimit() xmlReader.setDeclHandler(&handler); xmlReader.setErrorHandler(&handler); QVERIFY(!xmlReader.parse(source)); - QVERIFY(handler.recursionCount == 1); + QCOMPARE(handler.recursionCount, 2); } } -- cgit v1.2.3 From 3396ba5612c1047d1b21a90c4996dff848c00114 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 13 Sep 2013 23:20:38 +0200 Subject: Match up the specified paper size to an existing one if possible When EnumForms was used then the dmPaperSize was not always correct for the custom paper sizes available on some printers. By using DeviceCapabilities we can be sure that the information is correct in this respect. This also fixes respecting of the custom paper size if one is given and there is no corresponding existing paper size for it. Task-number: QTBUG-34276 Change-Id: I9924d5be8527027fc434261e37f6c7aae66210c3 Reviewed-by: Friedemann Kleint --- .../printsupport/kernel/qprinter/tst_qprinter.cpp | 79 +++++++++++++++++++++- 1 file changed, 77 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp index 7251cca528..644cd33e5c 100644 --- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp +++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp @@ -113,6 +113,8 @@ private slots: void testCustomPageSizes(); void customPaperSizeAndMargins_data(); void customPaperSizeAndMargins(); + void customPaperNameSettingBySize(); + void customPaperNameSettingByName(); #if !defined(QT_NO_COMPLETER) && !defined(QT_NO_FILEDIALOG) void printDialogCompleter(); #endif @@ -967,6 +969,13 @@ void tst_QPrinter::errorReporting() painter.end(); } +static QByteArray msgSizeMismatch(const QSizeF &actual, const QSizeF &expected) +{ + QString result; + QDebug(&result) << "Paper size mismatch" << actual << "!=" << expected; + return result.toLocal8Bit(); +} + void tst_QPrinter::testCustomPageSizes() { QPrinter p; @@ -975,12 +984,16 @@ void tst_QPrinter::testCustomPageSizes() p.setPaperSize(customSize, QPrinter::Inch); QSizeF paperSize = p.paperSize(QPrinter::Inch); - QCOMPARE(paperSize, customSize); + // Due to the different calculations, the sizes may be off by a fraction so we have to check it manually + // instead of relying on QSizeF comparison + QVERIFY2(sqrt(pow(paperSize.width() - customSize.width(), 2.0) + pow(paperSize.height() - customSize.height(), 2.0)) < 0.01, + msgSizeMismatch(paperSize, customSize)); QPrinter p2(QPrinter::HighResolution); p2.setPaperSize(customSize, QPrinter::Inch); paperSize = p.paperSize(QPrinter::Inch); - QCOMPARE(paperSize, customSize); + QVERIFY2(sqrt(pow(paperSize.width() - customSize.width(), 2.0) + pow(paperSize.height() - customSize.height(), 2.0)) < 0.01, + msgSizeMismatch(paperSize, customSize)); } void tst_QPrinter::customPaperSizeAndMargins_data() @@ -1193,6 +1206,68 @@ void tst_QPrinter::testPageMetrics() QCOMPARE(printer.pageSizeMM(), QSizeF(widthMMf, heightMMf)); } +void tst_QPrinter::customPaperNameSettingBySize() +{ +#ifndef Q_OS_WIN + QSKIP("Currently this triggers a problem on non Windows platforms, this will be fixed separately - QTBUG-34521"); +#endif + QPrinter printer(QPrinter::HighResolution); + QPrinterInfo info(printer); + QList > sizes = info.supportedSizesWithNames(); + if (sizes.size() == 0) + QSKIP("No printers installed on this machine"); + for (int i=0; i > sizes = info.supportedSizesWithNames(); + if (sizes.size() == 0) + QSKIP("No printers installed on this machine"); + for (int i=0; i Date: Tue, 12 Nov 2013 11:17:05 +0100 Subject: qcompilerdetection.h: add Q_COMPILER_UNIFORM_INIT Up to now, the feature classe Uniform Initialization was subsumed by the Q_COMPILER_INITIALIZER_LISTS flag together with support for std::initializer_list. This caused at least two problems: 1. On QNX, the standard libray does not ship , even though the compiler (a GCC 4.6, IIRC) supports it. But since there was only one Q_COMPILER flag for both, support for the compiler-only part of the feature had to be disabled, too. 2. MSVC 2013 supports initializer lists, but has a bug that renders full uniform initialization support, as required for QUuid, useless. By splitting the feature into two, we can separate them better, and do so in QUuid, which is the only class that currently takes advantage of uniform initialization (to provide constexpr constructors). Since Q_COMPILER_INITIALIZER_LISTS worked as a flag for uniform initialization so far, with the two known exceptions above, UNIFORM_INIT is defined whenever INITIALIZER_LIST is, except that I don't revert UNIFORM_INIT on QNX as I do for INITIALIZER_LISTS and that I expect the MSVC 2013 features to set INITIALIZER_LIST, but not UNIFORM_INIT. Task-number: QTBUG-34705 Change-Id: I81916e950a0f3aab3de7977e0326d2de3d31b14c Reviewed-by: Yuchen Deng Reviewed-by: Thiago Macieira --- tests/auto/corelib/plugin/quuid/tst_quuid.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp index 197d56359f..227351485d 100644 --- a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp +++ b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp @@ -64,6 +64,7 @@ private slots: void isNull(); void equal(); void notEqual(); + void cpp11(); // Only in Qt > 3.2.x void generate(); @@ -245,6 +246,17 @@ void tst_QUuid::notEqual() QVERIFY( uuidA != uuidB ); } +void tst_QUuid::cpp11() { +#ifdef Q_COMPILER_UNIFORM_INIT + // "{fc69b59e-cc34-4436-a43c-ee95d128b8c5}" cf, initTestCase + Q_DECL_CONSTEXPR QUuid u1{0xfc69b59e, 0xcc34, 0x4436, 0xa4, 0x3c, 0xee, 0x95, 0xd1, 0x28, 0xb8, 0xc5}; + Q_DECL_CONSTEXPR QUuid u2 = {0xfc69b59e, 0xcc34, 0x4436, 0xa4, 0x3c, 0xee, 0x95, 0xd1, 0x28, 0xb8, 0xc5}; + Q_UNUSED(u1); + Q_UNUSED(u2); +#else + QSKIP("This compiler is not in C++11 mode or it doesn't support uniform initialization"); +#endif +} void tst_QUuid::generate() { -- cgit v1.2.3 From 7d72516b52b20b0782d972224a55a43e74b8ae5a Mon Sep 17 00:00:00 2001 From: Alan Alpert <416365416c@gmail.com> Date: Fri, 13 Sep 2013 13:57:21 -0700 Subject: Change platform selectors to match qmake selectors Previously matched Qt.platform.os, however that can only provide one string. Multiple selectors can be present at once, so we can provide both unix and linux instead of having to pick the most specialized one. Task-number: QTBUG-34796 Change-Id: I219517d740fa7385e923a9e09cb7e241378fbaee Reviewed-by: David Faure --- .../io/qfileselector/platforms/+android/test2 | 0 .../io/qfileselector/platforms/+blackberry/test2 | 0 .../io/qfileselector/platforms/+generic_unix/test | 0 .../corelib/io/qfileselector/platforms/+ios/test2 | 0 .../io/qfileselector/platforms/+linux/test2 | 0 .../corelib/io/qfileselector/platforms/+mac/test | 0 .../corelib/io/qfileselector/platforms/+mac/test2 | 0 .../io/qfileselector/platforms/+unix/+android/test | 0 .../qfileselector/platforms/+unix/+blackberry/test | 0 .../io/qfileselector/platforms/+unix/+ios/test | 0 .../io/qfileselector/platforms/+unix/+linux/test | 0 .../io/qfileselector/platforms/+unix/+mac/test | 0 .../corelib/io/qfileselector/platforms/+unix/test | 0 .../io/qfileselector/platforms/+wince/test2 | 0 .../qfileselector/platforms/+windows/+wince/test | 0 .../io/qfileselector/platforms/+windows/test2 | 0 .../auto/corelib/io/qfileselector/platforms/test2 | 0 .../corelib/io/qfileselector/qfileselector.qrc | 22 +++++++++++++--- .../corelib/io/qfileselector/tst_qfileselector.cpp | 30 +++++++++++++++++++--- 19 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+android/test2 create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+blackberry/test2 delete mode 100644 tests/auto/corelib/io/qfileselector/platforms/+generic_unix/test create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+ios/test2 create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+linux/test2 create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+mac/test create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+mac/test2 create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+unix/+android/test create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+unix/+blackberry/test create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+unix/+ios/test create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+unix/+linux/test create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+unix/+mac/test create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+unix/test create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+wince/test2 create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+windows/+wince/test create mode 100644 tests/auto/corelib/io/qfileselector/platforms/+windows/test2 create mode 100644 tests/auto/corelib/io/qfileselector/platforms/test2 (limited to 'tests') diff --git a/tests/auto/corelib/io/qfileselector/platforms/+android/test2 b/tests/auto/corelib/io/qfileselector/platforms/+android/test2 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+blackberry/test2 b/tests/auto/corelib/io/qfileselector/platforms/+blackberry/test2 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+generic_unix/test b/tests/auto/corelib/io/qfileselector/platforms/+generic_unix/test deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+ios/test2 b/tests/auto/corelib/io/qfileselector/platforms/+ios/test2 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+linux/test2 b/tests/auto/corelib/io/qfileselector/platforms/+linux/test2 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+mac/test b/tests/auto/corelib/io/qfileselector/platforms/+mac/test new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+mac/test2 b/tests/auto/corelib/io/qfileselector/platforms/+mac/test2 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+android/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+android/test new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+blackberry/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+blackberry/test new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+ios/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+ios/test new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+linux/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+linux/test new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+mac/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+mac/test new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/test new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+wince/test2 b/tests/auto/corelib/io/qfileselector/platforms/+wince/test2 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+windows/+wince/test b/tests/auto/corelib/io/qfileselector/platforms/+windows/+wince/test new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+windows/test2 b/tests/auto/corelib/io/qfileselector/platforms/+windows/test2 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/test2 b/tests/auto/corelib/io/qfileselector/platforms/test2 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/corelib/io/qfileselector/qfileselector.qrc b/tests/auto/corelib/io/qfileselector/qfileselector.qrc index c644e41107..abfead2a55 100644 --- a/tests/auto/corelib/io/qfileselector/qfileselector.qrc +++ b/tests/auto/corelib/io/qfileselector/qfileselector.qrc @@ -11,13 +11,27 @@ extras/+custom3/+custom5/test extras/+custom5/+custom3/test platforms/test + platforms/+unix/+android/test + platforms/+unix/+blackberry/test + platforms/+unix/+ios/test + platforms/+unix/+mac/test + platforms/+windows/+wince/test + platforms/+windows/test + platforms/+windows/test2 + platforms/+unix/+linux/test + platforms/+unix/test + platforms/test2 + platforms/+android/test2 + platforms/+blackberry/test2 + platforms/+ios/test2 + platforms/+mac/test2 + platforms/+linux/test2 + platforms/+wince/test2 platforms/+android/test platforms/+blackberry/test platforms/+ios/test - platforms/+osx/test - platforms/+wince/test - platforms/+windows/test + platforms/+mac/test platforms/+linux/test - platforms/+generic_unix/test + platforms/+wince/test diff --git a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp index 2baebd0296..d6461c3aba 100644 --- a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp +++ b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp @@ -91,9 +91,33 @@ void tst_QFileSelector::basicTest_data() QTest::addColumn("expectedPath"); QString test("/test");// '/' is here so dir string can also be selector string - QTest::newRow("platform") << QString(":/platforms/test") << QStringList() - << QString(":/platforms/") + QLatin1Char(selectorIndicator) - + QFileSelectorPrivate::platformSelectors().first() + test; + QString test2("/test2"); + QString expectedPlatform1File(":/platforms"); + QString expectedPlatform2File(""); //Only the last selector +#if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID) && !defined(Q_OS_BLACKBERRY) && !defined(Q_OS_IOS) && !defined(Q_OS_LINUX) && !defined(Q_OS_MAC) + /* We are only aware of specific unixes, and do not have test files for any of the others. + However those unixes can get a selector added from the result of a uname call, so this will + lead to a case where we don't have that file so we can't expect the concatenation of platform + selectors to work. It should just find the +unix/test file.*/ + expectedPlatform1File = QString(":/platforms/") + QLatin1Char(selectorIndicator) + + QString("unix/test"); + expectedPlatform2File = QString(":/platforms/test2"); +#else + foreach (const QString &selector, QFileSelectorPrivate::platformSelectors()) { + expectedPlatform1File = expectedPlatform1File + QLatin1Char('/') + QLatin1Char(selectorIndicator) + + selector; + expectedPlatform2File = selector; + } + expectedPlatform1File += test; + expectedPlatform2File = QLatin1String(":/platforms/") + QLatin1Char(selectorIndicator) + + expectedPlatform2File + test2; +#endif + + QTest::newRow("platform1") << QString(":/platforms/test") << QStringList() + << expectedPlatform1File; + + QTest::newRow("platform2") << QString(":/platforms/test2") << QStringList() + << expectedPlatform2File; QString resourceTestPath(":/extras/test"); QString custom1("custom1"); -- cgit v1.2.3 From 6c04c21c101b70401ad9cb08de1562dc90166e9c Mon Sep 17 00:00:00 2001 From: Martin Pley Date: Fri, 15 Nov 2013 22:01:54 +0100 Subject: Crash fix in QTreeView::sizeHintForColumn(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vertical scrollbar may get out of sync. When this happens, the calculation of firstVisibleItem will retrun "-1". This must be handled in ::sizeHintForColumn(). Added an auto-test for the crashes. Task-number: QTBUG-34717 Change-Id: I867fd144ef3ce45e382337c5eafe345f573cd944 Reviewed-by: Thorbjørn Lund Martsum --- .../widgets/itemviews/qtreeview/tst_qtreeview.cpp | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 8d31fcdf13..ccdce1fe0c 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -259,6 +259,7 @@ private slots: void taskQTBUG_25333_adjustViewOptionsForIndex(); void taskQTBUG_18539_emitLayoutChanged(); void taskQTBUG_8176_emitOnExpandAll(); + void taskQTBUG_34717_collapseAtBottom(); void testInitialFocus(); }; @@ -4240,6 +4241,35 @@ void tst_QTreeView::taskQTBUG_8176_emitOnExpandAll() QCOMPARE(spy2.size(), 1); // item2 is collapsed } +// From QTBUG_34717 (QTreeWidget crashes when scrolling to the end +// of an expanded tree, then collapse all) +// The test passes simply if it doesn't crash. +void tst_QTreeView::taskQTBUG_34717_collapseAtBottom() +{ + QTreeWidget treeWidget; + treeWidget.header()->setSectionResizeMode(QHeaderView::ResizeToContents); + treeWidget.setColumnCount(2); + QTreeWidgetItem *mainItem = new QTreeWidgetItem(&treeWidget, QStringList() << "Root"); + for (int i = 0; i < 200; ++i) { + QTreeWidgetItem *item = new QTreeWidgetItem(mainItem, QStringList(QString("Item"))); + new QTreeWidgetItem(item, QStringList() << "Child" << "1"); + new QTreeWidgetItem(item, QStringList() << "Child" << "2"); + new QTreeWidgetItem(item, QStringList() << "Child" << "3"); + } + treeWidget.show(); + treeWidget.expandAll(); + treeWidget.scrollToBottom(); + treeWidget.collapseAll(); + + treeWidget.setAnimated(true); + treeWidget.expandAll(); + treeWidget.scrollToBottom(); + mainItem->setExpanded(false); + + PublicView *pview = (PublicView*) &treeWidget; + QVERIFY(pview->sizeHintForColumn(1) >= 0); +} + void tst_QTreeView::testInitialFocus() { QTreeWidget treeWidget; -- cgit v1.2.3 From 3e803b5180e7059c01c15ea84cadd54982e1a221 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 13 Nov 2013 11:37:37 +0100 Subject: QCollator: enable move semantics This necessitates adding d==0 checks in QCollator. By documenting that moved-from instances can only be assigned to or destroyed, we can limit the functions in which to check for d==0 to the assignment operator and the destructor. Doing otherwise would destroy all advantages of move semantics by introducing a heap allocation to re-populate other.d. Add a test for this (QCollator didn't have any before). Change-Id: Ic6ff202072822bebfd5e48259c3d0fa345a63118 Reviewed-by: Thiago Macieira --- tests/auto/corelib/tools/qcollator/qcollator.pro | 7 ++ .../auto/corelib/tools/qcollator/tst_qcollator.cpp | 92 ++++++++++++++++++++++ tests/auto/corelib/tools/tools.pro | 1 + 3 files changed, 100 insertions(+) create mode 100644 tests/auto/corelib/tools/qcollator/qcollator.pro create mode 100644 tests/auto/corelib/tools/qcollator/tst_qcollator.cpp (limited to 'tests') diff --git a/tests/auto/corelib/tools/qcollator/qcollator.pro b/tests/auto/corelib/tools/qcollator/qcollator.pro new file mode 100644 index 0000000000..3c5987ffa0 --- /dev/null +++ b/tests/auto/corelib/tools/qcollator/qcollator.pro @@ -0,0 +1,7 @@ +CONFIG += testcase parallel_test +TARGET = tst_qcollator +QT = core testlib +SOURCES = tst_qcollator.cpp +DEFINES += QT_NO_CAST_TO_ASCII +contains(QT_CONFIG,icu):DEFINES += QT_USE_ICU +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp new file mode 100644 index 0000000000..3df8422a34 --- /dev/null +++ b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt 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.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include +#include + +#include + +class tst_QCollator : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void moveSemantics(); +}; + +#ifdef Q_COMPILER_RVALUE_REFS +static bool dpointer_is_null(QCollator &c) +{ + char mem[sizeof c]; + using namespace std; + memcpy(mem, &c, sizeof c); + for (size_t i = 0; i < sizeof c; ++i) + if (mem[i]) + return false; + return true; +} +#endif + +void tst_QCollator::moveSemantics() +{ +#ifdef Q_COMPILER_RVALUE_REFS + const QLocale de_AT(QLocale::German, QLocale::Austria); + + QCollator c1(de_AT); + QCOMPARE(c1.locale(), de_AT); + + QCollator c2(std::move(c1)); + QCOMPARE(c2.locale(), de_AT); + QVERIFY(dpointer_is_null(c1)); + + c1 = std::move(c2); + QCOMPARE(c1.locale(), de_AT); + QVERIFY(dpointer_is_null(c2)); +#else + QSKIP("The compiler is not in C++11 mode or does not support move semantics."); +#endif +} + +QTEST_APPLESS_MAIN(tst_QCollator) + +#include "tst_qcollator.moc" diff --git a/tests/auto/corelib/tools/tools.pro b/tests/auto/corelib/tools/tools.pro index e920813db2..286afdfd18 100644 --- a/tests/auto/corelib/tools/tools.pro +++ b/tests/auto/corelib/tools/tools.pro @@ -8,6 +8,7 @@ SUBDIRS=\ qbytedatabuffer \ qcache \ qchar \ + qcollator \ qcommandlineparser \ qcontiguouscache \ qcryptographichash \ -- cgit v1.2.3 From eb122a6fe4de5b95acb287f92c6ca5e81864b1c6 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 16 Nov 2013 14:30:38 +0100 Subject: tst_QAlgorithms: fix compilation with C++11 enabled GCC refuses to use a merely static const uint array in a constexpr function. Fix by making the array constexpr if supported by the compiler. Change-Id: Idd59d3f74f8f4e98aad82bc892f4a6469932df9f Reviewed-by: Olivier Goffart Reviewed-by: Lars Knoll --- tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp index 144bc62b1b..64eb91b7b6 100644 --- a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp +++ b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp @@ -1027,7 +1027,7 @@ void tst_QAlgorithms::binaryFindOnLargeContainer() const } // alternative implementation of qPopulationCount for comparison: -static const uint bitsSetInNibble[] = { +static Q_DECL_CONSTEXPR const uint bitsSetInNibble[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, }; -- cgit v1.2.3