summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@digia.com>2014-03-31 17:45:37 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-31 17:45:37 +0200
commitbd822bedfea5126b12c32523a68c3a1ac7a8931d (patch)
tree0fafd5ac037e3b62ad45e8808989ec89155618b4 /tests/auto
parent84c10500b1730e8d947732728d190fde612fc840 (diff)
parent3b5c0bc0780f1749fed7c07bd8b691400a0282b7 (diff)
Merge "Merge remote-tracking branch 'origin/stable' into dev" into refs/staging/dev
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/io/qfile/tst_qfile.cpp12
-rw-r--r--tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp4
-rw-r--r--tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp12
-rw-r--r--tests/auto/corelib/io/qresourceengine/qresourceengine.pro9
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp8
-rw-r--r--tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp1
-rw-r--r--tests/auto/corelib/tools/qchar/qchar.pro2
-rw-r--r--tests/auto/corelib/tools/qmessageauthenticationcode/qmessageauthenticationcode.pro1
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp51
-rw-r--r--tests/auto/gui/painting/painting.pro3
-rw-r--r--tests/auto/gui/painting/qpagelayout/.gitignore1
-rw-r--r--tests/auto/gui/painting/qpagelayout/qpagelayout.pro9
-rw-r--r--tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp277
-rw-r--r--tests/auto/gui/painting/qpagesize/.gitignore1
-rw-r--r--tests/auto/gui/painting/qpagesize/qpagesize.pro9
-rw-r--r--tests/auto/gui/painting/qpagesize/tst_qpagesize.cpp258
-rw-r--r--tests/auto/gui/painting/qpdfwriter/.gitignore1
-rw-r--r--tests/auto/gui/painting/qpdfwriter/qpdfwriter.pro9
-rw-r--r--tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp265
-rw-r--r--tests/auto/gui/qopengl/tst_qopengl.cpp38
-rw-r--r--tests/auto/gui/text/qstatictext/tst_qstatictext.cpp28
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp122
-rw-r--r--tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp2
-rw-r--r--tests/auto/opengl/qgl/tst_qgl.cpp40
-rw-r--r--tests/auto/other/d3dcompiler/tst_d3dcompiler.cpp18
-rw-r--r--tests/auto/other/gestures/tst_gestures.cpp2
-rw-r--r--tests/auto/other/macgui/tst_macgui.cpp2
-rw-r--r--tests/auto/other/macnativeevents/tst_macnativeevents.cpp2
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp47
-rw-r--r--tests/auto/printsupport/kernel/kernel.pro1
-rw-r--r--tests/auto/printsupport/kernel/qprintdevice/.gitignore1
-rw-r--r--tests/auto/printsupport/kernel/qprintdevice/qprintdevice.pro9
-rw-r--r--tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp111
-rw-r--r--tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp462
-rw-r--r--tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp94
-rw-r--r--tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp23
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp93
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp31
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp2
-rw-r--r--tests/auto/widgets/itemviews/qabstractitemview/qabstractitemview.pro1
-rw-r--r--tests/auto/widgets/itemviews/qcolumnview/qcolumnview.pro1
-rw-r--r--tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp3
-rw-r--r--tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp32
-rw-r--r--tests/auto/widgets/util/qscroller/tst_qscroller.cpp2
-rw-r--r--tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp9
-rw-r--r--tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp4
47 files changed, 1676 insertions, 439 deletions
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp
index 77ac4bcd86..60d1517ed3 100644
--- a/tests/auto/corelib/io/qfile/tst_qfile.cpp
+++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp
@@ -181,7 +181,7 @@ private slots:
void writeTextFile_data();
void writeTextFile();
/* void largeFileSupport(); */
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
void largeUncFileSupport();
#endif
void flush();
@@ -480,7 +480,7 @@ void tst_QFile::exists()
file.remove();
QVERIFY(!file.exists());
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
QFile unc("//" + QtNetworkSettings::winServerName() + "/testshare/readme.txt");
QVERIFY(unc.exists());
#endif
@@ -605,7 +605,7 @@ void tst_QFile::size_data()
QTest::addColumn<qint64>("size");
QTest::newRow( "exist01" ) << m_testFile << (qint64)245;
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
// Only test UNC on Windows./
QTest::newRow("unc") << "//" + QString(QtNetworkSettings::winServerName() + "/testshare/test.pri") << (qint64)34;
#endif
@@ -1539,7 +1539,7 @@ void tst_QFile::writeTextFile()
QCOMPARE(file.readAll(), out);
}
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
void tst_QFile::largeUncFileSupport()
{
qint64 size = Q_INT64_C(8589934592);
@@ -2245,7 +2245,7 @@ void tst_QFile::writeLargeDataBlock_data()
QTest::newRow("localfile-Fd") << "./largeblockfile.txt" << (int)OpenFd;
QTest::newRow("localfile-Stream") << "./largeblockfile.txt" << (int)OpenStream;
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(QT_NO_NETWORK)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) && !defined(QT_NO_NETWORK)
// Some semi-randomness to avoid collisions.
QTest::newRow("unc file")
<< QString("//" + QtNetworkSettings::winServerName() + "/TESTSHAREWRITABLE/largefile-%1-%2.txt")
@@ -2605,7 +2605,7 @@ void tst_QFile::appendAndRead()
void tst_QFile::miscWithUncPathAsCurrentDir()
{
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
QString current = QDir::currentPath();
QVERIFY(QDir::setCurrent("//" + QtNetworkSettings::winServerName() + "/testshare"));
QFile file("test.pri");
diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
index b31b6631f4..6c147d68c8 100644
--- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
@@ -378,7 +378,7 @@ void tst_QFileInfo::isRoot_data()
QTest::newRow("drive 3") << "p:/" << false;
#endif
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
QTest::newRow("unc 1") << "//" + QtNetworkSettings::winServerName() << true;
QTest::newRow("unc 2") << "//" + QtNetworkSettings::winServerName() + "/" << true;
QTest::newRow("unc 3") << "//" + QtNetworkSettings::winServerName() + "/testshare" << false;
@@ -418,7 +418,7 @@ void tst_QFileInfo::exists_data()
QTest::newRow("simple dir") << m_resourcesDir << true;
QTest::newRow("simple dir with slash") << (m_resourcesDir + QLatin1Char('/')) << true;
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
QTest::newRow("unc 1") << "//" + QtNetworkSettings::winServerName() << true;
QTest::newRow("unc 2") << "//" + QtNetworkSettings::winServerName() + "/" << true;
QTest::newRow("unc 3") << "//" + QtNetworkSettings::winServerName() + "/testshare" << true;
diff --git a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp
index 4318396bd4..3064fd1320 100644
--- a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp
+++ b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp
@@ -172,7 +172,7 @@ private slots:
QLoggingRule rule(QStringRef(&pattern), true);
LoggingRuleState state = Invalid;
- if (rule.flags != QLoggingRule::Invalid) {
+ if (rule.flags != 0) {
switch (rule.pass(category, msgType)) {
case -1: QFAIL("Shoudn't happen, we set pattern to true"); break;
case 0: state = NoMatch; break;
@@ -302,6 +302,16 @@ private slots:
QVERIFY(!cat.isWarningEnabled());
}
+
+ void QLoggingRegistry_checkErrors()
+ {
+ QLoggingSettingsParser parser;
+ QString warnMsg = QString("Ignoring malformed logging rule: '***=false'");
+ QTest::ignoreMessage(QtWarningMsg, warnMsg.toLocal8Bit().constData());
+ parser.setContent("[Rules]\n"
+ "***=false\n");
+ QVERIFY(parser.rules().isEmpty());
+ }
};
QTEST_MAIN(tst_QLoggingRegistry)
diff --git a/tests/auto/corelib/io/qresourceengine/qresourceengine.pro b/tests/auto/corelib/io/qresourceengine/qresourceengine.pro
index b9e17f7418..b7606eb3fc 100644
--- a/tests/auto/corelib/io/qresourceengine/qresourceengine.pro
+++ b/tests/auto/corelib/io/qresourceengine/qresourceengine.pro
@@ -14,12 +14,5 @@ PRE_TARGETDEPS += $${runtime_resource.target}
TESTDATA += \
parentdir.txt \
testqrc/*
-
-# Special case needed for runtime_resource.rcc installation,
-# since it does not exist at qmake runtime.
-load(testcase) # to get value of target.path
-runtime_resource_install.CONFIG = no_check_exist
-runtime_resource_install.files = $$OUT_PWD/$${runtime_resource.target}
-runtime_resource_install.path = $${target.path}
-INSTALLS += runtime_resource_install
+GENERATED_TESTDATA = $${runtime_resource.target}
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
index 0e3ea86165..959c79ed60 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
@@ -278,15 +278,21 @@ void tst_QMetaType::threadSafety()
namespace TestSpace
{
struct Foo { double d; };
-
+ struct QungTfu {};
}
Q_DECLARE_METATYPE(TestSpace::Foo)
+#define ADD_TESTSPACE(F) TestSpace::F
+Q_DECLARE_METATYPE(ADD_TESTSPACE(QungTfu))
+
void tst_QMetaType::namespaces()
{
TestSpace::Foo nf = { 11.12 };
QVariant v = QVariant::fromValue(nf);
QCOMPARE(qvariant_cast<TestSpace::Foo>(v).d, 11.12);
+
+ int qungTfuId = qRegisterMetaType<ADD_TESTSPACE(QungTfu)>();
+ QCOMPARE(QMetaType::typeName(qungTfuId), "TestSpace::QungTfu");
}
void tst_QMetaType::qMetaTypeId()
diff --git a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
index 859cd1b36a..0c91c419cc 100644
--- a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
+++ b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
@@ -381,6 +381,7 @@ void tst_QThreadPool::expiryTimeoutRace() // QTBUG-3786
threadPool.start(&task);
QThread::msleep(50); // exactly the same as the expiry timeout
}
+ QVERIFY(task.semaphore.tryAcquire(numTasks, 10000));
QCOMPARE(task.runCount.load(), numTasks);
QVERIFY(threadPool.waitForDone(2000));
}
diff --git a/tests/auto/corelib/tools/qchar/qchar.pro b/tests/auto/corelib/tools/qchar/qchar.pro
index 7b36b2e45e..0738abad3a 100644
--- a/tests/auto/corelib/tools/qchar/qchar.pro
+++ b/tests/auto/corelib/tools/qchar/qchar.pro
@@ -3,5 +3,5 @@ TARGET = tst_qchar
QT = core-private testlib
SOURCES = tst_qchar.cpp
-TESTDATA += NormalizationTest.txt
+TESTDATA += data/NormalizationTest.txt
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/corelib/tools/qmessageauthenticationcode/qmessageauthenticationcode.pro b/tests/auto/corelib/tools/qmessageauthenticationcode/qmessageauthenticationcode.pro
index 1ea23915b7..afd0c1176d 100644
--- a/tests/auto/corelib/tools/qmessageauthenticationcode/qmessageauthenticationcode.pro
+++ b/tests/auto/corelib/tools/qmessageauthenticationcode/qmessageauthenticationcode.pro
@@ -3,5 +3,4 @@ TARGET = tst_qmessageauthenticationcode
QT = core testlib
SOURCES = tst_qmessageauthenticationcode.cpp
-TESTDATA += data/*
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index 7e6313295b..da142c80a6 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -71,6 +71,7 @@ private slots:
void mouseToTouchLoop();
void touchCancel();
void touchCancelWithTouchToMouse();
+ void touchInterruptedByPopup();
void orientation();
void sizes();
void close();
@@ -772,6 +773,56 @@ void tst_QWindow::touchCancelWithTouchToMouse()
QTRY_COMPARE(window.mouseReleaseButton, 0);
}
+void tst_QWindow::touchInterruptedByPopup()
+{
+ InputTestWindow window;
+ window.setGeometry(80, 80, 200, 200);
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+
+ QList<QWindowSystemInterface::TouchPoint> points;
+ QWindowSystemInterface::TouchPoint tp1;
+ tp1.id = 1;
+
+ // Start a touch.
+ tp1.state = Qt::TouchPointPressed;
+ tp1.area = QRect(10, 10, 4, 4);
+ points << tp1;
+ QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points);
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(window.touchEventType, QEvent::TouchBegin);
+ QTRY_COMPARE(window.touchPressedCount, 1);
+
+ // Launch a popup window
+ InputTestWindow popup;
+ popup.setFlags(Qt::Popup);
+ popup.setModality(Qt::WindowModal);
+ popup.setWidth(160);
+ popup.setHeight(160);
+ popup.setTransientParent(&window);
+ popup.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&popup));
+
+ // Send a move -> will not be delivered to the original window
+ // (TODO verify where it is forwarded, after we've defined that)
+ QTRY_COMPARE(window.touchMovedCount, 0);
+ points[0].state = Qt::TouchPointMoved;
+ tp1.area.adjust(2, 2, 2, 2);
+ QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points);
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(window.touchMovedCount, 0);
+
+ // Send a touch end -> will not be delivered to the original window
+ QTRY_COMPARE(window.touchReleasedCount, 0);
+ points[0].state = Qt::TouchPointReleased;
+ QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points);
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(window.touchReleasedCount, 0);
+
+ // Due to temporary fix for QTBUG-37371: the original window should receive a TouchCancel
+ QTRY_COMPARE(window.touchEventType, QEvent::TouchCancel);
+}
+
void tst_QWindow::orientation()
{
qRegisterMetaType<Qt::ScreenOrientation>("Qt::ScreenOrientation");
diff --git a/tests/auto/gui/painting/painting.pro b/tests/auto/gui/painting/painting.pro
index 8f018fd921..0f7595c871 100644
--- a/tests/auto/gui/painting/painting.pro
+++ b/tests/auto/gui/painting/painting.pro
@@ -5,8 +5,11 @@ SUBDIRS=\
qcolor \
qbrush \
qregion \
+ qpagelayout \
+ qpagesize \
qpainter \
qpathclipper \
+ qpdfwriter \
qpen \
qpaintengine \
qtransform \
diff --git a/tests/auto/gui/painting/qpagelayout/.gitignore b/tests/auto/gui/painting/qpagelayout/.gitignore
new file mode 100644
index 0000000000..7c7dcd262b
--- /dev/null
+++ b/tests/auto/gui/painting/qpagelayout/.gitignore
@@ -0,0 +1 @@
+tst_qpagelayout
diff --git a/tests/auto/gui/painting/qpagelayout/qpagelayout.pro b/tests/auto/gui/painting/qpagelayout/qpagelayout.pro
new file mode 100644
index 0000000000..38a1064357
--- /dev/null
+++ b/tests/auto/gui/painting/qpagelayout/qpagelayout.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+CONFIG += parallel_test
+TARGET = tst_qpagelayout
+SOURCES += tst_qpagelayout.cpp
+
+QT += gui-private testlib
+
+DEFINES += QT_USE_USING_NAMESPACE
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp b/tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp
new file mode 100644
index 0000000000..30d25f00d2
--- /dev/null
+++ b/tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp
@@ -0,0 +1,277 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 John Layt <jlayt@kde.org>
+** 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 <QtTest/QtTest>
+#include <QtGui/qpagelayout.h>
+
+class tst_QPageLayout : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void invalid();
+ void basics();
+ void setGetMargins();
+};
+
+void tst_QPageLayout::invalid()
+{
+ // Invalid
+ QPageLayout invalid = QPageLayout();
+ QCOMPARE(invalid.isValid(), false);
+ invalid = QPageLayout(QPageSize(), QPageLayout::Portrait, QMarginsF());
+ QCOMPARE(invalid.isValid(), false);
+}
+
+void tst_QPageLayout::basics()
+{
+ // Simple A4, no margins
+ QPageLayout simple = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF(0, 0, 0, 0));
+ QCOMPARE(simple.isValid(), true);
+ QCOMPARE(simple.pageSize().id(), QPageSize::A4);
+ QCOMPARE(simple.orientation(), QPageLayout::Portrait);
+ QCOMPARE(simple.margins(), QMarginsF(0, 0, 0, 0));
+ QCOMPARE(simple.margins(QPageLayout::Millimeter), QMarginsF(0, 0, 0, 0));
+ QCOMPARE(simple.marginsPoints(), QMargins(0, 0, 0, 0));
+ QCOMPARE(simple.marginsPixels(72), QMargins(0, 0, 0, 0));
+ QCOMPARE(simple.minimumMargins(), QMarginsF(0, 0, 0, 0));
+ QCOMPARE(simple.maximumMargins(), QMarginsF(595, 842, 595, 842));
+ QCOMPARE(simple.fullRect(), QRectF(0, 0, 595, 842));
+ QCOMPARE(simple.fullRect(QPageLayout::Millimeter), QRectF(0, 0, 210, 297));
+ QCOMPARE(simple.fullRectPoints(), QRect(0, 0, 595, 842));
+ QCOMPARE(simple.fullRectPixels(72), QRect(0, 0, 595, 842));
+ QCOMPARE(simple.paintRect(), QRectF(0, 0, 595, 842));
+ QCOMPARE(simple.paintRect(QPageLayout::Millimeter), QRectF(0, 0, 210, 297));
+ QCOMPARE(simple.paintRectPoints(), QRect(0, 0, 595, 842));
+ QCOMPARE(simple.paintRectPixels(72), QRect(0, 0, 595, 842));
+
+ // Change orientation
+ simple.setOrientation(QPageLayout::Landscape);
+ QCOMPARE(simple.orientation(), QPageLayout::Landscape);
+ QCOMPARE(simple.margins(), QMarginsF(0, 0, 0, 0));
+ QCOMPARE(simple.minimumMargins(), QMarginsF(0, 0, 0, 0));
+ QCOMPARE(simple.maximumMargins(), QMarginsF(842, 595, 842, 595));
+ QCOMPARE(simple.fullRect(), QRectF(0, 0, 842, 595));
+ QCOMPARE(simple.fullRect(QPageLayout::Millimeter), QRectF(0, 0, 297, 210));
+ QCOMPARE(simple.fullRectPoints(), QRect(0, 0, 842, 595));
+ QCOMPARE(simple.fullRectPixels(72), QRect(0, 0, 842, 595));
+ QCOMPARE(simple.paintRect(), QRectF(0, 0, 842, 595));
+ QCOMPARE(simple.paintRect(QPageLayout::Millimeter), QRectF(0, 0, 297, 210));
+ QCOMPARE(simple.paintRectPoints(), QRect(0, 0, 842, 595));
+ QCOMPARE(simple.paintRectPixels(72), QRect(0, 0, 842, 595));
+
+ // Change mode
+ QCOMPARE(simple.mode(), QPageLayout::StandardMode);
+ simple.setMode(QPageLayout::FullPageMode);
+ QCOMPARE(simple.mode(), QPageLayout::FullPageMode);
+ QCOMPARE(simple.orientation(), QPageLayout::Landscape);
+ QCOMPARE(simple.margins(), QMarginsF(0, 0, 0, 0));
+ QCOMPARE(simple.minimumMargins(), QMarginsF(0, 0, 0, 0));
+ QCOMPARE(simple.maximumMargins(), QMarginsF(842, 595, 842, 595));
+ QCOMPARE(simple.fullRect(), QRectF(0, 0, 842, 595));
+ QCOMPARE(simple.fullRect(QPageLayout::Millimeter), QRectF(0, 0, 297, 210));
+ QCOMPARE(simple.fullRectPoints(), QRect(0, 0, 842, 595));
+ QCOMPARE(simple.fullRectPixels(72), QRect(0, 0, 842, 595));
+ QCOMPARE(simple.paintRect(), QRectF(0, 0, 842, 595));
+ QCOMPARE(simple.paintRect(QPageLayout::Millimeter), QRectF(0, 0, 297, 210));
+ QCOMPARE(simple.paintRectPoints(), QRect(0, 0, 842, 595));
+ QCOMPARE(simple.paintRectPixels(72), QRect(0, 0, 842, 595));
+
+ // A4, 10pt margins
+ QPageLayout tenpoint = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF(10, 10, 10, 10));
+ QCOMPARE(tenpoint.isValid(), true);
+ QCOMPARE(tenpoint.margins(), QMarginsF(10, 10, 10, 10));
+ QCOMPARE(tenpoint.margins(QPageLayout::Millimeter), QMarginsF(3.53, 3.53, 3.53, 3.53));
+ QCOMPARE(tenpoint.marginsPoints(), QMargins(10, 10, 10, 10));
+ QCOMPARE(tenpoint.marginsPixels(72), QMargins(10, 10, 10, 10));
+ QCOMPARE(tenpoint.minimumMargins(), QMarginsF(0, 0, 0, 0));
+ QCOMPARE(tenpoint.maximumMargins(), QMarginsF(595, 842, 595, 842));
+ QCOMPARE(tenpoint.fullRect(), QRectF(0, 0, 595, 842));
+ QCOMPARE(tenpoint.fullRect(QPageLayout::Millimeter), QRectF(0, 0, 210, 297));
+ QCOMPARE(tenpoint.fullRectPoints(), QRect(0, 0, 595, 842));
+ QCOMPARE(tenpoint.fullRectPixels(72), QRect(0, 0, 595, 842));
+ QCOMPARE(tenpoint.paintRect(), QRectF(10, 10, 575, 822));
+ QCOMPARE(tenpoint.paintRect(QPageLayout::Millimeter), QRectF(3.53, 3.53, 202.94, 289.94));
+ QCOMPARE(tenpoint.paintRect(QPageLayout::Millimeter).x(), 3.53);
+ QCOMPARE(tenpoint.paintRect(QPageLayout::Millimeter).y(), 3.53);
+ QCOMPARE(tenpoint.paintRect(QPageLayout::Millimeter).width(), 202.94);
+ QCOMPARE(tenpoint.paintRect(QPageLayout::Millimeter).height(), 289.94);
+ QCOMPARE(tenpoint.paintRect(QPageLayout::Millimeter).left(), 3.53);
+ QCOMPARE(tenpoint.paintRect(QPageLayout::Millimeter).right(), 206.47);
+ QCOMPARE(tenpoint.paintRect(QPageLayout::Millimeter).top(), 3.53);
+ QCOMPARE(tenpoint.paintRect(QPageLayout::Millimeter).bottom(), 293.47);
+ QCOMPARE(tenpoint.paintRectPoints(), QRect(10, 10, 575, 822));
+ QCOMPARE(tenpoint.paintRectPixels(72), QRect(10, 10, 575, 822));
+
+ // Change orientation
+ tenpoint.setOrientation(QPageLayout::Landscape);
+ QCOMPARE(tenpoint.orientation(), QPageLayout::Landscape);
+ QCOMPARE(tenpoint.margins(), QMarginsF(10, 10, 10, 10));
+ QCOMPARE(tenpoint.minimumMargins(), QMarginsF(0, 0, 0, 0));
+ QCOMPARE(tenpoint.maximumMargins(), QMarginsF(842, 595, 842, 595));
+ QCOMPARE(tenpoint.fullRect(), QRectF(0, 0, 842, 595));
+ QCOMPARE(tenpoint.fullRect(QPageLayout::Millimeter), QRectF(0, 0, 297, 210));
+ QCOMPARE(tenpoint.fullRectPoints(), QRect(0, 0, 842, 595));
+ QCOMPARE(tenpoint.fullRectPixels(72), QRect(0, 0, 842, 595));
+ QCOMPARE(tenpoint.paintRect(), QRectF(10, 10, 822, 575));
+ QCOMPARE(tenpoint.paintRect(QPageLayout::Millimeter), QRectF(3.53, 3.53, 289.94, 202.94));
+ QCOMPARE(tenpoint.paintRectPoints(), QRect(10, 10, 822, 575));
+ QCOMPARE(tenpoint.paintRectPixels(72), QRect(10, 10, 822, 575));
+
+ // Change mode
+ QCOMPARE(tenpoint.mode(), QPageLayout::StandardMode);
+ tenpoint.setMode(QPageLayout::FullPageMode);
+ QCOMPARE(tenpoint.mode(), QPageLayout::FullPageMode);
+ QCOMPARE(tenpoint.orientation(), QPageLayout::Landscape);
+ QCOMPARE(tenpoint.margins(), QMarginsF(10, 10, 10, 10));
+ QCOMPARE(tenpoint.minimumMargins(), QMarginsF(0, 0, 0, 0));
+ QCOMPARE(tenpoint.maximumMargins(), QMarginsF(842, 595, 842, 595));
+ QCOMPARE(tenpoint.fullRect(), QRectF(0, 0, 842, 595));
+ QCOMPARE(tenpoint.fullRect(QPageLayout::Millimeter), QRectF(0, 0, 297, 210));
+ QCOMPARE(tenpoint.fullRectPoints(), QRect(0, 0, 842, 595));
+ QCOMPARE(tenpoint.fullRectPixels(72), QRect(0, 0, 842, 595));
+ QCOMPARE(tenpoint.paintRect(), QRectF(0, 0, 842, 595));
+ QCOMPARE(tenpoint.paintRect(QPageLayout::Millimeter), QRectF(0, 0, 297, 210));
+ QCOMPARE(tenpoint.paintRectPoints(), QRect(0, 0, 842, 595));
+ QCOMPARE(tenpoint.paintRectPixels(72), QRect(0, 0, 842, 595));
+}
+
+void tst_QPageLayout::setGetMargins()
+{
+ // A4, 20pt margins
+ QMarginsF margins = QMarginsF(10, 10, 10, 10);
+ QMarginsF min = QMarginsF(10, 10, 10, 10);
+ QMarginsF max = QMarginsF(585, 832, 585, 832);
+ QPageLayout change = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, margins, QPageLayout::Point, min);
+ QCOMPARE(change.isValid(), true);
+ QCOMPARE(change.margins(), margins);
+ QCOMPARE(change.margins(QPageLayout::Millimeter), QMarginsF(3.53, 3.53, 3.53, 3.53));
+ QCOMPARE(change.marginsPoints(), QMargins(10, 10, 10, 10));
+ QCOMPARE(change.marginsPixels(72), QMargins(10, 10, 10, 10));
+ QCOMPARE(change.minimumMargins(), min);
+ QCOMPARE(change.maximumMargins(), max);
+
+ // Set magins within min/max ok
+ margins = QMarginsF(20, 20, 20, 20);
+ change.setMargins(margins);
+ QCOMPARE(change.margins(QPageLayout::Millimeter), QMarginsF(7.06, 7.06, 7.06, 7.06));
+ QCOMPARE(change.marginsPoints(), QMargins(20, 20, 20, 20));
+ QCOMPARE(change.marginsPixels(72), QMargins(20, 20, 20, 20));
+ QCOMPARE(change.margins(), margins);
+
+ // Set margins all below min is rejected
+ change.setMargins(QMarginsF(0, 0, 0, 0));
+ QCOMPARE(change.margins(), margins);
+
+ // Set margins all above max is rejected
+ change.setMargins(QMarginsF(1000, 1000, 1000, 1000));
+ QCOMPARE(change.margins(), margins);
+
+ // Only 1 wrong, set still rejects
+ change.setMargins(QMarginsF(50, 50, 50, 0));
+ QCOMPARE(change.margins(), margins);
+
+ // Set page size resets min/max, clamps existing margins
+ change.setMargins(change.maximumMargins());
+ change.setPageSize(QPageSize(QPageSize::A5));
+ QCOMPARE(change.margins(), QMarginsF(420, 595, 420, 595));
+ QCOMPARE(change.minimumMargins(), QMarginsF(0, 0, 0, 0));
+ QCOMPARE(change.maximumMargins(), QMarginsF(420, 595, 420, 595));
+
+ // Set page size, sets min/max, clamps existing margins
+ margins = QMarginsF(20, 500, 20, 500);
+ change.setMargins(margins);
+ QCOMPARE(change.margins(), margins);
+ min = QMarginsF(30, 30, 30, 30);
+ max = QMarginsF(267, 390, 267, 390);
+ change.setPageSize(QPageSize(QPageSize::A6));
+ change.setMinimumMargins(min);
+ QCOMPARE(change.margins(), QMarginsF(30, 390, 30, 390));
+ QCOMPARE(change.minimumMargins(), min);
+ QCOMPARE(change.maximumMargins(), max);
+
+ // A4, 20pt margins
+ margins = QMarginsF(20, 20, 20, 20);
+ min = QMarginsF(10, 10, 10, 10);
+ max = QMarginsF(585, 832, 585, 832);
+ QPageLayout fullPage = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, margins, QPageLayout::Point, min);
+ fullPage.setMode(QPageLayout::FullPageMode);
+ QCOMPARE(fullPage.isValid(), true);
+ QCOMPARE(fullPage.margins(), margins);
+ QCOMPARE(fullPage.minimumMargins(), min);
+ QCOMPARE(fullPage.maximumMargins(), max);
+
+ // Set margins within min/max ok
+ margins = QMarginsF(50, 50, 50, 50);
+ fullPage.setMargins(margins);
+ QCOMPARE(fullPage.margins(), margins);
+
+ // Set margins all below min is accepted
+ margins = QMarginsF(0, 0, 0, 0);
+ fullPage.setMargins(margins);
+ QCOMPARE(fullPage.margins(), margins);
+
+ // Set margins all above max is rejected
+ margins = QMarginsF(1000, 1000, 1000, 1000);
+ fullPage.setMargins(margins);
+ QCOMPARE(fullPage.margins(), margins);
+
+ // Only 1 wrong, set still accepts
+ margins = QMarginsF(50, 50, 50, 0);
+ fullPage.setMargins(margins);
+ QCOMPARE(fullPage.margins(), margins);
+
+ // Set page size, sets min/max, clamps existing margins
+ margins = QMarginsF(20, 500, 20, 500);
+ fullPage.setMargins(margins);
+ QCOMPARE(fullPage.margins(), margins);
+ min = QMarginsF(30, 30, 30, 30);
+ max = QMarginsF(267, 390, 267, 390);
+ fullPage.setPageSize(QPageSize(QPageSize::A6));
+ fullPage.setMinimumMargins(min);
+ QCOMPARE(fullPage.margins(), margins);
+ QCOMPARE(fullPage.minimumMargins(), min);
+ QCOMPARE(fullPage.maximumMargins(), max);
+}
+
+QTEST_APPLESS_MAIN(tst_QPageLayout)
+
+#include "tst_qpagelayout.moc"
diff --git a/tests/auto/gui/painting/qpagesize/.gitignore b/tests/auto/gui/painting/qpagesize/.gitignore
new file mode 100644
index 0000000000..773a466f6d
--- /dev/null
+++ b/tests/auto/gui/painting/qpagesize/.gitignore
@@ -0,0 +1 @@
+tst_qpagesize
diff --git a/tests/auto/gui/painting/qpagesize/qpagesize.pro b/tests/auto/gui/painting/qpagesize/qpagesize.pro
new file mode 100644
index 0000000000..5836dc9ba0
--- /dev/null
+++ b/tests/auto/gui/painting/qpagesize/qpagesize.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+CONFIG += parallel_test
+TARGET = tst_qpagesize
+SOURCES += tst_qpagesize.cpp
+
+QT += testlib
+
+DEFINES += QT_USE_USING_NAMESPACE
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/gui/painting/qpagesize/tst_qpagesize.cpp b/tests/auto/gui/painting/qpagesize/tst_qpagesize.cpp
new file mode 100644
index 0000000000..968c5ff617
--- /dev/null
+++ b/tests/auto/gui/painting/qpagesize/tst_qpagesize.cpp
@@ -0,0 +1,258 @@
+/****************************************************************************
+**
+** 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 <QtTest/QtTest>
+#include <QtGlobal>
+#include <QtAlgorithms>
+#include <QtGui/QPageSize>
+
+#ifdef Q_OS_WIN
+#include <QtCore/qt_windows.h>
+#endif // Q_OS_WIN
+
+class tst_QPageSize : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void basics();
+ void fuzzy();
+ void custom();
+ void statics();
+};
+
+void tst_QPageSize::basics()
+{
+ // Invalid
+ QPageSize invalid = QPageSize(QPageSize::Custom);
+ QCOMPARE(invalid.isValid(), false);
+ invalid = QPageSize(QSize());
+ QCOMPARE(invalid.isValid(), false);
+ invalid = QPageSize(QSizeF(), QPageSize::Millimeter);
+ QCOMPARE(invalid.isValid(), false);
+
+ // Simple QPageSize::PaperSizeId
+ QPageSize a4 = QPageSize(QPageSize::A4);
+ QCOMPARE(a4.isValid(), true);
+ QCOMPARE(a4.key(), QString("A4"));
+ QCOMPARE(a4.name(), QString("A4"));
+ QCOMPARE(a4.id(), QPageSize::A4);
+#ifdef Q_OS_WIN
+ QCOMPARE(a4.windowsId(), DMPAPER_A4);
+#else
+ QCOMPARE(a4.windowsId(), 9); // DMPAPER_A4
+#endif
+ QCOMPARE(a4.definitionSize(), QSizeF(210, 297));
+ QCOMPARE(a4.definitionUnits(), QPageSize::Millimeter);
+ QCOMPARE(a4.size(QPageSize::Millimeter), QSizeF(210, 297));
+ QCOMPARE(a4.size(QPageSize::Inch), QSizeF(8.27, 11.69));
+ QCOMPARE(a4.size(QPageSize::Pica), QSizeF(49.58, 70.17));
+ QCOMPARE(a4.sizePoints(), QSize(595, 842));
+ QCOMPARE(a4.sizePixels(72), QSize(595, 842));
+ QCOMPARE(a4.rect(QPageSize::Millimeter), QRectF(0, 0, 210, 297));
+ QCOMPARE(a4.rect(QPageSize::Inch), QRectF(0, 0, 8.27, 11.69));
+ QCOMPARE(a4.rect(QPageSize::Pica), QRectF(0, 0, 49.58, 70.17));
+ QCOMPARE(a4.rectPoints(), QRect(0, 0, 595, 842));
+ QCOMPARE(a4.rectPixels(72), QRect(0, 0, 595, 842));
+
+ // Simple QPageSize::PaperSizeId later in list
+ QPageSize folio = QPageSize(QPageSize::Folio);
+ QCOMPARE(folio.isValid(), true);
+ QCOMPARE(folio.key(), QString("Folio"));
+ QCOMPARE(folio.name(), QString("Folio (8.27 x 13 in)"));
+ QCOMPARE(folio.id(), QPageSize::Folio);
+ QCOMPARE(folio.definitionSize(), QSizeF(210, 330));
+ QCOMPARE(folio.definitionUnits(), QPageSize::Millimeter);
+ QCOMPARE(folio.size(QPageSize::Millimeter), QSizeF(210, 330));
+ QCOMPARE(folio.sizePoints(), QSize(595, 935));
+ QCOMPARE(folio.sizePixels(72), QSize(595, 935));
+ QCOMPARE(folio.size(QPageSize::Inch), QSizeF(8.27, 13));
+
+ // Simple QPageSize::PaperSizeId last in list
+ QPageSize you4 = QPageSize(QPageSize::EnvelopeYou4);
+ QCOMPARE(you4.isValid(), true);
+ QCOMPARE(you4.key(), QString("EnvYou4"));
+ QCOMPARE(you4.name(), QString("Envelope You 4"));
+ QCOMPARE(you4.id(), QPageSize::EnvelopeYou4);
+#ifdef Q_OS_WIN
+ QCOMPARE(you4.windowsId(), DMPAPER_JENV_YOU4);
+#else
+ QCOMPARE(you4.windowsId(), 91);
+#endif
+ QCOMPARE(you4.size(QPageSize::Millimeter), QSizeF(105, 235));
+ QCOMPARE(you4.size(QPageSize::Inch), QSizeF(4.13, 9.25));
+ QCOMPARE(you4.sizePoints(), QSize(298, 666));
+ QCOMPARE(you4.sizePixels(72), QSize(298, 666));
+
+ // Simple QSize in Points
+ QPageSize a4b = QPageSize(QSize(595, 842));
+ QCOMPARE(a4b.isValid(), true);
+ QCOMPARE(a4b.id(), QPageSize::A4);
+ QCOMPARE(a4b.sizePoints(), QSize(595, 842));
+
+ // Simple QSize in Points later in list, custom name
+ QPageSize folio2 = QPageSize(QSize(595, 935), QStringLiteral("Folio2"));
+ QCOMPARE(folio2.isValid(), true);
+ QCOMPARE(folio2.name(), QString("Folio2"));
+ QCOMPARE(folio2.id(), QPageSize::Folio);
+ QCOMPARE(folio2.sizePoints(), QSize(595, 935));
+
+ // Comparisons
+ QCOMPARE((a4 == folio), false);
+ QCOMPARE((a4.isEquivalentTo(folio)), false);
+ QCOMPARE((a4 == a4b), true);
+ QCOMPARE((a4.isEquivalentTo(a4b)), true);
+ QCOMPARE((folio == folio2), false); // Name different
+ QCOMPARE((folio.isEquivalentTo(folio2)), true);
+
+ // Simple QSize in Millimeters
+ QPageSize folio3 = QPageSize(QSizeF(210, 330), QPageSize::Millimeter);
+ QCOMPARE(folio3.isValid(), true);
+ QCOMPARE(folio3.id(), QPageSize::Folio);
+ QCOMPARE(folio3.sizePoints(), QSize(595, 935));
+}
+
+void tst_QPageSize::fuzzy()
+{
+ // Using FuzzyMatch by default
+
+ // Simple QSize within 3 Points
+ QPageSize a4a = QPageSize(QSize(592, 845));
+ QCOMPARE(a4a.isValid(), true);
+ QCOMPARE(a4a.id(), QPageSize::A4);
+ QCOMPARE(a4a.sizePoints(), QSize(595, 842));
+
+ // Simple QSizeF within 1mm
+ QPageSize a4b = QPageSize(QSizeF(211, 298), QPageSize::Millimeter);
+ QCOMPARE(a4b.isValid(), true);
+ QCOMPARE(a4b.id(), QPageSize::A4);
+ QCOMPARE(a4b.size(QPageSize::Millimeter), QSizeF(210, 297));
+ QCOMPARE(a4b.sizePoints(), QSize(595, 842));
+
+ // Using FuzzyOrientationMatch
+
+ // Exact A4 in landscape mode
+ QPageSize a4l = QPageSize(QSize(842, 595));
+ QCOMPARE(a4l.isValid(), true);
+ QCOMPARE(a4l.id(), QPageSize::Custom);
+ QCOMPARE(a4l.sizePoints(), QSize(842, 595));
+
+ a4l = QPageSize(QSize(842, 595), QString(), QPageSize::FuzzyOrientationMatch);
+ QCOMPARE(a4l.isValid(), true);
+ QCOMPARE(a4l.id(), QPageSize::A4);
+ QCOMPARE(a4l.sizePoints(), QSize(595, 842));
+
+ // Using ExactMatch
+
+ // Simple QSize within 3 Points
+ QPageSize a4d = QPageSize(QSize(592, 845), QString(), QPageSize::ExactMatch);
+ QCOMPARE(a4d.isValid(), true);
+ QCOMPARE(a4d.id(), QPageSize::Custom);
+ QCOMPARE(a4d.sizePoints(), QSize(592, 845));
+
+ // Simple QSizeF within 1mm
+ QPageSize a4e = QPageSize(QSizeF(211, 298), QPageSize::Millimeter, QString(), QPageSize::ExactMatch);
+ QCOMPARE(a4e.isValid(), true);
+ QCOMPARE(a4e.id(), QPageSize::Custom);
+ QCOMPARE(a4e.size(QPageSize::Millimeter), QSizeF(211, 298));
+ QCOMPARE(a4e.sizePoints(), QSize(598, 845));
+}
+
+void tst_QPageSize::custom()
+{
+ // Simple non-standard Points QSize
+ QPageSize custom1 = QPageSize(QSize(500, 600));
+ QCOMPARE(custom1.isValid(), true);
+ QCOMPARE(custom1.key(), QString("Custom.500x600"));
+ QCOMPARE(custom1.name(), QString("Custom (500pt x 600pt)"));
+ QCOMPARE(custom1.id(), QPageSize::Custom);
+ QCOMPARE(custom1.definitionSize(), QSizeF(500, 600));
+ QCOMPARE(custom1.definitionUnits(), QPageSize::Point);
+ QCOMPARE(custom1.size(QPageSize::Millimeter), QSizeF(176.39, 211.67));
+ QCOMPARE(custom1.size(QPageSize::Pica), QSizeF(41.67, 50));
+ QCOMPARE(custom1.sizePoints(), QSize(500, 600));
+ QCOMPARE(custom1.sizePixels(72), QSize(500, 600));
+
+ // Simple non-standard MM QSizeF
+ QPageSize custom2 = QPageSize(QSizeF(500.3, 600.57), QPageSize::Millimeter);
+ QCOMPARE(custom2.isValid(), true);
+ QCOMPARE(custom2.key(), QString("Custom.500.3x600.57mm"));
+ QCOMPARE(custom2.name(), QString("Custom (500.3mm x 600.57mm)"));
+ QCOMPARE(custom2.id(), QPageSize::Custom);
+ QCOMPARE(custom2.definitionSize(), QSizeF(500.3, 600.57));
+ QCOMPARE(custom2.definitionUnits(), QPageSize::Millimeter);
+ QCOMPARE(custom2.size(QPageSize::Millimeter), QSizeF(500.3, 600.57));
+ QCOMPARE(custom2.size(QPageSize::Pica), QSizeF(118.18, 141.87));
+ QCOMPARE(custom2.sizePoints(), QSize(1418, 1702));
+ QCOMPARE(custom2.sizePixels(72), QSize(1418, 1702));
+}
+
+void tst_QPageSize::statics()
+{
+ QCOMPARE(QPageSize::key(QPageSize::EnvelopeYou4), QString("EnvYou4"));
+ QCOMPARE(QPageSize::name(QPageSize::EnvelopeYou4), QString("Envelope You 4"));
+
+#ifdef Q_OS_WIN
+ QCOMPARE(QPageSize::windowsId(QPageSize::EnvelopeYou4), DMPAPER_JENV_YOU4);
+ QCOMPARE(QPageSize::id(DMPAPER_JENV_YOU4), QPageSize::EnvelopeYou4);
+ QCOMPARE(QPageSize::id(DMPAPER_A4_ROTATED), QPageSize::A4);
+#else
+ QCOMPARE(QPageSize::windowsId(QPageSize::EnvelopeYou4), 91);
+ QCOMPARE(QPageSize::id(91), QPageSize::EnvelopeYou4);
+ QCOMPARE(QPageSize::id(77), QPageSize::A4);
+#endif
+
+ QCOMPARE(QPageSize::id(QSize(298, 666)), QPageSize::EnvelopeYou4);
+ QCOMPARE(QPageSize::id(QSizeF(105, 235), QPageSize::Millimeter), QPageSize::EnvelopeYou4);
+
+ QCOMPARE(QPageSize::definitionSize(QPageSize::Letter), QSizeF(8.5, 11));
+ QCOMPARE(QPageSize::definitionUnits(QPageSize::Letter), QPageSize::Inch);
+ QCOMPARE(QPageSize::definitionSize(QPageSize::EnvelopeYou4), QSizeF(105, 235));
+ QCOMPARE(QPageSize::definitionUnits(QPageSize::EnvelopeYou4), QPageSize::Millimeter);
+
+ QCOMPARE(QPageSize::size(QPageSize::EnvelopeYou4, QPageSize::Millimeter), QSizeF(105, 235));
+ QCOMPARE(QPageSize::sizePoints(QPageSize::EnvelopeYou4), QSize(298, 666));
+ QCOMPARE(QPageSize::sizePixels(QPageSize::EnvelopeYou4, 72), QSize(298, 666));
+}
+
+QTEST_APPLESS_MAIN(tst_QPageSize)
+
+#include "tst_qpagesize.moc"
diff --git a/tests/auto/gui/painting/qpdfwriter/.gitignore b/tests/auto/gui/painting/qpdfwriter/.gitignore
new file mode 100644
index 0000000000..5307a5ed2a
--- /dev/null
+++ b/tests/auto/gui/painting/qpdfwriter/.gitignore
@@ -0,0 +1 @@
+tst_qpdfwriter
diff --git a/tests/auto/gui/painting/qpdfwriter/qpdfwriter.pro b/tests/auto/gui/painting/qpdfwriter/qpdfwriter.pro
new file mode 100644
index 0000000000..fda0fad3b5
--- /dev/null
+++ b/tests/auto/gui/painting/qpdfwriter/qpdfwriter.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+CONFIG += parallel_test
+TARGET = tst_qpdfwriter
+SOURCES += tst_qpdfwriter.cpp
+
+QT += gui-private testlib
+
+DEFINES += QT_USE_USING_NAMESPACE
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp b/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp
new file mode 100644
index 0000000000..f06351b7b7
--- /dev/null
+++ b/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp
@@ -0,0 +1,265 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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 <QtTest/QtTest>
+#include <QtGlobal>
+#include <QtAlgorithms>
+#include <QtGui/QPageLayout>
+#include <QtGui/QPdfWriter>
+
+class tst_QPdfWriter : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void basics();
+ void testPageMetrics_data();
+ void testPageMetrics();
+};
+
+void tst_QPdfWriter::basics()
+{
+ QTemporaryFile file;
+ if (!file.open())
+ QSKIP("Couldn't open temp file!");
+ QPdfWriter writer(file.fileName());
+
+ QCOMPARE(writer.title(), QString());
+ writer.setTitle(QString("Test Title"));
+ QCOMPARE(writer.title(), QString("Test Title"));
+
+ QCOMPARE(writer.creator(), QString());
+ writer.setCreator(QString("Test Creator"));
+ QCOMPARE(writer.creator(), QString("Test Creator"));
+
+ QCOMPARE(writer.resolution(), 1200);
+ writer.setResolution(600);
+ QCOMPARE(writer.resolution(), 600);
+
+ QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::A4);
+ QCOMPARE(writer.pageSize(), QPdfWriter::A4);
+ QCOMPARE(writer.pageSizeMM(), QSizeF(210, 297));
+
+ writer.setPageSize(QPageSize(QPageSize::A5));
+ QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::A5);
+ QCOMPARE(writer.pageSize(), QPdfWriter::A5);
+ QCOMPARE(writer.pageSizeMM(), QSizeF(148, 210));
+
+ writer.setPageSize(QPdfWriter::A3);
+ QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::A3);
+ QCOMPARE(writer.pageSize(), QPdfWriter::A3);
+ QCOMPARE(writer.pageSizeMM(), QSizeF(297, 420));
+
+ writer.setPageSizeMM(QSize(210, 297));
+ QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::A4);
+ QCOMPARE(writer.pageSize(), QPdfWriter::A4);
+ QCOMPARE(writer.pageSizeMM(), QSizeF(210, 297));
+
+ QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Portrait);
+ writer.setPageOrientation(QPageLayout::Landscape);
+ QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Landscape);
+ QCOMPARE(writer.pageSizeMM(), QSizeF(210, 297));
+
+ QCOMPARE(writer.pageLayout().margins(), QMarginsF(10, 10, 10, 10));
+ QCOMPARE(writer.pageLayout().units(), QPageLayout::Point);
+ QCOMPARE(writer.margins().left, 3.53); // mm
+ QCOMPARE(writer.margins().right, 3.53);
+ QCOMPARE(writer.margins().top, 3.53);
+ QCOMPARE(writer.margins().bottom, 3.53);
+ writer.setPageMargins(QMarginsF(20, 20, 20, 20), QPageLayout::Millimeter);
+ QCOMPARE(writer.pageLayout().margins(), QMarginsF(20, 20, 20, 20));
+ QCOMPARE(writer.pageLayout().units(), QPageLayout::Millimeter);
+ QCOMPARE(writer.margins().left, 20.0);
+ QCOMPARE(writer.margins().right, 20.0);
+ QCOMPARE(writer.margins().top, 20.0);
+ QCOMPARE(writer.margins().bottom, 20.0);
+ QPdfWriter::Margins margins = {50, 50, 50, 50};
+ writer.setMargins(margins);
+ QCOMPARE(writer.pageLayout().margins(), QMarginsF(50, 50, 50, 50));
+ QCOMPARE(writer.pageLayout().units(), QPageLayout::Millimeter);
+ QCOMPARE(writer.margins().left, 50.0);
+ QCOMPARE(writer.margins().right, 50.0);
+ QCOMPARE(writer.margins().top, 50.0);
+ QCOMPARE(writer.margins().bottom, 50.0);
+
+ QCOMPARE(writer.pageLayout().fullRect(QPageLayout::Millimeter), QRectF(0, 0, 297, 210));
+ QCOMPARE(writer.pageLayout().paintRect(QPageLayout::Millimeter), QRectF(50, 50, 197, 110));
+}
+
+// Test the old page metrics methods, see also QPrinter tests for the same.
+void tst_QPdfWriter::testPageMetrics_data()
+{
+ QTest::addColumn<int>("pageSize");
+ QTest::addColumn<qreal>("widthMMf");
+ QTest::addColumn<qreal>("heightMMf");
+ QTest::addColumn<bool>("setMargins");
+ QTest::addColumn<qreal>("leftMMf");
+ QTest::addColumn<qreal>("rightMMf");
+ QTest::addColumn<qreal>("topMMf");
+ QTest::addColumn<qreal>("bottomMMf");
+
+ QTest::newRow("A4") << int(QPdfWriter::A4) << 210.0 << 297.0 << false << 3.53 << 3.53 << 3.53 << 3.53;
+ QTest::newRow("A4 Margins") << int(QPdfWriter::A4) << 210.0 << 297.0 << true << 20.0 << 30.0 << 40.0 << 50.0;
+ QTest::newRow("Portrait") << -1 << 345.0 << 678.0 << false << 3.53 << 3.53 << 3.53 << 3.53;
+ QTest::newRow("Portrait Margins") << -1 << 345.0 << 678.0 << true << 20.0 << 30.0 << 40.0 << 50.0;
+ QTest::newRow("Landscape") << -1 << 678.0 << 345.0 << false << 3.53 << 3.53 << 3.53 << 3.53;
+ QTest::newRow("Landscape Margins") << -1 << 678.0 << 345.0 << true << 20.0 << 30.0 << 40.0 << 50.0;
+}
+
+void tst_QPdfWriter::testPageMetrics()
+{
+ QFETCH(int, pageSize);
+ QFETCH(qreal, widthMMf);
+ QFETCH(qreal, heightMMf);
+ QFETCH(bool, setMargins);
+ QFETCH(qreal, leftMMf);
+ QFETCH(qreal, rightMMf);
+ QFETCH(qreal, topMMf);
+ QFETCH(qreal, bottomMMf);
+
+ QSizeF sizeMMf = QSizeF(widthMMf, heightMMf);
+
+ QTemporaryFile file;
+ if (!file.open())
+ QSKIP("Couldn't open temp file!");
+ QPdfWriter writer(file.fileName());
+ QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Portrait);
+
+ if (setMargins) {
+ // Setup the given margins
+ QPdfWriter::Margins margins;
+ margins.left = leftMMf;
+ margins.right = rightMMf;
+ margins.top = topMMf;
+ margins.bottom = bottomMMf;
+ writer.setMargins(margins);
+ QCOMPARE(writer.margins().left, leftMMf);
+ QCOMPARE(writer.margins().right, rightMMf);
+ QCOMPARE(writer.margins().top, topMMf);
+ QCOMPARE(writer.margins().bottom, bottomMMf);
+ }
+
+
+ // Set the given size, in Portrait mode
+ if (pageSize < 0) {
+ writer.setPageSizeMM(sizeMMf);
+ QCOMPARE(writer.pageSize(), QPdfWriter::Custom);
+ QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::Custom);
+ } else {
+ writer.setPageSize(QPdfWriter::PageSize(pageSize));
+ QCOMPARE(writer.pageSize(), QPdfWriter::PageSize(pageSize));
+ QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::PageSizeId(pageSize));
+ }
+ QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Portrait);
+ QCOMPARE(writer.margins().left, leftMMf);
+ QCOMPARE(writer.margins().right, rightMMf);
+ QCOMPARE(writer.margins().top, topMMf);
+ QCOMPARE(writer.margins().bottom, bottomMMf);
+
+ // QPagedPaintDevice::pageSizeMM() always returns Portrait
+ QCOMPARE(writer.pageSizeMM(), sizeMMf);
+
+ // QPagedPaintDevice::widthMM() and heightMM() are paint metrics and always return set orientation
+ QCOMPARE(writer.widthMM(), qRound(widthMMf - leftMMf - rightMMf));
+ QCOMPARE(writer.heightMM(), qRound(heightMMf - topMMf - bottomMMf));
+
+ // Now switch to Landscape mode, size should be unchanged, but rect and metrics should change
+ writer.setPageOrientation(QPageLayout::Landscape);
+ if (pageSize < 0) {
+ QCOMPARE(writer.pageSize(), QPdfWriter::Custom);
+ QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::Custom);
+ } else {
+ QCOMPARE(writer.pageSize(), QPdfWriter::PageSize(pageSize));
+ QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::PageSizeId(pageSize));
+ }
+ QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Landscape);
+ QCOMPARE(writer.margins().left, leftMMf);
+ QCOMPARE(writer.margins().right, rightMMf);
+ QCOMPARE(writer.margins().top, topMMf);
+ QCOMPARE(writer.margins().bottom, bottomMMf);
+
+ // QPagedPaintDevice::pageSizeMM() always returns Portrait
+ QCOMPARE(writer.pageSizeMM(), sizeMMf);
+
+ // QPagedPaintDevice::widthMM() and heightMM() are paint metrics and always return set orientation
+ QCOMPARE(writer.widthMM(), qRound(heightMMf - leftMMf - rightMMf));
+ QCOMPARE(writer.heightMM(), qRound(widthMMf - topMMf - bottomMMf));
+
+ // QPdfWriter::fullRect() always returns set orientation
+ QCOMPARE(writer.pageLayout().fullRect(QPageLayout::Millimeter), QRectF(0, 0, heightMMf, widthMMf));
+
+ // QPdfWriter::paintRect() always returns set orientation
+ QCOMPARE(writer.pageLayout().paintRect(QPageLayout::Millimeter), QRectF(leftMMf, topMMf, heightMMf - leftMMf - rightMMf, widthMMf - topMMf - bottomMMf));
+
+
+ // Now while in Landscape mode, set the size again, results should be the same
+ if (pageSize < 0) {
+ writer.setPageSizeMM(sizeMMf);
+ QCOMPARE(writer.pageSize(), QPdfWriter::Custom);
+ QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::Custom);
+ } else {
+ writer.setPageSize(QPdfWriter::PageSize(pageSize));
+ QCOMPARE(writer.pageSize(), QPdfWriter::PageSize(pageSize));
+ QCOMPARE(writer.pageLayout().pageSize().id(), QPageSize::PageSizeId(pageSize));
+ }
+ QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Landscape);
+ QCOMPARE(writer.margins().left, leftMMf);
+ QCOMPARE(writer.margins().right, rightMMf);
+ QCOMPARE(writer.margins().top, topMMf);
+ QCOMPARE(writer.margins().bottom, bottomMMf);
+
+ // QPagedPaintDevice::pageSizeMM() always returns Portrait
+ QCOMPARE(writer.pageSizeMM(), sizeMMf);
+
+ // QPagedPaintDevice::widthMM() and heightMM() are paint metrics and always return set orientation
+ QCOMPARE(writer.widthMM(), qRound(heightMMf - leftMMf - rightMMf));
+ QCOMPARE(writer.heightMM(), qRound(widthMMf - topMMf - bottomMMf));
+
+ // QPdfWriter::fullRect() always returns set orientation
+ QCOMPARE(writer.pageLayout().fullRect(QPageLayout::Millimeter), QRectF(0, 0, heightMMf, widthMMf));
+
+ // QPdfWriter::paintRect() always returns set orientation
+ QCOMPARE(writer.pageLayout().paintRect(QPageLayout::Millimeter), QRectF(leftMMf, topMMf, heightMMf - leftMMf - rightMMf, widthMMf - topMMf - bottomMMf));
+}
+
+QTEST_MAIN(tst_QPdfWriter)
+
+#include "tst_qpdfwriter.moc"
diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp
index 975c2acefd..4018c00a38 100644
--- a/tests/auto/gui/qopengl/tst_qopengl.cpp
+++ b/tests/auto/gui/qopengl/tst_qopengl.cpp
@@ -78,6 +78,7 @@ private slots:
void openGLPaintDevice_data();
void openGLPaintDevice();
void aboutToBeDestroyed();
+ void sizeLessWindow();
void QTBUG15621_triangulatingStrokerDivZero();
void textureblitterFullSourceRectTransform();
void textureblitterPartOriginBottomLeftSourceRectTransform();
@@ -645,6 +646,43 @@ void tst_QOpenGL::aboutToBeDestroyed()
QCOMPARE(spy.size(), 1);
}
+// Verify that QOpenGLContext works with QWindows that do
+// not have an explicit size set.
+void tst_QOpenGL::sizeLessWindow()
+{
+ // top-level window
+ {
+ QWindow window;
+ window.setSurfaceType(QWindow::OpenGLSurface);
+
+ QOpenGLContext context;
+ QVERIFY(context.create());
+
+ window.show();
+ QVERIFY(context.makeCurrent(&window));
+ QVERIFY(QOpenGLContext::currentContext());
+ }
+
+ QVERIFY(!QOpenGLContext::currentContext());
+
+ // child window
+ {
+ QWindow parent;
+ QWindow window(&parent);
+ window.setSurfaceType(QWindow::OpenGLSurface);
+
+ QOpenGLContext context;
+ QVERIFY(context.create());
+
+ parent.show();
+ window.show();
+ QVERIFY(context.makeCurrent(&window));
+ QVERIFY(QOpenGLContext::currentContext());
+ }
+
+ QVERIFY(!QOpenGLContext::currentContext());
+}
+
void tst_QOpenGL::QTBUG15621_triangulatingStrokerDivZero()
{
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(__x86_64__)
diff --git a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp
index 46f97840af..4ae70fe137 100644
--- a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp
+++ b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp
@@ -87,6 +87,7 @@ private slots:
void plainTextVsRichText();
+ void setPenPlainText_data();
void setPenPlainText();
void setPenRichText();
void richTextOverridesPen();
@@ -106,6 +107,8 @@ private:
QImage const m_whiteSquare;
};
+Q_DECLARE_METATYPE(QImage::Format);
+
void tst_QStaticText::initTestCase()
{
// a "blank" square; we compare against in our testfunctions to verify
@@ -615,30 +618,41 @@ void tst_QStaticText::plainTextVsRichText()
QCOMPARE(imagePlainText, imageRichText);
}
+void tst_QStaticText::setPenPlainText_data()
+{
+ QTest::addColumn<QImage::Format>("format");
+
+ QTest::newRow("argb32pm") << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("rgb32") << QImage::Format_RGB32;
+ QTest::newRow("rgba8888pm") << QImage::Format_RGBA8888_Premultiplied;
+ QTest::newRow("rgbx8888") << QImage::Format_RGBX8888;
+}
+
void tst_QStaticText::setPenPlainText()
{
+ QFETCH(QImage::Format, format);
+
QFont font = QGuiApplication::font();
font.setStyleStrategy(QFont::NoAntialias);
QFontMetricsF fm(font);
- QPixmap image(qCeil(fm.width("XXXXX")), qCeil(fm.height()));
+ QImage image(qCeil(fm.width("XXXXX")), qCeil(fm.height()), format);
image.fill(Qt::white);
{
QPainter p(&image);
p.setFont(font);
- p.setPen(Qt::green);
+ p.setPen(Qt::yellow);
QStaticText staticText("XXXXX");
staticText.setTextFormat(Qt::PlainText);
p.drawStaticText(0, 0, staticText);
}
- QImage img = image.toImage();
- for (int x=0; x<img.width(); ++x) {
- for (int y=0; y<img.height(); ++y) {
- QRgb pixel = img.pixel(x, y);
+ for (int x=0; x<image.width(); ++x) {
+ for (int y=0; y<image.height(); ++y) {
+ QRgb pixel = image.pixel(x, y);
QVERIFY(pixel == QColor(Qt::white).rgba()
- || pixel == QColor(Qt::green).rgba());
+ || pixel == QColor(Qt::yellow).rgba());
}
}
}
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index c448e89375..11ea8aebc8 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -545,9 +545,11 @@ public:
multiple(false), totalConnections(0)
{
if (useipv6) {
- listen(QHostAddress::AnyIPv6);
+ if (!listen(QHostAddress::AnyIPv6))
+ qWarning() << "listen() IPv6 failed" << errorString();
} else {
- listen(QHostAddress::AnyIPv4);
+ if (!listen(QHostAddress::AnyIPv4))
+ qWarning() << "listen() IPv4 failed" << errorString();
}
if (thread) {
connect(thread, SIGNAL(started()), this, SLOT(threadStartedSlot()));
@@ -1377,6 +1379,22 @@ QString tst_QNetworkReply::runCustomRequest(const QNetworkRequest &request,
return QString();
}
+static QByteArray msgWaitForFinished(QNetworkReplyPtr &reply)
+{
+ QString result;
+ QDebug debug(&result);
+ debug << reply->url();
+ if (reply->isFinished()) {
+ if (reply->error() == QNetworkReply::NoError)
+ debug << "finished.";
+ else
+ debug << "failed: #" << reply->error() << reply->errorString();
+ } else {
+ debug << "timed out.";
+ }
+ return result.toLocal8Bit();
+}
+
int tst_QNetworkReply::waitForFinish(QNetworkReplyPtr &reply)
{
int count = 0;
@@ -2839,7 +2857,7 @@ void tst_QNetworkReply::connectToIPv6Address()
QNetworkRequest request(url);
QNetworkReplyPtr reply(manager.get(request));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QByteArray content = reply->readAll();
//qDebug() << server.receivedData;
QByteArray hostinfo = "\r\nHost: " + hostfield + ":" + QByteArray::number(server.serverPort()) + "\r\n";
@@ -3020,7 +3038,7 @@ void tst_QNetworkReply::ioGetFromFtp()
QNetworkReplyPtr reply(manager.get(request));
DataReader reader(reply);
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QCOMPARE(reply->url(), request.url());
QCOMPARE(reply->error(), QNetworkReply::NoError);
@@ -3075,7 +3093,7 @@ void tst_QNetworkReply::ioGetFromHttp()
QNetworkReplyPtr reply(manager.get(request));
DataReader reader(reply);
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QCOMPARE(reply->url(), request.url());
QCOMPARE(reply->error(), QNetworkReply::NoError);
@@ -3129,7 +3147,7 @@ void tst_QNetworkReply::ioGetFromHttpWithReuseSequential()
QNetworkReplyPtr reply(manager.get(request));
DataReader reader(reply);
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QCOMPARE(reply->url(), request.url());
QCOMPARE(reply->error(), QNetworkReply::NoError);
@@ -3147,7 +3165,7 @@ void tst_QNetworkReply::ioGetFromHttpWithReuseSequential()
QNetworkReplyPtr reply(manager.get(request));
DataReader reader(reply);
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QCOMPARE(reply->url(), request.url());
QCOMPARE(reply->error(), QNetworkReply::NoError);
@@ -3226,7 +3244,7 @@ void tst_QNetworkReply::ioGetFromHttpWithAuth()
connect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*)));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
manager.disconnect(SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
this, SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*)));
@@ -3359,7 +3377,7 @@ void tst_QNetworkReply::ioGetFromHttpWithProxyAuth()
connect(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
manager.disconnect(SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
@@ -3432,7 +3450,7 @@ void tst_QNetworkReply::ioGetFromHttpWithSocksProxy()
connect(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
manager.disconnect(SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
@@ -3487,7 +3505,7 @@ void tst_QNetworkReply::ioGetFromHttpsWithSslErrors()
SLOT(sslErrors(QNetworkReply*,QList<QSslError>)));
connect(reply, SIGNAL(metaDataChanged()), SLOT(storeSslConfiguration()));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
manager.disconnect(SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),
this, SLOT(sslErrors(QNetworkReply*,QList<QSslError>)));
@@ -3518,7 +3536,7 @@ void tst_QNetworkReply::ioGetFromHttpsWithIgnoreSslErrors()
QSignalSpy sslspy(&manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)));
connect(reply, SIGNAL(metaDataChanged()), SLOT(storeSslConfiguration()));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
QCOMPARE(reader.data, reference.readAll());
@@ -3631,7 +3649,7 @@ void tst_QNetworkReply::ioGetFromHttpStatus100()
QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort())));
QNetworkReplyPtr reply(manager.get(request));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QCOMPARE(reply->url(), request.url());
QCOMPARE(reply->error(), QNetworkReply::NoError);
@@ -3654,7 +3672,7 @@ void tst_QNetworkReply::ioGetFromHttpNoHeaders()
QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort())));
QNetworkReplyPtr reply(manager.get(request));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QCOMPARE(reply->url(), request.url());
QCOMPARE(reply->error(), QNetworkReply::NoError);
@@ -4118,7 +4136,7 @@ void tst_QNetworkReply::ioPutToFileFromFile()
QNetworkRequest request(url);
QNetworkReplyPtr reply(manager.put(request, &sourceFile));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QCOMPARE(reply->url(), url);
QCOMPARE(reply->error(), QNetworkReply::NoError);
@@ -4153,7 +4171,7 @@ void tst_QNetworkReply::ioPutToFileFromSocket()
QNetworkReplyPtr reply(manager.put(QNetworkRequest(url), socketpair.endPoints[1]));
socketpair.endPoints[0]->close();
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QCOMPARE(reply->error(), QNetworkReply::NoError);
QCOMPARE(reply->url(), url);
@@ -4201,7 +4219,7 @@ void tst_QNetworkReply::ioPutToFileFromLocalSocket()
if (!data.isEmpty())
QEXPECT_FAIL("", "QTBUG-18385", Abort);
#endif
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QCOMPARE(reply->error(), QNetworkReply::NoError);
QCOMPARE(reply->url(), url);
@@ -4249,7 +4267,7 @@ void tst_QNetworkReply::ioPutToFileFromProcess()
QNetworkReplyPtr reply(manager.put(QNetworkRequest(url), &process));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QCOMPARE(reply->url(), url);
QCOMPARE(reply->error(), QNetworkReply::NoError);
@@ -4283,7 +4301,7 @@ void tst_QNetworkReply::ioPutToFtpFromFile()
QNetworkRequest request(url);
QNetworkReplyPtr reply(manager.put(request, &sourceFile));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QCOMPARE(reply->url(), url);
QCOMPARE(reply->error(), QNetworkReply::NoError);
@@ -4332,7 +4350,7 @@ void tst_QNetworkReply::ioPutToHttpFromFile()
QNetworkRequest request(url);
QNetworkReplyPtr reply(manager.put(request, &sourceFile));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QCOMPARE(reply->url(), url);
QCOMPARE(reply->error(), QNetworkReply::NoError);
@@ -4347,7 +4365,7 @@ void tst_QNetworkReply::ioPutToHttpFromFile()
// correctly
reply.reset(manager.get(request));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QCOMPARE(reply->url(), url);
QCOMPARE(reply->error(), QNetworkReply::NoError);
@@ -4373,7 +4391,7 @@ void tst_QNetworkReply::ioPostToHttpFromFile()
QNetworkReplyPtr reply(manager.post(request, &sourceFile));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QCOMPARE(reply->url(), url);
QCOMPARE(reply->error(), QNetworkReply::NoError);
@@ -4460,7 +4478,7 @@ void tst_QNetworkReply::ioPostToHttpFromSocket()
QSignalSpy authenticationRequiredSpy(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)));
QSignalSpy proxyAuthenticationRequiredSpy(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
disconnect(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
@@ -4557,7 +4575,7 @@ void tst_QNetworkReply::ioPostToHttpFromMiddleOfFileToEnd()
connect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*)));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
disconnect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
this, SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*)));
@@ -4586,7 +4604,7 @@ void tst_QNetworkReply::ioPostToHttpFromMiddleOfFileFiveBytes()
connect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*)));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
disconnect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
this, SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*)));
@@ -4614,7 +4632,7 @@ void tst_QNetworkReply::ioPostToHttpFromMiddleOfQBufferFiveBytes()
connect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*)));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
disconnect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
this, SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*)));
@@ -4754,7 +4772,7 @@ void tst_QNetworkReply::ioPostToHttpsUploadProgress()
incomingSocket->write("Content-Length: 0\r\n");
incomingSocket->write("\r\n");
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
incomingSocket->close();
server.close();
@@ -4813,7 +4831,7 @@ void tst_QNetworkReply::ioGetFromBuiltinHttp()
QTime loopTime;
loopTime.start();
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
const int elapsedTime = loopTime.elapsed();
server.wait();
@@ -4968,7 +4986,7 @@ void tst_QNetworkReply::lastModifiedHeaderForFile()
QNetworkRequest request(url);
QNetworkReplyPtr reply(manager.head(request));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QDateTime header = reply->header(QNetworkRequest::LastModifiedHeader).toDateTime();
QCOMPARE(header, fileInfo.lastModified());
@@ -4982,7 +5000,7 @@ void tst_QNetworkReply::lastModifiedHeaderForHttp()
QNetworkRequest request(url);
QNetworkReplyPtr reply(manager.head(request));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QDateTime header = reply->header(QNetworkRequest::LastModifiedHeader).toDateTime();
QDateTime realDate = QDateTime::fromString("2007-05-22T12:04:57", Qt::ISODate);
@@ -4996,7 +5014,7 @@ void tst_QNetworkReply::httpCanReadLine()
QNetworkRequest request(QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt"));
QNetworkReplyPtr reply(manager.get(request));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QCOMPARE(reply->error(), QNetworkReply::NoError);
@@ -5042,7 +5060,7 @@ void tst_QNetworkReply::rateControl()
QTime loopTime;
loopTime.start();
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
int elapsedTime = loopTime.elapsed();
@@ -5167,7 +5185,7 @@ void tst_QNetworkReply::uploadProgress()
QTcpSocket *receiver = server.nextPendingConnection();
if (finished.count() == 0) {
// it's not finished yet, so wait for it to be
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
}
delete receiver;
@@ -6412,7 +6430,7 @@ void tst_QNetworkReply::getFromHttpIntoBufferCanReadLine()
request.setAttribute(QNetworkRequest::MaximumDownloadBufferSizeAttribute, 1024*1024*128); // 128 MB is max allowed
QNetworkReplyPtr reply(manager.get(request));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QCOMPARE(reply->error(), QNetworkReply::NoError);
QVERIFY(reply->canReadLine());
@@ -6436,7 +6454,7 @@ void tst_QNetworkReply::ioGetFromHttpWithoutContentLength()
QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort())));
QNetworkReplyPtr reply(manager.get(request));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QCOMPARE(reply->url(), request.url());
QVERIFY(reply->isFinished());
@@ -6484,7 +6502,7 @@ void tst_QNetworkReply::qtbug12908compressedHttpReply()
QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort())));
QNetworkReplyPtr reply(manager.get(request));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QCOMPARE(reply->error(), QNetworkReply::NoError);
QCOMPARE(reply->size(), qint64(16384));
@@ -6826,7 +6844,7 @@ void tst_QNetworkReply::httpWithNoCredentialUsage()
{
QNetworkRequest request(QUrl("http://httptest:httptest@" + QtNetworkSettings::serverName() + "/qtest/protected/cgi-bin/md5sum.cgi"));
QNetworkReplyPtr reply(manager.get(request));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
// credentials in URL, so don't expect authentication signal
QCOMPARE(authSpy.count(), 0);
QCOMPARE(finishedSpy.count(), 1);
@@ -6837,7 +6855,7 @@ void tst_QNetworkReply::httpWithNoCredentialUsage()
{
QNetworkRequest request(QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/protected/cgi-bin/md5sum.cgi"));
QNetworkReplyPtr reply(manager.get(request));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
// credentials in cache, so don't expect authentication signal
QCOMPARE(authSpy.count(), 0);
QCOMPARE(finishedSpy.count(), 1);
@@ -6874,7 +6892,7 @@ void tst_QNetworkReply::qtbug15311doubleContentLength()
QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort())));
QNetworkReplyPtr reply(manager.get(request));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QVERIFY(reply->isFinished());
QCOMPARE(reply->error(), QNetworkReply::NoError);
@@ -6893,7 +6911,7 @@ void tst_QNetworkReply::qtbug18232gzipContentLengthZero()
QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort())));
QNetworkReplyPtr reply(manager.get(request));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QVERIFY(reply->isFinished());
QCOMPARE(reply->error(), QNetworkReply::NoError);
@@ -6914,7 +6932,7 @@ void tst_QNetworkReply::qtbug22660gzipNoContentLengthEmptyContent()
QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort())));
QNetworkReplyPtr reply(manager.get(request));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QVERIFY(reply->isFinished());
QCOMPARE(reply->error(), QNetworkReply::NoError);
@@ -6983,7 +7001,7 @@ void tst_QNetworkReply::qtbug27161httpHeaderMayBeDamaged(){
QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort())));
QNetworkReplyPtr reply(manager.get(request));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QVERIFY(reply->isFinished());
QCOMPARE(reply->error(), QNetworkReply::NoError);
@@ -7033,7 +7051,7 @@ void tst_QNetworkReply::qtbug28035browserDoesNotLoadQtProjectOrgCorrectly() {
QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort())));
QNetworkReplyPtr reply(manager.get(request));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QVERIFY(reply->isFinished());
QCOMPARE(reply->error(), QNetworkReply::NoError);
@@ -7042,7 +7060,7 @@ void tst_QNetworkReply::qtbug28035browserDoesNotLoadQtProjectOrgCorrectly() {
server.setDataToTransmit(getReply);
reply.reset(manager.get(request));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QVERIFY(reply->isFinished());
QCOMPARE(reply->error(), QNetworkReply::NoError);
@@ -7053,7 +7071,7 @@ void tst_QNetworkReply::qtbug28035browserDoesNotLoadQtProjectOrgCorrectly() {
request.setRawHeader("Content-Type", "text/plain");
reply.reset(manager.post(request, postData));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QVERIFY(reply->isFinished());
QCOMPARE(reply->error(), QNetworkReply::NoError);
@@ -7064,7 +7082,7 @@ void tst_QNetworkReply::qtbug28035browserDoesNotLoadQtProjectOrgCorrectly() {
server.setDataToTransmit(getReply);
reply.reset(manager.get(request));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QVERIFY(reply->isFinished());
QCOMPARE(reply->error(), QNetworkReply::NoError);
@@ -7074,7 +7092,7 @@ void tst_QNetworkReply::qtbug28035browserDoesNotLoadQtProjectOrgCorrectly() {
server.setDataToTransmit(getReply);
reply.reset(manager.get(request));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QVERIFY(reply->isFinished());
QCOMPARE(reply->error(), QNetworkReply::NoError);
@@ -7084,7 +7102,7 @@ void tst_QNetworkReply::qtbug28035browserDoesNotLoadQtProjectOrgCorrectly() {
server.setDataToTransmit(putReply);
reply.reset(manager.put(request, postData));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QVERIFY(reply->isFinished());
QCOMPARE(reply->error(), QNetworkReply::NoError);
@@ -7093,7 +7111,7 @@ void tst_QNetworkReply::qtbug28035browserDoesNotLoadQtProjectOrgCorrectly() {
server.setDataToTransmit(getReply);
reply.reset(manager.get(request));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QVERIFY(reply->isFinished());
QCOMPARE(reply->error(), QNetworkReply::NoError);
@@ -7103,7 +7121,7 @@ void tst_QNetworkReply::qtbug28035browserDoesNotLoadQtProjectOrgCorrectly() {
server.setDataToTransmit(getReply);
reply.reset(manager.get(request));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QVERIFY(reply->isFinished());
QCOMPARE(reply->error(), QNetworkReply::NoError);
@@ -7312,7 +7330,7 @@ void tst_QNetworkReply::dontInsertPartialContentIntoTheCache()
QNetworkReplyPtr reply(manager.get(request));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QVERIFY(server.totalConnections > 0);
QCOMPARE(reply->readAll().constData(), "load");
@@ -7329,7 +7347,7 @@ void tst_QNetworkReply::httpUserAgent()
request.setHeader(QNetworkRequest::UserAgentHeader, "abcDEFghi");
QNetworkReplyPtr reply(manager.get(request));
- QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply));
QVERIFY(reply->isFinished());
QCOMPARE(reply->error(), QNetworkReply::NoError);
diff --git a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp
index 6ba6781913..b61ec0883e 100644
--- a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp
+++ b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp
@@ -146,7 +146,7 @@ void tst_QAuthenticator::ntlmAuth()
if (sso)
QVERIFY(priv->calculateResponse("GET", "/").startsWith("NTLM "));
else
- QCOMPARE(priv->calculateResponse("GET", "/").constData(), "NTLM TlRMTVNTUAABAAAABQIAAAAAAAAAAAAAAAAAAAAAAAA=");
+ QCOMPARE(priv->calculateResponse("GET", "/").constData(), "NTLM TlRMTVNTUAABAAAABYIIAAAAAAAAAAAAAAAAAAAAAAA=");
// NTLM phase 2: challenge
headers.clear();
diff --git a/tests/auto/opengl/qgl/tst_qgl.cpp b/tests/auto/opengl/qgl/tst_qgl.cpp
index 718b5263bf..22f284e365 100644
--- a/tests/auto/opengl/qgl/tst_qgl.cpp
+++ b/tests/auto/opengl/qgl/tst_qgl.cpp
@@ -60,6 +60,7 @@
#include <QtOpenGL/private/qgl_p.h>
#include <QtGui/private/qimage_p.h>
#include <QtGui/private/qimagepixmapcleanuphooks_p.h>
+#include <QtGui/private/qopenglextensions_p.h>
#endif
class tst_QGL : public QObject
@@ -99,6 +100,7 @@ private slots:
void threadImages();
void nullRectCrash();
void graphicsViewClipping();
+ void extensions();
};
tst_QGL::tst_QGL()
@@ -2361,5 +2363,43 @@ void tst_QGL::nullRectCrash()
fboPainter.end();
}
+void tst_QGL::extensions()
+{
+ QGLWidget glw;
+ glw.makeCurrent();
+
+ QOpenGLContext *ctx = QOpenGLContext::currentContext();
+ QVERIFY(ctx);
+ QOpenGLFunctions *funcs = ctx->functions();
+ QVERIFY(funcs);
+ QSurfaceFormat format = ctx->format();
+
+#ifdef QT_BUILD_INTERNAL
+ QOpenGLExtensions *exts = static_cast<QOpenGLExtensions *>(funcs);
+ QOpenGLExtensions::OpenGLExtensions allExts = exts->openGLExtensions();
+ // Mipmapping is always available in GL2/GLES2+. Verify this.
+ if (format.majorVersion() >= 2)
+ QVERIFY(allExts.testFlag(QOpenGLExtensions::GenerateMipmap));
+#endif
+
+ // Now look for some features should always be available in a given version.
+ QOpenGLFunctions::OpenGLFeatures allFeatures = funcs->openGLFeatures();
+ QVERIFY(allFeatures.testFlag(QOpenGLFunctions::Multitexture));
+ if (format.majorVersion() >= 2) {
+ QVERIFY(allFeatures.testFlag(QOpenGLFunctions::Shaders));
+ QVERIFY(allFeatures.testFlag(QOpenGLFunctions::Buffers));
+ QVERIFY(allFeatures.testFlag(QOpenGLFunctions::Multisample));
+ QVERIFY(!ctx->isES() || allFeatures.testFlag(QOpenGLFunctions::Framebuffers));
+ QVERIFY(allFeatures.testFlag(QOpenGLFunctions::NPOTTextures)
+ && allFeatures.testFlag(QOpenGLFunctions::NPOTTextureRepeat));
+ if (ctx->isES()) {
+ QVERIFY(!allFeatures.testFlag(QOpenGLFunctions::FixedFunctionPipeline));
+ QVERIFY(allFeatures.testFlag(QOpenGLFunctions::Framebuffers));
+ }
+ }
+ if (format.majorVersion() >= 3)
+ QVERIFY(allFeatures.testFlag(QOpenGLFunctions::Framebuffers));
+}
+
QTEST_MAIN(tst_QGL)
#include "tst_qgl.moc"
diff --git a/tests/auto/other/d3dcompiler/tst_d3dcompiler.cpp b/tests/auto/other/d3dcompiler/tst_d3dcompiler.cpp
index 1a34c2076b..750ea8fc4c 100644
--- a/tests/auto/other/d3dcompiler/tst_d3dcompiler.cpp
+++ b/tests/auto/other/d3dcompiler/tst_d3dcompiler.cpp
@@ -170,6 +170,7 @@ void tst_d3dcompiler::init()
{
qunsetenv("QT_D3DCOMPILER_DIR");
qunsetenv("QT_D3DCOMPILER_TIMEOUT");
+ qunsetenv("QT_D3DCOMPILER_DISABLE_DLL");
}
void tst_d3dcompiler::cleanup()
@@ -195,8 +196,8 @@ void tst_d3dcompiler::service_data()
// Don't test the default case, as it would clutter the AppData directory
//QTest::newRow("default") << QByteArrayLiteral("") << true << E_ABORT;
QTest::newRow("temporary") << QFile::encodeName(tempDir.path()) << true << E_ABORT;
- QTest::newRow("invalid") << QByteArrayLiteral("ZZ:\\") << false << S_OK;
- QTest::newRow("empty") << QByteArrayLiteral("") << false << S_OK;
+ QTest::newRow("invalid") << QByteArrayLiteral("ZZ:\\") << false << E_FAIL;
+ QTest::newRow("empty") << QByteArrayLiteral("") << false << E_FAIL;
}
void tst_d3dcompiler::service()
@@ -205,16 +206,12 @@ void tst_d3dcompiler::service()
QFETCH(bool, exists);
QFETCH(HRESULT, result);
qputenv("QT_D3DCOMPILER_DIR", compilerDir);
+ qputenv("QT_D3DCOMPILER_DISABLE_DLL", QByteArrayLiteral("1"));
const QDir path = blobPath();
if (exists) {
// Activate service
QVERIFY(path.exists());
-
- QFile control(path.absoluteFilePath(QStringLiteral("control")));
- QVERIFY(control.open(QFile::WriteOnly));
- control.close();
- QVERIFY(control.exists());
} else {
QVERIFY(!path.exists());
}
@@ -262,6 +259,7 @@ void tst_d3dcompiler::service()
void tst_d3dcompiler::offlineCompile()
{
qputenv("QT_D3DCOMPILER_DIR", QFile::encodeName(tempDir.path()));
+ qputenv("QT_D3DCOMPILER_DISABLE_DLL", QByteArrayLiteral("1"));
for (int i = 0; compilerDlls[i]; ++i) {
d3dcompiler_win = loadLibrary(compilerDlls[i]);
@@ -302,6 +300,8 @@ void tst_d3dcompiler::offlineCompile()
void tst_d3dcompiler::onlineCompile()
{
qputenv("QT_D3DCOMPILER_DIR", QFile::encodeName(tempDir.path()));
+ qputenv("QT_D3DCOMPILER_TIMEOUT", QByteArray::number(3000));
+ qputenv("QT_D3DCOMPILER_DISABLE_DLL", QByteArrayLiteral("1"));
QByteArray data(hlsl);
@@ -309,10 +309,6 @@ void tst_d3dcompiler::onlineCompile()
// Activate service
QVERIFY(path.exists());
- QFile control(path.absoluteFilePath(QStringLiteral("control")));
- QVERIFY(control.open(QFile::WriteOnly));
- control.close();
- QVERIFY(control.exists());
d3dcompiler_qt = loadLibrary(D3DCOMPILER_DLL);
QVERIFY(d3dcompiler_qt);
diff --git a/tests/auto/other/gestures/tst_gestures.cpp b/tests/auto/other/gestures/tst_gestures.cpp
index 448825fd81..df168aef58 100644
--- a/tests/auto/other/gestures/tst_gestures.cpp
+++ b/tests/auto/other/gestures/tst_gestures.cpp
@@ -1545,7 +1545,7 @@ void tst_Gestures::autoCancelGestures()
QVERIFY(QTest::qWaitForWindowExposed(&parent));
/*
- An event is send to both the child and the parent, when the child gets it a gesture is triggered
+ An event is sent to both the child and the parent, when the child gets it a gesture is triggered
and send to the child.
When the parent gets the event a new gesture is triggered and delivered to the parent. When the
parent gets it he accepts it and that causes the cancel policy to activate.
diff --git a/tests/auto/other/macgui/tst_macgui.cpp b/tests/auto/other/macgui/tst_macgui.cpp
index e796b44843..14993145b4 100644
--- a/tests/auto/other/macgui/tst_macgui.cpp
+++ b/tests/auto/other/macgui/tst_macgui.cpp
@@ -142,6 +142,8 @@ void tst_MacGui::splashScreenModality()
box.setText("accessible?");
box.show();
+ QSKIP("QTBUG-35169");
+
// Find the "OK" button and schedule a press.
QAccessibleInterface *interface = wn.find(QAccessible::Name, "OK", &box);
QVERIFY(interface);
diff --git a/tests/auto/other/macnativeevents/tst_macnativeevents.cpp b/tests/auto/other/macnativeevents/tst_macnativeevents.cpp
index ae59672c72..1cb752b4b0 100644
--- a/tests/auto/other/macnativeevents/tst_macnativeevents.cpp
+++ b/tests/auto/other/macnativeevents/tst_macnativeevents.cpp
@@ -272,7 +272,7 @@ void tst_MacNativeEvents::testDragWindow()
void tst_MacNativeEvents::testMouseEnter()
{
// When a mouse enters a widget, both a mouse enter events and a
- // mouse move event should be sendt. Lets test this:
+ // mouse move event should be sent. Let's test this:
QWidget w;
w.setMouseTracking(true);
w.show();
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index 53f74d091b..2bf8a40451 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -1650,30 +1650,33 @@ void tst_QAccessibility::textEditTest()
QTest::qWaitForWindowShown(&edit);
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(&edit);
QCOMPARE(iface->text(QAccessible::Value), edit.toPlainText());
- QCOMPARE(iface->textInterface()->textAtOffset(8, QAccessible::WordBoundary, &startOffset, &endOffset), QString("world"));
+ QAccessibleTextInterface *textIface = iface->textInterface();
+ QVERIFY(textIface);
+
+ QCOMPARE(textIface->textAtOffset(8, QAccessible::WordBoundary, &startOffset, &endOffset), QString("world"));
QCOMPARE(startOffset, 6);
QCOMPARE(endOffset, 11);
- QCOMPARE(iface->textInterface()->textAtOffset(15, QAccessible::LineBoundary, &startOffset, &endOffset), QString("How are you today?"));
+ QCOMPARE(textIface->textAtOffset(15, QAccessible::LineBoundary, &startOffset, &endOffset), QString("How are you today?"));
QCOMPARE(startOffset, 13);
QCOMPARE(endOffset, 31);
- QCOMPARE(iface->textInterface()->characterCount(), 48);
+ QCOMPARE(textIface->characterCount(), 48);
QFontMetrics fm(edit.currentFont());
- QCOMPARE(iface->textInterface()->characterRect(0).size(), QSize(fm.width("h"), fm.height()));
- QCOMPARE(iface->textInterface()->characterRect(5).size(), QSize(fm.width(" "), fm.height()));
- QCOMPARE(iface->textInterface()->characterRect(6).size(), QSize(fm.width("w"), fm.height()));
+ QCOMPARE(textIface->characterRect(0).size(), QSize(fm.width("h"), fm.height()));
+ QCOMPARE(textIface->characterRect(5).size(), QSize(fm.width(" "), fm.height()));
+ QCOMPARE(textIface->characterRect(6).size(), QSize(fm.width("w"), fm.height()));
int offset = 10;
- QCOMPARE(iface->textInterface()->text(offset, offset + 1), QStringLiteral("d"));
- QVERIFY(fuzzyRectCompare(iface->textInterface()->characterRect(offset), characterRect(edit, offset)));
+ QCOMPARE(textIface->text(offset, offset + 1), QStringLiteral("d"));
+ QVERIFY(fuzzyRectCompare(textIface->characterRect(offset), characterRect(edit, offset)));
offset = 13;
- QCOMPARE(iface->textInterface()->text(offset, offset + 1), QStringLiteral("H"));
- QVERIFY(fuzzyRectCompare(iface->textInterface()->characterRect(offset), characterRect(edit, offset)));
+ QCOMPARE(textIface->text(offset, offset + 1), QStringLiteral("H"));
+ QVERIFY(fuzzyRectCompare(textIface->characterRect(offset), characterRect(edit, offset)));
offset = 21;
- QCOMPARE(iface->textInterface()->text(offset, offset + 1), QStringLiteral("y"));
- QVERIFY(fuzzyRectCompare(iface->textInterface()->characterRect(offset), characterRect(edit, offset)));
+ QCOMPARE(textIface->text(offset, offset + 1), QStringLiteral("y"));
+ QVERIFY(fuzzyRectCompare(textIface->characterRect(offset), characterRect(edit, offset)));
offset = 32;
- QCOMPARE(iface->textInterface()->text(offset, offset + 1), QStringLiteral("I"));
- QVERIFY(fuzzyRectCompare(iface->textInterface()->characterRect(offset), characterRect(edit, offset)));
+ QCOMPARE(textIface->text(offset, offset + 1), QStringLiteral("I"));
+ QVERIFY(fuzzyRectCompare(textIface->characterRect(offset), characterRect(edit, offset)));
QTestAccessibility::clearEvents();
@@ -1692,6 +1695,22 @@ void tst_QAccessibility::textEditTest()
sel.setCursorPosition(end);
sel.setSelection(0, end);
QVERIFY_EVENT(&sel);
+
+ // check that we have newlines handled
+ QString poem = QStringLiteral("Once upon a midnight dreary,\nwhile I pondered, weak and weary,\nOver many a quaint and curious volume of forgotten lore\n");
+ QAccessibleEditableTextInterface *editableTextIface = iface->editableTextInterface();
+ QVERIFY(editableTextIface);
+ editableTextIface->replaceText(0, end, poem);
+ QCOMPARE(iface->text(QAccessible::Value), poem);
+ QCOMPARE(textIface->text(0, poem.size()), poem);
+ QCOMPARE(textIface->text(28, 29), QLatin1String("\n"));
+ int start;
+ QCOMPARE(textIface->textAtOffset(42, QAccessible::LineBoundary, &start, &end), QStringLiteral("while I pondered, weak and weary,"));
+ QCOMPARE(start, 29);
+ QCOMPARE(end, 62);
+ QCOMPARE(textIface->textAtOffset(28, QAccessible::CharBoundary, &start, &end), QLatin1String("\n"));
+ QCOMPARE(start, 28);
+ QCOMPARE(end, 29);
}
QTestAccessibility::clearEvents();
}
diff --git a/tests/auto/printsupport/kernel/kernel.pro b/tests/auto/printsupport/kernel/kernel.pro
index 6f5802bf3e..0566556e01 100644
--- a/tests/auto/printsupport/kernel/kernel.pro
+++ b/tests/auto/printsupport/kernel/kernel.pro
@@ -1,4 +1,5 @@
TEMPLATE=subdirs
SUBDIRS=\
+ qprintdevice \
qprinter \
qprinterinfo \
diff --git a/tests/auto/printsupport/kernel/qprintdevice/.gitignore b/tests/auto/printsupport/kernel/qprintdevice/.gitignore
new file mode 100644
index 0000000000..fcef7c1997
--- /dev/null
+++ b/tests/auto/printsupport/kernel/qprintdevice/.gitignore
@@ -0,0 +1 @@
+tst_qprinterinfo
diff --git a/tests/auto/printsupport/kernel/qprintdevice/qprintdevice.pro b/tests/auto/printsupport/kernel/qprintdevice/qprintdevice.pro
new file mode 100644
index 0000000000..fb11b0361e
--- /dev/null
+++ b/tests/auto/printsupport/kernel/qprintdevice/qprintdevice.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+CONFIG += parallel_test
+TARGET = tst_qprintdevice
+SOURCES += tst_qprintdevice.cpp
+
+QT += printsupport-private network testlib
+
+DEFINES += QT_USE_USING_NAMESPACE
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp b/tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp
new file mode 100644
index 0000000000..1064b18168
--- /dev/null
+++ b/tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 John Layt <jlayt@kde.org>
+** 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 <QtTest/QtTest>
+
+#include <qpa/qplatformprintplugin.h>
+#include <qpa/qplatformprintersupport.h>
+
+#include <private/qprintdevice_p.h>
+
+class tst_QPrintDevice : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void basics();
+};
+
+void tst_QPrintDevice::basics()
+{
+#ifndef QT_NO_PRINTER
+ QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
+ if (!ps)
+ QSKIP("Could not load platform plugin");
+
+ QString defaultId = ps->defaultPrintDeviceId();
+ if (defaultId.isEmpty()) {
+ qDebug() << "No default printer found";
+ } else {
+ qDebug() << "Default Printer ID :" << defaultId;
+ QVERIFY(ps->availablePrintDeviceIds().contains(defaultId));
+ }
+
+ qDebug() << "Available Printer IDs :" << ps->availablePrintDeviceIds();
+
+ // Just exercise the api for now as we don't know what is installed
+ foreach (const QString id, ps->availablePrintDeviceIds()) {
+ QPrintDevice printDevice = ps->createPrintDevice(id);
+ qDebug() << "Created printer" << id;
+ QCOMPARE(printDevice.isValid(), true);
+ printDevice.id();
+ printDevice.name();
+ printDevice.location();
+ printDevice.makeAndModel();
+ printDevice.isValid();
+ printDevice.isDefault();
+ printDevice.isRemote();
+ printDevice.state();
+ printDevice.supportsMultipleCopies();
+ printDevice.supportsCollateCopies();
+ printDevice.defaultPageSize();
+ printDevice.supportedPageSizes();
+ printDevice.supportsCustomPageSizes();
+ printDevice.minimumPhysicalPageSize();
+ printDevice.maximumPhysicalPageSize();
+ printDevice.defaultResolution();
+ printDevice.supportedResolutions();
+ printDevice.defaultInputSlot();
+ printDevice.supportedInputSlots();
+ printDevice.defaultOutputBin();
+ printDevice.supportedOutputBins();
+ printDevice.defaultDuplexMode();
+ printDevice.supportedDuplexModes();
+ printDevice.defaultColorMode();
+ printDevice.supportedColorModes();
+ printDevice.supportedMimeTypes();
+ }
+#endif // QT_NO_PRINTER
+}
+
+QTEST_MAIN(tst_QPrintDevice)
+
+#include "tst_qprintdevice.moc"
diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
index b138f34967..5d99cca8d9 100644
--- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
+++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
@@ -51,6 +51,7 @@
#include <qvariant.h>
#include <qpainter.h>
#include <qprintengine.h>
+#include <qpagelayout.h>
#include <math.h>
@@ -88,9 +89,6 @@ public slots:
void cleanupTestCase();
#else
private slots:
-#ifdef Q_OS_WIN
- void testNonExistentPrinter();
-#endif
void testPageRectAndPaperRect();
void testPageRectAndPaperRect_data();
void testSetOptions();
@@ -103,7 +101,6 @@ private slots:
void testPageMargins_data();
void testPageMargins();
void outputFormatFromSuffix();
- void setGetPaperSize();
void errorReporting();
void testCustomPageSizes();
void customPaperSizeAndMargins_data();
@@ -116,8 +113,6 @@ private slots:
void testCurrentPage();
void taskQTBUG4497_reusePrinterOnDifferentFiles();
void testPdfTitle();
- void testPageMetrics_data();
- void testPageMetrics();
// Test QPrintEngine keys and their QPrinter setters/getters
void testMultipleKeys();
@@ -148,6 +143,9 @@ private slots:
// Test QPrinter setters/getters for non-QPrintEngine options
void outputFormat();
void fromToPage();
+
+ void testPageMetrics_data();
+ void testPageMetrics();
#endif
};
@@ -356,40 +354,6 @@ void tst_QPrinter::testMargins()
QFile::remove("silly");
}
-#ifdef Q_OS_WIN
-// QPrinter::testNonExistentPrinter() is not relevant for this platform
-void tst_QPrinter::testNonExistentPrinter()
-{
- QPrinter printer;
- QPainter painter;
-
- // Make sure it doesn't crash on setting or getting properties
- printer.printEngine()->setProperty(QPrintEngine::PPK_PrinterName, "some non existing printer");
- printer.setPageSize(QPrinter::A4);
- printer.setOrientation(QPrinter::Portrait);
- printer.setFullPage(true);
- printer.pageSize();
- printer.orientation();
- printer.fullPage();
- printer.setCopyCount(1);
- printer.printerName();
-
- // nor metrics
- QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmWidth), 0);
- QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmHeight), 0);
- QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmWidthMM), 0);
- QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmHeightMM), 0);
- QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmNumColors), 0);
- QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmDepth), 0);
- QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmDpiX), 0);
- QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmDpiY), 0);
- QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmPhysicalDpiX), 0);
- QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmPhysicalDpiY), 0);
-
- QVERIFY(!painter.begin(&printer));
-}
-#endif
-
void tst_QPrinter::testMulitpleSets_data()
{
QTest::addColumn<int>("resolution");
@@ -477,20 +441,6 @@ void tst_QPrinter::outputFormatFromSuffix()
QVERIFY(p.outputFormat() == QPrinter::NativeFormat);
}
-void tst_QPrinter::setGetPaperSize()
-{
- QPrinter p;
- p.setOutputFormat(QPrinter::PdfFormat);
- QSizeF size(500, 10);
- p.setPaperSize(size, QPrinter::Millimeter);
- QCOMPARE(p.paperSize(QPrinter::Millimeter), size);
- QCOMPARE(p.pageSizeMM(), size);
- QSizeF ptSize = p.paperSize(QPrinter::Point);
- //qDebug() << ptSize;
- QVERIFY(qAbs(ptSize.width() - size.width() * (72/25.4)) < 1E-4);
- QVERIFY(qAbs(ptSize.height() - size.height() * (72/25.4)) < 1E-4);
-}
-
void tst_QPrinter::testPageMargins_data()
{
QTest::addColumn<qreal>("left");
@@ -499,11 +449,12 @@ void tst_QPrinter::testPageMargins_data()
QTest::addColumn<qreal>("bottom");
QTest::addColumn<int>("unit");
- QTest::newRow("data0") << qreal(5.5) << qreal(6.5) << qreal(7.5) << qreal(8.5) << static_cast<int>(QPrinter::Millimeter);
- QTest::newRow("data1") << qreal(5.5) << qreal(6.5) << qreal(7.5) << qreal(8.5) << static_cast<int>(QPrinter::Point);
+ // Use custom margins that will exceed most printers minimum allowed
+ QTest::newRow("data0") << qreal(25.5) << qreal(26.5) << qreal(27.5) << qreal(28.5) << static_cast<int>(QPrinter::Millimeter);
+ QTest::newRow("data1") << qreal(55.5) << qreal(56.5) << qreal(57.5) << qreal(58.5) << static_cast<int>(QPrinter::Point);
QTest::newRow("data2") << qreal(5.5) << qreal(6.5) << qreal(7.5) << qreal(8.5) << static_cast<int>(QPrinter::Inch);
QTest::newRow("data3") << qreal(5.5) << qreal(6.5) << qreal(7.5) << qreal(8.5) << static_cast<int>(QPrinter::Pica);
- QTest::newRow("data4") << qreal(5.5) << qreal(6.5) << qreal(7.5) << qreal(8.5) << static_cast<int>(QPrinter::Didot);
+ QTest::newRow("data4") << qreal(55.5) << qreal(56.5) << qreal(57.5) << qreal(58.5) << static_cast<int>(QPrinter::Didot);
QTest::newRow("data5") << qreal(5.5) << qreal(6.5) << qreal(7.5) << qreal(8.5) << static_cast<int>(QPrinter::Cicero);
}
@@ -511,61 +462,54 @@ void tst_QPrinter::testPageMargins()
{
QPrinter obj1;
- qreal toMillimeters[6];
- toMillimeters[QPrinter::Millimeter] = 1;
- toMillimeters[QPrinter::Point] = 0.352777778;
- toMillimeters[QPrinter::Inch] = 25.4;
- toMillimeters[QPrinter::Pica] = 4.23333333;
- toMillimeters[QPrinter::Didot] = 0.376;
- toMillimeters[QPrinter::Cicero] = 4.51166667;
-
QFETCH(qreal, left);
QFETCH(qreal, top);
QFETCH(qreal, right);
QFETCH(qreal, bottom);
QFETCH(int, unit);
- qreal nLeft, nTop, nRight, nBottom;
+ QPageLayout layout = QPageLayout(QPageSize(QPageSize::A0), QPageLayout::Portrait,
+ QMarginsF(left, top, right, bottom), QPageLayout::Unit(unit));
- obj1.setPageMargins(left, top, right, bottom, static_cast<QPrinter::Unit>(unit));
+ qreal nLeft, nTop, nRight, nBottom;
- qreal tolerance = 0.05;
+ obj1.setPageMargins(left, top, right, bottom, QPrinter::Unit(unit));
obj1.getPageMargins(&nLeft, &nTop, &nRight, &nBottom, QPrinter::Millimeter);
- QVERIFY(fabs(left*toMillimeters[unit] - nLeft*toMillimeters[QPrinter::Millimeter]) < tolerance);
- QVERIFY(fabs(top*toMillimeters[unit] - nTop*toMillimeters[QPrinter::Millimeter]) < tolerance);
- QVERIFY(fabs(right*toMillimeters[unit] - nRight*toMillimeters[QPrinter::Millimeter]) < tolerance);
- QVERIFY(fabs(bottom*toMillimeters[unit] - nBottom*toMillimeters[QPrinter::Millimeter]) < tolerance);
+ QCOMPARE(nLeft, layout.margins(QPageLayout::Millimeter).left());
+ QCOMPARE(nRight, layout.margins(QPageLayout::Millimeter).right());
+ QCOMPARE(nTop, layout.margins(QPageLayout::Millimeter).top());
+ QCOMPARE(nBottom, layout.margins(QPageLayout::Millimeter).bottom());
obj1.getPageMargins(&nLeft, &nTop, &nRight, &nBottom, QPrinter::Point);
- QVERIFY(fabs(left*toMillimeters[unit] - nLeft*toMillimeters[QPrinter::Point]) < tolerance);
- QVERIFY(fabs(top*toMillimeters[unit] - nTop*toMillimeters[QPrinter::Point]) < tolerance);
- QVERIFY(fabs(right*toMillimeters[unit] - nRight*toMillimeters[QPrinter::Point]) < tolerance);
- QVERIFY(fabs(bottom*toMillimeters[unit] - nBottom*toMillimeters[QPrinter::Point]) < tolerance);
+ QCOMPARE(nLeft, layout.margins(QPageLayout::Point).left());
+ QCOMPARE(nRight, layout.margins(QPageLayout::Point).right());
+ QCOMPARE(nTop, layout.margins(QPageLayout::Point).top());
+ QCOMPARE(nBottom, layout.margins(QPageLayout::Point).bottom());
obj1.getPageMargins(&nLeft, &nTop, &nRight, &nBottom, QPrinter::Inch);
- QVERIFY(fabs(left*toMillimeters[unit] - nLeft*toMillimeters[QPrinter::Inch]) < tolerance);
- QVERIFY(fabs(top*toMillimeters[unit] - nTop*toMillimeters[QPrinter::Inch]) < tolerance);
- QVERIFY(fabs(right*toMillimeters[unit] - nRight*toMillimeters[QPrinter::Inch]) < tolerance);
- QVERIFY(fabs(bottom*toMillimeters[unit] - nBottom*toMillimeters[QPrinter::Inch]) < tolerance);
+ QCOMPARE(nLeft, layout.margins(QPageLayout::Inch).left());
+ QCOMPARE(nRight, layout.margins(QPageLayout::Inch).right());
+ QCOMPARE(nTop, layout.margins(QPageLayout::Inch).top());
+ QCOMPARE(nBottom, layout.margins(QPageLayout::Inch).bottom());
obj1.getPageMargins(&nLeft, &nTop, &nRight, &nBottom, QPrinter::Pica);
- QVERIFY(fabs(left*toMillimeters[unit] - nLeft*toMillimeters[QPrinter::Pica]) < tolerance);
- QVERIFY(fabs(top*toMillimeters[unit] - nTop*toMillimeters[QPrinter::Pica]) < tolerance);
- QVERIFY(fabs(right*toMillimeters[unit] - nRight*toMillimeters[QPrinter::Pica]) < tolerance);
- QVERIFY(fabs(bottom*toMillimeters[unit] - nBottom*toMillimeters[QPrinter::Pica]) < tolerance);
+ QCOMPARE(nLeft, layout.margins(QPageLayout::Pica).left());
+ QCOMPARE(nRight, layout.margins(QPageLayout::Pica).right());
+ QCOMPARE(nTop, layout.margins(QPageLayout::Pica).top());
+ QCOMPARE(nBottom, layout.margins(QPageLayout::Pica).bottom());
obj1.getPageMargins(&nLeft, &nTop, &nRight, &nBottom, QPrinter::Didot);
- QVERIFY(fabs(left*toMillimeters[unit] - nLeft*toMillimeters[QPrinter::Didot]) < tolerance);
- QVERIFY(fabs(top*toMillimeters[unit] - nTop*toMillimeters[QPrinter::Didot]) < tolerance);
- QVERIFY(fabs(right*toMillimeters[unit] - nRight*toMillimeters[QPrinter::Didot]) < tolerance);
- QVERIFY(fabs(bottom*toMillimeters[unit] - nBottom*toMillimeters[QPrinter::Didot]) < tolerance);
+ QCOMPARE(nLeft, layout.margins(QPageLayout::Didot).left());
+ QCOMPARE(nRight, layout.margins(QPageLayout::Didot).right());
+ QCOMPARE(nTop, layout.margins(QPageLayout::Didot).top());
+ QCOMPARE(nBottom, layout.margins(QPageLayout::Didot).bottom());
obj1.getPageMargins(&nLeft, &nTop, &nRight, &nBottom, QPrinter::Cicero);
- QVERIFY(fabs(left*toMillimeters[unit] - nLeft*toMillimeters[QPrinter::Cicero]) < tolerance);
- QVERIFY(fabs(top*toMillimeters[unit] - nTop*toMillimeters[QPrinter::Cicero]) < tolerance);
- QVERIFY(fabs(right*toMillimeters[unit] - nRight*toMillimeters[QPrinter::Cicero]) < tolerance);
- QVERIFY(fabs(bottom*toMillimeters[unit] - nBottom*toMillimeters[QPrinter::Cicero]) < tolerance);
+ QCOMPARE(nLeft, layout.margins(QPageLayout::Cicero).left());
+ QCOMPARE(nRight, layout.margins(QPageLayout::Cicero).right());
+ QCOMPARE(nTop, layout.margins(QPageLayout::Cicero).top());
+ QCOMPARE(nBottom, layout.margins(QPageLayout::Cicero).bottom());
}
void tst_QPrinter::errorReporting()
@@ -586,13 +530,6 @@ 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;
@@ -601,16 +538,14 @@ void tst_QPrinter::testCustomPageSizes()
p.setPaperSize(customSize, QPrinter::Inch);
QSizeF paperSize = p.paperSize(QPrinter::Inch);
- // 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));
+ QCOMPARE(paperSize.width(), customSize.width());
+ QCOMPARE(paperSize.height(), customSize.height());
QPrinter p2(QPrinter::HighResolution);
p2.setPaperSize(customSize, QPrinter::Inch);
paperSize = p.paperSize(QPrinter::Inch);
- QVERIFY2(sqrt(pow(paperSize.width() - customSize.width(), 2.0) + pow(paperSize.height() - customSize.height(), 2.0)) < 0.01,
- msgSizeMismatch(paperSize, customSize));
+ QCOMPARE(paperSize.width(), customSize.width());
+ QCOMPARE(paperSize.height(), customSize.height());
}
void tst_QPrinter::customPaperSizeAndMargins_data()
@@ -622,10 +557,11 @@ void tst_QPrinter::customPaperSizeAndMargins_data()
QTest::addColumn<qreal>("right");
QTest::addColumn<qreal>("bottom");
- QTest::newRow("beforeNoPDF") << false << true << qreal(2) << qreal(2) << qreal(2) << qreal(2);
- QTest::newRow("beforePDF") << true << true << qreal(2) << qreal(2) << qreal(2) << qreal(2);
- QTest::newRow("afterNoPDF") << false << false << qreal(2) << qreal(2) << qreal(2) << qreal(2);
- QTest::newRow("afterAfterPDF") << true << false << qreal(2) << qreal(2) << qreal(2) << qreal(2);
+ // Use custom margins that will exceed most printers minimum allowed
+ QTest::newRow("beforeNoPDF") << false << true << qreal(30) << qreal(30) << qreal(30) << qreal(30);
+ QTest::newRow("beforePDF") << true << true << qreal(30) << qreal(30) << qreal(30) << qreal(30);
+ QTest::newRow("afterNoPDF") << false << false << qreal(30) << qreal(30) << qreal(30) << qreal(30);
+ QTest::newRow("afterAfterPDF") << true << false << qreal(30) << qreal(30) << qreal(30) << qreal(30);
}
void tst_QPrinter::customPaperSizeAndMargins()
@@ -642,7 +578,9 @@ void tst_QPrinter::customPaperSizeAndMargins()
qreal getRight = 0;
qreal getTop = 0;
qreal getBottom = 0;
- QSizeF customSize(8.5, 11.0);
+ // Use a custom page size that most printers should support, A4 is 210x297
+ // TODO Use print device api when available
+ QSizeF customSize(200.0, 300.0);
QPrinter p;
if (pdf)
@@ -657,10 +595,6 @@ void tst_QPrinter::customPaperSizeAndMargins()
QVERIFY(fabs(left - getRight) < tolerance);
QVERIFY(fabs(left - getBottom) < tolerance);
} else {
- QVERIFY(getLeft == 0);
- QVERIFY(getTop == 0);
- QVERIFY(getRight == 0);
- QVERIFY(getBottom == 0);
p.setPageMargins(left, top, right, bottom, QPrinter::Millimeter);
p.getPageMargins(&getLeft, &getTop, &getRight, &getBottom, QPrinter::Millimeter);
QVERIFY(fabs(left - getLeft) < tolerance);
@@ -781,100 +715,62 @@ void tst_QPrinter::testPdfTitle()
QVERIFY(file.readAll().contains(QByteArray(expected, 26)));
}
-void tst_QPrinter::testPageMetrics_data()
-{
- QTest::addColumn<int>("pageSize");
- QTest::addColumn<int>("widthMM");
- QTest::addColumn<int>("heightMM");
- QTest::addColumn<float>("widthMMf");
- QTest::addColumn<float>("heightMMf");
-
- QTest::newRow("A4") << int(QPrinter::A4) << 210 << 297 << 210.0f << 297.0f;
- QTest::newRow("A5") << int(QPrinter::A5) << 148 << 210 << 148.0f << 210.0f;
- QTest::newRow("Letter") << int(QPrinter::Letter) << 216 << 279 << 215.9f << 279.4f;
-}
-
-void tst_QPrinter::testPageMetrics()
-{
- QFETCH(int, pageSize);
- QFETCH(int, widthMM);
- QFETCH(int, heightMM);
- QFETCH(float, widthMMf);
- QFETCH(float, heightMMf);
-
- QPrinter printer(QPrinter::HighResolution);
- printer.setFullPage(true);
- printer.setPageSize(QPrinter::PageSize(pageSize));
-
- if (printer.pageSize() != pageSize) {
- QSKIP("Current page size is not supported on this printer");
- return;
- }
-
- QCOMPARE(printer.widthMM(), int(widthMM));
- QCOMPARE(printer.heightMM(), int(heightMM));
- 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<QPair<QString, QSizeF> > sizes = info.supportedSizesWithNames();
+ QList<QPageSize> sizes = info.supportedPageSizes();
if (sizes.size() == 0)
QSKIP("No printers installed on this machine");
for (int i=0; i<sizes.size(); i++) {
- printer.setPaperSize(sizes.at(i).second, QPrinter::Millimeter);
- QCOMPARE(sizes.at(i).second, printer.paperSize(QPrinter::Millimeter));
+ printer.setPaperSize(sizes.at(i).size(QPageSize::Millimeter), QPrinter::Millimeter);
+ QCOMPARE(sizes.at(i).size(QPageSize::Millimeter), printer.paperSize(QPrinter::Millimeter));
// Some printers have the same size under different names which can cause a problem for the test
- // So we iterate up to the current position to check
- QSizeF paperSize = sizes.at(i).second;
+ // So we look at all the other sizes to see if one also matches as we don't know which order they are in
+ QSizeF paperSize = sizes.at(i).size(QPageSize::Millimeter);
QString paperName = printer.paperName();
- bool paperNameFound = (sizes.at(i).first == paperName);
+ bool paperNameFound = (sizes.at(i).name() == paperName);
if (!paperNameFound) {
- for (int j=0; j<i; j++) {
- if (sizes.at(j).second == paperSize && sizes.at(j).first == paperName) {
+ for (int j = 0; j < sizes.size(); ++j) {
+ if (j != i
+ && sizes.at(j).size(QPageSize::Millimeter) == paperSize
+ && sizes.at(j).name() == paperName) {
paperNameFound = true;
break;
}
}
}
// Fail with the original values
- if (!paperNameFound)
- QCOMPARE(sizes.at(i).first, printer.paperName());
+ if (!paperNameFound) {
+ qDebug() << "supportedPageSizes() = " << sizes;
+ QEXPECT_FAIL("", "Paper Name mismatch: please report this failure at bugreports.qt-project.org", Continue);
+ QCOMPARE(sizes.at(i).name(), printer.paperName());
+ }
}
// Check setting a custom size after setting a standard one works
- QSizeF customSize(200, 200);
+ QSizeF customSize(200, 300);
printer.setPaperSize(customSize, QPrinter::Millimeter);
QCOMPARE(printer.paperSize(QPrinter::Millimeter), customSize);
QCOMPARE(printer.paperSize(), QPrinter::Custom);
// Finally check setting a standard size after a custom one works
- printer.setPaperSize(sizes.at(0).second, QPrinter::Millimeter);
- QCOMPARE(printer.paperName(), sizes.at(0).first);
- QCOMPARE(printer.paperSize(QPrinter::Millimeter), sizes.at(0).second);
+ printer.setPaperSize(sizes.at(0).size(QPageSize::Millimeter), QPrinter::Millimeter);
+ QCOMPARE(printer.paperName(), sizes.at(0).name());
+ QCOMPARE(printer.paperSize(QPrinter::Millimeter), sizes.at(0).size(QPageSize::Millimeter));
}
void tst_QPrinter::customPaperNameSettingByName()
{
-#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<QPair<QString, QSizeF> > sizes = info.supportedSizesWithNames();
+ QList<QPageSize> sizes = info.supportedPageSizes();
if (sizes.size() == 0)
QSKIP("No printers installed on this machine");
for (int i=0; i<sizes.size(); i++) {
- printer.setPaperName(sizes.at(i).first);
- QCOMPARE(sizes.at(i).first, printer.paperName());
- QSizeF paperSize = printer.paperSize(QPrinter::Millimeter);
- QVERIFY2(sqrt(pow(sizes.at(i).second.width() - paperSize.width(), 2.0) + pow(sizes.at(i).second.height() - paperSize.height(), 2.0)) < 0.01,
- msgSizeMismatch(sizes.at(i).second, paperSize));
+ printer.setPaperName(sizes.at(i).name());
+ QCOMPARE(sizes.at(i).name(), printer.paperName());
+ QCOMPARE(sizes.at(i).size(QPageSize::Millimeter), printer.paperSize(QPrinter::Millimeter));
}
}
@@ -1794,43 +1690,46 @@ void tst_QPrinter::supportedResolutions()
void tst_QPrinter::windowsPageSize()
{
// winPageSize() / setWinPageSize() / PPK_WindowsPageSize
- // PdfFormat: ifdef'd out TODO remove ifdef
- // NativeFormat, Cups: ifdef'd out TODO remove ifdef
+ // PdfFormat: Supported, defaults to printer default
+ // NativeFormat, Cups: Supported, defaults to printer default
// NativeFormat, Win: Supported, defaults to printer default
- // NativeFormat, Mac: ifdef'd out TODO remove ifdef
+ // NativeFormat, Mac: Supported, defaults to printer default
+
+ QPrinter pdf;
+ pdf.setOutputFormat(QPrinter::PdfFormat);
+ QCOMPARE(pdf.winPageSize(), 9); // DMPAPER_A4
+ pdf.setWinPageSize(1); // DMPAPER_LETTER
+ QCOMPARE(pdf.winPageSize(), 1);
-#ifdef Q_OS_WIN
QPrinter native;
if (native.outputFormat() == QPrinter::NativeFormat) {
// Test set/get
native.setPaperSize(QPrinter::A4);
QCOMPARE(native.pageSize(), QPrinter::A4);
- QCOMPARE(native.winPageSize(), DMPAPER_A4);
+ QCOMPARE(native.winPageSize(), 9); // DMPAPER_A4
native.setPaperSize(QPrinter::Letter);
QCOMPARE(native.pageSize(), QPrinter::Letter);
- QCOMPARE(native.winPageSize(), DMPAPER_LETTER);
+ QCOMPARE(native.winPageSize(), 1); // DMPAPER_LETTER
- native.setWinPageSize(DMPAPER_A4);
+ native.setWinPageSize(9); // DMPAPER_A4
QCOMPARE(native.pageSize(), QPrinter::A4);
- QCOMPARE(native.winPageSize(), DMPAPER_A4);
+ QCOMPARE(native.winPageSize(), 9); // DMPAPER_A4
- native.setWinPageSize(DMPAPER_LETTER);
+ native.setWinPageSize(1); // DMPAPER_LETTER
QCOMPARE(native.pageSize(), QPrinter::Letter);
- QCOMPARE(native.winPageSize(), DMPAPER_LETTER);
+ QCOMPARE(native.winPageSize(), 1); // DMPAPER_LETTER
// Test value preservation
native.setOutputFormat(QPrinter::PdfFormat);
QCOMPARE(native.pageSize(), QPrinter::Letter);
- QEXPECT_FAIL("", "Win paper size doesn't persist over format change", Continue);
- QCOMPARE(native.winPageSize(), DMPAPER_LETTER);
+ QCOMPARE(native.winPageSize(), 1); // DMPAPER_LETTER
native.setOutputFormat(QPrinter::NativeFormat);
QCOMPARE(native.pageSize(), QPrinter::Letter);
- QCOMPARE(native.winPageSize(), DMPAPER_LETTER);
+ QCOMPARE(native.winPageSize(), 1); // DMPAPER_LETTER
} else {
QSKIP("No printers installed, cannot test NativeFormat, please install printers to test");
}
-#endif // Q_OS_WIN
}
// Test QPrinter setters/getters for non-QPrintEngine options
@@ -1861,6 +1760,191 @@ void tst_QPrinter::fromToPage()
QCOMPARE(printer.toPage(), 7);
}
+void tst_QPrinter::testPageMetrics_data()
+{
+ QTest::addColumn<int>("outputFormat");
+ QTest::addColumn<int>("pageSize");
+ QTest::addColumn<qreal>("widthMMf");
+ QTest::addColumn<qreal>("heightMMf");
+ QTest::addColumn<bool>("setMargins");
+ QTest::addColumn<qreal>("leftMMf");
+ QTest::addColumn<qreal>("rightMMf");
+ QTest::addColumn<qreal>("topMMf");
+ QTest::addColumn<qreal>("bottomMMf");
+
+ QTest::newRow("PDF A4") << int(QPrinter::PdfFormat) << int(QPrinter::A4) << 210.0 << 297.0 << false << 0.0 << 0.0 << 0.0 << 0.0;
+ QTest::newRow("PDF A4 Margins") << int(QPrinter::PdfFormat) << int(QPrinter::A4) << 210.0 << 297.0 << true << 20.0 << 30.0 << 40.0 << 50.0;
+ QTest::newRow("Native A4") << int(QPrinter::NativeFormat) << int(QPrinter::A4) << 210.0 << 297.0 << false << 0.0 << 0.0 << 0.0 << 0.0;
+ QTest::newRow("Native A4 Margins") << int(QPrinter::NativeFormat) << int(QPrinter::A4) << 210.0 << 297.0 << true << 20.0 << 30.0 << 40.0 << 50.0;
+
+ QTest::newRow("PDF Portrait") << int(QPrinter::PdfFormat) << -1 << 200.0 << 300.0 << false << 0.0 << 0.0 << 0.0 << 0.0;
+ QTest::newRow("PDF Portrait Margins") << int(QPrinter::PdfFormat) << -1 << 200.0 << 300.0 << true << 20.0 << 30.0 << 40.0 << 50.0;
+ QTest::newRow("PDF Landscape") << int(QPrinter::PdfFormat) << -1 << 300.0 << 200.0 << false << 0.0 << 0.0 << 0.0 << 0.0;
+ QTest::newRow("PDF Landscape Margins") << int(QPrinter::PdfFormat) << -1 << 300.0 << 200.0 << true << 20.0 << 30.0 << 40.0 << 50.0;
+ QTest::newRow("Native Portrait") << int(QPrinter::NativeFormat) << -1 << 200.0 << 300.0 << false << 0.0 << 0.0 << 0.0 << 0.0;
+ QTest::newRow("Native Portrait Margins") << int(QPrinter::NativeFormat) << -1 << 200.0 << 300.0 << true << 20.0 << 30.0 << 40.0 << 50.0;
+ QTest::newRow("Native Landscape") << int(QPrinter::NativeFormat) << -1 << 300.0 << 200.0 << false << 0.0 << 0.0 << 0.0 << 0.0;
+ QTest::newRow("Native Landscape Margins") << int(QPrinter::NativeFormat) << -1 << 300.0 << 200.0 << true << 20.0 << 30.0 << 40.0 << 50.0;
+}
+
+void tst_QPrinter::testPageMetrics()
+{
+ QFETCH(int, outputFormat);
+ QFETCH(int, pageSize);
+ QFETCH(qreal, widthMMf);
+ QFETCH(qreal, heightMMf);
+ QFETCH(bool, setMargins);
+ QFETCH(qreal, leftMMf);
+ QFETCH(qreal, rightMMf);
+ QFETCH(qreal, topMMf);
+ QFETCH(qreal, bottomMMf);
+
+ QSizeF sizeMMf = QSizeF(widthMMf, heightMMf);
+
+ QPrinter printer;
+ printer.setOutputFormat(QPrinter::OutputFormat(outputFormat));
+ if (printer.outputFormat() != QPrinter::OutputFormat(outputFormat))
+ QSKIP("Please install a native printer to run this test");
+ QCOMPARE(printer.outputFormat(), QPrinter::OutputFormat(outputFormat));
+ QCOMPARE(printer.orientation(), QPrinter::Portrait);
+
+ if (setMargins) {
+ // Setup the given margins
+ QPrinter::Margins margins;
+ margins.left = leftMMf;
+ margins.right = rightMMf;
+ margins.top = topMMf;
+ margins.bottom = bottomMMf;
+ printer.setMargins(margins);
+ QCOMPARE(printer.margins().left, leftMMf);
+ QCOMPARE(printer.margins().right, rightMMf);
+ QCOMPARE(printer.margins().top, topMMf);
+ QCOMPARE(printer.margins().bottom, bottomMMf);
+ }
+
+
+ // Set the given size, in Portrait mode
+ if (pageSize < 0) {
+ printer.setPageSizeMM(sizeMMf);
+ QCOMPARE(printer.pageSize(), QPrinter::Custom);
+ } else {
+ printer.setPageSize(QPrinter::PageSize(pageSize));
+ QCOMPARE(printer.pageSize(), QPrinter::PageSize(pageSize));
+ }
+ QCOMPARE(printer.orientation(), QPrinter::Portrait);
+ if (setMargins) {
+ // Check margins unchanged from page size change
+ QCOMPARE(printer.margins().left, leftMMf);
+ QCOMPARE(printer.margins().right, rightMMf);
+ QCOMPARE(printer.margins().top, topMMf);
+ QCOMPARE(printer.margins().bottom, bottomMMf);
+ } else {
+ // Fetch the default margins for the printer and page size
+ // TODO Check against margins from print device when api added
+ leftMMf = printer.margins().left;
+ rightMMf = printer.margins().right;
+ topMMf = printer.margins().top;
+ bottomMMf = printer.margins().bottom;
+ }
+
+ // QPagedPaintDevice::pageSizeMM() always returns Portrait
+ QCOMPARE(printer.pageSizeMM(), sizeMMf);
+
+ // QPrinter::paperSize() always returns set orientation
+ QCOMPARE(printer.paperSize(QPrinter::Millimeter), sizeMMf);
+
+ // QPagedPaintDevice::widthMM() and heightMM() are paint metrics and always return set orientation
+ QCOMPARE(printer.widthMM(), qRound(widthMMf - leftMMf - rightMMf));
+ QCOMPARE(printer.heightMM(), qRound(heightMMf - topMMf - bottomMMf));
+
+ // QPrinter::paperRect() always returns set orientation
+ QCOMPARE(printer.paperRect(QPrinter::Millimeter), QRectF(0, 0, widthMMf, heightMMf));
+
+ // QPrinter::pageRect() always returns set orientation
+ QCOMPARE(printer.pageRect(QPrinter::Millimeter), QRectF(leftMMf, topMMf, widthMMf - leftMMf - rightMMf, heightMMf - topMMf - bottomMMf));
+
+
+ // Now switch to Landscape mode, size should be unchanged, but rect and metrics should change
+ printer.setOrientation(QPrinter::Landscape);
+ if (pageSize < 0) {
+ QCOMPARE(printer.pageSize(), QPrinter::Custom);
+ } else {
+ QCOMPARE(printer.pageSize(), QPrinter::PageSize(pageSize));
+ }
+ QCOMPARE(printer.orientation(), QPrinter::Landscape);
+ if (setMargins) {
+ // Check margins unchanged from page size change
+ QCOMPARE(printer.margins().left, leftMMf);
+ QCOMPARE(printer.margins().right, rightMMf);
+ QCOMPARE(printer.margins().top, topMMf);
+ QCOMPARE(printer.margins().bottom, bottomMMf);
+ } else {
+ // Fetch the default margins for the printer and page size
+ // TODO Check against margins from print device when api added
+ leftMMf = printer.margins().left;
+ rightMMf = printer.margins().right;
+ topMMf = printer.margins().top;
+ bottomMMf = printer.margins().bottom;
+ }
+
+ // QPagedPaintDevice::pageSizeMM() always returns Portrait
+ QCOMPARE(printer.pageSizeMM(), sizeMMf);
+
+ // QPrinter::paperSize() always returns set orientation
+ QCOMPARE(printer.paperSize(QPrinter::Millimeter), sizeMMf.transposed());
+
+ // QPagedPaintDevice::widthMM() and heightMM() are paint metrics and always return set orientation
+ QCOMPARE(printer.widthMM(), qRound(heightMMf - leftMMf - rightMMf));
+ QCOMPARE(printer.heightMM(), qRound(widthMMf - topMMf - bottomMMf));
+
+ // QPrinter::paperRect() always returns set orientation
+ QCOMPARE(printer.paperRect(QPrinter::Millimeter), QRectF(0, 0, heightMMf, widthMMf));
+
+ // QPrinter::pageRect() always returns set orientation
+ QCOMPARE(printer.pageRect(QPrinter::Millimeter), QRectF(leftMMf, topMMf, heightMMf - leftMMf - rightMMf, widthMMf - topMMf - bottomMMf));
+
+
+ // Now while in Landscape mode, set the size again, results should be the same
+ if (pageSize < 0) {
+ printer.setPageSizeMM(sizeMMf);
+ QCOMPARE(printer.pageSize(), QPrinter::Custom);
+ } else {
+ printer.setPageSize(QPrinter::PageSize(pageSize));
+ QCOMPARE(printer.pageSize(), QPrinter::PageSize(pageSize));
+ }
+ QCOMPARE(printer.orientation(), QPrinter::Landscape);
+ if (setMargins) {
+ // Check margins unchanged from page size change
+ QCOMPARE(printer.margins().left, leftMMf);
+ QCOMPARE(printer.margins().right, rightMMf);
+ QCOMPARE(printer.margins().top, topMMf);
+ QCOMPARE(printer.margins().bottom, bottomMMf);
+ } else {
+ // Fetch the default margins for the printer and page size
+ // TODO Check against margins from print device when api added
+ leftMMf = printer.margins().left;
+ rightMMf = printer.margins().right;
+ topMMf = printer.margins().top;
+ bottomMMf = printer.margins().bottom;
+ }
+
+ // QPagedPaintDevice::pageSizeMM() always returns Portrait
+ QCOMPARE(printer.pageSizeMM(), sizeMMf);
+
+ // QPrinter::paperSize() always returns set orientation
+ QCOMPARE(printer.paperSize(QPrinter::Millimeter), sizeMMf.transposed());
+
+ // QPagedPaintDevice::widthMM() and heightMM() are paint metrics and always return set orientation
+ QCOMPARE(printer.widthMM(), qRound(heightMMf - leftMMf - rightMMf));
+ QCOMPARE(printer.heightMM(), qRound(widthMMf - topMMf - bottomMMf));
+
+ // QPrinter::paperRect() always returns set orientation
+ QCOMPARE(printer.paperRect(QPrinter::Millimeter), QRectF(0, 0, heightMMf, widthMMf));
+
+ // QPrinter::pageRect() always returns set orientation
+ QCOMPARE(printer.pageRect(QPrinter::Millimeter), QRectF(leftMMf, topMMf, heightMMf - leftMMf - rightMMf, widthMMf - topMMf - bottomMMf));
+}
+
#endif // QT_NO_PRINTER
QTEST_MAIN(tst_QPrinter)
diff --git a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp
index fb2609b7ec..294c90fdd3 100644
--- a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp
+++ b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp
@@ -267,8 +267,14 @@ void tst_QPrinterInfo::testForPaperSizes()
// In the meantime just exercise the code path and print-out for inspection.
QList<QPrinterInfo> printers = QPrinterInfo::availablePrinters();
- for (int i = 0; i < printers.size(); ++i)
- qDebug() << "Printer: " << printers.at(i).printerName() << " Paper Sizes: " << printers.at(i).supportedPaperSizes();
+ for (int i = 0; i < printers.size(); ++i) {
+ qDebug() << "Printer : " << printers.at(i).printerName() << printers.at(i).defaultPageSize();
+ qDebug() << "Paper Sizes : " << printers.at(i).supportedPageSizes();
+ qDebug() << "Custom Sizes : " << printers.at(i).supportsCustomPageSizes();
+ qDebug() << "Physical Sizes: " << printers.at(i).minimumPhysicalPageSize()
+ << printers.at(i).maximumPhysicalPageSize();
+ qDebug() << "";
+ }
}
void tst_QPrinterInfo::testConstructors()
@@ -284,17 +290,41 @@ void tst_QPrinterInfo::testConstructors()
for (int i = 0; i < printers.size(); ++i) {
QPrinterInfo copy1(printers.at(i));
- QCOMPARE(copy1.printerName(), printers.at(i).printerName());
- QCOMPARE(copy1.isNull(), printers.at(i).isNull());
- QCOMPARE(copy1.isDefault(), printers.at(i).isDefault());
- QCOMPARE(copy1.supportedPaperSizes(), printers.at(i).supportedPaperSizes());
+ QCOMPARE(copy1.printerName(), printers.at(i).printerName());
+ QCOMPARE(copy1.description(), printers.at(i).description());
+ QCOMPARE(copy1.location(), printers.at(i).location());
+ QCOMPARE(copy1.makeAndModel(), printers.at(i).makeAndModel());
+ QCOMPARE(copy1.isNull(), printers.at(i).isNull());
+ QCOMPARE(copy1.isDefault(), printers.at(i).isDefault());
+ QCOMPARE(copy1.isRemote(), printers.at(i).isRemote());
+ QCOMPARE(copy1.state(), printers.at(i).state());
+ QCOMPARE(copy1.supportedPageSizes(), printers.at(i).supportedPageSizes());
+ QCOMPARE(copy1.defaultPageSize(), printers.at(i).defaultPageSize());
+ QCOMPARE(copy1.supportsCustomPageSizes(), printers.at(i).supportsCustomPageSizes());
+ QCOMPARE(copy1.minimumPhysicalPageSize(), printers.at(i).minimumPhysicalPageSize());
+ QCOMPARE(copy1.maximumPhysicalPageSize(), printers.at(i).maximumPhysicalPageSize());
+ QCOMPARE(copy1.supportedPaperSizes(), printers.at(i).supportedPaperSizes());
+ QCOMPARE(copy1.supportedSizesWithNames(), printers.at(i).supportedSizesWithNames());
+ QCOMPARE(copy1.supportedResolutions(), printers.at(i).supportedResolutions());
QPrinter printer(printers.at(i));
QPrinterInfo copy2(printer);
- QCOMPARE(copy2.printerName(), printers.at(i).printerName());
- QCOMPARE(copy2.isNull(), printers.at(i).isNull());
- QCOMPARE(copy2.isDefault(), printers.at(i).isDefault());
- QCOMPARE(copy2.supportedPaperSizes(), printers.at(i).supportedPaperSizes());
+ QCOMPARE(copy2.printerName(), printers.at(i).printerName());
+ QCOMPARE(copy2.description(), printers.at(i).description());
+ QCOMPARE(copy2.location(), printers.at(i).location());
+ QCOMPARE(copy2.makeAndModel(), printers.at(i).makeAndModel());
+ QCOMPARE(copy2.isNull(), printers.at(i).isNull());
+ QCOMPARE(copy2.isDefault(), printers.at(i).isDefault());
+ QCOMPARE(copy2.isRemote(), printers.at(i).isRemote());
+ QCOMPARE(copy2.state(), printers.at(i).state());
+ QCOMPARE(copy2.supportedPageSizes(), printers.at(i).supportedPageSizes());
+ QCOMPARE(copy2.defaultPageSize(), printers.at(i).defaultPageSize());
+ QCOMPARE(copy2.supportsCustomPageSizes(), printers.at(i).supportsCustomPageSizes());
+ QCOMPARE(copy2.minimumPhysicalPageSize(), printers.at(i).minimumPhysicalPageSize());
+ QCOMPARE(copy2.maximumPhysicalPageSize(), printers.at(i).maximumPhysicalPageSize());
+ QCOMPARE(copy2.supportedPaperSizes(), printers.at(i).supportedPaperSizes());
+ QCOMPARE(copy2.supportedSizesWithNames(), printers.at(i).supportedSizesWithNames());
+ QCOMPARE(copy2.supportedResolutions(), printers.at(i).supportedResolutions());
}
}
@@ -311,13 +341,20 @@ void tst_QPrinterInfo::testAssignment()
for (int i = 0; i < printers.size(); ++i) {
QPrinterInfo copy;
copy = printers.at(i);
- QCOMPARE(copy.printerName(), printers.at(i).printerName());
- QCOMPARE(copy.isNull(), printers.at(i).isNull());
- QCOMPARE(copy.isDefault(), printers.at(i).isDefault());
- QCOMPARE(copy.description(), printers.at(i).description());
- QCOMPARE(copy.location(), printers.at(i).location());
- QCOMPARE(copy.makeAndModel(), printers.at(i).makeAndModel());
- QCOMPARE(copy.supportedPaperSizes(), printers.at(i).supportedPaperSizes());
+ QCOMPARE(copy.printerName(), printers.at(i).printerName());
+ QCOMPARE(copy.description(), printers.at(i).description());
+ QCOMPARE(copy.location(), printers.at(i).location());
+ QCOMPARE(copy.makeAndModel(), printers.at(i).makeAndModel());
+ QCOMPARE(copy.isNull(), printers.at(i).isNull());
+ QCOMPARE(copy.isDefault(), printers.at(i).isDefault());
+ QCOMPARE(copy.isRemote(), printers.at(i).isRemote());
+ QCOMPARE(copy.state(), printers.at(i).state());
+ QCOMPARE(copy.supportedPageSizes(), printers.at(i).supportedPageSizes());
+ QCOMPARE(copy.defaultPageSize(), printers.at(i).defaultPageSize());
+ QCOMPARE(copy.supportsCustomPageSizes(), printers.at(i).supportsCustomPageSizes());
+ QCOMPARE(copy.minimumPhysicalPageSize(), printers.at(i).minimumPhysicalPageSize());
+ QCOMPARE(copy.maximumPhysicalPageSize(), printers.at(i).maximumPhysicalPageSize());
+ QCOMPARE(copy.supportedResolutions(), printers.at(i).supportedResolutions());
}
}
@@ -329,16 +366,19 @@ void tst_QPrinterInfo::namedPrinter()
foreach (const QPrinterInfo &pi, printers) {
QPrinterInfo pi2 = QPrinterInfo::printerInfo(pi.printerName());
- qDebug() << "Printer: " << pi2.printerName() << " : " << pi2.description() << " : "
- << pi2.location() << " : " << pi2.makeAndModel() << " : "
- << pi2.isNull() << " : " << pi2.isDefault();
- QCOMPARE(pi2.printerName(), pi.printerName());
- QCOMPARE(pi2.description(), pi.description());
- QCOMPARE(pi2.location(), pi.location());
- QCOMPARE(pi2.makeAndModel(), pi.makeAndModel());
- QCOMPARE(pi2.supportedPaperSizes(), pi.supportedPaperSizes());
- QCOMPARE(pi2.isNull(), pi.isNull());
- QCOMPARE(pi2.isDefault(), pi.isDefault());
+ QCOMPARE(pi2.printerName(), pi.printerName());
+ QCOMPARE(pi2.description(), pi.description());
+ QCOMPARE(pi2.location(), pi.location());
+ QCOMPARE(pi2.makeAndModel(), pi.makeAndModel());
+ QCOMPARE(pi2.isNull(), pi.isNull());
+ QCOMPARE(pi2.isDefault(), pi.isDefault());
+ QCOMPARE(pi2.isRemote(), pi.isRemote());
+ QCOMPARE(pi2.supportedPageSizes(), pi.supportedPageSizes());
+ QCOMPARE(pi2.defaultPageSize(), pi.defaultPageSize());
+ QCOMPARE(pi2.supportsCustomPageSizes(), pi.supportsCustomPageSizes());
+ QCOMPARE(pi2.minimumPhysicalPageSize(), pi.minimumPhysicalPageSize());
+ QCOMPARE(pi2.maximumPhysicalPageSize(), pi.maximumPhysicalPageSize());
+ QCOMPARE(pi2.supportedResolutions(), pi.supportedResolutions());
}
}
#endif // QT_NO_PRINTER
diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
index 38f561dbaa..5f1eb99524 100644
--- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
@@ -211,6 +211,8 @@ private slots:
void QTBUG_6852();
void QTBUG_5765_data() { generic_data("QMYSQL"); }
void QTBUG_5765();
+ void QTBUG_12186_data() { generic_data("QSQLITE"); }
+ void QTBUG_12186();
void QTBUG_14132_data() { generic_data("QOCI"); }
void QTBUG_14132();
void QTBUG_18435_data() { generic_data("QODBC"); }
@@ -3054,6 +3056,27 @@ void tst_QSqlQuery::QTBUG_551()
QCOMPARE(res_outLst[2].toString(), QLatin1String("3. Value is 2"));
}
+void tst_QSqlQuery::QTBUG_12186()
+{
+ QFETCH( QString, dbName );
+ QSqlDatabase db = QSqlDatabase::database(dbName);
+
+ // make sure that query.boundValues() returns the values in the right order even for more than 16 placeholders
+ QSqlQuery query(db);
+ query.prepare("INSERT INTO person (col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11, col12, col13, col14, col15, col16, col17, col18) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+
+ QList<QVariant> values;
+
+ for (int i = 0; i < 18; ++i)
+ values << i;
+
+ foreach (QVariant v, values)
+ query.bindValue(v.toInt(), v);
+
+ QCOMPARE(query.boundValues().values(), values);
+}
+
void tst_QSqlQuery::QTBUG_14132()
{
QFETCH( QString, dbName );
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
index 54a3a85e87..d360a646f1 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
@@ -146,7 +146,6 @@ private slots:
void saveButtonText();
void clearLineEdit();
void enableChooseButton();
- void hooks();
void widgetlessNativeDialog();
void trailingDotsAndSpaces();
#ifdef Q_OS_UNIX
@@ -1308,98 +1307,6 @@ void tst_QFiledialog::enableChooseButton()
QCOMPARE(button->isEnabled(), true);
}
-QT_BEGIN_NAMESPACE
-typedef QString (*_qt_filedialog_existing_directory_hook)(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options);
-extern Q_GUI_EXPORT _qt_filedialog_existing_directory_hook qt_filedialog_existing_directory_hook;
-QT_END_NAMESPACE
-QString existing(QWidget *, const QString &, const QString &, QFileDialog::Options) {
- return "dir";
-}
-
-QT_BEGIN_NAMESPACE
-typedef QString (*_qt_filedialog_open_filename_hook)(QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options);
-extern Q_GUI_EXPORT _qt_filedialog_open_filename_hook qt_filedialog_open_filename_hook;
-QT_END_NAMESPACE
-QString openName(QWidget *, const QString &, const QString &, const QString &, QString *, QFileDialog::Options) {
- return "openName";
-}
-
-QT_BEGIN_NAMESPACE
-typedef QStringList (*_qt_filedialog_open_filenames_hook)(QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options);
-extern Q_GUI_EXPORT _qt_filedialog_open_filenames_hook qt_filedialog_open_filenames_hook;
-QT_END_NAMESPACE
-QStringList openNames(QWidget *, const QString &, const QString &, const QString &, QString *, QFileDialog::Options) {
- return QStringList("openNames");
-}
-
-QT_BEGIN_NAMESPACE
-typedef QString (*_qt_filedialog_save_filename_hook)(QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options);
-extern Q_GUI_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_filename_hook;
-QT_END_NAMESPACE
-QString saveName(QWidget *, const QString &, const QString &, const QString &, QString *, QFileDialog::Options) {
- return "saveName";
-}
-
-QT_BEGIN_NAMESPACE
-typedef QUrl (*_qt_filedialog_existing_directory_url_hook)(QWidget *parent, const QString &caption, const QUrl &dir, QFileDialog::Options options, const QStringList &supportedSchemes);
-extern Q_WIDGETS_EXPORT _qt_filedialog_existing_directory_url_hook qt_filedialog_existing_directory_url_hook;
-QT_END_NAMESPACE
-QUrl existingUrl(QWidget *, const QString &, const QUrl &, QFileDialog::Options, const QStringList &) {
- return QUrl("http://dirUrl");
-}
-
-QT_BEGIN_NAMESPACE
-typedef QUrl (*_qt_filedialog_open_file_url_hook)(QWidget * parent, const QString &caption, const QUrl &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options, const QStringList &supportedSchemes);
-extern Q_WIDGETS_EXPORT _qt_filedialog_open_file_url_hook qt_filedialog_open_file_url_hook;
-QT_END_NAMESPACE
-QUrl openUrl(QWidget *, const QString &, const QUrl &, const QString &, QString *, QFileDialog::Options, const QStringList &) {
- return QUrl("http://openUrl");
-}
-
-QT_BEGIN_NAMESPACE
-typedef QList<QUrl> (*_qt_filedialog_open_file_urls_hook)(QWidget * parent, const QString &caption, const QUrl &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options, const QStringList &supportedSchemes);
-extern Q_WIDGETS_EXPORT _qt_filedialog_open_file_urls_hook qt_filedialog_open_file_urls_hook;
-QT_END_NAMESPACE
-QList<QUrl> openUrls(QWidget *, const QString &, const QUrl &, const QString &, QString *, QFileDialog::Options, const QStringList &) {
- return QList<QUrl>() << QUrl("http://openUrls");
-}
-
-QT_BEGIN_NAMESPACE
-typedef QUrl (*_qt_filedialog_save_file_url_hook)(QWidget * parent, const QString &caption, const QUrl &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options, const QStringList &supportedSchemes);
-extern Q_WIDGETS_EXPORT _qt_filedialog_save_file_url_hook qt_filedialog_save_file_url_hook;
-QT_END_NAMESPACE
-QUrl saveUrl(QWidget *, const QString &, const QUrl &, const QString &, QString *, QFileDialog::Options, const QStringList &) {
- return QUrl("http://saveUrl");
-}
-
-
-void tst_QFiledialog::hooks()
-{
- qt_filedialog_existing_directory_hook = &existing;
- qt_filedialog_save_filename_hook = &saveName;
- qt_filedialog_open_filename_hook = &openName;
- qt_filedialog_open_filenames_hook = &openNames;
-
- QCOMPARE(QFileDialog::getExistingDirectory(), QString("dir"));
- QCOMPARE(QFileDialog::getOpenFileName(), QString("openName"));
- QCOMPARE(QFileDialog::getOpenFileNames(), QStringList("openNames"));
- QCOMPARE(QFileDialog::getSaveFileName(), QString("saveName"));
- QCOMPARE(QFileDialog::getExistingDirectoryUrl(), QUrl::fromLocalFile("dir"));
- QCOMPARE(QFileDialog::getOpenFileUrl(), QUrl::fromLocalFile("openName"));
- QCOMPARE(QFileDialog::getOpenFileUrls(), QList<QUrl>() << QUrl::fromLocalFile("openNames"));
- QCOMPARE(QFileDialog::getSaveFileUrl(), QUrl::fromLocalFile("saveName"));
-
- qt_filedialog_existing_directory_url_hook = &existingUrl;
- qt_filedialog_save_file_url_hook = &saveUrl;
- qt_filedialog_open_file_url_hook = &openUrl;
- qt_filedialog_open_file_urls_hook = &openUrls;
-
- QCOMPARE(QFileDialog::getExistingDirectoryUrl(), QUrl("http://dirUrl"));
- QCOMPARE(QFileDialog::getOpenFileUrl(), QUrl("http://openUrl"));
- QCOMPARE(QFileDialog::getOpenFileUrls(), QList<QUrl>() << QUrl("http://openUrls"));
- QCOMPARE(QFileDialog::getSaveFileUrl(), QUrl("http://saveUrl"));
-}
-
void tst_QFiledialog::widgetlessNativeDialog()
{
if (!QGuiApplicationPrivate::platformTheme()->usePlatformNativeDialog(QPlatformTheme::FileDialog))
diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
index 217fb4c30b..47cf657289 100644
--- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
@@ -294,7 +294,7 @@ void tst_QFileDialog2::showNameFilterDetails()
void tst_QFileDialog2::unc()
{
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
// Only test UNC on Windows./
QString dir("\\\\" + QtNetworkSettings::winServerName() + "\\testsharewritable");
#else
diff --git a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
index 1768106100..49e3cfe4ab 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -1365,14 +1365,22 @@ void tst_QGraphicsAnchorLayout::hardComplexS60()
delete p;
}
+static inline QByteArray msgStability(const QRectF &actual, const QRectF &expected, int pass, int item)
+{
+ QString result;
+ QDebug(&result)
+ << "The layout has several solutions, but which solution it picks is not stable ("
+ << actual << "!=" << expected << ", iteration" << pass << ", item" << item << ')';
+ return result.toLocal8Bit();
+}
+
void tst_QGraphicsAnchorLayout::stability()
{
QVector<QRectF> geometries;
geometries.resize(7);
- QGraphicsWidget *p = new QGraphicsWidget(0, Qt::Window);
- bool sameAsPreviousArrangement = true;
+ QGraphicsWidget p(0, Qt::Window);
// it usually fails after 3-4 iterations
- for (int pass = 0; pass < 20 && sameAsPreviousArrangement; ++pass) {
+ for (int pass = 0; pass < 20; ++pass) {
// In case we need to "scramble" the heap allocator to provoke this bug.
//static const int primes[] = {2, 3, 5, 13, 89, 233, 1597, 28657, 514229}; // fibo primes
//const int primeCount = sizeof(primes)/sizeof(int);
@@ -1380,23 +1388,22 @@ void tst_QGraphicsAnchorLayout::stability()
//void *mem = malloc(alloc);
//free(mem);
QGraphicsAnchorLayout *l = createAmbiguousS60Layout();
- p->setLayout(l);
+ p.setLayout(l);
QSizeF layoutMinimumSize = l->effectiveSizeHint(Qt::MinimumSize);
l->setGeometry(QRectF(QPointF(0,0), layoutMinimumSize));
QApplication::processEvents();
- for (int i = l->count() - 1; i >=0 && sameAsPreviousArrangement; --i) {
- QRectF geom = l->itemAt(i)->geometry();
+ for (int i = l->count() - 1; i >=0; --i) {
+ const QRectF actualGeom = l->itemAt(i)->geometry();
if (pass != 0) {
- sameAsPreviousArrangement = (geometries[i] == geom);
+ if (actualGeom != geometries[i])
+ QEXPECT_FAIL("", msgStability(actualGeom, geometries[i], pass, i).constData(), Abort);
+ QCOMPARE(actualGeom, geometries[i]);
}
- geometries[i] = geom;
+ geometries[i] = actualGeom;
}
- p->setLayout(0); // uninstalls and deletes the layout
+ p.setLayout(0); // uninstalls and deletes the layout
QApplication::processEvents();
}
- delete p;
- QEXPECT_FAIL("", "The layout have several solutions, but which solution it picks is not stable", Continue);
- QCOMPARE(sameAsPreviousArrangement, true);
}
void tst_QGraphicsAnchorLayout::delete_anchor()
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
index de7c528825..84466b92d1 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -3660,7 +3660,7 @@ void tst_QGraphicsItem::setGroup2()
oldSceneTransform = rect->sceneTransform();
rect->setGroup(0);
- QCOMPARE(rect->sceneTransform(), oldSceneTransform);
+ qFuzzyCompare(rect->sceneTransform(), oldSceneTransform);
}
void tst_QGraphicsItem::nestedGroups()
diff --git a/tests/auto/widgets/itemviews/qabstractitemview/qabstractitemview.pro b/tests/auto/widgets/itemviews/qabstractitemview/qabstractitemview.pro
index 8fbc3c15a8..2f0ca73265 100644
--- a/tests/auto/widgets/itemviews/qabstractitemview/qabstractitemview.pro
+++ b/tests/auto/widgets/itemviews/qabstractitemview/qabstractitemview.pro
@@ -1,5 +1,4 @@
CONFIG += testcase
-CONFIG += parallel_test
TARGET = tst_qabstractitemview
QT += widgets testlib
SOURCES += tst_qabstractitemview.cpp
diff --git a/tests/auto/widgets/itemviews/qcolumnview/qcolumnview.pro b/tests/auto/widgets/itemviews/qcolumnview/qcolumnview.pro
index 2cc8e9ea01..5096cc691a 100644
--- a/tests/auto/widgets/itemviews/qcolumnview/qcolumnview.pro
+++ b/tests/auto/widgets/itemviews/qcolumnview/qcolumnview.pro
@@ -1,5 +1,4 @@
CONFIG += testcase
-CONFIG += parallel_test
QT += widgets widgets-private
QT += gui-private core-private testlib
diff --git a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp
index 1ed33b9233..ebfc5751e7 100644
--- a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp
+++ b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp
@@ -411,7 +411,10 @@ void tst_QColumnView::scrollTo()
ColumnView view(&topLevel);
view.resize(200, 200);
topLevel.show();
+ topLevel.activateWindow();
centerOnScreen(&topLevel);
+ QVERIFY(QTest::qWaitForWindowActive(&topLevel));
+
view.scrollTo(QModelIndex(), QAbstractItemView::EnsureVisible);
QCOMPARE(view.HorizontalOffset(), 0);
diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
index 24e3ac2c99..5a36ffc671 100644
--- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
+++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
@@ -99,6 +99,7 @@ private slots:
void task232085_spinBoxLineEditBg();
void changeStyleInChangeEvent();
void QTBUG15910_crashNullWidget();
+ void QTBUG36933_brokenPseudoClassLookup();
//at the end because it mess with the style.
void widgetStyle();
@@ -1656,6 +1657,37 @@ void tst_QStyleSheetStyle::QTBUG15910_crashNullWidget()
QVERIFY(QTest::qWaitForWindowExposed(&w));
}
+void tst_QStyleSheetStyle::QTBUG36933_brokenPseudoClassLookup()
+{
+ const int rowCount = 10;
+ const int columnCount = 10;
+
+ QTableWidget widget(rowCount, columnCount);
+
+ for (int row = 0; row < rowCount; ++row) {
+ for (int column = 0; column < columnCount; ++column)
+ widget.setItem(row, column, new QTableWidgetItem(QStringLiteral("row %1 column %2").arg(row + 1).arg(column + 1)));
+
+ // put no visible text for the vertical headers, but still put some text or they will collapse
+ widget.setVerticalHeaderItem(row, new QTableWidgetItem(QStringLiteral(" ")));
+ }
+
+ // parsing of this stylesheet must not crash, and it must be correctly applied
+ widget.setStyleSheet(QStringLiteral("QHeaderView::section:vertical { background-color: #FF0000 }"));
+
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+
+ widget.activateWindow();
+ QApplication::setActiveWindow(&widget);
+ QVERIFY(QTest::qWaitForWindowActive(&widget));
+
+ QHeaderView *verticalHeader = widget.verticalHeader();
+ QImage image(verticalHeader->size(), QImage::Format_ARGB32);
+ verticalHeader->render(&image);
+ QVERIFY(testForColors(image, QColor(0xFF, 0x00, 0x00)));
+}
+
QTEST_MAIN(tst_QStyleSheetStyle)
#include "tst_qstylesheetstyle.moc"
diff --git a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp
index bbd71a9284..e8a21341b1 100644
--- a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp
+++ b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp
@@ -407,7 +407,7 @@ void tst_QScroller::scroll()
// now we should be scrolling
QTRY_COMPARE( s1->state(), QScroller::Scrolling );
- // wait until finished, check that no further first scroll is send
+ // wait until finished, check that no further first scroll is sent
sw->receivedFirst = false;
sw->receivedScroll = false;
while (s1->state() == QScroller::Scrolling)
diff --git a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp
index adb3c26dce..4b577d59e5 100644
--- a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp
+++ b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp
@@ -990,15 +990,12 @@ void tst_QAbstractSlider::sliderPressedReleased()
QRect rect = slider->style()->subControlRect(QStyle::ComplexControl(control), &option,
QStyle::SubControl(subControl), slider);
+ if (qApp->style()->styleHint(QStyle::SH_ScrollBar_LeftClickAbsolutePosition))
+ QSKIP("The result depends on system setting on mac");
+
QTest::mousePress(slider, Qt::LeftButton, 0, QPoint(rect.center().x() + 2, rect.center().y() + 2));
-#ifdef Q_OS_MAC
- QEXPECT_FAIL("scrollbar on the groove", "QTBUG-23679", Continue);
-#endif
QCOMPARE(spy1.count(), expectedCount);
QTest::mouseRelease(slider, Qt::LeftButton, 0, rect.center());
-#ifdef Q_OS_MAC
- QEXPECT_FAIL("scrollbar on the groove", "QTBUG-23679", Continue);
-#endif
QCOMPARE(spy2.count(), expectedCount);
delete slider;
diff --git a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp
index 51dd0852ee..4e0c563fc1 100644
--- a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp
+++ b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp
@@ -147,6 +147,10 @@ void tst_QScrollBar::task_209492()
QApplication::sendEvent(verticalScrollBar, &mouseReleaseEvent);
// Check that the action was triggered once.
+
+#ifdef Q_OS_MAC
+ QSKIP("The result depends on system setting and is not relevant on Mac");
+#endif
QCOMPARE(scrollArea.scrollCount, 1);
QCOMPARE(spy.count(), 1);
}