summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp20
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp11
-rw-r--r--tests/auto/corelib/kernel/qtimer/BLACKLIST2
-rw-r--r--tests/auto/corelib/tools/qcollator/tst_qcollator.cpp18
-rw-r--r--tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp76
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp14
-rw-r--r--tests/auto/gui/painting/qpainter/tst_qpainter.cpp16
-rw-r--r--tests/auto/gui/text/qfontmetrics/testfont.qrc1
-rw-r--r--tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp27
-rw-r--r--tests/auto/tools/moc/cxx11-enums.h9
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp3
-rw-r--r--tests/auto/tools/qmakelib/qmakelib.pro2
-rw-r--r--tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp302
-rw-r--r--tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp40
-rw-r--r--tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp1129
-rw-r--r--tests/manual/textrendering/nativetext/main.cpp36
16 files changed, 1308 insertions, 398 deletions
diff --git a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
index 9a54c0a70d..1b40e77648 100644
--- a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
@@ -81,6 +81,8 @@ private slots:
void setData_emits_both_roles_data();
void setData_emits_both_roles();
+ void setData_emits_on_change_only();
+
void supportedDragDropActions();
};
@@ -246,6 +248,24 @@ void tst_QStringListModel::setData_emits_both_roles()
expected);
}
+void tst_QStringListModel::setData_emits_on_change_only()
+{
+ QStringListModel model(QStringList{QStringLiteral("one"), QStringLiteral("two")});
+ QSignalSpy dataChangedSpy(&model, &QAbstractItemModel::dataChanged);
+ QVERIFY(dataChangedSpy.isValid());
+ const QModelIndex modelIdx = model.index(0, 0);
+ const QString newStringData = QStringLiteral("test");
+ QVERIFY(model.setData(modelIdx, newStringData));
+ QCOMPARE(dataChangedSpy.count(), 1);
+ const QList<QVariant> spyList = dataChangedSpy.takeFirst();
+ QCOMPARE(spyList.at(0).value<QModelIndex>(), modelIdx);
+ QCOMPARE(spyList.at(1).value<QModelIndex>(), modelIdx);
+ const QVector<int> expectedRoles{Qt::DisplayRole, Qt::EditRole};
+ QCOMPARE(spyList.at(2).value<QVector<int> >(), expectedRoles);
+ QVERIFY(model.setData(modelIdx, newStringData));
+ QVERIFY(dataChangedSpy.isEmpty());
+}
+
void tst_QStringListModel::supportedDragDropActions()
{
QStringListModel model;
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
index 5d9b5ca95c..e6fac74ccc 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
@@ -123,6 +123,7 @@ private slots:
void compareCustomType();
void compareCustomEqualOnlyType();
void customDebugStream();
+ void unknownType();
};
struct BaseGenericType
@@ -2529,6 +2530,16 @@ void tst_QMetaType::customDebugStream()
qDebug() << v1;
}
+void tst_QMetaType::unknownType()
+{
+ QMetaType invalid(QMetaType::UnknownType);
+ QVERIFY(!invalid.create());
+ QVERIFY(!invalid.sizeOf());
+ QVERIFY(!invalid.metaObject());
+ int buffer = 0xBAD;
+ invalid.construct(&buffer);
+ QCOMPARE(buffer, 0xBAD);
+}
// Compile-time test, it should be possible to register function pointer types
class Undefined;
diff --git a/tests/auto/corelib/kernel/qtimer/BLACKLIST b/tests/auto/corelib/kernel/qtimer/BLACKLIST
index b355bc22c2..e5136624d8 100644
--- a/tests/auto/corelib/kernel/qtimer/BLACKLIST
+++ b/tests/auto/corelib/kernel/qtimer/BLACKLIST
@@ -1,5 +1,3 @@
[remainingTime]
windows
osx
-[basic_chrono]
-osx ci
diff --git a/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp
index 2d65d3433f..72f88a235d 100644
--- a/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp
+++ b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp
@@ -93,7 +93,7 @@ void tst_QCollator::compare_data()
QTest::addColumn<int>("caseInsensitiveResult");
QTest::addColumn<bool>("numericMode");
QTest::addColumn<bool>("ignorePunctuation");
- QTest::addColumn<int>("punctuationResult");
+ QTest::addColumn<int>("punctuationResult"); // Test ignores punctuation *and case*
/*
It's hard to test English, because it's treated differently
@@ -169,8 +169,12 @@ void tst_QCollator::compare_data()
QTest::newRow("french6") << QString("fr_FR") << QString("Test 9") << QString("Test_19") << -1 << -1 << true << true << -1;
QTest::newRow("french7") << QString("fr_FR") << QString("test_19") << QString("test 19") << 1 << 1 << true << false << 1;
QTest::newRow("french8") << QString("fr_FR") << QString("test.19") << QString("test,19") << 1 << 1 << true << true << 0;
-}
+ // C locale: case sensitive [A-Z] < [a-z] but case insensitive [Aa] < [Bb] <...< [Zz]
+ const QString C = QStringLiteral("C");
+ QTest::newRow("C:ABBA:AaaA") << C << QStringLiteral("ABBA") << QStringLiteral("AaaA") << -1 << 1 << false << false << 1;
+ QTest::newRow("C:AZa:aAZ") << C << QStringLiteral("AZa") << QStringLiteral("aAZ") << -1 << 1 << false << false << 1;
+}
void tst_QCollator::compare()
{
@@ -184,6 +188,10 @@ void tst_QCollator::compare()
QFETCH(int, punctuationResult);
QCollator collator(locale);
+ // Need to canonicalize sign to -1, 0 or 1, as .compare() can produce any -ve for <, any +ve for >.
+ auto asSign = [](int compared) {
+ return compared < 0 ? -1 : compared > 0 ? 1 : 0;
+ };
#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED)
if (collator.locale() != QLocale())
@@ -193,12 +201,12 @@ void tst_QCollator::compare()
if (numericMode)
collator.setNumericMode(true);
- QCOMPARE(collator.compare(s1, s2), result);
+ QCOMPARE(asSign(collator.compare(s1, s2)), result);
collator.setCaseSensitivity(Qt::CaseInsensitive);
- QCOMPARE(collator.compare(s1, s2), caseInsensitiveResult);
+ QCOMPARE(asSign(collator.compare(s1, s2)), caseInsensitiveResult);
#if !QT_CONFIG(iconv)
collator.setIgnorePunctuation(ignorePunctuation);
- QCOMPARE(collator.compare(s1, s2), punctuationResult);
+ QCOMPARE(asSign(collator.compare(s1, s2)), punctuationResult);
#endif
}
diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
index c23ee3b0ba..c02756d76a 100644
--- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
+++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
@@ -2169,47 +2169,47 @@ void tst_QRegularExpression::wildcard_data()
addRow("*.html", "test.html", 0);
addRow("*.html", "test.htm", -1);
- addRow("bar*", "foobarbaz", 3);
+ addRow("*bar*", "foobarbaz", 0);
addRow("*", "Qt Rocks!", 0);
- addRow(".html", "test.html", 4);
- addRow(".h", "test.cpp", -1);
- addRow(".???l", "test.html", 4);
- addRow("?", "test.html", 0);
- addRow("?m", "test.html", 6);
- addRow("[*]", "test.html", -1);
- addRow("[?]","test.html", -1);
- addRow("[?]","test.h?ml", 6);
- addRow("[[]","test.h[ml", 6);
- addRow("[]]","test.h]ml", 6);
- addRow(".h[a-z]ml", "test.html", 4);
- addRow(".h[A-Z]ml", "test.html", -1);
- addRow(".h[A-Z]ml", "test.hTml", 4);
- addRow(".h[!A-Z]ml", "test.hTml", -1);
- addRow(".h[!A-Z]ml", "test.html", 4);
- addRow(".h[!T]ml", "test.hTml", -1);
- addRow(".h[!T]ml", "test.html", 4);
- addRow(".h[!T]m[!L]", "test.htmL", -1);
- addRow(".h[!T]m[!L]", "test.html", 4);
- addRow(".h[][!]", "test.h]ml", 4);
- addRow(".h[][!]", "test.h[ml", 4);
- addRow(".h[][!]", "test.h!ml", 4);
-
- addRow("foo/*/bar", "Qt/foo/baz/bar", 3);
- addRow("foo/(*)/bar", "Qt/foo/baz/bar", -1);
- addRow("foo/(*)/bar", "Qt/foo/(baz)/bar", 3);
- addRow("foo/?/bar", "Qt/foo/Q/bar", 3);
- addRow("foo/?/bar", "Qt/foo/Qt/bar", -1);
- addRow("foo/(?)/bar", "Qt/foo/Q/bar", -1);
- addRow("foo/(?)/bar", "Qt/foo/(Q)/bar", 3);
+ addRow("*.html", "test.html", 0);
+ addRow("*.h", "test.cpp", -1);
+ addRow("*.???l", "test.html", 0);
+ addRow("*?", "test.html", 0);
+ addRow("*?ml", "test.html", 0);
+ addRow("*[*]", "test.html", -1);
+ addRow("*[?]","test.html", -1);
+ addRow("*[?]ml","test.h?ml", 0);
+ addRow("*[[]ml","test.h[ml", 0);
+ addRow("*[]]ml","test.h]ml", 0);
+ addRow("*.h[a-z]ml", "test.html", 0);
+ addRow("*.h[A-Z]ml", "test.html", -1);
+ addRow("*.h[A-Z]ml", "test.hTml", 0);
+ addRow("*.h[!A-Z]ml", "test.hTml", -1);
+ addRow("*.h[!A-Z]ml", "test.html", 0);
+ addRow("*.h[!T]ml", "test.hTml", -1);
+ addRow("*.h[!T]ml", "test.html", 0);
+ addRow("*.h[!T]m[!L]", "test.htmL", -1);
+ addRow("*.h[!T]m[!L]", "test.html", 0);
+ addRow("*.h[][!]ml", "test.h]ml", 0);
+ addRow("*.h[][!]ml", "test.h[ml", 0);
+ addRow("*.h[][!]ml", "test.h!ml", 0);
+
+ addRow("foo/*/bar", "foo/baz/bar", 0);
+ addRow("foo/(*)/bar", "foo/baz/bar", -1);
+ addRow("foo/(*)/bar", "foo/(baz)/bar", 0);
+ addRow("foo/?/bar", "foo/Q/bar", 0);
+ addRow("foo/?/bar", "foo/Qt/bar", -1);
+ addRow("foo/(?)/bar", "foo/Q/bar", -1);
+ addRow("foo/(?)/bar", "foo/(Q)/bar", 0);
#ifdef Q_OS_WIN
- addRow("foo\\*\\bar", "Qt\\foo\\baz\\bar", 3);
- addRow("foo\\(*)\\bar", "Qt\\foo\\baz\\bar", -1);
- addRow("foo\\(*)\\bar", "Qt\\foo\\(baz)\\bar", 3);
- addRow("foo\\?\\bar", "Qt\\foo\\Q\\bar", 3);
- addRow("foo\\?\\bar", "Qt\\foo\\Qt\\bar", -1);
- addRow("foo\\(?)\\bar", "Qt\\foo\\Q\\bar", -1);
- addRow("foo\\(?)\\bar", "Qt\\foo\\(Q)\\bar", 3);
+ addRow("foo\\*\\bar", "foo\\baz\\bar", 0);
+ addRow("foo\\(*)\\bar", "foo\\baz\\bar", -1);
+ addRow("foo\\(*)\\bar", "foo\\(baz)\\bar", 0);
+ addRow("foo\\?\\bar", "foo\\Q\\bar", 0);
+ addRow("foo\\?\\bar", "foo\\Qt\\bar", -1);
+ addRow("foo\\(?)\\bar", "foo\\Q\\bar", -1);
+ addRow("foo\\(?)\\bar", "foo\\(Q)\\bar", 0);
#endif
}
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index 5ffd75f931..eded206d37 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -233,6 +233,7 @@ private slots:
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
void toWinHBITMAP_data();
void toWinHBITMAP();
+ void fromMonoHBITMAP();
#endif // Q_OS_WIN && !Q_OS_WINRT
private:
@@ -3635,6 +3636,19 @@ void tst_QImage::toWinHBITMAP()
DeleteDC(bitmapDc);
ReleaseDC(0, displayDc);
}
+
+void tst_QImage::fromMonoHBITMAP() // QTBUG-72343, corruption for mono bitmaps
+{
+ enum : int { width = 32, height = 32, size = width * height / 8 }; // 32x32 mono bitmap
+ char bitmapData[size];
+ memset(bitmapData, 0, size);
+ const HBITMAP hbitmap = CreateBitmap(width, height, /* planes */ 1, /* bitcount */ 1, bitmapData);
+ const QImage image = qt_imageFromWinHBITMAP(hbitmap);
+ QCOMPARE(image.size(), QSize(width, height));
+ QCOMPARE(image.scanLine(0)[0], 0u);
+ DeleteObject(hbitmap);
+}
+
#endif // Q_OS_WIN && !Q_OS_WINRT
QTEST_GUILESS_MAIN(tst_QImage)
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
index 9bf9e99bf9..bc0baed15c 100644
--- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
@@ -299,6 +299,8 @@ private slots:
void fillPolygon();
+ void drawImageAtPointF();
+
private:
void fillData();
void setPenColor(QPainter& p);
@@ -5292,6 +5294,20 @@ void tst_QPainter::fillPolygon()
}
}
+void tst_QPainter::drawImageAtPointF()
+{
+ // Just test we do not crash
+ QImage image1(10, 10, QImage::Format_RGB32);
+ QImage image2(200, 200, QImage::Format_RGB32);
+
+ QPainter paint(&image2);
+ paint.setClipRect(97, 46, 14, 14);
+ paint.setCompositionMode(QPainter::CompositionMode_Source);
+ paint.drawImage(QPointF(96, std::numeric_limits<int>::max()), image1);
+ paint.drawImage(QPointF(std::numeric_limits<int>::min(), 48), image1);
+ paint.end();
+}
+
QTEST_MAIN(tst_QPainter)
#include "tst_qpainter.moc"
diff --git a/tests/auto/gui/text/qfontmetrics/testfont.qrc b/tests/auto/gui/text/qfontmetrics/testfont.qrc
index bc0c0b0959..30b4a3f82e 100644
--- a/tests/auto/gui/text/qfontmetrics/testfont.qrc
+++ b/tests/auto/gui/text/qfontmetrics/testfont.qrc
@@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/fonts">
<file>ucs4font.ttf</file>
+ <file alias="testfont.ttf">../../../shared/resources/testfont.ttf</file>
</qresource>
</RCC>
diff --git a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp
index 9e705b4a00..a0e8525268 100644
--- a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp
+++ b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp
@@ -58,6 +58,7 @@ private slots:
void lineWidth();
void mnemonicTextWidth();
void leadingBelowLine();
+ void elidedMetrics();
};
void tst_QFontMetrics::same()
@@ -331,5 +332,31 @@ void tst_QFontMetrics::leadingBelowLine()
QCOMPARE(line.base(), line.ascent);
}
+void tst_QFontMetrics::elidedMetrics()
+{
+ QString testFont = QFINDTESTDATA("fonts/testfont.ttf");
+ QVERIFY(!testFont.isEmpty());
+
+ int id = QFontDatabase::addApplicationFont(testFont);
+ QVERIFY(id >= 0);
+
+ QFont font(QFontDatabase::applicationFontFamilies(id).at(0));
+ font.setPixelSize(12.0);
+
+ QFontMetricsF metrics(font);
+ QString s = QStringLiteral("VeryLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongText");
+
+ QRectF boundingRect = metrics.boundingRect(s);
+
+ QString elided = metrics.elidedText(s, Qt::ElideRight, boundingRect.width() / 2.0);
+
+ QRectF elidedBoundingRect = metrics.boundingRect(elided);
+
+ QCOMPARE(boundingRect.height(), elidedBoundingRect.height());
+ QCOMPARE(boundingRect.y(), elidedBoundingRect.y());
+
+ QFontDatabase::removeApplicationFont(id);
+}
+
QTEST_MAIN(tst_QFontMetrics)
#include "tst_qfontmetrics.moc"
diff --git a/tests/auto/tools/moc/cxx11-enums.h b/tests/auto/tools/moc/cxx11-enums.h
index 93ab16c157..cc14c0acda 100644
--- a/tests/auto/tools/moc/cxx11-enums.h
+++ b/tests/auto/tools/moc/cxx11-enums.h
@@ -40,13 +40,22 @@ public:
enum class TypedEnumClass : char { C0, C1, C2, C3 };
enum NormalEnum { D2 = 2, D3, D0 =0 , D1 };
enum class ClassFlag { F0 = 1, F1 = 2, F2 = 4, F3 = 8};
+
+ enum struct EnumStruct { G0, G1, G2, G3 };
+ enum struct TypedEnumStruct : char { H0, H1, H2, H3 };
+ enum struct StructFlag { I0 = 1, I1 = 2, I2 = 4, I3 = 8};
+
Q_DECLARE_FLAGS(ClassFlags, ClassFlag)
+ Q_DECLARE_FLAGS(StructFlags, StructFlag)
Q_ENUM(EnumClass)
Q_ENUM(TypedEnum)
Q_ENUM(TypedEnumClass)
Q_ENUM(NormalEnum)
+ Q_ENUM(EnumStruct)
+ Q_ENUM(TypedEnumStruct)
Q_FLAG(ClassFlags)
+ Q_FLAG(StructFlags)
};
// Also test the Q_ENUMS macro
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index 92a94055a4..293cbd8323 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -2266,6 +2266,9 @@ void tst_Moc::cxx11Enums_data()
QTest::newRow("NormalEnum 2") << meta2 << QByteArray("NormalEnum") << QByteArray("NormalEnum") << 'D' << false;
QTest::newRow("ClassFlags") << meta1 << QByteArray("ClassFlags") << QByteArray("ClassFlag") << 'F' << true;
QTest::newRow("ClassFlags 2") << meta2 << QByteArray("ClassFlags") << QByteArray("ClassFlag") << 'F' << true;
+ QTest::newRow("EnumStruct") << meta1 << QByteArray("EnumStruct") << QByteArray("EnumStruct") << 'G' << true;
+ QTest::newRow("TypedEnumStruct") << meta1 << QByteArray("TypedEnumStruct") << QByteArray("TypedEnumStruct") << 'H' << true;
+ QTest::newRow("StructFlags") << meta1 << QByteArray("StructFlags") << QByteArray("StructFlag") << 'I' << true;
}
void tst_Moc::cxx11Enums()
diff --git a/tests/auto/tools/qmakelib/qmakelib.pro b/tests/auto/tools/qmakelib/qmakelib.pro
index 140bece708..29f17f6a14 100644
--- a/tests/auto/tools/qmakelib/qmakelib.pro
+++ b/tests/auto/tools/qmakelib/qmakelib.pro
@@ -1,6 +1,7 @@
CONFIG += testcase
TARGET = tst_qmakelib
QT = core testlib
+win32: LIBS += -ladvapi32
INCLUDEPATH += ../../../../qmake/library
VPATH += ../../../../qmake/library
@@ -13,6 +14,7 @@ SOURCES += \
parsertest.cpp \
evaltest.cpp \
ioutils.cpp \
+ registry.cpp \
proitems.cpp \
qmakevfs.cpp \
qmakeparser.cpp \
diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
index 049468fd7c..76314564f1 100644
--- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
+++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
@@ -38,49 +38,6 @@
#include <qpa/qplatformtheme.h>
#include <private/qguiapplication_p.h>
-#define CONVENIENCE_FUNC_SYMS(func) \
- { \
- int x1 = QMessageBox::func(0, "Foo", "Bar"); \
- int x3 = QMessageBox::func(0, "Foo", "Bar", "Save"); \
- int x6 = QMessageBox::func(0, "Foo", "Bar", "Save", "Save As"); \
- int x7 = QMessageBox::func(0, "Foo", "Bar", "Save", "Save As", "Dont Save"); \
- int x8 = QMessageBox::func(0, "Foo", "Bar", "Save", "Save As", "Dont Save", 1); \
- int x9 = QMessageBox::func(0, "Foo", "Bar", "Save", "Save As", "Dont Save", 1, 2); \
- int x10 = QMessageBox::func(0, "Foo", "Bar", QMessageBox::YesAll, QMessageBox::Yes); \
- int x11 = QMessageBox::func(0, "Foo", "Bar", QMessageBox::YesAll, QMessageBox::Yes, \
- QMessageBox::No); \
- qDebug("%d %d %d %d %d %d %d %d", x1, x3, x6, x7, x8, x9, x10, x11); \
- { \
- int x4 = QMessageBox::func(0, "Foo", "Bar", (int)QMessageBox::Yes, (int)QMessageBox::No); \
- int x5 = QMessageBox::func(0, "Foo", "Bar", QMessageBox::Yes, (int)QMessageBox::No); \
- int x6 = QMessageBox::func(0, "Foo", "Bar", QMessageBox::Yes | QMessageBox::Default, (int)QMessageBox::No); \
- int x7 = QMessageBox::func(0, "Foo", "Bar", (int)QMessageBox::Yes, QMessageBox::No); \
- int x8 = QMessageBox::func(0, "Foo", "Bar", QMessageBox::Yes, QMessageBox::No); \
- int x9 = QMessageBox::func(0, "Foo", "Bar", QMessageBox::Yes | QMessageBox::Default, QMessageBox::No); \
- int x10 = QMessageBox::func(0, "Foo", "Bar", (int)QMessageBox::Yes, (int)QMessageBox::No, (int)QMessageBox::Ok); \
- int x11 = QMessageBox::func(0, "Foo", "Bar", QMessageBox::Yes, (int)QMessageBox::No, (int)QMessageBox::Ok); \
- int x12 = QMessageBox::func(0, "Foo", "Bar", QMessageBox::Yes | QMessageBox::Default, (int)QMessageBox::No, (int)QMessageBox::Ok); \
- int x13 = QMessageBox::func(0, "Foo", "Bar", (int)QMessageBox::Yes, QMessageBox::No, (int)QMessageBox::Ok); \
- int x14 = QMessageBox::func(0, "Foo", "Bar", QMessageBox::Yes, QMessageBox::No, (int)QMessageBox::Ok); \
- int x15 = QMessageBox::func(0, "Foo", "Bar", QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, (int)QMessageBox::Ok); \
- int x16 = QMessageBox::func(0, "Foo", "Bar", (int)QMessageBox::Yes, (int)QMessageBox::No, QMessageBox::Ok); \
- int x17 = QMessageBox::func(0, "Foo", "Bar", QMessageBox::Yes, (int)QMessageBox::No, QMessageBox::Ok); \
- int x18 = QMessageBox::func(0, "Foo", "Bar", QMessageBox::Yes | QMessageBox::Default, (int)QMessageBox::No, QMessageBox::Ok); \
- int x19 = QMessageBox::func(0, "Foo", "Bar", (int)QMessageBox::Yes, QMessageBox::No, QMessageBox::Ok); \
- int x20 = QMessageBox::func(0, "Foo", "Bar", QMessageBox::Yes, QMessageBox::No, QMessageBox::Ok); \
- int x21 = QMessageBox::func(0, "Foo", "Bar", QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Ok); \
- qDebug("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21); \
- } \
- }
-
-#define CONVENIENCE_FUNC_SYMS_EXTRA(func) \
- { \
- int x1 = QMessageBox::func(0, "Foo", "Bar", (int)QMessageBox::Yes); \
- int x2 = QMessageBox::func(0, "Foo", "Bar", QMessageBox::Yes); \
- int x3 = QMessageBox::func(0, "Foo", "Bar", QMessageBox::Yes | QMessageBox::Default); \
- qDebug("%d %d %d", x1, x2, x3); \
- }
-
class tst_QMessageBox : public QObject
{
Q_OBJECT
@@ -103,13 +60,16 @@ private slots:
void staticSourceCompat();
void instanceSourceCompat();
- void testSymbols();
void incorrectDefaultButton();
void updateSize();
void setInformativeText();
void iconPixmap();
+ // QTBUG-44131
+ void acceptedRejectedSignals();
+ void acceptedRejectedSignals_data();
+
void cleanup();
};
@@ -210,9 +170,9 @@ void tst_QMessageBox::button()
{
QMessageBox msgBox;
msgBox.addButton("retry", QMessageBox::DestructiveRole);
- QVERIFY(msgBox.button(QMessageBox::Ok) == 0); // not added yet
+ QVERIFY(msgBox.button(QMessageBox::Ok) == nullptr); // not added yet
QPushButton *b1 = msgBox.addButton(QMessageBox::Ok);
- QCOMPARE(msgBox.button(QMessageBox::Ok), (QAbstractButton *)b1); // just added
+ QCOMPARE(msgBox.button(QMessageBox::Ok), static_cast<QAbstractButton *>(b1)); // just added
QCOMPARE(msgBox.standardButton(b1), QMessageBox::Ok);
msgBox.addButton(QMessageBox::Cancel);
QCOMPARE(msgBox.standardButtons(), QMessageBox::Ok | QMessageBox::Cancel);
@@ -220,12 +180,12 @@ void tst_QMessageBox::button()
// remove the cancel, should not exist anymore
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
QVERIFY(!msgBox.button(QMessageBox::Cancel));
- QVERIFY(msgBox.button(QMessageBox::Yes) != 0);
+ QVERIFY(msgBox.button(QMessageBox::Yes) != nullptr);
// should not crash
QPushButton *b4 = new QPushButton;
msgBox.addButton(b4, QMessageBox::DestructiveRole);
- msgBox.addButton(0, QMessageBox::ActionRole);
+ msgBox.addButton(nullptr, QMessageBox::ActionRole);
}
void tst_QMessageBox::defaultButton()
@@ -237,7 +197,7 @@ void tst_QMessageBox::defaultButton()
QVERIFY(!msgBox.defaultButton());
QPushButton pushButton;
msgBox.setDefaultButton(&pushButton);
- QVERIFY(msgBox.defaultButton() == 0); // we have not added it yet
+ QVERIFY(msgBox.defaultButton() == nullptr); // we have not added it yet
QPushButton *retryButton = msgBox.addButton(QMessageBox::Retry);
msgBox.setDefaultButton(retryButton);
QCOMPARE(msgBox.defaultButton(), retryButton);
@@ -248,11 +208,11 @@ void tst_QMessageBox::defaultButton()
closeHelper.start(Qt::Key_Enter, &msgBox);
msgBox.exec();
- QCOMPARE(msgBox.clickedButton(), (QAbstractButton *)retryButton);
+ QCOMPARE(msgBox.clickedButton(), static_cast<QAbstractButton *>(retryButton));
QAbstractButton *okButton = msgBox.button(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
- QCOMPARE(msgBox.defaultButton(), (QPushButton *)okButton);
+ QCOMPARE(msgBox.defaultButton(), static_cast<QPushButton *>(okButton));
closeHelper.start(Qt::Key_Enter, &msgBox);
msgBox.exec();
QCOMPARE(msgBox.clickedButton(), okButton);
@@ -260,7 +220,7 @@ void tst_QMessageBox::defaultButton()
QCOMPARE(msgBox.defaultButton(), okButton);
msgBox.removeButton(okButton);
delete okButton;
- okButton = 0;
+ okButton = nullptr;
QVERIFY(!msgBox.defaultButton());
msgBox.setDefaultButton(QMessageBox::Ok);
QVERIFY(!msgBox.defaultButton());
@@ -287,7 +247,7 @@ void tst_QMessageBox::escapeButton()
QVERIFY(msgBox.clickedButton() == msgBox.button(QMessageBox::Cancel)); // auto detected (cancel)
msgBox.setEscapeButton(retryButton);
- QCOMPARE(msgBox.escapeButton(), (QAbstractButton *)retryButton);
+ QCOMPARE(msgBox.escapeButton(), static_cast<QAbstractButton *>(retryButton));
// with escape
closeHelper.start(Qt::Key_Escape, &msgBox);
@@ -297,7 +257,7 @@ void tst_QMessageBox::escapeButton()
// with close
closeHelper.start(ExecCloseHelper::CloseWindow, &msgBox);
msgBox.exec();
- QCOMPARE(msgBox.clickedButton(), (QAbstractButton *)retryButton);
+ QCOMPARE(msgBox.clickedButton(), static_cast<QAbstractButton *>(retryButton));
QAbstractButton *okButton = msgBox.button(QMessageBox::Ok);
msgBox.setEscapeButton(QMessageBox::Ok);
@@ -309,7 +269,7 @@ void tst_QMessageBox::escapeButton()
QCOMPARE(msgBox.escapeButton(), okButton);
msgBox.removeButton(okButton);
delete okButton;
- okButton = 0;
+ okButton = nullptr;
QVERIFY(!msgBox.escapeButton());
msgBox.setEscapeButton(QMessageBox::Ok);
QVERIFY(!msgBox.escapeButton());
@@ -353,28 +313,28 @@ void tst_QMessageBox::statics()
ExecCloseHelper closeHelper;
for (int i = 0; i < 4; i++) {
closeHelper.start(Qt::Key_Escape);
- QMessageBox::StandardButton sb = (*statics[i])(0, "caption",
+ QMessageBox::StandardButton sb = (*statics[i])(nullptr, "caption",
"text", QMessageBox::Yes | QMessageBox::No | QMessageBox::Help | QMessageBox::Cancel,
QMessageBox::NoButton);
QCOMPARE(sb, QMessageBox::Cancel);
QVERIFY(closeHelper.done());
closeHelper.start(ExecCloseHelper::CloseWindow);
- sb = (*statics[i])(0, "caption",
+ sb = (*statics[i])(nullptr, "caption",
"text", QMessageBox::Yes | QMessageBox::No | QMessageBox::Help | QMessageBox::Cancel,
QMessageBox::NoButton);
QCOMPARE(sb, QMessageBox::Cancel);
QVERIFY(closeHelper.done());
closeHelper.start(Qt::Key_Enter);
- sb = (*statics[i])(0, "caption",
+ sb = (*statics[i])(nullptr, "caption",
"text", QMessageBox::Yes | QMessageBox::No | QMessageBox::Help,
QMessageBox::Yes);
QCOMPARE(sb, QMessageBox::Yes);
QVERIFY(closeHelper.done());
closeHelper.start(Qt::Key_Enter);
- sb = (*statics[i])(0, "caption",
+ sb = (*statics[i])(nullptr, "caption",
"text", QMessageBox::Yes | QMessageBox::No | QMessageBox::Help,
QMessageBox::No);
QCOMPARE(sb, QMessageBox::No);
@@ -400,7 +360,7 @@ void tst_QMessageBox::about()
{
ExecCloseHelper closeHelper;
closeHelper.start(Qt::Key_Escape);
- QMessageBox::about(0, "Caption", "This is an auto test");
+ QMessageBox::about(nullptr, "Caption", "This is an auto test");
// On Mac, about and aboutQt are not modal, so we need to
// explicitly run the event loop
#ifdef Q_OS_MAC
@@ -412,7 +372,7 @@ void tst_QMessageBox::about()
const int keyToSend = Qt::Key_Enter;
closeHelper.start(keyToSend);
- QMessageBox::aboutQt(0, "Caption");
+ QMessageBox::aboutQt(nullptr, "Caption");
#ifdef Q_OS_MAC
QTRY_VERIFY(closeHelper.done());
#else
@@ -427,7 +387,7 @@ void tst_QMessageBox::staticSourceCompat()
// source compat tests for < 4.2
ExecCloseHelper closeHelper;
closeHelper.start(Qt::Key_Enter);
- ret = QMessageBox::information(0, "title", "text", QMessageBox::Yes, QMessageBox::No);
+ ret = QMessageBox::information(nullptr, "title", "text", QMessageBox::Yes, QMessageBox::No);
int expectedButton = int(QMessageBox::Yes);
if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
const int dialogButtonBoxLayout = theme->themeHint(QPlatformTheme::DialogButtonBoxLayout).toInt();
@@ -439,39 +399,39 @@ void tst_QMessageBox::staticSourceCompat()
QVERIFY(closeHelper.done());
closeHelper.start(Qt::Key_Enter);
- ret = QMessageBox::information(0, "title", "text", QMessageBox::Yes | QMessageBox::Default, QMessageBox::No);
+ ret = QMessageBox::information(nullptr, "title", "text", QMessageBox::Yes | QMessageBox::Default, QMessageBox::No);
QCOMPARE(ret, int(QMessageBox::Yes));
QVERIFY(closeHelper.done());
closeHelper.start(Qt::Key_Enter);
- ret = QMessageBox::information(0, "title", "text", QMessageBox::Yes, QMessageBox::No | QMessageBox::Default);
+ ret = QMessageBox::information(nullptr, "title", "text", QMessageBox::Yes, QMessageBox::No | QMessageBox::Default);
QCOMPARE(ret, int(QMessageBox::No));
QVERIFY(closeHelper.done());
closeHelper.start(Qt::Key_Enter);
- ret = QMessageBox::information(0, "title", "text", QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape);
+ ret = QMessageBox::information(nullptr, "title", "text", QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape);
QCOMPARE(ret, int(QMessageBox::Yes));
QVERIFY(closeHelper.done());
closeHelper.start(Qt::Key_Enter);
- ret = QMessageBox::information(0, "title", "text", QMessageBox::Yes | QMessageBox::Escape, QMessageBox::No | QMessageBox::Default);
+ ret = QMessageBox::information(nullptr, "title", "text", QMessageBox::Yes | QMessageBox::Escape, QMessageBox::No | QMessageBox::Default);
QCOMPARE(ret, int(QMessageBox::No));
QVERIFY(closeHelper.done());
// the button text versions
closeHelper.start(Qt::Key_Enter);
- ret = QMessageBox::information(0, "title", "text", "Yes", "No", QString(), 1);
+ ret = QMessageBox::information(nullptr, "title", "text", "Yes", "No", QString(), 1);
QCOMPARE(ret, 1);
QVERIFY(closeHelper.done());
if (0) { // don't run these tests since the dialog won't close!
closeHelper.start(Qt::Key_Escape);
- ret = QMessageBox::information(0, "title", "text", "Yes", "No", QString(), 1);
+ ret = QMessageBox::information(nullptr, "title", "text", "Yes", "No", QString(), 1);
QCOMPARE(ret, -1);
QVERIFY(closeHelper.done());
closeHelper.start(Qt::Key_Escape);
- ret = QMessageBox::information(0, "title", "text", "Yes", "No", QString(), 0, 1);
+ ret = QMessageBox::information(nullptr, "title", "text", "Yes", "No", QString(), 0, 1);
QCOMPARE(ret, 1);
QVERIFY(closeHelper.done());
}
@@ -505,96 +465,6 @@ void tst_QMessageBox::instanceSourceCompat()
#endif
}
-void tst_QMessageBox::testSymbols()
-{
- return;
-
- QMessageBox::Icon icon;
- icon = QMessageBox::NoIcon;
- icon = QMessageBox::Information;
- icon = QMessageBox::Warning;
- icon = QMessageBox::Critical;
- icon = QMessageBox::Question;
-
- QMessageBox mb1;
- QMessageBox mb2(0);
- QMessageBox mb3(&mb1);
- QMessageBox mb3b("title", "text", QMessageBox::Critical, int(QMessageBox::Yes),
- int(QMessageBox::No), int(QMessageBox::Cancel), &mb1, Qt::Dialog);
-
- QMessageBox::Button button = QMessageBox::NoButton;
- button = QMessageBox::Ok;
- button = QMessageBox::Cancel;
- button = QMessageBox::Yes;
- button = QMessageBox::No;
- button = QMessageBox::Abort;
- button = QMessageBox::Retry;
- button = QMessageBox::Ignore;
- button = QMessageBox::YesAll;
- button = QMessageBox::NoAll;
- button = QMessageBox::ButtonMask;
- button = QMessageBox::Default;
- button = QMessageBox::Escape;
- button = QMessageBox::FlagMask;
- QVERIFY(button);
-
- const QString text = QStringLiteral("Foo");
- mb1.setText(text);
- QCOMPARE(mb1.text(), text);
-
- icon = mb1.icon();
- QCOMPARE(icon, QMessageBox::NoIcon);
- mb1.setIcon(QMessageBox::Question);
- QCOMPARE(mb1.icon(), QMessageBox::Question);
-
- QPixmap iconPixmap = mb1.iconPixmap();
- mb1.setIconPixmap(iconPixmap);
- QCOMPARE(mb1.icon(), QMessageBox::NoIcon);
-
- QCOMPARE(mb1.buttonText(QMessageBox::Ok), QLatin1String("OK"));
- QCOMPARE(mb1.buttonText(QMessageBox::Cancel), QString());
- QCOMPARE(mb1.buttonText(QMessageBox::Ok | QMessageBox::Default), QString());
-
- const QString button1 = QStringLiteral("Bar");
- mb2.setButtonText(QMessageBox::Cancel, QStringLiteral("Foo"));
- mb2.setButtonText(QMessageBox::Ok, button1);
- mb2.setButtonText(QMessageBox::Ok | QMessageBox::Default, QStringLiteral("Baz"));
-
- QCOMPARE(mb2.buttonText(QMessageBox::Cancel), QString());
- QCOMPARE(mb2.buttonText(QMessageBox::Ok), button1);
-
- QVERIFY(mb3b.buttonText(QMessageBox::Yes).endsWith("Yes"));
- QCOMPARE(mb3b.buttonText(QMessageBox::YesAll), QString());
- QCOMPARE(mb3b.buttonText(QMessageBox::Ok), QString());
-
- const QString button2 = QStringLiteral("Blah");
- mb3b.setButtonText(QMessageBox::Yes, button2);
- mb3b.setButtonText(QMessageBox::YesAll, QStringLiteral("Zoo"));
- mb3b.setButtonText(QMessageBox::Ok, QStringLiteral("Zoo"));
-
- QCOMPARE(mb3b.buttonText(QMessageBox::Yes), button2);
- QCOMPARE(mb3b.buttonText(QMessageBox::YesAll), QString());
- QCOMPARE(mb3b.buttonText(QMessageBox::Ok), QString());
-
- QCOMPARE(mb1.textFormat(), Qt::AutoText);
- mb1.setTextFormat(Qt::PlainText);
- QCOMPARE(mb1.textFormat(), Qt::PlainText);
-
- CONVENIENCE_FUNC_SYMS(information);
- CONVENIENCE_FUNC_SYMS_EXTRA(information);
- CONVENIENCE_FUNC_SYMS(question);
- CONVENIENCE_FUNC_SYMS_EXTRA(question);
- CONVENIENCE_FUNC_SYMS(warning);
- CONVENIENCE_FUNC_SYMS(critical);
-
- QSize sizeHint = mb1.sizeHint();
- QVERIFY(sizeHint.width() > 20 && sizeHint.height() > 20);
-
- QMessageBox::about(&mb1, "title", "text");
- QMessageBox::aboutQt(&mb1);
- QMessageBox::aboutQt(&mb1, "title");
-}
-
void tst_QMessageBox::detailsText()
{
QMessageBox box;
@@ -618,9 +488,8 @@ void tst_QMessageBox::detailsButtonText()
QDialogButtonBox* bb = box.findChild<QDialogButtonBox*>("qt_msgbox_buttonbox");
QVERIFY(bb); //get the detail button
- QList<QAbstractButton *> list = bb->buttons();
- QAbstractButton* btn = NULL;
- foreach(btn, list) {
+ auto list = bb->buttons();
+ for (auto btn : list) {
if (btn && (btn->inherits("QPushButton"))) {
if (btn->text().remove(QLatin1Char('&')) != QMessageBox::tr("OK")
&& btn->text() != QMessageBox::tr("Show Details...")) {
@@ -640,12 +509,12 @@ void tst_QMessageBox::expandDetails_QTBUG_32473()
QDialogButtonBox* bb = box.findChild<QDialogButtonBox*>("qt_msgbox_buttonbox");
QVERIFY(bb);
- QList<QAbstractButton *> list = bb->buttons();
- QAbstractButton* moreButton = NULL;
- foreach (QAbstractButton* btn, list)
- if (btn && bb->buttonRole(btn) == QDialogButtonBox::ActionRole)
- moreButton = btn;
- QVERIFY(moreButton);
+ auto list = bb->buttons();
+ auto it = std::find_if(list.rbegin(), list.rend(), [&](QAbstractButton *btn) {
+ return btn && bb->buttonRole(btn) == QDialogButtonBox::ActionRole; });
+ QVERIFY(it != list.rend());
+ auto moreButton = *it;
+
QVERIFY(QTest::qWaitForWindowExposed(&box));
QRect geom = box.geometry();
box.resized = false;
@@ -667,19 +536,19 @@ void tst_QMessageBox::incorrectDefaultButton()
closeHelper.start(Qt::Key_Escape);
//Do not crash here
QTest::ignoreMessage(QtWarningMsg, "QDialogButtonBox::createButton: Invalid ButtonRole, button not added");
- QMessageBox::question( 0, "", "I've been hit!",QMessageBox::Ok | QMessageBox::Cancel,QMessageBox::Save );
+ QMessageBox::question(nullptr, "", "I've been hit!",QMessageBox::Ok | QMessageBox::Cancel,QMessageBox::Save);
QVERIFY(closeHelper.done());
closeHelper.start(Qt::Key_Escape);
QTest::ignoreMessage(QtWarningMsg, "QDialogButtonBox::createButton: Invalid ButtonRole, button not added");
- QMessageBox::question( 0, "", "I've been hit!",QFlag(QMessageBox::Ok | QMessageBox::Cancel),QMessageBox::Save );
+ QMessageBox::question(nullptr, "", "I've been hit!",QFlag(QMessageBox::Ok | QMessageBox::Cancel),QMessageBox::Save);
QVERIFY(closeHelper.done());
closeHelper.start(Qt::Key_Escape);
QTest::ignoreMessage(QtWarningMsg, "QDialogButtonBox::createButton: Invalid ButtonRole, button not added");
QTest::ignoreMessage(QtWarningMsg, "QDialogButtonBox::createButton: Invalid ButtonRole, button not added");
//do not crash here -> call old function of QMessageBox in this case
- QMessageBox::question( 0, "", "I've been hit!",QMessageBox::Ok | QMessageBox::Cancel,QMessageBox::Save | QMessageBox::Cancel,QMessageBox::Ok);
+ QMessageBox::question(nullptr, "", "I've been hit!",QMessageBox::Ok | QMessageBox::Cancel,QMessageBox::Save | QMessageBox::Cancel,QMessageBox::Ok);
QVERIFY(closeHelper.done());
}
@@ -718,5 +587,96 @@ void tst_QMessageBox::iconPixmap()
QCOMPARE(messageBox.iconPixmap(), QPixmap());
}
+using SignalSignature = void(QDialog::*)();
+Q_DECLARE_METATYPE(SignalSignature);
+Q_DECLARE_METATYPE(QMessageBox::ButtonRole)
+
+using ButtonsCreator = std::function<QVector<QPushButton*>(QMessageBox &)>;
+Q_DECLARE_METATYPE(ButtonsCreator);
+
+using RoleSet = QSet<QMessageBox::ButtonRole>;
+Q_DECLARE_METATYPE(RoleSet);
+
+void tst_QMessageBox::acceptedRejectedSignals()
+{
+ QMessageBox messageBox(QMessageBox::Information, "Test window", "Test text");
+
+ QFETCH(ButtonsCreator, buttonsCreator);
+ QVERIFY(buttonsCreator);
+
+ const auto buttons = buttonsCreator(messageBox);
+ QVERIFY(!buttons.isEmpty());
+
+ QFETCH(RoleSet, roles);
+ QFETCH(SignalSignature, signalSignature);
+ for (auto button: buttons) {
+ QVERIFY(button);
+
+ messageBox.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&messageBox));
+
+ QSignalSpy spy(&messageBox, signalSignature);
+ QVERIFY(spy.isValid());
+ button->click();
+
+ if (roles.contains(messageBox.buttonRole(button)))
+ QCOMPARE(spy.count(), 1);
+ else
+ QVERIFY(spy.isEmpty());
+ }
+}
+
+static void addAcceptedRow(const char *title, ButtonsCreator bc)
+{
+ QTest::newRow(title) << (RoleSet() << QMessageBox::AcceptRole << QMessageBox::YesRole)
+ << &QDialog::accepted << bc;
+}
+
+static void addRejectedRow(const char *title, ButtonsCreator bc)
+{
+ QTest::newRow(title) << (RoleSet() << QMessageBox::RejectRole << QMessageBox::NoRole)
+ << &QDialog::rejected << bc;
+}
+
+static void addCustomButtonsData()
+{
+ ButtonsCreator buttonsCreator = [](QMessageBox &messageBox) {
+ QVector<QPushButton*> buttons(QMessageBox::NRoles);
+ for (int i = QMessageBox::AcceptRole; i < QMessageBox::NRoles; ++i) {
+ buttons[i] = messageBox.addButton(
+ QString("Button role: %1").arg(i), QMessageBox::ButtonRole(i));
+ }
+
+ return buttons;
+ };
+
+ addAcceptedRow("Accepted_CustomButtons", buttonsCreator);
+ addRejectedRow("Rejected_CustomButtons", buttonsCreator);
+}
+
+static void addStandardButtonsData()
+{
+ ButtonsCreator buttonsCreator = [](QMessageBox &messageBox) {
+ QVector<QPushButton*> buttons;
+ for (int i = QMessageBox::FirstButton; i <= QMessageBox::LastButton; i <<= 1)
+ buttons << messageBox.addButton(QMessageBox::StandardButton(i));
+
+ return buttons;
+ };
+
+ addAcceptedRow("Accepted_StandardButtons", buttonsCreator);
+ addRejectedRow("Rejected_StandardButtons", buttonsCreator);
+}
+
+void tst_QMessageBox::acceptedRejectedSignals_data()
+{
+ QTest::addColumn<RoleSet>("roles");
+ QTest::addColumn<SignalSignature>("signalSignature");
+ QTest::addColumn<ButtonsCreator>("buttonsCreator");
+
+ addStandardButtonsData();
+ addCustomButtonsData();
+}
+
QTEST_MAIN(tst_QMessageBox)
#include "tst_qmessagebox.moc"
diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
index ab746dfee8..1b95b5a3ca 100644
--- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
@@ -1264,19 +1264,47 @@ void tst_QTableView::moveCursorStrikesBack_data()
for (int i = 0; i < 7; ++i)
fullList << i;
- QTest::newRow("All disabled, wrap forward. Timeout => FAIL") << -1 << -1
+ QTest::newRow("All disabled, wrap forward. => invalid index") << -1 << -1
<< fullList
<< fullList
<< QRect()
<< 1 << 0 << (IntList() << int(QtTestTableView::MoveNext))
- << 1 << 0;
+ << -1 << -1;
- QTest::newRow("All disabled, wrap backwards. Timeout => FAIL") << -1 << -1
+ QTest::newRow("All disabled, wrap backwards. => invalid index") << -1 << -1
<< fullList
<< fullList
<< QRect()
<< 1 << 0 << (IntList() << int(QtTestTableView::MovePrevious))
+ << -1 << -1;
+
+ QTest::newRow("Last column disabled, MoveEnd. QTBUG-72400") << -1 << -1
+ << IntList()
+ << (IntList() << 6)
+ << QRect()
+ << 0 << 0 << (IntList() << int(QtTestTableView::MoveEnd))
+ << 0 << 5;
+
+ QTest::newRow("First column disabled, MoveHome. QTBUG-72400") << -1 << -1
+ << IntList()
+ << (IntList() << 0)
+ << QRect()
+ << 0 << 6 << (IntList() << int(QtTestTableView::MoveHome))
+ << 0 << 1;
+
+ QTest::newRow("First row disabled, MovePageUp. QTBUG-72400") << -1 << -1
+ << (IntList() << 0)
+ << IntList()
+ << QRect()
+ << 2 << 0 << (IntList() << int(QtTestTableView::MovePageUp))
<< 1 << 0;
+
+ QTest::newRow("Last row disabled, MovePageDown. QTBUG-72400") << -1 << -1
+ << (IntList() << 6)
+ << IntList()
+ << QRect()
+ << 4 << 0 << (IntList() << int(QtTestTableView::MovePageDown))
+ << 5 << 0;
}
void tst_QTableView::moveCursorStrikesBack()
@@ -1302,6 +1330,9 @@ void tst_QTableView::moveCursorStrikesBack()
if (span.height() && span.width())
view.setSpan(span.top(), span.left(), span.height(), span.width());
view.show();
+ QVERIFY(QTest::qWaitForWindowActive(&view));
+ // resize to make sure there are scrollbars
+ view.resize(view.columnWidth(0) * 7, view.rowHeight(0) * 7);
QModelIndex index = model.index(startRow, startColumn);
view.setCurrentIndex(index);
@@ -1320,9 +1351,6 @@ void tst_QTableView::moveCursorStrikesBack()
newColumn = newIndex.column();
}
- // expected fails, task 119433
- if(newRow == -1)
- return;
QCOMPARE(newRow, expectedRow);
QCOMPARE(newColumn, expectedColumn);
}
diff --git a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp
index 70ae453896..1a0d7a9289 100644
--- a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp
+++ b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp
@@ -467,160 +467,1001 @@ void tst_QAbstractSlider::keyPressed_data()
QTest::addColumn<int>("maximum");
QTest::addColumn<int>("stepSize");
QTest::addColumn<int>("pageSize");
+ QTest::addColumn<bool>("invertedAppearance");
+ QTest::addColumn<bool>("invertedControls");
QTest::addColumn<QList<Qt::Key> >("keySequence");
- QTest::addColumn<int>("expectedSliderPositionHorizontal");
- QTest::addColumn<int>("expectedSliderPositionVertical");
- QTest::addColumn<int>("expectedSliderPositionHorizontalInverted"); // :)
- QTest::addColumn<int>("expectedSliderPositionVerticalInverted");
-
+ QTest::addColumn<int>("expectedSliderPosition");
QList<Qt::Key> list;
-
list << Qt::Key_Down;
- QTest::newRow("Step down once 1") << 10 // initial position
- << 0 // minimum
- << 100 // maximum
- << 3 // single step size
- << 0 // page step size
- << list // key sequence
- << 7 // result in case of horizontal slider
- << 7 // result in case of vertical slider
- << 13 // result in case of inverted horiz. slider
- << 13; // result in case of inverted vertical slider
+ QTest::newRow("Step down once 1, horizontal")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << false// inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 7; // expected position
+
+ QTest::newRow("Step down once 1, horizontal, appearance inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << true // inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 7; // expected position
+
+ QTest::newRow("Step down once 1, horizontal, controls inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << false// inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 13; // expected position
+
+ QTest::newRow("Step down once 1, horizontal, both inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << true // inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 13; // expected position
+
+ QTest::newRow("Step down once 1, vertical")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << false// inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 7; // expected position
+
+ QTest::newRow("Step down once 1, vertical, appearance inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << true // inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 7; // expected position
+
+ QTest::newRow("Step down once 1, vertical, controls inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << false// inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 13; // expected position
+
+ QTest::newRow("Step down once 1, vertical, both inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << true // inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 13; // expected position
list = QList<Qt::Key>();
list << Qt::Key_Up;
- QTest::newRow("Step down once 2") << 10 // initial position
- << 0 // minimum
- << 100 // maximum
- << 3 // single step size
- << 0 // page step size
- << list // key sequence
- << 13 // result in case of horizontal slider
- << 13 // result in case of vertical slider
- << 7 // result in case of inverted horiz. slider
- << 7; // result in case of inverted vertical slider
-
+ QTest::newRow("Step up once 2, horizontal")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << false// inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 13; // expected position
+
+ QTest::newRow("Step up once 2, horizontal, appearance inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << true // inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 13; // expected position
+
+ QTest::newRow("Step up once 2, horizontal, controls inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << false// inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 7; // expected position
+
+ QTest::newRow("Step up once 2, horizontal, both inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << true // inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 7; // expected position
+
+ QTest::newRow("Step up once 2, vertical")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << false// inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 13; // expected position
+
+ QTest::newRow("Step up once 2, vertical, appearance inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << true // inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 13; // expected position
+
+ QTest::newRow("Step up once 2, vertical, controls inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << false// inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 7; // expected position
+
+ QTest::newRow("Step up once 2, vertical, both inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << true // inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 7; // expected position
list = QList<Qt::Key>();
list << Qt::Key_Left;
- QTest::newRow("Step left once") << 10 // initial position
- << 0 // minimum
- << 100 // maximum
- << 3 // single step size
- << 0 // page step size
- << list // key sequence
- << 7 // result in case of horizontal slider
- << 7 // result in case of vertical slider
- << 13 // result in case of inverted horiz. slider
- << 13; // result in case of inverted vertical slider
+ QTest::newRow("Step left once 2, horizontal")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << false// inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 7; // expected position
+
+ QTest::newRow("Step left once 2, horizontal, appearance inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << true // inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 7; // expected position
+
+ QTest::newRow("Step left once 2, horizontal, controls inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << false// inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 13; // expected position
+
+ QTest::newRow("Step left once 2, horizontal, both inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << true // inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 13; // expected position
+
+ QTest::newRow("Step left once 2, vertical")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << false// inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 7; // expected position
+
+ QTest::newRow("Step left once 2, vertical, appearance inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << true // inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 7; // expected position
+
+ QTest::newRow("Step left once 2, vertical, controls inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << false// inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 13; // expected position
+
+ QTest::newRow("Step left once 2, vertical, both inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << true // inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 13; // expected position
list = QList<Qt::Key>();
list << Qt::Key_Right;
- QTest::newRow("Step right once") << 10 // initial position
- << 0 // minimum
- << 100 // maximum
- << 3 // single step size
- << 0 // page step size
- << list // key sequence
- << 13 // result in case of horizontal slider
- << 13 // result in case of vertical slider
- << 7 // result in case of inverted horiz. slider
- << 7; // result in case of inverted vertical slider
+ QTest::newRow("Step right once 2, horizontal")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << false// inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 13; // expected position
+
+ QTest::newRow("Step right once 2, horizontal, appearance inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << true // inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 13; // expected position
+
+ QTest::newRow("Step right once 2, horizontal, controls inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << false// inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 7; // expected position
+
+ QTest::newRow("Step right once 2, horizontal, both inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << true // inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 7; // expected position
+
+ QTest::newRow("Step right once 2, vertical")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << false// inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 13; // expected position
+
+ QTest::newRow("Step right once 2, vertical, appearance inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << true // inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 13; // expected position
+
+ QTest::newRow("Step right once 2, vertical, controls inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << false// inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 7; // expected position
+
+ QTest::newRow("Step right once 2, vertical, both inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << true // inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 7; // expected position
list = QList<Qt::Key>();
list << Qt::Key_PageDown;
- QTest::newRow("Page down once") << 10 // initial position
- << 0 // minimum
- << 100 // maximum
- << 0 // single step size
- << 3 // page step size
- << list // key sequence
- << 7 // result in case of horizontal slider
- << 7 // result in case of vertical slider
- << 13 // result in case of inverted horiz. slider
- << 13; // result in case of inverted vertical slider
+ QTest::newRow("Page down once, horizontal")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 7; // expected position
+
+ QTest::newRow("Page down once, horizontal, appearance inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 7; // expected position
+
+ QTest::newRow("Page down once, horizontal, controls inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 13; // expected position
+
+ QTest::newRow("Page down once, horizontal, both inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 13; // expected position
+
+ QTest::newRow("Page down once, vertical")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 7; // expected position
+
+ QTest::newRow("Page down once, vertical, appearance inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 7; // expected position
+
+ QTest::newRow("Page down once, vertical, controls inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 13; // expected position
+
+ QTest::newRow("Page down once, vertical, both inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 13; // expected position
list = QList<Qt::Key>();
list << Qt::Key_PageUp;
- QTest::newRow("Page up once") << 10 // initial position
- << 0 // minimum
- << 100 // maximum
- << 0 // single step size
- << 3 // page step size
- << list // key sequence
- << 13 // result in case of horizontal slider
- << 13 // result in case of vertical slider
- << 7 // result in case of inverted horiz. slider
- << 7; // result in case of inverted vertical slider
+ QTest::newRow("Page up once, horizontal")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 13; // expected position
+
+ QTest::newRow("Page up once, horizontal, appearance inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 13; // expected position
+
+ QTest::newRow("Page up once, horizontal, controls inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 7; // expected position
+
+ QTest::newRow("Page up once, horizontal, both inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 7; // expected position
+
+ QTest::newRow("Page up once, vertical")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 13; // expected position
+
+ QTest::newRow("Page up once, vertical, appearance inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 13; // expected position
+
+ QTest::newRow("Page up once, vertical, controls inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 7; // expected position
+
+ QTest::newRow("Page up once, vertical, both inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 7; // expected position
list = QList<Qt::Key>();
list << Qt::Key_Up << Qt::Key_Up << Qt::Key_PageDown << Qt::Key_PageDown << Qt::Key_Left << Qt::Key_Left
<< Qt::Key_Right << Qt::Key_Down << Qt::Key_PageUp << Qt::Key_PageUp << Qt::Key_Down << Qt::Key_Right;
- QTest::newRow("Symmetric seq") << 50 // initial position
- << 0 // minimum
- << 100 // maximum
- << 3 // single step size
- << 3 // page step size
- << list // key sequence
- << 50 // result in case of horizontal slider
- << 50 // result in case of vertical slider
- << 50 // result in case of inverted horiz. slider
- << 50; // result in case of inverted vertical slider
-
+ QTest::newRow("Symmetric seq, horizontal")
+ << 50 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 50; // expected position
+
+ QTest::newRow("Symmetric seq, horizontal, appearance inverted")
+ << 50 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 50; // expected position
+
+ QTest::newRow("Symmetric seq, horizontal, controls inverted")
+ << 50 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 50; // expected position
+
+ QTest::newRow("Symmetric seq, horizontal, both inverted")
+ << 50 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 50; // expected position
+
+ QTest::newRow("Symmetric seq, vertical")
+ << 50 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 50; // expected position
+
+ QTest::newRow("Symmetric seq, vertical, appearance inverted")
+ << 50 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 50; // expected position
+
+ QTest::newRow("Symmetric seq, vertical, controls inverted")
+ << 50 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 50; // expected position
+
+ QTest::newRow("Symmetric seq, vertical, both inverted")
+ << 50 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 50; // expected position
list = QList<Qt::Key>();
list << Qt::Key_Home;
- QTest::newRow("Home") << 10 // initial position
- << 0 // minimum
- << 100 // maximum
- << 0 // single step size
- << 3 // page step size
- << list // key sequence
- << 0 // result in case of horizontal slider
- << 0 // result in case of vertical slider
- << 0 // result in case of inverted horiz. slider
- << 0; // result in case of inverted vertical slider
+ QTest::newRow("Home, horizontal")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 0; // expected position
+
+ QTest::newRow("Home, horizontal, appearance inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 0; // expected position
+
+ QTest::newRow("Home, horizontal, controls inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 0; // expected position
+
+ QTest::newRow("Home, horizontal, both inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 0; // expected position
+
+ QTest::newRow("Home, vertical")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 0; // expected position
+
+ QTest::newRow("Home, vertical, appearance inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 0; // expected position
+
+ QTest::newRow("Home, vertical, controls inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 0; // expected position
+
+ QTest::newRow("Home, vertical, both inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 0; // expected position
list = QList<Qt::Key>();
list << Qt::Key_End;
- QTest::newRow("End") << 10 // initial position
- << 0 // minimum
- << 100 // maximum
- << 0 // single step size
- << 3 // page step size
- << list // key sequence
- << 100 // result in case of horizontal slider
- << 100 // result in case of vertical slider
- << 100 // result in case of inverted horiz. slider
- << 100; // result in case of inverted vertical slider
+ QTest::newRow("End, horizontal")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 100; // expected position
+
+ QTest::newRow("End, horizontal, appearance inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 100; // expected position
+
+ QTest::newRow("End, horizontal, controls inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 100; // expected position
+
+ QTest::newRow("End, horizontal, both inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 100; // expected position
+
+ QTest::newRow("End, vertical")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 100; // expected position
+
+ QTest::newRow("End, vertical, appearance inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 100; // expected position
+
+ QTest::newRow("End, vertical, controls inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 100; // expected position
+
+ QTest::newRow("End, vertical, both inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 100; // expected position
list = QList<Qt::Key>();
list << Qt::Key_End << Qt::Key_Up;
- QTest::newRow("Past end")<< 10 // initial position
- << 0 // minimum
- << 100 // maximum
- << 3 // single step size
- << 3 // page step size
- << list // key sequence
- << 100 // result in case of horizontal slider
- << 100 // result in case of vertical slider
- << 97 // result in case of inverted horiz. slider
- << 97; // result in case of inverted vertical slider
+ QTest::newRow("Past end, horizontal")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 100; // expected position
+
+ QTest::newRow("Past end, horizontal, appearance inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 100; // expected position
+
+ QTest::newRow("Past end, horizontal, controls inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 97; // expected position
+
+ QTest::newRow("Past end, horizontal, both inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 97; // expected position
+
+ QTest::newRow("Past end, vertical")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 100; // expected position
+
+ QTest::newRow("Past end, vertical, appearance inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 100; // expected position
+
+ QTest::newRow("Past end, vertical, controls inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 97; // expected position
+
+ QTest::newRow("Past end, vertical, both inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 97; // expected position
list = QList<Qt::Key>();
list << Qt::Key_Home << Qt::Key_Down;
- QTest::newRow("Past home")<< 10 // initial position
- << 0 // minimum
- << 100 // maximum
- << 3 // single step size
- << 3 // page step size
- << list // key sequence
- << 0 // result in case of horizontal slider
- << 0 // result in case of vertical slider
- << 3 // result in case of inverted horiz. slider
- << 3; // result in case of inverted vertical slider
-
+ QTest::newRow("Past home, horizontal")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 0; // expected position
+
+ QTest::newRow("Past home, horizontal, appearance inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 0; // expected position
+
+ QTest::newRow("Past home, horizontal, controls inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 3; // expected position
+
+ QTest::newRow("Past home, horizontal, both inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 3; // expected position
+
+ QTest::newRow("Past home, vertical")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 0; // expected position
+
+ QTest::newRow("Past home, vertical, appearance inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << false// inverted controls
+ << list // key sequence
+ << 0; // expected position
+
+ QTest::newRow("Past home, vertical, controls inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << false// inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 3; // expected position
+
+ QTest::newRow("Past home, vertical, both inverted")
+ << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << true // inverted appearance
+ << true // inverted controls
+ << list // key sequence
+ << 3; // expected position
}
void tst_QAbstractSlider::keyPressed()
@@ -630,60 +1471,22 @@ void tst_QAbstractSlider::keyPressed()
QFETCH(int, maximum);
QFETCH(int, stepSize);
QFETCH(int, pageSize);
+ QFETCH(bool, invertedAppearance);
+ QFETCH(bool, invertedControls);
QFETCH(QList<Qt::Key>, keySequence);
- QFETCH(int, expectedSliderPositionHorizontal);
- QFETCH(int, expectedSliderPositionVertical);
- QFETCH(int, expectedSliderPositionHorizontalInverted);
- QFETCH(int, expectedSliderPositionVerticalInverted);
+ QFETCH(int, expectedSliderPosition);
- // Horizontal non-inverted
slider->setRange(minimum,maximum);
slider->setSliderPosition(initialSliderPosition);
slider->setSingleStep(stepSize);
slider->setPageStep(pageSize);
slider->setOrientation(Qt::Horizontal);
- slider->setInvertedAppearance(false);
- slider->setInvertedControls(false);
+ slider->setInvertedAppearance(invertedAppearance);
+ slider->setInvertedControls(invertedControls);
for (int i=0;i<keySequence.count();i++) {
QTest::keyClick(slider, keySequence.at(i));
}
- QCOMPARE(slider->sliderPosition(), expectedSliderPositionHorizontal);
-
- // Horizontal inverted
- slider->setRange(minimum,maximum);
- slider->setSliderPosition(initialSliderPosition);
- slider->setSingleStep(stepSize);
- slider->setPageStep(pageSize);
- slider->setOrientation(Qt::Horizontal);
- slider->setInvertedAppearance(true);
- slider->setInvertedControls(true);
- for (int i=0;i<keySequence.count();i++)
- QTest::keyPress(slider, keySequence.at(i));
- QCOMPARE(slider->sliderPosition(), expectedSliderPositionHorizontalInverted);
-
- // Vertical non-inverted
- slider->setRange(minimum,maximum);
- slider->setSliderPosition(initialSliderPosition);
- slider->setSingleStep(stepSize);
- slider->setPageStep(pageSize);
- slider->setOrientation(Qt::Vertical);
- slider->setInvertedAppearance(false);
- slider->setInvertedControls(false);
- for (int i=0;i<keySequence.count();i++)
- QTest::keyPress(slider, keySequence.at(i));
- QCOMPARE(slider->sliderPosition(), expectedSliderPositionVertical);
-
- // Vertical inverted
- slider->setRange(minimum,maximum);
- slider->setSliderPosition(initialSliderPosition);
- slider->setSingleStep(stepSize);
- slider->setPageStep(pageSize);
- slider->setOrientation(Qt::Vertical);
- slider->setInvertedAppearance(true);
- slider->setInvertedControls(true);
- for (int i=0;i<keySequence.count();i++)
- QTest::keyPress(slider, keySequence.at(i));
- QCOMPARE(slider->sliderPosition(), expectedSliderPositionVerticalInverted);
+ QCOMPARE(slider->sliderPosition(), expectedSliderPosition);
}
#if QT_CONFIG(wheelevent)
diff --git a/tests/manual/textrendering/nativetext/main.cpp b/tests/manual/textrendering/nativetext/main.cpp
index 5c7621e61f..b481e44bae 100644
--- a/tests/manual/textrendering/nativetext/main.cpp
+++ b/tests/manual/textrendering/nativetext/main.cpp
@@ -101,7 +101,9 @@ public:
const int ascent = fontMetrics().ascent();
- p.setPen(Qt::magenta);
+ QPen metricsPen(QColor(112, 216, 255), 1.0);
+ metricsPen.setCosmetic(true);
+ p.setPen(metricsPen);
p.drawLine(QPoint(0, ascent), QPoint(width(), ascent));
p.end();
@@ -152,13 +154,22 @@ public:
if (font().styleStrategy() & QFont::NoAntialias)
CGContextSetShouldAntialias(ctx, false);
- // Retain count already tracked by QMacCGContext above
- NSGraphicsContext.currentContext = [NSGraphicsContext graphicsContextWithCGContext:ctx flipped:YES];
- [text().toNSString() drawAtPoint:CGPointZero withAttributes:@{
- NSFontAttributeName : (NSFont *)fontEngine->handle(),
- NSForegroundColorAttributeName : nsColor
- }];
- NSGraphicsContext.currentContext = nil;
+ // Flip to what CT expects
+ CGContextScaleCTM(ctx, 1, -1);
+ CGContextTranslateCTM(ctx, 0, -height());
+
+ // Set up baseline
+ CGContextSetTextPosition(ctx, 0, height() - fontMetrics().ascent());
+
+ auto *attributedString = [[NSAttributedString alloc] initWithString:text().toNSString()
+ attributes:@{
+ NSFontAttributeName : (NSFont *)fontEngine->handle(),
+ NSForegroundColorAttributeName : nsColor
+ }
+ ];
+
+ QCFType<CTLineRef> line = CTLineCreateWithAttributedString(CFAttributedStringRef([attributedString autorelease]));
+ CTLineDraw(line, ctx);
#endif
}
@@ -190,17 +201,16 @@ public:
case 0: return qMakePair(QColor(), QColor());
case 1: return qMakePair(QColor(Qt::black), QColor(Qt::white));
case 2: return qMakePair(QColor(Qt::white), QColor(Qt::black));
- case 3: return qMakePair(QColor(Qt::green), QColor(Qt::red));
+ case 3: return qMakePair(QColor(Qt::magenta), QColor(Qt::green));
case 4: return qMakePair(QColor(0, 0, 0, 128), QColor(Qt::white));
case 5: return qMakePair(QColor(255, 255, 255, 128), QColor(Qt::black));
default: return qMakePair(QColor(), QColor());
}
}();
- layout->addWidget(new TextRenderer(12, text, color.first, color.second));
- layout->addWidget(new TextRenderer(24, text, color.first, color.second));
- layout->addWidget(new TextRenderer(36, text, color.first, color.second));
- layout->addWidget(new TextRenderer(48, text, color.first, color.second));
+ for (int pointSize : {8, 12, 24, 36, 48})
+ layout->addWidget(new TextRenderer(pointSize, text, color.first, color.second));
+
static_cast<QHBoxLayout*>(m_previews->layout())->addLayout(layout);
}