summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/auto/android/runtests_androiddeployqt.pl4
-rw-r--r--tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp4
-rw-r--r--tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp3
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp2
-rw-r--r--tests/auto/corelib/io/qsettings/tst_qsettings.cpp165
-rw-r--r--tests/auto/corelib/json/tst_qtjson.cpp8
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp6
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp21
-rw-r--r--tests/auto/gui/kernel/qevent/tst_qevent.cpp30
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp54
-rw-r--r--tests/auto/gui/qopengl/tst_qopengl.cpp88
-rw-r--r--tests/auto/gui/text/qfont/tst_qfont.cpp34
-rw-r--r--tests/auto/gui/text/qfontdatabase/FreeMono.ttfbin267400 -> 0 bytes
-rw-r--r--tests/auto/gui/text/qfontdatabase/LED_REAL.TTFbin0 -> 4708 bytes
-rw-r--r--tests/auto/gui/text/qfontdatabase/LED_REAL_readme.txt34
-rw-r--r--tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp2
-rw-r--r--tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp287
-rw-r--r--tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp22
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp12
-rw-r--r--tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp20
-rw-r--r--tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.h3
-rw-r--r--tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm83
-rw-r--r--tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp12
-rw-r--r--tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp32
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp41
-rw-r--r--tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp96
-rw-r--r--tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp80
-rw-r--r--tests/manual/dialogs/dialogs.pro1
-rw-r--r--tests/manual/dialogs/printdialogpanel.cpp490
-rw-r--r--tests/manual/dialogs/printdialogpanel.h62
-rw-r--r--tests/manual/dialogs/printdialogpanel.ui677
-rw-r--r--tests/manual/dialogs/utils.cpp21
-rw-r--r--tests/manual/dialogs/utils.h4
33 files changed, 1968 insertions, 430 deletions
diff --git a/tests/auto/android/runtests_androiddeployqt.pl b/tests/auto/android/runtests_androiddeployqt.pl
index 1cc52d0495..3d57dcfd65 100755
--- a/tests/auto/android/runtests_androiddeployqt.pl
+++ b/tests/auto/android/runtests_androiddeployqt.pl
@@ -217,6 +217,10 @@ sub startTest
print "Someone should kill $packageName\n";
return 1;
}
+
+ # Wait for three seconds to allow process to write all data
+ sleep(3);
+
system("$adb_tool $device_serial pull /data/data/$packageName/output.xml $output_dir/$output_file.xml") if ($get_xml);
system("$adb_tool $device_serial pull /data/data/$packageName/output.txt $output_dir/$output_file.txt") if ($get_txt);
return 1;
diff --git a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp
index 79df4b7055..0b4f0e3c4b 100644
--- a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp
+++ b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp
@@ -167,7 +167,7 @@ void tst_QNumeric::floatDistance()
QFETCH(float, val1);
QFETCH(float, val2);
QFETCH(quint32, expectedDistance);
-#ifdef Q_OS_BLACKBERRY
+#ifdef Q_OS_QNX
QEXPECT_FAIL("denormal", "See QTBUG-37094", Continue);
#endif
QCOMPARE(qFloatDistance(val1, val2), expectedDistance);
@@ -214,7 +214,7 @@ void tst_QNumeric::floatDistance_double()
QFETCH(double, val1);
QFETCH(double, val2);
QFETCH(quint64, expectedDistance);
-#ifdef Q_OS_BLACKBERRY
+#ifdef Q_OS_QNX
QEXPECT_FAIL("denormal", "See QTBUG-37094", Continue);
#endif
QCOMPARE(qFloatDistance(val1, val2), expectedDistance);
diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
index b681cec802..a58c7dfb4b 100644
--- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
+++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
@@ -324,6 +324,9 @@ void tst_QFileSystemWatcher::watchDirectory()
fileName = changedSpy.at(1).at(0).toString();
QCOMPARE(fileName, testDir.absolutePath());
+ // flush pending signals (like the one from the rmdir above)
+ timer.start(5000);
+ eventLoop.exec();
changedSpy.clear();
// recreate the file, we should not get any notification
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index f5aa2c2412..b67166272b 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -1069,7 +1069,7 @@ void tst_QProcess::softExitInSlots()
SoftExitProcess proc(i);
proc.writeAfterStart("OLEBOLE", 8); // include the \0
proc.start(appName);
- QTRY_VERIFY(proc.waitedForFinished);
+ QTRY_VERIFY_WITH_TIMEOUT(proc.waitedForFinished, 10000);
QCOMPARE(proc.state(), QProcess::NotRunning);
}
}
diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
index 42c360f2d8..501ad6f415 100644
--- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
+++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
@@ -50,6 +50,7 @@
#include <QtCore/QString>
#include <QtCore/QDir>
#include <QtCore/QThread>
+#include <QtCore/QSysInfo>
#include <QtGui/QKeySequence>
#include <cctype>
@@ -73,10 +74,30 @@ Q_DECLARE_METATYPE(QSettings::Format)
QT_FORWARD_DECLARE_CLASS(QSettings)
+static inline bool canWriteNativeSystemSettings()
+{
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
+ HKEY key;
+ const LONG result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software", 0, KEY_WRITE, &key);
+ if (result == ERROR_SUCCESS)
+ RegCloseKey(key);
+ else
+ qErrnoWarning(result, "RegOpenKeyEx failed");
+ return result == ERROR_SUCCESS;
+#else // Q_OS_WIN && !Q_OS_WINRT
+ return true;
+#endif
+}
+
+static const char insufficientPermissionSkipMessage[] = "Insufficient permissions for this test.";
+
class tst_QSettings : public QObject
{
Q_OBJECT
+public:
+ tst_QSettings() : m_canWriteNativeSystemSettings(canWriteNativeSystemSettings()) {}
+
public slots:
void initTestCase();
void init();
@@ -145,6 +166,9 @@ private slots:
void testByteArray_data();
void testByteArray();
+
+private:
+ const bool m_canWriteNativeSystemSettings;
};
// Testing get/set functions
@@ -259,6 +283,8 @@ static void populateWithFormats()
void tst_QSettings::initTestCase()
{
+ if (!m_canWriteNativeSystemSettings)
+ qWarning("The test is not running with administrative rights. Some tests will be skipped.");
QSettings::Format custom1 = QSettings::registerFormat("custom1", readCustom1File, writeCustom1File);
QSettings::Format custom2 = QSettings::registerFormat("custom2", readCustom2File, writeCustom2File
#ifndef QT_QSETTINGS_ALWAYS_CASE_SENSITIVE_AND_FORGET_ORIGINAL_KEY_ORDER
@@ -276,17 +302,19 @@ void tst_QSettings::init()
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
QSettings("HKEY_CURRENT_USER\\Software\\software.org", QSettings::NativeFormat).clear();
- QSettings("HKEY_LOCAL_MACHINE\\Software\\software.org", QSettings::NativeFormat).clear();
QSettings("HKEY_CURRENT_USER\\Software\\other.software.org", QSettings::NativeFormat).clear();
- QSettings("HKEY_LOCAL_MACHINE\\Software\\other.software.org", QSettings::NativeFormat).clear();
QSettings("HKEY_CURRENT_USER\\Software\\foo", QSettings::NativeFormat).clear();
QSettings("HKEY_CURRENT_USER\\Software\\bar", QSettings::NativeFormat).clear();
QSettings("HKEY_CURRENT_USER\\Software\\bat", QSettings::NativeFormat).clear();
QSettings("HKEY_CURRENT_USER\\Software\\baz", QSettings::NativeFormat).clear();
- QSettings("HKEY_LOCAL_MACHINE\\Software\\foo", QSettings::NativeFormat).clear();
- QSettings("HKEY_LOCAL_MACHINE\\Software\\bar", QSettings::NativeFormat).clear();
- QSettings("HKEY_LOCAL_MACHINE\\Software\\bat", QSettings::NativeFormat).clear();
- QSettings("HKEY_LOCAL_MACHINE\\Software\\baz", QSettings::NativeFormat).clear();
+ if (m_canWriteNativeSystemSettings) {
+ QSettings("HKEY_LOCAL_MACHINE\\Software\\software.org", QSettings::NativeFormat).clear();
+ QSettings("HKEY_LOCAL_MACHINE\\Software\\other.software.org", QSettings::NativeFormat).clear();
+ QSettings("HKEY_LOCAL_MACHINE\\Software\\foo", QSettings::NativeFormat).clear();
+ QSettings("HKEY_LOCAL_MACHINE\\Software\\bar", QSettings::NativeFormat).clear();
+ QSettings("HKEY_LOCAL_MACHINE\\Software\\bat", QSettings::NativeFormat).clear();
+ QSettings("HKEY_LOCAL_MACHINE\\Software\\baz", QSettings::NativeFormat).clear();
+ }
if (QDir(settingsPath()).exists()) {
#if defined(Q_OS_WINCE)
removePath(settingsPath());
@@ -334,6 +362,9 @@ void tst_QSettings::ctor()
{
QFETCH(QSettings::Format, format);
+ if (!m_canWriteNativeSystemSettings && format == QSettings::NativeFormat)
+ QSKIP(insufficientPermissionSkipMessage);
+
{
QSettings settings1(format, QSettings::UserScope, "software.org", "KillerAPP");
QSettings settings2(format, QSettings::UserScope, "software.org");
@@ -1263,43 +1294,55 @@ void tst_QSettings::remove()
QSettings settings1(QSettings::UserScope, "software.org", "KillerAPP");
QSettings settings2(QSettings::UserScope, "software.org");
- QSettings settings3(QSettings::SystemScope, "software.org", "KillerAPP");
- QSettings settings4(QSettings::SystemScope, "software.org");
- settings4.setValue("key 1", "doodah");
- settings3.setValue("key 1", "blah");
+ QScopedPointer<QSettings> settings3;
+ QScopedPointer<QSettings> settings4;
+
+ if (m_canWriteNativeSystemSettings) {
+ settings3.reset(new QSettings(QSettings::SystemScope, "software.org", "KillerAPP"));
+ settings4.reset(new QSettings(QSettings::SystemScope, "software.org"));
+ settings3->setValue("key 1", "blah");
+ settings4->setValue("key 1", "doodah");
+ }
+
settings2.setValue("key 1", "whoa");
settings1.setValue("key 1", "gurgle");
QCOMPARE(settings1.value("key 1").toString(), QString("gurgle"));
QCOMPARE(settings2.value("key 1").toString(), QString("whoa"));
#if !defined(Q_OS_BLACKBERRY)
- QCOMPARE(settings3.value("key 1").toString(), QString("blah"));
- QCOMPARE(settings4.value("key 1").toString(), QString("doodah"));
+ if (m_canWriteNativeSystemSettings) {
+ QCOMPARE(settings3->value("key 1").toString(), QString("blah"));
+ QCOMPARE(settings4->value("key 1").toString(), QString("doodah"));
+ }
settings1.remove("key 1");
QCOMPARE(settings1.value("key 1").toString(), QString("whoa"));
QCOMPARE(settings2.value("key 1").toString(), QString("whoa"));
- QCOMPARE(settings3.value("key 1").toString(), QString("blah"));
- QCOMPARE(settings4.value("key 1").toString(), QString("doodah"));
+ if (m_canWriteNativeSystemSettings) {
+ QCOMPARE(settings3->value("key 1").toString(), QString("blah"));
+ QCOMPARE(settings4->value("key 1").toString(), QString("doodah"));
+ }
- settings2.remove("key 1");
- QCOMPARE(settings1.value("key 1").toString(), QString("blah"));
- QCOMPARE(settings2.value("key 1").toString(), QString("doodah"));
- QCOMPARE(settings3.value("key 1").toString(), QString("blah"));
- QCOMPARE(settings4.value("key 1").toString(), QString("doodah"));
-
- settings3.remove("key 1");
- QCOMPARE(settings1.value("key 1").toString(), QString("doodah"));
- QCOMPARE(settings2.value("key 1").toString(), QString("doodah"));
- QCOMPARE(settings3.value("key 1").toString(), QString("doodah"));
- QCOMPARE(settings4.value("key 1").toString(), QString("doodah"));
-
- settings4.remove("key 1");
- QVERIFY(!settings1.contains("key 1"));
- QVERIFY(!settings2.contains("key 1"));
- QVERIFY(!settings3.contains("key 1"));
- QVERIFY(!settings4.contains("key 1"));
+ if (m_canWriteNativeSystemSettings) {
+ settings2.remove("key 1");
+ QCOMPARE(settings1.value("key 1").toString(), QString("blah"));
+ QCOMPARE(settings2.value("key 1").toString(), QString("doodah"));
+ QCOMPARE(settings3->value("key 1").toString(), QString("blah"));
+ QCOMPARE(settings4->value("key 1").toString(), QString("doodah"));
+
+ settings3->remove("key 1");
+ QCOMPARE(settings1.value("key 1").toString(), QString("doodah"));
+ QCOMPARE(settings2.value("key 1").toString(), QString("doodah"));
+ QCOMPARE(settings3->value("key 1").toString(), QString("doodah"));
+ QCOMPARE(settings4->value("key 1").toString(), QString("doodah"));
+
+ settings4->remove("key 1");
+ QVERIFY(!settings1.contains("key 1"));
+ QVERIFY(!settings2.contains("key 1"));
+ QVERIFY(!settings3->contains("key 1"));
+ QVERIFY(!settings4->contains("key 1"));
+ }
#else
settings1.remove("key 1");
QCOMPARE(settings2.value("key 1").toString(), QString("whoa"));
@@ -1315,13 +1358,18 @@ void tst_QSettings::remove()
settings1.clear();
settings2.clear();
- settings3.clear();
- settings4.clear();
+ if (m_canWriteNativeSystemSettings) {
+ settings3->clear();
+ settings4->clear();
+ }
settings1.sync();
settings2.sync();
- settings3.sync();
- settings4.sync();
+
+ if (m_canWriteNativeSystemSettings) {
+ settings3->sync();
+ settings4->sync();
+ }
/*
Check that recursive removes work correctly when some of the
@@ -1556,6 +1604,9 @@ void tst_QSettings::setFallbacksEnabled()
{
QFETCH(QSettings::Format, format);
+ if (!m_canWriteNativeSystemSettings && format == QSettings::NativeFormat)
+ QSKIP(insufficientPermissionSkipMessage);
+
QSettings settings1(format, QSettings::UserScope, "software.org", "KillerAPP");
QSettings settings2(format, QSettings::UserScope, "software.org");
QSettings settings3(format, QSettings::SystemScope, "software.org", "KillerAPP");
@@ -2747,10 +2798,30 @@ void tst_QSettings::isWritable()
QSettings s1(format, QSettings::SystemScope, "software.org", "KillerAPP");
QSettings s2(format, QSettings::SystemScope, "software.org", "Something Different");
QSettings s3(format, QSettings::SystemScope, "foo.org", "Something Different");
+
if (s1.contains("foo")) {
- QVERIFY(s1.isWritable());
- QVERIFY(s2.isWritable());
- QVERIFY(s3.isWritable());
+#if defined(Q_OS_MACX)
+ if (QSysInfo::macVersion() >= QSysInfo::MV_10_9) {
+ QVERIFY(s1.isWritable());
+ if (format == QSettings::NativeFormat) {
+ QVERIFY(!s2.isWritable());
+ QVERIFY(!s3.isWritable());
+ } else {
+ QVERIFY(s2.isWritable());
+ QVERIFY(s3.isWritable());
+ }
+ } else if (QSysInfo::macVersion() >= QSysInfo::MV_10_7 &&
+ format == QSettings::NativeFormat) {
+ QVERIFY(!s1.isWritable());
+ QVERIFY(!s2.isWritable());
+ QVERIFY(!s3.isWritable());
+ } else
+#endif
+ {
+ QVERIFY(s1.isWritable());
+ QVERIFY(s2.isWritable());
+ QVERIFY(s3.isWritable());
+ }
} else {
QVERIFY(!s1.isWritable());
QVERIFY(!s2.isWritable());
@@ -2771,8 +2842,10 @@ void tst_QSettings::childGroups()
{
QFETCH(QSettings::Format, format);
+ const QSettings::Scope scope = m_canWriteNativeSystemSettings ? QSettings::SystemScope : QSettings::UserScope;
+
{
- QSettings settings(format, QSettings::SystemScope, "software.org");
+ QSettings settings(format, scope, "software.org");
settings.setValue("alpha", "1");
settings.setValue("alpha/a", "2");
settings.setValue("alpha/b", "3");
@@ -2789,7 +2862,7 @@ void tst_QSettings::childGroups()
for (int pass = 0; pass < 3; ++pass) {
QConfFile::clearCache();
- QSettings settings(format, QSettings::SystemScope, "software.org");
+ QSettings settings(format, scope, "software.org");
settings.setFallbacksEnabled(false);
if (pass == 1) {
settings.value("gamma/d");
@@ -2837,8 +2910,10 @@ void tst_QSettings::childKeys()
{
QFETCH(QSettings::Format, format);
+ const QSettings::Scope scope = m_canWriteNativeSystemSettings ? QSettings::SystemScope : QSettings::UserScope;
+
{
- QSettings settings(format, QSettings::SystemScope, "software.org");
+ QSettings settings(format, scope, "software.org");
settings.setValue("alpha", "1");
settings.setValue("alpha/a", "2");
settings.setValue("alpha/b", "3");
@@ -2855,7 +2930,7 @@ void tst_QSettings::childKeys()
for (int pass = 0; pass < 3; ++pass) {
QConfFile::clearCache();
- QSettings settings(format, QSettings::SystemScope, "software.org");
+ QSettings settings(format, scope, "software.org");
settings.setFallbacksEnabled(false);
if (pass == 1) {
settings.value("gamma/d");
@@ -2907,15 +2982,17 @@ void tst_QSettings::allKeys()
allKeys << "alpha" << "alpha/a" << "alpha/b" << "alpha/c" << "beta" << "gamma" << "gamma/d"
<< "gamma/d/e" << "gamma/f/g" << "omicron/h/i/j/x" << "omicron/h/i/k/y" << "zeta/z";
+ const QSettings::Scope scope = m_canWriteNativeSystemSettings ? QSettings::SystemScope : QSettings::UserScope;
+
{
- QSettings settings(format, QSettings::SystemScope, "software.org");
+ QSettings settings(format, scope, "software.org");
for (int i = 0; i < allKeys.size(); ++i)
settings.setValue(allKeys.at(i), QString::number(i + 1));
}
for (int pass = 0; pass < 3; ++pass) {
QConfFile::clearCache();
- QSettings settings(format, QSettings::SystemScope, "software.org");
+ QSettings settings(format, scope, "software.org");
settings.setFallbacksEnabled(false);
if (pass == 1) {
diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp
index 2f75ad631f..a17fe7561a 100644
--- a/tests/auto/corelib/json/tst_qtjson.cpp
+++ b/tests/auto/corelib/json/tst_qtjson.cpp
@@ -347,7 +347,7 @@ void tst_QtJson::testNumbers_2()
QJsonDocument jDocument2(QJsonDocument::fromJson(ba));
for (int power = 0; power <= 1075; power++) {
floatValues_1[power] = jDocument2.object().value(QString::number(power)).toDouble();
-#ifdef Q_OS_BLACKBERRY
+#ifdef Q_OS_QNX
if (power >= 970)
QEXPECT_FAIL("", "See QTBUG-37066", Abort);
#endif
@@ -1346,7 +1346,7 @@ void tst_QtJson::toJsonLargeNumericValues()
" ]\n"
"}\n";
-#ifdef Q_OS_BLACKBERRY
+#ifdef Q_OS_QNX
QEXPECT_FAIL("", "See QTBUG-37066", Continue);
#endif
QCOMPARE(json, expected);
@@ -1354,7 +1354,7 @@ void tst_QtJson::toJsonLargeNumericValues()
QJsonDocument doc;
doc.setObject(object);
json = doc.toJson();
-#ifdef Q_OS_BLACKBERRY
+#ifdef Q_OS_QNX
QEXPECT_FAIL("", "See QTBUG-37066", Continue);
#endif
QCOMPARE(json, expected);
@@ -1758,7 +1758,7 @@ void tst_QtJson::parseNumbers()
json += numbers[i].str;
json += " ]";
QJsonDocument doc = QJsonDocument::fromJson(json);
-#ifdef Q_OS_BLACKBERRY
+#ifdef Q_OS_QNX
if (0 == QString::compare(numbers[i].str, "1.1e-308"))
QEXPECT_FAIL("", "See QTBUG-37066", Abort);
#endif
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index 629a095f9d..5655d9f529 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -4876,10 +4876,8 @@ void tst_QString::localeAwareCompare()
DWORD oldLcid = GetUserDefaultLCID();
SetUserDefaultLCID(locale);
QCOMPARE(locale, GetUserDefaultLCID());
-#elif defined (Q_OS_MAC)
- QSKIP("Setting the locale is not supported on OS X (you can set the C locale, but that won't affect CFStringCompare which is used to compare strings)");
-#elif defined(QT_USE_ICU)
- QLocale::setDefault(QLocale(locale));
+#elif defined (Q_OS_MAC) || defined(QT_USE_ICU)
+ QSKIP("Setting the locale is not supported on OS X or ICU (you can set the C locale, but that won't affect localeAwareCompare)");
#else
if (!locale.isEmpty()) {
const char *newLocale = setlocale(LC_ALL, locale.toLatin1());
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index 01a56883bf..95a9b142ec 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -168,6 +168,8 @@ private slots:
void convertOverUnPreMul();
+ void scaled_QTBUG35972();
+
void cleanupFunctions();
};
@@ -2439,6 +2441,25 @@ void tst_QImage::convertOverUnPreMul()
}
}
+void tst_QImage::scaled_QTBUG35972()
+{
+ QImage src(532,519,QImage::Format_ARGB32_Premultiplied);
+ src.fill(QColor(Qt::white));
+ QImage dest(1000,1000,QImage::Format_ARGB32_Premultiplied);
+ dest.fill(QColor(Qt::white));
+ QPainter painter1(&dest);
+ const QTransform trf(1.25, 0,
+ 0, 1.25,
+ /*dx */ 15.900000000000034, /* dy */ 72.749999999999986);
+ painter1.setTransform(trf);
+ painter1.drawImage(QRectF(-2.6, -2.6, 425.6, 415.20000000000005), src, QRectF(0,0,532,519));
+
+ const quint32 *pixels = reinterpret_cast<const quint32 *>(dest.constBits());
+ int size = dest.width()*dest.height();
+ for (int i = 0; i < size; ++i)
+ QCOMPARE(pixels[i], 0xffffffff);
+}
+
static void cleanupFunction(void* info)
{
bool *called = static_cast<bool*>(info);
diff --git a/tests/auto/gui/kernel/qevent/tst_qevent.cpp b/tests/auto/gui/kernel/qevent/tst_qevent.cpp
index 3865eb00da..73f9486752 100644
--- a/tests/auto/gui/kernel/qevent/tst_qevent.cpp
+++ b/tests/auto/gui/kernel/qevent/tst_qevent.cpp
@@ -55,9 +55,14 @@ public:
private slots:
void registerEventType_data();
void registerEventType();
+ void exhaustEventTypeRegistration(); // keep behind registerEventType() test
+
+private:
+ bool registerEventTypeSucceeded; // track success of registerEventType for use by exhaustEventTypeRegistration()
};
tst_QEvent::tst_QEvent()
+ : registerEventTypeSucceeded(true)
{ }
tst_QEvent::~tst_QEvent()
@@ -72,17 +77,40 @@ void tst_QEvent::registerEventType_data()
QTest::newRow("default") << -1 << int(QEvent::MaxUser);
// hint not valid
QTest::newRow("User-1") << int(QEvent::User - 1) << int(QEvent::MaxUser - 1);
+ // hint not valid II
+ QTest::newRow("MaxUser+1") << int(QEvent::MaxUser + 1) << int(QEvent::MaxUser - 2);
// hint valid, but already taken
- QTest::newRow("MaxUser-1") << int(QEvent::MaxUser - 1) << int(QEvent::MaxUser - 2);
+ QTest::newRow("MaxUser-1") << int(QEvent::MaxUser - 1) << int(QEvent::MaxUser - 3);
// hint valid, but not taken
QTest::newRow("User + 1000") << int(QEvent::User + 1000) << int(QEvent::User + 1000);
}
void tst_QEvent::registerEventType()
{
+ const bool oldRegisterEventTypeSucceeded = registerEventTypeSucceeded;
+ registerEventTypeSucceeded = false;
QFETCH(int, hint);
QFETCH(int, expected);
QCOMPARE(QEvent::registerEventType(hint), expected);
+ registerEventTypeSucceeded = oldRegisterEventTypeSucceeded;
+}
+
+void tst_QEvent::exhaustEventTypeRegistration()
+{
+ if (!registerEventTypeSucceeded)
+ QSKIP("requires the previous test (registerEventType) to have finished successfully");
+
+ int i = QEvent::User;
+ int result;
+ while ((result = QEvent::registerEventType(i)) == i)
+ ++i;
+ QCOMPARE(i, int(QEvent::User + 1000));
+ QCOMPARE(result, int(QEvent::MaxUser - 4));
+ i = QEvent::User + 1001;
+ while ((result = QEvent::registerEventType(i)) == i)
+ ++i;
+ QCOMPARE(result, -1);
+ QCOMPARE(i, int(QEvent::MaxUser - 4));
}
QTEST_MAIN(tst_QEvent)
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index da142c80a6..eefa85a745 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -49,6 +49,10 @@
#include <QEvent>
#include <QStyleHints>
+#if defined(Q_OS_QNX)
+#include <QOpenGLContext>
+#endif
+
// For QSignalSpy slot connections.
Q_DECLARE_METATYPE(Qt::ScreenOrientation)
Q_DECLARE_METATYPE(QWindow::Visibility)
@@ -122,6 +126,9 @@ public:
{
reset();
setFlags(flags);
+#if defined(Q_OS_QNX)
+ setSurfaceType(QSurface::OpenGLSurface);
+#endif
}
void reset()
@@ -187,7 +194,12 @@ void tst_QWindow::resizeEventAfterResize()
// Make sure we get a resizeEvent after calling resize
window.resize(400, 100);
+#if defined(Q_OS_BLACKBERRY) // "window" is the "root" window and will always be shown fullscreen
+ // so we only expect one resize event
+ QTRY_COMPARE(window.received(QEvent::Resize), 1);
+#else
QTRY_COMPARE(window.received(QEvent::Resize), 2);
+#endif
}
void tst_QWindow::positioning_data()
@@ -244,13 +256,24 @@ void tst_QWindow::positioning()
window.setWindowState(Qt::WindowFullScreen);
QCoreApplication::processEvents();
+#if defined(Q_OS_BLACKBERRY) // "window" is the "root" window and will always be shown fullscreen
+ // so we only expect one resize event
+ Q_UNUSED(resizecount);
+ QTRY_COMPARE(window.received(QEvent::Resize), 1);
+#else
QTRY_COMPARE(window.received(QEvent::Resize), 2);
+#endif
QTest::qWait(2000);
window.setWindowState(Qt::WindowNoState);
QCoreApplication::processEvents();
+#if defined(Q_OS_BLACKBERRY) // "window" is the "root" window and will always be shown fullscreen
+ // so we only expect one resize event
+ QTRY_COMPARE(window.received(QEvent::Resize), 1);
+#else
QTRY_COMPARE(window.received(QEvent::Resize), resizecount);
+#endif
QTRY_COMPARE(originalPos, window.position());
QTRY_COMPARE(originalFramePos, window.framePosition());
@@ -309,6 +332,13 @@ void tst_QWindow::isActive()
QCoreApplication::processEvents();
QTRY_VERIFY(window.isExposed());
+#if defined(Q_OS_QNX) // We either need to create a eglSurface or a create a backing store
+ // and then post the window in order for screen to show the window
+ QOpenGLContext context;
+ context.create();
+ context.makeCurrent(&window);
+ context.swapBuffers(&window);
+#endif
QTRY_COMPARE(window.received(QEvent::Resize), 1);
QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
QVERIFY(window.isActive());
@@ -511,7 +541,7 @@ void tst_QWindow::testInputEvents()
// Now with null pointer as window. local param should not be utilized:
// handleMouseEvent() with tlw == 0 means the event is in global coords only.
window.mousePressButton = window.mouseReleaseButton = 0;
- QPointF nonWindowGlobal(500, 500); // not inside the window
+ QPointF nonWindowGlobal(2000, 500); // not inside the window
QWindowSystemInterface::handleMouseEvent(0, nonWindowGlobal, nonWindowGlobal, Qt::LeftButton);
QWindowSystemInterface::handleMouseEvent(0, nonWindowGlobal, nonWindowGlobal, Qt::NoButton);
QCoreApplication::processEvents();
@@ -913,10 +943,21 @@ void tst_QWindow::activateAndClose()
{
for (int i = 0; i < 10; ++i) {
QWindow window;
+#if defined(Q_OS_QNX)
+ window.setSurfaceType(QSurface::OpenGLSurface);
+#endif
// qWaitForWindowActive will block for the duration of
// of the timeout if the window is at 0,0
window.setGeometry(QGuiApplication::primaryScreen()->availableGeometry().adjusted(1, 1, -1, -1));
window.showNormal();
+#if defined(Q_OS_QNX) // We either need to create a eglSurface or a create a backing store
+ // and then post the window in order for screen to show the window
+ QTest::qWaitForWindowExposed(&window);
+ QOpenGLContext context;
+ context.create();
+ context.makeCurrent(&window);
+ context.swapBuffers(&window);
+#endif
window.requestActivate();
QVERIFY(QTest::qWaitForWindowActive(&window));
QCOMPARE(qGuiApp->focusWindow(), &window);
@@ -1252,15 +1293,26 @@ void tst_QWindow::initialSize()
Window w;
w.setWidth(200);
w.show();
+#if defined(Q_OS_BLACKBERRY) // "window" is the "root" window and will always be shown fullscreen
+ // so we only expect one resize event
+ QTRY_COMPARE(w.width(), qGuiApp->primaryScreen()->availableGeometry().width());
+#else
QTRY_COMPARE(w.width(), 200);
+#endif
QTRY_VERIFY(w.height() > 0);
}
{
Window w;
w.resize(200, 42);
w.show();
+#if defined(Q_OS_BLACKBERRY) // "window" is the "root" window and will always be shown fullscreen
+ // so we only expect one resize event
+ QTRY_COMPARE(w.width(), qGuiApp->primaryScreen()->availableGeometry().width());
+ QTRY_COMPARE(w.height(), qGuiApp->primaryScreen()->availableGeometry().height());
+#else
QTRY_COMPARE(w.width(), 200);
QTRY_COMPARE(w.height(), 42);
+#endif
}
}
diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp
index 4018c00a38..63fe8b9693 100644
--- a/tests/auto/gui/qopengl/tst_qopengl.cpp
+++ b/tests/auto/gui/qopengl/tst_qopengl.cpp
@@ -157,7 +157,22 @@ static QSurface *createSurface(int surfaceClass)
window->create();
return window;
} else if (surfaceClass == int(QSurface::Offscreen)) {
+ // Create a window and get the format from that. For example, if an EGL
+ // implementation provides 565 and 888 configs for PBUFFER_BIT but only
+ // 888 for WINDOW_BIT, we may end up with a pbuffer surface that is
+ // incompatible with the context since it could choose the 565 while the
+ // window and the context uses a config with 888.
+ static QSurfaceFormat format;
+ if (format.redBufferSize() == -1) {
+ QWindow *window = new QWindow;
+ window->setSurfaceType(QWindow::OpenGLSurface);
+ window->setGeometry(0, 0, 10, 10);
+ window->create();
+ format = window->format();
+ delete window;
+ }
QOffscreenSurface *offscreenSurface = new QOffscreenSurface;
+ offscreenSurface->setFormat(format);
offscreenSurface->create();
return offscreenSurface;
}
@@ -392,6 +407,10 @@ void qt_opengl_check_test_pattern(const QImage& img)
// As we're doing more than trivial painting, we can't just compare to
// an image rendered with raster. Instead, we sample at well-defined
// test-points:
+ QVERIFY(!img.isNull());
+ QVERIFY2(img.width() > 217, QByteArray::number(img.width()));
+ QVERIFY2(img.height() > 90, QByteArray::number(img.height()));
+
QFUZZY_COMPARE_PIXELS(img.pixel(39, 64), QColor(Qt::red).rgb());
QFUZZY_COMPARE_PIXELS(img.pixel(89, 64), QColor(Qt::red).rgb());
QFUZZY_COMPARE_PIXELS(img.pixel(64, 39), QColor(Qt::blue).rgb());
@@ -415,7 +434,7 @@ void tst_QOpenGL::fboSimpleRendering()
QOpenGLContext ctx;
QVERIFY(ctx.create());
- ctx.makeCurrent(surface.data());
+ QVERIFY(ctx.makeCurrent(surface.data()));
if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects())
QSKIP("QOpenGLFramebufferObject not supported on this platform");
@@ -424,21 +443,21 @@ void tst_QOpenGL::fboSimpleRendering()
QOpenGLFramebufferObjectFormat fboFormat;
fboFormat.setAttachment(QOpenGLFramebufferObject::NoAttachment);
- QOpenGLFramebufferObject *fbo = new QOpenGLFramebufferObject(200, 100, fboFormat);
+ const QSize size(200, 100);
+ QScopedPointer<QOpenGLFramebufferObject> fbo(new QOpenGLFramebufferObject(size, fboFormat));
- fbo->bind();
+ QVERIFY(fbo->bind());
glClearColor(1.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glFinish();
- QImage fb = fbo->toImage().convertToFormat(QImage::Format_RGB32);
- QImage reference(fb.size(), QImage::Format_RGB32);
+ const QImage fb = fbo->toImage().convertToFormat(QImage::Format_RGB32);
+ QCOMPARE(fb.size(), size);
+ QImage reference(size, QImage::Format_RGB32);
reference.fill(0xffff0000);
QFUZZY_COMPARE_IMAGES(fb, reference);
-
- delete fbo;
}
void tst_QOpenGL::fboTextureOwnership_data()
@@ -511,7 +530,7 @@ void tst_QOpenGL::fboRendering()
QOpenGLContext ctx;
QVERIFY(ctx.create());
- ctx.makeCurrent(surface.data());
+ QVERIFY(ctx.makeCurrent(surface.data()));
if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects())
QSKIP("QOpenGLFramebufferObject not supported on this platform");
@@ -521,12 +540,13 @@ void tst_QOpenGL::fboRendering()
fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
// Uncomplicate things by using NPOT:
- QOpenGLFramebufferObject fbo(256, 128, fboFormat);
+ const QSize size(256, 128);
+ QOpenGLFramebufferObject fbo(size, fboFormat);
if (fbo.attachment() != QOpenGLFramebufferObject::CombinedDepthStencil)
QSKIP("FBOs missing combined depth~stencil support");
- fbo.bind();
+ QVERIFY(fbo.bind());
QPainter fboPainter;
QOpenGLPaintDevice device(fbo.width(), fbo.height());
@@ -537,7 +557,8 @@ void tst_QOpenGL::fboRendering()
fboPainter.end();
- QImage fb = fbo.toImage().convertToFormat(QImage::Format_RGB32);
+ const QImage fb = fbo.toImage().convertToFormat(QImage::Format_RGB32);
+ QCOMPARE(fb.size(), size);
qt_opengl_check_test_pattern(fb);
}
@@ -588,9 +609,11 @@ void tst_QOpenGL::openGLPaintDevice()
QSurfaceFormat format = ctx.format();
if (format.majorVersion() < 2)
QSKIP("This test requires at least OpenGL 2.0");
- ctx.makeCurrent(surface.data());
+ QVERIFY(ctx.makeCurrent(surface.data()));
- QImage image(128, 128, QImage::Format_RGB32);
+ const QSize size(128, 128);
+
+ QImage image(size, QImage::Format_RGB32);
QPainter p(&image);
p.fillRect(0, 0, image.width() / 2, image.height() / 2, Qt::red);
p.fillRect(image.width() / 2, 0, image.width() / 2, image.height() / 2, Qt::green);
@@ -598,32 +621,38 @@ void tst_QOpenGL::openGLPaintDevice()
p.fillRect(0, image.height() / 2, image.width() / 2, image.height() / 2, Qt::white);
p.end();
- QOpenGLFramebufferObject fbo(128, 128);
- fbo.bind();
+ QOpenGLFramebufferObject fbo(size);
+ QVERIFY(fbo.bind());
- QOpenGLPaintDevice device(128, 128);
- p.begin(&device);
+ QOpenGLPaintDevice device(size);
+ QVERIFY(p.begin(&device));
p.fillRect(0, 0, image.width() / 2, image.height() / 2, Qt::red);
p.fillRect(image.width() / 2, 0, image.width() / 2, image.height() / 2, Qt::green);
p.fillRect(image.width() / 2, image.height() / 2, image.width() / 2, image.height() / 2, Qt::blue);
p.fillRect(0, image.height() / 2, image.width() / 2, image.height() / 2, Qt::white);
p.end();
- QCOMPARE(image, fbo.toImage().convertToFormat(QImage::Format_RGB32));
+ QImage actual = fbo.toImage().convertToFormat(QImage::Format_RGB32);
+ QCOMPARE(image.size(), actual.size());
+ QCOMPARE(image, actual);
- p.begin(&device);
+ QVERIFY(p.begin(&device));
p.fillRect(0, 0, image.width(), image.height(), Qt::black);
p.drawImage(0, 0, image);
p.end();
- QCOMPARE(image, fbo.toImage().convertToFormat(QImage::Format_RGB32));
+ actual = fbo.toImage().convertToFormat(QImage::Format_RGB32);
+ QCOMPARE(image.size(), actual.size());
+ QCOMPARE(image, actual);
- p.begin(&device);
+ QVERIFY(p.begin(&device));
p.fillRect(0, 0, image.width(), image.height(), Qt::black);
p.fillRect(0, 0, image.width(), image.height(), QBrush(image));
p.end();
- QCOMPARE(image, fbo.toImage().convertToFormat(QImage::Format_RGB32));
+ actual = fbo.toImage().convertToFormat(QImage::Format_RGB32);
+ QCOMPARE(image.size(), actual.size());
+ QCOMPARE(image, actual);
}
void tst_QOpenGL::aboutToBeDestroyed()
@@ -689,9 +718,11 @@ void tst_QOpenGL::QTBUG15621_triangulatingStrokerDivZero()
QSKIP("QTBUG-22617");
#endif
+ const QSize size(128, 128);
+
QWindow window;
window.setSurfaceType(QWindow::OpenGLSurface);
- window.setGeometry(0, 0, 128, 128);
+ window.setGeometry(QRect(QPoint(0, 0), size));
window.create();
QOpenGLContext ctx;
@@ -701,10 +732,10 @@ void tst_QOpenGL::QTBUG15621_triangulatingStrokerDivZero()
if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects())
QSKIP("QOpenGLFramebufferObject not supported on this platform");
- QOpenGLFramebufferObject fbo(128, 128);
- fbo.bind();
+ QOpenGLFramebufferObject fbo(size);
+ QVERIFY(fbo.bind());
- QOpenGLPaintDevice device(128, 128);
+ QOpenGLPaintDevice device(size);
// QTBUG-15621 is only a problem when qreal is double, but do the test anyway.
qreal delta = sizeof(qreal) == sizeof(float) ? 1e-4 : 1e-8;
@@ -731,10 +762,11 @@ void tst_QOpenGL::QTBUG15621_triangulatingStrokerDivZero()
QPen pen(Qt::red, 28, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
QPainter p(&device);
- p.fillRect(QRect(0, 0, 128, 128), Qt::blue);
+ p.fillRect(QRect(QPoint(0, 0), size), Qt::blue);
p.strokePath(path, pen);
p.end();
- QImage image = fbo.toImage().convertToFormat(QImage::Format_RGB32);
+ const QImage image = fbo.toImage().convertToFormat(QImage::Format_RGB32);
+ QCOMPARE(image.size(), size);
const QRgb red = 0xffff0000;
const QRgb blue = 0xff0000ff;
diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp
index 8406e843cf..6f75a1f8bb 100644
--- a/tests/auto/gui/text/qfont/tst_qfont.cpp
+++ b/tests/auto/gui/text/qfont/tst_qfont.cpp
@@ -74,7 +74,6 @@ private slots:
void resetFont();
#endif
void isCopyOf();
- void setFontRaw();
void italicOblique();
void insertAndRemoveSubstitutions();
void serialize_data();
@@ -418,15 +417,6 @@ void tst_QFont::compare()
QVERIFY(font == font2);
QVERIFY(!(font < font2));
}
-
-#if defined(Q_WS_X11)
- {
- QFont font1, font2;
- font1.setRawName("-Adobe-Helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1");
- font2.setRawName("-Adobe-Helvetica-medium-r-normal--24-240-75-75-p-130-iso8859-1");
- QVERIFY(font1 != font2);
- }
-#endif
}
void tst_QFont::resolve()
@@ -520,30 +510,6 @@ void tst_QFont::isCopyOf()
QVERIFY(!font3.isCopyOf(font));
}
-void tst_QFont::setFontRaw()
-{
-#ifndef Q_WS_X11
- QSKIP("Only tested on X11");
-#else
- QFont f;
- f.setRawName("-*-fixed-bold-r-normal--0-0-*-*-*-0-iso8859-1");
-// qDebug("font family: %s", f.family().utf8());
- QFontDatabase fdb;
- QStringList families = fdb.families();
- bool found = false;
- for (int i = 0; i < families.size(); ++i) {
- QString str = families.at(i);
- if (str.contains('['))
- str = str.left(str.indexOf('[')-1);
- if (str.toLower() == "fixed")
- found = true;
- }
- if (!found)
- QSKIP("Fixed font not available.");
- QCOMPARE(QFontInfo(f).family().left(5).toLower(), QString("fixed"));
-#endif
-}
-
void tst_QFont::insertAndRemoveSubstitutions()
{
QFont::removeSubstitution("BogusFontFamily");
diff --git a/tests/auto/gui/text/qfontdatabase/FreeMono.ttf b/tests/auto/gui/text/qfontdatabase/FreeMono.ttf
deleted file mode 100644
index d7ce52ddc7..0000000000
--- a/tests/auto/gui/text/qfontdatabase/FreeMono.ttf
+++ /dev/null
Binary files differ
diff --git a/tests/auto/gui/text/qfontdatabase/LED_REAL.TTF b/tests/auto/gui/text/qfontdatabase/LED_REAL.TTF
new file mode 100644
index 0000000000..f87ea95e0e
--- /dev/null
+++ b/tests/auto/gui/text/qfontdatabase/LED_REAL.TTF
Binary files differ
diff --git a/tests/auto/gui/text/qfontdatabase/LED_REAL_readme.txt b/tests/auto/gui/text/qfontdatabase/LED_REAL_readme.txt
new file mode 100644
index 0000000000..06a5b40313
--- /dev/null
+++ b/tests/auto/gui/text/qfontdatabase/LED_REAL_readme.txt
@@ -0,0 +1,34 @@
+Font: LED Real (led_real.ttf)
+Created By: Matthew Welch
+E-Mail: daffy-duck@worldnet.att.net
+Web Address: http://home.att.net/~daffy-duck
+ (PGP public key available here)
+
+LED Real, like all of my fonts, is free. You can use it for most
+personal or business uses you'd like, and I ask for no money. I
+would, however, like to hear from you. If you use my fonts for
+something please send me a postcard or e-mail letting me know how
+you used it. Send me a copy if you can or let me know where I can
+find your work.
+
+You may use this font for graphical or printed work, but you may not
+sell it or include it in a collection of fonts (on CD or otherwise)
+being sold. You can redistribute this font as long as you charge
+nothing to receive it. If you redistribute it include this text file
+with it as is (without modifications).
+
+If you use this font for commercial purposes please credit me in
+at least some little way.
+
+About the font:
+
+Unlike most LED/LCD style fonts mine could be recreated with an
+actual LED. I created this font working from memories of the good
+old Speak and Spell display. Since I don't have an actual Speak
+and Spell to work from I had to just do as well as I could in its
+spirit. Be warned that some characters look just like others. The
+( and the <, for instance. Also C and [. Most of these will be
+pretty clear in context. To see all the sections of the LED "lit
+up" at once use character 127 (hold down alt and type 0127 on the
+numeric keypad). This font is, of course, monospaced.
+
diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
index fa5c81a2f0..28db0ba291 100644
--- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
@@ -83,7 +83,7 @@ private:
};
tst_QFontDatabase::tst_QFontDatabase()
- : m_testFont(QFINDTESTDATA("FreeMono.ttf"))
+ : m_testFont(QFINDTESTDATA("LED_REAL.TTF"))
{
}
diff --git a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp
index 74802c3217..c4db669695 100644
--- a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp
+++ b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp
@@ -86,12 +86,13 @@ private slots:
void greek_data();
void greek();
- void controlInSyllable_qtbug14204();
- void combiningMarks_qtbug15675();
-
void mirroredChars_data();
void mirroredChars();
+ void controlInSyllable_qtbug14204();
+ void combiningMarks_qtbug15675_data();
+ void combiningMarks_qtbug15675();
+
void thaiIsolatedSaraAm();
void thaiWithZWJ();
void thaiMultipleVowels();
@@ -1051,87 +1052,18 @@ void tst_QTextScriptEngine::greek()
doShapingTests();
}
-void tst_QTextScriptEngine::controlInSyllable_qtbug14204()
-{
-#if 0 && defined(Q_OS_UNIX)
- // ### the test is incorrect -> disable for now
- QString s;
- s.append(QChar(0x0915));
- s.append(QChar(0x094d));
- s.append(QChar(0x200d));
- s.append(QChar(0x0915));
-
- QTextLayout layout(s);
- QTextEngine *e = layout.engine();
- e->itemize();
- e->shape(0);
-
- QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(2));
- QVERIFY(e->layoutData->glyphLayout.advances[1].toInt() != 0);
-#endif
-}
-
-void tst_QTextScriptEngine::combiningMarks_qtbug15675()
-{
-#if defined(Q_OS_MAC)
- QString s;
- s.append(QChar(0x0061));
- s.append(QChar(0x0062));
- s.append(QChar(0x0300));
- s.append(QChar(0x0063));
-
- QFont font("Monaco");
- QTextLayout layout(s, font);
- QTextEngine *e = layout.engine();
- e->itemize();
- e->shape(0);
-
- QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(4));
- QCOMPARE(e->layoutData->glyphLayout.advances[2].toInt(), 0);
-#else
- QFontDatabase db;
-
- if (!db.families().contains("DejaVu Sans Mono"))
- QSKIP("Required font (DejaVu Sans Mono) doesn't exist, skip test.");
-
- QString s;
- s.append(QChar(0x0062));
- s.append(QChar(0x0332));
- s.append(QChar(0x0063));
-
- QTextLayout layout(s, QFont("DejaVu Sans Mono"));
- QTextEngine *e = layout.engine();
- e->itemize();
- e->shape(0);
-
- QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(3));
- QCOMPARE(e->layoutData->glyphLayout.advances[1].toInt(), 0);
-#endif
-}
-
void tst_QTextScriptEngine::mirroredChars_data()
{
- QTest::addColumn<int>("hintingPreference");
+ QTest::addColumn<QString>("s");
- QTest::newRow("Default hinting") << int(QFont::PreferDefaultHinting);
- QTest::newRow("No hinting") << int(QFont::PreferNoHinting);
- QTest::newRow("Vertical hinting") << int(QFont::PreferVerticalHinting);
- QTest::newRow("Full hinting") << int(QFont::PreferFullHinting);
+ QTest::newRow("()") << QStringLiteral("()");
+ QTest::newRow("[]") << QStringLiteral("[]");
+ QTest::newRow("{}") << QStringLiteral("{}");
}
void tst_QTextScriptEngine::mirroredChars()
{
-#if defined(Q_OS_MAC)
- QSKIP("Not supported on Mac");
-#endif
- QFETCH(int, hintingPreference);
-
- QFont font;
- font.setHintingPreference(QFont::HintingPreference(hintingPreference));
-
- QString s;
- s.append(QLatin1Char('('));
- s.append(QLatin1Char(')'));
+ QFETCH(QString, s);
glyph_t leftParenthesis;
glyph_t rightParenthesis;
@@ -1144,10 +1076,12 @@ void tst_QTextScriptEngine::mirroredChars()
QTextEngine *e = layout.engine();
e->itemize();
+ QCOMPARE(e->layoutData->items.size(), 1);
+
e->shape(0);
QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(2));
- const QGlyphLayout &glyphLayout = e->layoutData->glyphLayout;
+ const QGlyphLayout glyphLayout = e->shapedGlyphs(&e->layoutData->items[0]);
leftParenthesis = glyphLayout.glyphs[0];
rightParenthesis = glyphLayout.glyphs[1];
}
@@ -1158,61 +1092,170 @@ void tst_QTextScriptEngine::mirroredChars()
QTextEngine *e = layout.engine();
e->itemize();
+ QCOMPARE(e->layoutData->items.size(), 1);
+
e->shape(0);
QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(2));
- const QGlyphLayout &glyphLayout = e->layoutData->glyphLayout;
+ const QGlyphLayout glyphLayout = e->shapedGlyphs(&e->layoutData->items[0]);
QCOMPARE(glyphLayout.glyphs[0], rightParenthesis);
QCOMPARE(glyphLayout.glyphs[1], leftParenthesis);
}
}
+void tst_QTextScriptEngine::controlInSyllable_qtbug14204()
+{
+ QFontDatabase db;
+ if (!db.families().contains(QStringLiteral("Aparajita")))
+ QSKIP("couldn't find 'Aparajita' font");
+
+ QFont font(QStringLiteral("Aparajita"));
+ font.setStyleStrategy(QFont::NoFontMerging);
+
+ QString s;
+ s.append(QChar(0x0915));
+ s.append(QChar(0x094d));
+ s.append(QChar(0x200d));
+ s.append(QChar(0x0915));
+
+ QTextLayout layout(s, font);
+ QTextEngine *e = layout.engine();
+ e->itemize();
+ QCOMPARE(e->layoutData->items.size(), 1);
+
+ QFontEngine *fe = e->fontEngine(e->layoutData->items[0]);
+ if (fe->type() == QFontEngine::Box)
+ QSKIP("OpenType support missing for script");
+ QCOMPARE(fe->fontDef.family, font.family());
+
+ e->shape(0);
+ QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(2));
+
+ const ushort *log_clusters = e->logClusters(&e->layoutData->items[0]);
+ QCOMPARE(log_clusters[0], ushort(0));
+ QCOMPARE(log_clusters[1], ushort(0));
+ QCOMPARE(log_clusters[2], ushort(0));
+ QCOMPARE(log_clusters[3], ushort(0));
+}
+
+void tst_QTextScriptEngine::combiningMarks_qtbug15675_data()
+{
+ QTest::addColumn<QFont>("font");
+ QTest::addColumn<QString>("string");
+
+ bool hasTests = false;
+
+ QStringList families;
+ families << QStringLiteral("Monaco");
+ families << QStringLiteral("DejaVu Sans Mono");
+
+ foreach (const QString &family, families) {
+ QFont font(family);
+ font.setStyleStrategy(QFont::NoFontMerging);
+ if (QFontInfo(font).family() != family)
+ continue;
+
+ hasTests = true;
+
+ QString s(QStringLiteral("ab cd"));
+ for (ushort uc = 0x0300; uc < 0x0370; ++uc) {
+ s[2] = QChar(uc);
+ QByteArray testName = family.toLatin1() + ": ab<U+" + QByteArray::number(uc, 16).rightJustified(4, '0') + ">cd";
+ QTest::newRow(testName.constData()) << font << s;
+ }
+ }
+
+ if (!hasTests)
+ QSKIP("Couldn't find required fonts, skip test.");
+}
+
+void tst_QTextScriptEngine::combiningMarks_qtbug15675()
+{
+ QFETCH(QFont, font);
+ QFETCH(QString, string);
+
+ QTextLayout layout(string, font);
+ QTextEngine *e = layout.engine();
+ e->itemize();
+ QCOMPARE(e->layoutData->items.size(), 1);
+
+ QFontEngine *fe = e->fontEngine(e->layoutData->items[0]);
+ if (fe->type() == QFontEngine::Box)
+ QSKIP("OpenType support missing for script");
+ QCOMPARE(fe->fontDef.family, font.family());
+
+ e->shape(0);
+ const int diff = e->layoutData->items[0].num_glyphs - string.size();
+ QVERIFY(diff >= -1 && diff <= 1); // could compose or decompose exactly one character
+
+ const ushort *log_clusters = e->logClusters(&e->layoutData->items[0]);
+ QCOMPARE(log_clusters[0], ushort(0));
+ QCOMPARE(log_clusters[1], ushort(1));
+ QCOMPARE(log_clusters[2], ushort(1));
+ QCOMPARE(log_clusters[3], ushort(3 + diff));
+ QCOMPARE(log_clusters[4], ushort(4 + diff));
+
+ const QGlyphLayout glyphLayout = e->shapedGlyphs(&e->layoutData->items[0]);
+ for (int i = 0; i < glyphLayout.numGlyphs; ++i) {
+ if ((diff >= 0 && i == 2) || (diff > 0 && i == 2 + diff))
+ QCOMPARE(glyphLayout.advances[i].toInt(), 0);
+ else
+ QVERIFY(glyphLayout.advances[i].toInt() != 0);
+ }
+}
+
void tst_QTextScriptEngine::thaiIsolatedSaraAm()
{
- if (QFontDatabase().families(QFontDatabase::Any).contains("Waree")) {
- QString s;
- s.append(QChar(0x0e33));
+ QFontDatabase db;
+ if (!db.families().contains("Waree"))
+ QSKIP("couldn't find 'Waree' font");
- QTextLayout layout(s, QFont("Waree"));
- layout.setCacheEnabled(true);
- layout.beginLayout();
- layout.createLine();
- layout.endLayout();
+ QFont font(QStringLiteral("Waree"));
+ font.setStyleStrategy(QFont::NoFontMerging);
- QTextEngine *e = layout.engine();
- e->itemize();
- e->shape(0);
- QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(3));
+ QString s;
+ s.append(QChar(0x0e33));
- unsigned short *logClusters = e->logClusters(&e->layoutData->items[0]);
- QCOMPARE(logClusters[0], ushort(0));
- } else
- QSKIP("Cannot find Waree.");
+ QTextLayout layout(s, font);
+ QTextEngine *e = layout.engine();
+ e->itemize();
+ QCOMPARE(e->layoutData->items.size(), 1);
+
+ QFontEngine *fe = e->fontEngine(e->layoutData->items[0]);
+ if (fe->type() == QFontEngine::Box)
+ QSKIP("OpenType support missing for script");
+ QCOMPARE(fe->fontDef.family, font.family());
+
+ e->shape(0);
+ QVERIFY(e->layoutData->items[0].num_glyphs > 0);
+
+ const ushort *log_clusters = e->logClusters(&e->layoutData->items[0]);
+ QCOMPARE(log_clusters[0], ushort(0));
}
void tst_QTextScriptEngine::thaiWithZWJ()
{
-#ifdef Q_OS_WIN
- QSKIP("This test currently fails on Windows - QTBUG-24565");
-#endif
+ QFontDatabase db;
+ if (!db.families().contains("Waree"))
+ QSKIP("couldn't find 'Waree' font");
+
+ QFont font(QStringLiteral("Waree"));
+ font.setStyleStrategy(QFont::NoFontMerging);
+
QString s(QString::fromUtf8("\xe0\xb8\xa3\xe2\x80\x8d\xe0\xb8\xa3\xe2\x80"
"\x8c\x2e\xe0\xb8\xa3\x2e\xe2\x80\x9c\xe0\xb8"
"\xa3\xe2\x80\xa6\xe0\xb8\xa3\xe2\x80\x9d\xe0"
"\xb8\xa3\xa0\xe0\xb8\xa3\xe6\x9c\xac\xe0\xb8\xa3")
+ QChar(0x0363)/*superscript 'a', for testing Inherited class*/);
- QTextLayout layout(s);
- layout.setCacheEnabled(true);
- layout.beginLayout();
- layout.createLine();
- layout.endLayout();
+ QTextLayout layout(s, font);
QTextEngine *e = layout.engine();
- e->width(0, s.length()); //force itemize and shape
-
- // A thai implementation could either remove the ZWJ and ZWNJ characters, or hide them.
- // The current implementation hides them, so we test for that.
- // But make sure that we don't hide anything else
+ e->itemize();
QCOMPARE(e->layoutData->items.size(), 11);
+
+ for (int item = 0; item < e->layoutData->items.size(); ++item)
+ e->shape(item);
+
QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(7)); // Thai: The ZWJ and ZWNJ characters are inherited, so should be part of the thai script
QCOMPARE(e->layoutData->items[1].num_glyphs, ushort(1)); // Common: The smart quotes cannot be handled by thai, so should be a separate item
QCOMPARE(e->layoutData->items[2].num_glyphs, ushort(1)); // Thai: Thai character
@@ -1231,15 +1274,18 @@ void tst_QTextScriptEngine::thaiWithZWJ()
QCOMPARE(logClusters[i], ushort(i));
for (int i = 0; i < 10; i++)
QCOMPARE(logClusters[i+7], ushort(0));
-#ifdef Q_OS_MAC
- QEXPECT_FAIL("", "QTBUG-23064", Abort);
-#endif
QCOMPARE(logClusters[17], ushort(1));
- // The only characters that we should be hiding are the ZWJ and ZWNJ characters in position 1
- // and 3.
- for (int i = 0; i < 18; i++)
- QCOMPARE((bool)e->layoutData->glyphLayout.attributes[i].dontPrint, (i == 1 || i == 3));
+ // A thai implementation could either remove the ZWJ and ZWNJ characters, or hide them.
+ // The current implementation hides them, so we test for that.
+ // The only characters that we should be hiding are the ZWJ and ZWNJ characters in position 1 and 3.
+ const QGlyphLayout glyphLayout = e->layoutData->glyphLayout;
+ for (int i = 0; i < 18; i++) {
+ if (i == 1 || i == 3)
+ QCOMPARE(glyphLayout.advances[i].toInt(), 0);
+ else
+ QVERIFY(glyphLayout.advances[i].toInt() != 0);
+ }
}
void tst_QTextScriptEngine::thaiMultipleVowels()
@@ -1253,14 +1299,13 @@ void tst_QTextScriptEngine::thaiMultipleVowels()
for (int i = 0; i < 10; i++)
s += s; //Repeat the string to make it more likely to crash if we have a buffer overflow
- QTextLayout layout(s);
- layout.setCacheEnabled(true);
- layout.beginLayout();
- layout.createLine();
- layout.endLayout();
+ QTextLayout layout(s);
QTextEngine *e = layout.engine();
- e->width(0, s.length()); //force itemize and shape
+ e->itemize();
+
+ for (int item = 0; item < e->layoutData->items.size(); ++item)
+ e->shape(item);
// If we haven't crashed at this point, then the test has passed.
}
diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
index 6eb20dd1f5..ded3966992 100644
--- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
@@ -271,6 +271,9 @@ void tst_QSslSocket::initTestCase_data()
void tst_QSslSocket::initTestCase()
{
+ qDebug("Using SSL library %s (%ld)",
+ qPrintable(QSslSocket::sslLibraryVersionString()),
+ QSslSocket::sslLibraryVersionNumber());
QVERIFY(QtNetworkSettings::verifyTestNetworkSettings());
}
@@ -347,6 +350,9 @@ void tst_QSslSocket::proxyAuthenticationRequired(const QNetworkProxy &, QAuthent
void tst_QSslSocket::constructing()
{
+ const char readNotOpenMessage[] = "QIODevice::read: device not open";
+ const char writeNotOpenMessage[] = "QIODevice::write: device not open";
+
if (!QSslSocket::supportsSsl())
return;
@@ -363,6 +369,7 @@ void tst_QSslSocket::constructing()
QCOMPARE(socket.sslConfiguration(), QSslConfiguration::defaultConfiguration());
QCOMPARE(socket.errorString(), QString("Unknown error"));
char c = '\0';
+ QTest::ignoreMessage(QtWarningMsg, readNotOpenMessage);
QVERIFY(!socket.getChar(&c));
QCOMPARE(c, '\0');
QVERIFY(!socket.isOpen());
@@ -371,11 +378,16 @@ void tst_QSslSocket::constructing()
QVERIFY(!socket.isTextModeEnabled());
QVERIFY(!socket.isWritable());
QCOMPARE(socket.openMode(), QIODevice::NotOpen);
+ QTest::ignoreMessage(QtWarningMsg, readNotOpenMessage);
QVERIFY(socket.peek(2).isEmpty());
QCOMPARE(socket.pos(), qint64(0));
+ QTest::ignoreMessage(QtWarningMsg, writeNotOpenMessage);
QVERIFY(!socket.putChar('c'));
+ QTest::ignoreMessage(QtWarningMsg, readNotOpenMessage);
QVERIFY(socket.read(2).isEmpty());
+ QTest::ignoreMessage(QtWarningMsg, readNotOpenMessage);
QCOMPARE(socket.read(0, 0), qint64(-1));
+ QTest::ignoreMessage(QtWarningMsg, readNotOpenMessage);
QVERIFY(socket.readAll().isEmpty());
QTest::ignoreMessage(QtWarningMsg, "QIODevice::readLine: Called with maxSize < 2");
QCOMPARE(socket.readLine(0, 0), qint64(-1));
@@ -388,7 +400,9 @@ void tst_QSslSocket::constructing()
QCOMPARE(socket.size(), qint64(0));
QVERIFY(!socket.waitForBytesWritten(10));
QVERIFY(!socket.waitForReadyRead(10));
+ QTest::ignoreMessage(QtWarningMsg, writeNotOpenMessage);
QCOMPARE(socket.write(0, 0), qint64(-1));
+ QTest::ignoreMessage(QtWarningMsg, writeNotOpenMessage);
QCOMPARE(socket.write(QByteArray()), qint64(-1));
QCOMPARE(socket.error(), QAbstractSocket::UnknownSocketError);
QVERIFY(!socket.flush());
@@ -672,7 +686,7 @@ void tst_QSslSocket::sessionCipher()
connect(socket.data(), SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot()));
QVERIFY(socket->sessionCipher().isNull());
socket->connectToHost(QtNetworkSettings::serverName(), 443 /* https */);
- QVERIFY(socket->waitForConnected(10000));
+ QVERIFY2(socket->waitForConnected(10000), qPrintable(socket->errorString()));
QVERIFY(socket->sessionCipher().isNull());
socket->startClientEncryption();
if (!socket->waitForEncrypted(5000))
@@ -775,7 +789,7 @@ void tst_QSslSocket::peerCertificateChain()
socket->connectToHost(QtNetworkSettings::serverName(), 443);
QCOMPARE(socket->mode(), QSslSocket::UnencryptedMode);
QVERIFY(socket->peerCertificateChain().isEmpty());
- QVERIFY2(socket->waitForConnected(10000), "Network timeout");
+ QVERIFY2(socket->waitForConnected(10000), qPrintable(socket->errorString()));
socket->startClientEncryption();
if (setProxy && !socket->waitForEncrypted(10000))
@@ -1334,7 +1348,7 @@ void tst_QSslSocket::waitForConnectedEncryptedReadyRead()
connect(this->socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot()));
socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 993);
- QVERIFY(socket->waitForConnected(10000));
+ QVERIFY2(socket->waitForConnected(10000), qPrintable(socket->errorString()));
QFETCH_GLOBAL(bool, setProxy);
if (setProxy && !socket->waitForEncrypted(10000))
QSKIP("Skipping flaky test - See QTBUG-29941");
@@ -1679,7 +1693,7 @@ void tst_QSslSocket::setReadBufferSize_task_250027()
socket->ignoreSslErrors();
socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
socket->ignoreSslErrors();
- QVERIFY(socket->waitForConnected(10*1000));
+ QVERIFY2(socket->waitForConnected(10*1000), qPrintable(socket->errorString()));
if (setProxy && !socket->waitForEncrypted(10*1000))
QSKIP("Skipping flaky test - See QTBUG-29941");
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index 2bf8a40451..9f0540173a 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -1415,19 +1415,19 @@ void tst_QAccessibility::menuTest()
iFile->actionInterface()->doAction(QAccessibleActionInterface::showMenuAction());
if(menuFade)
QTest::qWait(menuFadeDelay);
- QVERIFY(file->isVisible() && !edit->isVisible() && !help->isVisible());
+ QTRY_VERIFY(file->isVisible() && !edit->isVisible() && !help->isVisible());
iEdit->actionInterface()->doAction(QAccessibleActionInterface::showMenuAction());
if(menuFade)
QTest::qWait(menuFadeDelay);
- QVERIFY(!file->isVisible() && edit->isVisible() && !help->isVisible());
+ QTRY_VERIFY(!file->isVisible() && edit->isVisible() && !help->isVisible());
iHelp->actionInterface()->doAction(QAccessibleActionInterface::showMenuAction());
if(menuFade)
QTest::qWait(menuFadeDelay);
- QVERIFY(!file->isVisible() && !edit->isVisible() && help->isVisible());
+ QTRY_VERIFY(!file->isVisible() && !edit->isVisible() && help->isVisible());
iAction->actionInterface()->doAction(QAccessibleActionInterface::showMenuAction());
if(menuFade)
QTest::qWait(menuFadeDelay);
- QVERIFY(!file->isVisible() && !edit->isVisible() && !help->isVisible());
+ QTRY_VERIFY(!file->isVisible() && !edit->isVisible() && !help->isVisible());
QVERIFY(interface->actionInterface());
QCOMPARE(interface->actionInterface()->actionNames(), QStringList());
@@ -1500,8 +1500,8 @@ void tst_QAccessibility::menuTest()
iFile->actionInterface()->doAction(QAccessibleActionInterface::showMenuAction());
iFileNew->actionInterface()->doAction(QAccessibleActionInterface::showMenuAction());
- QVERIFY(file->isVisible());
- QVERIFY(fileNew->isVisible());
+ QTRY_VERIFY(file->isVisible());
+ QTRY_VERIFY(fileNew->isVisible());
QVERIFY(!edit->isVisible());
QVERIFY(!help->isVisible());
diff --git a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp
index 25dd0d39dd..25b47ee836 100644
--- a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp
+++ b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp
@@ -79,6 +79,7 @@ private slots:
void init();
void cleanup();
+ void singleWidgetTest();
void lineEditTest();
void hierarchyTest();
private:
@@ -101,6 +102,16 @@ void tst_QAccessibilityMac::cleanup()
delete m_window;
}
+void tst_QAccessibilityMac::singleWidgetTest()
+{
+ if (!macNativeAccessibilityEnabled())
+ return;
+
+ delete m_window;
+ m_window = 0;
+
+ QVERIFY(singleWidget());
+}
void tst_QAccessibilityMac::lineEditTest()
{
@@ -122,14 +133,19 @@ void tst_QAccessibilityMac::hierarchyTest()
QWidget *w = new QWidget(m_window);
m_window->addWidget(w);
- QPushButton *b = new QPushButton(w);
+
w->setLayout(new QVBoxLayout());
+ QPushButton *b = new QPushButton(w);
w->layout()->addWidget(b);
b->setText("I am a button");
+ QPushButton *b2 = new QPushButton(w);
+ w->layout()->addWidget(b2);
+ b2->setText("Button 2");
+
QVERIFY(QTest::qWaitForWindowExposed(m_window));
QCoreApplication::processEvents();
- QVERIFY(testHierarchy());
+ QVERIFY(testHierarchy(w));
}
QTEST_MAIN(tst_QAccessibilityMac)
diff --git a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.h b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.h
index ec5beab125..635b6383ab 100644
--- a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.h
+++ b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.h
@@ -48,4 +48,5 @@
bool macNativeAccessibilityEnabled();
bool trusted();
bool testLineEdit();
-bool testHierarchy();
+bool testHierarchy(QWidget *w);
+bool singleWidget();
diff --git a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm
index 8620b7dd2f..bc89ac858b 100644
--- a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm
+++ b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm
@@ -43,8 +43,10 @@
#define QT_NO_KEYWORDS
#include "tst_qaccessibilitymac_helpers.h"
-#include <QApplication>
-#include <QDebug>
+#include <QtWidgets/qapplication.h>
+#include <QtWidgets/qlineedit.h>
+#include <QtWidgets/qpushbutton.h>
+#include <QtTest>
#include <unistd.h>
#import <Cocoa/Cocoa.h>
@@ -148,9 +150,41 @@ bool trusted()
return p;
}
++ (TestAXObject *) getApplicationAXObject
+{
+ pid_t pid = getpid();
+ AXUIElementRef appRef = AXUIElementCreateApplication(pid);
+ TestAXObject *appObject = [[TestAXObject alloc] initWithAXUIElementRef: appRef];
+ return appObject;
+}
+
@end
+bool singleWidget()
+{
+ QLineEdit le;
+ le.setText("button");
+ le.show();
+ EXPECT(QTest::qWaitForWindowExposed(&le));
+ QCoreApplication::processEvents();
+
+ TestAXObject *appObject = [TestAXObject getApplicationAXObject];
+ EXPECT(appObject);
+
+ NSArray *windows = [appObject windowList];
+ EXPECT([windows count] == 1);
+
+ AXUIElementRef windowRef = (AXUIElementRef) [windows objectAtIndex: 0];
+ EXPECT(windowRef != nil);
+ TestAXObject *window = [[TestAXObject alloc] initWithAXUIElementRef: windowRef];
+
+ AXUIElementRef lineEdit = [window findDirectChildByRole: kAXTextFieldRole];
+ EXPECT(lineEdit != nil);
+
+ return true;
+}
+
bool testLineEdit()
{
// not sure if this is needed. on my machine the calls succeed.
@@ -159,10 +193,8 @@ bool testLineEdit()
// AXError e = AXMakeProcessTrusted((CFStringRef) path);
// NSLog(@"error: %i", e);
- pid_t pid = getpid();
- AXUIElementRef app = AXUIElementCreateApplication(pid);
- EXPECT(app != nil);
- TestAXObject *appObject = [[TestAXObject alloc] initWithAXUIElementRef: app];
+ TestAXObject *appObject = [TestAXObject getApplicationAXObject];
+ EXPECT(appObject);
NSArray *windowList = [appObject windowList];
// one window
@@ -184,12 +216,10 @@ bool testLineEdit()
return true;
}
-bool testHierarchy()
+bool testHierarchy(QWidget *w)
{
- pid_t pid = getpid();
- AXUIElementRef app = AXUIElementCreateApplication(pid);
- EXPECT(app != nil);
- TestAXObject *appObject = [[TestAXObject alloc] initWithAXUIElementRef: app];
+ TestAXObject *appObject = [TestAXObject getApplicationAXObject];
+ EXPECT(appObject);
NSArray *windowList = [appObject windowList];
// one window
@@ -207,7 +237,36 @@ bool testHierarchy()
TestAXObject *parentObject = [[TestAXObject alloc] initWithAXUIElementRef: [buttonObject parent]];
// check that the parent is a window
- EXPECT([[parentObject role] isEqualToString: (NSString *)kAXWindowRole]);
+ EXPECT([[parentObject role] isEqualToString: NSAccessibilityWindowRole]);
+
+ // test the focus
+ // child 0 is the layout, then button1 and 2
+ QPushButton *button1 = qobject_cast<QPushButton*>(w->children().at(1));
+ EXPECT(button1);
+ QPushButton *button2 = qobject_cast<QPushButton*>(w->children().at(2));
+ EXPECT(button2);
+ button2->setFocus();
+
+ AXUIElementRef systemWideElement = AXUIElementCreateSystemWide();
+ AXUIElementRef focussedElement = NULL;
+ AXError error = AXUIElementCopyAttributeValue(systemWideElement,
+ (CFStringRef)NSAccessibilityFocusedUIElementAttribute, (CFTypeRef*)&focussedElement);
+ EXPECT(!error);
+ EXPECT(focussedElement);
+ TestAXObject *focusButton2 = [[TestAXObject alloc] initWithAXUIElementRef: focussedElement];
+
+ EXPECT([[focusButton2 role] isEqualToString: NSAccessibilityButtonRole]);
+ EXPECT([[focusButton2 description] isEqualToString: @"Button 2"]);
+
+
+ button1->setFocus();
+ error = AXUIElementCopyAttributeValue(systemWideElement,
+ (CFStringRef)NSAccessibilityFocusedUIElementAttribute, (CFTypeRef*)&focussedElement);
+ EXPECT(!error);
+ EXPECT(focussedElement);
+ TestAXObject *focusButton1 = [[TestAXObject alloc] initWithAXUIElementRef: focussedElement];
+ EXPECT([[focusButton1 role] isEqualToString: NSAccessibilityButtonRole]);
+ EXPECT([[focusButton1 description] isEqualToString: @"I am a button"]);
return true;
}
diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
index 5f1eb99524..a497fac79a 100644
--- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
@@ -1069,6 +1069,18 @@ void tst_QSqlQuery::numRowsAffected()
QCOMPARE( q.numRowsAffected(), i );
QCOMPARE( q.numRowsAffected(), i ); // yes, we check twice
+ QVERIFY_SQL( q, prepare( "update " + qtest + " set id = id + :newid" ) );
+ q.bindValue(":newid", 100);
+ QVERIFY_SQL( q, exec() );
+ QCOMPARE( q.numRowsAffected(), i );
+ QCOMPARE( q.numRowsAffected(), i ); // yes, we check twice
+
+ QVERIFY_SQL( q, prepare( "update " + qtest + " set id = id + :newid where NOT(1 = 1)" ) );
+ q.bindValue(":newid", 100);
+ QVERIFY_SQL( q, exec() );
+ QCOMPARE( q.numRowsAffected(), 0 );
+ QCOMPARE( q.numRowsAffected(), 0 ); // yes, we check twice
+
QVERIFY_SQL( q, exec( "insert into " + qtest + " values (42000, 'homer', 'marge')" ) );
QCOMPARE( q.numRowsAffected(), 1 );
QCOMPARE( q.numRowsAffected(), 1 ); // yes, we check twice
diff --git a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
index 6eb36115cb..c5717a808c 100644
--- a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
+++ b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
@@ -66,6 +66,7 @@ public slots:
void postKeyReturn();
void testGetFont();
void testSetFont();
+ void testNonStandardFontSize();
public slots:
void initTestCase();
@@ -76,6 +77,7 @@ private slots:
void defaultOkButton();
void setFont();
void task256466_wrongStyle();
+ void setNonStandardFontSize();
private:
void runSlotWithFailsafeTimer(const char *member);
@@ -203,8 +205,38 @@ void tst_QFontDialog::task256466_wrongStyle()
}
}
+void tst_QFontDialog::setNonStandardFontSize()
+{
+ runSlotWithFailsafeTimer(SLOT(testNonStandardFontSize()));
+}
+void tst_QFontDialog::testNonStandardFontSize()
+{
+ QList<int> standardSizesList = QFontDatabase::standardSizes();
+ int nonStandardFontSize;
+ if (!standardSizesList.isEmpty()) {
+ nonStandardFontSize = standardSizesList.at(standardSizesList.count()-1); // get the maximum standard size.
+ nonStandardFontSize += 1; // the increment of 1 to mock a non-standard font size.
+ } else {
+ QSKIP("QFontDatabase::standardSizes() is empty.");
+ }
+ QFont testFont;
+ testFont.setPointSize(nonStandardFontSize);
+
+ bool accepted = false;
+ QTimer::singleShot(2000, this, SLOT(postKeyReturn()));
+ QFont resultFont = QFontDialog::getFont(&accepted, testFont,
+ QApplication::activeWindow(),
+ QLatin1String("QFontDialog - NonStandardFontSize Test"),
+ QFontDialog::DontUseNativeDialog);
+ QVERIFY(accepted);
+
+ if (accepted)
+ QCOMPARE(testFont.pointSize(), resultFont.pointSize());
+ else
+ QWARN("Fail using a non-standard font size.");
+}
QTEST_MAIN(tst_QFontDialog)
#include "tst_qfontdialog.moc"
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index d3f6c2db00..5b178903cf 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -3065,21 +3065,30 @@ void tst_QGraphicsProxyWidget::createProxyForChildWidget()
delete boxProxy;
}
-class ContextMenuWidget : public QWidget
+class ContextMenuWidget : public QLabel
{
Q_OBJECT
public:
ContextMenuWidget()
- : embeddedPopup(false),
- gotContextMenuEvent(false)
+ : QLabel(QStringLiteral("ContextMenuWidget"))
+ , embeddedPopup(false)
+ , gotContextMenuEvent(false)
+ , m_embeddedPopupSet(false)
+ , m_timer(0)
{ }
bool embeddedPopup;
bool gotContextMenuEvent;
protected:
bool event(QEvent *event)
{
- if (event->type() == QEvent::ContextMenu)
- QTimer::singleShot(0, this, SLOT(checkMenu()));
+ if (event->type() == QEvent::ContextMenu) {
+ if (!m_timer) {
+ m_timer = new QTimer(this);
+ m_timer->setInterval(10);
+ connect(m_timer, SIGNAL(timeout()), this, SLOT(checkMenu()));
+ m_timer->start();
+ }
+ }
return QWidget::event(event);
}
void contextMenuEvent(QContextMenuEvent *)
@@ -3090,10 +3099,19 @@ protected:
private slots:
void checkMenu()
{
- if (this->findChild<QMenu *>())
- embeddedPopup = true;
+ QMenu *menu = findChild<QMenu *>();
+ if (!m_embeddedPopupSet) {
+ m_embeddedPopupSet = true;
+ embeddedPopup = menu != 0;
+ }
+ if (menu && menu->isVisible())
+ menu->hide();
hide();
}
+
+private:
+ bool m_embeddedPopupSet;
+ QTimer *m_timer;
};
void tst_QGraphicsProxyWidget::actionsContextMenu_data()
@@ -3120,8 +3138,11 @@ void tst_QGraphicsProxyWidget::actionsContextMenu()
widget->setContextMenuPolicy(Qt::ActionsContextMenu);
}
QGraphicsScene scene;
-
+ QGraphicsProxyWidget *proxyWidget = scene.addWidget(widget);
QGraphicsView view(&scene);
+ view.setWindowTitle(QStringLiteral("actionsContextMenu"));
+ view.resize(200, 200);
+ view.move(QGuiApplication::primaryScreen()->geometry().center() - QPoint(100, 100));
view.show();
QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
@@ -3129,9 +3150,9 @@ void tst_QGraphicsProxyWidget::actionsContextMenu()
QTRY_VERIFY(view.hasFocus());
if (hasFocus)
- scene.addWidget(widget)->setFocus();
+ proxyWidget->setFocus();
else
- scene.addWidget(widget)->clearFocus();
+ proxyWidget->clearFocus();
QApplication::processEvents();
diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
index c3aaf6be16..1005bf6b3c 100644
--- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
@@ -60,6 +60,7 @@
#include <qlineedit.h>
#include <qscreen.h>
#include <qscopedpointer.h>
+#include <qstyleditemdelegate.h>
static inline void setFrameless(QWidget *w)
{
@@ -244,6 +245,9 @@ private slots:
void testChangeEditorState();
void deselectInSingleSelection();
void testNoActivateOnDisabledItem();
+ void testFocusPolicy_data();
+ void testFocusPolicy();
+ void QTBUG31411_noSelection();
};
class MyAbstractItemDelegate : public QAbstractItemDelegate
@@ -1728,5 +1732,97 @@ void tst_QAbstractItemView::testNoActivateOnDisabledItem()
QCOMPARE(activatedSpy.count(), 0);
}
+void tst_QAbstractItemView::testFocusPolicy_data()
+{
+ QTest::addColumn<QAbstractItemDelegate*>("delegate");
+
+ QAbstractItemDelegate *styledItemDelegate = new QStyledItemDelegate(this);
+ QAbstractItemDelegate *itemDelegate = new QItemDelegate(this);
+
+ QTest::newRow("QStyledItemDelegate") << styledItemDelegate;
+ QTest::newRow("QItemDelegate") << itemDelegate;
+}
+
+void tst_QAbstractItemView::testFocusPolicy()
+{
+ QFETCH(QAbstractItemDelegate*, delegate);
+
+ QWidget window;
+ QTableView *table = new QTableView(&window);
+ table->setItemDelegate(delegate);
+ QVBoxLayout *layout = new QVBoxLayout(&window);
+ layout->addWidget(table);
+
+ QStandardItemModel model;
+ model.setRowCount(10);
+ model.setColumnCount(10);
+ table->setModel(&model);
+ table->setCurrentIndex(model.index(1, 1));
+
+ centerOnScreen(&window);
+ moveCursorAway(&window);
+
+ window.show();
+ QApplication::setActiveWindow(&window);
+ QVERIFY(QTest::qWaitForWindowActive(&window));
+
+ // itemview accepts focus => editor is closed => return focus to the itemview
+ QPoint clickpos = table->visualRect(model.index(1, 1)).center();
+ QTest::mouseDClick(table->viewport(), Qt::LeftButton, Qt::NoModifier, clickpos);
+ QWidget *editor = qApp->focusWidget();
+ QVERIFY(editor);
+ QTest::keyClick(editor, Qt::Key_Escape, Qt::NoModifier);
+ QCOMPARE(qApp->focusWidget(), table);
+
+ // itemview doesn't accept focus => editor is closed => clear the focus
+ table->setFocusPolicy(Qt::NoFocus);
+ QTest::mouseDClick(table->viewport(), Qt::LeftButton, Qt::NoModifier, clickpos);
+ editor = qApp->focusWidget();
+ QVERIFY(editor);
+ QTest::keyClick(editor, Qt::Key_Escape, Qt::NoModifier);
+ QVERIFY(!qApp->focusWidget());
+}
+
+Q_DECLARE_METATYPE(QItemSelection)
+void tst_QAbstractItemView::QTBUG31411_noSelection()
+{
+ QWidget window;
+ QTableView *table = new QTableView(&window);
+ table->setSelectionMode(QAbstractItemView::NoSelection);
+ QVBoxLayout *layout = new QVBoxLayout(&window);
+ layout->addWidget(table);
+
+ QStandardItemModel model;
+ model.setRowCount(10);
+ model.setColumnCount(10);
+ table->setModel(&model);
+ table->setCurrentIndex(model.index(1, 1));
+
+ centerOnScreen(&window);
+ moveCursorAway(&window);
+
+ window.show();
+ QApplication::setActiveWindow(&window);
+ QVERIFY(QTest::qWaitForWindowActive(&window));
+
+ qRegisterMetaType<QItemSelection>();
+ QSignalSpy selectionChangeSpy(table->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)));
+ QVERIFY(selectionChangeSpy.isValid());
+
+ QPoint clickpos = table->visualRect(model.index(1, 1)).center();
+ QTest::mouseClick(table->viewport(), Qt::LeftButton, Qt::NoModifier, clickpos);
+ QTest::mouseDClick(table->viewport(), Qt::LeftButton, Qt::NoModifier, clickpos);
+
+ QPointer<QWidget> editor1 = qApp->focusWidget();
+ QVERIFY(editor1);
+ QTest::keyClick(editor1, Qt::Key_Tab, Qt::NoModifier);
+
+ QPointer<QWidget> editor2 = qApp->focusWidget();
+ QVERIFY(editor2);
+ QTest::keyClick(editor2, Qt::Key_Escape, Qt::NoModifier);
+
+ QCOMPARE(selectionChangeSpy.count(), 0);
+}
+
QTEST_MAIN(tst_QAbstractItemView)
#include "tst_qabstractitemview.moc"
diff --git a/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp
index aaff322c4b..168a17773e 100644
--- a/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp
+++ b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp
@@ -48,6 +48,8 @@
#include <qmenu.h>
#include <qaction.h>
#include <qstyleoption.h>
+#include <qscreen.h>
+#include <qlabel.h>
class tst_QToolButton : public QObject
{
@@ -68,7 +70,7 @@ private slots:
protected slots:
void sendMouseClick();
private:
- QWidget *w;
+ QPointer<QWidget> m_menu;
};
tst_QToolButton::tst_QToolButton()
@@ -121,29 +123,39 @@ void tst_QToolButton::getSetCheck()
void tst_QToolButton::triggered()
{
qRegisterMetaType<QAction *>("QAction *");
- QToolButton tb;
- tb.show();
- QSignalSpy spy(&tb,SIGNAL(triggered(QAction*)));
- QMenu *menu = new QMenu("Menu");
+ QWidget mainWidget;
+ mainWidget.setWindowTitle(QStringLiteral("triggered"));
+ mainWidget.resize(200, 200);
+ mainWidget.move(QGuiApplication::primaryScreen()->availableGeometry().center() - QPoint(100, 100));
+ QToolButton *toolButton = new QToolButton(&mainWidget);
+ QSignalSpy spy(toolButton,SIGNAL(triggered(QAction*)));
+ QScopedPointer<QMenu> menu(new QMenu(QStringLiteral("Menu")));
QAction *one = menu->addAction("one");
menu->addAction("two");
- QAction *def = new QAction("def", this);
+ QAction *defaultAction = new QAction(QStringLiteral("def"), this);
- tb.setMenu(menu);
- tb.setDefaultAction(def);
+ toolButton->setMenu(menu.data());
+ toolButton->setDefaultAction(defaultAction);
+ mainWidget.show();
+ QApplication::setActiveWindow(&mainWidget);
+ QVERIFY(QTest::qWaitForWindowActive(&mainWidget));
- def->trigger();
+ defaultAction->trigger();
QCOMPARE(spy.count(),1);
- QCOMPARE(qvariant_cast<QAction *>(spy.at(0).at(0)), def);
+ QCOMPARE(qvariant_cast<QAction *>(spy.at(0).at(0)), defaultAction);
- w = menu;
- QTimer::singleShot(30, this, SLOT(sendMouseClick()));
- tb.showMenu();
+ m_menu = menu.data();
+
+ QTimer *timer = new QTimer(this);
+ timer->setInterval(50);
+ connect(timer, SIGNAL(timeout()), this, SLOT(sendMouseClick()));
+ timer->start();
+ QTimer::singleShot(10000, &mainWidget, SLOT(close())); // Emergency bail-out
+ toolButton->showMenu();
QTest::qWait(20);
QCOMPARE(spy.count(),2);
QCOMPARE(qvariant_cast<QAction *>(spy.at(1).at(0)), one);
- delete menu;
}
void tst_QToolButton::collapseTextOnPriority()
@@ -195,20 +207,30 @@ void tst_QToolButton::task230994_iconSize()
void tst_QToolButton::task176137_autoRepeatOfAction()
{
QAction action(0);
- QToolButton tb;
- tb.setDefaultAction (&action);
- tb.show();
+ QWidget mainWidget;
+ mainWidget.setWindowTitle(QStringLiteral("task176137_autoRepeatOfAction"));
+ mainWidget.resize(200, 200);
+ mainWidget.move(QGuiApplication::primaryScreen()->availableGeometry().center() - QPoint(100, 100));
+ QToolButton *toolButton = new QToolButton(&mainWidget);
+ toolButton->setDefaultAction (&action);
+ QLabel *label = new QLabel(QStringLiteral("This test takes a while."), &mainWidget);
+ label->move(0, 50);
+
+ mainWidget.show();
+ QApplication::setActiveWindow(&mainWidget);
+ QVERIFY(QTest::qWaitForWindowActive(&mainWidget));
+
QSignalSpy spy(&action,SIGNAL(triggered()));
- QTest::mousePress ( &tb, Qt::LeftButton);
- QTest::mouseRelease ( &tb, Qt::LeftButton, 0, QPoint (), 2000);
+ QTest::mousePress (toolButton, Qt::LeftButton);
+ QTest::mouseRelease (toolButton, Qt::LeftButton, 0, QPoint (), 2000);
QCOMPARE(spy.count(),1);
// try again with auto repeat
- tb.setAutoRepeat (true);
+ toolButton->setAutoRepeat (true);
QSignalSpy repeatSpy(&action,SIGNAL(triggered())); // new spy
- QTest::mousePress ( &tb, Qt::LeftButton);
- QTest::mouseRelease ( &tb, Qt::LeftButton, 0, QPoint (), 3000);
- qreal expected = (3000 - tb.autoRepeatDelay()) / tb.autoRepeatInterval() + 1;
+ QTest::mousePress (toolButton, Qt::LeftButton);
+ QTest::mouseRelease (toolButton, Qt::LeftButton, 0, QPoint (), 3000);
+ const qreal expected = (3000 - toolButton->autoRepeatDelay()) / toolButton->autoRepeatInterval() + 1;
//we check that the difference is small (on some systems timers are not super accurate)
qreal diff = (expected - repeatSpy.count()) / expected;
QVERIFY2(qAbs(diff) < 0.2, qPrintable(
@@ -221,7 +243,17 @@ void tst_QToolButton::task176137_autoRepeatOfAction()
void tst_QToolButton::sendMouseClick()
{
- QTest::mouseClick(w, Qt::LeftButton, 0, QPoint(7,7));
+ if (m_menu.isNull()) {
+ qWarning("m_menu is NULL");
+ return;
+ }
+ if (!m_menu->isVisible())
+ return;
+ QTest::mouseClick(m_menu.data(), Qt::LeftButton, 0, QPoint(7, 7));
+ if (QTimer *timer = qobject_cast<QTimer *>(sender())) {
+ timer->stop();
+ timer->deleteLater();
+ }
}
void tst_QToolButton::qtbug_26956_popupTimerDone()
diff --git a/tests/manual/dialogs/dialogs.pro b/tests/manual/dialogs/dialogs.pro
index 71c41119fe..21ebf9b622 100644
--- a/tests/manual/dialogs/dialogs.pro
+++ b/tests/manual/dialogs/dialogs.pro
@@ -8,3 +8,4 @@ SOURCES += main.cpp filedialogpanel.cpp colordialogpanel.cpp fontdialogpanel.cpp
wizardpanel.cpp messageboxpanel.cpp printdialogpanel.cpp utils.cpp
HEADERS += filedialogpanel.h colordialogpanel.h fontdialogpanel.h \
wizardpanel.h messageboxpanel.h printdialogpanel.h utils.h
+FORMS += printdialogpanel.ui
diff --git a/tests/manual/dialogs/printdialogpanel.cpp b/tests/manual/dialogs/printdialogpanel.cpp
index 5c89055e22..f7d027020c 100644
--- a/tests/manual/dialogs/printdialogpanel.cpp
+++ b/tests/manual/dialogs/printdialogpanel.cpp
@@ -45,6 +45,7 @@
#include "utils.h"
#include <QPrinter>
+#include <QPrinterInfo>
#include <QPrintDialog>
#include <QPrintPreviewDialog>
#include <QPageSetupDialog>
@@ -64,20 +65,16 @@
#include <QDateTime>
#include <QDebug>
#include <QTextStream>
+#include <QDir>
-const FlagData modeComboData[] =
+const FlagData printerModeComboData[] =
{
{"ScreenResolution", QPrinter::ScreenResolution},
{"PrinterResolution", QPrinter::PrinterResolution},
{"HighResolution", QPrinter::HighResolution}
};
-const FlagData orientationComboData[] =
-{
- {"Portrait", QPrinter::Portrait},
- {"Landscape", QPrinter::Landscape},
-};
-
+#if QT_VERSION < 0x050300
const FlagData pageSizeComboData[] =
{
{"A4", QPrinter::A4},
@@ -112,6 +109,76 @@ const FlagData pageSizeComboData[] =
{"Tabloid", QPrinter::Tabloid},
{"Custom", QPrinter::Custom}
};
+#endif
+
+const FlagData printRangeComboData[] =
+{
+ {"AllPages", QPrinter::AllPages},
+ {"Selection", QPrinter::Selection},
+ {"PageRange", QPrinter::PageRange},
+ {"CurrentPage", QPrinter::CurrentPage}
+};
+
+const FlagData pageOrderComboData[] =
+{
+ {"FirstPageFirst", QPrinter::FirstPageFirst},
+ {"LastPageFirst", QPrinter::LastPageFirst},
+};
+
+const FlagData duplexModeComboData[] =
+{
+ {"DuplexNone", QPrinter::DuplexNone},
+ {"DuplexAuto", QPrinter::DuplexAuto},
+ {"DuplexLongSide", QPrinter::DuplexLongSide},
+ {"DuplexShortSide", QPrinter::DuplexShortSide},
+};
+
+const FlagData paperSourceComboData[] =
+{
+ {"OnlyOne", QPrinter::OnlyOne},
+ {"Lower", QPrinter::Lower},
+ {"Middle", QPrinter::Middle},
+ {"Manual", QPrinter::Manual},
+ {"Envelope", QPrinter::Envelope},
+ {"EnvelopeManual", QPrinter::EnvelopeManual},
+ {"Auto", QPrinter::Auto},
+ {"Tractor", QPrinter::Tractor},
+ {"SmallFormat", QPrinter::SmallFormat},
+ {"LargeFormat", QPrinter::LargeFormat},
+ {"LargeCapacity", QPrinter::LargeCapacity},
+ {"Cassette", QPrinter::Cassette},
+ {"FormSource", QPrinter::FormSource},
+ {"DuplexLongSide", QPrinter::DuplexLongSide},
+ {"DuplexShortSide", QPrinter::DuplexShortSide},
+};
+
+const FlagData colorModeComboData[] =
+{
+ {"GrayScale", QPrinter::GrayScale},
+ {"Color", QPrinter::Color},
+};
+
+const FlagData unitsComboData[] =
+{
+ {"Millimeter", QPageLayout::Millimeter},
+ {"Inch", QPageLayout::Inch},
+ {"Point", QPageLayout::Point},
+ {"Pica", QPageLayout::Pica},
+ {"Didot", QPageLayout::Didot},
+ {"Cicero", QPageLayout::Cicero},
+};
+
+const FlagData orientationComboData[] =
+{
+ {"Portrait", QPageLayout::Portrait},
+ {"Landscape", QPageLayout::Landscape},
+};
+
+const FlagData layoutModeComboData[] =
+{
+ {"StandardMode", QPageLayout::StandardMode},
+ {"FullPageMode", QPageLayout::FullPageMode},
+};
const FlagData printDialogOptions[] =
{
@@ -123,14 +190,6 @@ const FlagData printDialogOptions[] =
{"PrintCurrentPage", QPrintDialog::PrintCurrentPage}
};
-const FlagData printRangeOptions[] =
-{
- {"AllPages", QPrintDialog::AllPages},
- {"Selection", QPrintDialog::Selection},
- {"PageRange", QPrintDialog::PageRange},
- {"CurrentPage", QPrintDialog::CurrentPage}
-};
-
QTextStream &operator<<(QTextStream &s, const QSizeF &size)
{
s << size.width() << 'x' << size.height();
@@ -260,93 +319,69 @@ public slots:
void slotPaintRequested(QPrinter *p) { print(p); }
};
-class PageSizeControl : public QWidget {
-public:
- explicit PageSizeControl(QWidget *parent = 0);
- QSizeF pageSize() const { return QSizeF(m_width->value(), m_height->value()); }
- void setPageSize(const QSizeF &s) { m_width->setValue(s.width()); m_height->setValue(s.height()); }
-
-private:
- QDoubleSpinBox *m_width;
- QDoubleSpinBox *m_height;
-};
+PrintDialogPanel::PrintDialogPanel(QWidget *parent)
+ : QWidget(parent), m_blockSignals(true)
+{
+#if QT_VERSION < 0x050300
+ m_printerLayout.setOutputFormat(QPrinter::PdfFormat);
+#endif
-PageSizeControl::PageSizeControl(QWidget *parent)
- : QWidget(parent)
- , m_width(new QDoubleSpinBox(this))
- , m_height(new QDoubleSpinBox(this))
-{
- m_width->setRange(1, 1000);
- m_width->setSingleStep(10);
- m_height->setRange(1, 1000);
- m_height->setSingleStep(10);
- QHBoxLayout *hBoxLayout = new QHBoxLayout(this);
- hBoxLayout->addWidget(m_width);
- hBoxLayout->addWidget(new QLabel("x", this));
- hBoxLayout->addWidget(m_height);
- hBoxLayout->addWidget(new QLabel("mm", this));
-}
+ m_panel.setupUi(this);
-PrintDialogPanel::PrintDialogPanel(QWidget *parent)
- : QWidget(parent)
- , m_creationGroupBox(new QGroupBox(tr("Create"), this))
- , m_settingsGroupBox(new QGroupBox(tr("Settings"), this))
- , m_dialogsGroupBox(new QGroupBox(tr("Dialogs"), this))
- , m_pageSizeCombo(new QComboBox)
-{
- // Create with resolution
- QHBoxLayout *hBoxLayout = new QHBoxLayout(m_creationGroupBox);
- m_modeCombo = createCombo(m_creationGroupBox, modeComboData, sizeof(modeComboData)/sizeof(FlagData));
- hBoxLayout->addWidget(m_modeCombo);
- m_createButton = new QPushButton(tr("Create"), m_creationGroupBox);
- connect(m_createButton, SIGNAL(clicked()), this, SLOT(createPrinter()));
- hBoxLayout->addWidget(m_createButton);
- m_deleteButton = new QPushButton(tr("Delete"), m_creationGroupBox);
- connect(m_deleteButton, SIGNAL(clicked()), this, SLOT(deletePrinter()));
- hBoxLayout->addWidget(m_deleteButton);
- hBoxLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Ignored));
-
- QFormLayout *formLayout = new QFormLayout(m_settingsGroupBox);
- m_pageSizeCombo = createCombo(m_settingsGroupBox, pageSizeComboData, sizeof(pageSizeComboData)/sizeof(FlagData));
- connect(m_pageSizeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(enableCustomSizeControl()));
- formLayout->addRow(tr("Paper #:"), m_pageSizeCombo);
- m_customPageSizeControl = new PageSizeControl;
- formLayout->addRow(tr("Custom size:"), m_customPageSizeControl);
- m_orientationCombo = createCombo(m_settingsGroupBox, orientationComboData, sizeof(orientationComboData)/sizeof(FlagData));
- formLayout->addRow("Orientation:", m_orientationCombo);
- m_fullPageCheckBox = new QCheckBox(tr("Full page"), m_settingsGroupBox);
- formLayout->addRow(m_fullPageCheckBox);
-
- QVBoxLayout *vBoxLayout = new QVBoxLayout(m_dialogsGroupBox);
-
- m_printDialogOptionsControl = new OptionsControl(tr("Options"), printDialogOptions, sizeof(printDialogOptions) / sizeof(FlagData), m_dialogsGroupBox);
- vBoxLayout->addWidget(m_printDialogOptionsControl);
- m_printDialogRangeCombo = createCombo(m_dialogsGroupBox, printRangeOptions, sizeof(printRangeOptions) / sizeof(FlagData));
- vBoxLayout->addWidget(m_printDialogRangeCombo);
+ // Setup the Create box
+ populateCombo(m_panel.m_printerModeCombo, printerModeComboData, sizeof(printerModeComboData)/sizeof(FlagData));
+ connect(m_panel.m_createButton, SIGNAL(clicked()), this, SLOT(createPrinter()));
+ connect(m_panel.m_deleteButton, SIGNAL(clicked()), this, SLOT(deletePrinter()));
- {
- QPrintDialog dialog;
- m_printDialogOptionsControl->setValue(dialog.options());
- m_printDialogRangeCombo->setCurrentIndex(dialog.printRange());
+ // Setup the Page Layout box
+ populateCombo(m_panel.m_unitsCombo, unitsComboData, sizeof(unitsComboData)/sizeof(FlagData));
+ connect(m_panel.m_unitsCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(unitsChanged()));
+#if QT_VERSION >= 0x050300
+ for (int i = QPageSize::A4; i < QPageSize::LastPageSize; ++i) {
+ QPageSize::PageSizeId id = QPageSize::PageSizeId(i);
+ m_panel.m_pageSizeCombo->addItem(QPageSize::name(id), QVariant(id));
}
-
- QPushButton *button = new QPushButton(tr("Print..."), m_dialogsGroupBox);
- connect(button, SIGNAL(clicked()), this, SLOT(showPrintDialog()));
- vBoxLayout->addWidget(button);
- button = new QPushButton(tr("Preview..."), m_dialogsGroupBox);
- connect(button, SIGNAL(clicked()), this, SLOT(showPreviewDialog()));
- vBoxLayout->addWidget(button);
- button = new QPushButton(tr("Page Setup..."), m_dialogsGroupBox);
- connect(button, SIGNAL(clicked()), this, SLOT(showPageSetupDialog()));
- vBoxLayout->addWidget(button);
-
- QGridLayout *gridLayout = new QGridLayout(this);
- gridLayout->addWidget(m_creationGroupBox, 0, 0);
- gridLayout->addWidget(m_settingsGroupBox, 1, 0);
- gridLayout->addWidget(m_dialogsGroupBox, 0, 1, 2, 1);
- gridLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 2, 0, 1, 2);
+#else
+ populateCombo(m_panel.m_pageSizeCombo, pageSizeComboData, sizeof(pageSizeComboData)/sizeof(FlagData));
+#endif
+ connect(m_panel.m_pageSizeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(pageSizeChanged()));
+ connect(m_panel.m_pageWidth, SIGNAL(valueChanged(double)), this, SLOT(pageDimensionsChanged()));
+ connect(m_panel.m_pageHeight, SIGNAL(valueChanged(double)), this, SLOT(pageDimensionsChanged()));
+ populateCombo(m_panel.m_orientationCombo, orientationComboData, sizeof(orientationComboData)/sizeof(FlagData));
+ connect(m_panel.m_orientationCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(orientationChanged()));
+ connect(m_panel.m_leftMargin, SIGNAL(valueChanged(double)), this, SLOT(marginsChanged()));
+ connect(m_panel.m_topMargin, SIGNAL(valueChanged(double)), this, SLOT(marginsChanged()));
+ connect(m_panel.m_rightMargin, SIGNAL(valueChanged(double)), this, SLOT(marginsChanged()));
+ connect(m_panel.m_bottomMargin, SIGNAL(valueChanged(double)), this, SLOT(marginsChanged()));
+ populateCombo(m_panel.m_layoutModeCombo, layoutModeComboData, sizeof(layoutModeComboData)/sizeof(FlagData));
+ connect(m_panel.m_layoutModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(layoutModeChanged()));
+
+ // Setup the Print Job box
+ m_panel.m_printerCombo->addItem(tr("Print to PDF"), QVariant("PdfFormat"));
+#if QT_VERSION >= 0x050300
+ foreach (const QString &name, QPrinterInfo::availablePrinterNames())
+ m_panel.m_printerCombo->addItem(name, QVariant(name));
+#else
+ foreach (const QPrinterInfo &printer, QPrinterInfo::availablePrinters())
+ m_panel.m_printerCombo->addItem(printer.printerName(), QVariant(printer.printerName()));
+#endif
+ connect(m_panel.m_printerCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(printerChanged()));
+ populateCombo(m_panel.m_printRangeCombo, printRangeComboData, sizeof(printRangeComboData)/sizeof(FlagData));
+ populateCombo(m_panel.m_pageOrderCombo, pageOrderComboData, sizeof(pageOrderComboData)/sizeof(FlagData));
+ populateCombo(m_panel.m_duplexModeCombo, duplexModeComboData, sizeof(duplexModeComboData)/sizeof(FlagData));
+ populateCombo(m_panel.m_paperSourceCombo, paperSourceComboData, sizeof(paperSourceComboData)/sizeof(FlagData));
+ populateCombo(m_panel.m_colorModeCombo, colorModeComboData, sizeof(colorModeComboData)/sizeof(FlagData));
+
+ // Setup the Dialogs box
+ m_panel.m_dialogOptionsGroupBox->populateOptions(printDialogOptions, sizeof(printDialogOptions) / sizeof(FlagData));
+ QPrintDialog dialog;
+ m_panel.m_dialogOptionsGroupBox->setValue(dialog.options());
+ connect(m_panel.m_printButton, SIGNAL(clicked()), this, SLOT(showPrintDialog()));
+ connect(m_panel.m_printPreviewButton, SIGNAL(clicked()), this, SLOT(showPreviewDialog()));
+ connect(m_panel.m_pageSetupButton, SIGNAL(clicked()), this, SLOT(showPageSetupDialog()));
enablePanels();
+ m_blockSignals = false;
}
PrintDialogPanel::~PrintDialogPanel()
@@ -356,20 +391,20 @@ PrintDialogPanel::~PrintDialogPanel()
void PrintDialogPanel::enablePanels()
{
const bool exists = !m_printer.isNull();
- m_createButton->setEnabled(!exists);
- m_modeCombo->setEnabled(!exists);
- m_deleteButton->setEnabled(exists);
- m_settingsGroupBox->setEnabled(exists);
- m_dialogsGroupBox->setEnabled(exists);
+ m_panel.m_createButton->setEnabled(!exists);
+ m_panel.m_printerModeCombo->setEnabled(!exists);
+ m_panel.m_deleteButton->setEnabled(exists);
+ m_panel.m_pageLayoutGroupBox->setEnabled(exists);
+ m_panel.m_printJobGroupBox->setEnabled(exists);
+ m_panel.m_dialogsGroupBox->setEnabled(exists);
}
void PrintDialogPanel::createPrinter()
{
- const QPrinter::PrinterMode mode = comboBoxValue<QPrinter::PrinterMode>(m_modeCombo);
+ const QPrinter::PrinterMode mode = comboBoxValue<QPrinter::PrinterMode>(m_panel.m_printerModeCombo);
m_printer.reset(new QPrinter(mode)); // Can set only once.
retrieveSettings(m_printer.data());
enablePanels();
- enableCustomSizeControl();
}
void PrintDialogPanel::deletePrinter()
@@ -378,36 +413,256 @@ void PrintDialogPanel::deletePrinter()
enablePanels();
}
+QSizeF PrintDialogPanel::customPageSize() const
+{
+ return QSizeF(m_panel.m_pageWidth->value(), m_panel.m_pageHeight->value());
+}
+
+// Apply the settings to the QPrinter
void PrintDialogPanel::applySettings(QPrinter *printer) const
{
- const QPrinter::PageSize pageSize = comboBoxValue<QPrinter::PageSize>(m_pageSizeCombo);
- if (pageSize == QPrinter::Custom)
- printer->setPaperSize(m_customPageSizeControl->pageSize(), QPrinter::Millimeter);
+ QString printerName = m_panel.m_printerCombo->currentData().toString();
+ if (printerName == QStringLiteral("PdfFormat"))
+ printer->setOutputFileName(m_panel.m_fileName->text());
+ else
+ printer->setPrinterName(printerName);
+ printer->setPrintRange(comboBoxValue<QPrinter::PrintRange>(m_panel.m_printRangeCombo));
+ printer->setFromTo(m_panel.m_fromPage->value(), m_panel.m_toPage->value());
+ printer->setPageOrder(comboBoxValue<QPrinter::PageOrder>(m_panel.m_pageOrderCombo));
+ printer->setCopyCount(m_panel.m_copyCount->value());
+ printer->setCollateCopies(m_panel.m_collateCopies->isChecked());
+ printer->setDuplex(comboBoxValue<QPrinter::DuplexMode>(m_panel.m_duplexModeCombo));
+ printer->setPaperSource(comboBoxValue<QPrinter::PaperSource>(m_panel.m_paperSourceCombo));
+ printer->setColorMode(comboBoxValue<QPrinter::ColorMode>(m_panel.m_colorModeCombo));
+ printer->setResolution(m_panel.m_resolution->value());
+
+#if QT_VERSION >= 0x050300
+ printer->setPageLayout(m_pageLayout);
+#else
+ if (m_printerLayout.pageSize() == QPrinter::Custom)
+ printer->setPaperSize(customPageSize(), m_units);
else
- printer->setPageSize(pageSize);
- printer->setOrientation(comboBoxValue<QPrinter::Orientation>(m_orientationCombo));
- printer->setFullPage(m_fullPageCheckBox->isChecked());
+ printer->setPageSize(m_printerLayout.pageSize());
+ printer->setOrientation(m_printerLayout.orientation());
+ printer->setFullPage(m_printerLayout.fullPage());
+ double left, top, right, bottom;
+ m_printerLayout.getPageMargins(&left, &top, &right, &bottom, m_units);
+ printer->setPageMargins(left, top, right, bottom, m_units);
+#endif
}
+// Retrieve the settings from the QPrinter
void PrintDialogPanel::retrieveSettings(const QPrinter *printer)
{
- setComboBoxValue(m_pageSizeCombo, printer->pageSize());
- setComboBoxValue(m_orientationCombo, printer->orientation());
- m_fullPageCheckBox->setChecked(printer->fullPage());
- m_customPageSizeControl->setPageSize(m_printer->paperSize(QPrinter::Millimeter));
+ if (printer->outputFormat() == QPrinter::NativeFormat) {
+ m_panel.m_printerCombo->setCurrentIndex(m_panel.m_printerCombo->findData(QVariant(printer->printerName())));
+ m_panel.m_fileName->setEnabled(false);
+ } else {
+ m_panel.m_printerCombo->setCurrentIndex(m_panel.m_printerCombo->findData(QVariant(QStringLiteral("PdfFormat"))));
+ m_panel.m_fileName->setEnabled(true);
+ }
+ m_panel.m_fileName->setText(printer->outputFileName());
+ setComboBoxValue(m_panel.m_printRangeCombo, printer->printRange());
+ m_panel.m_fromPage->setValue(printer->fromPage());
+ m_panel.m_toPage->setValue(printer->toPage());
+ setComboBoxValue(m_panel.m_pageOrderCombo, printer->pageOrder());
+ m_panel.m_copyCount->setValue(printer->copyCount());
+ m_panel.m_collateCopies->setChecked(printer->collateCopies());
+ setComboBoxValue(m_panel.m_duplexModeCombo, printer->duplex());
+ setComboBoxValue(m_panel.m_paperSourceCombo, printer->paperSource());
+ setComboBoxValue(m_panel.m_colorModeCombo, printer->colorMode());
+ m_panel.m_resolution->setValue(printer->resolution());
+
+#if QT_VERSION >= 0x050300
+ m_pageLayout = printer->pageLayout();
+#else
+ if (printer->pageSize() == QPrinter::Custom)
+ m_printerLayout.setPaperSize(customPageSize(), m_units);
+ else
+ m_printerLayout.setPageSize(printer->pageSize());
+ m_printerLayout.setOrientation(printer->orientation());
+ m_printerLayout.setFullPage(printer->fullPage());
+ double left, top, right, bottom;
+ printer->getPageMargins(&left, &top, &right, &bottom, m_units);
+ m_printerLayout.setPageMargins(left, top, right, bottom, m_units);
+#endif
+ updatePageLayoutWidgets();
+}
+
+void PrintDialogPanel::updatePageLayoutWidgets()
+{
+ m_blockSignals = true;
+#if QT_VERSION >= 0x050300
+ setComboBoxValue(m_panel.m_unitsCombo, m_pageLayout.units());
+ setComboBoxValue(m_panel.m_pageSizeCombo, m_pageLayout.pageSize().id());
+ QSizeF sizef = m_pageLayout.pageSize().size(QPageSize::Unit(m_pageLayout.units()));
+ bool custom = (m_pageLayout.pageSize().id() == QPageSize::Custom);
+ setComboBoxValue(m_panel.m_orientationCombo, m_pageLayout.orientation());
+ m_panel.m_leftMargin->setValue(m_pageLayout.margins().left());
+ m_panel.m_topMargin->setValue(m_pageLayout.margins().top());
+ m_panel.m_rightMargin->setValue(m_pageLayout.margins().right());
+ m_panel.m_bottomMargin->setValue(m_pageLayout.margins().bottom());
+ setComboBoxValue(m_panel.m_layoutModeCombo, m_pageLayout.mode());
+ QRectF rectf = m_pageLayout.paintRect();
+#else
+ setComboBoxValue(m_panel.m_unitsCombo, m_units);
+ setComboBoxValue(m_panel.m_pageSizeCombo, m_printerLayout.pageSize());
+ QSizeF sizef = m_printerLayout.paperSize(m_units);
+ bool custom = (m_printerLayout.pageSize() == QPrinter::Custom);
+ setComboBoxValue(m_panel.m_orientationCombo, m_printerLayout.orientation());
+ double left, top, right, bottom;
+ m_printerLayout.getPageMargins(&left, &top, &right, &bottom, m_units);
+ m_panel.m_leftMargin->setValue(left);
+ m_panel.m_topMargin->setValue(top);
+ m_panel.m_rightMargin->setValue(right);
+ m_panel.m_bottomMargin->setValue(bottom);
+ if (m_printerLayout.fullPage())
+ setComboBoxValue(m_panel.m_layoutModeCombo, QPageLayout::FullPageMode);
+ else
+ setComboBoxValue(m_panel.m_layoutModeCombo, QPageLayout::StandardMode);
+ QRectF rectf = m_printerLayout.pageRect(m_units);
+#endif
+ m_panel.m_pageWidth->setValue(sizef.width());
+ m_panel.m_pageHeight->setValue(sizef.height());
+ m_panel.m_pageWidth->setEnabled(custom);
+ m_panel.m_pageHeight->setEnabled(custom);
+ m_panel.m_rectX->setValue(rectf.x());
+ m_panel.m_rectY->setValue(rectf.y());
+ m_panel.m_rectWidth->setValue(rectf.width());
+ m_panel.m_rectHeight->setValue(rectf.height());
+ QString suffix;
+ switch (comboBoxValue<QPageLayout::Unit>(m_panel.m_unitsCombo)) {
+ case QPageLayout::Millimeter:
+ suffix = tr(" mm");
+ break;
+ case QPageLayout::Point:
+ suffix = tr(" pt");
+ break;
+ case QPageLayout::Inch:
+ suffix = tr(" in");
+ break;
+ case QPageLayout::Pica:
+ suffix = tr(" pc");
+ break;
+ case QPageLayout::Didot:
+ suffix = tr(" DD");
+ break;
+ case QPageLayout::Cicero:
+ suffix = tr(" CC");
+ break;
+ }
+ m_panel.m_pageWidth->setSuffix(suffix);
+ m_panel.m_pageHeight->setSuffix(suffix);
+ m_panel.m_leftMargin->setSuffix(suffix);
+ m_panel.m_topMargin->setSuffix(suffix);
+ m_panel.m_rightMargin->setSuffix(suffix);
+ m_panel.m_bottomMargin->setSuffix(suffix);
+ m_panel.m_rectX->setSuffix(suffix);
+ m_panel.m_rectY->setSuffix(suffix);
+ m_panel.m_rectWidth->setSuffix(suffix);
+ m_panel.m_rectHeight->setSuffix(suffix);
+ m_blockSignals = false;
+}
+
+void PrintDialogPanel::unitsChanged()
+{
+ if (m_blockSignals)
+ return;
+#if QT_VERSION >= 0x050300
+ m_pageLayout.setUnits(comboBoxValue<QPageLayout::Unit>(m_panel.m_unitsCombo));
+#else
+ m_units = comboBoxValue<QPrinter::Unit>(m_panel.m_unitsCombo);
+#endif
+ updatePageLayoutWidgets();
+}
+
+void PrintDialogPanel::pageSizeChanged()
+{
+ if (m_blockSignals)
+ return;
+#if QT_VERSION >= 0x050300
+ const QPageSize::PageSizeId pageSizeId = comboBoxValue<QPageSize::PageSizeId>(m_panel.m_pageSizeCombo);
+ QPageSize pageSize;
+ if (pageSizeId == QPageSize::Custom)
+ pageSize = QPageSize(QSizeF(200, 200), QPageSize::Unit(m_pageLayout.units()));
+ else
+ pageSize = QPageSize(pageSizeId);
+ m_pageLayout.setPageSize(pageSize);
+#else
+ const QPrinter::PageSize pageSize = comboBoxValue<QPrinter::PageSize>(m_panel.m_pageSizeCombo);
+ if (pageSize == QPrinter::Custom)
+ m_printerLayout.setPaperSize(QSizeF(200, 200), m_units);
+ else
+ m_printerLayout.setPageSize(pageSize);
+#endif
+ updatePageLayoutWidgets();
+}
+
+void PrintDialogPanel::pageDimensionsChanged()
+{
+ if (m_blockSignals)
+ return;
+#if QT_VERSION >= 0x050300
+ m_pageLayout.setPageSize(QPageSize(customPageSize(), QPageSize::Unit(m_pageLayout.units())));
+#else
+ m_printerLayout.setPaperSize(customPageSize(), m_units);
+#endif
+ updatePageLayoutWidgets();
+}
+
+void PrintDialogPanel::orientationChanged()
+{
+ if (m_blockSignals)
+ return;
+#if QT_VERSION >= 0x050300
+ m_pageLayout.setOrientation(comboBoxValue<QPageLayout::Orientation>(m_panel.m_orientationCombo));
+#else
+ m_printerLayout.setOrientation(comboBoxValue<QPrinter::Orientation>(m_panel.m_orientationCombo));
+#endif
+ updatePageLayoutWidgets();
+}
+
+void PrintDialogPanel::marginsChanged()
+{
+ if (m_blockSignals)
+ return;
+#if QT_VERSION >= 0x050300
+ m_pageLayout.setMargins(QMarginsF(m_panel.m_leftMargin->value(), m_panel.m_topMargin->value(),
+ m_panel.m_rightMargin->value(), m_panel.m_bottomMargin->value()));
+#else
+ m_printerLayout.setPageMargins(m_panel.m_leftMargin->value(), m_panel.m_topMargin->value(),
+ m_panel.m_rightMargin->value(), m_panel.m_bottomMargin->value(),
+ m_units);
+#endif
+ updatePageLayoutWidgets();
+}
+
+void PrintDialogPanel::layoutModeChanged()
+{
+ if (m_blockSignals)
+ return;
+#if QT_VERSION >= 0x050300
+ m_pageLayout.setMode(comboBoxValue<QPageLayout::Mode>(m_panel.m_layoutModeCombo));
+#else
+ bool fullPage = (comboBoxValue<QPageLayout::Mode>(m_panel.m_layoutModeCombo) == QPageLayout::FullPageMode);
+ m_printerLayout.setFullPage(fullPage);
+#endif
+ updatePageLayoutWidgets();
}
-void PrintDialogPanel::enableCustomSizeControl()
+void PrintDialogPanel::printerChanged()
{
- m_customPageSizeControl->setEnabled(m_pageSizeCombo->currentIndex() == QPrinter::Custom);
+ bool isPdf = (m_panel.m_printerCombo->currentData().toString() == QStringLiteral("PdfFormat"));
+ m_panel.m_fileName->setEnabled(isPdf);
+ if (isPdf && m_panel.m_fileName->text().isEmpty())
+ m_panel.m_fileName->setText(QDir::homePath() + QDir::separator() + QStringLiteral("print.pdf"));
}
void PrintDialogPanel::showPrintDialog()
{
applySettings(m_printer.data());
QPrintDialog dialog(m_printer.data(), this);
- dialog.setOptions(m_printDialogOptionsControl->value<QPrintDialog::PrintDialogOptions>());
- dialog.setPrintRange(comboBoxValue<QPrintDialog::PrintRange>(m_printDialogRangeCombo));
+ dialog.setOptions(m_panel.m_dialogOptionsGroupBox->value<QPrintDialog::PrintDialogOptions>());
if (dialog.exec() == QDialog::Accepted) {
retrieveSettings(m_printer.data());
print(m_printer.data());
@@ -431,6 +686,7 @@ void PrintDialogPanel::showPageSetupDialog()
retrieveSettings(m_printer.data());
}
+#include "moc_printdialogpanel.cpp"
#include "printdialogpanel.moc"
#endif // !QT_NO_PRINTER
diff --git a/tests/manual/dialogs/printdialogpanel.h b/tests/manual/dialogs/printdialogpanel.h
index c869782769..3932cd174f 100644
--- a/tests/manual/dialogs/printdialogpanel.h
+++ b/tests/manual/dialogs/printdialogpanel.h
@@ -44,6 +44,12 @@
#ifndef QT_NO_PRINTER
+#include "ui_printdialogpanel.h"
+
+#if QT_VERSION >= 0x050300
+#include <QPageLayout>
+#endif
+#include <QPrinter>
#include <QWidget>
QT_BEGIN_NAMESPACE
@@ -57,6 +63,31 @@ QT_END_NAMESPACE
class PageSizeControl;
class OptionsControl;
+#if QT_VERSION < 0x050300
+// Copied from class QPageLayout introduced in Qt 5.3
+namespace QPageLayout
+{
+ enum Unit {
+ Millimeter,
+ Point,
+ Inch,
+ Pica,
+ Didot,
+ Cicero
+ };
+
+ enum Orientation {
+ Portrait,
+ Landscape
+ };
+
+ enum Mode {
+ StandardMode, // Paint Rect includes margins
+ FullPageMode // Paint Rect excludes margins
+ };
+}
+#endif
+
class PrintDialogPanel : public QWidget
{
Q_OBJECT
@@ -70,25 +101,30 @@ private slots:
void showPrintDialog();
void showPreviewDialog();
void showPageSetupDialog();
- void enableCustomSizeControl();
+ void unitsChanged();
+ void pageSizeChanged();
+ void pageDimensionsChanged();
+ void orientationChanged();
+ void marginsChanged();
+ void layoutModeChanged();
+ void printerChanged();
private:
+ QSizeF customPageSize() const;
void applySettings(QPrinter *printer) const;
void retrieveSettings(const QPrinter *printer);
+ void updatePageLayoutWidgets();
void enablePanels();
- QGroupBox *m_creationGroupBox;
- QPushButton *m_createButton;
- QPushButton *m_deleteButton;
- QGroupBox *m_settingsGroupBox;
- QCheckBox *m_fullPageCheckBox;
- QGroupBox *m_dialogsGroupBox;
- OptionsControl *m_printDialogOptionsControl;
- QComboBox *m_printDialogRangeCombo;
- QComboBox *m_modeCombo;
- QComboBox *m_orientationCombo;
- QComboBox *m_pageSizeCombo;
- PageSizeControl *m_customPageSizeControl;
+ bool m_blockSignals;
+ Ui::PrintDialogPanel m_panel;
+
+#if QT_VERSION >= 0x050300
+ QPageLayout m_pageLayout;
+#else
+ QPrinter m_printerLayout;
+ QPrinter::Unit m_units;
+#endif
QScopedPointer<QPrinter> m_printer;
};
diff --git a/tests/manual/dialogs/printdialogpanel.ui b/tests/manual/dialogs/printdialogpanel.ui
new file mode 100644
index 0000000000..733d52ad9e
--- /dev/null
+++ b/tests/manual/dialogs/printdialogpanel.ui
@@ -0,0 +1,677 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>PrintDialogPanel</class>
+ <widget class="QWidget" name="PrintDialogPanel">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>650</width>
+ <height>707</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QGroupBox" name="m_createGroupBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Create</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Printer Mode:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="m_printerModeCombo"/>
+ </item>
+ <item row="1" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QPushButton" name="m_createButton">
+ <property name="text">
+ <string>Create</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="m_deleteButton">
+ <property name="text">
+ <string>Delete</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="m_pageLayoutGroupBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Page Layout</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout_2">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Units:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="m_unitsCombo"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Page Size:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="m_pageSizeCombo"/>
+ </item>
+ <item row="2" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QDoubleSpinBox" name="m_pageWidth">
+ <property name="suffix">
+ <string> mm</string>
+ </property>
+ <property name="maximum">
+ <double>1000.000000000000000</double>
+ </property>
+ <property name="singleStep">
+ <double>10.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>x</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDoubleSpinBox" name="m_pageHeight">
+ <property name="suffix">
+ <string> mm</string>
+ </property>
+ <property name="maximum">
+ <double>1000.000000000000000</double>
+ </property>
+ <property name="singleStep">
+ <double>10.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Orientation:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QComboBox" name="m_orientationCombo"/>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label_7">
+ <property name="text">
+ <string>Margins:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QDoubleSpinBox" name="m_leftMargin">
+ <property name="maximum">
+ <double>1000.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_8">
+ <property name="text">
+ <string>l</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDoubleSpinBox" name="m_rightMargin">
+ <property name="maximum">
+ <double>1000.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_9">
+ <property name="text">
+ <string>t</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDoubleSpinBox" name="m_topMargin">
+ <property name="maximum">
+ <double>1000.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_10">
+ <property name="text">
+ <string>r</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDoubleSpinBox" name="m_bottomMargin">
+ <property name="maximum">
+ <double>1000.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_11">
+ <property name="text">
+ <string>b</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="5" column="0">
+ <widget class="QLabel" name="label_6">
+ <property name="text">
+ <string>Layout Mode:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QComboBox" name="m_layoutModeCombo"/>
+ </item>
+ <item row="6" column="0">
+ <widget class="QLabel" name="label_16">
+ <property name="text">
+ <string>Paint Rect:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <widget class="QDoubleSpinBox" name="m_rectX">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="buttonSymbols">
+ <enum>QAbstractSpinBox::NoButtons</enum>
+ </property>
+ <property name="suffix">
+ <string> mm</string>
+ </property>
+ <property name="maximum">
+ <double>1000.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_12">
+ <property name="text">
+ <string>x</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDoubleSpinBox" name="m_rectY">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="buttonSymbols">
+ <enum>QAbstractSpinBox::NoButtons</enum>
+ </property>
+ <property name="maximum">
+ <double>1000.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_13">
+ <property name="text">
+ <string>y</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDoubleSpinBox" name="m_rectWidth">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="buttonSymbols">
+ <enum>QAbstractSpinBox::NoButtons</enum>
+ </property>
+ <property name="maximum">
+ <double>1000.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_14">
+ <property name="text">
+ <string>w</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDoubleSpinBox" name="m_rectHeight">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="buttonSymbols">
+ <enum>QAbstractSpinBox::NoButtons</enum>
+ </property>
+ <property name="maximum">
+ <double>1000.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_15">
+ <property name="text">
+ <string>h</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_4">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="m_printJobGroupBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Print Job</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout_3">
+ <property name="fieldGrowthPolicy">
+ <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_17">
+ <property name="text">
+ <string>Printer:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="m_printerCombo"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_18">
+ <property name="text">
+ <string>File Name:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="m_fileName"/>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_19">
+ <property name="text">
+ <string>Print Range:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QComboBox" name="m_printRangeCombo"/>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_20">
+ <property name="text">
+ <string>Page Range:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <item>
+ <widget class="QSpinBox" name="m_fromPage">
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_21">
+ <property name="text">
+ <string>to</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="m_toPage">
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_5">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="5" column="0">
+ <widget class="QLabel" name="label_25">
+ <property name="text">
+ <string>Copies:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_6">
+ <item>
+ <widget class="QSpinBox" name="m_copyCount">
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_7">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="m_collateCopies">
+ <property name="text">
+ <string>Collate Copies</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="6" column="0">
+ <widget class="QLabel" name="label_22">
+ <property name="text">
+ <string>Duplex Mode:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="1">
+ <widget class="QComboBox" name="m_duplexModeCombo"/>
+ </item>
+ <item row="7" column="0">
+ <widget class="QLabel" name="label_27">
+ <property name="text">
+ <string>Paper Source:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="1">
+ <widget class="QComboBox" name="m_paperSourceCombo"/>
+ </item>
+ <item row="8" column="0">
+ <widget class="QLabel" name="label_23">
+ <property name="text">
+ <string>Color Mode:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="1">
+ <widget class="QComboBox" name="m_colorModeCombo"/>
+ </item>
+ <item row="9" column="0">
+ <widget class="QLabel" name="label_28">
+ <property name="text">
+ <string>Resolution:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="9" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_7">
+ <item>
+ <widget class="QSpinBox" name="m_resolution">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>5000</number>
+ </property>
+ <property name="singleStep">
+ <number>100</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_6">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label_24">
+ <property name="text">
+ <string>Page Order:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QComboBox" name="m_pageOrderCombo"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>22</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="0" column="1">
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QGroupBox" name="m_dialogsGroupBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Dialogs</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="OptionsControl" name="m_dialogOptionsGroupBox">
+ <property name="title">
+ <string>Options</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="m_printButton">
+ <property name="text">
+ <string>Print...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="m_printPreviewButton">
+ <property name="text">
+ <string>Preview...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="m_pageSetupButton">
+ <property name="text">
+ <string>Page Setup...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>80</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>OptionsControl</class>
+ <extends>QGroupBox</extends>
+ <header>utils.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/tests/manual/dialogs/utils.cpp b/tests/manual/dialogs/utils.cpp
index 7e0067c7f3..2dc01359b1 100644
--- a/tests/manual/dialogs/utils.cpp
+++ b/tests/manual/dialogs/utils.cpp
@@ -52,11 +52,23 @@ QComboBox *createCombo(QWidget *parent, const FlagData *d, size_t size)
return c;
}
+void populateCombo(QComboBox *combo, const FlagData *d, size_t size)
+{
+ for (size_t i = 0; i < size; ++i)
+ combo->addItem(QLatin1String(d[i].description), QVariant(d[i].value));
+}
+
void setComboBoxValue(QComboBox *c, int v)
{
c->setCurrentIndex(c->findData(QVariant(v)));
}
+OptionsControl::OptionsControl(QWidget *parent)
+ : QGroupBox(parent)
+{
+ setLayout(new QVBoxLayout(this));
+}
+
OptionsControl::OptionsControl(const QString &title, const FlagData *data, size_t count, QWidget *parent)
: QGroupBox(title, parent)
{
@@ -68,6 +80,15 @@ OptionsControl::OptionsControl(const QString &title, const FlagData *data, size_
}
}
+void OptionsControl::populateOptions(const FlagData *data, size_t count)
+{
+ for (size_t i = 0; i < count; ++i) {
+ QCheckBox *box = new QCheckBox(QString::fromLatin1(data[i].description));
+ m_checkBoxes.push_back(CheckBoxFlagPair(box, data[i].value));
+ layout()->addWidget(box);
+ }
+}
+
void OptionsControl::setValue(int flags)
{
foreach (const CheckBoxFlagPair &cf, m_checkBoxes)
diff --git a/tests/manual/dialogs/utils.h b/tests/manual/dialogs/utils.h
index 634795627f..ac91754139 100644
--- a/tests/manual/dialogs/utils.h
+++ b/tests/manual/dialogs/utils.h
@@ -59,6 +59,7 @@ struct FlagData
// Helpers for creating combo boxes representing enumeration values from flag data.
QComboBox *createCombo(QWidget *parent, const FlagData *d, size_t size);
+void populateCombo(QComboBox *combo, const FlagData *d, size_t size);
template <class Enum>
Enum comboBoxValue(const QComboBox *c)
@@ -71,8 +72,11 @@ void setComboBoxValue(QComboBox *c, int v);
// A group box with check boxes for option flags.
class OptionsControl : public QGroupBox {
public:
+ OptionsControl(QWidget *parent);
explicit OptionsControl(const QString &title, const FlagData *data, size_t count, QWidget *parent);
+ void populateOptions(const FlagData *data, size_t count);
+
void setValue(int flags);
template <class Enum>
Enum value() const { return static_cast<Enum>(intValue()); }