summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp2
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp5
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp39
-rw-r--r--tests/auto/widgets/dialogs/qfontdialog/BLACKLIST5
-rw-r--r--tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp45
-rw-r--r--tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp20
-rw-r--r--tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp4
-rw-r--r--tests/auto/widgets/gestures/gestures.pro6
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp53
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/BLACKLIST6
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp18
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp32
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp18
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicswidget/BLACKLIST4
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp12
-rw-r--r--tests/auto/widgets/itemviews/itemviews.pro4
-rw-r--r--tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp79
-rw-r--r--tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp86
-rw-r--r--tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp82
-rw-r--r--tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp23
-rw-r--r--tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp12
-rw-r--r--tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp33
-rw-r--r--tests/auto/widgets/itemviews/qtableview/BLACKLIST2
-rw-r--r--tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp29
-rw-r--r--tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp166
-rw-r--r--tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp47
-rw-r--r--tests/auto/widgets/kernel/kernel.pro4
-rw-r--r--tests/auto/widgets/kernel/qaction/BLACKLIST2
-rw-r--r--tests/auto/widgets/kernel/qaction/tst_qaction.cpp41
-rw-r--r--tests/auto/widgets/kernel/qactiongroup/BLACKLIST2
-rw-r--r--tests/auto/widgets/kernel/qapplication/BLACKLIST2
-rw-r--r--tests/auto/widgets/kernel/qapplication/test/BLACKLIST2
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp2
-rw-r--r--tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp10
-rw-r--r--tests/auto/widgets/kernel/qgesturerecognizer/BLACKLIST (renamed from tests/auto/widgets/gestures/qgesturerecognizer/BLACKLIST)0
-rw-r--r--tests/auto/widgets/kernel/qgesturerecognizer/qgesturerecognizer.pro (renamed from tests/auto/widgets/gestures/qgesturerecognizer/qgesturerecognizer.pro)0
-rw-r--r--tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp (renamed from tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp)2
-rw-r--r--tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp6
-rw-r--r--tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp2
-rw-r--r--tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp2
-rw-r--r--tests/auto/widgets/kernel/qtooltip/BLACKLIST4
-rw-r--r--tests/auto/widgets/kernel/qtooltip/tst_qtooltip.cpp4
-rw-r--r--tests/auto/widgets/kernel/qwidget/BLACKLIST22
-rw-r--r--tests/auto/widgets/kernel/qwidget/qwidget.pro2
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp329
-rw-r--r--tests/auto/widgets/kernel/qwidget_window/BLACKLIST4
-rw-r--r--tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp83
-rw-r--r--tests/auto/widgets/styles/qmacstyle/qmacstyle.pro2
-rw-r--r--tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp43
-rw-r--r--tests/auto/widgets/styles/qstyle/tst_qstyle.cpp70
-rw-r--r--tests/auto/widgets/styles/qstylesheetstyle/BLACKLIST6
-rw-r--r--tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp4
-rw-r--r--tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp19
-rw-r--r--tests/auto/widgets/widgets.pro1
-rw-r--r--tests/auto/widgets/widgets/qcombobox/BLACKLIST6
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp86
-rw-r--r--tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp65
-rw-r--r--tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp2
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_noshadow_0_0.pngbin103 -> 103 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_noshadow_0_1.pngbin103 -> 103 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_noshadow_0_2.pngbin103 -> 103 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_noshadow_1_0.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_noshadow_1_1.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_noshadow_1_2.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_noshadow_2_0.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_noshadow_2_1.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_noshadow_2_2.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_plain_0_0.pngbin103 -> 103 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_plain_0_1.pngbin103 -> 103 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_plain_0_2.pngbin103 -> 103 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_plain_1_0.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_plain_1_1.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_plain_1_2.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_plain_2_0.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_plain_2_1.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_plain_2_2.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_raised_0_0.pngbin103 -> 103 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_raised_0_1.pngbin129 -> 128 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_raised_0_2.pngbin126 -> 126 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_raised_1_0.pngbin135 -> 135 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_raised_1_1.pngbin158 -> 158 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_raised_1_2.pngbin162 -> 162 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_raised_2_0.pngbin148 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_raised_2_1.pngbin182 -> 182 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_raised_2_2.pngbin182 -> 182 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_sunken_0_0.pngbin103 -> 103 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_sunken_0_1.pngbin129 -> 128 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_sunken_0_2.pngbin126 -> 126 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_sunken_1_0.pngbin138 -> 138 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_sunken_1_1.pngbin159 -> 159 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_sunken_1_2.pngbin163 -> 163 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_sunken_2_0.pngbin148 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_sunken_2_1.pngbin182 -> 182 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/box_sunken_2_2.pngbin182 -> 182 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_0.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_1.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_2.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_0.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_1.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_2.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_0.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_1.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_2.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_0.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_1.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_2.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_0.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_1.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_2.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_0.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_1.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_2.pngbin114 -> 114 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_0.pngbin148 -> 146 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_1.pngbin148 -> 146 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_2.pngbin148 -> 146 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_0.pngbin148 -> 146 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_1.pngbin148 -> 146 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_2.pngbin148 -> 146 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_0.pngbin148 -> 146 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_1.pngbin148 -> 146 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_2.pngbin148 -> 146 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_0.pngbin154 -> 152 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_1.pngbin154 -> 152 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_2.pngbin154 -> 152 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_0.pngbin154 -> 152 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_1.pngbin154 -> 152 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_2.pngbin154 -> 152 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_0.pngbin154 -> 152 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_1.pngbin154 -> 152 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_2.pngbin154 -> 152 bytes
-rw-r--r--tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp4
-rw-r--r--tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp2
-rw-r--r--tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp137
-rw-r--r--tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp2
-rw-r--r--tests/auto/widgets/widgets/qmenu/BLACKLIST7
-rw-r--r--tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp168
-rw-r--r--tests/auto/widgets/widgets/qmenubar/BLACKLIST1
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp95
-rw-r--r--tests/auto/widgets/widgets/qopenglwidget/BLACKLIST13
-rw-r--r--tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp128
-rw-r--r--tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp2
-rw-r--r--tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp41
-rw-r--r--tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp7
-rw-r--r--tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp8
-rw-r--r--tests/auto/widgets/widgets/qspinbox/BLACKLIST3
-rw-r--r--tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp61
-rw-r--r--tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp2
-rw-r--r--tests/auto/widgets/widgets/qtabbar/BLACKLIST1
-rw-r--r--tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp24
152 files changed, 1726 insertions, 647 deletions
diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
index d704d212dd..7e246b5366 100644
--- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
+++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
@@ -243,7 +243,7 @@ void tst_QDialog::showMaximized()
dialog.showMaximized();
QVERIFY(dialog.isMaximized());
QVERIFY(dialog.isVisible());
-#if QT_CONFIG(sizegrip) && !defined(Q_OS_DARWIN) && !defined(Q_OS_IRIX) && !defined(Q_OS_HPUX)
+#if QT_CONFIG(sizegrip) && !defined(Q_OS_DARWIN) && !defined(Q_OS_HPUX)
QVERIFY(!sizeGrip->isVisible());
#endif
diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
index b950bf3957..eafd4d7cea 100644
--- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
@@ -48,6 +48,7 @@
#include <qlineedit.h>
#include <qlayout.h>
#include <qmenu.h>
+#include <qrandom.h>
#include "../../../../../src/widgets/dialogs/qsidebar_p.h"
#include "../../../../../src/widgets/dialogs/qfilesystemmodel_p.h"
#include "../../../../../src/widgets/dialogs/qfiledialog_p.h"
@@ -367,7 +368,7 @@ void tst_QFileDialog2::task143519_deleteAndRenameActionBehavior()
fd.selectFile(ctx.file.fileName());
fd.show();
- QTest::qWaitForWindowActive(&fd);
+ QVERIFY(QTest::qWaitForWindowActive(&fd));
// grab some internals:
QAction *rm = fd.findChild<QAction*>("qt_delete_action");
@@ -1196,7 +1197,7 @@ void tst_QFileDialog2::QTBUG6558_showDirsOnly()
{
const QString tempPath = tempDir.path();
QDir dirTemp(tempPath);
- const QString tempName = QLatin1String("showDirsOnly.") + QString::number(qrand());
+ const QString tempName = QLatin1String("showDirsOnly.") + QString::number(QRandomGenerator::global()->generate());
dirTemp.mkdir(tempName);
dirTemp.cd(tempName);
QTRY_VERIFY(dirTemp.exists());
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
index 71efe1d59a..40a7d56432 100644
--- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -102,6 +102,7 @@ private slots:
void mkdir();
void deleteFile();
+ void deleteDirectory();
void caseSensitivity();
@@ -884,6 +885,44 @@ void tst_QFileSystemModel::deleteFile()
QVERIFY(!newFile.exists());
}
+void tst_QFileSystemModel::deleteDirectory()
+{
+ // QTBUG-65683: Verify that directories can be removed recursively despite
+ // file system watchers being active on them or their sub-directories (Windows).
+ // Create a temporary directory, a nested directory and expand a treeview
+ // to show them to ensure watcher creation. Then delete the directory.
+ QTemporaryDir dirToBeDeleted(flatDirTestPath + QStringLiteral("/deleteDirectory-XXXXXX"));
+ QVERIFY(dirToBeDeleted.isValid());
+ const QString dirToBeDeletedPath = dirToBeDeleted.path();
+ const QString nestedTestDir = QStringLiteral("test");
+ QVERIFY(QDir(dirToBeDeletedPath).mkpath(nestedTestDir));
+ const QString nestedTestDirPath = dirToBeDeletedPath + QLatin1Char('/') + nestedTestDir;
+ QFile testFile(nestedTestDirPath + QStringLiteral("/test.txt"));
+ QVERIFY(testFile.open(QIODevice::WriteOnly | QIODevice::Text));
+ testFile.write("Hello\n");
+ testFile.close();
+
+ QFileSystemModel model;
+ const QModelIndex rootIndex = model.setRootPath(flatDirTestPath);
+ QTreeView treeView;
+ treeView.setWindowTitle(QTest::currentTestFunction());
+ treeView.setModel(&model);
+ treeView.setRootIndex(rootIndex);
+
+ const QModelIndex dirToBeDeletedPathIndex = model.index(dirToBeDeletedPath);
+ QVERIFY(dirToBeDeletedPathIndex.isValid());
+ treeView.setExpanded(dirToBeDeletedPathIndex, true);
+ const QModelIndex nestedTestDirIndex = model.index(nestedTestDirPath);
+ QVERIFY(nestedTestDirIndex.isValid());
+ treeView.setExpanded(nestedTestDirIndex, true);
+
+ treeView.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&treeView));
+
+ QVERIFY(model.remove(dirToBeDeletedPathIndex));
+ dirToBeDeleted.setAutoRemove(false);
+}
+
static QString flipCase(QString s)
{
for (int i = 0, size = s.size(); i < size; ++i) {
diff --git a/tests/auto/widgets/dialogs/qfontdialog/BLACKLIST b/tests/auto/widgets/dialogs/qfontdialog/BLACKLIST
deleted file mode 100644
index 07f3a41df3..0000000000
--- a/tests/auto/widgets/dialogs/qfontdialog/BLACKLIST
+++ /dev/null
@@ -1,5 +0,0 @@
-[task256466_wrongStyle]
-opensuse-13.1
-opensuse-42.1
-rhel-7.1
-rhel-7.2
diff --git a/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp b/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp
index 8da6ef0363..259de49c67 100644
--- a/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp
+++ b/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp
@@ -47,6 +47,7 @@ class tst_QInputDialog : public QObject
static void testFuncGetDouble(QInputDialog *dialog);
static void testFuncGetText(QInputDialog *dialog);
static void testFuncGetItem(QInputDialog *dialog);
+ static void testFuncSingleStepDouble(QInputDialog *dialog);
void timerEvent(QTimerEvent *event);
private slots:
void getInt_data();
@@ -61,6 +62,8 @@ private slots:
void getItem();
void task256299_getTextReturnNullStringOnRejected();
void inputMethodHintsOfChildWidget();
+ void setDoubleStep_data();
+ void setDoubleStep();
};
QString stripFraction(const QString &s)
@@ -335,7 +338,7 @@ class SelfDestructParent : public QWidget
Q_OBJECT
public:
explicit SelfDestructParent(int delay = 100)
- : QWidget(Q_NULLPTR)
+ : QWidget(nullptr)
{
QTimer::singleShot(delay, this, SLOT(deleteLater()));
}
@@ -498,5 +501,45 @@ void tst_QInputDialog::inputMethodHintsOfChildWidget()
QCOMPARE(editWidget->inputMethodHints(), Qt::ImhDigitsOnly);
}
+void tst_QInputDialog::testFuncSingleStepDouble(QInputDialog *dialog)
+{
+ QDoubleSpinBox *sbox = dialog->findChild<QDoubleSpinBox *>();
+ QVERIFY(sbox);
+ QTest::keyClick(sbox, Qt::Key_Up);
+}
+
+void tst_QInputDialog::setDoubleStep_data()
+{
+ QTest::addColumn<double>("min");
+ QTest::addColumn<double>("max");
+ QTest::addColumn<int>("decimals");
+ QTest::addColumn<double>("doubleStep");
+ QTest::addColumn<double>("actualResult");
+ QTest::newRow("step 2.0") << 0.0 << 10.0 << 0 << 2.0 << 2.0;
+ QTest::newRow("step 2.5") << 0.5 << 10.5 << 1 << 2.5 << 3.0;
+ QTest::newRow("step 2.25") << 10.05 << 20.05 << 2 << 2.25 << 12.30;
+ QTest::newRow("step 2.25 fewer decimals") << 0.5 << 10.5 << 1 << 2.25 << 2.75;
+}
+
+void tst_QInputDialog::setDoubleStep()
+{
+ QFETCH(double, min);
+ QFETCH(double, max);
+ QFETCH(int, decimals);
+ QFETCH(double, doubleStep);
+ QFETCH(double, actualResult);
+ QWidget p;
+ parent = &p;
+ doneCode = QDialog::Accepted;
+ testFunc = &tst_QInputDialog::testFuncSingleStepDouble;
+ startTimer(0);
+ bool ok = false;
+ const double result = QInputDialog::getDouble(parent, QString(), QString(), min, min,
+ max, decimals, &ok, QFlags<Qt::WindowType>(),
+ doubleStep);
+ QVERIFY(ok);
+ QCOMPARE(result, actualResult);
+}
+
QTEST_MAIN(tst_QInputDialog)
#include "tst_qinputdialog.moc"
diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
index d6c4841b22..a5058f4b6c 100644
--- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
+++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
@@ -134,10 +134,10 @@ class ExecCloseHelper : public QObject
public:
enum { CloseWindow = -1 };
- explicit ExecCloseHelper(QObject *parent = Q_NULLPTR)
- : QObject(parent), m_key(0), m_timerId(0), m_testCandidate(Q_NULLPTR) { }
+ explicit ExecCloseHelper(QObject *parent = nullptr)
+ : QObject(parent), m_key(0), m_timerId(0), m_testCandidate(nullptr) { }
- void start(int key, QWidget *testCandidate = Q_NULLPTR)
+ void start(int key, QWidget *testCandidate = nullptr)
{
m_key = key;
m_testCandidate = testCandidate;
@@ -147,7 +147,7 @@ public:
bool done() const { return !m_timerId; }
protected:
- void timerEvent(QTimerEvent *te) Q_DECL_OVERRIDE;
+ void timerEvent(QTimerEvent *te) override;
private:
int m_key;
@@ -172,7 +172,7 @@ void ExecCloseHelper::timerEvent(QTimerEvent *te)
QKeyEvent *ke = new QKeyEvent(QEvent::KeyPress, m_key, Qt::NoModifier);
QCoreApplication::postEvent(m_testCandidate, ke);
}
- m_testCandidate = Q_NULLPTR;
+ m_testCandidate = nullptr;
killTimer(m_timerId);
m_timerId = m_key = 0;
}
@@ -185,6 +185,12 @@ void tst_QMessageBox::cleanup()
void tst_QMessageBox::sanityTest()
{
+#if defined(Q_OS_MACOS)
+ if (QSysInfo::productVersion() == QLatin1String("10.12")) {
+ QSKIP("Test hangs on macOS 10.12 -- QTQAINFRA-1362");
+ return;
+ }
+#endif
QMessageBox msgBox;
msgBox.setText("This is insane");
for (int i = 0; i < 10; i++)
@@ -588,7 +594,7 @@ void tst_QMessageBox::detailsText()
box.setDetailedText(text);
QCOMPARE(box.detailedText(), text);
box.show();
- QTest::qWaitForWindowExposed(&box);
+ QVERIFY(QTest::qWaitForWindowExposed(&box));
// QTBUG-39334, the box should now have the default "Ok" button as well as
// the "Show Details.." button.
QCOMPARE(box.findChildren<QAbstractButton *>().size(), 2);
@@ -641,7 +647,7 @@ void tst_QMessageBox::expandDetails_QTBUG_32473()
// that the window manager is also done manipulating the first QMessageBox.
QWidget fleece;
fleece.show();
- QTest::qWaitForWindowExposed(&fleece);
+ QVERIFY(QTest::qWaitForWindowExposed(&fleece));
if (geom.topLeft() == box.geometry().topLeft())
QTest::qWait(500);
QCOMPARE(geom.topLeft(), box.geometry().topLeft());
diff --git a/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp b/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp
index 44b7894c53..00d640e55e 100644
--- a/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp
+++ b/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp
@@ -255,10 +255,10 @@ class QTestTranslator : public QTranslator
public:
explicit QTestTranslator(QString str) : m_str(qMove(str)) {}
- QString translate(const char *, const char *sourceText, const char *, int) const Q_DECL_OVERRIDE
+ QString translate(const char *, const char *sourceText, const char *, int) const override
{ return m_str + sourceText + m_str; }
- bool isEmpty() const Q_DECL_OVERRIDE { return false; }
+ bool isEmpty() const override { return false; }
};
template <typename Translator>
diff --git a/tests/auto/widgets/gestures/gestures.pro b/tests/auto/widgets/gestures/gestures.pro
deleted file mode 100644
index 5a87a01ee2..0000000000
--- a/tests/auto/widgets/gestures/gestures.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-TEMPLATE=subdirs
-SUBDIRS=\
- qgesturerecognizer \
-
-mac: SUBDIRS -= \ # Uses native recognizers
- qgesturerecognizer \
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST
deleted file mode 100644
index abfa7a3329..0000000000
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/BLACKLIST
+++ /dev/null
@@ -1,2 +0,0 @@
-[ensureUpdateOnTextItem]
-osx-10.10
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
index 0fc1a643b4..26831002ce 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -33,6 +33,7 @@
#include <private/qgraphicsitem_p.h>
#include <private/qgraphicsview_p.h>
#include <private/qgraphicsscene_p.h>
+#include <QRandomGenerator>
#include <QStyleOptionGraphicsItem>
#include <QAbstractTextDocumentLayout>
#include <QBitmap>
@@ -1100,11 +1101,11 @@ void tst_QGraphicsItem::visible()
scene.addItem(item);
QVERIFY(item->isVisible());
- QCOMPARE(scene.items(QPointF(0, 0)).value(0, Q_NULLPTR), item);
+ QCOMPARE(scene.items(QPointF(0, 0)).value(0, nullptr), item);
item->setVisible(false);
QVERIFY(scene.items(QPointF(0, 0)).isEmpty());
item->setVisible(true);
- QCOMPARE(scene.items(QPointF(0, 0)).value(0, Q_NULLPTR), item);
+ QCOMPARE(scene.items(QPointF(0, 0)).value(0, nullptr), item);
QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress);
event.setButton(Qt::LeftButton);
@@ -3585,12 +3586,12 @@ void tst_QGraphicsItem::group()
QList<QGraphicsItem *> newItems;
for (int i = 0; i < 100; ++i) {
QGraphicsItem *item = scene.addRect(QRectF(-25, -25, 50, 50), QPen(Qt::black, 0),
- QBrush(QColor(rand() % 255, rand() % 255,
- rand() % 255, rand() % 255)));
+ QBrush(QColor(QRandomGenerator::global()->bounded(255), QRandomGenerator::global()->bounded(255),
+ QRandomGenerator::global()->bounded(255), QRandomGenerator::global()->bounded(255))));
newItems << item;
- item->setPos(-1000 + rand() % 2000,
- -1000 + rand() % 2000);
- item->setTransform(QTransform().rotate(rand() % 90), true);
+ item->setPos(-1000 + QRandomGenerator::global()->bounded(2000),
+ -1000 + QRandomGenerator::global()->bounded(2000));
+ item->setTransform(QTransform().rotate(QRandomGenerator::global()->bounded(90)), true);
}
view.fitInView(scene.itemsBoundingRect());
@@ -4133,8 +4134,8 @@ void tst_QGraphicsItem::ensureVisible()
for (int x = -100; x < 100; x += 25) {
for (int y = -100; y < 100; y += 25) {
- int xmargin = rand() % 75;
- int ymargin = rand() % 75;
+ int xmargin = QRandomGenerator::global()->bounded(75);
+ int ymargin = QRandomGenerator::global()->bounded(75);
item->ensureVisible(x, y, 25, 25, xmargin, ymargin);
QApplication::processEvents();
@@ -5493,16 +5494,16 @@ void tst_QGraphicsItem::itemClipsChildrenToShape2()
QGraphicsScene scene;
scene.addItem(parent);
- QCOMPARE(scene.items(QPointF(5, 5)).value(0, Q_NULLPTR), (QGraphicsItem *)parent);
+ QCOMPARE(scene.items(QPointF(5, 5)).value(0, nullptr), (QGraphicsItem *)parent);
QVERIFY(scene.items(QPointF(15, 5)).isEmpty());
QVERIFY(scene.items(QPointF(5, 15)).isEmpty());
QVERIFY(scene.items(QPointF(60, 60)).isEmpty());
QVERIFY(scene.items(QPointF(140, 60)).isEmpty());
QVERIFY(scene.items(QPointF(60, 140)).isEmpty());
QVERIFY(scene.items(QPointF(140, 140)).isEmpty());
- QCOMPARE(scene.items(QPointF(75, 75)).value(0, Q_NULLPTR), (QGraphicsItem *)child2);
- QCOMPARE(scene.items(QPointF(75, 100)).value(0, Q_NULLPTR), (QGraphicsItem *)child1);
- QCOMPARE(scene.items(QPointF(100, 75)).value(0, Q_NULLPTR), (QGraphicsItem *)child1);
+ QCOMPARE(scene.items(QPointF(75, 75)).value(0, nullptr), (QGraphicsItem *)child2);
+ QCOMPARE(scene.items(QPointF(75, 100)).value(0, nullptr), (QGraphicsItem *)child1);
+ QCOMPARE(scene.items(QPointF(100, 75)).value(0, nullptr), (QGraphicsItem *)child1);
QImage image(100, 100, QImage::Format_ARGB32_Premultiplied);
image.fill(0);
@@ -5537,9 +5538,9 @@ void tst_QGraphicsItem::itemClipsChildrenToShape3()
grandchild->setPos( 50, 50 );
parent->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
- QCOMPARE(scene.items(QPointF(25, 25)).value(0, Q_NULLPTR), (QGraphicsItem *)parent);
- QCOMPARE(scene.items(QPointF(75, 75)).value(0, Q_NULLPTR), (QGraphicsItem *)child);
- QCOMPARE(scene.items(QPointF(125, 125)).value(0, Q_NULLPTR), (QGraphicsItem *)grandchild);
+ QCOMPARE(scene.items(QPointF(25, 25)).value(0, nullptr), (QGraphicsItem *)parent);
+ QCOMPARE(scene.items(QPointF(75, 75)).value(0, nullptr), (QGraphicsItem *)child);
+ QCOMPARE(scene.items(QPointF(125, 125)).value(0, nullptr), (QGraphicsItem *)grandchild);
QVERIFY(scene.items(QPointF(175, 175)).isEmpty());
// Move child to fully overlap the parent. The grandchild should
@@ -5547,9 +5548,9 @@ void tst_QGraphicsItem::itemClipsChildrenToShape3()
child->prepareGeometryChange();
child->setPos( 0, 0 );
- QCOMPARE(scene.items(QPointF(25, 25)).value(0, Q_NULLPTR), (QGraphicsItem *)child);
- QCOMPARE(scene.items(QPointF(75, 75)).value(0, Q_NULLPTR), (QGraphicsItem *)grandchild);
- QCOMPARE(scene.items(QPointF(125, 125)).value(0, Q_NULLPTR), (QGraphicsItem *)grandchild);
+ QCOMPARE(scene.items(QPointF(25, 25)).value(0, nullptr), (QGraphicsItem *)child);
+ QCOMPARE(scene.items(QPointF(75, 75)).value(0, nullptr), (QGraphicsItem *)grandchild);
+ QCOMPARE(scene.items(QPointF(125, 125)).value(0, nullptr), (QGraphicsItem *)grandchild);
QVERIFY(scene.items(QPointF(175, 175)).isEmpty());
}
@@ -5822,8 +5823,8 @@ void tst_QGraphicsItem::itemClippingDiscovery()
rightRectItem->setParentItem(clipItem);
// The rects item are both visible at these points.
- QCOMPARE(scene.items(QPointF(10, 10)).value(0, Q_NULLPTR), (QGraphicsItem *)leftRectItem);
- QCOMPARE(scene.items(QPointF(90, 90)).value(0, Q_NULLPTR), (QGraphicsItem *)rightRectItem);
+ QCOMPARE(scene.items(QPointF(10, 10)).value(0, nullptr), (QGraphicsItem *)leftRectItem);
+ QCOMPARE(scene.items(QPointF(90, 90)).value(0, nullptr), (QGraphicsItem *)rightRectItem);
// The ellipse clips the rects now.
clipItem->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
@@ -5863,7 +5864,7 @@ void tst_QGraphicsItem::itemContainsChildrenInShape()
int oldChildBoundingRectCalls = childOutsideShape->boundingRectCalls;
// First test that both items are searched if no optimization flags are set
- QGraphicsItem* item = scene.items(QPointF(25, 5)).value(0, Q_NULLPTR);
+ QGraphicsItem* item = scene.items(QPointF(25, 5)).value(0, nullptr);
QCOMPARE(item, childOutsideShape);
QVERIFY(parent->boundingRectCalls > oldParentBoundingRectCalls);
@@ -5874,7 +5875,7 @@ void tst_QGraphicsItem::itemContainsChildrenInShape()
oldChildBoundingRectCalls = childOutsideShape->boundingRectCalls;
// Repeat the test to make sure that no caching/indexing is in effect
- item = scene.items(QPointF(25, 5)).value(0, Q_NULLPTR);
+ item = scene.items(QPointF(25, 5)).value(0, nullptr);
QCOMPARE(item, childOutsideShape);
QVERIFY(parent->boundingRectCalls > oldParentBoundingRectCalls);
@@ -5887,7 +5888,7 @@ void tst_QGraphicsItem::itemContainsChildrenInShape()
// Set the optimization flag and make sure that the child is not returned
// and that the child's boundingRect() method is never called.
parent->setFlag(QGraphicsItem::ItemContainsChildrenInShape);
- item = scene.items(QPointF(25, 5)).value(0, Q_NULLPTR);
+ item = scene.items(QPointF(25, 5)).value(0, nullptr);
QVERIFY(!(item));
QVERIFY(parent->boundingRectCalls > oldParentBoundingRectCalls);
@@ -7127,7 +7128,7 @@ public:
: QGraphicsRectItem(QRectF(-10, -10, 20, 20))
{
setPen(QPen(Qt::black, 0));
- setBrush(QColor(qrand() % 256, qrand() % 256, qrand() % 256));
+ setBrush(QColor(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256)));
}
QTransform x;
@@ -11409,7 +11410,7 @@ void tst_QGraphicsItem::doNotMarkFullUpdateIfNotInScene()
item2->setParentItem(item);
scene.addItem(item);
view.show();
- QTest::qWaitForWindowActive(view.windowHandle());
+ QVERIFY(QTest::qWaitForWindowActive(view.windowHandle()));
view.activateWindow();
QTRY_VERIFY(view.isActiveWindow());
QTRY_VERIFY(view.repaints >= 1);
diff --git a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
index 0f5277710c..97f3eb4a60 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
@@ -894,7 +894,7 @@ public:
: QProxyStyle(key),
horizontalSpacing(-1), verticalSpacing(-1) {}
- virtual int pixelMetric(QStyle::PixelMetric pm, const QStyleOption *option = 0, const QWidget *widget = 0) const Q_DECL_OVERRIDE
+ virtual int pixelMetric(QStyle::PixelMetric pm, const QStyleOption *option = 0, const QWidget *widget = 0) const override
{
if (pm == QStyle::PM_LayoutHorizontalSpacing && horizontalSpacing >= 0) {
return horizontalSpacing;
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/BLACKLIST
deleted file mode 100644
index 16f3534921..0000000000
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/BLACKLIST
+++ /dev/null
@@ -1,6 +0,0 @@
-[hoverEnterLeaveEvent]
-ubuntu-14.04
-rhel-7.1
-rhel-7.2
-[QTBUG_6986_sendMouseEventToAlienWidget]
-rhel-7.1
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index e49cd87941..8287b9ebdd 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -824,7 +824,7 @@ void tst_QGraphicsProxyWidget::focusOutEvent()
QApplication::setActiveWindow(&view);
view.activateWindow();
view.setFocus();
- QTest::qWaitForWindowActive(&view);
+ QVERIFY(QTest::qWaitForWindowActive(&view));
QTRY_VERIFY(view.isVisible());
QTRY_COMPARE(QApplication::activeWindow(), (QWidget*)&view);
@@ -1471,6 +1471,15 @@ protected:
}
};
+// ### work around missing QVector ctor from iterator pair:
+static QVector<QRect> rects(const QRegion &region)
+{
+ QVector<QRect> result;
+ for (QRect r : region)
+ result.push_back(r);
+ return result;
+}
+
void tst_QGraphicsProxyWidget::scrollUpdate()
{
ScrollWidget *widget = new ScrollWidget;
@@ -1492,10 +1501,10 @@ void tst_QGraphicsProxyWidget::scrollUpdate()
// QRect(0, 0, 200, 12) is the first update, expanded (-2, -2, 2, 2)
// QRect(0, 12, 102, 10) is the scroll update, expanded (-2, -2, 2, 2),
// intersected with the above update.
- QCOMPARE(view.paintEventRegion.rects(),
+ QCOMPARE(rects(view.paintEventRegion),
QVector<QRect>() << QRect(0, 0, 200, 12) << QRect(0, 12, 102, 10));
QCOMPARE(widget->npaints, 2);
- QCOMPARE(widget->paintEventRegion.rects(),
+ QCOMPARE(rects(widget->paintEventRegion),
QVector<QRect>() << QRect(0, 0, 200, 12) << QRect(0, 12, 102, 10));
}
@@ -2661,9 +2670,6 @@ void tst_QGraphicsProxyWidget::childPos_data()
void tst_QGraphicsProxyWidget::childPos()
{
-#ifdef Q_OS_IRIX
- QSKIP("This test is not reliable on IRIX.");
-#endif
QFETCH(bool, moveCombo);
QFETCH(QPoint, comboPos);
QFETCH(QPointF, proxyPos);
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST
index c6f69a51a5..70170d2822 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST
+++ b/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST
@@ -1,3 +1,5 @@
[removeItem]
# QTBUG-60754, QTest::mouseMove is not always respected, or the CI moves the cursor
osx-10.11 ci
+[isActive]
+opensuse-42.3 ci
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
index 2a77321bf8..3b340d06ab 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -295,7 +295,7 @@ void tst_QGraphicsScene::construction()
static inline const QGraphicsItem *itemAt(const QGraphicsScene &scene, qreal x, qreal y)
{
- return scene.items(QPointF(x, y)).value(0, Q_NULLPTR);
+ return scene.items(QPointF(x, y)).value(0, nullptr);
}
void tst_QGraphicsScene::sceneRect()
@@ -1507,10 +1507,10 @@ void tst_QGraphicsScene::mouseGrabberItem()
QCOMPARE(scene.mouseGrabberItem(), topMostItem);
// Geometrical changes should not affect the mouse grabber.
- item->setZValue(rand() % 500);
- item2->setZValue(rand() % 500);
- item->setPos(rand() % 50000, rand() % 50000);
- item2->setPos(rand() % 50000, rand() % 50000);
+ item->setZValue(QRandomGenerator::global()->bounded(500));
+ item2->setZValue(QRandomGenerator::global()->bounded(500));
+ item->setPos(QRandomGenerator::global()->bounded(50000), QRandomGenerator::global()->bounded(50000));
+ item2->setPos(QRandomGenerator::global()->bounded(50000), QRandomGenerator::global()->bounded(50000));
}
QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease);
@@ -3424,7 +3424,7 @@ void tst_QGraphicsScene::task139710_bspTreeCrash()
// add 1000 more items - the BSP tree is now resized
for (int i = 0; i < 1000; ++i) {
QGraphicsRectItem *item = scene.addRect(QRectF(0, 0, 200, 200));
- item->setPos(qrand() % 10000, qrand() % 10000);
+ item->setPos(QRandomGenerator::global()->bounded(10000), QRandomGenerator::global()->bounded(10000));
}
// trigger delayed item indexing for the first 1000 items
@@ -3433,7 +3433,7 @@ void tst_QGraphicsScene::task139710_bspTreeCrash()
// add 1000 more items - the BSP tree is now resized
for (int i = 0; i < 1000; ++i) {
QGraphicsRectItem *item = scene.addRect(QRectF(0, 0, 200, 200));
- item->setPos(qrand() % 10000, qrand() % 10000);
+ item->setPos(QRandomGenerator::global()->bounded(10000), QRandomGenerator::global()->bounded(10000));
}
// get items from the BSP tree and use them. there was junk in the tree
@@ -3543,15 +3543,15 @@ void tst_QGraphicsScene::sorting()
QGraphicsRectItem *c_2_1 = new QGraphicsRectItem(0, 0, 30, 30, c_2);
QGraphicsRectItem *c_2_1_1 = new QGraphicsRectItem(0, 0, 20, 20, c_2_1);
QGraphicsRectItem *c_2_2 = new QGraphicsRectItem(0, 0, 30, 30, c_2);
- t_1->setBrush(QColor(qrand() % 256, qrand() % 256, qrand() % 256));
- c_1->setBrush(QColor(qrand() % 256, qrand() % 256, qrand() % 256));
- c_1_1->setBrush(QColor(qrand() % 256, qrand() % 256, qrand() % 256));
- c_1_1_1->setBrush(QColor(qrand() % 256, qrand() % 256, qrand() % 256));
- c_1_2->setBrush(QColor(qrand() % 256, qrand() % 256, qrand() % 256));
- c_2->setBrush(QColor(qrand() % 256, qrand() % 256, qrand() % 256));
- c_2_1->setBrush(QColor(qrand() % 256, qrand() % 256, qrand() % 256));
- c_2_1_1->setBrush(QColor(qrand() % 256, qrand() % 256, qrand() % 256));
- c_2_2->setBrush(QColor(qrand() % 256, qrand() % 256, qrand() % 256));
+ t_1->setBrush(QColor(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256)));
+ c_1->setBrush(QColor(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256)));
+ c_1_1->setBrush(QColor(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256)));
+ c_1_1_1->setBrush(QColor(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256)));
+ c_1_2->setBrush(QColor(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256)));
+ c_2->setBrush(QColor(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256)));
+ c_2_1->setBrush(QColor(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256)));
+ c_2_1_1->setBrush(QColor(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256)));
+ c_2_2->setBrush(QColor(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256)));
c_1->setPos(23, 18);
c_1_1->setPos(24, 28);
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
index 5b557dba58..3d5df7506d 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
@@ -684,7 +684,7 @@ void tst_QGraphicsView::openGLViewport()
view.setViewport(glw);
view.show();
- QTest::qWaitForWindowExposed(&view);
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QTRY_VERIFY(spy1.count() > 0);
QTRY_VERIFY(spy2.count() >= spy1.count());
spy1.clear();
@@ -2464,9 +2464,9 @@ void tst_QGraphicsView::viewportUpdateMode()
// The view gets two updates for the update scene updates.
QTRY_VERIFY(!view.lastUpdateRegions.isEmpty());
#ifndef Q_OS_MAC //cocoa doesn't support drawing regions
- QCOMPARE(view.lastUpdateRegions.last().rects().size(), 2);
- QCOMPARE(view.lastUpdateRegions.last().rects().at(0).size(), QSize(14, 14));
- QCOMPARE(view.lastUpdateRegions.last().rects().at(1).size(), QSize(14, 14));
+ QCOMPARE(view.lastUpdateRegions.last().rectCount(), 2);
+ QCOMPARE(view.lastUpdateRegions.last().begin()[0].size(), QSize(14, 14));
+ QCOMPARE(view.lastUpdateRegions.last().begin()[1].size(), QSize(14, 14));
#endif
// Set full update mode.
@@ -2481,8 +2481,8 @@ void tst_QGraphicsView::viewportUpdateMode()
qApp->processEvents();
// The view gets one full viewport update for the update scene updates.
- QCOMPARE(view.lastUpdateRegions.last().rects().size(), 1);
- QCOMPARE(view.lastUpdateRegions.last().rects().at(0).size(), view.viewport()->size());
+ QCOMPARE(view.lastUpdateRegions.last().rectCount(), 1);
+ QCOMPARE(view.lastUpdateRegions.last().begin()[0].size(), view.viewport()->size());
view.lastUpdateRegions.clear();
// Set smart update mode
@@ -2499,8 +2499,8 @@ void tst_QGraphicsView::viewportUpdateMode()
qApp->processEvents();
// The view gets one bounding rect update.
- QCOMPARE(view.lastUpdateRegions.last().rects().size(), 1);
- QCOMPARE(view.lastUpdateRegions.last().rects().at(0).size(), QSize(32, 32));
+ QCOMPARE(view.lastUpdateRegions.last().rectCount(), 1);
+ QCOMPARE(view.lastUpdateRegions.last().begin()[0].size(), QSize(32, 32));
// Set no update mode
view.setViewportUpdateMode(QGraphicsView::NoViewportUpdate);
@@ -2899,7 +2899,7 @@ void tst_QGraphicsView::scrollBarRanges()
QFETCH(ExpectedValueDescription, vmax);
QFETCH(bool, useStyledPanel);
- if (useStyledPanel && style == "Macintosh" && platformName == QStringLiteral("cocoa"))
+ if (useStyledPanel && style == "macintosh" && platformName == QStringLiteral("cocoa"))
QSKIP("Insignificant on OSX");
QScopedPointer<QStyle> stylePtr;
diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicswidget/BLACKLIST
deleted file mode 100644
index 13ec840eff..0000000000
--- a/tests/auto/widgets/graphicsview/qgraphicswidget/BLACKLIST
+++ /dev/null
@@ -1,4 +0,0 @@
-[initialShow2]
-ubuntu-14.04
-rhel-7.1
-rhel-7.2
diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
index 1be17b552e..85b42e54fe 100644
--- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -2059,10 +2059,10 @@ void tst_QGraphicsWidget::task236127_bspTreeIndexFails()
QTRY_VERIFY(scene.items(QPointF(25, 25)).isEmpty());
widget->setGeometry(0, 112, 360, 528);
- QTRY_COMPARE(scene.items(QPointF(15, 120)).value(0, Q_NULLPTR), (QGraphicsItem *)widget);
+ QTRY_COMPARE(scene.items(QPointF(15, 120)).value(0, nullptr), (QGraphicsItem *)widget);
widget2->setGeometry(0, 573, 360, 67);
- QTRY_COMPARE(scene.items(QPointF(15, 120)).value(0, Q_NULLPTR), (QGraphicsItem *)widget);
- QTRY_COMPARE(scene.items(QPointF(50, 585)).value(0, Q_NULLPTR), (QGraphicsItem *)widget2);
+ QTRY_COMPARE(scene.items(QPointF(15, 120)).value(0, nullptr), (QGraphicsItem *)widget);
+ QTRY_COMPARE(scene.items(QPointF(50, 585)).value(0, nullptr), (QGraphicsItem *)widget2);
}
void tst_QGraphicsWidget::defaultSize()
@@ -3461,12 +3461,12 @@ void tst_QGraphicsWidget::QTBUG_45867_send_itemChildAddedChange_to_parent()
{
}
- QRectF boundingRect() const Q_DECL_OVERRIDE { return QRectF(); }
+ QRectF boundingRect() const override { return QRectF(); }
- void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) Q_DECL_OVERRIDE {}
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override {}
protected:
- QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) Q_DECL_OVERRIDE
+ QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) override
{
if (change == QGraphicsItem::ItemChildAddedChange)
++m_itemChildAddedChangeNotificationsCount;
diff --git a/tests/auto/widgets/itemviews/itemviews.pro b/tests/auto/widgets/itemviews/itemviews.pro
index af0b6aeef0..f2ee0e9124 100644
--- a/tests/auto/widgets/itemviews/itemviews.pro
+++ b/tests/auto/widgets/itemviews/itemviews.pro
@@ -20,7 +20,3 @@ SUBDIRS=\
!qtConfig(private_tests): SUBDIRS -= \
qcolumnview \
qlistwidget \
-
-# This test takes too long to run on IRIX, so skip it on that platform
-irix-*:SUBDIRS -= qitemview
-
diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
index 165c4b079e..e99ed8f2f4 100644
--- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
@@ -77,7 +77,7 @@ public:
GeometriesTestView() : QTableView(), updateGeometriesCalled(false) {}
bool updateGeometriesCalled;
protected slots:
- void updateGeometries() Q_DECL_OVERRIDE { updateGeometriesCalled = true; QTableView::updateGeometries(); }
+ void updateGeometries() override { updateGeometriesCalled = true; QTableView::updateGeometries(); }
};
class tst_QAbstractItemView : public QObject
@@ -147,6 +147,8 @@ private slots:
void testClearModelInClickedSignal();
void inputMethodEnabled_data();
void inputMethodEnabled();
+ void currentFollowsIndexWidget_data();
+ void currentFollowsIndexWidget();
};
class MyAbstractItemDelegate : public QAbstractItemDelegate
@@ -620,7 +622,9 @@ void tst_QAbstractItemView::rowDelegate()
QVERIFY(QTest::qWaitForWindowExposed(&view));
QModelIndex index = model.index(3, 0);
+ QVERIFY(!view.isPersistentEditorOpen(index));
view.openPersistentEditor(index);
+ QVERIFY(view.isPersistentEditorOpen(index));
QWidget *w = view.indexWidget(index);
QVERIFY(w);
QCOMPARE(w->metaObject()->className(), "QWidget");
@@ -640,7 +644,9 @@ void tst_QAbstractItemView::columnDelegate()
QVERIFY(QTest::qWaitForWindowExposed(&view));
QModelIndex index = model.index(0, 3);
+ QVERIFY(!view.isPersistentEditorOpen(index));
view.openPersistentEditor(index);
+ QVERIFY(view.isPersistentEditorOpen(index));
QWidget *w = view.indexWidget(index);
QVERIFY(w);
QCOMPARE(w->metaObject()->className(), "QWidget");
@@ -1228,8 +1234,8 @@ void tst_QAbstractItemView::task200665_itemEntered()
moveCursorAway(&view);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QCursor::setPos( view.geometry().center() );
- QCoreApplication::processEvents();
+ QCursor::setPos(view.geometry().center());
+ QTRY_COMPARE(QCursor::pos(), view.geometry().center());
QSignalSpy spy(&view, SIGNAL(entered(QModelIndex)));
view.verticalScrollBar()->setValue(view.verticalScrollBar()->maximum());
@@ -1551,7 +1557,7 @@ public:
QItemDelegate(parent)
{}
- void setEditorData(QWidget *editor, const QModelIndex &index) const Q_DECL_OVERRIDE {
+ void setEditorData(QWidget *editor, const QModelIndex &index) const override {
Q_UNUSED(index);
static bool w = true;
editor->setEnabled(w);
@@ -1800,7 +1806,7 @@ void tst_QAbstractItemView::shiftSelectionAfterChangingModelContents()
view.setModel(&proxyModel);
view.setSelectionMode(QAbstractItemView::ExtendedSelection);
view.show();
- QTest::qWaitForWindowExposed(&view);
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
// Click "C"
QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, view.visualRect(indexC).center());
@@ -1914,7 +1920,7 @@ void tst_QAbstractItemView::QTBUG48968_reentrant_updateEditorGeometries()
tree.setRootIsDecorated(false);
QObject::connect(&tree, SIGNAL(doubleClicked(QModelIndex)), &tree, SLOT(setRootIndex(QModelIndex)));
tree.show();
- QTest::qWaitForWindowActive(&tree);
+ QVERIFY(QTest::qWaitForWindowActive(&tree));
// Trigger editing idx
QModelIndex idx = m->index(1, 0);
@@ -1995,7 +2001,7 @@ void tst_QAbstractItemView::QTBUG50535_update_on_new_selection_model()
{
}
- void setSelectionModel(QItemSelectionModel *model) Q_DECL_OVERRIDE
+ void setSelectionModel(QItemSelectionModel *model) override
{
m_deselectedMustBeEmpty = !selectionModel() || !model || selectionModel()->model() != model->model();
QListView::setSelectionModel(model);
@@ -2005,7 +2011,7 @@ void tst_QAbstractItemView::QTBUG50535_update_on_new_selection_model()
bool selectionChangedOk() const { return m_selectionChangedOk; }
protected:
- bool viewportEvent(QEvent *event) Q_DECL_OVERRIDE
+ bool viewportEvent(QEvent *event) override
{
if (event->type() == QEvent::Paint)
++m_paintEventsCount;
@@ -2013,7 +2019,7 @@ void tst_QAbstractItemView::QTBUG50535_update_on_new_selection_model()
}
void selectionChanged(const QItemSelection &selected,
- const QItemSelection &deselected) Q_DECL_OVERRIDE
+ const QItemSelection &deselected) override
{
if (m_deselectedMustBeEmpty && !deselected.isEmpty())
m_selectionChangedOk = false;
@@ -2136,7 +2142,7 @@ signals:
void setSelectionCalled(const QRect &rect);
protected:
- void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags flags) Q_DECL_OVERRIDE
+ void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags flags) override
{
emit setSelectionCalled(rect);
QListView::setSelection(rect, flags);
@@ -2156,7 +2162,7 @@ void tst_QAbstractItemView::testClickToSelect()
SetSelectionTestView view;
view.setModel(&model);
view.show();
- QTest::qWaitForWindowExposed(&view);
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QSignalSpy spy(&view, &SetSelectionTestView::setSelectionCalled);
@@ -2386,5 +2392,56 @@ void tst_QAbstractItemView::inputMethodEnabled()
QCOMPARE(view->testAttribute(Qt::WA_InputMethodEnabled), result);
}
+void tst_QAbstractItemView::currentFollowsIndexWidget_data()
+{
+ QTest::addColumn<QByteArray>("viewType");
+
+ QList<QByteArray> widgets;
+ widgets << "QListView" << "QTreeView" << "QTableView";
+ for (const QByteArray &widget : qAsConst(widgets))
+ QTest::newRow(widget) << widget;
+}
+
+void tst_QAbstractItemView::currentFollowsIndexWidget()
+{
+ QFETCH(QByteArray, viewType);
+
+ QScopedPointer<QAbstractItemView> view;
+ if (viewType == "QListView")
+ view.reset(new QListView());
+ else if (viewType == "QTableView")
+ view.reset(new QTableView());
+ else if (viewType == "QTreeView")
+ view.reset(new QTreeView());
+ else
+ QVERIFY(0);
+
+ centerOnScreen(view.data());
+ view->show();
+ QVERIFY(QTest::qWaitForWindowExposed(view.data()));
+
+ QStandardItemModel *model = new QStandardItemModel(view.data());
+ QStandardItem *item1 = new QStandardItem("first item");
+ item1->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+ model->appendRow(item1);
+
+ QStandardItem *item2 = new QStandardItem("test item");
+ item2->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+ model->appendRow(item2);
+
+ view->setModel(model);
+ QLineEdit *lineEdit1 = new QLineEdit;
+ QLineEdit *lineEdit2 = new QLineEdit;
+ view->setIndexWidget(item1->index(), lineEdit1);
+ view->setIndexWidget(item2->index(), lineEdit2);
+
+ lineEdit2->setFocus();
+ QTRY_VERIFY(lineEdit2->hasFocus());
+ QCOMPARE(view->currentIndex(), item2->index());
+ lineEdit1->setFocus();
+ QTRY_VERIFY(lineEdit1->hasFocus());
+ QCOMPARE(view->currentIndex(), item1->index());
+}
+
QTEST_MAIN(tst_QAbstractItemView)
#include "tst_qabstractitemview.moc"
diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
index 6dae2cf8e4..3594e7fa01 100644
--- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
@@ -239,13 +239,15 @@ private slots:
void testStreamWithHide();
void testStylePosition();
void stretchAndRestoreLastSection();
-
+ void testMinMaxSectionSizeStretched();
+ void testMinMaxSectionSizeNotStretched();
void sizeHintCrash();
protected:
void setupTestData(bool use_reset_model = false);
void additionalInit();
void calculateAndCheck(int cppline, const int precalced_comparedata[]);
+ void testMinMaxSectionSize(bool stretchLastSection);
QWidget *topLevel;
QHeaderView *view;
@@ -402,6 +404,7 @@ void tst_QHeaderView::init()
QCOMPARE(view->length(), 0);
QCOMPARE(view->sizeHint(), QSize(0,0));
QCOMPARE(view->sectionSizeHint(0), -1);
+ view->setMinimumSectionSize(0); // system default min size can be to large
/*
model = new QStandardItemModel(1, 1);
@@ -514,6 +517,12 @@ void tst_QHeaderView::movable()
QCOMPARE(view->sectionsMovable(), false);
view->setSectionsMovable(true);
QCOMPARE(view->sectionsMovable(), true);
+
+ QCOMPARE(view->firstSectionMovable(), true);
+ view->setFirstSectionMovable(false);
+ QCOMPARE(view->firstSectionMovable(), false);
+ view->setFirstSectionMovable(true);
+ QCOMPARE(view->firstSectionMovable(), true);
}
void tst_QHeaderView::clickable()
@@ -1598,6 +1607,7 @@ static QByteArray savedState()
QStandardItemModel m(4, 4);
QHeaderView h1(Qt::Horizontal);
h1.setModel(&m);
+ h1.setMinimumSectionSize(0); // system default min size can be to large
h1.swapSections(0, 2);
h1.resizeSection(1, 10);
h1.setSortIndicatorShown(true);
@@ -1800,7 +1810,7 @@ class TestHeaderViewStyle : public QProxyStyle
{
public:
TestHeaderViewStyle() : horizontalSectionSize(100) {}
- int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const Q_DECL_OVERRIDE
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const override
{
if (metric == QStyle::PM_HeaderDefaultSectionSizeHorizontal)
return horizontalSectionSize;
@@ -2188,6 +2198,7 @@ void tst_QHeaderView::task248050_hideRow()
//this is the sequence of events that make the task fail
protected_QHeaderView header(Qt::Vertical);
QStandardItemModel model(0, 1);
+ header.setMinimumSectionSize(0); // system default min size can be to large
header.setStretchLastSection(false);
header.setDefaultSectionSize(17);
header.setModel(&model);
@@ -3181,5 +3192,76 @@ void tst_QHeaderView::stretchAndRestoreLastSection()
QCOMPARE(header.sectionSize(9), someOtherSectionSize);
}
+void tst_QHeaderView::testMinMaxSectionSizeStretched()
+{
+ testMinMaxSectionSize(true);
+}
+
+void tst_QHeaderView::testMinMaxSectionSizeNotStretched()
+{
+ testMinMaxSectionSize(false);
+}
+
+static void waitFor(const std::function<bool()> &func)
+{
+ for (int i = 0; i < 100; i++)
+ {
+ if (func())
+ return;
+ QTest::qWait(10);
+ }
+}
+
+void tst_QHeaderView::testMinMaxSectionSize(bool stretchLastSection)
+{
+ QStandardItemModel m(5, 5);
+ QTableView tv;
+ tv.setModel(&m);
+ tv.show();
+
+ const int sectionSizeMin = 20;
+ const int sectionSizeMax = 40;
+ const int defaultSectionSize = 30;
+
+ QVERIFY(QTest::qWaitForWindowExposed(&tv));
+
+ QHeaderView &header = *tv.horizontalHeader();
+ header.setMinimumSectionSize(sectionSizeMin);
+ header.setMaximumSectionSize(sectionSizeMax);
+ header.setDefaultSectionSize(defaultSectionSize);
+ header.setStretchLastSection(stretchLastSection);
+
+ // check defaults
+ QCOMPARE(header.sectionSize(0), defaultSectionSize);
+ QCOMPARE(header.sectionSize(3), defaultSectionSize);
+
+ // do not go above maxSectionSize
+ header.resizeSection(0, sectionSizeMax + 1);
+ QCOMPARE(header.sectionSize(0), sectionSizeMax);
+
+ // do not go below minSectionSize
+ header.resizeSection(0, sectionSizeMin - 1);
+ QCOMPARE(header.sectionSize(0), sectionSizeMin);
+
+ // change section size on max change
+ header.setMinimumSectionSize(sectionSizeMin);
+ header.setMaximumSectionSize(sectionSizeMax);
+ header.resizeSection(0, sectionSizeMax);
+ QCOMPARE(header.sectionSize(0), sectionSizeMax);
+ header.setMaximumSectionSize(defaultSectionSize);
+ waitFor([this, &header, defaultSectionSize]() { return header.sectionSize(0) == defaultSectionSize; });
+ QCOMPARE(header.sectionSize(0), defaultSectionSize);
+
+ // change section size on min change
+ header.setMinimumSectionSize(sectionSizeMin);
+ header.setMaximumSectionSize(sectionSizeMax);
+ header.resizeSection(0, sectionSizeMin);
+ QCOMPARE(header.sectionSize(0), sectionSizeMin);
+ header.setMinimumSectionSize(defaultSectionSize);
+ waitFor([this, &header, defaultSectionSize]() { return header.sectionSize(0) == defaultSectionSize; });
+ QCOMPARE(header.sectionSize(0), defaultSectionSize);
+}
+
+
QTEST_MAIN(tst_QHeaderView)
#include "tst_qheaderview.moc"
diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
index 5b353bb2ae..2fed2e0c69 100644
--- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
@@ -220,6 +220,20 @@ private slots:
void QTBUG4435_keepSelectionOnCheck();
void QTBUG16469_textForRole();
+ void dateTextForRole_data();
+ void dateTextForRole();
+
+#ifdef QT_BUILD_INTERNAL
+private:
+ struct RoleDelegate : public QItemDelegate
+ {
+ QString textForRole(Qt::ItemDataRole role, const QVariant &value, const QLocale &locale)
+ {
+ QAbstractItemDelegatePrivate *d = reinterpret_cast<QAbstractItemDelegatePrivate *>(qGetPtrHelper(d_ptr));
+ return d->textForRole(role, value, locale);
+ }
+ };
+#endif
};
@@ -474,7 +488,7 @@ void tst_QItemDelegate::doLayout_data()
<< QRect(0, 0, 50, 50)
<< QRect(0, 0, 1000, 1000)
<< QRect(0, 0, 400, 400)
- << QRect(m, 0, 50 + 2*m, 1000)
+ << QRect(0, 0, 50 + 2*m, 1000)
<< QRect(50 + 2*m, 0, 1000 + 2*m, 1000 + m)
<< QRect(50 + 2*m, 1000 + m, 1000 + 2*m, 400);
/*
@@ -510,7 +524,7 @@ void tst_QItemDelegate::doLayout_data()
<< QRect(0, 0, 50, 50)
<< QRect(0, 0, 1000, 1000)
<< QRect(0, 0, 400, 400)
- << QRect(m, 0, 50 + 2 * m, 1000)
+ << QRect(0, 0, 50 + 2 * m, 1000)
<< QRect(50 + 2 * m, 400 + m, 1000 + 2 * m, 1000)
<< QRect(50 + 2 * m, 0, 1000 + 2 * m, 400 + m);
@@ -534,7 +548,7 @@ void tst_QItemDelegate::doLayout_data()
<< QRect(0, 0, 50, 50)
<< QRect(0, 0, 1000, 1000)
<< QRect(0, 0, 400, 400)
- << QRect(m, 0, 50 + 2 * m, 1000)
+ << QRect(0, 0, 50 + 2 * m, 1000)
<< QRect(50 + 2 * m, 0, 1000 + 2 * m, 1000)
<< QRect(1050 + 4 * m, 0, 400 + 2 * m, 1000);
@@ -558,7 +572,7 @@ void tst_QItemDelegate::doLayout_data()
<< QRect(0, 0, 50, 50)
<< QRect(0, 0, 1000, 1000)
<< QRect(0, 0, 400, 400)
- << QRect(m, 0, 50 + 2 * m, 1000)
+ << QRect(0, 0, 50 + 2 * m, 1000)
<< QRect(450 + 4 * m, 0, 1000 + 2 * m, 1000)
<< QRect(50 + 2 * m, 0, 400 + 2 * m, 1000);
@@ -1021,7 +1035,7 @@ void tst_QItemDelegate::decoration()
}
case QVariant::Image: {
QImage img(size, QImage::Format_Mono);
- memset(img.bits(), 0, img.byteCount());
+ memset(img.bits(), 0, img.sizeInBytes());
value = img;
break;
}
@@ -1530,14 +1544,7 @@ void tst_QItemDelegate::QTBUG16469_textForRole()
#ifndef QT_BUILD_INTERNAL
QSKIP("This test requires a developer build");
#else
- struct TestDelegate : public QItemDelegate
- {
- QString textForRole(Qt::ItemDataRole role, const QVariant &value, const QLocale &locale)
- {
- QAbstractItemDelegatePrivate *d = reinterpret_cast<QAbstractItemDelegatePrivate *>(qGetPtrHelper(d_ptr));
- return d->textForRole(role, value, locale);
- }
- } delegate;
+ RoleDelegate delegate;
QLocale locale;
const float f = 123.456f;
@@ -1559,20 +1566,6 @@ void tst_QItemDelegate::QTBUG16469_textForRole()
QCOMPARE(delegate.textForRole(Qt::DisplayRole, ull, locale), locale.toString(ull));
QCOMPARE(delegate.textForRole(Qt::ToolTipRole, ull, locale), locale.toString(ull));
- const QDateTime dateTime = QDateTime::currentDateTime();
- const QDate date = dateTime.date();
- const QTime time = dateTime.time();
- const QString shortDate = locale.toString(date, QLocale::ShortFormat);
- const QString longDate = locale.toString(date, QLocale::LongFormat);
- const QString shortTime = locale.toString(time, QLocale::ShortFormat);
- const QString longTime = locale.toString(time, QLocale::LongFormat);
- QCOMPARE(delegate.textForRole(Qt::DisplayRole, date, locale), shortDate);
- QCOMPARE(delegate.textForRole(Qt::ToolTipRole, date, locale), longDate);
- QCOMPARE(delegate.textForRole(Qt::DisplayRole, time, locale), shortTime);
- QCOMPARE(delegate.textForRole(Qt::ToolTipRole, time, locale), longTime);
- QCOMPARE(delegate.textForRole(Qt::DisplayRole, dateTime, locale), shortDate + QLatin1Char(' ') + shortTime);
- QCOMPARE(delegate.textForRole(Qt::ToolTipRole, dateTime, locale), longDate + QLatin1Char(' ') + longTime);
-
const QString text("text");
QCOMPARE(delegate.textForRole(Qt::DisplayRole, text, locale), text);
QCOMPARE(delegate.textForRole(Qt::ToolTipRole, text, locale), text);
@@ -1584,6 +1577,41 @@ void tst_QItemDelegate::QTBUG16469_textForRole()
#endif
}
+void tst_QItemDelegate::dateTextForRole_data()
+{
+#ifdef QT_BUILD_INTERNAL
+ QTest::addColumn<QDateTime>("when");
+
+ QTest::newRow("now") << QDateTime::currentDateTime(); // It's a local time
+ QDate date(2013, 12, 11);
+ QTime time(10, 9, 8, 765);
+ // Ensure we exercise every time-spec variant:
+ QTest::newRow("local") << QDateTime(date, time, Qt::LocalTime);
+ QTest::newRow("UTC") << QDateTime(date, time, Qt::UTC);
+ QTest::newRow("zone") << QDateTime(date, time, QTimeZone("Europe/Dublin"));
+ QTest::newRow("offset") << QDateTime(date, time, Qt::OffsetFromUTC, 36000);
+#endif
+}
+
+void tst_QItemDelegate::dateTextForRole()
+{
+#ifndef QT_BUILD_INTERNAL
+ QSKIP("This test requires a developer build");
+#else
+ QFETCH(QDateTime, when);
+ RoleDelegate delegate;
+ QLocale locale;
+# define CHECK(value) \
+ QCOMPARE(delegate.textForRole(Qt::DisplayRole, value, locale), locale.toString(value, QLocale::ShortFormat)); \
+ QCOMPARE(delegate.textForRole(Qt::ToolTipRole, value, locale), locale.toString(value, QLocale::LongFormat))
+
+ CHECK(when);
+ CHECK(when.date());
+ CHECK(when.time());
+# undef CHECK
+#endif
+}
+
// ### _not_ covered:
// editing with a custom editor factory
diff --git a/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp b/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp
index 1fd7b31e22..f1239b2e7c 100644
--- a/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp
+++ b/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp
@@ -30,16 +30,6 @@
#include <QtTest/QtTest>
#include <QtCore/QtCore>
#include "viewstotest.cpp"
-#include <stdlib.h>
-
-#if defined(Q_OS_UNIX) || defined(Q_OS_WIN)
-#include <time.h>
-#endif
-
-#if defined(Q_OS_WIN)
-# define random rand
-# define srandom srand
-#endif
/*!
See viewstotest.cpp for instructions on how to have your view tested with these tests.
@@ -410,13 +400,15 @@ void touch(QWidget *widget, Qt::KeyboardModifier modifier, Qt::Key keyPress){
int width = widget->width();
int height = widget->height();
for (int i = 0; i < 5; ++i) {
- QTest::mouseClick(widget, Qt::LeftButton, modifier, QPoint(random() % width, random() % height));
- QTest::mouseDClick(widget, Qt::LeftButton, modifier, QPoint(random() % width, random() % height));
- QPoint press(random() % width, random() % height);
- QPoint releasePoint(random() % width, random() % height);
+ QTest::mouseClick(widget, Qt::LeftButton, modifier,
+ QPoint(QRandomGenerator::global()->bounded(width), QRandomGenerator::global()->bounded(height)));
+ QTest::mouseDClick(widget, Qt::LeftButton, modifier,
+ QPoint(QRandomGenerator::global()->bounded(width), QRandomGenerator::global()->bounded(height)));
+ QPoint press(QRandomGenerator::global()->bounded(width), QRandomGenerator::global()->bounded(height));
+ QPoint releasePoint(QRandomGenerator::global()->bounded(width), QRandomGenerator::global()->bounded(height));
QTest::mousePress(widget, Qt::LeftButton, modifier, press);
QTest::mouseMove(widget, releasePoint);
- if (random() % 1 == 0)
+ if (QRandomGenerator::global()->bounded(1) == 0)
QTest::mouseRelease(widget, Qt::LeftButton, 0, releasePoint);
else
QTest::mouseRelease(widget, Qt::LeftButton, modifier, releasePoint);
@@ -443,7 +435,6 @@ void tst_QItemView::spider()
view->setModel(treeModel);
view->show();
QVERIFY(QTest::qWaitForWindowActive(view));
- srandom(time(0));
touch(view->viewport(), Qt::NoModifier, Qt::Key_Left);
touch(view->viewport(), Qt::ShiftModifier, Qt::Key_Enter);
touch(view->viewport(), Qt::ControlModifier, Qt::Key_Backspace);
diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
index d8b8546d86..1d8286b3cf 100644
--- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
+++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
@@ -282,7 +282,7 @@ public:
class ScrollPerItemListView : public QListView
{
public:
- explicit ScrollPerItemListView(QWidget *parent = Q_NULLPTR)
+ explicit ScrollPerItemListView(QWidget *parent = nullptr)
: QListView(parent)
{
// Force per item scroll mode since it comes from the style by default
@@ -2157,7 +2157,7 @@ void tst_QListView::draggablePaintPairs()
view.setModel(&model);
view.show();
- QTest::qWaitForWindowExposed(&view);
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QModelIndex expectedIndex = model.index(row, 0);
QListViewPrivate *privateClass = static_cast<QListViewPrivate *>(QListViewPrivate::get(&view));
@@ -2201,7 +2201,7 @@ void tst_QListView::taskQTBUG_21804_hiddenItemsAndScrollingWithKeys()
lv.setSpacing(spacing);
lv.setModel(&model);
lv.show();
- QTest::qWaitForWindowExposed(&lv);
+ QVERIFY(QTest::qWaitForWindowExposed(&lv));
// hide every odd number row
for (int i = 1; i < model.rowCount(); i+=2)
@@ -2273,7 +2273,7 @@ void tst_QListView::spacing()
lv.setModel(&model);
lv.setSpacing(spacing);
lv.show();
- QTest::qWaitForWindowExposed(&lv);
+ QVERIFY(QTest::qWaitForWindowExposed(&lv));
// check size and position of first two items
QRect item1 = lv.visualRect(lv.model()->index(0, 0));
@@ -2304,7 +2304,7 @@ void tst_QListView::testScrollToWithHidden()
lv.setSpacing(5);
lv.showNormal();
- QTest::qWaitForWindowExposed(&lv);
+ QVERIFY(QTest::qWaitForWindowExposed(&lv));
QCOMPARE(lv.verticalScrollBar()->value(), 0);
@@ -2449,7 +2449,7 @@ void tst_QListView::horizontalScrollingByVerticalWheelEvents()
lv.resize(300, 300);
lv.show();
- QTest::qWaitForWindowExposed(&lv);
+ QVERIFY(QTest::qWaitForWindowExposed(&lv));
QPoint globalPos = lv.geometry().center();
QPoint pos = lv.viewport()->geometry().center();
diff --git a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
index 6547bb8985..f7332a15f5 100644
--- a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
+++ b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
@@ -1381,20 +1381,38 @@ void tst_QListWidget::changeDataWithSorting_data()
<< false;
}
+class QListWidgetDataChanged : public QListWidget
+{
+ Q_OBJECT
+public:
+ using QListWidget::QListWidget;
+
+ void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles) override
+ {
+ QListWidget::dataChanged(topLeft, bottomRight, roles);
+ currentRoles = roles;
+ }
+ QVector<int> currentRoles;
+};
+
void tst_QListWidget::itemData()
{
- QListWidget widget;
+ QListWidgetDataChanged widget;
QListWidgetItem item(&widget);
item.setFlags(item.flags() | Qt::ItemIsEditable);
item.setData(Qt::DisplayRole, QString("0"));
+ QCOMPARE(widget.currentRoles, QVector<int>({Qt::DisplayRole, Qt::EditRole}));
item.setData(Qt::CheckStateRole, Qt::PartiallyChecked);
- item.setData(Qt::UserRole + 0, QString("1"));
- item.setData(Qt::UserRole + 1, QString("2"));
- item.setData(Qt::UserRole + 2, QString("3"));
- item.setData(Qt::UserRole + 3, QString("4"));
+ QCOMPARE(widget.currentRoles, {Qt::CheckStateRole});
+ for (int i = 0; i < 4; ++i)
+ {
+ item.setData(Qt::UserRole + i, QString::number(i + 1));
+ QCOMPARE(widget.currentRoles, {Qt::UserRole + i});
+ }
QMap<int, QVariant> flags = widget.model()->itemData(widget.model()->index(0, 0));
QCOMPARE(flags.count(), 6);
- QCOMPARE(flags[Qt::UserRole + 0].toString(), QString("1"));
+ for (int i = 0; i < 4; ++i)
+ QCOMPARE(flags[Qt::UserRole + i].toString(), QString::number(i + 1));
}
void tst_QListWidget::changeDataWithSorting()
@@ -1710,12 +1728,11 @@ void tst_QListWidget::QTBUG50891_ensureSelectionModelSignalConnectionsAreSet()
list.setSelectionModel(new QItemSelectionModel(list.model()));
list.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&list));
QSignalSpy currentItemChangedSpy(&list, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)));
QSignalSpy itemSelectionChangedSpy(&list, SIGNAL(itemSelectionChanged()));
- QVERIFY(QTest::qWaitForWindowExposed(&list));
-
QCOMPARE(currentItemChangedSpy.count(), 0);
QCOMPARE(itemSelectionChangedSpy.count(), 0);
diff --git a/tests/auto/widgets/itemviews/qtableview/BLACKLIST b/tests/auto/widgets/itemviews/qtableview/BLACKLIST
index 329010a86e..fc231a4e30 100644
--- a/tests/auto/widgets/itemviews/qtableview/BLACKLIST
+++ b/tests/auto/widgets/itemviews/qtableview/BLACKLIST
@@ -1,4 +1,2 @@
[moveCursorBiggerJump]
osx
-[resizeColumnsToContents]
-ubuntu-14.04
diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
index 4e401ddd86..06c80bf8d2 100644
--- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
@@ -426,6 +426,9 @@ public:
this, SLOT(slotCurrentChanged(QModelIndex,QModelIndex)));
connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT(itemSelectionChanged(QItemSelection,QItemSelection)));
+ // Allow small sections in this test, since this test was made before we correctly enforced minimum sizes.
+ horizontalHeader()->setMinimumSectionSize(0);
+ verticalHeader()->setMinimumSectionSize(0);
}
// enum CursorAction and moveCursor() are protected in QTableView.
@@ -738,6 +741,8 @@ void tst_QTableView::headerSections()
QHeaderView *vheader = view.verticalHeader();
view.setModel(&model);
+ hheader->setMinimumSectionSize(columnWidth);
+ vheader->setMinimumSectionSize(rowHeight);
view.show();
hheader->doItemsLayout();
@@ -1147,6 +1152,9 @@ void tst_QTableView::moveCursor()
QtTestTableView view;
view.setModel(&model);
+ // we have to make sure that PgUp/PgDown can scroll to the bottom/top
+ view.resize(view.horizontalHeader()->length() + 50,
+ view.verticalHeader()->length() + 50);
view.hideRow(hideRow);
view.hideColumn(hideColumn);
if (moveColumn.first != moveColumn.second)
@@ -2085,6 +2093,8 @@ void tst_QTableView::visualRect()
QTableView view;
view.setModel(&model);
+ view.horizontalHeader()->setMinimumSectionSize(0);
+ view.verticalHeader()->setMinimumSectionSize(0);
// Make sure that it has 1 pixel between each cell.
view.setGridStyle(Qt::SolidLine);
for (int i = 0; i < view.verticalHeader()->count(); ++i)
@@ -3533,6 +3543,9 @@ void tst_QTableView::editSpanFromDirections()
TableViewWithCursorExposed view;
view.setModel(model.data());
+ // we have to make sure that PgUp/PgDown can scroll to the bottom/top
+ view.resize(view.horizontalHeader()->length() + 50,
+ view.verticalHeader()->length() + 50);
view.setSpan(row, column, rowSpan, columnSpan);
view.show();
QVERIFY(QTest::qWaitForWindowActive(&view));
@@ -3978,7 +3991,7 @@ void tst_QTableView::mouseWheel_data()
<< 10 + qApp->wheelScrollLines() << 10 + qApp->wheelScrollLines();
QTest::newRow("scroll down per pixel")
<< int(QAbstractItemView::ScrollPerPixel) << -120
- << 10 + qApp->wheelScrollLines() * 89 << 10 + qApp->wheelScrollLines() * 28;
+ << 10 + qApp->wheelScrollLines() * 91 << 10 + qApp->wheelScrollLines() * 46;
}
void tst_QTableView::mouseWheel()
@@ -3992,16 +4005,17 @@ void tst_QTableView::mouseWheel()
QWidget topLevel;
QtTestTableView view(&topLevel);
view.resize(500, 500);
- for (int r = 0; r < 100; ++r)
- view.setRowHeight(r, 50);
- for (int c = 0; c < 100; ++c)
- view.setColumnWidth(c, 100);
topLevel.show();
QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
view.setModel(&model);
+ for (int r = 0; r < 100; ++r)
+ view.setRowHeight(r, 50);
+ for (int c = 0; c < 100; ++c)
+ view.setColumnWidth(c, 100);
+
view.setHorizontalScrollMode((QAbstractItemView::ScrollMode)scrollMode);
view.setVerticalScrollMode((QAbstractItemView::ScrollMode)scrollMode);
view.horizontalScrollBar()->setValue(10);
@@ -4270,7 +4284,7 @@ void tst_QTableView::changeHeaderData()
QVERIFY(QTest::qWaitForWindowExposed(&view));
QString text = "long long long text";
- const int textWidth = view.verticalHeader()->fontMetrics().width(text);
+ const int textWidth = view.verticalHeader()->fontMetrics().horizontalAdvance(text);
QVERIFY(view.verticalHeader()->width() < textWidth);
model.setHeaderData(2, Qt::Vertical, text);
@@ -4364,7 +4378,8 @@ void tst_QTableView::taskQTBUG_7774_RtoLVisualRegionForSelection()
QItemSelection selection;
selection << range;
QRegion region = view.visualRegionForSelection(selection);
- QCOMPARE(region.rects().at(0), view.visualRect(range.topLeft()) | view.visualRect(range.bottomRight()));
+ QVERIFY(!region.isEmpty());
+ QCOMPARE(region.begin()[0], view.visualRect(range.topLeft()) | view.visualRect(range.bottomRight()));
}
void tst_QTableView::taskQTBUG_8777_scrollToSpans()
diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
index dfcaa9b5b9..5293ba487a 100644
--- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
@@ -163,6 +163,10 @@ private slots:
void styleOptionViewItem();
void keyboardNavigationWithDisabled();
+ void statusTip_data();
+ void statusTip();
+ void fetchMoreOnScroll();
+
// task-specific tests:
void task174627_moveLeftToRoot();
void task171902_expandWith1stColHidden();
@@ -206,23 +210,23 @@ public:
QtTestModel(int _rows, int _cols, QObject *parent = 0): QAbstractItemModel(parent),
fetched(false), rows(_rows), cols(_cols), levels(INT_MAX), wrongIndex(false) { init(); }
- void init() {
+ void init()
+ {
decorationsEnabled = false;
+ statusTipsEnabled = false;
}
- inline qint32 level(const QModelIndex &index) const {
+ inline qint32 level(const QModelIndex &index) const
+ {
return index.isValid() ? qint32(index.internalId()) : qint32(-1);
}
- bool canFetchMore(const QModelIndex &) const {
- return !fetched;
- }
+ bool canFetchMore(const QModelIndex &) const override { return !fetched; }
- void fetchMore(const QModelIndex &) {
- fetched = true;
- }
+ void fetchMore(const QModelIndex &) override { fetched = true; }
- bool hasChildren(const QModelIndex &parent = QModelIndex()) const {
+ bool hasChildren(const QModelIndex &parent = QModelIndex()) const override
+ {
bool hasFetched = fetched;
fetched = true;
bool r = QAbstractItemModel::hasChildren(parent);
@@ -230,26 +234,29 @@ public:
return r;
}
- int rowCount(const QModelIndex& parent = QModelIndex()) const {
+ int rowCount(const QModelIndex& parent = QModelIndex()) const override
+ {
if (!fetched)
qFatal("%s: rowCount should not be called before fetching", Q_FUNC_INFO);
if ((parent.column() > 0) || (level(parent) > levels))
return 0;
return rows;
}
- int columnCount(const QModelIndex& parent = QModelIndex()) const {
+ int columnCount(const QModelIndex& parent = QModelIndex()) const override
+ {
if ((parent.column() > 0) || (level(parent) > levels))
return 0;
return cols;
}
- bool isEditable(const QModelIndex &index) const {
+ bool isEditable(const QModelIndex &index) const
+ {
if (index.isValid())
return true;
return false;
}
- QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override
{
if (row < 0 || column < 0 || (level(parent) > levels) || column >= cols || row >= rows) {
return QModelIndex();
@@ -259,14 +266,14 @@ public:
return i;
}
- QModelIndex parent(const QModelIndex &index) const
+ QModelIndex parent(const QModelIndex &index) const override
{
if (!parentHash.contains(index))
return QModelIndex();
return parentHash[index];
}
- QVariant data(const QModelIndex &idx, int role) const
+ QVariant data(const QModelIndex &idx, int role) const override
{
if (!idx.isValid())
return QVariant();
@@ -289,9 +296,28 @@ public:
pm.fill(QColor::fromHsv((idx.column() % 16)*8 + 64, 254, (idx.row() % 16)*8 + 32));
return pm;
}
+ if (statusTipsEnabled && role == Qt::StatusTipRole)
+ return QString("[%1,%2,%3] -- Status").arg(idx.row()).arg(idx.column()).arg(level(idx));
+ return QVariant();
+ }
+
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const override
+ {
+ Q_UNUSED(orientation);
+ if (section < 0 || section >= columnCount())
+ return QVariant();
+ if (statusTipsEnabled && role == Qt::StatusTipRole)
+ return QString("Header %1 -- Status").arg(section);
return QVariant();
}
+ void simulateMoveRows()
+ {
+ beginMoveRows(QModelIndex(), 0, 0, QModelIndex(), 2);
+ endMoveRows();
+ }
+
void removeLastRow()
{
beginRemoveRows(QModelIndex(), rows - 1, rows - 1);
@@ -334,6 +360,7 @@ public:
mutable bool fetched;
bool decorationsEnabled;
+ bool statusTipsEnabled;
int rows, cols;
int levels;
mutable bool wrongIndex;
@@ -1306,6 +1333,17 @@ void tst_QTreeView::columnHidden()
for (int c = 0; c < model.columnCount(); ++c)
QCOMPARE(view.isColumnHidden(c), true);
view.update();
+
+ // QTBUG 54610
+ // QAbstractItemViewPrivate::_q_layoutChanged() is called on
+ // rows/columnMoved and because this function is virtual,
+ // QHeaderViewPrivate::_q_layoutChanged() was called and unhided
+ // all sections because QHeaderViewPrivate::_q_layoutAboutToBeChanged()
+ // could not fill persistentHiddenSections (and is not needed)
+ view.hideColumn(model.cols - 1);
+ QCOMPARE(view.isColumnHidden(model.cols - 1), true);
+ model.simulateMoveRows();
+ QCOMPARE(view.isColumnHidden(model.cols - 1), true);
}
void tst_QTreeView::rowHidden()
@@ -2587,7 +2625,7 @@ class TestTreeViewStyle : public QProxyStyle
{
public:
TestTreeViewStyle() : indentation(20) {}
- int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const Q_DECL_OVERRIDE
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const override
{
if (metric == QStyle::PM_TreeViewIndentation)
return indentation;
@@ -4312,7 +4350,7 @@ void tst_QTreeView::testInitialFocus()
treeWidget.header()->hideSection(0); // make sure we skip hidden section(s)
treeWidget.header()->swapSections(1, 2); // make sure that we look for first visual index (and not first logical)
treeWidget.show();
- QTest::qWaitForWindowExposed(&treeWidget);
+ QVERIFY(QTest::qWaitForWindowExposed(&treeWidget));
QApplication::processEvents();
QCOMPARE(treeWidget.currentIndex().column(), 2);
}
@@ -4335,7 +4373,7 @@ void tst_QTreeView::quickExpandCollapse()
QVERIFY(rootIndex.isValid());
tree.show();
- QTest::qWaitForWindowExposed(&tree);
+ QVERIFY(QTest::qWaitForWindowExposed(&tree));
const QAbstractItemView::State initialState = tree.state();
@@ -4497,6 +4535,97 @@ void tst_QTreeView::taskQTBUG_7232_AllowUserToControlSingleStep()
QCOMPARE(hStep1, t.horizontalScrollBar()->singleStep());
}
+void tst_QTreeView::statusTip_data()
+{
+ QTest::addColumn<bool>("intermediateParent");
+ QTest::newRow("noIntermediate") << false;
+ QTest::newRow("intermediate") << true;
+}
+
+void tst_QTreeView::statusTip()
+{
+ QFETCH(bool, intermediateParent);
+ QMainWindow mw;
+ QtTestModel model;
+ model.statusTipsEnabled = true;
+ model.rows = model.cols = 5;
+ QTreeView *view = new QTreeView;
+ view->setModel(&model);
+ view->viewport()->setMouseTracking(true);
+ view->header()->viewport()->setMouseTracking(true);
+ if (intermediateParent) {
+ QWidget *inter = new QWidget;
+ QVBoxLayout *vbox = new QVBoxLayout;
+ inter->setLayout(vbox);
+ vbox->addWidget(view);
+ mw.setCentralWidget(inter);
+ } else {
+ mw.setCentralWidget(view);
+ }
+ mw.statusBar();
+ mw.setGeometry(QRect(QPoint(QApplication::desktop()->geometry().center() - QPoint(250, 250)),
+ QSize(500, 500)));
+ mw.show();
+ qApp->setActiveWindow(&mw);
+ QVERIFY(QTest::qWaitForWindowActive(&mw));
+ // Ensure it is moved away first and then moved to the relevant section
+ QTest::mouseMove(mw.windowHandle(), view->mapTo(&mw, view->rect().bottomLeft() + QPoint(20, 20)));
+ QPoint centerPoint = view->viewport()->mapTo(&mw, view->visualRect(model.index(0, 0)).center());
+ QTest::mouseMove(mw.windowHandle(), centerPoint);
+ QTRY_COMPARE(mw.statusBar()->currentMessage(), QLatin1String("[0,0,0] -- Status"));
+ centerPoint = view->viewport()->mapTo(&mw, view->visualRect(model.index(0, 1)).center());
+ QTest::mouseMove(mw.windowHandle(), centerPoint);
+ QTRY_COMPARE(mw.statusBar()->currentMessage(), QLatin1String("[0,1,0] -- Status"));
+ centerPoint = view->header()->viewport()->mapTo(&mw,
+ QPoint(view->header()->sectionViewportPosition(0) + view->header()->sectionSize(0) / 2,
+ view->header()->height() / 2));
+ QTest::mouseMove(mw.windowHandle(), centerPoint);
+ QTRY_COMPARE(mw.statusBar()->currentMessage(), QLatin1String("Header 0 -- Status"));
+}
+
+class FetchMoreModel : public QStandardItemModel
+{
+public:
+ FetchMoreModel() : QStandardItemModel(), canFetchReady(false)
+ {
+ for (int i = 0; i < 20; ++i) {
+ QStandardItem *item = new QStandardItem("Row");
+ item->appendRow(new QStandardItem("Child"));
+ appendRow(item);
+ }
+ }
+ bool canFetchMore(const QModelIndex &parent) const override
+ {
+ if (!canFetchReady || !parent.isValid())
+ return false;
+ if (!parent.parent().isValid())
+ return rowCount(parent) < 20;
+ return false;
+ }
+ void fetchMore(const QModelIndex &parent) override
+ {
+ QStandardItem *item = itemFromIndex(parent);
+ for (int i = 0; i < 19; ++i)
+ item->appendRow(new QStandardItem(QString("New Child %1").arg(i)));
+ }
+ bool canFetchReady;
+};
+
+void tst_QTreeView::fetchMoreOnScroll()
+{
+ QTreeView tw;
+ FetchMoreModel im;
+ tw.setModel(&im);
+ tw.show();
+ tw.expandAll();
+ QVERIFY(QTest::qWaitForWindowActive(&tw));
+ // Now we can allow the fetch to happen
+ im.canFetchReady = true;
+ tw.verticalScrollBar()->setValue(tw.verticalScrollBar()->maximum());
+ // The item should have now fetched the other children, thus bringing the count to 20
+ QCOMPARE(im.item(19)->rowCount(), 20);
+}
+
static void fillModeltaskQTBUG_8376(QAbstractItemModel &model)
{
model.insertRow(0);
@@ -4542,6 +4671,5 @@ void tst_QTreeView::taskQTBUG_8376()
QCOMPARE(rowHeightLvl1Visible, rowHeightLvl1Visible2);
}
-
QTEST_MAIN(tst_QTreeView)
#include "tst_qtreeview.moc"
diff --git a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
index fa7f9596da..d0e6407283 100644
--- a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
+++ b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
@@ -159,6 +159,7 @@ private slots:
void taskQTBUG_34717_collapseAtBottom();
void task20345_sortChildren();
void getMimeDataWithInvalidItem();
+ void testVisualItemRect();
public slots:
void itemSelectionChanged();
@@ -332,10 +333,19 @@ void tst_QTreeWidget::addTopLevelItem()
for (int i = 0; i < 10; ++i)
tops << new TreeItem();
int count = tree.topLevelItemCount();
- tree.insertTopLevelItems(100000, tops);
- // ### fixme
+ tree.insertTopLevelItems(count, tops);
QCOMPARE(tree.topLevelItemCount(), count + 10);
}
+
+ // invalid insert
+ {
+ tops.clear();
+ for (int i = 0; i < 10; ++i)
+ tops << new TreeItem();
+ int count = tree.topLevelItemCount();
+ tree.insertTopLevelItems(100000, tops); // should be a no-op
+ QCOMPARE(tree.topLevelItemCount(), count);
+ }
}
void tst_QTreeWidget::currentItem_data()
@@ -3269,7 +3279,7 @@ void tst_QTreeWidget::task239150_editorWidth()
QVERIFY(tree.itemWidget(&item, 0) == 0);
tree.editItem(&item);
QVERIFY(tree.itemWidget(&item, 0));
- QVERIFY(tree.itemWidget(&item, 0)->width() >= minWidth + tree.fontMetrics().width(item.text(0)));
+ QVERIFY(tree.itemWidget(&item, 0)->width() >= minWidth + tree.fontMetrics().horizontalAdvance(item.text(0)));
}
}
@@ -3449,9 +3459,38 @@ void tst_QTreeWidget::getMimeDataWithInvalidItem()
{
CustomTreeWidget w;
QTest::ignoreMessage(QtWarningMsg, "QTreeWidget::mimeData: Null-item passed");
- QMimeData *md = w.mimeData(QList<QTreeWidgetItem*>() << Q_NULLPTR);
+ QMimeData *md = w.mimeData(QList<QTreeWidgetItem*>() << nullptr);
QVERIFY(!md);
}
+// visualItemRect returned a wrong rect when the columns were moved
+// (-> logical index != visual index). see QTBUG-28733
+void tst_QTreeWidget::testVisualItemRect()
+{
+ QTreeWidget tw;
+ tw.setColumnCount(2);
+ QTreeWidgetItem *item = new QTreeWidgetItem(&tw);
+ item->setText(0, "text 0");
+ item->setText(1, "text 1");
+
+ static const int sectionSize = 30;
+ tw.header()->setStretchLastSection(false);
+ tw.header()->setMinimumSectionSize(sectionSize);
+ tw.header()->resizeSection(0, sectionSize);
+ tw.header()->resizeSection(1, sectionSize);
+ tw.setRootIsDecorated(false);
+ tw.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&tw));
+
+ QRect r = tw.visualItemRect(item);
+ QCOMPARE(r.width(), sectionSize * 2); // 2 columns
+ tw.header()->moveSection(1, 0);
+ r = tw.visualItemRect(item);
+ QCOMPARE(r.width(), sectionSize * 2); // 2 columns
+ tw.hideColumn(0);
+ r = tw.visualItemRect(item);
+ QCOMPARE(r.width(), sectionSize);
+}
+
QTEST_MAIN(tst_QTreeWidget)
#include "tst_qtreewidget.moc"
diff --git a/tests/auto/widgets/kernel/kernel.pro b/tests/auto/widgets/kernel/kernel.pro
index 20720dc928..73fd934502 100644
--- a/tests/auto/widgets/kernel/kernel.pro
+++ b/tests/auto/widgets/kernel/kernel.pro
@@ -6,6 +6,7 @@ SUBDIRS=\
qboxlayout \
qdesktopwidget \
qformlayout \
+ qgesturerecognizer \
qgridlayout \
qlayout \
qstackedlayout \
@@ -19,4 +20,7 @@ SUBDIRS=\
qshortcut \
qsizepolicy
+darwin:SUBDIRS -= \ # Uses native recognizers
+ qgesturerecognizer \
+
SUBDIRS -= qsound
diff --git a/tests/auto/widgets/kernel/qaction/BLACKLIST b/tests/auto/widgets/kernel/qaction/BLACKLIST
deleted file mode 100644
index 1ad524fdbf..0000000000
--- a/tests/auto/widgets/kernel/qaction/BLACKLIST
+++ /dev/null
@@ -1,2 +0,0 @@
-[setStandardKeys]
-linux
diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
index 88ddb7c11d..ddf9ccb416 100644
--- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
+++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
@@ -64,6 +64,7 @@ private slots:
void task229128TriggeredSignalWhenInActiongroup();
void repeat();
void setData();
+ void keysequence(); // QTBUG-53381
void disableShortcutsWithBlockedWidgets_data();
void disableShortcutsWithBlockedWidgets();
@@ -239,7 +240,7 @@ void tst_QAction::setStandardKeys()
expected << ctrlC << ctrlInsert;
break;
default: // X11
- expected << ctrlC << QKeySequence(QStringLiteral("F16")) << ctrlInsert;
+ expected << ctrlC << ctrlInsert << QKeySequence(QStringLiteral("F16"));
break;
}
@@ -280,6 +281,40 @@ void tst_QAction::alternateShortcuts()
QTest::keyClick(&testWidget, Qt::Key_A, Qt::ControlModifier);
}
+void tst_QAction::keysequence()
+{
+ MyWidget testWidget(this);
+ testWidget.show();
+ QApplication::setActiveWindow(&testWidget);
+
+ {
+ QAction act(&testWidget);
+ testWidget.addAction(&act);
+
+ QKeySequence ks(QKeySequence::SelectAll);
+
+ act.setShortcut(ks);
+
+ QSignalSpy spy(&act, &QAction::triggered);
+
+ act.setAutoRepeat(true);
+ QTest::keySequence(&testWidget, ks);
+ QCoreApplication::processEvents();
+ QCOMPARE(spy.count(), 1); // act should have been triggered
+
+ act.setAutoRepeat(false);
+ QTest::keySequence(&testWidget, ks);
+ QCoreApplication::processEvents();
+ QCOMPARE(spy.count(), 2); //act should have been triggered a 2nd time
+
+ // end of the scope of the action, it will be destroyed and removed from widget
+ // This action should also unregister its shortcuts
+ }
+
+ // this tests a crash (if the action did not unregister its alternate shortcuts)
+ QTest::keyClick(&testWidget, Qt::Key_A, Qt::ControlModifier);
+}
+
void tst_QAction::enabledVisibleInteraction()
{
MyWidget testWidget(this);
@@ -319,7 +354,7 @@ void tst_QAction::enabledVisibleInteraction()
void tst_QAction::task200823_tooltip()
{
- const QScopedPointer<QAction> action(new QAction("foo", Q_NULLPTR));
+ const QScopedPointer<QAction> action(new QAction("foo", nullptr));
QString shortcut("ctrl+o");
action->setShortcut(shortcut);
@@ -333,7 +368,7 @@ void tst_QAction::task200823_tooltip()
void tst_QAction::task229128TriggeredSignalWithoutActiongroup()
{
// test without a group
- const QScopedPointer<QAction> actionWithoutGroup(new QAction("Test", Q_NULLPTR));
+ const QScopedPointer<QAction> actionWithoutGroup(new QAction("Test", nullptr));
QSignalSpy spyWithoutGroup(actionWithoutGroup.data(), SIGNAL(triggered(bool)));
QCOMPARE(spyWithoutGroup.count(), 0);
actionWithoutGroup->trigger();
diff --git a/tests/auto/widgets/kernel/qactiongroup/BLACKLIST b/tests/auto/widgets/kernel/qactiongroup/BLACKLIST
deleted file mode 100644
index fdc424b6ac..0000000000
--- a/tests/auto/widgets/kernel/qactiongroup/BLACKLIST
+++ /dev/null
@@ -1,2 +0,0 @@
-[QTBUG_14292_filesystem]
-linux
diff --git a/tests/auto/widgets/kernel/qapplication/BLACKLIST b/tests/auto/widgets/kernel/qapplication/BLACKLIST
deleted file mode 100644
index f4a9cb6166..0000000000
--- a/tests/auto/widgets/kernel/qapplication/BLACKLIST
+++ /dev/null
@@ -1,2 +0,0 @@
-[quitOnLastWindowClosed]
-osx-10.10
diff --git a/tests/auto/widgets/kernel/qapplication/test/BLACKLIST b/tests/auto/widgets/kernel/qapplication/test/BLACKLIST
deleted file mode 100644
index f4a9cb6166..0000000000
--- a/tests/auto/widgets/kernel/qapplication/test/BLACKLIST
+++ /dev/null
@@ -1,2 +0,0 @@
-[quitOnLastWindowClosed]
-osx-10.10
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index 6ff38abdb8..c70ac0309f 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -2214,7 +2214,7 @@ void tst_QApplication::staticFunctions()
QApplication::activeModalWidget();
QApplication::focusWidget();
QApplication::activeWindow();
- QApplication::setActiveWindow(Q_NULLPTR);
+ QApplication::setActiveWindow(nullptr);
QApplication::widgetAt(QPoint(0, 0));
QApplication::topLevelAt(QPoint(0, 0));
QApplication::setGlobalStrut(QSize(0, 0));
diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
index 1dac242114..2f1a305710 100644
--- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
+++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
@@ -156,7 +156,7 @@ void tst_QBoxLayout::sizeHint()
lay1->addLayout(lay2);
window.setLayout(lay1);
window.show();
- QTest::qWaitForWindowExposed(&window);
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
label->setText("foooooooo baaaaaaar");
QSize sh = lay1->sizeHint();
QApplication::processEvents();
@@ -177,7 +177,7 @@ void tst_QBoxLayout::sizeConstraints()
lay->setSizeConstraint(QLayout::SetFixedSize);
window.setLayout(lay);
window.show();
- QTest::qWaitForWindowExposed(&window);
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
QSize sh = window.sizeHint();
delete lay->takeAt(1);
QVERIFY(sh.width() >= window.sizeHint().width() &&
@@ -224,7 +224,7 @@ void tst_QBoxLayout::setStyleShouldChangeSpacing()
style1->hspacing = 6;
window.setStyle(style1.data());
window.show();
- QTest::qWaitForWindowExposed(&window);
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
int spacing = pb2->geometry().left() - pb1->geometry().right() - 1;
QCOMPARE(spacing, 6);
@@ -293,7 +293,7 @@ void tst_QBoxLayout::taskQTBUG_40609_addingWidgetToItsOwnLayout(){
layout.setObjectName("ef9e2b42298e0e6420105bb");
QTest::ignoreMessage(QtWarningMsg, "QLayout: Cannot add a null widget to QVBoxLayout/ef9e2b42298e0e6420105bb");
- layout.addWidget(Q_NULLPTR);
+ layout.addWidget(nullptr);
QCOMPARE(layout.count(), 0);
QTest::ignoreMessage(QtWarningMsg, "QLayout: Cannot add parent widget QWidget/347b469225a24a0ef05150a to its child layout QVBoxLayout/ef9e2b42298e0e6420105bb");
@@ -309,7 +309,7 @@ void tst_QBoxLayout::taskQTBUG_40609_addingLayoutToItself(){
layout.setObjectName("cc751dd0f50f62b05a62da");
QTest::ignoreMessage(QtWarningMsg, "QLayout: Cannot add a null layout to QVBoxLayout/cc751dd0f50f62b05a62da");
- layout.addLayout(Q_NULLPTR);
+ layout.addLayout(nullptr);
QCOMPARE(layout.count(), 0);
QTest::ignoreMessage(QtWarningMsg, "QLayout: Cannot add layout QVBoxLayout/cc751dd0f50f62b05a62da to itself");
diff --git a/tests/auto/widgets/gestures/qgesturerecognizer/BLACKLIST b/tests/auto/widgets/kernel/qgesturerecognizer/BLACKLIST
index 7f55c2dae0..7f55c2dae0 100644
--- a/tests/auto/widgets/gestures/qgesturerecognizer/BLACKLIST
+++ b/tests/auto/widgets/kernel/qgesturerecognizer/BLACKLIST
diff --git a/tests/auto/widgets/gestures/qgesturerecognizer/qgesturerecognizer.pro b/tests/auto/widgets/kernel/qgesturerecognizer/qgesturerecognizer.pro
index 7c9ddcfb03..7c9ddcfb03 100644
--- a/tests/auto/widgets/gestures/qgesturerecognizer/qgesturerecognizer.pro
+++ b/tests/auto/widgets/kernel/qgesturerecognizer/qgesturerecognizer.pro
diff --git a/tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp b/tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp
index c3ebb838bb..bcf48c21df 100644
--- a/tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp
+++ b/tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp
@@ -84,7 +84,7 @@ public:
{ return m_receivedGestures.value(gestureType); }
protected:
- bool event(QEvent * event) Q_DECL_OVERRIDE;
+ bool event(QEvent * event) override;
private:
typedef QHash<Qt::GestureType, bool> GestureTypeHash;
diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
index 37e2bdb069..40a2319910 100644
--- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
+++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
@@ -336,7 +336,7 @@ void tst_QGridLayout::setMinAndMaxSize()
layout.removeItem(spacer);
delete spacer;
- spacer = Q_NULLPTR;
+ spacer = nullptr;
rightChild.hide();
QApplication::sendPostedEvents(0, 0);
@@ -1624,7 +1624,7 @@ void tst_QGridLayout::taskQTBUG_40609_addingWidgetToItsOwnLayout(){
layout.setObjectName("d631e91a35f2b66a6dff35");
QTest::ignoreMessage(QtWarningMsg, "QLayout: Cannot add a null widget to QGridLayout/d631e91a35f2b66a6dff35");
- layout.addWidget(Q_NULLPTR, 0, 0);
+ layout.addWidget(nullptr, 0, 0);
QCOMPARE(layout.count(), 0);
QTest::ignoreMessage(QtWarningMsg, "QLayout: Cannot add parent widget QWidget/9bb37ca762aeb7269b8 to its child layout QGridLayout/d631e91a35f2b66a6dff35");
@@ -1639,7 +1639,7 @@ void tst_QGridLayout::taskQTBUG_40609_addingLayoutToItself(){
layout.setObjectName("5d79e1b0aed83f100e3c2");
QTest::ignoreMessage(QtWarningMsg, "QLayout: Cannot add a null layout to QGridLayout/5d79e1b0aed83f100e3c2");
- layout.addLayout(Q_NULLPTR, 0, 0);
+ layout.addLayout(nullptr, 0, 0);
QCOMPARE(layout.count(), 0);
QTest::ignoreMessage(QtWarningMsg, "QLayout: Cannot add layout QGridLayout/5d79e1b0aed83f100e3c2 to itself");
diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
index 9d0c939d84..ff35b0cdb1 100644
--- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
+++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
@@ -1105,7 +1105,7 @@ public:
int overrideCount;
- bool event(QEvent *e) Q_DECL_OVERRIDE
+ bool event(QEvent *e) override
{
if (e->type() == QEvent::ShortcutOverride)
overrideCount++;
diff --git a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp
index d50f46cc16..eb3264be53 100644
--- a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp
+++ b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp
@@ -60,7 +60,7 @@ private:
struct PrettyPrint {
const char *m_s;
template <typename T>
- explicit PrettyPrint(const T &t) : m_s(Q_NULLPTR)
+ explicit PrettyPrint(const T &t) : m_s(nullptr)
{
using QT_PREPEND_NAMESPACE(QTest)::toString;
m_s = toString(t);
diff --git a/tests/auto/widgets/kernel/qtooltip/BLACKLIST b/tests/auto/widgets/kernel/qtooltip/BLACKLIST
deleted file mode 100644
index f8d062cc46..0000000000
--- a/tests/auto/widgets/kernel/qtooltip/BLACKLIST
+++ /dev/null
@@ -1,4 +0,0 @@
-[whatsThis]
-ubuntu-14.04
-[task183679]
-opensuse-13.1
diff --git a/tests/auto/widgets/kernel/qtooltip/tst_qtooltip.cpp b/tests/auto/widgets/kernel/qtooltip/tst_qtooltip.cpp
index c163117ef3..86736bb082 100644
--- a/tests/auto/widgets/kernel/qtooltip/tst_qtooltip.cpp
+++ b/tests/auto/widgets/kernel/qtooltip/tst_qtooltip.cpp
@@ -129,7 +129,7 @@ static QWidget *findWhatsThat()
if (widget->inherits("QWhatsThat"))
return widget;
}
- return Q_NULLPTR;
+ return nullptr;
}
void tst_QToolTip::whatsThis()
@@ -137,7 +137,7 @@ void tst_QToolTip::whatsThis()
qApp->setStyleSheet( "QWidget { font-size: 72px; }" );
QWhatsThis::showText(QPoint(0, 0), "This is text");
- QWidget *whatsthis = Q_NULLPTR;
+ QWidget *whatsthis = nullptr;
QTRY_VERIFY( (whatsthis = findWhatsThat()) );
QVERIFY(whatsthis->isVisible());
const int whatsThisHeight = whatsthis->height();
diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST
index a04a67e4be..c822539966 100644
--- a/tests/auto/widgets/kernel/qwidget/BLACKLIST
+++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST
@@ -1,30 +1,18 @@
# OSX QTBUG-25300 QTBUG-45502
[normalGeometry]
-ubuntu-14.04
ubuntu-16.04
[saveRestoreGeometry]
-ubuntu-14.04
ubuntu-16.04
b2qt
[restoreVersion1Geometry]
xcb
osx
[updateWhileMinimized]
-ubuntu-14.04
ubuntu-16.04
-rhel-7.1
-rhel-7.2
-rhel-7.3
rhel-7.4
osx
[focusProxyAndInputMethods]
linux
-[touchEventSynthesizedMouseEvent]
-ubuntu-14.04
-[grabMouse]
-ubuntu-14.04
-[largerThanScreen_QTBUG30142]
-ubuntu-14.04
[showMaximized]
osx
[setGeometry]
@@ -48,7 +36,6 @@ osx
[render_systemClip]
osx
[showMinimizedKeepsFocus]
-osx-10.10
osx-10.11 ci
osx-10.12 ci
[moveWindowInShowEvent:1]
@@ -61,10 +48,7 @@ osx
osx
[maskedUpdate]
osx
-opensuse-42.1
opensuse-42.3
-[hideWhenFocusWidgetIsChild]
-osx-10.10
[hideOpaqueChildWhileHidden]
osx
[resizeStaticContentsChildWidget_QTBUG35282]
@@ -74,10 +58,10 @@ osx
[setClearAndResizeMask]
osx
[setToolTip]
-osx-10.9
-[moveInResizeEvent]
-ubuntu-14.04
+osx
[moveChild:right]
osx
[activateWindow]
osx-10.12 ci
+[multipleToplevelFocusCheck]
+linux
diff --git a/tests/auto/widgets/kernel/qwidget/qwidget.pro b/tests/auto/widgets/kernel/qwidget/qwidget.pro
index 3e4e96760b..c1908af2a2 100644
--- a/tests/auto/widgets/kernel/qwidget/qwidget.pro
+++ b/tests/auto/widgets/kernel/qwidget/qwidget.pro
@@ -12,7 +12,7 @@ aix-g++*:QMAKE_CXXFLAGS+=-fpermissive
CONFIG += x11inc
mac {
- LIBS += -framework Security -framework AppKit -framework Carbon
+ LIBS += -framework Security -framework AppKit
OBJECTIVE_SOURCES += tst_qwidget_mac_helpers.mm
}
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index c1bff5b00a..5a9c5dd175 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -50,6 +50,7 @@
#include <qcalendarwidget.h>
#include <qmainwindow.h>
#include <qdockwidget.h>
+#include <qrandom.h>
#include <qtoolbar.h>
#include <qtoolbutton.h>
#include <QtGui/qpaintengine.h>
@@ -183,7 +184,10 @@ private slots:
void mapFromAndTo();
void focusChainOnHide();
void focusChainOnReparent();
- void setTabOrder();
+ void defaultTabOrder();
+ void reverseTabOrder();
+ void tabOrderWithProxy();
+ void tabOrderWithCompoundWidgets();
#ifdef Q_OS_WIN
void activation();
#endif
@@ -1650,79 +1654,281 @@ public:
class Composite : public QFrame
{
public:
- Composite(QWidget* parent = 0, const char* name = 0)
+ Composite(QWidget* parent = 0, const QString &name = 0)
: QFrame(parent)
{
setObjectName(name);
- //QHBoxLayout* hbox = new QHBoxLayout(this, 2, 0);
- //hbox->setAutoAdd(true);
+
+ lineEdit1 = new QLineEdit;
+ lineEdit2 = new QLineEdit;
+ lineEdit3 = new QLineEdit;
+ lineEdit3->setEnabled(false);
+
QHBoxLayout* hbox = new QHBoxLayout(this);
+ hbox->addWidget(lineEdit1);
+ hbox->addWidget(lineEdit2);
+ hbox->addWidget(lineEdit3);
+ }
- lineEdit = new QLineEdit(this);
- hbox->addWidget(lineEdit);
+public:
+ QLineEdit *lineEdit1;
+ QLineEdit *lineEdit2;
+ QLineEdit *lineEdit3;
+};
- button = new QPushButton(this);
- hbox->addWidget(button);
- button->setFocusPolicy( Qt::NoFocus );
+void tst_QWidget::defaultTabOrder()
+{
+ const int compositeCount = 2;
+ Container container;
+ Composite *composite[compositeCount];
- setFocusProxy( lineEdit );
- setFocusPolicy( Qt::StrongFocus );
+ QLineEdit *firstEdit = new QLineEdit;
+ container.box->addWidget(firstEdit);
- setTabOrder(lineEdit, button);
+ for (int i = 0; i < compositeCount; i++) {
+ composite[i] = new Composite();
+ container.box->addWidget(composite[i]);
}
-private:
- QLineEdit* lineEdit;
- QPushButton* button;
-};
+ QLineEdit *lastEdit = new QLineEdit();
+ container.box->addWidget(lastEdit);
-#define NUM_WIDGETS 4
+ container.show();
+ container.activateWindow();
+ qApp->setActiveWindow(&container);
+ QVERIFY(QTest::qWaitForWindowActive(&container));
-void tst_QWidget::setTabOrder()
-{
- QTest::qWait(100);
+ QTRY_VERIFY(firstEdit->hasFocus());
+ // Check that focus moves between the line edits when we tab forward
+ for (int i = 0; i < compositeCount; ++i) {
+ container.tab();
+ QVERIFY(composite[i]->lineEdit1->hasFocus());
+ QVERIFY(!composite[i]->lineEdit2->hasFocus());
+ container.tab();
+ QVERIFY(!composite[i]->lineEdit1->hasFocus());
+ QVERIFY(composite[i]->lineEdit2->hasFocus());
+ }
+
+ container.tab();
+ QVERIFY(lastEdit->hasFocus());
+
+ // Check that focus moves between the line edits in reverse
+ // order when we tab backwards
+ for (int i = compositeCount - 1; i >= 0; --i) {
+ container.backTab();
+ QVERIFY(!composite[i]->lineEdit1->hasFocus());
+ QVERIFY(composite[i]->lineEdit2->hasFocus());
+
+ container.backTab();
+ QVERIFY(composite[i]->lineEdit1->hasFocus());
+ QVERIFY(!composite[i]->lineEdit2->hasFocus());
+ }
+
+ container.backTab();
+ QVERIFY(firstEdit->hasFocus());
+}
+
+void tst_QWidget::reverseTabOrder()
+{
+ const int compositeCount = 2;
Container container;
- container.setObjectName("setTabOrder");
- container.setWindowTitle(container.objectName());
+ Composite* composite[compositeCount];
+
+ QLineEdit *firstEdit = new QLineEdit();
+ container.box->addWidget(firstEdit);
+
+ for (int i = 0; i < compositeCount; i++) {
+ composite[i] = new Composite();
+ container.box->addWidget(composite[i]);
+ }
+
+ QLineEdit *lastEdit = new QLineEdit();
+ container.box->addWidget(lastEdit);
- Composite* comp[NUM_WIDGETS];
+ // Reverse tab order inside each composite
+ for (int i = 0; i < compositeCount; ++i)
+ QWidget::setTabOrder(composite[i]->lineEdit2, composite[i]->lineEdit1);
- QLineEdit *firstEdit = new QLineEdit(&container);
+ container.show();
+ container.activateWindow();
+ qApp->setActiveWindow(&container);
+ QVERIFY(QTest::qWaitForWindowActive(&container));
+
+ QTRY_VERIFY(firstEdit->hasFocus());
+
+ // Check that focus moves in reverse order when tabbing inside the composites
+ // (but in the correct order when tabbing between them)
+ for (int i = 0; i < compositeCount; ++i) {
+ container.tab();
+ QVERIFY(!composite[i]->lineEdit1->hasFocus());
+ QVERIFY(composite[i]->lineEdit2->hasFocus());
+ container.tab();
+ QVERIFY(composite[i]->lineEdit1->hasFocus());
+ QVERIFY(!composite[i]->lineEdit2->hasFocus());
+ }
+
+ container.tab();
+ QVERIFY(lastEdit->hasFocus());
+
+ // Check that focus moves in "normal" order when tabbing backwards inside the
+ // composites (since backwards of reversed order cancels each other out),
+ // but in the reverse order when tabbing between them.
+ for (int i = compositeCount - 1; i >= 0; --i) {
+ container.backTab();
+ QVERIFY(composite[i]->lineEdit1->hasFocus());
+ QVERIFY(!composite[i]->lineEdit2->hasFocus());
+ container.backTab();
+ QVERIFY(!composite[i]->lineEdit1->hasFocus());
+ QVERIFY(composite[i]->lineEdit2->hasFocus());
+ }
+
+ container.backTab();
+ QVERIFY(firstEdit->hasFocus());
+}
+
+void tst_QWidget::tabOrderWithProxy()
+{
+ const int compositeCount = 2;
+ Container container;
+ Composite* composite[compositeCount];
+
+ QLineEdit *firstEdit = new QLineEdit();
container.box->addWidget(firstEdit);
- int i = 0;
- for(i = 0; i < NUM_WIDGETS; i++) {
- comp[i] = new Composite(&container);
- container.box->addWidget(comp[i]);
+ for (int i = 0; i < compositeCount; i++) {
+ composite[i] = new Composite();
+ container.box->addWidget(composite[i]);
+
+ // Set second child as focus proxy
+ composite[i]->setFocusPolicy(Qt::StrongFocus);
+ composite[i]->setFocusProxy(composite[i]->lineEdit2);
}
- QLineEdit *lastEdit = new QLineEdit(&container);
+ QLineEdit *lastEdit = new QLineEdit();
container.box->addWidget(lastEdit);
- container.setTabOrder(lastEdit, comp[NUM_WIDGETS-1]);
- for(i = NUM_WIDGETS-1; i > 0; i--) {
- container.setTabOrder(comp[i], comp[i-1]);
+ container.show();
+ container.activateWindow();
+ qApp->setActiveWindow(&container);
+ QVERIFY(QTest::qWaitForWindowActive(&container));
+
+ QTRY_VERIFY(firstEdit->hasFocus());
+
+ // Check that focus moves between the second line edits
+ // (the focus proxies) when we tab forward
+ for (int i = 0; i < compositeCount; ++i) {
+ container.tab();
+ QVERIFY(!composite[i]->lineEdit1->hasFocus());
+ QVERIFY(composite[i]->lineEdit2->hasFocus());
}
- container.setTabOrder(comp[0], firstEdit);
- int current = NUM_WIDGETS-1;
- lastEdit->setFocus();
+ container.tab();
+ QVERIFY(lastEdit->hasFocus());
+
+ // Check that focus moves between the line edits
+ // in reverse order when we tab backwards.
+ // Note that in this case, the focus proxies should not
+ // be taken into consideration, since they only take
+ // effect when tabbing forward
+ for (int i = compositeCount - 1; i >= 0; --i) {
+ container.backTab();
+ QVERIFY(!composite[i]->lineEdit1->hasFocus());
+ QVERIFY(composite[i]->lineEdit2->hasFocus());
+ container.backTab();
+ QVERIFY(composite[i]->lineEdit1->hasFocus());
+ QVERIFY(!composite[i]->lineEdit2->hasFocus());
+ }
+
+ container.backTab();
+ QVERIFY(firstEdit->hasFocus());
+}
+
+void tst_QWidget::tabOrderWithCompoundWidgets()
+{
+ const int compositeCount = 4;
+ Container container;
+ Composite *composite[compositeCount];
+
+ QLineEdit *firstEdit = new QLineEdit();
+ container.box->addWidget(firstEdit);
+
+ for (int i = 0; i < compositeCount; i++) {
+ composite[i] = new Composite(0, QStringLiteral("Composite: ") + QString::number(i));
+ container.box->addWidget(composite[i]);
+
+ // Let the composite handle focus, and set a child as focus proxy (use the second child, just
+ // to ensure that we don't just tab to the first child by coinsidence). This will make the
+ // composite "compound". Also enable the last line edit to have a bit more data to check when
+ // tabbing forwards.
+ composite[i]->setFocusPolicy(Qt::StrongFocus);
+ composite[i]->setFocusProxy(composite[i]->lineEdit2);
+ composite[i]->lineEdit3->setEnabled(true);
+ }
+
+ QLineEdit *lastEdit = new QLineEdit();
+ container.box->addWidget(lastEdit);
+
+ // Reverse tab order between each composite
+ // (but not inside them), including first and last line edit.
+ // The result should not affect local tab order inside each
+ // composite, only between them.
+ QWidget::setTabOrder(lastEdit, composite[compositeCount - 1]);
+ for (int i = compositeCount - 1; i >= 1; --i)
+ QWidget::setTabOrder(composite[i], composite[i-1]);
+ QWidget::setTabOrder(composite[0], firstEdit);
container.show();
container.activateWindow();
qApp->setActiveWindow(&container);
QVERIFY(QTest::qWaitForWindowActive(&container));
+ lastEdit->setFocus();
QTRY_VERIFY(lastEdit->hasFocus());
- container.tab();
- do {
- QVERIFY(comp[current]->focusProxy()->hasFocus());
+
+ // Check that focus moves between the line edits in the normal
+ // order when tabbing inside each compound, but in the reverse
+ // order when tabbing between them. Since the composites have
+ // lineEdit2 as focus proxy, lineEdit2 will be the first with focus
+ // when the compound gets focus, and lineEdit1 will therefore be skipped.
+ for (int i = compositeCount - 1; i >= 0; --i) {
+ container.tab();
+ Composite *c = composite[i];
+ QVERIFY(!c->lineEdit1->hasFocus());
+ QVERIFY(c->lineEdit2->hasFocus());
+ QVERIFY(!c->lineEdit3->hasFocus());
container.tab();
- current--;
- } while (current >= 0);
+ QVERIFY(!c->lineEdit1->hasFocus());
+ QVERIFY(!c->lineEdit2->hasFocus());
+ QVERIFY(c->lineEdit3->hasFocus());
+ }
+ container.tab();
QVERIFY(firstEdit->hasFocus());
+
+ // Check that focus moves in reverse order when backTab inside the composites, but
+ // in the 'correct' order when backTab between them (since the composites are in reverse tab
+ // order from before, which cancels it out). Note that when we backtab into a compound, we start
+ // at lineEdit3 rather than the focus proxy, since that is the reverse of what happens when we tab
+ // forward. And this time we will also backtab to lineEdit1, since there is no focus proxy that interferes.
+ for (int i = 0; i < compositeCount; ++i) {
+ container.backTab();
+ Composite *c = composite[i];
+ QVERIFY(!c->lineEdit1->hasFocus());
+ QVERIFY(!c->lineEdit2->hasFocus());
+ QVERIFY(c->lineEdit3->hasFocus());
+ container.backTab();
+ QVERIFY(!c->lineEdit1->hasFocus());
+ QVERIFY(c->lineEdit2->hasFocus());
+ QVERIFY(!c->lineEdit3->hasFocus());
+ container.backTab();
+ QVERIFY(c->lineEdit1->hasFocus());
+ QVERIFY(!c->lineEdit2->hasFocus());
+ QVERIFY(!c->lineEdit3->hasFocus());
+ }
+
+ container.backTab();
+ QVERIFY(lastEdit->hasFocus());
}
#ifdef Q_OS_WIN
@@ -1787,9 +1993,11 @@ void tst_QWidget::windowState()
QCOMPARE(widget1.pos(), pos);
QCOMPARE(widget1.size(), size);
-#define VERIFY_STATE(s) QCOMPARE(int(widget1.windowState() & stateMask), int(s))
+#define VERIFY_STATE(s) \
+ QCOMPARE(int(widget1.windowState() & stateMask), int(s)); \
+ QCOMPARE(int(widget1.windowHandle()->windowStates() & stateMask), int(s))
- const int stateMask = Qt::WindowMaximized|Qt::WindowMinimized|Qt::WindowFullScreen;
+ const auto stateMask = Qt::WindowMaximized | Qt::WindowMinimized | Qt::WindowFullScreen;
widget1.setWindowState(Qt::WindowMaximized);
QTest::qWait(100);
@@ -2079,7 +2287,7 @@ void tst_QWidget::resizeEvent()
wParent.resize(200, 200);
ResizeWidget wChild(&wParent);
wParent.show();
- QTest::qWaitForWindowExposed(&wParent);
+ QVERIFY(QTest::qWaitForWindowExposed(&wParent));
QCOMPARE (wChild.m_resizeEventCount, 1); // initial resize event before paint
wParent.hide();
QSize safeSize(640,480);
@@ -2095,7 +2303,7 @@ void tst_QWidget::resizeEvent()
ResizeWidget wTopLevel;
wTopLevel.resize(200, 200);
wTopLevel.show();
- QTest::qWaitForWindowExposed(&wTopLevel);
+ QVERIFY(QTest::qWaitForWindowExposed(&wTopLevel));
QCOMPARE (wTopLevel.m_resizeEventCount, 1); // initial resize event before paint for toplevels
wTopLevel.hide();
QSize safeSize(640,480);
@@ -2104,7 +2312,7 @@ void tst_QWidget::resizeEvent()
wTopLevel.resize(safeSize);
QCOMPARE (wTopLevel.m_resizeEventCount, 1);
wTopLevel.show();
- QTest::qWaitForWindowExposed(&wTopLevel);
+ QVERIFY(QTest::qWaitForWindowExposed(&wTopLevel));
QCOMPARE (wTopLevel.m_resizeEventCount, 2);
}
}
@@ -3498,7 +3706,7 @@ public:
gotPaintEvent = true;
// qDebug() << "paint" << e->region();
// Look for a full update, set partial to false if found.
- foreach(QRect r, e->region().rects()) {
+ for (QRect r : e->region()) {
partial = (r != rect());
if (partial == false)
break;
@@ -4937,13 +5145,12 @@ static QPixmap grabWindow(QWindow *window, int x, int y, int width, int height)
bool verifyColor(QWidget &child, const QRegion &region, const QColor &color, unsigned int callerLine)
{
- const QRegion r = QRegion(region);
QWindow *window = child.window()->windowHandle();
Q_ASSERT(window);
const QPoint offset = child.mapTo(child.window(), QPoint(0,0));
bool grabBackingStore = false;
- for (int i = 0; i < r.rects().size(); ++i) {
- QRect rect = r.rects().at(i).translated(offset);
+ for (QRect r : region) {
+ QRect rect = r.translated(offset);
for (int t = 0; t < 6; t++) {
const QPixmap pixmap = grabBackingStore
? child.grab(rect)
@@ -4968,7 +5175,7 @@ bool verifyColor(QWidget &child, const QRegion &region, const QColor &color, uns
} else {
if (t == 4) {
grabBackingStore = true;
- rect = r.rects().at(i);
+ rect = r;
} else {
QTest::qWait(200);
}
@@ -5857,7 +6064,7 @@ public:
startTimer(1000);
}
- void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE
+ void timerEvent(QTimerEvent *) override
{
switch (state++) {
case 0:
@@ -5880,7 +6087,7 @@ public:
return false;
}
- bool nativeEvent(const QByteArray &eventType, void *message, long *) Q_DECL_OVERRIDE
+ bool nativeEvent(const QByteArray &eventType, void *message, long *) override
{
if (isMapNotify(eventType, message))
gotExpectedMapNotify = true;
@@ -5888,7 +6095,7 @@ public:
}
// QAbstractNativeEventFilter interface
- bool nativeEventFilter(const QByteArray &eventType, void *message, long *) Q_DECL_OVERRIDE
+ bool nativeEventFilter(const QByteArray &eventType, void *message, long *) override
{
if (isMapNotify(eventType, message))
gotExpectedGlobalEvent = true;
@@ -8014,7 +8221,7 @@ public:
QPainter p(this);
paintedRegion += event->region();
- foreach(QRect r, event->region().rects())
+ for (const QRect &r : event->region())
p.fillRect(r, Qt::red);
}
@@ -8060,8 +8267,8 @@ void tst_QWidget::setMaskInResizeEvent()
QRegion expectedParentUpdate(0, 0, 100, 10); // Old testWidget area.
expectedParentUpdate += testWidget.geometry(); // New testWidget area.
- QCOMPARE(w.paintedRegion, expectedParentUpdate);
- QCOMPARE(testWidget.paintedRegion, testWidget.mask());
+ QTRY_COMPARE(w.paintedRegion, expectedParentUpdate);
+ QTRY_COMPARE(testWidget.paintedRegion, testWidget.mask());
testWidget.paintedRegion = QRegion();
// Now resize the widget again, but in the oposite direction
@@ -8525,7 +8732,7 @@ public:
QPainter p(this);
paintedRegion += event->region();
- foreach(QRect r, event->region().rects())
+ for (const QRect &r : event->region())
p.fillRect(r, Qt::red);
}
@@ -9609,7 +9816,7 @@ void tst_QWidget::grab()
for (int row = 0; row < image.height(); ++row) {
QRgb *line = reinterpret_cast<QRgb *>(image.scanLine(row));
for (int col = 0; col < image.width(); ++col)
- line[col] = qRgba(rand() & 255, row, col, opaque ? 255 : 127);
+ line[col] = qRgba(QRandomGenerator::global()->bounded(255), row, col, opaque ? 255 : 127);
}
QPalette pal = widget.palette();
@@ -10313,7 +10520,7 @@ public slots:
QTimer::singleShot(100, this, SLOT(doMouseMoves()));
modal->exec();
delete modal;
- modal = Q_NULLPTR;
+ modal = nullptr;
}
void doMouseMoves()
@@ -10386,7 +10593,7 @@ class KeyboardWidget : public QWidget
{
public:
KeyboardWidget(QWidget* parent = 0) : QWidget(parent), m_eventCounter(0) {}
- virtual void mousePressEvent(QMouseEvent* ev) Q_DECL_OVERRIDE {
+ virtual void mousePressEvent(QMouseEvent* ev) override {
m_modifiers = ev->modifiers();
m_appModifiers = QApplication::keyboardModifiers();
++m_eventCounter;
@@ -10489,6 +10696,8 @@ void tst_QWidget::qmlSetParentHelper()
void tst_QWidget::testForOutsideWSRangeFlag()
{
+ QSKIP("Test assumes QWindows can have 0x0 size, see QTBUG-61953");
+
// QTBUG-49445
{
QWidget widget;
diff --git a/tests/auto/widgets/kernel/qwidget_window/BLACKLIST b/tests/auto/widgets/kernel/qwidget_window/BLACKLIST
new file mode 100644
index 0000000000..d3bfaba433
--- /dev/null
+++ b/tests/auto/widgets/kernel/qwidget_window/BLACKLIST
@@ -0,0 +1,4 @@
+[tst_resize_count]
+# QTBUG-66345
+opensuse-42.3
+ubuntu-16.04
diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
index e4564a8640..9021be1515 100644
--- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
+++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
@@ -96,6 +96,11 @@ private slots:
void QTBUG_50561_QCocoaBackingStore_paintDevice_crash();
+ void setWindowState_data();
+ void setWindowState();
+
+ void nativeShow();
+
void QTBUG_56277_resize_on_showEvent();
};
@@ -209,12 +214,12 @@ class PaintTestWidget : public QWidget
public:
int paintEventCount;
- explicit PaintTestWidget(QWidget *parent = Q_NULLPTR)
+ explicit PaintTestWidget(QWidget *parent = nullptr)
: QWidget(parent)
, paintEventCount(0)
{}
- void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE
+ void paintEvent(QPaintEvent *event) override
{
++paintEventCount;
QWidget::paintEvent(event);
@@ -687,7 +692,7 @@ public:
int resizeCount;
protected:
- void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE
+ void resizeEvent(QResizeEvent *) override
{
resizeCount++;
}
@@ -754,7 +759,7 @@ public:
, moveCount(0)
{ }
- void moveEvent(QMoveEvent *) Q_DECL_OVERRIDE
+ void moveEvent(QMoveEvent *) override
{
moveCount++;
}
@@ -793,7 +798,7 @@ public:
}
protected:
- bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE
+ bool eventFilter(QObject *o, QEvent *e) override
{
if (e->type() == filterEventType())
++eventCount;
@@ -842,7 +847,7 @@ void tst_QWidget_window::QTBUG_50561_QCocoaBackingStore_paintDevice_crash()
QMainWindow w;
w.addToolBar(new QToolBar(&w));
w.show();
- QTest::qWaitForWindowExposed(&w);
+ QVERIFY(QTest::qWaitForWindowExposed(&w));
// Simulate window system close
QCloseEvent *e = new QCloseEvent;
@@ -859,6 +864,72 @@ void tst_QWidget_window::QTBUG_50561_QCocoaBackingStore_paintDevice_crash()
w.close();
}
+void tst_QWidget_window::setWindowState_data()
+{
+ QString platformName = QGuiApplication::platformName().toLower();
+
+ QTest::addColumn<Qt::WindowStates>("state");
+ QTest::newRow("0") << Qt::WindowStates();
+ QTest::newRow("Qt::WindowMaximized") << Qt::WindowStates(Qt::WindowMaximized);
+ QTest::newRow("Qt::WindowMinimized") << Qt::WindowStates(Qt::WindowMinimized);
+ QTest::newRow("Qt::WindowFullScreen") << Qt::WindowStates(Qt::WindowFullScreen);
+
+ if (platformName != "xcb" && platformName != "windows" && !platformName.startsWith("wayland")
+ && platformName != "offscreen")
+ return; // Combination of states is not preserved on all platforms.
+ if (platformName == "xcb" && qgetenv("XDG_CURRENT_DESKTOP") != "KDE"
+ && qgetenv("XDG_CURRENT_DESKTOP") != "Unity")
+ return; // Not all window managers support state combinations.
+
+ QTest::newRow("Qt::WindowMaximized|Qt::WindowMinimized")
+ << (Qt::WindowMaximized | Qt::WindowMinimized);
+ QTest::newRow("Qt::WindowFullScreen|Qt::WindowMinimized")
+ << (Qt::WindowFullScreen | Qt::WindowMinimized);
+ QTest::newRow("Qt::WindowMaximized|Qt::WindowFullScreen")
+ << (Qt::WindowMaximized | Qt::WindowFullScreen);
+ QTest::newRow("Qt::WindowMaximized|Qt::WindowFullScreen|Qt::WindowMinimized")
+ << (Qt::WindowMaximized | Qt::WindowFullScreen | Qt::WindowMinimized);
+}
+
+void tst_QWidget_window::setWindowState()
+{
+ QFETCH(Qt::WindowStates, state);
+
+ // This tests make sure that the states are preserved when the window is shown.
+
+ QWidget w;
+ w.setWindowState(state);
+ QCOMPARE(w.windowState(), state);
+ w.show();
+ QCOMPARE(w.windowState(), state);
+ QCOMPARE(w.windowHandle()->windowStates(), state);
+ if (!(state & Qt::WindowMinimized))
+ QVERIFY(QTest::qWaitForWindowExposed(&w));
+ QTRY_COMPARE(w.windowState(), state);
+ QCOMPARE(w.windowHandle()->windowStates(), state);
+
+ // Minimizing keeps other states
+ w.showMinimized();
+ QCOMPARE(w.windowState(), state | Qt::WindowMinimized);
+ QTest::qWait(100);
+ QCOMPARE(w.windowState(), state | Qt::WindowMinimized);
+ QCOMPARE(w.windowHandle()->windowStates(), state | Qt::WindowMinimized);
+}
+
+void tst_QWidget_window::nativeShow()
+{
+ // Verify that a native widget can be shown using the QWindow::setVisible() API
+ QWidget w;
+ w.winId();
+ w.windowHandle()->setVisible(true);
+ QVERIFY(QTest::qWaitForWindowExposed(&w));
+ QVERIFY(w.isVisible());
+
+ // ... and that we can hide it
+ w.windowHandle()->setVisible(false);
+ QTRY_VERIFY(!w.isVisible());
+}
+
class ResizedOnShowEventWidget : public QWidget
{
public:
diff --git a/tests/auto/widgets/styles/qmacstyle/qmacstyle.pro b/tests/auto/widgets/styles/qmacstyle/qmacstyle.pro
index 4cd85ab7f2..90bf134ef1 100644
--- a/tests/auto/widgets/styles/qmacstyle/qmacstyle.pro
+++ b/tests/auto/widgets/styles/qmacstyle/qmacstyle.pro
@@ -1,4 +1,4 @@
CONFIG += testcase
TARGET = tst_qmacstyle
-QT += widgets testlib
+QT += widgets-private testlib
SOURCES += tst_qmacstyle.cpp
diff --git a/tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp b/tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp
index fbd1505b30..2ab2fa4c86 100644
--- a/tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp
+++ b/tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp
@@ -29,12 +29,11 @@
#include <QtTest/QtTest>
#include <QtWidgets>
+#include <private/qstylehelper_p.h>
const int N = 1;
-enum Size { Normal, Small, Mini };
-
-Q_DECLARE_METATYPE(Size);
+Q_DECLARE_METATYPE(QStyleHelper::WidgetSizePolicy);
#define CT(E) \
static const ControlType E = QSizePolicy::E;
@@ -63,7 +62,7 @@ class tst_QMacStyle : public QObject
Q_OBJECT
public:
- tst_QMacStyle() { qRegisterMetaType<Size>("Size"); }
+ tst_QMacStyle() { qRegisterMetaType<QStyleHelper::WidgetSizePolicy>("WidgetSizePolicy"); }
private slots:
void sizeHints_data();
@@ -85,27 +84,27 @@ private:
static QSize gap(QWidget *widget1, QWidget *widget2);
static int hgap(QWidget *widget1, QWidget *widget2) { return gap(widget1, widget2).width(); }
static int vgap(QWidget *widget1, QWidget *widget2) { return gap(widget1, widget2).height(); }
- static void setSize(QWidget *widget, Size size);
+ static void setSize(QWidget *widget, QStyleHelper::WidgetSizePolicy size);
static int spacing(ControlType control1, ControlType control2, Qt::Orientation orientation,
QStyleOption *option = 0, QWidget *widget = 0);
- static int hspacing(ControlType control1, ControlType control2, Size size = Normal);
- static int vspacing(ControlType control1, ControlType control2, Size size = Normal);
+ static int hspacing(ControlType control1, ControlType control2, QStyleHelper::WidgetSizePolicy size = QStyleHelper::SizeLarge);
+ static int vspacing(ControlType control1, ControlType control2, QStyleHelper::WidgetSizePolicy size = QStyleHelper::SizeLarge);
};
#define SIZE(x, y, z) \
- ((size == Normal) ? (x) : (size == Small) ? (y) : (z))
+ ((size == QStyleHelper::SizeLarge) ? (x) : (size == QStyleHelper::SizeSmall) ? (y) : (z))
void tst_QMacStyle::sizeHints_data()
{
- QTest::addColumn<Size>("size");
- QTest::newRow("normal") << Normal;
-// QTest::newRow("small") << Small;
-// QTest::newRow("mini") << Mini;
+ QTest::addColumn<QStyleHelper::WidgetSizePolicy>("size");
+ QTest::newRow("normal") << QStyleHelper::SizeLarge;
+// QTest::newRow("small") << QStyleHelper::SizeSmall;
+// QTest::newRow("mini") << QStyleHelper::SizeMini;
}
void tst_QMacStyle::sizeHints()
{
- QFETCH(Size, size);
+ QFETCH(QStyleHelper::WidgetSizePolicy, size);
QDialog w;
setSize(&w, size);
@@ -160,7 +159,7 @@ void tst_QMacStyle::sizeHints()
QPushButton cancel1("Cancel", &w);
QSize s1 = sh(&ok1);
- if (size == Normal) {
+ if (size == QStyleHelper::SizeLarge) {
// AHIG says 68, Builder does 70, and Qt seems to do 69
QVERIFY(s1.width() >= 68 && s1.width() <= 70);
}
@@ -222,7 +221,7 @@ void tst_QMacStyle::layoutMargins_data()
void tst_QMacStyle::layoutMargins()
{
- QFETCH(Size, size);
+ QFETCH(QStyleHelper::WidgetSizePolicy, size);
QWidget w;
setSize(&w, size);
@@ -235,7 +234,7 @@ void tst_QMacStyle::layoutSpacings_data()
void tst_QMacStyle::layoutSpacings()
{
- QFETCH(Size, size);
+ QFETCH(QStyleHelper::WidgetSizePolicy, size);
/*
Constraints specified by AHIG.
@@ -304,16 +303,16 @@ QSize tst_QMacStyle::gap(QWidget *widget1, QWidget *widget2)
return s + QSize(d.x(), d.y());
}
-void tst_QMacStyle::setSize(QWidget *widget, Size size)
+void tst_QMacStyle::setSize(QWidget *widget, QStyleHelper::WidgetSizePolicy size)
{
switch (size) {
- case Normal:
+ case QStyleHelper::SizeLarge:
widget->setAttribute(Qt::WA_MacNormalSize, true);
break;
- case Small:
+ case QStyleHelper::SizeSmall:
widget->setAttribute(Qt::WA_MacSmallSize, true);
break;
- case Mini:
+ case QStyleHelper::SizeMini:
widget->setAttribute(Qt::WA_MacMiniSize, true);
}
}
@@ -324,7 +323,7 @@ int tst_QMacStyle::spacing(ControlType control1, ControlType control2, Qt::Orien
return QApplication::style()->layoutSpacing(control1, control2, orientation, option, widget);
}
-int tst_QMacStyle::hspacing(ControlType control1, ControlType control2, Size size)
+int tst_QMacStyle::hspacing(ControlType control1, ControlType control2, QStyleHelper::WidgetSizePolicy size)
{
QWidget w;
setSize(&w, size);
@@ -335,7 +334,7 @@ int tst_QMacStyle::hspacing(ControlType control1, ControlType control2, Size siz
return spacing(control1, control2, Qt::Horizontal, &opt);
}
-int tst_QMacStyle::vspacing(ControlType control1, ControlType control2, Size size)
+int tst_QMacStyle::vspacing(ControlType control1, ControlType control2, QStyleHelper::WidgetSizePolicy size)
{
QWidget w;
setSize(&w, size);
diff --git a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp
index 5369101dae..e49fd701d6 100644
--- a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp
+++ b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp
@@ -82,9 +82,6 @@ private slots:
void testFusionStyle();
#endif
void testWindowsStyle();
-#if defined(Q_OS_WIN) && !defined(QT_NO_STYLE_WINDOWSXP)
- void testWindowsXPStyle();
-#endif
#if defined(Q_OS_WIN) && !defined(QT_NO_STYLE_WINDOWSVISTA)
void testWindowsVistaStyle();
#endif
@@ -142,14 +139,6 @@ void tst_QStyle::testStyleFactory()
#ifndef QT_NO_STYLE_WINDOWS
QVERIFY(keys.contains("Windows"));
#endif
-#ifdef Q_OS_WIN
- if (QSysInfo::WindowsVersion >= QSysInfo::WV_XP &&
- (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based))
- QVERIFY(keys.contains("WindowsXP"));
- if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA &&
- (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based))
- QVERIFY(keys.contains("WindowsVista"));
-#endif
foreach (QString styleName , keys) {
QStyle *style = QStyleFactory::create(styleName);
@@ -295,16 +284,22 @@ bool tst_QStyle::testAllFunctions(QStyle *style)
bool tst_QStyle::testScrollBarSubControls()
{
+ const auto *style = testWidget->style();
+ const bool isMacStyle = style->objectName().toLower() == "macintosh";
QScrollBar scrollBar;
setFrameless(&scrollBar);
scrollBar.show();
const QStyleOptionSlider opt = qt_qscrollbarStyleOption(&scrollBar);
- foreach (int subControl, QList<int>() << 1 << 2 << 4 << 8) {
- QRect sr = testWidget->style()->subControlRect(QStyle::CC_ScrollBar, &opt,
- QStyle::SubControl(subControl), &scrollBar);
+ foreach (int sc, QList<int>() << 1 << 2 << 4 << 8) {
+ const auto subControl = static_cast<QStyle::SubControl>(sc);
+ const QRect sr = style->subControlRect(QStyle::CC_ScrollBar, &opt, subControl, &scrollBar);
if (sr.isNull()) {
- qWarning("Null rect for subcontrol %d", subControl);
- return false;
+ // macOS scrollbars no longer have these, so there's no reason to fail
+ if (!(isMacStyle && (subControl == QStyle::SC_ScrollBarAddLine ||
+ subControl == QStyle::SC_ScrollBarSubLine))) {
+ qWarning() << "Unexpected null rect for subcontrol" << subControl;
+ return false;
+ }
}
}
return true;
@@ -335,17 +330,6 @@ void tst_QStyle::testWindowsStyle()
delete wstyle;
}
-#if defined(Q_OS_WIN) && !defined(QT_NO_STYLE_WINDOWSXP)
-// WindowsXP style
-void tst_QStyle::testWindowsXPStyle()
-{
- QStyle *xpstyle = QStyleFactory::create("WindowsXP");
- QVERIFY(testAllFunctions(xpstyle));
- lineUpLayoutTest(xpstyle);
- delete xpstyle;
-}
-#endif
-
void writeImage(const QString &fileName, QImage image)
{
QImageWriter imageWriter(fileName);
@@ -368,8 +352,6 @@ void tst_QStyle::testWindowsVistaStyle()
if (QSysInfo::WindowsVersion == QSysInfo::WV_VISTA)
testPainting(vistastyle, "vista");
- else if (QSysInfo::WindowsVersion == QSysInfo::WV_XP)
- testPainting(vistastyle, "xp");
delete vistastyle;
}
#endif
@@ -748,7 +730,7 @@ public:
, called(false)
{}
- void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w) const Q_DECL_OVERRIDE {
+ void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w) const override {
called = true;
return QProxyStyle::drawPrimitive(pe, opt, p, w);
}
@@ -791,74 +773,74 @@ class TestStyleOptionInitProxy: public QProxyStyle
Q_OBJECT
public:
mutable bool invalidOptionsDetected;
- explicit TestStyleOptionInitProxy(QStyle *style = Q_NULLPTR)
+ explicit TestStyleOptionInitProxy(QStyle *style = nullptr)
: QProxyStyle(style),
invalidOptionsDetected(false)
{}
- void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w) const Q_DECL_OVERRIDE {
+ void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w) const override {
checkStyleEnum<QStyle::PrimitiveElement>(pe, opt);
return QProxyStyle::drawPrimitive(pe, opt, p, w);
}
- void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w) const Q_DECL_OVERRIDE {
+ void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w) const override {
checkStyleEnum<QStyle::ControlElement>(element, opt);
return QProxyStyle::drawControl(element, opt, p, w);
}
- QRect subElementRect(SubElement subElement, const QStyleOption *option, const QWidget *widget) const Q_DECL_OVERRIDE {
+ QRect subElementRect(SubElement subElement, const QStyleOption *option, const QWidget *widget) const override {
checkStyleEnum<QStyle::SubElement>(subElement, option);
return QProxyStyle::subElementRect(subElement, option, widget);
}
- void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget) const Q_DECL_OVERRIDE {
+ void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget) const override {
checkStyleEnum<QStyle::ComplexControl>(cc, opt);
return QProxyStyle::drawComplexControl(cc, opt, p, widget);
}
- QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const Q_DECL_OVERRIDE {
+ QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const override {
checkStyleEnum<QStyle::ComplexControl>(cc, opt);
return QProxyStyle::subControlRect(cc, opt, sc, widget);
}
- int pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const Q_DECL_OVERRIDE {
+ int pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const override {
checkStyleEnum<QStyle::PixelMetric>(metric, option);
return QProxyStyle::pixelMetric(metric, option, widget);
}
- QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w) const Q_DECL_OVERRIDE {
+ QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w) const override {
checkStyleEnum<QStyle::ContentsType>(ct, opt);
return QProxyStyle::sizeFromContents(ct, opt, contentsSize, w);
}
- int styleHint(StyleHint stylehint, const QStyleOption *opt, const QWidget *widget, QStyleHintReturn *returnData) const Q_DECL_OVERRIDE {
+ int styleHint(StyleHint stylehint, const QStyleOption *opt, const QWidget *widget, QStyleHintReturn *returnData) const override {
checkStyleEnum<QStyle::StyleHint>(stylehint, opt);
return QProxyStyle::styleHint(stylehint, opt, widget, returnData);
}
- QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget) const Q_DECL_OVERRIDE {
+ QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget) const override {
checkStyleEnum<QStyle::StandardPixmap>(standardPixmap, opt);
return QProxyStyle::standardPixmap(standardPixmap, opt, widget);
}
- QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const Q_DECL_OVERRIDE {
+ QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const override {
checkStyleEnum<QStyle::StandardPixmap>(standardIcon, option);
return QProxyStyle::standardIcon(standardIcon, option, widget);
}
- QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const Q_DECL_OVERRIDE {
+ QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const override {
checkStyle(QString::asprintf("QIcon::Mode(%i)", iconMode).toLatin1(), opt);
return QProxyStyle::generatedIconPixmap(iconMode, pixmap, opt);
}
- int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option, const QWidget *widget) const Q_DECL_OVERRIDE {
+ int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option, const QWidget *widget) const override {
checkStyle(QString::asprintf("QSizePolicy::ControlType(%i), QSizePolicy::ControlType(%i)", control1, control2).toLatin1(), option);
return QProxyStyle::layoutSpacing(control1, control2, orientation, option, widget);
}
private:
void checkStyle(const QByteArray &info, const QStyleOption *opt) const {
- if (opt && (opt->version == 0 || opt->styleObject == Q_NULLPTR) ) {
+ if (opt && (opt->version == 0 || opt->styleObject == nullptr) ) {
invalidOptionsDetected = true;
qWarning() << baseStyle()->metaObject()->className()
<< "Invalid QStyleOption found for"
diff --git a/tests/auto/widgets/styles/qstylesheetstyle/BLACKLIST b/tests/auto/widgets/styles/qstylesheetstyle/BLACKLIST
index 61966e684f..6b2e4f3fb2 100644
--- a/tests/auto/widgets/styles/qstylesheetstyle/BLACKLIST
+++ b/tests/auto/widgets/styles/qstylesheetstyle/BLACKLIST
@@ -1,4 +1,2 @@
-[hoverColors]
-ubuntu-14.04
-opensuse-13.1
-opensuse-42.1
+[task232085_spinBoxLineEditBg]
+osx
diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
index 92bcd5c350..6fbb0fe5fa 100644
--- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
@@ -610,7 +610,7 @@ void tst_QCompleter::directoryModel_data()
QTest::newRow("(/et)") << "/et" << "" << "etc" << "/etc";
#else
QTest::newRow("()") << "" << "" << "/" << "/";
-#if !defined(Q_OS_IRIX) && !defined(Q_OS_AIX) && !defined(Q_OS_HPUX) && !defined(Q_OS_QNX)
+#if !defined(Q_OS_AIX) && !defined(Q_OS_HPUX) && !defined(Q_OS_QNX)
QTest::newRow("(/h)") << "/h" << "" << "home" << "/home";
#endif
QTest::newRow("(/et)") << "/et" << "" << "etc" << "/etc";
@@ -656,7 +656,7 @@ void tst_QCompleter::fileSystemModel_data()
QTest::newRow("(/et)") << "/et" << "" << "etc" << "/etc";
#else
QTest::newRow("()") << "" << "" << "/" << "/";
-#if !defined(Q_OS_IRIX) && !defined(Q_OS_AIX) && !defined(Q_OS_HPUX) && !defined(Q_OS_QNX)
+#if !defined(Q_OS_AIX) && !defined(Q_OS_HPUX) && !defined(Q_OS_QNX)
QTest::newRow("(/h)") << "/h" << "" << "home" << "/home";
#endif
QTest::newRow("(/et)") << "/et" << "" << "etc" << "/etc";
diff --git a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp b/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp
index 62c3469447..c1524d870d 100644
--- a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp
+++ b/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp
@@ -30,24 +30,6 @@
#include <QUndoStack>
#include <QAction>
-// Temporarily disabling IRIX due to build issuues with GCC
-#if defined(__sgi) && defined(__GNUC__)
-
-class tst_QUndoGroup : public QObject
-{
- Q_OBJECT
-public:
- tst_QUndoGroup() {}
-
-private slots:
- void setActive() { QSKIP( "Not tested on irix-g++"); }
- void addRemoveStack() { QSKIP( "Not tested on irix-g++"); }
- void deleteStack() { QSKIP( "Not tested on irix-g++"); }
- void checkSignals() { QSKIP( "Not tested on irix-g++"); }
- void addStackAndDie() { QSKIP( "Not tested on irix-g++"); }
-};
-#else
-
/******************************************************************************
** Commands
*/
@@ -652,7 +634,6 @@ void tst_QUndoGroup::commandTextFormat()
qApp->removeTranslator(&translator);
#endif
}
-#endif // !(SGI && GCC)
QTEST_MAIN(tst_QUndoGroup)
diff --git a/tests/auto/widgets/widgets.pro b/tests/auto/widgets/widgets.pro
index efcc47171d..8b6c4722be 100644
--- a/tests/auto/widgets/widgets.pro
+++ b/tests/auto/widgets/widgets.pro
@@ -8,4 +8,3 @@ SUBDIRS=\
styles \
util \
widgets \
- gestures \
diff --git a/tests/auto/widgets/widgets/qcombobox/BLACKLIST b/tests/auto/widgets/widgets/qcombobox/BLACKLIST
index 4a270c085b..2d6228075a 100644
--- a/tests/auto/widgets/widgets/qcombobox/BLACKLIST
+++ b/tests/auto/widgets/widgets/qcombobox/BLACKLIST
@@ -1,3 +1,3 @@
-QTBUG-45531
-[task260974_menuItemRectangleForComboBoxPopup]
-osx-10.10
+[task_QTBUG_56693_itemFontFromModel]
+# Counts draw calls, but we could have multiple expose events QTBUG-62080
+osx
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index 2195f43ef1..0c229c9194 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -164,6 +164,7 @@ private slots:
void task_QTBUG_49831_scrollerNotActivated();
void task_QTBUG_56693_itemFontFromModel();
void inputMethodUpdate();
+ void task_QTBUG_52027_mapCompleterIndex();
private:
PlatformInputContext m_platformInputContext;
@@ -2051,13 +2052,13 @@ void tst_QComboBox::mouseWheel_data()
QTest::newRow("upper locked") << disabled << start << wheel << expected;
wheel = -1;
-#ifdef Q_OS_DARWIN
+ const bool allowsWheelScroll = QApplication::style()->styleHint(QStyle::SH_ComboBox_AllowWheelScrolling);
// on OS X & iOS mouse wheel shall have no effect on combo box
- expected = start;
-#else
- // on other OSes we should jump to next enabled item (no. 5)
- expected = 5;
-#endif
+ if (!allowsWheelScroll)
+ expected = start;
+ else // on other OSes we should jump to next enabled item (no. 5)
+ expected = 5;
+
QTest::newRow("jump over") << disabled << start << wheel << expected;
disabled.clear();
@@ -2256,7 +2257,7 @@ void tst_QComboBox::task190351_layout()
listCombo.setCurrentIndex(70);
listCombo.showPopup();
QTRY_VERIFY(listCombo.view());
- QTest::qWaitForWindowExposed(listCombo.view());
+ QVERIFY(QTest::qWaitForWindowExposed(listCombo.view()));
QTRY_VERIFY(listCombo.view()->isVisible());
QApplication::processEvents();
@@ -2403,7 +2404,7 @@ void tst_QComboBox::task248169_popupWithMinimalSize()
QTRY_VERIFY(comboBox.isVisible());
comboBox.showPopup();
QTRY_VERIFY(comboBox.view());
- QTest::qWaitForWindowExposed(comboBox.view());
+ QVERIFY(QTest::qWaitForWindowExposed(comboBox.view()));
QTRY_VERIFY(comboBox.view()->isVisible());
#if defined QT_BUILD_INTERNAL
@@ -3249,12 +3250,12 @@ void tst_QComboBox::task_QTBUG_49831_scrollerNotActivated()
box.setModel(&model);
box.setCurrentIndex(500);
box.show();
- QTest::qWaitForWindowExposed(&box);
+ QVERIFY(QTest::qWaitForWindowExposed(&box));
QTest::mouseMove(&box, QPoint(5, 5), 100);
box.showPopup();
QFrame *container = box.findChild<QComboBoxPrivateContainer *>();
QVERIFY(container);
- QTest::qWaitForWindowExposed(container);
+ QVERIFY(QTest::qWaitForWindowExposed(container));
QList<QComboBoxPrivateScroller *> scrollers = container->findChildren<QComboBoxPrivateScroller *>();
// Not all styles support scrollers. We rely only on those platforms that do to catch any regression.
@@ -3272,7 +3273,7 @@ void tst_QComboBox::task_QTBUG_49831_scrollerNotActivated()
class QTBUG_56693_Model : public QStandardItemModel
{
public:
- QTBUG_56693_Model(QObject *parent = Q_NULLPTR)
+ QTBUG_56693_Model(QObject *parent = nullptr)
: QStandardItemModel(parent)
{ }
@@ -3300,7 +3301,7 @@ public:
}
- void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w = Q_NULLPTR) const override
+ void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w = nullptr) const override
{
if (element == CE_MenuItem)
if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt))
@@ -3330,11 +3331,11 @@ void tst_QComboBox::task_QTBUG_56693_itemFontFromModel()
box.addItem(QLatin1String("Item ") + QString::number(i));
box.show();
- QTest::qWaitForWindowExposed(&box);
+ QVERIFY(QTest::qWaitForWindowExposed(&box));
box.showPopup();
QFrame *container = box.findChild<QComboBoxPrivateContainer *>();
QVERIFY(container);
- QTest::qWaitForWindowExposed(container);
+ QVERIFY(QTest::qWaitForWindowExposed(container));
QCOMPARE(proxyStyle->italicItemsNo, 5);
@@ -3395,5 +3396,62 @@ void tst_QComboBox::inputMethodUpdate()
QVERIFY(m_platformInputContext.m_updateCallCount >= 1);
}
+void tst_QComboBox::task_QTBUG_52027_mapCompleterIndex()
+{
+ QStringList words;
+ words << "" << "foobar1" << "foobar2";
+
+ QStringList altWords;
+ altWords << "foobar2" << "hello" << "," << "world" << "" << "foobar0" << "foobar1";
+
+ QComboBox cbox;
+ setFrameless(&cbox);
+ cbox.setEditable(true);
+ cbox.setInsertPolicy(QComboBox::NoInsert);
+ cbox.addItems(words);
+
+ QCompleter *completer = new QCompleter(altWords);
+ completer->setCaseSensitivity(Qt::CaseInsensitive);
+ cbox.setCompleter(completer);
+
+ QSignalSpy spy(&cbox, SIGNAL(activated(int)));
+ QCOMPARE(spy.count(), 0);
+ cbox.move(200, 200);
+ cbox.show();
+ QApplication::setActiveWindow(&cbox);
+ QVERIFY(QTest::qWaitForWindowActive(&cbox));
+
+ QTest::keyClicks(&cbox, "foobar2");
+ QApplication::processEvents();
+ QTRY_VERIFY(completer->popup());
+ QTest::keyClick(completer->popup(), Qt::Key_Down);
+ QApplication::processEvents();
+ QTest::keyClick(completer->popup(), Qt::Key_Return);
+ QApplication::processEvents();
+ QList<QVariant> arguments = spy.takeLast();
+ QCOMPARE(arguments.at(0).toInt(), 2);
+
+ cbox.lineEdit()->selectAll();
+ cbox.lineEdit()->del();
+
+ QSortFilterProxyModel* model = new QSortFilterProxyModel();
+ model->setSourceModel(cbox.model());
+ model->setFilterFixedString("foobar1");
+ completer->setModel(model);
+
+ QApplication::setActiveWindow(&cbox);
+ QVERIFY(QTest::qWaitForWindowActive(&cbox));
+
+ QTest::keyClicks(&cbox, "foobar1");
+ QApplication::processEvents();
+ QTRY_VERIFY(completer->popup());
+ QTest::keyClick(completer->popup(), Qt::Key_Down);
+ QApplication::processEvents();
+ QTest::keyClick(completer->popup(), Qt::Key_Return);
+ QApplication::processEvents();
+ arguments = spy.takeLast();
+ QCOMPARE(arguments.at(0).toInt(), 1);
+}
+
QTEST_MAIN(tst_QComboBox)
#include "tst_qcombobox.moc"
diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
index 94e4fc005c..fa28ec2575 100644
--- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
+++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
@@ -239,6 +239,8 @@ private slots:
void deleteCalendarWidget();
+ void setLocaleOnCalendarWidget();
+
#ifdef QT_BUILD_INTERNAL
void dateEditCorrectSectionSize_data();
void dateEditCorrectSectionSize();
@@ -334,7 +336,7 @@ void tst_QDateTimeEdit::constructor_qwidget()
QCOMPARE(dte.dateTime(), QDateTime(QDate(2000, 1, 1), QTime(0, 0, 0, 0)));
QCOMPARE(dte.minimumDate(), QDate(1752, 9, 14));
QCOMPARE(dte.minimumTime(), QTime(0, 0, 0, 0));
- QCOMPARE(dte.maximumDate(), QDate(7999, 12, 31));
+ QCOMPARE(dte.maximumDate(), QDate(9999, 12, 31));
QCOMPARE(dte.maximumTime(), QTime(23, 59, 59, 999));
}
@@ -350,12 +352,12 @@ void tst_QDateTimeEdit::constructor_qdatetime_data()
QTest::newRow("normal") << QDateTime(QDate(2004, 6, 16), QTime(13, 46, 32, 764))
<< QDateTime(QDate(2004, 6, 16), QTime(13, 46, 32, 764))
<< QDate(1752, 9, 14) << QTime(0, 0, 0, 0)
- << QDate(7999, 12, 31) << QTime(23, 59, 59, 999);
+ << QDate(9999, 12, 31) << QTime(23, 59, 59, 999);
QTest::newRow("invalid") << QDateTime(QDate(9999, 99, 99), QTime(13, 46, 32, 764))
<< QDateTime(QDate(2000, 1, 1), QTime(0, 0, 0, 0))
<< QDate(1752, 9, 14) << QTime(0, 0, 0, 0)
- << QDate(7999, 12, 31) << QTime(23, 59, 59, 999);
+ << QDate(9999, 12, 31) << QTime(23, 59, 59, 999);
}
void tst_QDateTimeEdit::constructor_qdatetime()
@@ -390,12 +392,12 @@ void tst_QDateTimeEdit::constructor_qdate_data()
QTest::newRow("normal") << QDate(2004, 6, 16)
<< QDateTime(QDate(2004, 6, 16), QTime(0, 0, 0, 0))
<< QDate(1752, 9, 14) << QTime(0, 0, 0, 0)
- << QDate(7999, 12, 31) << QTime(23, 59, 59, 999);
+ << QDate(9999, 12, 31) << QTime(23, 59, 59, 999);
QTest::newRow("invalid") << QDate(9999, 99, 99)
<< QDateTime(QDate(2000, 1, 1), QTime(0, 0, 0, 0))
<< QDate(1752, 9, 14) << QTime(0, 0, 0, 0)
- << QDate(7999, 12, 31) << QTime(23, 59, 59, 999);
+ << QDate(9999, 12, 31) << QTime(23, 59, 59, 999);
}
void tst_QDateTimeEdit::constructor_qdate()
@@ -465,7 +467,7 @@ void tst_QDateTimeEdit::minimumDate_data()
QTest::newRow("normal-0") << QDate(2004, 5, 10) << QDate(2004, 5, 10);
QTest::newRow("normal-1") << QDate(2002, 3, 15) << QDate(2002, 3, 15);
- QTest::newRow("normal-2") << QDate(7999, 12, 31) << QDate(7999, 12, 31);
+ QTest::newRow("normal-2") << QDate(9999, 12, 31) << QDate(9999, 12, 31);
QTest::newRow("normal-3") << QDate(1753, 1, 1) << QDate(1753, 1, 1);
QTest::newRow("invalid-0") << QDate(0, 0, 0) << QDate(1752, 9, 14);
QTest::newRow("old") << QDate(1492, 8, 3) << QDate(1492, 8, 3);
@@ -526,7 +528,7 @@ void tst_QDateTimeEdit::maximumDateTime_data()
<< QDateTime(QDate(2007, 5, 10), QTime(22, 23, 23));
QTest::newRow("normal-4") << QDateTime(QDate(2008, 5, 10), QTime(2, 3, 1))
<< QDateTime(QDate(2008, 5, 10), QTime(2, 3, 1));
- QTest::newRow("invalid-0") << QDateTime() << QDateTime(QDate(7999, 12, 31), QTime(23, 59, 59, 999));
+ QTest::newRow("invalid-0") << QDateTime() << QDateTime(QDate(9999, 12, 31), QTime(23, 59, 59, 999));
}
void tst_QDateTimeEdit::maximumDateTime()
@@ -545,9 +547,9 @@ void tst_QDateTimeEdit::maximumDate_data()
QTest::newRow("normal-0") << QDate(2004, 05, 10) << QDate(2004, 5, 10);
QTest::newRow("normal-1") << QDate(2002, 03, 15) << QDate(2002, 3, 15);
- QTest::newRow("normal-2") << QDate(7999, 12, 31) << QDate(7999, 12, 31);
+ QTest::newRow("normal-2") << QDate(9999, 12, 31) << QDate(9999, 12, 31);
QTest::newRow("normal-3") << QDate(1753, 1, 1) << QDate(1753, 1, 1);
- QTest::newRow("invalid-0") << QDate(0, 0, 0) << QDate(7999, 12, 31);
+ QTest::newRow("invalid-0") << QDate(0, 0, 0) << QDate(9999, 12, 31);
}
void tst_QDateTimeEdit::maximumDate()
@@ -567,7 +569,7 @@ void tst_QDateTimeEdit::clearMinimumDate_data()
QTest::newRow("normal-0") << QDate(2004, 05, 10) << true << QDate(1752, 9, 14);
QTest::newRow("normal-1") << QDate(2002, 3, 15) << true << QDate(1752, 9, 14);
- QTest::newRow("normal-2") << QDate(7999, 12, 31) << true << QDate(1752, 9, 14);
+ QTest::newRow("normal-2") << QDate(9999, 12, 31) << true << QDate(1752, 9, 14);
QTest::newRow("normal-3") << QDate(1753, 1, 1) << true << QDate(1752, 9, 14);
QTest::newRow("invalid-0") << QDate(0, 0, 0) << false << QDate(1752, 9, 14);
}
@@ -595,7 +597,7 @@ void tst_QDateTimeEdit::clearMinimumDateTime_data()
<< true << QDateTime(QDate(1752, 9, 14), QTime(0, 0));
QTest::newRow("normal-1") << QDateTime(QDate(2002, 3, 15), QTime(13, 13, 13))
<< true << QDateTime(QDate(1752, 9, 14), QTime(0, 0));
- QTest::newRow("normal-2") << QDateTime(QDate(7999, 12, 31), QTime(14, 14, 14))
+ QTest::newRow("normal-2") << QDateTime(QDate(9999, 12, 31), QTime(14, 14, 14))
<< true << QDateTime(QDate(1752, 9, 14), QTime(0, 0));
QTest::newRow("normal-3") << QDateTime(QDate(1753, 1, 1), QTime(15, 15, 15))
<< true << QDateTime(QDate(1752, 9, 14), QTime(0, 0));
@@ -624,15 +626,15 @@ void tst_QDateTimeEdit::clearMaximumDateTime_data()
QTest::addColumn<QDateTime>("expectedMinDateTimeAfterClear");
QTest::newRow("normal-0") << QDateTime(QDate(2004, 05, 10), QTime(12, 12, 12))
- << true << QDateTime(QDate(7999, 12, 31), QTime(23, 59, 59, 999));
+ << true << QDateTime(QDate(9999, 12, 31), QTime(23, 59, 59, 999));
QTest::newRow("normal-1") << QDateTime(QDate(2002, 3, 15), QTime(13, 13, 13))
- << true << QDateTime(QDate(7999, 12, 31), QTime(23, 59, 59, 999));
- QTest::newRow("normal-2") << QDateTime(QDate(7999, 12, 31), QTime(14, 14, 14))
- << true << QDateTime(QDate(7999, 12, 31), QTime(23, 59, 59, 999));
+ << true << QDateTime(QDate(9999, 12, 31), QTime(23, 59, 59, 999));
+ QTest::newRow("normal-2") << QDateTime(QDate(9999, 12, 31), QTime(14, 14, 14))
+ << true << QDateTime(QDate(9999, 12, 31), QTime(23, 59, 59, 999));
QTest::newRow("normal-3") << QDateTime(QDate(1753, 1, 1), QTime(15, 15, 15))
- << true << QDateTime(QDate(7999, 12, 31), QTime(23, 59, 59, 999));
+ << true << QDateTime(QDate(9999, 12, 31), QTime(23, 59, 59, 999));
QTest::newRow("invalid-0") << QDateTime()
- << false << QDateTime(QDate(7999, 12, 31), QTime(23, 59, 59, 999));
+ << false << QDateTime(QDate(9999, 12, 31), QTime(23, 59, 59, 999));
}
void tst_QDateTimeEdit::clearMaximumDateTime()
@@ -654,11 +656,11 @@ void tst_QDateTimeEdit::clearMaximumDate_data()
QTest::addColumn<bool>("valid");
QTest::addColumn<QDate>("expectedMaxDateAfterClear");
- QTest::newRow("normal-0") << QDate(2004, 05, 10) << true << QDate(7999, 12, 31);
- QTest::newRow("normal-1") << QDate(2002, 03, 15) << true << QDate(7999, 12, 31);
- QTest::newRow("normal-2") << QDate(7999, 12, 31) << true << QDate(7999, 12, 31);
- QTest::newRow("normal-3") << QDate(2000, 1, 1) << true << QDate(7999, 12, 31);
- QTest::newRow("invalid-0") << QDate(0, 0, 0) << false << QDate(7999, 12, 31);
+ QTest::newRow("normal-0") << QDate(2004, 05, 10) << true << QDate(9999, 12, 31);
+ QTest::newRow("normal-1") << QDate(2002, 03, 15) << true << QDate(9999, 12, 31);
+ QTest::newRow("normal-2") << QDate(9999, 12, 31) << true << QDate(9999, 12, 31);
+ QTest::newRow("normal-3") << QDate(2000, 1, 1) << true << QDate(9999, 12, 31);
+ QTest::newRow("invalid-0") << QDate(0, 0, 0) << false << QDate(9999, 12, 31);
}
void tst_QDateTimeEdit::clearMaximumDate()
@@ -3409,6 +3411,25 @@ void tst_QDateTimeEdit::deleteCalendarWidget()
}
}
+void tst_QDateTimeEdit::setLocaleOnCalendarWidget()
+{
+ QDateEdit dateEdit;
+ QList<QLocale> allLocales = QLocale::matchingLocales(
+ QLocale::AnyLanguage,
+ QLocale::AnyScript,
+ QLocale::AnyCountry);
+ QLocale c = QLocale::c();
+ dateEdit.setCalendarPopup(true);
+ dateEdit.setLocale(c);
+ for (const QLocale& l : allLocales) {
+ dateEdit.setLocale(l);
+ const QLocale locCal = dateEdit.calendarWidget()->locale();
+ const QLocale locEdit = dateEdit.locale();
+ QCOMPARE(locCal.name(), locEdit.name());
+ QVERIFY(locCal == locEdit);
+ }
+}
+
#ifdef QT_BUILD_INTERNAL
typedef QPair<Qt::Key, Qt::KeyboardModifier> KeyPair;
diff --git a/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp b/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp
index 9e6b16d4ce..1813e5ad5f 100644
--- a/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp
+++ b/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp
@@ -204,7 +204,7 @@ void tst_QFontComboBox::sizeHint()
SubQFontComboBox box;
QSize sizeHint = box.QComboBox::sizeHint();
QFontMetrics fm(box.font());
- sizeHint.setWidth(qMax(sizeHint.width(), fm.width(QLatin1Char('m'))*14));
+ sizeHint.setWidth(qMax(sizeHint.width(), fm.horizontalAdvance(QLatin1Char('m'))*14));
QCOMPARE(box.sizeHint(), sizeHint);
}
diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_0.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_0.png
index f1d6392779..2647ac98b2 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_1.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_1.png
index f1d6392779..2647ac98b2 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_2.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_2.png
index f1d6392779..2647ac98b2 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_0_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_0.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_0.png
index 0cc9090e3b..84be445138 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_1.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_1.png
index 0cc9090e3b..84be445138 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_2.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_2.png
index 0cc9090e3b..84be445138 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_1_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_0.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_0.png
index 61f683df52..8c29cd9965 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_1.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_1.png
index 61f683df52..8c29cd9965 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_2.png b/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_2.png
index 61f683df52..8c29cd9965 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_noshadow_2_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_0_0.png b/tests/auto/widgets/widgets/qframe/images/box_plain_0_0.png
index f1d6392779..2647ac98b2 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_plain_0_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_plain_0_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_0_1.png b/tests/auto/widgets/widgets/qframe/images/box_plain_0_1.png
index f1d6392779..2647ac98b2 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_plain_0_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_plain_0_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_0_2.png b/tests/auto/widgets/widgets/qframe/images/box_plain_0_2.png
index f1d6392779..2647ac98b2 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_plain_0_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_plain_0_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_1_0.png b/tests/auto/widgets/widgets/qframe/images/box_plain_1_0.png
index 0cc9090e3b..84be445138 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_plain_1_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_plain_1_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_1_1.png b/tests/auto/widgets/widgets/qframe/images/box_plain_1_1.png
index 0cc9090e3b..84be445138 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_plain_1_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_plain_1_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_1_2.png b/tests/auto/widgets/widgets/qframe/images/box_plain_1_2.png
index 0cc9090e3b..84be445138 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_plain_1_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_plain_1_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_2_0.png b/tests/auto/widgets/widgets/qframe/images/box_plain_2_0.png
index 61f683df52..8c29cd9965 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_plain_2_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_plain_2_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_2_1.png b/tests/auto/widgets/widgets/qframe/images/box_plain_2_1.png
index 61f683df52..8c29cd9965 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_plain_2_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_plain_2_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_plain_2_2.png b/tests/auto/widgets/widgets/qframe/images/box_plain_2_2.png
index 61f683df52..8c29cd9965 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_plain_2_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_plain_2_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_0_0.png b/tests/auto/widgets/widgets/qframe/images/box_raised_0_0.png
index f1d6392779..2647ac98b2 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_raised_0_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_raised_0_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_0_1.png b/tests/auto/widgets/widgets/qframe/images/box_raised_0_1.png
index b2ab941d30..e35498674c 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_raised_0_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_raised_0_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_0_2.png b/tests/auto/widgets/widgets/qframe/images/box_raised_0_2.png
index 21ebe53eff..b958b62259 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_raised_0_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_raised_0_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_1_0.png b/tests/auto/widgets/widgets/qframe/images/box_raised_1_0.png
index 4f097cee48..879f6ddc31 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_raised_1_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_raised_1_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_1_1.png b/tests/auto/widgets/widgets/qframe/images/box_raised_1_1.png
index 86f9ed6186..343caa06e4 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_raised_1_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_raised_1_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_1_2.png b/tests/auto/widgets/widgets/qframe/images/box_raised_1_2.png
index 51a7899d05..377e1377f2 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_raised_1_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_raised_1_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_2_0.png b/tests/auto/widgets/widgets/qframe/images/box_raised_2_0.png
index 8c3769c32d..d59309bb3e 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_raised_2_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_raised_2_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_2_1.png b/tests/auto/widgets/widgets/qframe/images/box_raised_2_1.png
index 81e0c2a152..36f6c0a9f3 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_raised_2_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_raised_2_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_raised_2_2.png b/tests/auto/widgets/widgets/qframe/images/box_raised_2_2.png
index 107272d0b9..c6bdab7eb4 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_raised_2_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_raised_2_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_0_0.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_0_0.png
index f1d6392779..2647ac98b2 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_sunken_0_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_0_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_0_1.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_0_1.png
index b2ab941d30..e35498674c 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_sunken_0_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_0_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_0_2.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_0_2.png
index 21ebe53eff..b958b62259 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_sunken_0_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_0_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_1_0.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_1_0.png
index 6905baa1fd..7e57872d19 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_sunken_1_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_1_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_1_1.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_1_1.png
index 9d5440b3aa..8bf9170f89 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_sunken_1_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_1_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_1_2.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_1_2.png
index 17eb7f59c0..bb34a4db29 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_sunken_1_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_1_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_2_0.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_2_0.png
index a6ccd54a39..4aa344ad54 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_sunken_2_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_2_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_2_1.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_2_1.png
index 3736bf6c99..da5f2ba6b9 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_sunken_2_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_2_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/box_sunken_2_2.png b/tests/auto/widgets/widgets/qframe/images/box_sunken_2_2.png
index 5750751c58..80ce6d846e 100644
--- a/tests/auto/widgets/widgets/qframe/images/box_sunken_2_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/box_sunken_2_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_0.png
index 61f683df52..8c29cd9965 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_1.png
index 61f683df52..8c29cd9965 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_2.png
index 61f683df52..8c29cd9965 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_0_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_0.png
index 61f683df52..8c29cd9965 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_1.png
index 61f683df52..8c29cd9965 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_2.png
index 61f683df52..8c29cd9965 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_1_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_0.png
index 61f683df52..8c29cd9965 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_1.png
index 61f683df52..8c29cd9965 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_2.png
index 61f683df52..8c29cd9965 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_noshadow_2_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_0.png
index 61f683df52..8c29cd9965 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_1.png
index 61f683df52..8c29cd9965 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_2.png
index 61f683df52..8c29cd9965 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_0_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_0.png
index 61f683df52..8c29cd9965 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_1.png
index 61f683df52..8c29cd9965 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_2.png
index 61f683df52..8c29cd9965 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_1_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_0.png
index 61f683df52..8c29cd9965 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_1.png
index 61f683df52..8c29cd9965 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_2.png
index 61f683df52..8c29cd9965 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_plain_2_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_0.png
index 00447760ec..a28358ec55 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_1.png
index 00447760ec..a28358ec55 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_2.png
index 00447760ec..a28358ec55 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_0.png
index 00447760ec..a28358ec55 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_1.png
index 00447760ec..a28358ec55 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_2.png
index 00447760ec..a28358ec55 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_0.png
index 00447760ec..a28358ec55 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_1.png
index 00447760ec..a28358ec55 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_2.png
index 00447760ec..a28358ec55 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_0.png
index 4c809a2c80..b5ea56f422 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_1.png
index 4c809a2c80..b5ea56f422 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_2.png
index 4c809a2c80..b5ea56f422 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_0.png
index 4c809a2c80..b5ea56f422 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_1.png
index 4c809a2c80..b5ea56f422 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_2.png
index 4c809a2c80..b5ea56f422 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_0.png
index 4c809a2c80..b5ea56f422 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_0.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_0.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_1.png
index 4c809a2c80..b5ea56f422 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_1.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_1.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_2.png
index 4c809a2c80..b5ea56f422 100644
--- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_2.png
+++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_2.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
index 62224217d6..420ef56106 100644
--- a/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+++ b/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
@@ -67,7 +67,7 @@ private slots:
void toggledVsClicked();
void childrenAreDisabled();
void propagateFocus();
- void task_QTBUG_19170_ignoreMouseReleseEvent();
+ void task_QTBUG_19170_ignoreMouseReleaseEvent();
void task_QTBUG_15519_propagateMouseEvents();
private:
@@ -477,7 +477,7 @@ void tst_QGroupBox::propagateFocus()
QTRY_COMPARE(qApp->focusWidget(), static_cast<QWidget*>(&lineEdit));
}
-void tst_QGroupBox::task_QTBUG_19170_ignoreMouseReleseEvent()
+void tst_QGroupBox::task_QTBUG_19170_ignoreMouseReleaseEvent()
{
QGroupBox box;
box.setCheckable(true);
diff --git a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
index 6363d0c673..500ec2e1fa 100644
--- a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
+++ b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
@@ -47,7 +47,7 @@ public:
QList<QEvent::Type> events;
protected:
- bool event(QEvent *ev) Q_DECL_OVERRIDE {
+ bool event(QEvent *ev) override {
events.append(ev->type());
return QWidget::event(ev);
}
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
index 2c6599631e..1513025f16 100644
--- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
@@ -44,10 +44,6 @@
#include <private/qapplication_p.h>
#include "qclipboard.h"
-#ifdef Q_OS_MAC
-#include <cstdlib> // For the random function.
-#endif
-
#include <qlineedit.h>
#include <private/qlineedit_p.h>
#include <private/qwidgetlinecontrol_p.h>
@@ -71,6 +67,8 @@
#include "../../../shared/platforminputcontext.h"
#include <private/qinputmethod_p.h>
+Q_LOGGING_CATEGORY(lcTests, "qt.widgets.tests")
+
QT_BEGIN_NAMESPACE
class QPainter;
QT_END_NAMESPACE
@@ -304,8 +302,8 @@ private slots:
void shortcutOverrideOnReadonlyLineEdit_data();
void shortcutOverrideOnReadonlyLineEdit();
void QTBUG59957_clearButtonLeftmostAction();
-
void QTBUG_60319_setInputMaskCheckImSurroundingText();
+ void testQuickSelectionWithMouse();
protected slots:
void editingFinished();
@@ -1922,7 +1920,7 @@ void tst_QLineEdit::noCursorBlinkWhenReadOnly()
centerOnScreen(&le);
le.show();
le.setFocus();
- QTest::qWaitForWindowActive(&le);
+ QVERIFY(QTest::qWaitForWindowActive(&le));
le.updates = 0;
QTest::qWait(cursorFlashTime);
QVERIFY(le.updates > 0);
@@ -1941,17 +1939,7 @@ void tst_QLineEdit::noCursorBlinkWhenReadOnly()
static void figureOutProperKey(Qt::Key &key, Qt::KeyboardModifiers &pressState)
{
#ifdef Q_OS_MAC
- static bool tst_lineedit_randomized = false;
- // Mac has 3 different ways of accomplishing this (same for moving to the back)
- // So I guess we should just randomly do this for now. Which may get people mad, but if
- // we fail at one point, it's just a matter of setting roll to the correct value
- // instead of random.
-
- if (!tst_lineedit_randomized) {
- tst_lineedit_randomized = true;
- ::srandom(ulong(time(0)));
- }
- long roll = ::random() % 3;
+ long roll = QRandomGenerator::global()->bounded(3);
switch (roll) {
case 0:
key = key == Qt::Key_Home ? Qt::Key_Up : Qt::Key_Down;
@@ -1963,9 +1951,8 @@ static void figureOutProperKey(Qt::Key &key, Qt::KeyboardModifiers &pressState)
break;
}
#else
- // Naively kill the warning.
- key = key;
- pressState = pressState;
+ Q_UNUSED(key);
+ Q_UNUSED(pressState);
#endif
}
@@ -3061,7 +3048,7 @@ void tst_QLineEdit::cutWithoutSelection()
QClipboard *clipboard = QGuiApplication::clipboard();
if (!PlatformClipboard::isAvailable()
|| !QGuiApplication::platformName().compare("xcb", Qt::CaseInsensitive)) { // Avoid unstable X11 clipboard
- clipboard = Q_NULLPTR;
+ clipboard = nullptr;
}
if (clipboard)
@@ -3361,7 +3348,7 @@ void tst_QLineEdit::inlineCompletion()
completer->setCaseSensitivity(Qt::CaseInsensitive);
centerOnScreen(testWidget);
testWidget->show();
- QTest::qWaitForWindowExposed(testWidget);
+ QVERIFY(QTest::qWaitForWindowExposed(testWidget));
testWidget->setFocus();
QTRY_COMPARE(qApp->activeWindow(), (QWidget*)testWidget);
testWidget->setCompleter(completer);
@@ -3451,8 +3438,8 @@ void tst_QLineEdit::textMargin_data()
// Different styles generate different offsets, so
// calculate the width rather than hardcode it.
- const int pixelWidthOfM = metrics.width(s, 1);
- const int pixelWidthOfMMM_MM = metrics.width(s, 6);
+ const int pixelWidthOfM = metrics.horizontalAdvance(s, 1);
+ const int pixelWidthOfMMM_MM = metrics.horizontalAdvance(s, 6);
QTest::newRow("default-0") << 0 << 0 << 0 << 0 << QPoint(pixelWidthOfMMM_MM, 0) << 6;
QTest::newRow("default-1") << 0 << 0 << 0 << 0 << QPoint(1, 1) << 0;
@@ -3689,7 +3676,7 @@ void tst_QLineEdit::task229938_dontEmitChangedWhenTextIsNotChanged()
QLineEdit lineEdit;
lineEdit.setMaxLength(5);
lineEdit.show();
- QTest::qWaitForWindowExposed(&lineEdit); // to be safe and avoid failing setFocus with window managers
+ QVERIFY(QTest::qWaitForWindowExposed(&lineEdit)); // to be safe and avoid failing setFocus with window managers
lineEdit.setFocus();
QSignalSpy changedSpy(&lineEdit, SIGNAL(textChanged(QString)));
QTest::qWait(200);
@@ -3979,6 +3966,8 @@ void tst_QLineEdit::QTBUG16850_setSelection()
le.setText(" 1");
le.setSelection(3, 1);
QCOMPARE(le.selectionStart(), 3);
+ QCOMPARE(le.selectionEnd(), 4);
+ QCOMPARE(le.selectionLength(), 1);
QCOMPARE(le.selectedText(), QString("1"));
}
@@ -4173,11 +4162,16 @@ void tst_QLineEdit::inputMethodSelection()
QCOMPARE(selectionSpy.count(), 0);
QCOMPARE(testWidget->selectionStart(), -1);
+ QCOMPARE(testWidget->selectionEnd(), -1);
+ QCOMPARE(testWidget->selectionLength(), 0);
testWidget->setSelection(0,5);
QCOMPARE(selectionSpy.count(), 1);
QCOMPARE(testWidget->selectionStart(), 0);
+ QCOMPARE(testWidget->selectionEnd(), 5);
+ QCOMPARE(testWidget->selectionLength(), 5);
+
// selection gained
{
@@ -4189,6 +4183,8 @@ void tst_QLineEdit::inputMethodSelection()
QCOMPARE(selectionSpy.count(), 2);
QCOMPARE(testWidget->selectionStart(), 12);
+ QCOMPARE(testWidget->selectionEnd(), 17);
+ QCOMPARE(testWidget->selectionLength(), 5);
// selection removed
{
@@ -4199,6 +4195,10 @@ void tst_QLineEdit::inputMethodSelection()
}
QCOMPARE(selectionSpy.count(), 3);
+ QCOMPARE(testWidget->selectionStart(), -1);
+ QCOMPARE(testWidget->selectionEnd(), -1);
+ QCOMPARE(testWidget->selectionLength(), 0);
+
}
Q_DECLARE_METATYPE(Qt::InputMethodHints)
@@ -4477,7 +4477,7 @@ template <class T> T *findAssociatedWidget(const QAction *a)
if (T *result = qobject_cast<T *>(w))
return result;
}
- return Q_NULLPTR;
+ return nullptr;
}
void tst_QLineEdit::sideWidgetsActionEvents()
@@ -4701,5 +4701,90 @@ void tst_QLineEdit::QTBUG_60319_setInputMaskCheckImSurroundingText()
QCOMPARE(surroundingText.length(), cursorPosition);
}
+void tst_QLineEdit::testQuickSelectionWithMouse()
+{
+ const auto text = QStringLiteral("This is quite a long line of text.");
+ const auto prefix = QStringLiteral("Th");
+ const auto suffix = QStringLiteral("t.");
+ QVERIFY(text.startsWith(prefix));
+ QVERIFY(text.endsWith(suffix));
+
+ QLineEdit lineEdit;
+ lineEdit.setText(text);
+ lineEdit.show();
+
+ const QPoint center = lineEdit.contentsRect().center();
+
+ // Normal mouse selection from left to right, y doesn't change.
+ QTest::mousePress(lineEdit.windowHandle(), Qt::LeftButton, Qt::NoModifier, center);
+ QTest::mouseMove(lineEdit.windowHandle(), center + QPoint(20, 0));
+ qCDebug(lcTests) << "Selected text:" << lineEdit.selectedText();
+ QVERIFY(!lineEdit.selectedText().isEmpty());
+ QVERIFY(!lineEdit.selectedText().endsWith(suffix));
+
+ // Normal mouse selection from left to right, y change is below threshold.
+ QTest::mousePress(lineEdit.windowHandle(), Qt::LeftButton, Qt::NoModifier, center);
+ QTest::mouseMove(lineEdit.windowHandle(), center + QPoint(20, 5));
+ qCDebug(lcTests) << "Selected text:" << lineEdit.selectedText();
+ QVERIFY(!lineEdit.selectedText().isEmpty());
+ QVERIFY(!lineEdit.selectedText().endsWith(suffix));
+
+ // Normal mouse selection from right to left, y doesn't change.
+ QTest::mousePress(lineEdit.windowHandle(), Qt::LeftButton, Qt::NoModifier, center);
+ QTest::mouseMove(lineEdit.windowHandle(), center + QPoint(-20, 0));
+ qCDebug(lcTests) << "Selected text:" << lineEdit.selectedText();
+ QVERIFY(!lineEdit.selectedText().isEmpty());
+ QVERIFY(!lineEdit.selectedText().startsWith(prefix));
+
+ // Normal mouse selection from right to left, y change is below threshold.
+ QTest::mousePress(lineEdit.windowHandle(), Qt::LeftButton, Qt::NoModifier, center);
+ QTest::mouseMove(lineEdit.windowHandle(), center + QPoint(-20, -5));
+ qCDebug(lcTests) << "Selected text:" << lineEdit.selectedText();
+ QVERIFY(!lineEdit.selectedText().isEmpty());
+ QVERIFY(!lineEdit.selectedText().startsWith(prefix));
+
+ const int offset = QGuiApplication::styleHints()->mouseQuickSelectionThreshold() + 1;
+
+ // Select the whole right half.
+ QTest::mousePress(lineEdit.windowHandle(), Qt::LeftButton, Qt::NoModifier, center);
+ QTest::mouseMove(lineEdit.windowHandle(), center + QPoint(1, offset));
+ qCDebug(lcTests) << "Selected text:" << lineEdit.selectedText();
+ QVERIFY(lineEdit.selectedText().endsWith(suffix));
+
+ // Select the whole left half.
+ QTest::mousePress(lineEdit.windowHandle(), Qt::LeftButton, Qt::NoModifier, center);
+ QTest::mouseMove(lineEdit.windowHandle(), center + QPoint(1, -offset));
+ qCDebug(lcTests) << "Selected text:" << lineEdit.selectedText();
+ QVERIFY(lineEdit.selectedText().startsWith(prefix));
+
+ // Normal selection -> quick selection -> back to normal selection.
+ QTest::mousePress(lineEdit.windowHandle(), Qt::LeftButton, Qt::NoModifier, center);
+ QTest::mouseMove(lineEdit.windowHandle(), center + QPoint(20, 0));
+ const auto partialSelection = lineEdit.selectedText();
+ qCDebug(lcTests) << "Selected text:" << lineEdit.selectedText();
+ QVERIFY(!partialSelection.endsWith(suffix));
+ QTest::mouseMove(lineEdit.windowHandle(), center + QPoint(20, offset));
+ qCDebug(lcTests) << "Selected text:" << lineEdit.selectedText();
+ QVERIFY(lineEdit.selectedText().endsWith(suffix));
+ QTest::mouseMove(lineEdit.windowHandle(), center + QPoint(20, 0));
+ qCDebug(lcTests) << "Selected text:" << lineEdit.selectedText();
+#ifdef Q_PROCESSOR_ARM
+ QEXPECT_FAIL("", "Currently fails on gcc-armv7, needs investigation.", Continue);
+#endif
+ QCOMPARE(lineEdit.selectedText(), partialSelection);
+
+ lineEdit.setLayoutDirection(Qt::RightToLeft);
+
+ // Select the whole left half (RTL layout).
+ QTest::mousePress(lineEdit.windowHandle(), Qt::LeftButton, Qt::NoModifier, center);
+ QTest::mouseMove(lineEdit.windowHandle(), center + QPoint(1, offset));
+ QVERIFY(lineEdit.selectedText().startsWith(prefix));
+
+ // Select the whole right half (RTL layout).
+ QTest::mousePress(lineEdit.windowHandle(), Qt::LeftButton, Qt::NoModifier, center);
+ QTest::mouseMove(lineEdit.windowHandle(), center + QPoint(1, -offset));
+ QVERIFY(lineEdit.selectedText().endsWith(suffix));
+}
+
QTEST_MAIN(tst_QLineEdit)
#include "tst_qlineedit.moc"
diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
index 292080c55f..30dc1e6043 100644
--- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
+++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
@@ -2013,7 +2013,7 @@ void tst_QMainWindow::resizeDocks()
mw.setCentralWidget(new QTextEdit);
mw.show();
- QTest::qWaitForWindowExposed(&mw);
+ QVERIFY(QTest::qWaitForWindowExposed(&mw));
QFETCH(Qt::Orientation, orientation);
QFETCH(QStringList, docks);
diff --git a/tests/auto/widgets/widgets/qmenu/BLACKLIST b/tests/auto/widgets/widgets/qmenu/BLACKLIST
index cfd6bb1247..1c970c43b3 100644
--- a/tests/auto/widgets/widgets/qmenu/BLACKLIST
+++ b/tests/auto/widgets/widgets/qmenu/BLACKLIST
@@ -3,3 +3,10 @@ osx
[submenuTearOffDontClose]
osx-10.11 ci
osx-10.12 ci
+[layoutDirection]
+# Fails when enabling synchronous expose events QTBUG-62092
+osx ci
+[pushButtonPopulateOnAboutToShow]
+osx
+[tearOff]
+osx
diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
index 99d29d487d..28e8ba81d6 100644
--- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
+++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
@@ -111,13 +111,14 @@ private slots:
void QTBUG7411_submenus_activate();
void QTBUG30595_rtl_submenu();
void QTBUG20403_nested_popup_on_shortcut_trigger();
-#ifndef QT_NO_CURSOR
void QTBUG47515_widgetActionEnterLeave();
-#endif
+
void QTBUG_10735_crashWithDialog();
#ifdef Q_OS_MAC
void QTBUG_37933_ampersands_data();
void QTBUG_37933_ampersands();
+#else
+ void click_while_dismissing_submenu();
#endif
void QTBUG_56917_wideMenuSize();
void QTBUG_56917_wideMenuScreenNumber();
@@ -608,7 +609,7 @@ static QMenu *getTornOffMenu()
if (w->isVisible() && w->inherits("QTornOffMenu"))
return static_cast<QMenu *>(w);
}
- return Q_NULLPTR;
+ return nullptr;
}
void tst_QMenu::tearOff()
@@ -810,7 +811,7 @@ public:
}
protected:
- void showEvent(QShowEvent *e) Q_DECL_OVERRIDE
+ void showEvent(QShowEvent *e) override
{
QVERIFY(m_subMenu->isVisible());
QVERIFY2(m_subMenu->x() > x(),
@@ -819,7 +820,7 @@ protected:
QMenu::showEvent(e);
}
- void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE
+ void timerEvent(QTimerEvent *e) override
{
if (e->timerId() == m_timerId) {
switch (m_timerTick++) {
@@ -1164,6 +1165,41 @@ void tst_QMenu::QTBUG20403_nested_popup_on_shortcut_trigger()
QVERIFY(!subsub1.isVisible());
}
+#ifndef Q_OS_MACOS
+void tst_QMenu::click_while_dismissing_submenu()
+{
+ QMenu menu("Test Menu");
+ QAction *action = menu.addAction("action");
+ QMenu sub("&sub");
+ sub.addAction("subaction");
+ menu.addMenu(&sub);
+ centerOnScreen(&menu, QSize(120, 100));
+ menu.show();
+ QSignalSpy spy(action, &QAction::triggered);
+ QSignalSpy menuShownSpy(&sub, &QMenu::aboutToShow);
+ QSignalSpy menuHiddenSpy(&sub, &QMenu::aboutToHide);
+ QVERIFY(QTest::qWaitForWindowExposed(&menu));
+ QWindow *menuWindow = menu.windowHandle();
+ QVERIFY(menuWindow);
+ //go over the submenu, press, move and release over the top level action
+ //this opens the submenu, move two times to emulate user interaction (d->motions > 0 in QMenu)
+ QTest::mouseMove(menuWindow, menu.rect().center() + QPoint(0,2));
+ QTest::mouseMove(menuWindow, menu.rect().center() + QPoint(1,3), 60);
+ QVERIFY(menuShownSpy.wait());
+ QVERIFY(sub.isVisible());
+ QVERIFY(QTest::qWaitForWindowExposed(&sub));
+ //press over the submenu entry
+ QTest::mousePress(menuWindow, Qt::LeftButton, 0, menu.rect().center() + QPoint(0,2), 300);
+ //move over the main action
+ QTest::mouseMove(menuWindow, menu.rect().center() - QPoint(0,2));
+ QVERIFY(menuHiddenSpy.wait());
+ //the submenu must have been hidden for the bug to be triggered
+ QVERIFY(!sub.isVisible());
+ QTest::mouseRelease(menuWindow, Qt::LeftButton, 0, menu.rect().center() - QPoint(0,2), 300);
+ QCOMPARE(spy.count(), 1);
+}
+#endif
+
class MyWidget : public QWidget
{
public:
@@ -1175,7 +1211,7 @@ public:
setMouseTracking(true);
}
- bool event(QEvent *e) Q_DECL_OVERRIDE
+ bool event(QEvent *e) override
{
switch (e->type()) {
case QEvent::MouseMove:
@@ -1196,79 +1232,99 @@ public:
int move, enter, leave;
};
-#ifndef QT_NO_CURSOR
void tst_QMenu::QTBUG47515_widgetActionEnterLeave()
{
+#if !QT_CONFIG(cursor)
+ QSKIP("This test requires QCursor API");
+#else
if (QGuiApplication::platformName() == QLatin1String("cocoa"))
- QSKIP("This test fails on OS X on CI");
+ QSKIP("See QTBUG-63031");
- const QPoint center = QGuiApplication::primaryScreen()->availableGeometry().center();
- const QPoint cursorPos = center - QPoint(100, 100);
+ QPoint screenCenter = QGuiApplication::primaryScreen()->availableGeometry().center();
+ QPoint pointOutsideMenu = screenCenter - QPoint(100, 100);
- QScopedPointer<QMenu> menu1(new QMenu("Menu1"));
- QScopedPointer<QMenu> menu2(new QMenu("Menu2"));
+ QMenu menu("Menu1");
+ QMenu submenu("Menu2");
- QWidgetAction *wA1 = new QWidgetAction(menu1.data());
- MyWidget *w1 = new MyWidget(menu1.data());
- wA1->setDefaultWidget(w1);
+ QWidgetAction menuAction(&menu);
+ MyWidget w1(&menu);
+ menuAction.setDefaultWidget(&w1);
- QWidgetAction *wA2 = new QWidgetAction(menu2.data());
- MyWidget *w2 = new MyWidget(menu2.data());
- wA2->setDefaultWidget(w2);
+ QWidgetAction submenuAction(&submenu);
+ MyWidget w2(&submenu);
+ submenuAction.setDefaultWidget(&w2);
- QAction *nextMenuAct = menu1->addMenu(menu2.data());
+ QAction *nextMenuAct = menu.addMenu(&submenu);
- menu1->addAction(wA1);
- menu2->addAction(wA2);
+ menu.addAction(&menuAction);
+ submenu.addAction(&submenuAction);
// Root menu
{
- QCursor::setPos(cursorPos);
- QCoreApplication::processEvents();
-
- menu1->popup(center);
- QVERIFY(QTest::qWaitForWindowExposed(menu1.data()));
+ QCursor::setPos(pointOutsideMenu);
+ QTRY_COMPARE(QCursor::pos(), pointOutsideMenu);
+ menu.popup(screenCenter);
+ QVERIFY(QTest::qWaitForWindowExposed(&menu));
- QCursor::setPos(w1->mapToGlobal(w1->rect().center()));
- QVERIFY(w1->isVisible());
- QTRY_COMPARE(w1->leave, 0);
- QTRY_COMPARE(w1->enter, 1);
+ w1.enter = 0;
+ w1.leave = 0;
+ QPoint w1Center = w1.rect().center();
+ const QPoint w1CenterGlobal = w1.mapToGlobal(w1Center);
+ QCursor::setPos(w1CenterGlobal);
+ QTRY_COMPARE(QCursor::pos(), w1CenterGlobal);
+ QVERIFY(w1.isVisible());
+ QTRY_COMPARE(w1.leave, 0);
+ QTRY_COMPARE(w1.enter, 1);
// Check whether leave event is not delivered on mouse move
- w1->move = 0;
- QCursor::setPos(w1->mapToGlobal(w1->rect().center()) + QPoint(1, 1));
- QTRY_COMPARE(w1->move, 1);
- QTRY_COMPARE(w1->leave, 0);
- QTRY_COMPARE(w1->enter, 1);
-
- QCursor::setPos(cursorPos);
- QTRY_COMPARE(w1->leave, 1);
- QTRY_COMPARE(w1->enter, 1);
+ w1.move = 0;
+ QWidget *nativeParent = w1.nativeParentWidget();
+ QVERIFY(nativeParent);
+ QWindow *window = nativeParent->windowHandle();
+ QVERIFY(window);
+ QTest::mouseMove(window, w1.mapTo(nativeParent, w1Center + QPoint(1, 1)));
+ QTRY_COMPARE(w1.move, 1);
+ QTRY_COMPARE(w1.leave, 0);
+ QTRY_COMPARE(w1.enter, 1);
+
+ QCursor::setPos(pointOutsideMenu);
+ QTRY_COMPARE(QCursor::pos(), pointOutsideMenu);
+ QTRY_COMPARE(w1.leave, 1);
+ QTRY_COMPARE(w1.enter, 1);
}
// Submenu
{
- menu1->setActiveAction(nextMenuAct);
- QVERIFY(QTest::qWaitForWindowExposed(menu2.data()));
+ menu.setActiveAction(nextMenuAct);
+ QVERIFY(QTest::qWaitForWindowExposed(&submenu));
- QCursor::setPos(w2->mapToGlobal(w2->rect().center()));
- QVERIFY(w2->isVisible());
- QTRY_COMPARE(w2->leave, 0);
- QTRY_COMPARE(w2->enter, 1);
+ QPoint w2Center = w2.rect().center();
+ const QPoint w2CenterGlobal = w2.mapToGlobal(w2Center);
+ QCursor::setPos(w2CenterGlobal);
+ QTRY_COMPARE(QCursor::pos(), w2CenterGlobal);
+
+ QVERIFY(w2.isVisible());
+ QTRY_COMPARE(w2.leave, 0);
+ QTRY_COMPARE(w2.enter, 1);
// Check whether leave event is not delivered on mouse move
- w2->move = 0;
- QCursor::setPos(w2->mapToGlobal(w2->rect().center()) + QPoint(1, 1));
- QTRY_COMPARE(w2->move, 1);
- QTRY_COMPARE(w2->leave, 0);
- QTRY_COMPARE(w2->enter, 1);
-
- QCursor::setPos(cursorPos);
- QTRY_COMPARE(w2->leave, 1);
- QTRY_COMPARE(w2->enter, 1);
+ w2.move = 0;
+ QWidget *nativeParent = w2.nativeParentWidget();
+ QVERIFY(nativeParent);
+ QWindow *window = nativeParent->windowHandle();
+ QVERIFY(window);
+ QTest::mouseMove(window, w2.mapTo(nativeParent, w2Center + QPoint(1, 1)));
+ QTRY_COMPARE(w2.move, 1);
+ QTRY_COMPARE(w2.leave, 0);
+ QTRY_COMPARE(w2.enter, 1);
+
+ QCursor::setPos(pointOutsideMenu);
+ QTRY_COMPARE(QCursor::pos(), pointOutsideMenu);
+ QTRY_COMPARE(w2.leave, 1);
+ QTRY_COMPARE(w2.enter, 1);
}
+#endif // QT_NO_CURSOR
}
-#endif // !QT_NO_CURSOR
class MyMenu : public QMenu
{
@@ -1483,7 +1539,7 @@ void tst_QMenu::menuSize_Scrolling()
~TestMenu() {}
private:
- void showEvent(QShowEvent *e) Q_DECL_OVERRIDE
+ void showEvent(QShowEvent *e) override
{
QVERIFY(actions().length() == m_numItems);
diff --git a/tests/auto/widgets/widgets/qmenubar/BLACKLIST b/tests/auto/widgets/widgets/qmenubar/BLACKLIST
index 3bfd34782e..9b8e07312d 100644
--- a/tests/auto/widgets/widgets/qmenubar/BLACKLIST
+++ b/tests/auto/widgets/widgets/qmenubar/BLACKLIST
@@ -1,5 +1,4 @@
[check_menuPosition]
-ubuntu-14.04
ubuntu-16.04
#QTBUG-66255
[activatedCount]
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
index 417fa9befa..ab82268578 100644
--- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
@@ -136,7 +136,7 @@ private slots:
void task223138_triggered();
void task256322_highlight();
void menubarSizeHint();
-#ifndef Q_OS_MAC
+#ifndef Q_OS_MACOS
void taskQTBUG4965_escapeEaten();
#endif
void taskQTBUG11823_crashwithInvisibleActions();
@@ -148,11 +148,12 @@ private slots:
void taskQTBUG56275_reinsertMenuInParentlessQMenuBar();
void QTBUG_57404_existingMenuItemException();
#endif
+ void QTBUG_25669_menubarActionDoubleTriggered();
void taskQTBUG55966_subMenuRemoved();
void QTBUG_58344_invalidIcon();
-
void platformMenu();
-
+ void addActionQt5connect();
+ void QTBUG_65488_hiddenActionTriggered();
protected slots:
void onSimpleActivated( QAction*);
void onComplexActionTriggered();
@@ -1376,7 +1377,7 @@ void tst_QMenuBar::menubarSizeHint()
}
// On Mac, do not test the menubar with escape key
-#ifndef Q_OS_MAC
+#ifndef Q_OS_MACOS
void tst_QMenuBar::taskQTBUG4965_escapeEaten()
{
QMenuBar menubar;
@@ -1549,7 +1550,7 @@ void tst_QMenuBar::taskQTBUG53205_crashReparentNested()
//set the new parent, a window
QScopedPointer<QWidget> windowedParent;
- windowedParent.reset(new QWidget(Q_NULLPTR, Qt::WindowFlags()));
+ windowedParent.reset(new QWidget(nullptr, Qt::WindowFlags()));
windowedParent->setGeometry(400, 10, 300, 300);
windowedParent->show();
@@ -1566,7 +1567,7 @@ void tst_QMenuBar::taskQTBUG53205_crashReparentNested()
//to windowedParent<-movingParent<-containerWidget<-containedWidget<-menuBar
movingParent.setParent(windowedParent.data(),0);
// this resets the parenting and the menu bar's window
- taskQTBUG53205MenuBar->setParent(Q_NULLPTR);
+ taskQTBUG53205MenuBar->setParent(nullptr);
taskQTBUG53205MenuBar->setParent(&containedWidget);
//from windowedParent<-movingParent<-containerWidget<-containedWidget<-menuBar
//to : QMainWindow<-hiddenParent<-movingParent<-containerWidget<-containedWidget<-menuBar
@@ -1576,6 +1577,25 @@ void tst_QMenuBar::taskQTBUG53205_crashReparentNested()
testMenus.actions[0]->trigger();
}
+void tst_QMenuBar::QTBUG_65488_hiddenActionTriggered()
+{
+ QMainWindow win;
+ win.menuBar()->setNativeMenuBar(false);
+ QAction *act1 = win.menuBar()->addAction("A very long named action that make menuBar item wide enough");
+ QSignalSpy spy(win.menuBar(), &QMenuBar::triggered);
+
+ QRect actRect = win.menuBar()->actionGeometry(act1);
+ // resize to action's size to make Action1 hidden
+ win.resize(actRect.width() - 10, win.size().height());
+ win.show();
+ QApplication::setActiveWindow(&win);
+ QVERIFY(QTest::qWaitForWindowExposed(&win));
+ // click center of the blank area on the menubar where Action1 resided
+ QTest::mouseClick(win.windowHandle(), Qt::LeftButton, Qt::NoModifier, win.menuBar()->geometry().center());
+ QCoreApplication::sendPostedEvents(); // make sure all queued events also dispatched
+ QCOMPARE(spy.count(), 0);
+}
+
// QTBUG-56526
void tst_QMenuBar::platformMenu()
{
@@ -1595,10 +1615,71 @@ void tst_QMenuBar::platformMenu()
QVERIFY(menu->platformMenu());
}
+class TestObject : public QObject
+{
+ Q_OBJECT
+public:
+ bool flag = false;
+ void setFlag()
+ {
+ flag = true;
+ }
+};
+
+void tst_QMenuBar::addActionQt5connect()
+{
+ bool flag = false;
+ auto functor = [&flag](){ flag = true; };
+
+ TestObject obj;
+
+ QMenuBar menuBar;
+
+ auto action1 = menuBar.addAction(QStringLiteral("1"), &obj, &TestObject::setFlag);
+ auto action2 = menuBar.addAction(QStringLiteral("2"), functor);
+
+ action1->activate(QAction::Trigger);
+ action2->activate(QAction::Trigger);
+
+ QVERIFY(obj.flag);
+ QVERIFY(flag);
+
+ flag = false;
+
+ auto action3 = menuBar.addAction(QStringLiteral("3"), this, functor);
+ action3->activate(QAction::Trigger);
+ QVERIFY(flag);
+}
+
+void tst_QMenuBar::QTBUG_25669_menubarActionDoubleTriggered()
+{
+ QMainWindow win;
+ win.menuBar()->setNativeMenuBar(false);
+ QAction *act1 = win.menuBar()->addAction("Action1");
+ QAction *act2 = win.menuBar()->addAction("Action2");
+ QSignalSpy spy(win.menuBar(), &QMenuBar::triggered);
+
+ win.show();
+ QApplication::setActiveWindow(&win);
+ QVERIFY(QTest::qWaitForWindowExposed(&win));
+
+ QPoint posAct1 = menuBarActionWindowPos(win.menuBar(), act1);
+ QPoint posAct2 = menuBarActionWindowPos(win.menuBar(), act2);
+
+ QTest::mouseClick(win.windowHandle(), Qt::LeftButton, Qt::NoModifier, posAct1);
+ QTRY_COMPARE(spy.count(), 1);
+
+ QTest::mouseClick(win.windowHandle(), Qt::LeftButton, Qt::NoModifier, posAct2);
+ QTRY_COMPARE(spy.count(), 2);
+
+ QTest::mouseClick(win.windowHandle(), Qt::LeftButton, Qt::NoModifier, posAct2);
+ QTRY_COMPARE(spy.count(), 3);
+}
+
void tst_QMenuBar::slotForTaskQTBUG53205()
{
QWidget *parent = taskQTBUG53205MenuBar->parentWidget();
- taskQTBUG53205MenuBar->setParent(Q_NULLPTR);
+ taskQTBUG53205MenuBar->setParent(nullptr);
taskQTBUG53205MenuBar->setParent(parent);
}
diff --git a/tests/auto/widgets/widgets/qopenglwidget/BLACKLIST b/tests/auto/widgets/widgets/qopenglwidget/BLACKLIST
index 7825c33a0a..b67c8354e8 100644
--- a/tests/auto/widgets/widgets/qopenglwidget/BLACKLIST
+++ b/tests/auto/widgets/widgets/qopenglwidget/BLACKLIST
@@ -1,18 +1,5 @@
[clearAndGrab]
-opensuse-13.1
ubuntu
-#QTBUG-31611
-[painter]
-windows msvc-2010 32bit developer-build
-
-#QTBUG-31611
-[reparentToAlreadyCreated]
-windows msvc-2010 32bit developer-build
-
-#QTBUG-31611
-[reparentToNotYetCreated]
-windows msvc-2010 32bit developer-build
-
[stackWidgetOpaqueChildIsVisible]
windows
diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp
index 2a05900adc..db125f6644 100644
--- a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp
+++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp
@@ -62,6 +62,8 @@ private slots:
void showHide();
void nativeWindow();
void stackWidgetOpaqueChildIsVisible();
+ void offscreen();
+ void offscreenThenOnscreen();
};
void tst_QOpenGLWidget::initTestCase()
@@ -75,15 +77,17 @@ void tst_QOpenGLWidget::create()
{
QScopedPointer<QOpenGLWidget> w(new QOpenGLWidget);
QVERIFY(!w->isValid());
+ QVERIFY(w->textureFormat() == 0);
QSignalSpy frameSwappedSpy(w.data(), SIGNAL(frameSwapped()));
w->show();
- QTest::qWaitForWindowExposed(w.data());
+ QVERIFY(QTest::qWaitForWindowExposed(w.data()));
QVERIFY(frameSwappedSpy.count() > 0);
QVERIFY(w->isValid());
QVERIFY(w->context());
QCOMPARE(w->context()->format(), w->format());
QVERIFY(w->defaultFramebufferObject() != 0);
+ QVERIFY(w->textureFormat() != 0);
}
class ClearWidget : public QOpenGLWidget, protected QOpenGLFunctions
@@ -96,16 +100,16 @@ public:
m_w(expectedWidth), m_h(expectedHeight),
r(1.0f), g(0.0f), b(0.0f) { }
- void initializeGL() Q_DECL_OVERRIDE {
+ void initializeGL() override {
m_initCalled = true;
initializeOpenGLFunctions();
}
- void paintGL() Q_DECL_OVERRIDE {
+ void paintGL() override {
m_paintCalled = true;
glClearColor(r, g, b, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
}
- void resizeGL(int w, int h) Q_DECL_OVERRIDE {
+ void resizeGL(int w, int h) override {
m_resizeCalled = true;
m_resizeOk = w == m_w && h == m_h;
}
@@ -127,7 +131,7 @@ void tst_QOpenGLWidget::clearAndGrab()
QScopedPointer<ClearWidget> w(new ClearWidget(0, 800, 600));
w->resize(800, 600);
w->show();
- QTest::qWaitForWindowExposed(w.data());
+ QVERIFY(QTest::qWaitForWindowExposed(w.data()));
QVERIFY(w->m_initCalled);
QVERIFY(w->m_resizeCalled);
QVERIFY(w->m_resizeOk);
@@ -145,7 +149,7 @@ void tst_QOpenGLWidget::clearAndResizeAndGrab()
QScopedPointer<QOpenGLWidget> w(new ClearWidget(0, 640, 480));
w->resize(640, 480);
w->show();
- QTest::qWaitForWindowExposed(w.data());
+ QVERIFY(QTest::qWaitForWindowExposed(w.data()));
QImage image = w->grabFramebuffer();
QVERIFY(!image.isNull());
@@ -168,7 +172,7 @@ void tst_QOpenGLWidget::createNonTopLevel()
QSignalSpy frameSwappedSpy(glw, SIGNAL(frameSwapped()));
w.resize(400, 400);
w.show();
- QTest::qWaitForWindowExposed(&w);
+ QVERIFY(QTest::qWaitForWindowExposed(&w));
QVERIFY(frameSwappedSpy.count() > 0);
QVERIFY(glw->m_resizeCalled);
@@ -199,10 +203,10 @@ public:
PainterWidget(QWidget *parent)
: QOpenGLWidget(parent), m_clear(false) { }
- void initializeGL() Q_DECL_OVERRIDE {
+ void initializeGL() override {
initializeOpenGLFunctions();
}
- void paintGL() Q_DECL_OVERRIDE {
+ void paintGL() override {
QPainter p(this);
QCOMPARE(p.device()->width(), width());
QCOMPARE(p.device()->height(), height());
@@ -224,7 +228,7 @@ void tst_QOpenGLWidget::painter()
w.resize(640, 480);
glw->resize(320, 200);
w.show();
- QTest::qWaitForWindowExposed(&w);
+ QVERIFY(QTest::qWaitForWindowExposed(&w));
QImage image = glw->grabFramebuffer();
QCOMPARE(image.width(), glw->width());
@@ -245,11 +249,11 @@ void tst_QOpenGLWidget::reparentToAlreadyCreated()
w1.resize(640, 480);
glw->resize(320, 200);
w1.show();
- QTest::qWaitForWindowExposed(&w1);
+ QVERIFY(QTest::qWaitForWindowExposed(&w1));
QWidget w2;
w2.show();
- QTest::qWaitForWindowExposed(&w2);
+ QVERIFY(QTest::qWaitForWindowExposed(&w2));
glw->setParent(&w2);
glw->show();
@@ -267,12 +271,12 @@ void tst_QOpenGLWidget::reparentToNotYetCreated()
w1.resize(640, 480);
glw->resize(320, 200);
w1.show();
- QTest::qWaitForWindowExposed(&w1);
+ QVERIFY(QTest::qWaitForWindowExposed(&w1));
QWidget w2;
glw->setParent(&w2);
w2.show();
- QTest::qWaitForWindowExposed(&w2);
+ QVERIFY(QTest::qWaitForWindowExposed(&w2));
QImage image = glw->grabFramebuffer();
QCOMPARE(image.width(), 320);
@@ -293,12 +297,12 @@ void tst_QOpenGLWidget::reparentHidden()
glw->hide(); // Explicitly hidden
- QTest::qWaitForWindowExposed(&topLevel1);
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel1));
QWidget topLevel2;
topLevel2.resize(640, 480);
topLevel2.show();
- QTest::qWaitForWindowExposed(&topLevel2);
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel2));
QOpenGLContext *originalContext = glw->context();
QVERIFY(originalContext);
@@ -318,7 +322,7 @@ public:
void resetPaintCount() { m_count = 0; }
protected:
- void drawForeground(QPainter *, const QRectF &) Q_DECL_OVERRIDE;
+ void drawForeground(QPainter *, const QRectF &) override;
int m_count;
};
@@ -349,7 +353,7 @@ void tst_QOpenGLWidget::asViewport()
layout->addWidget(btn);
widget.setLayout(layout);
widget.show();
- QTest::qWaitForWindowExposed(&widget);
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
QVERIFY(view->paintCount() > 0);
view->resetPaintCount();
@@ -368,7 +372,7 @@ class PaintCountWidget : public QOpenGLWidget
public:
PaintCountWidget() : m_count(0) { }
void reset() { m_count = 0; }
- void paintGL() Q_DECL_OVERRIDE { ++m_count; }
+ void paintGL() override { ++m_count; }
int m_count;
};
@@ -377,7 +381,7 @@ void tst_QOpenGLWidget::requestUpdate()
PaintCountWidget w;
w.resize(640, 480);
w.show();
- QTest::qWaitForWindowExposed(&w);
+ QVERIFY(QTest::qWaitForWindowExposed(&w));
w.reset();
QCOMPARE(w.m_count, 0);
@@ -389,7 +393,7 @@ void tst_QOpenGLWidget::requestUpdate()
class FboCheckWidget : public QOpenGLWidget
{
public:
- void paintGL() Q_DECL_OVERRIDE {
+ void paintGL() override {
GLuint reportedDefaultFbo = QOpenGLContext::currentContext()->defaultFramebufferObject();
GLuint expectedDefaultFbo = defaultFramebufferObject();
QCOMPARE(reportedDefaultFbo, expectedDefaultFbo);
@@ -401,7 +405,7 @@ void tst_QOpenGLWidget::fboRedirect()
FboCheckWidget w;
w.resize(640, 480);
w.show();
- QTest::qWaitForWindowExposed(&w);
+ QVERIFY(QTest::qWaitForWindowExposed(&w));
// Unlike in paintGL(), the default fbo reported by the context is not affected by the widget,
// so we get the real default fbo: either 0 or (on iOS) the fbo associated with the window.
@@ -416,7 +420,7 @@ void tst_QOpenGLWidget::showHide()
QScopedPointer<ClearWidget> w(new ClearWidget(0, 800, 600));
w->resize(800, 600);
w->show();
- QTest::qWaitForWindowExposed(w.data());
+ QVERIFY(QTest::qWaitForWindowExposed(w.data()));
w->hide();
@@ -428,7 +432,7 @@ void tst_QOpenGLWidget::showHide()
w->setClearColor(0, 0, 1);
w->show();
- QTest::qWaitForWindowExposed(w.data());
+ QVERIFY(QTest::qWaitForWindowExposed(w.data()));
image = w->grabFramebuffer();
QVERIFY(!image.isNull());
@@ -443,7 +447,7 @@ void tst_QOpenGLWidget::nativeWindow()
w->resize(800, 600);
w->show();
w->winId();
- QTest::qWaitForWindowExposed(w.data());
+ QVERIFY(QTest::qWaitForWindowExposed(w.data()));
QImage image = w->grabFramebuffer();
QVERIFY(!image.isNull());
@@ -462,7 +466,7 @@ void tst_QOpenGLWidget::nativeWindow()
child->resize(400, 400);
child->move(23, 34);
nativeParent.show();
- QTest::qWaitForWindowExposed(&nativeParent);
+ QVERIFY(QTest::qWaitForWindowExposed(&nativeParent));
QVERIFY(nativeParent.internalWinId());
QVERIFY(!child->internalWinId());
@@ -582,8 +586,8 @@ void tst_QOpenGLWidget::stackWidgetOpaqueChildIsVisible()
stack.setCurrentIndex(0);
stack.resize(dimensionSize, dimensionSize);
stack.show();
- QTest::qWaitForWindowExposed(&stack);
- QTest::qWaitForWindowActive(&stack);
+ QVERIFY(QTest::qWaitForWindowExposed(&stack));
+ QVERIFY(QTest::qWaitForWindowActive(&stack));
// Switch to the QOpenGLWidget.
stack.setCurrentIndex(1);
@@ -603,6 +607,74 @@ void tst_QOpenGLWidget::stackWidgetOpaqueChildIsVisible()
#undef VERIFY_COLOR
}
+void tst_QOpenGLWidget::offscreen()
+{
+ {
+ QScopedPointer<ClearWidget> w(new ClearWidget(0, 800, 600));
+ w->resize(800, 600);
+
+ w->setClearColor(0, 0, 1);
+ QImage image = w->grabFramebuffer();
+
+ QVERIFY(!image.isNull());
+ QCOMPARE(image.width(), w->width());
+ QCOMPARE(image.height(), w->height());
+ QVERIFY(image.pixel(30, 40) == qRgb(0, 0, 255));
+ }
+
+ // QWidget::grab() should eventually end up in grabFramebuffer() as well
+ {
+ QScopedPointer<ClearWidget> w(new ClearWidget(0, 800, 600));
+ w->resize(800, 600);
+
+ w->setClearColor(0, 0, 1);
+ QPixmap pm = w->grab();
+ QImage image = pm.toImage();
+
+ QVERIFY(!image.isNull());
+ QCOMPARE(image.width(), w->width());
+ QCOMPARE(image.height(), w->height());
+ QVERIFY(image.pixel(30, 40) == qRgb(0, 0, 255));
+ }
+
+ // ditto for QWidget::render()
+ {
+ QScopedPointer<ClearWidget> w(new ClearWidget(0, 800, 600));
+ w->resize(800, 600);
+
+ w->setClearColor(0, 0, 1);
+ QImage image(800, 600, QImage::Format_ARGB32);
+ w->render(&image);
+
+ QVERIFY(image.pixel(30, 40) == qRgb(0, 0, 255));
+ }
+}
+
+void tst_QOpenGLWidget::offscreenThenOnscreen()
+{
+ QScopedPointer<ClearWidget> w(new ClearWidget(0, 800, 600));
+ w->resize(800, 600);
+
+ w->setClearColor(0, 0, 1);
+ QImage image = w->grabFramebuffer();
+
+ QVERIFY(!image.isNull());
+ QCOMPARE(image.width(), w->width());
+ QCOMPARE(image.height(), w->height());
+ QVERIFY(image.pixel(30, 40) == qRgb(0, 0, 255));
+
+ // now let's make things more challenging: show. Internally this needs
+ // recreating the context.
+ w->show();
+ QVERIFY(QTest::qWaitForWindowExposed(w.data()));
+
+ image = w->grabFramebuffer();
+ QVERIFY(!image.isNull());
+ QCOMPARE(image.width(), w->width());
+ QCOMPARE(image.height(), w->height());
+ QVERIFY(image.pixel(30, 40) == qRgb(0, 0, 255));
+}
+
QTEST_MAIN(tst_QOpenGLWidget)
#include "tst_qopenglwidget.moc"
diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
index af0ad1a601..a08a8862b8 100644
--- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
+++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
@@ -870,7 +870,7 @@ void tst_QPlainTextEdit::lineWrapModes()
// QPlainTextEdit does lazy line layout on resize, only for the visible blocks.
// We thus need to make it wide enough to show something visible.
int minimumWidth = 2 * ed->document()->documentMargin();
- minimumWidth += ed->fontMetrics().width(QLatin1Char('a'));
+ minimumWidth += ed->fontMetrics().horizontalAdvance(QLatin1Char('a'));
minimumWidth += ed->frameWidth();
ed->resize(minimumWidth, 1000);
QCOMPARE(lineCount(), 26);
diff --git a/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp b/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp
index 205ef34958..35209c2501 100644
--- a/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp
+++ b/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp
@@ -45,6 +45,7 @@ private slots:
void destroyIndeterminate();
void text();
void format();
+ void setValueRepaint_data();
void setValueRepaint();
#ifndef Q_OS_MAC
void setMinMaxRepaint();
@@ -191,21 +192,49 @@ void tst_QProgressBar::format()
QCOMPARE(bar.text(), QString());
}
+void tst_QProgressBar::setValueRepaint_data()
+{
+ QTest::addColumn<int>("min");
+ QTest::addColumn<int>("max");
+ QTest::addColumn<int>("increment");
+
+ auto add = [](int min, int max, int increment) {
+ QTest::addRow("%d-%d@%d", min, max, increment) << min << max << increment;
+ };
+
+ add(0, 10, 1);
+
+ auto add_set = [=](int min, int max, int increment) {
+ // check corner cases, and adjacent values (to circumvent explicit checks for corner cases)
+ add(min, max, increment);
+ add(min + 1, max, increment);
+ add(min, max - 1, increment);
+ add(min + 1, max - 1, increment);
+ };
+
+ add_set(INT_MIN, INT_MAX, INT_MAX / 50 + 1);
+ add_set(0, INT_MAX, INT_MAX / 100 + 1);
+ add_set(INT_MIN, 0, INT_MAX / 100 + 1);
+}
+
void tst_QProgressBar::setValueRepaint()
{
+ QFETCH(int, min);
+ QFETCH(int, max);
+ QFETCH(int, increment);
+
ProgressBar pbar;
- pbar.setMinimum(0);
- pbar.setMaximum(10);
+ pbar.setMinimum(min);
+ pbar.setMaximum(max);
pbar.setFormat("%v");
pbar.move(300, 300);
pbar.show();
QVERIFY(QTest::qWaitForWindowExposed(&pbar));
QApplication::processEvents();
- for (int i = pbar.minimum(); i < pbar.maximum(); ++i) {
+ for (qint64 i = min; i < max; i += increment) {
pbar.repainted = false;
- pbar.setValue(i);
- QTest::qWait(50);
+ pbar.setValue(int(i));
QTRY_VERIFY(pbar.repainted);
}
}
@@ -264,7 +293,7 @@ void tst_QProgressBar::sizeHint()
QFontMetrics fm = bar.fontMetrics();
QStyleOptionProgressBar opt;
bar.initStyleOption(&opt);
- QSize size = QSize(9 * 7 + fm.width(QLatin1Char('0')) * 4, fm.height() + 8);
+ QSize size = QSize(9 * 7 + fm.horizontalAdvance(QLatin1Char('0')) * 4, fm.height() + 8);
size= bar.style()->sizeFromContents(QStyle::CT_ProgressBar, &opt, size, &bar);
QSize barSize = bar.sizeHint();
QVERIFY(barSize.width() >= size.width());
diff --git a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
index 7bbbc46b5a..2b54008de7 100644
--- a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+++ b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
@@ -520,9 +520,6 @@ void tst_QPushButton::sizeHint_data()
#if !defined(QT_NO_STYLE_FUSION)
QTest::newRow("fusion") << QString::fromLatin1("fusion");
#endif
-#if defined(Q_OS_WIN) && !defined(QT_NO_STYLE_WINDOWSXP)
- QTest::newRow("windowsxp") << QString::fromLatin1("windowsxp");
-#endif
#if defined(Q_OS_WIN) && !defined(QT_NO_STYLE_WINDOWSVISTA)
QTest::newRow("windowsvista") << QString::fromLatin1("windowsvista");
#endif
@@ -597,7 +594,7 @@ void tst_QPushButton::taskQTBUG_20191_shortcutWithKeypadModifer()
QDialog dialog;
dialog.setLayout(layout);
dialog.show();
- QTest::qWaitForWindowExposed(&dialog);
+ QVERIFY(QTest::qWaitForWindowExposed(&dialog));
QApplication::setActiveWindow(&dialog);
// add shortcut '5' to button1 and test with keyboard and keypad '5' keys
@@ -642,7 +639,7 @@ void tst_QPushButton::emitReleasedAfterChange()
QDialog dialog;
dialog.setLayout(layout);
dialog.show();
- QTest::qWaitForWindowExposed(&dialog);
+ QVERIFY(QTest::qWaitForWindowExposed(&dialog));
QApplication::setActiveWindow(&dialog);
button1->setFocus();
diff --git a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp
index f9a3e51977..278f5cdd68 100644
--- a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp
+++ b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp
@@ -71,7 +71,7 @@ void tst_QScrollBar::scrollSingleStep()
testWidget.resize(100, testWidget.height());
centerOnScreen(&testWidget);
testWidget.show();
- QTest::qWaitForWindowExposed(&testWidget);
+ QVERIFY(QTest::qWaitForWindowExposed(&testWidget));
testWidget.setValue(testWidget.minimum());
QCOMPARE(testWidget.value(), testWidget.minimum());
@@ -110,7 +110,7 @@ void tst_QScrollBar::task_209492()
verticalScrollBar->setRange(0, 1000);
centerOnScreen(&scrollArea);
scrollArea.show();
- QTest::qWaitForWindowExposed(&scrollArea);
+ QVERIFY(QTest::qWaitForWindowExposed(&scrollArea));
QSignalSpy spy(verticalScrollBar, SIGNAL(actionTriggered(int)));
QCOMPARE(scrollArea.scrollCount, 0);
@@ -147,7 +147,7 @@ void tst_QScrollBar::QTBUG_27308()
testWidget.resize(100, testWidget.height());
centerOnScreen(&testWidget);
testWidget.show();
- QTest::qWaitForWindowExposed(&testWidget);
+ QVERIFY(QTest::qWaitForWindowExposed(&testWidget));
testWidget.setValue(testWidget.minimum());
testWidget.setEnabled(false);
@@ -176,7 +176,7 @@ void tst_QScrollBar::QTBUG_42871()
scrollBarWidget.resize(100, scrollBarWidget.height());
centerOnScreen(&scrollBarWidget);
scrollBarWidget.show();
- QTest::qWaitForWindowExposed(&scrollBarWidget);
+ QVERIFY(QTest::qWaitForWindowExposed(&scrollBarWidget));
QSignalSpy spy(&scrollBarWidget, SIGNAL(actionTriggered(int)));
QVERIFY(spy.isValid());
QCOMPARE(myHandler.updatesCount, 0);
diff --git a/tests/auto/widgets/widgets/qspinbox/BLACKLIST b/tests/auto/widgets/widgets/qspinbox/BLACKLIST
deleted file mode 100644
index 5bf6c3beed..0000000000
--- a/tests/auto/widgets/widgets/qspinbox/BLACKLIST
+++ /dev/null
@@ -1,3 +0,0 @@
-[editingFinished]
-osx-10.8
-osx-10.9
diff --git a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp
index 72e6ffdeb5..cad7bd69d7 100644
--- a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp
+++ b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp
@@ -299,7 +299,7 @@ class TestSplitterStyle : public QProxyStyle
{
public:
TestSplitterStyle() : handleWidth(5) {}
- int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const Q_DECL_OVERRIDE
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const override
{
if (metric == QStyle::PM_SplitterWidth)
return handleWidth;
@@ -658,13 +658,34 @@ public:
class EventCounterSpy : public QObject
{
public:
- EventCounterSpy(QWidget *parentWidget) : QObject(parentWidget)
+ EventCounterSpy(QWidget *obj) : objectToWatch(obj)
{ }
+ ~EventCounterSpy()
+ {
+ removeEventFilter();
+ }
+
+ void installEventFilter()
+ {
+ if (needRemoveEventFilter)
+ return;
+ needRemoveEventFilter = true;
+ qApp->installEventFilter(this);
+ }
+
+ void removeEventFilter()
+ {
+ if (!needRemoveEventFilter)
+ return;
+ needRemoveEventFilter = false;
+ qApp->removeEventFilter(this);
+ }
+
bool eventFilter(QObject *watched, QEvent *event) override
{
// Watch for events in the parent widget and all its children
- if (watched == parent() || watched->parent() == parent()) {
+ if (watched == objectToWatch || watched->parent() == objectToWatch) {
if (event->type() == QEvent::Resize)
resizeCount++;
else if (event->type() == QEvent::Paint)
@@ -676,6 +697,8 @@ public:
int resizeCount = 0;
int paintCount = 0;
+ bool needRemoveEventFilter = false;
+ QObject *objectToWatch;
};
void tst_QSplitter::replaceWidget_data()
@@ -733,31 +756,30 @@ void tst_QSplitter::replaceWidget()
// to set a shorter label.
QLabel *newWidget = new QLabel(QLatin1String("<b>NEW</b>"));
- EventCounterSpy *ef = new EventCounterSpy(&sp);
- qApp->installEventFilter(ef);
+ EventCounterSpy ef(&sp);
+ ef.installEventFilter();
const QWidget *res = sp.replaceWidget(index, newWidget);
QTest::qWait(100); // Give visibility and resizing some time
- qApp->removeEventFilter(ef);
// Check
if (index < 0 || index >= count) {
QVERIFY(!res);
QVERIFY(!newWidget->parentWidget());
- QCOMPARE(ef->resizeCount, 0);
- QCOMPARE(ef->paintCount, 0);
+ QCOMPARE(ef.resizeCount, 0);
+ QCOMPARE(ef.paintCount, 0);
} else {
QCOMPARE(res, oldWidget);
QVERIFY(!res->parentWidget());
QVERIFY(!res->isVisible());
+ const int expectedResizeCount = visible ? 1 : 0; // new widget only
+ const int expectedPaintCount = visible && !collapsed ? 2 : 0; // splitter and new widget
+ QTRY_COMPARE(ef.resizeCount, expectedResizeCount);
+ QTRY_COMPARE(ef.paintCount, expectedPaintCount);
QCOMPARE(newWidget->parentWidget(), &sp);
QCOMPARE(newWidget->isVisible(), visible);
if (visible && !collapsed)
QCOMPARE(newWidget->geometry(), oldGeom);
QCOMPARE(newWidget->size().isEmpty(), !visible || collapsed);
- const int expectedResizeCount = visible ? 1 : 0; // new widget only
- const int expectedPaintCount = visible && !collapsed ? 2 : 0; // splitter and new widget
- QCOMPARE(ef->resizeCount, expectedResizeCount);
- QCOMPARE(ef->paintCount, expectedPaintCount);
delete res;
}
QCOMPARE(sp.count(), count);
@@ -797,25 +819,24 @@ void tst_QSplitter::replaceWidgetWithSplitterChild()
const QList<int> sizes = sp.sizes();
QWidget *sibling = srcIndex == -1 ? (new QLabel("<b>NEW</b>", &sp)) : sp.widget(srcIndex);
- EventCounterSpy *ef = new EventCounterSpy(&sp);
- qApp->installEventFilter(ef);
+ EventCounterSpy ef(&sp);
+ ef.installEventFilter();
const QWidget *res = sp.replaceWidget(dstIndex, sibling);
QTest::qWait(100); // Give visibility and resizing some time
- qApp->removeEventFilter(ef);
QVERIFY(!res);
if (srcIndex == -1) {
// Create and replace before recalc. The sibling is scheduled to be
// added after replaceWidget(), when QSplitter receives a child event.
- QVERIFY(ef->resizeCount > 0);
- QVERIFY(ef->paintCount > 0);
+ QTRY_VERIFY(ef.resizeCount > 0);
+ QTRY_VERIFY(ef.paintCount > 0);
QCOMPARE(sp.count(), count + 1);
QCOMPARE(sp.sizes().mid(0, count), sizes);
QCOMPARE(sp.sizes().last(), sibling->width());
} else {
// No-op for the rest
- QCOMPARE(ef->resizeCount, 0);
- QCOMPARE(ef->paintCount, 0);
+ QCOMPARE(ef.resizeCount, 0);
+ QCOMPARE(ef.paintCount, 0);
QCOMPARE(sp.count(), count);
QCOMPARE(sp.sizes(), sizes);
}
@@ -828,7 +849,7 @@ void tst_QSplitter::handleMinimumWidth()
split.addWidget(new QLabel("Number Too"));
split.show();
- QTest::qWaitForWindowExposed(&split);
+ QVERIFY(QTest::qWaitForWindowExposed(&split));
for (int i = 0; i < 10; i++) {
split.setHandleWidth(i);
QTest::qWait(100); // resizing
diff --git a/tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp b/tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp
index 2df5f01627..59a334fab9 100644
--- a/tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp
+++ b/tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp
@@ -180,7 +180,7 @@ void tst_QStackedWidget::dynamicPages()
sw->resize(200, 200);
sw->show();
qApp->setActiveWindow(sw);
- QTest::qWaitForWindowActive(sw);
+ QVERIFY(QTest::qWaitForWindowActive(sw));
QTRY_COMPARE(QApplication::focusWidget(), le11);
sw->setCurrentIndex(1);
diff --git a/tests/auto/widgets/widgets/qtabbar/BLACKLIST b/tests/auto/widgets/widgets/qtabbar/BLACKLIST
index 5a3f33e3e4..735b044d8b 100644
--- a/tests/auto/widgets/widgets/qtabbar/BLACKLIST
+++ b/tests/auto/widgets/widgets/qtabbar/BLACKLIST
@@ -1,3 +1,2 @@
[sizeHints]
-ubuntu-14.04
redhatenterpriselinuxworkstation-6.6
diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
index 55ef44f4e0..f383d430d6 100644
--- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
+++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
@@ -2507,7 +2507,7 @@ void tst_QTextEdit::highlightLongLine()
};
NumHighlighter nh(edit.document());
edit.show();
- QTest::qWaitForWindowActive(edit.windowHandle());
+ QVERIFY(QTest::qWaitForWindowActive(edit.windowHandle()));
QCoreApplication::processEvents();
//If there is a quadratic behaviour, this would take forever.
QVERIFY(true);
@@ -2604,30 +2604,20 @@ namespace {
class MyPaintEngine : public QPaintEngine
{
public:
- bool begin(QPaintDevice *)
- {
- return true;
- }
+ bool begin(QPaintDevice *) override { return true; }
- bool end()
- {
- return true;
- }
+ bool end() override { return true; }
- void updateState(const QPaintEngineState &)
- {
- }
+ void updateState(const QPaintEngineState &) override { }
- void drawPixmap(const QRectF &, const QPixmap &, const QRectF &)
- {
- }
+ void drawPixmap(const QRectF &, const QPixmap &, const QRectF &) override { }
- void drawTextItem(const QPointF &, const QTextItem &textItem) Q_DECL_OVERRIDE
+ void drawTextItem(const QPointF &, const QTextItem &textItem) override
{
itemFonts.append(qMakePair(textItem.text(), textItem.font()));
}
- Type type() const { return User; }
+ Type type() const override { return User; }
QList<QPair<QString, QFont> > itemFonts;