summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/dialogs/qcolordialog/qcolordialog.pro3
-rw-r--r--tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp2
-rw-r--r--tests/auto/widgets/dialogs/qdialog/BLACKLIST2
-rw-r--r--tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp35
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/qfiledialog.pro2
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp16
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp81
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp196
-rw-r--r--tests/auto/widgets/dialogs/qfontdialog/BLACKLIST5
-rw-r--r--tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog_mac_helpers.mm2
-rw-r--r--tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp274
-rw-r--r--tests/auto/widgets/dialogs/qprogressdialog/BLACKLIST2
-rw-r--r--tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp96
-rw-r--r--tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp4
-rw-r--r--tests/auto/widgets/gestures/qgesturerecognizer/BLACKLIST2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp11
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp8
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp32
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp4
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp38
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp113
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp47
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST18
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp13
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp18
-rw-r--r--tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp42
-rw-r--r--tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp4
-rw-r--r--tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp52
-rw-r--r--tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp16
-rw-r--r--tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp17
-rw-r--r--tests/auto/widgets/itemviews/qlistview/qlistview.pro1
-rw-r--r--tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp54
-rw-r--r--tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp10
-rw-r--r--tests/auto/widgets/itemviews/qtableview/BLACKLIST2
-rw-r--r--tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp12
-rw-r--r--tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp25
-rw-r--r--tests/auto/widgets/itemviews/qtreeview/qtreeview.pro2
-rw-r--r--tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp53
-rw-r--r--tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp53
-rw-r--r--tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp4
-rw-r--r--tests/auto/widgets/kernel/qaction/BLACKLIST2
-rw-r--r--tests/auto/widgets/kernel/qaction/tst_qaction.cpp2
-rw-r--r--tests/auto/widgets/kernel/qactiongroup/BLACKLIST2
-rw-r--r--tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp3
-rw-r--r--tests/auto/widgets/kernel/qapplication/BLACKLIST4
-rw-r--r--tests/auto/widgets/kernel/qapplication/qapplication.pro3
-rw-r--r--tests/auto/widgets/kernel/qapplication/test/BLACKLIST2
-rw-r--r--tests/auto/widgets/kernel/qapplication/test/test.pro9
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp159
-rw-r--r--tests/auto/widgets/kernel/qapplication/wincmdline/main.cpp46
-rw-r--r--tests/auto/widgets/kernel/qapplication/wincmdline/wincmdline.pro5
-rw-r--r--tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp103
-rw-r--r--tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp1
-rw-r--r--tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp429
-rw-r--r--tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp160
-rw-r--r--tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp7
-rw-r--r--tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp24
-rw-r--r--tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp21
-rw-r--r--tests/auto/widgets/kernel/qtooltip/BLACKLIST4
-rw-r--r--tests/auto/widgets/kernel/qwidget/BLACKLIST78
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp135
-rw-r--r--tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp91
-rw-r--r--tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp33
-rw-r--r--tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp6
-rw-r--r--tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp4
-rw-r--r--tests/auto/widgets/styles/qstyle/tst_qstyle.cpp10
-rw-r--r--tests/auto/widgets/styles/qstyleoption/tst_qstyleoption.cpp16
-rw-r--r--tests/auto/widgets/styles/qstylesheetstyle/BLACKLIST2
-rw-r--r--tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp192
-rw-r--r--tests/auto/widgets/util/qcompleter/BLACKLIST2
-rw-r--r--tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp22
-rw-r--r--tests/auto/widgets/util/qscroller/tst_qscroller.cpp2
-rw-r--r--tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp2
-rw-r--r--tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp34
-rw-r--r--tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp6
-rw-r--r--tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp36
-rw-r--r--tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp4
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp44
-rw-r--r--tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp8
-rw-r--r--tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp14
-rw-r--r--tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp6
-rw-r--r--tests/auto/widgets/widgets/qdockwidget/BLACKLIST2
-rw-r--r--tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp88
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_0.pngbin148 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_1.pngbin148 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_2.pngbin148 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_0.pngbin148 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_1.pngbin148 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_2.pngbin148 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_0.pngbin148 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_1.pngbin148 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_2.pngbin148 -> 148 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_0.pngbin154 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_1.pngbin154 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_2.pngbin154 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_0.pngbin154 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_1.pngbin154 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_2.pngbin154 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_0.pngbin154 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_1.pngbin154 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_2.pngbin154 -> 154 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp33
-rw-r--r--tests/auto/widgets/widgets/qlineedit/qlineedit.pro1
-rw-r--r--tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp86
-rw-r--r--tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp159
-rw-r--r--tests/auto/widgets/widgets/qmdiarea/BLACKLIST3
-rw-r--r--tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp30
-rw-r--r--tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp20
-rw-r--r--tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp93
-rw-r--r--tests/auto/widgets/widgets/qmenubar/BLACKLIST1
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp150
-rw-r--r--tests/auto/widgets/widgets/qopenglwidget/BLACKLIST2
-rw-r--r--tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp78
-rw-r--r--tests/auto/widgets/widgets/qplaintextedit/qplaintextedit.pro1
-rw-r--r--tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp30
-rw-r--r--tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp2
-rw-r--r--tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp4
-rw-r--r--tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp4
-rw-r--r--tests/auto/widgets/widgets/qsizegrip/BLACKLIST2
-rw-r--r--tests/auto/widgets/widgets/qspinbox/BLACKLIST3
-rw-r--r--tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp2
-rw-r--r--tests/auto/widgets/widgets/qtabbar/BLACKLIST3
-rw-r--r--tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp42
-rw-r--r--tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp60
-rw-r--r--tests/auto/widgets/widgets/qtextedit/qtextedit.pro2
-rw-r--r--tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp48
-rw-r--r--tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp32
-rw-r--r--tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp4
129 files changed, 2383 insertions, 1708 deletions
diff --git a/tests/auto/widgets/dialogs/qcolordialog/qcolordialog.pro b/tests/auto/widgets/dialogs/qcolordialog/qcolordialog.pro
index 22f6bab497..c379e67ec5 100644
--- a/tests/auto/widgets/dialogs/qcolordialog/qcolordialog.pro
+++ b/tests/auto/widgets/dialogs/qcolordialog/qcolordialog.pro
@@ -4,5 +4,4 @@ TARGET = tst_qcolordialog
QT += widgets testlib
SOURCES += tst_qcolordialog.cpp
-
-
+linux*: CONFIG += insignificant_test # Crashes on different Linux distros
diff --git a/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp b/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp
index 59227a6168..c5e31a4bd4 100644
--- a/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp
+++ b/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp
@@ -98,7 +98,7 @@ void tst_QColorDialog::testNativeActiveModalWidget()
TestNativeDialog d;
QTimer::singleShot(1000, &d, SLOT(hide()));
d.exec();
- QVERIFY(&d == d.m_activeModalWidget);
+ QCOMPARE(&d, d.m_activeModalWidget);
}
void tst_QColorDialog::native_activeModalWidget()
diff --git a/tests/auto/widgets/dialogs/qdialog/BLACKLIST b/tests/auto/widgets/dialogs/qdialog/BLACKLIST
new file mode 100644
index 0000000000..3da7337784
--- /dev/null
+++ b/tests/auto/widgets/dialogs/qdialog/BLACKLIST
@@ -0,0 +1,2 @@
+[snapToDefaultButton]
+osx
diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
index a23938959b..37afa7f0a5 100644
--- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
+++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
@@ -42,6 +42,8 @@
#include <QVBoxLayout>
#include <QSizeGrip>
#include <QDesktopWidget>
+#include <QGraphicsProxyWidget>
+#include <QGraphicsView>
#include <QWindow>
#include <private/qguiapplication_p.h>
#include <qpa/qplatformtheme.h>
@@ -88,6 +90,7 @@ private slots:
void snapToDefaultButton();
void transientParent_data();
void transientParent();
+ void dialogInGraphicsView();
private:
DummyDialog *testWidget;
@@ -119,9 +122,11 @@ void tst_QDialog::getSetCheck()
class ToolDialog : public QDialog
{
public:
- ToolDialog(QWidget *parent = 0) : QDialog(parent, Qt::Tool), mWasActive(false), tId(-1) {
- }
+ ToolDialog(QWidget *parent = 0)
+ : QDialog(parent, Qt::Tool), mWasActive(false), mWasModalWindow(false), tId(-1) {}
+
bool wasActive() const { return mWasActive; }
+ bool wasModalWindow() const { return mWasModalWindow; }
int exec() {
tId = startTimer(300);
@@ -132,12 +137,14 @@ protected:
if (tId == event->timerId()) {
killTimer(tId);
mWasActive = isActiveWindow();
+ mWasModalWindow = QGuiApplication::modalWindow() == windowHandle();
reject();
}
}
private:
int mWasActive;
+ bool mWasModalWindow;
int tId;
};
@@ -558,7 +565,7 @@ void tst_QDialog::snapToDefaultButton()
#ifdef QT_NO_CURSOR
QSKIP("Test relies on there being a cursor");
#else
- if (qApp->platformName().toLower() == QLatin1String("wayland"))
+ if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: Wayland does not support setting the cursor position.");
QPoint topLeftPos = QApplication::desktop()->availableGeometry().topLeft();
@@ -617,5 +624,27 @@ void tst_QDialog::transientParent()
QCOMPARE(dialog.windowHandle()->transientParent(), topLevel.windowHandle());
}
+void tst_QDialog::dialogInGraphicsView()
+{
+ // QTBUG-49124: A dialog embedded into QGraphicsView has Qt::WA_DontShowOnScreen
+ // set (as has a native dialog). It must not trigger the modal handling though
+ // as not to lock up.
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ view.setWindowTitle(QTest::currentTestFunction());
+ const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry();
+ view.resize(availableGeometry.size() / 2);
+ view.move(availableGeometry.left() + availableGeometry.width() / 4,
+ availableGeometry.top() + availableGeometry.height() / 4);
+ ToolDialog *dialog = new ToolDialog;
+ scene.addWidget(dialog);
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+ for (int i = 0; i < 3; ++i) {
+ dialog->exec();
+ QVERIFY(!dialog->wasModalWindow());
+ }
+}
+
QTEST_MAIN(tst_QDialog)
#include "tst_qdialog.moc"
diff --git a/tests/auto/widgets/dialogs/qfiledialog/qfiledialog.pro b/tests/auto/widgets/dialogs/qfiledialog/qfiledialog.pro
index 3a96827352..2a11a29420 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/qfiledialog.pro
+++ b/tests/auto/widgets/dialogs/qfiledialog/qfiledialog.pro
@@ -21,3 +21,5 @@ wince* {
} else {
DEFINES += SRCDIR=\\\"$$PWD/\\\"
}
+
+linux*: CONFIG += insignificant_test # Crashes on different Linux distros
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
index 59288bd764..42e2bd09a5 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
@@ -484,11 +484,11 @@ void tst_QFiledialog::completer()
if (startPath.isEmpty()) {
tempDir.reset(new QTemporaryDir);
- QVERIFY(tempDir->isValid());
+ QVERIFY2(tempDir->isValid(), qPrintable(tempDir->errorString()));
startPath = tempDir->path();
for (int i = 0; i < 10; ++i) {
TemporaryFilePtr file(new QTemporaryFile(startPath + QStringLiteral("/rXXXXXX")));
- QVERIFY(file->open());
+ QVERIFY2(file->open(), qPrintable(file->errorString()));
files.append(file);
}
}
@@ -678,7 +678,7 @@ void tst_QFiledialog::filters()
// effects
QList<QComboBox*> views = fd.findChildren<QComboBox*>("fileTypeCombo");
- QVERIFY(views.count() == 1);
+ QCOMPARE(views.count(), 1);
QCOMPARE(views.at(0)->isVisible(), false);
QStringList filters;
@@ -890,7 +890,7 @@ void tst_QFiledialog::selectFile()
QScopedPointer<QTemporaryFile> tempFile;
if (file == QLatin1String("temp")) {
tempFile.reset(new QTemporaryFile(QDir::tempPath() + QStringLiteral("/aXXXXXX")));
- QVERIFY(tempFile->open());
+ QVERIFY2(tempFile->open(), qPrintable(tempFile->errorString()));
file = tempFile->fileName();
}
@@ -928,7 +928,7 @@ void tst_QFiledialog::selectFileWrongCaseSaveAs()
void tst_QFiledialog::selectFiles()
{
QTemporaryDir tempDir;
- QVERIFY(tempDir.isValid());
+ QVERIFY2(tempDir.isValid(), qPrintable(tempDir.errorString()));
const QString tempPath = tempDir.path();
{
QNonNativeFileDialog fd;
@@ -1297,7 +1297,7 @@ void tst_QFiledialog::clearLineEdit()
QLineEdit *lineEdit = fd.findChild<QLineEdit*>("fileNameEdit");
QVERIFY(lineEdit);
- QVERIFY(lineEdit->text() == "foo");
+ QCOMPARE(lineEdit->text(), QLatin1String("foo"));
fd.setDirectory(QDir::home());
QListView* list = fd.findChild<QListView*>("listView");
@@ -1394,12 +1394,12 @@ void tst_QFiledialog::trailingDotsAndSpaces()
QTest::keyClick(lineEdit, Qt::Key_Space);
QTest::keyClick(lineEdit, Qt::Key_Period);
QTest::qWait(1000);
- QVERIFY(currentChildrenCount == list->model()->rowCount(list->rootIndex()));
+ QCOMPARE(currentChildrenCount, list->model()->rowCount(list->rootIndex()));
lineEdit->clear();
QTest::keyClick(lineEdit, Qt::Key_Period);
QTest::keyClick(lineEdit, Qt::Key_Space);
QTest::qWait(1000);
- QVERIFY(currentChildrenCount == list->model()->rowCount(list->rootIndex()));
+ QCOMPARE(currentChildrenCount, list->model()->rowCount(list->rootIndex()));
}
#ifdef Q_OS_UNIX
diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
index ed34c67aad..b457558879 100644
--- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
@@ -57,6 +57,8 @@
#include "../../../../../src/widgets/dialogs/qfilesystemmodel_p.h"
#include "../../../../../src/widgets/dialogs/qfiledialog_p.h"
+#include <qpa/qplatformdialoghelper.h>
+
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
#include "../../../network-settings.h"
#endif
@@ -79,6 +81,12 @@ public:
}
};
+static QByteArray msgDoesNotExist(const QString &name)
+{
+ return (QLatin1Char('"') + QDir::toNativeSeparators(name)
+ + QLatin1String("\" does not exist.")).toLocal8Bit();
+}
+
class tst_QFileDialog2 : public QObject
{
Q_OBJECT
@@ -122,6 +130,7 @@ private slots:
#endif
void completionOnLevelAfterRoot();
void task233037_selectingDirectory();
+ void task235069_hideOnEscape_data();
void task235069_hideOnEscape();
void task203703_returnProperSeparator();
void task228844_ensurePreviousSorting();
@@ -134,6 +143,8 @@ private slots:
void QTBUG6558_showDirsOnly();
void QTBUG4842_selectFilterWithHideNameFilterDetails();
void dontShowCompleterOnRoot();
+ void nameFilterParsing_data();
+ void nameFilterParsing();
private:
void cleanupSettingsFile();
@@ -167,7 +178,7 @@ void tst_QFileDialog2::cleanupSettingsFile()
void tst_QFileDialog2::initTestCase()
{
- QVERIFY(tempDir.isValid());
+ QVERIFY2(tempDir.isValid(), qPrintable(tempDir.errorString()));
QStandardPaths::setTestModeEnabled(true);
cleanupSettingsFile();
}
@@ -239,13 +250,13 @@ void tst_QFileDialog2::deleteDirAndFiles()
QTemporaryFile *t;
t = new QTemporaryFile(tempPath + "/foo/aXXXXXX");
t->setAutoRemove(false);
- t->open();
+ QVERIFY2(t->open(), qPrintable(t->errorString()));
t->close();
delete t;
t = new QTemporaryFile(tempPath + "/foo/B/yXXXXXX");
t->setAutoRemove(false);
- t->open();
+ QVERIFY2(t->open(), qPrintable(t->errorString()));
t->close();
delete t;
FriendlyQFileDialog fd;
@@ -303,7 +314,7 @@ void tst_QFileDialog2::unc()
#else
QString dir(QDir::currentPath());
#endif
- QVERIFY(QFile::exists(dir));
+ QVERIFY2(QFile::exists(dir), msgDoesNotExist(dir).constData());
QNonNativeFileDialog fd(0, QString(), dir);
QFileSystemModel *model = fd.findChild<QFileSystemModel*>("qt_filesystem_model");
QVERIFY(model);
@@ -459,7 +470,7 @@ void tst_QFileDialog2::task180459_lastDirectory_data()
void tst_QFileDialog2::task180459_lastDirectory()
{
- if (qApp->platformName().toLower() == QStringLiteral("cocoa"))
+ if (!QGuiApplication::platformName().compare(QLatin1String("cocoa"), Qt::CaseInsensitive))
QSKIP("Insignificant on OSX"); //QTBUG-39183
//first visit the temp directory and close the dialog
QNonNativeFileDialog *dlg = new QNonNativeFileDialog(0, "", tempDir.path());
@@ -760,26 +771,38 @@ void tst_QFileDialog2::task233037_selectingDirectory()
current.rmdir("test");
}
+void tst_QFileDialog2::task235069_hideOnEscape_data()
+{
+ QTest::addColumn<QString>("childName");
+ QTest::addColumn<QFileDialog::ViewMode>("viewMode");
+ QTest::newRow("listView") << QStringLiteral("listView") << QFileDialog::List;
+ QTest::newRow("fileNameEdit") << QStringLiteral("fileNameEdit") << QFileDialog::List;
+ QTest::newRow("treeView") << QStringLiteral("treeView") << QFileDialog::Detail;
+}
+
void tst_QFileDialog2::task235069_hideOnEscape()
{
+ QFETCH(QString, childName);
+ QFETCH(QFileDialog::ViewMode, viewMode);
QDir current = QDir::currentPath();
+
QNonNativeFileDialog fd;
- fd.setViewMode(QFileDialog::List);
+ QSignalSpy spyFinished(&fd, &QDialog::finished);
+ QVERIFY(spyFinished.isValid());
+ QSignalSpy spyRejected(&fd, &QDialog::rejected);
+ QVERIFY(spyRejected.isValid());
+ fd.setViewMode(viewMode);
fd.setDirectory(current.absolutePath());
- fd.setAcceptMode( QFileDialog::AcceptSave);
+ fd.setAcceptMode(QFileDialog::AcceptSave);
fd.show();
- QListView *list = fd.findChild<QListView*>("listView");
- list->setFocus();
+ QWidget *child = fd.findChild<QWidget *>(childName);
+ QVERIFY(child);
+ child->setFocus();
QTest::qWait(200);
- QTest::keyClick(list, Qt::Key_Escape);
+ QTest::keyClick(child, Qt::Key_Escape);
QCOMPARE(fd.isVisible(), false);
- QNonNativeFileDialog fd2;
- fd2.setDirectory(current.absolutePath());
- fd2.setAcceptMode( QFileDialog::AcceptSave);
- fd2.show();
- QLineEdit *edit = fd2.findChild<QLineEdit*>("fileNameEdit");
- QTest::keyClick(edit, Qt::Key_Escape);
- QCOMPARE(fd2.isVisible(), false);
+ QCOMPARE(spyFinished.count(), 1); // QTBUG-7690
+ QCOMPARE(spyRejected.count(), 1); // reject(), don't hide()
}
#ifdef QT_BUILD_INTERNAL
@@ -845,7 +868,7 @@ void tst_QFileDialog2::task228844_ensurePreviousSorting()
current.mkdir("f");
current.mkdir("g");
QTemporaryFile *tempFile = new QTemporaryFile(current.absolutePath() + "/rXXXXXX");
- tempFile->open();
+ QVERIFY2(tempFile->open(), qPrintable(tempFile->errorString()));
current.cdUp();
QNonNativeFileDialog fd;
@@ -1104,6 +1127,7 @@ void tst_QFileDialog2::task254490_selectFileMultipleTimes()
QString tempPath = tempDir.path();
QTemporaryFile *t;
t = new QTemporaryFile;
+ QVERIFY2(t->open(), qPrintable(t->errorString()));
t->open();
QNonNativeFileDialog fd(0, "TestFileDialog");
@@ -1205,7 +1229,7 @@ void tst_QFileDialog2::QTBUG4419_lineEditSelectAll()
{
QString tempPath = tempDir.path();
QTemporaryFile temporaryFile(tempPath + "/tst_qfiledialog2_lineEditSelectAll.XXXXXX");
- QVERIFY(temporaryFile.open());
+ QVERIFY2(temporaryFile.open(), qPrintable(temporaryFile.errorString()));
QNonNativeFileDialog fd(0, "TestFileDialog", temporaryFile.fileName());
fd.setDirectory(tempPath);
@@ -1353,5 +1377,24 @@ void tst_QFileDialog2::dontShowCompleterOnRoot()
QTRY_VERIFY(lineEdit->completer()->popup()->isHidden());
}
+void tst_QFileDialog2::nameFilterParsing_data()
+{
+ QTest::addColumn<QString>("filterString");
+ QTest::addColumn<QStringList>("filters");
+
+ // QTBUG-47923: Do not trip over "*,v".
+ QTest::newRow("text") << "plain text document (*.txt *.asc *,v *.doc)"
+ << (QStringList() << "*.txt" << "*.asc" << "*,v" << "*.doc");
+ QTest::newRow("html") << "HTML document (*.html *.htm)"
+ << (QStringList() << "*.html" << "*.htm");
+}
+
+void tst_QFileDialog2::nameFilterParsing()
+{
+ QFETCH(QString, filterString);
+ QFETCH(QStringList, filters);
+ QCOMPARE(QPlatformFileDialogHelper::cleanFilterList(filterString), filters);
+}
+
QTEST_MAIN(tst_QFileDialog2)
#include "tst_qfiledialog2.moc"
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
index 03f0d25375..d370a647b4 100644
--- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -78,10 +78,6 @@ private slots:
void indexPath();
void rootPath();
-#ifdef QT_BUILD_INTERNAL
- void naturalCompare_data();
- void naturalCompare();
-#endif
void readOnly();
void iconProvider();
@@ -127,6 +123,9 @@ private slots:
void permissions_data();
void permissions();
+ void doNotUnwatchOnFailedRmdir();
+ void specialFiles();
+
protected:
bool createFiles(const QString &test_path, const QStringList &initial_files, int existingFileCount = 0, const QStringList &intial_dirs = QStringList());
@@ -167,13 +166,13 @@ void tst_QFileSystemModel::cleanup()
QVERIFY(dir.rmdir(list.at(i)));
}
list = dir.entryList(QDir::AllEntries | QDir::System | QDir::Hidden | QDir::NoDotAndDotDot);
- QVERIFY(list.count() == 0);
+ QCOMPARE(list.count(), 0);
}
}
void tst_QFileSystemModel::initTestCase()
{
- QVERIFY(m_tempDir.isValid());
+ QVERIFY2(m_tempDir.isValid(), qPrintable(m_tempDir.errorString()));
flatDirTestPath = m_tempDir.path();
}
@@ -242,83 +241,11 @@ void tst_QFileSystemModel::rootPath()
}
}
-#ifdef QT_BUILD_INTERNAL
-void tst_QFileSystemModel::naturalCompare_data()
-{
- QTest::addColumn<QString>("s1");
- QTest::addColumn<QString>("s2");
- QTest::addColumn<int>("caseSensitive");
- QTest::addColumn<int>("result");
- QTest::addColumn<int>("swap");
-
-#define ROWNAME(name) (qPrintable(QString("prefix=%1, postfix=%2, num=%3, i=%4, test=%5").arg(prefix).arg(postfix).arg(num).arg(i).arg(name)))
-
- for (int j = 0; j < 4; ++j) { // <- set a prefix and a postfix string (not numbers)
- QString prefix = (j == 0 || j == 1) ? "b" : "";
- QString postfix = (j == 1 || j == 2) ? "y" : "";
-
- for (int k = 0; k < 3; ++k) { // <- make 0 not a special case
- QString num = QString("%1").arg(k);
- QString nump = QString("%1").arg(k + 1);
- for (int i = 10; i < 12; ++i) { // <- swap s1 and s2 and reverse the result
- QTest::newRow(ROWNAME("basic")) << prefix + "0" + postfix << prefix + "0" + postfix << int(Qt::CaseInsensitive) << 0;
-
- // s1 should always be less then s2
- QTest::newRow(ROWNAME("just text")) << prefix + "fred" + postfix << prefix + "jane" + postfix << int(Qt::CaseInsensitive) << i;
- QTest::newRow(ROWNAME("just numbers")) << prefix + num + postfix << prefix + "9" + postfix << int(Qt::CaseInsensitive) << i;
- QTest::newRow(ROWNAME("zero")) << prefix + num + postfix << prefix + "0" + nump + postfix << int(Qt::CaseInsensitive) << i;
- QTest::newRow(ROWNAME("space b")) << prefix + num + postfix << prefix + " " + nump + postfix << int(Qt::CaseInsensitive) << i;
- QTest::newRow(ROWNAME("space a")) << prefix + num + postfix << prefix + nump + " " + postfix << int(Qt::CaseInsensitive) << i;
- QTest::newRow(ROWNAME("tab b")) << prefix + num + postfix << prefix + " " + nump + postfix << int(Qt::CaseInsensitive) << i;
- QTest::newRow(ROWNAME("tab a")) << prefix + num + postfix << prefix + nump + " " + postfix << int(Qt::CaseInsensitive) << i;
- QTest::newRow(ROWNAME("10 vs 2")) << prefix + num + postfix << prefix + "10" + postfix << int(Qt::CaseInsensitive) << i;
- QTest::newRow(ROWNAME("diff len")) << prefix + num + postfix << prefix + nump + postfix + "x" << int(Qt::CaseInsensitive) << i;
- QTest::newRow(ROWNAME("01 before 1")) << prefix + "0" + num + postfix << prefix + nump + postfix << int(Qt::CaseInsensitive) << i;
- QTest::newRow(ROWNAME("mul nums 2nd 1")) << prefix + "1-" + num + postfix << prefix + "1-" + nump + postfix << int(Qt::CaseInsensitive) << i;
- QTest::newRow(ROWNAME("mul nums 2nd 2")) << prefix + "10-" + num + postfix<< prefix + "10-10" + postfix << int(Qt::CaseInsensitive) << i;
- QTest::newRow(ROWNAME("mul nums 2nd 3")) << prefix + "10-0"+ num + postfix<< prefix + "10-10" + postfix << int(Qt::CaseInsensitive) << i;
- QTest::newRow(ROWNAME("mul nums 2nd 4")) << prefix + "10-" + num + postfix<< prefix + "10-010" + postfix << int(Qt::CaseInsensitive) << i;
- QTest::newRow(ROWNAME("mul nums big 1")) << prefix + "10-" + num + postfix<< prefix + "20-0" + postfix << int(Qt::CaseInsensitive) << i;
- QTest::newRow(ROWNAME("mul nums big 2")) << prefix + "2-" + num + postfix << prefix + "10-0" + postfix << int(Qt::CaseInsensitive) << i;
- QTest::newRow(ROWNAME("mul alphabet 1")) << prefix + num + "-a" + postfix << prefix + num + "-c" + postfix << int(Qt::CaseInsensitive) << i;
- QTest::newRow(ROWNAME("mul alphabet 2")) << prefix + num + "-a9" + postfix<< prefix + num + "-c0" + postfix << int(Qt::CaseInsensitive) << i;
- QTest::newRow(ROWNAME("mul nums w\\0")) << prefix + num + "-"+ num + postfix<< prefix + num+"-0"+nump + postfix << int(Qt::CaseInsensitive) << i;
- QTest::newRow(ROWNAME("num first")) << prefix + num + postfix << prefix + "a" + postfix << int(Qt::CaseInsensitive) << i;
- }
- }
- }
-#undef ROWNAME
-}
-#endif
-
-#ifdef QT_BUILD_INTERNAL
-void tst_QFileSystemModel::naturalCompare()
-{
- QFETCH(QString, s1);
- QFETCH(QString, s2);
- QFETCH(int, caseSensitive);
- QFETCH(int, result);
-
- if (result == 10)
- QCOMPARE(QFileSystemModelPrivate::naturalCompare(s1, s2, Qt::CaseSensitivity(caseSensitive)), -1);
- else
- if (result == 11)
- QCOMPARE(QFileSystemModelPrivate::naturalCompare(s2, s1, Qt::CaseSensitivity(caseSensitive)), 1);
- else
- QCOMPARE(QFileSystemModelPrivate::naturalCompare(s2, s1, Qt::CaseSensitivity(caseSensitive)), result);
-#if defined(Q_OS_WINCE)
- // On Windows CE we need to wait after each test, otherwise no new threads can be
- // created. The scheduler takes its time to recognize ended threads.
- QTest::qWait(300);
-#endif
-}
-#endif
-
void tst_QFileSystemModel::readOnly()
{
QCOMPARE(model->isReadOnly(), true);
QTemporaryFile file(flatDirTestPath + QStringLiteral("/XXXXXX.dat"));
- file.open();
+ QVERIFY2(file.open(), qPrintable(file.errorString()));
QModelIndex root = model->setRootPath(flatDirTestPath);
QTRY_VERIFY(model->rowCount(root) > 0);
@@ -523,8 +450,14 @@ void tst_QFileSystemModel::rowsInserted()
QVERIFY(createFiles(tmp, QStringList(".hidden_file"), 5 + count));
- if (count != 0) QTRY_VERIFY(spy0.count() >= 1); else QTRY_VERIFY(spy0.count() == 0);
- if (count != 0) QTRY_VERIFY(spy1.count() >= 1); else QTRY_VERIFY(spy1.count() == 0);
+ if (count != 0)
+ QTRY_VERIFY(spy0.count() >= 1);
+ else
+ QTRY_COMPARE(spy0.count(), 0);
+ if (count != 0)
+ QTRY_VERIFY(spy1.count() >= 1);
+ else
+ QTRY_COMPARE(spy1.count(), 0);
}
void tst_QFileSystemModel::rowsRemoved_data()
@@ -563,8 +496,8 @@ void tst_QFileSystemModel::rowsRemoved()
}
} else {
if (i == 10 || spy0.count() == 0) {
- QVERIFY(spy0.count() == 0);
- QVERIFY(spy1.count() == 0);
+ QCOMPARE(spy0.count(), 0);
+ QCOMPARE(spy1.count(), 0);
}
}
QStringList lst;
@@ -583,8 +516,8 @@ void tst_QFileSystemModel::rowsRemoved()
QVERIFY(QFile::remove(tmp + '/' + QString(".c")));
QTest::qWait(WAITTIME);
- if (count != 0) QVERIFY(spy0.count() >= 1); else QVERIFY(spy0.count() == 0);
- if (count != 0) QVERIFY(spy1.count() >= 1); else QVERIFY(spy1.count() == 0);
+ if (count != 0) QVERIFY(spy0.count() >= 1); else QCOMPARE(spy0.count(), 0);
+ if (count != 0) QVERIFY(spy1.count() >= 1); else QCOMPARE(spy1.count(), 0);
}
void tst_QFileSystemModel::dataChanged_data()
@@ -614,7 +547,7 @@ void tst_QFileSystemModel::dataChanged()
QTest::qWait(WAITTIME);
- if (count != 0) QVERIFY(spy.count() >= 1); else QVERIFY(spy.count() == 0);
+ if (count != 0) QVERIFY(spy.count() >= 1); else QCOMPARE(spy.count(), 0);
*/
}
@@ -813,7 +746,7 @@ void tst_QFileSystemModel::setData()
void tst_QFileSystemModel::sortPersistentIndex()
{
QTemporaryFile file(flatDirTestPath + QStringLiteral("/XXXXXX.dat"));
- file.open();
+ QVERIFY2(file.open(), qPrintable(file.errorString()));
QModelIndex root = model->setRootPath(flatDirTestPath);
QTRY_VERIFY(model->rowCount(root) > 0);
@@ -890,18 +823,21 @@ void tst_QFileSystemModel::sort()
QModelIndex parent = myModel->index(dirPath, 0);
QList<QString> expectedOrder;
expectedOrder << tempFile2.fileName() << tempFile.fileName() << dirPath + QChar('/') + ".." << dirPath + QChar('/') + ".";
- //File dialog Mode means sub trees are not sorted, only the current root
+
if (fileDialogMode) {
- // FIXME: we were only able to disableRecursiveSort in developer builds, so we can only
- // stably perform this test for developer builds
-#ifdef QT_BUILD_INTERNAL
- QList<QString> actualRows;
+ // File dialog Mode means sub trees are not sorted, only the current root.
+ // There's no way we can check that the sub tree is "not sorted"; just check if it
+ // has the same contents of the expected list
+ QList<QString> actualRows;
for(int i = 0; i < myModel->rowCount(parent); ++i)
{
actualRows << dirPath + QChar('/') + myModel->index(i, 1, parent).data(QFileSystemModel::FileNameRole).toString();
}
- QVERIFY(actualRows != expectedOrder);
-#endif
+
+ std::sort(expectedOrder.begin(), expectedOrder.end());
+ std::sort(actualRows.begin(), actualRows.end());
+
+ QCOMPARE(actualRows, expectedOrder);
} else {
for(int i = 0; i < myModel->rowCount(parent); ++i)
{
@@ -1113,6 +1049,78 @@ void tst_QFileSystemModel::permissions() // checks QTBUG-20503
QCOMPARE(fileInfoPermissions, modelPermissions);
}
+void tst_QFileSystemModel::doNotUnwatchOnFailedRmdir()
+{
+ const QString tmp = flatDirTestPath;
+
+ QFileSystemModel model;
+
+ const QTemporaryDir tempDir(tmp + '/' + QStringLiteral("doNotUnwatchOnFailedRmdir-XXXXXX"));
+ QVERIFY(tempDir.isValid());
+
+ const QModelIndex rootIndex = model.setRootPath(tempDir.path());
+
+ // create a file in the directory so to prevent it from deletion
+ {
+ QFile file(tempDir.path() + '/' + QStringLiteral("file1"));
+ QVERIFY(file.open(QIODevice::WriteOnly));
+ }
+
+ QCOMPARE(model.rmdir(rootIndex), false);
+
+ // create another file
+ {
+ QFile file(tempDir.path() + '/' + QStringLiteral("file2"));
+ QVERIFY(file.open(QIODevice::WriteOnly));
+ }
+
+ // the model must now detect this second file
+ QTRY_COMPARE(model.rowCount(rootIndex), 2);
+}
+
+static QSet<QString> fileListUnderIndex(const QFileSystemModel *model, const QModelIndex &parent)
+{
+ QSet<QString> fileNames;
+ const int rowCount = model->rowCount(parent);
+ for (int i = 0; i < rowCount; ++i)
+ fileNames.insert(model->index(i, 0, parent).data(QFileSystemModel::FileNameRole).toString());
+ return fileNames;
+}
+
+void tst_QFileSystemModel::specialFiles()
+{
+ QFileSystemModel model;
+
+ model.setFilter(QDir::AllEntries | QDir::System | QDir::Hidden);
+
+ // Can't simply verify if the model returns a valid model index for a special file
+ // as it will always return a valid index for existing files,
+ // even if the file is not visible with the given filter.
+
+#if defined(Q_OS_UNIX)
+ const QModelIndex rootIndex = model.setRootPath(QStringLiteral("/dev/"));
+ const QString testFileName = QStringLiteral("null");
+#elif defined(Q_OS_WIN)
+ const QModelIndex rootIndex = model.setRootPath(flatDirTestPath);
+
+ const QString testFileName = QStringLiteral("linkSource.lnk");
+
+ QFile file(flatDirTestPath + QLatin1String("/linkTarget.txt"));
+ QVERIFY(file.open(QIODevice::WriteOnly));
+ file.close();
+ QVERIFY(file.link(flatDirTestPath + '/' + testFileName));
+#else
+ QSKIP("Not implemented");
+ QModelIndex rootIndex;
+ QString testFileName;
+#endif
+
+ QTRY_VERIFY(fileListUnderIndex(&model, rootIndex).contains(testFileName));
+
+ model.setFilter(QDir::AllEntries | QDir::Hidden);
+
+ QTRY_VERIFY(!fileListUnderIndex(&model, rootIndex).contains(testFileName));
+}
QTEST_MAIN(tst_QFileSystemModel)
#include "tst_qfilesystemmodel.moc"
diff --git a/tests/auto/widgets/dialogs/qfontdialog/BLACKLIST b/tests/auto/widgets/dialogs/qfontdialog/BLACKLIST
new file mode 100644
index 0000000000..6d3c17f35f
--- /dev/null
+++ b/tests/auto/widgets/dialogs/qfontdialog/BLACKLIST
@@ -0,0 +1,5 @@
+[task256466_wrongStyle]
+opensuse-13.1
+[setFont]
+ubuntu-14.04
+redhatenterpriselinuxworkstation-6.6
diff --git a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog_mac_helpers.mm b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog_mac_helpers.mm
index 6e4ad29190..0d29f5b7a2 100644
--- a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog_mac_helpers.mm
+++ b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog_mac_helpers.mm
@@ -36,7 +36,7 @@
void click_cocoa_button()
{
- QMacCocoaAutoReleasePool pool;
+ QMacAutoReleasePool pool;
NSArray *windows = [NSApp windows];
for (NSWindow *window in windows) {
// This is NOT how one should do RTTI, but since I don't want to leak the class too much...
diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
index cb816a7e85..1a4f9077d9 100644
--- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
+++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
@@ -89,13 +89,6 @@
class tst_QMessageBox : public QObject
{
Q_OBJECT
-public:
- tst_QMessageBox();
- int exec(QMessageBox *msgBox, int key = -1);
- void sendKeySoon();
-
-public slots:
- void sendKey();
private slots:
void sanityTest();
@@ -122,12 +115,7 @@ private slots:
void setInformativeText();
void iconPixmap();
- void init();
- void initTestCase();
-
-private:
- int keyToSend;
- QTimer keySendTimer;
+ void cleanup();
};
class tst_ResizingMessageBox : public QMessageBox
@@ -143,51 +131,61 @@ protected:
}
};
-tst_QMessageBox::tst_QMessageBox() : keyToSend(-1)
+// ExecCloseHelper: Closes a modal QDialog during its exec() function by either
+// sending a key event or closing it (CloseWindow) once it becomes the active
+// modal window. Pass nullptr to "autodetect" the instance for static methods.
+class ExecCloseHelper : public QObject
{
-}
+public:
+ enum { CloseWindow = -1 };
-int tst_QMessageBox::exec(QMessageBox *msgBox, int key)
-{
- if (key == -1) {
- QTimer::singleShot(1000, msgBox, SLOT(close()));
- } else {
- keyToSend = key;
- sendKeySoon();
+ explicit ExecCloseHelper(QObject *parent = Q_NULLPTR)
+ : QObject(parent), m_key(0), m_timerId(0), m_testCandidate(Q_NULLPTR) { }
+
+ void start(int key, QWidget *testCandidate = Q_NULLPTR)
+ {
+ m_key = key;
+ m_testCandidate = testCandidate;
+ m_timerId = startTimer(50);
}
- return msgBox->exec();
-}
-void tst_QMessageBox::sendKey()
+ bool done() const { return !m_timerId; }
+
+protected:
+ void timerEvent(QTimerEvent *te) Q_DECL_OVERRIDE;
+
+private:
+ int m_key;
+ int m_timerId;
+ QWidget *m_testCandidate;
+};
+
+void ExecCloseHelper::timerEvent(QTimerEvent *te)
{
- if (keyToSend == -2) {
- QApplication::activeModalWidget()->close();
- keyToSend = -1;
- return;
- }
- if (keyToSend == -1)
+ if (te->timerId() != m_timerId)
return;
- QKeyEvent *ke = new QKeyEvent(QEvent::KeyPress, keyToSend, Qt::NoModifier);
- qApp->postEvent(QApplication::activeModalWidget(), ke);
- keyToSend = -1;
-}
-void tst_QMessageBox::sendKeySoon()
-{
- keySendTimer.start();
-}
+ QWidget *modalWidget = QApplication::activeModalWidget();
-void tst_QMessageBox::init()
-{
- // if there is any pending key send from the last test, cancel it.
- keySendTimer.stop();
+ if (!m_testCandidate && modalWidget)
+ m_testCandidate = modalWidget;
+
+ if (m_testCandidate && m_testCandidate == modalWidget) {
+ if (m_key == CloseWindow) {
+ m_testCandidate->close();
+ } else {
+ QKeyEvent *ke = new QKeyEvent(QEvent::KeyPress, m_key, Qt::NoModifier);
+ QCoreApplication::postEvent(m_testCandidate, ke);
+ }
+ m_testCandidate = Q_NULLPTR;
+ killTimer(m_timerId);
+ m_timerId = m_key = 0;
+ }
}
-void tst_QMessageBox::initTestCase()
+void tst_QMessageBox::cleanup()
{
- keySendTimer.setInterval(1000);
- keySendTimer.setSingleShot(true);
- QVERIFY(QObject::connect(&keySendTimer, SIGNAL(timeout()), this, SLOT(sendKey())));
+ QTRY_VERIFY(QApplication::topLevelWidgets().isEmpty()); // OS X requires TRY
}
void tst_QMessageBox::sanityTest()
@@ -200,7 +198,9 @@ void tst_QMessageBox::sanityTest()
msgBox.setIconPixmap(QPixmap("whatever.png"));
msgBox.setTextFormat(Qt::RichText);
msgBox.setTextFormat(Qt::PlainText);
- exec(&msgBox);
+ ExecCloseHelper closeHelper;
+ closeHelper.start(ExecCloseHelper::CloseWindow, &msgBox);
+ msgBox.exec();
}
void tst_QMessageBox::button()
@@ -216,7 +216,7 @@ void tst_QMessageBox::button()
// remove the cancel, should not exist anymore
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
- QVERIFY(msgBox.button(QMessageBox::Cancel) == 0);
+ QVERIFY(!msgBox.button(QMessageBox::Cancel));
QVERIFY(msgBox.button(QMessageBox::Yes) != 0);
// should not crash
@@ -228,92 +228,105 @@ void tst_QMessageBox::button()
void tst_QMessageBox::defaultButton()
{
QMessageBox msgBox;
- QVERIFY(msgBox.defaultButton() == 0);
+ QVERIFY(!msgBox.defaultButton());
msgBox.addButton(QMessageBox::Ok);
msgBox.addButton(QMessageBox::Cancel);
- QVERIFY(msgBox.defaultButton() == 0);
+ QVERIFY(!msgBox.defaultButton());
QPushButton pushButton;
msgBox.setDefaultButton(&pushButton);
QVERIFY(msgBox.defaultButton() == 0); // we have not added it yet
QPushButton *retryButton = msgBox.addButton(QMessageBox::Retry);
msgBox.setDefaultButton(retryButton);
QCOMPARE(msgBox.defaultButton(), retryButton);
- exec(&msgBox);
+ ExecCloseHelper closeHelper;
+ closeHelper.start(ExecCloseHelper::CloseWindow, &msgBox);
+ msgBox.exec();
QCOMPARE(msgBox.clickedButton(), msgBox.button(QMessageBox::Cancel));
- exec(&msgBox, Qt::Key_Enter);
+ closeHelper.start(Qt::Key_Enter, &msgBox);
+ msgBox.exec();
QCOMPARE(msgBox.clickedButton(), (QAbstractButton *)retryButton);
QAbstractButton *okButton = msgBox.button(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
QCOMPARE(msgBox.defaultButton(), (QPushButton *)okButton);
- exec(&msgBox, Qt::Key_Enter);
+ closeHelper.start(Qt::Key_Enter, &msgBox);
+ msgBox.exec();
QCOMPARE(msgBox.clickedButton(), okButton);
msgBox.setDefaultButton(QMessageBox::Yes); // its not in there!
- QVERIFY(msgBox.defaultButton() == okButton);
+ QCOMPARE(msgBox.defaultButton(), okButton);
msgBox.removeButton(okButton);
delete okButton;
okButton = 0;
- QVERIFY(msgBox.defaultButton() == 0);
+ QVERIFY(!msgBox.defaultButton());
msgBox.setDefaultButton(QMessageBox::Ok);
- QVERIFY(msgBox.defaultButton() == 0);
+ QVERIFY(!msgBox.defaultButton());
}
void tst_QMessageBox::escapeButton()
{
QMessageBox msgBox;
- QVERIFY(msgBox.escapeButton() == 0);
+ QVERIFY(!msgBox.escapeButton());
msgBox.addButton(QMessageBox::Ok);
- exec(&msgBox);
+ ExecCloseHelper closeHelper;
+ closeHelper.start(ExecCloseHelper::CloseWindow, &msgBox);
+ msgBox.exec();
QVERIFY(msgBox.clickedButton() == msgBox.button(QMessageBox::Ok)); // auto detected (one button only)
msgBox.addButton(QMessageBox::Cancel);
- QVERIFY(msgBox.escapeButton() == 0);
+ QVERIFY(!msgBox.escapeButton());
QPushButton invalidButton;
msgBox.setEscapeButton(&invalidButton);
- QVERIFY(msgBox.escapeButton() == 0);
+ QVERIFY(!msgBox.escapeButton());
QAbstractButton *retryButton = msgBox.addButton(QMessageBox::Retry);
- exec(&msgBox);
+ closeHelper.start(ExecCloseHelper::CloseWindow, &msgBox);
+ msgBox.exec();
QVERIFY(msgBox.clickedButton() == msgBox.button(QMessageBox::Cancel)); // auto detected (cancel)
msgBox.setEscapeButton(retryButton);
QCOMPARE(msgBox.escapeButton(), (QAbstractButton *)retryButton);
// with escape
- exec(&msgBox, Qt::Key_Escape);
+ closeHelper.start(Qt::Key_Escape, &msgBox);
+ msgBox.exec();
QCOMPARE(msgBox.clickedButton(), retryButton);
// with close
- exec(&msgBox);
+ closeHelper.start(ExecCloseHelper::CloseWindow, &msgBox);
+ msgBox.exec();
QCOMPARE(msgBox.clickedButton(), (QAbstractButton *)retryButton);
QAbstractButton *okButton = msgBox.button(QMessageBox::Ok);
msgBox.setEscapeButton(QMessageBox::Ok);
QCOMPARE(msgBox.escapeButton(), okButton);
- exec(&msgBox, Qt::Key_Escape);
+ closeHelper.start(Qt::Key_Escape, &msgBox);
+ msgBox.exec();
QCOMPARE(msgBox.clickedButton(), okButton);
msgBox.setEscapeButton(QMessageBox::Yes); // its not in there!
- QVERIFY(msgBox.escapeButton() == okButton);
+ QCOMPARE(msgBox.escapeButton(), okButton);
msgBox.removeButton(okButton);
delete okButton;
okButton = 0;
- QVERIFY(msgBox.escapeButton() == 0);
+ QVERIFY(!msgBox.escapeButton());
msgBox.setEscapeButton(QMessageBox::Ok);
- QVERIFY(msgBox.escapeButton() == 0);
+ QVERIFY(!msgBox.escapeButton());
QMessageBox msgBox2;
msgBox2.addButton(QMessageBox::Yes);
msgBox2.addButton(QMessageBox::No);
- exec(&msgBox2);
+ closeHelper.start(ExecCloseHelper::CloseWindow, &msgBox2);
+ msgBox2.exec();
QVERIFY(msgBox2.clickedButton() == msgBox2.button(QMessageBox::No)); // auto detected (one No button only)
QPushButton *rejectButton = new QPushButton;
msgBox2.addButton(rejectButton, QMessageBox::RejectRole);
- exec(&msgBox2);
+ closeHelper.start(ExecCloseHelper::CloseWindow, &msgBox2);
+ msgBox2.exec();
QVERIFY(msgBox2.clickedButton() == rejectButton); // auto detected (one reject button only)
msgBox2.addButton(new QPushButton, QMessageBox::RejectRole);
- exec(&msgBox2);
+ closeHelper.start(ExecCloseHelper::CloseWindow, &msgBox2);
+ msgBox2.exec();
QVERIFY(msgBox2.clickedButton() == msgBox2.button(QMessageBox::No)); // auto detected (one No button only)
}
@@ -328,38 +341,35 @@ void tst_QMessageBox::statics()
statics[2] = QMessageBox::question;
statics[3] = QMessageBox::warning;
+ ExecCloseHelper closeHelper;
for (int i = 0; i < 4; i++) {
- keyToSend = Qt::Key_Escape;
- sendKeySoon();
+ closeHelper.start(Qt::Key_Escape);
QMessageBox::StandardButton sb = (*statics[i])(0, "caption",
"text", QMessageBox::Yes | QMessageBox::No | QMessageBox::Help | QMessageBox::Cancel,
QMessageBox::NoButton);
QCOMPARE(sb, QMessageBox::Cancel);
- QCOMPARE(keyToSend, -1);
+ QVERIFY(closeHelper.done());
- keyToSend = -2; // close()
- sendKeySoon();
+ closeHelper.start(ExecCloseHelper::CloseWindow);
sb = (*statics[i])(0, "caption",
"text", QMessageBox::Yes | QMessageBox::No | QMessageBox::Help | QMessageBox::Cancel,
QMessageBox::NoButton);
QCOMPARE(sb, QMessageBox::Cancel);
- QCOMPARE(keyToSend, -1);
+ QVERIFY(closeHelper.done());
- keyToSend = Qt::Key_Enter;
- sendKeySoon();
+ closeHelper.start(Qt::Key_Enter);
sb = (*statics[i])(0, "caption",
"text", QMessageBox::Yes | QMessageBox::No | QMessageBox::Help,
QMessageBox::Yes);
QCOMPARE(sb, QMessageBox::Yes);
- QCOMPARE(keyToSend, -1);
+ QVERIFY(closeHelper.done());
- keyToSend = Qt::Key_Enter;
- sendKeySoon();
+ closeHelper.start(Qt::Key_Enter);
sb = (*statics[i])(0, "caption",
"text", QMessageBox::Yes | QMessageBox::No | QMessageBox::Help,
QMessageBox::No);
QCOMPARE(sb, QMessageBox::No);
- QCOMPARE(keyToSend, -1);
+ QVERIFY(closeHelper.done());
}
}
@@ -371,34 +381,36 @@ void tst_QMessageBox::shortcut()
msgBox.addButton("O&k", QMessageBox::YesRole);
msgBox.addButton("&No", QMessageBox::YesRole);
msgBox.addButton("&Maybe", QMessageBox::YesRole);
- QCOMPARE(exec(&msgBox, Qt::Key_M), 2);
+ ExecCloseHelper closeHelper;
+ closeHelper.start(Qt::Key_M, &msgBox);
+ QCOMPARE(msgBox.exec(), 2);
}
#endif
void tst_QMessageBox::about()
{
- keyToSend = Qt::Key_Escape;
- sendKeySoon();
+ ExecCloseHelper closeHelper;
+ closeHelper.start(Qt::Key_Escape);
QMessageBox::about(0, "Caption", "This is an auto test");
// On Mac, about and aboutQt are not modal, so we need to
// explicitly run the event loop
#ifdef Q_OS_MAC
- QTRY_COMPARE(keyToSend, -1);
+ QTRY_VERIFY(closeHelper.done());
#else
- QCOMPARE(keyToSend, -1);
+ QVERIFY(closeHelper.done());
#endif
#if !defined(Q_OS_WINCE)
- keyToSend = Qt::Key_Enter;
+ const int keyToSend = Qt::Key_Enter;
#else
- keyToSend = Qt::Key_Escape;
+ const keyToSend = Qt::Key_Escape;
#endif
- sendKeySoon();
+ closeHelper.start(keyToSend);
QMessageBox::aboutQt(0, "Caption");
#ifdef Q_OS_MAC
- QTRY_COMPARE(keyToSend, -1);
+ QTRY_VERIFY(closeHelper.done());
#else
- QCOMPARE(keyToSend, -1);
+ QVERIFY(closeHelper.done());
#endif
}
@@ -407,8 +419,8 @@ void tst_QMessageBox::staticSourceCompat()
int ret;
// source compat tests for < 4.2
- keyToSend = Qt::Key_Enter;
- sendKeySoon();
+ ExecCloseHelper closeHelper;
+ closeHelper.start(Qt::Key_Enter);
ret = QMessageBox::information(0, "title", "text", QMessageBox::Yes, QMessageBox::No);
int expectedButton = int(QMessageBox::Yes);
if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
@@ -418,51 +430,44 @@ void tst_QMessageBox::staticSourceCompat()
expectedButton = int(QMessageBox::No);
}
QCOMPARE(ret, expectedButton);
- QCOMPARE(keyToSend, -1);
+ QVERIFY(closeHelper.done());
- keyToSend = Qt::Key_Enter;
- sendKeySoon();
+ closeHelper.start(Qt::Key_Enter);
ret = QMessageBox::information(0, "title", "text", QMessageBox::Yes | QMessageBox::Default, QMessageBox::No);
QCOMPARE(ret, int(QMessageBox::Yes));
- QCOMPARE(keyToSend, -1);
+ QVERIFY(closeHelper.done());
- keyToSend = Qt::Key_Enter;
- sendKeySoon();
+ closeHelper.start(Qt::Key_Enter);
ret = QMessageBox::information(0, "title", "text", QMessageBox::Yes, QMessageBox::No | QMessageBox::Default);
QCOMPARE(ret, int(QMessageBox::No));
- QCOMPARE(keyToSend, -1);
+ QVERIFY(closeHelper.done());
- keyToSend = Qt::Key_Enter;
- sendKeySoon();
+ closeHelper.start(Qt::Key_Enter);
ret = QMessageBox::information(0, "title", "text", QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape);
QCOMPARE(ret, int(QMessageBox::Yes));
- QCOMPARE(keyToSend, -1);
+ QVERIFY(closeHelper.done());
- keyToSend = Qt::Key_Enter;
- sendKeySoon();
+ closeHelper.start(Qt::Key_Enter);
ret = QMessageBox::information(0, "title", "text", QMessageBox::Yes | QMessageBox::Escape, QMessageBox::No | QMessageBox::Default);
QCOMPARE(ret, int(QMessageBox::No));
- QCOMPARE(keyToSend, -1);
+ QVERIFY(closeHelper.done());
// the button text versions
- keyToSend = Qt::Key_Enter;
- sendKeySoon();
+ closeHelper.start(Qt::Key_Enter);
ret = QMessageBox::information(0, "title", "text", "Yes", "No", QString(), 1);
QCOMPARE(ret, 1);
- QCOMPARE(keyToSend, -1);
+ QVERIFY(closeHelper.done());
if (0) { // don't run these tests since the dialog won't close!
- keyToSend = Qt::Key_Escape;
- sendKeySoon();
+ closeHelper.start(Qt::Key_Escape);
ret = QMessageBox::information(0, "title", "text", "Yes", "No", QString(), 1);
QCOMPARE(ret, -1);
- QCOMPARE(keyToSend, -1);
+ QVERIFY(closeHelper.done());
- keyToSend = Qt::Key_Escape;
- sendKeySoon();
+ closeHelper.start(Qt::Key_Escape);
ret = QMessageBox::information(0, "title", "text", "Yes", "No", QString(), 0, 1);
QCOMPARE(ret, 1);
- QCOMPARE(keyToSend, -1);
+ QVERIFY(closeHelper.done());
}
}
@@ -480,12 +485,17 @@ void tst_QMessageBox::instanceSourceCompat()
mb.addButton("&Revert", QMessageBox::RejectRole);
mb.addButton("&Zoo", QMessageBox::ActionRole);
- QCOMPARE(exec(&mb, Qt::Key_Enter), int(QMessageBox::Yes));
- QCOMPARE(exec(&mb, Qt::Key_Escape), int(QMessageBox::Cancel));
+ ExecCloseHelper closeHelper;
+ closeHelper.start(Qt::Key_Enter, &mb);
+ QCOMPARE(mb.exec(), int(QMessageBox::Yes));
+ closeHelper.start(Qt::Key_Escape, &mb);
+ QCOMPARE(mb.exec(), int(QMessageBox::Cancel));
#ifndef Q_OS_MAC
// mnemonics are not used on OS X
- QCOMPARE(exec(&mb, Qt::ALT + Qt::Key_R), 0);
- QCOMPARE(exec(&mb, Qt::ALT + Qt::Key_Z), 1);
+ closeHelper.start(Qt::ALT + Qt::Key_R, &mb);
+ QCOMPARE(mb.exec(), 0);
+ closeHelper.start(Qt::ALT + Qt::Key_Z, &mb);
+ QCOMPARE(mb.exec(), 1);
#endif
}
@@ -527,13 +537,13 @@ void tst_QMessageBox::testSymbols()
QCOMPARE(mb1.text(), text);
icon = mb1.icon();
- QVERIFY(icon == QMessageBox::NoIcon);
+ QCOMPARE(icon, QMessageBox::NoIcon);
mb1.setIcon(QMessageBox::Question);
- QVERIFY(mb1.icon() == QMessageBox::Question);
+ QCOMPARE(mb1.icon(), QMessageBox::Question);
QPixmap iconPixmap = mb1.iconPixmap();
mb1.setIconPixmap(iconPixmap);
- QVERIFY(mb1.icon() == QMessageBox::NoIcon);
+ QCOMPARE(mb1.icon(), QMessageBox::NoIcon);
QCOMPARE(mb1.buttonText(QMessageBox::Ok), QLatin1String("OK"));
QCOMPARE(mb1.buttonText(QMessageBox::Cancel), QString());
@@ -647,26 +657,24 @@ void tst_QMessageBox::expandDetails_QTBUG_32473()
void tst_QMessageBox::incorrectDefaultButton()
{
- keyToSend = Qt::Key_Escape;
- sendKeySoon();
+ ExecCloseHelper closeHelper;
+ closeHelper.start(Qt::Key_Escape);
//Do not crash here
QTest::ignoreMessage(QtWarningMsg, "QDialogButtonBox::createButton: Invalid ButtonRole, button not added");
QMessageBox::question( 0, "", "I've been hit!",QMessageBox::Ok | QMessageBox::Cancel,QMessageBox::Save );
- QCOMPARE(keyToSend, -1);
+ QVERIFY(closeHelper.done());
- keyToSend = Qt::Key_Escape;
- sendKeySoon();
+ closeHelper.start(Qt::Key_Escape);
QTest::ignoreMessage(QtWarningMsg, "QDialogButtonBox::createButton: Invalid ButtonRole, button not added");
QMessageBox::question( 0, "", "I've been hit!",QFlag(QMessageBox::Ok | QMessageBox::Cancel),QMessageBox::Save );
- QCOMPARE(keyToSend, -1);
+ QVERIFY(closeHelper.done());
- keyToSend = Qt::Key_Escape;
- sendKeySoon();
+ closeHelper.start(Qt::Key_Escape);
QTest::ignoreMessage(QtWarningMsg, "QDialogButtonBox::createButton: Invalid ButtonRole, button not added");
QTest::ignoreMessage(QtWarningMsg, "QDialogButtonBox::createButton: Invalid ButtonRole, button not added");
//do not crash here -> call old function of QMessageBox in this case
QMessageBox::question( 0, "", "I've been hit!",QMessageBox::Ok | QMessageBox::Cancel,QMessageBox::Save | QMessageBox::Cancel,QMessageBox::Ok);
- QCOMPARE(keyToSend, -1);
+ QVERIFY(closeHelper.done());
}
void tst_QMessageBox::updateSize()
diff --git a/tests/auto/widgets/dialogs/qprogressdialog/BLACKLIST b/tests/auto/widgets/dialogs/qprogressdialog/BLACKLIST
new file mode 100644
index 0000000000..a2670e8f36
--- /dev/null
+++ b/tests/auto/widgets/dialogs/qprogressdialog/BLACKLIST
@@ -0,0 +1,2 @@
+[autoShow:50_to_100_fast_0_compat]
+osx
diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
index 21c15edff2..b2bdbac79a 100644
--- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
+++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
@@ -400,7 +400,7 @@ void tst_QWizard::setButton()
// revert to default button
wizard.setButton(QWizard::NextButton, 0);
- QVERIFY(toolButton == 0);
+ QVERIFY(toolButton.isNull());
QVERIFY(qobject_cast<QPushButton *>(wizard.button(QWizard::NextButton)));
QVERIFY(wizard.button(QWizard::NextButton)->text().contains("Next"));
}
@@ -408,16 +408,16 @@ void tst_QWizard::setButton()
void tst_QWizard::setTitleFormatEtc()
{
QWizard wizard;
- QVERIFY(wizard.titleFormat() == Qt::AutoText);
- QVERIFY(wizard.subTitleFormat() == Qt::AutoText);
+ QCOMPARE(wizard.titleFormat(), Qt::AutoText);
+ QCOMPARE(wizard.subTitleFormat(), Qt::AutoText);
wizard.setTitleFormat(Qt::RichText);
- QVERIFY(wizard.titleFormat() == Qt::RichText);
- QVERIFY(wizard.subTitleFormat() == Qt::AutoText);
+ QCOMPARE(wizard.titleFormat(), Qt::RichText);
+ QCOMPARE(wizard.subTitleFormat(), Qt::AutoText);
wizard.setSubTitleFormat(Qt::PlainText);
- QVERIFY(wizard.titleFormat() == Qt::RichText);
- QVERIFY(wizard.subTitleFormat() == Qt::PlainText);
+ QCOMPARE(wizard.titleFormat(), Qt::RichText);
+ QCOMPARE(wizard.subTitleFormat(), Qt::PlainText);
}
void tst_QWizard::setPixmap()
@@ -439,7 +439,7 @@ void tst_QWizard::setPixmap()
QVERIFY(wizard.pixmap(QWizard::LogoPixmap).isNull());
QVERIFY(wizard.pixmap(QWizard::WatermarkPixmap).isNull());
#ifdef Q_OS_OSX
- QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).isNull() == false);
+ QVERIFY(!wizard.pixmap(QWizard::BackgroundPixmap).isNull());
#else
QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).isNull());
#endif
@@ -448,7 +448,7 @@ void tst_QWizard::setPixmap()
QVERIFY(page->pixmap(QWizard::LogoPixmap).isNull());
QVERIFY(page->pixmap(QWizard::WatermarkPixmap).isNull());
#ifdef Q_OS_OSX
- QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).isNull() == false);
+ QVERIFY(!wizard.pixmap(QWizard::BackgroundPixmap).isNull());
#else
QVERIFY(page->pixmap(QWizard::BackgroundPixmap).isNull());
#endif
@@ -459,20 +459,20 @@ void tst_QWizard::setPixmap()
page->setPixmap(QWizard::LogoPixmap, p5);
- QVERIFY(wizard.pixmap(QWizard::BannerPixmap).size() == p1.size());
- QVERIFY(wizard.pixmap(QWizard::LogoPixmap).size() == p2.size());
- QVERIFY(wizard.pixmap(QWizard::WatermarkPixmap).size() == p3.size());
- QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).size() == p4.size());
+ QCOMPARE(wizard.pixmap(QWizard::BannerPixmap).size(), p1.size());
+ QCOMPARE(wizard.pixmap(QWizard::LogoPixmap).size(), p2.size());
+ QCOMPARE(wizard.pixmap(QWizard::WatermarkPixmap).size(), p3.size());
+ QCOMPARE(wizard.pixmap(QWizard::BackgroundPixmap).size(), p4.size());
- QVERIFY(page->pixmap(QWizard::BannerPixmap).size() == p1.size());
- QVERIFY(page->pixmap(QWizard::LogoPixmap).size() == p5.size());
- QVERIFY(page->pixmap(QWizard::WatermarkPixmap).size() == p3.size());
- QVERIFY(page->pixmap(QWizard::BackgroundPixmap).size() == p4.size());
+ QCOMPARE(page->pixmap(QWizard::BannerPixmap).size(), p1.size());
+ QCOMPARE(page->pixmap(QWizard::LogoPixmap).size(), p5.size());
+ QCOMPARE(page->pixmap(QWizard::WatermarkPixmap).size(), p3.size());
+ QCOMPARE(page->pixmap(QWizard::BackgroundPixmap).size(), p4.size());
- QVERIFY(page2->pixmap(QWizard::BannerPixmap).size() == p1.size());
- QVERIFY(page2->pixmap(QWizard::LogoPixmap).size() == p2.size());
- QVERIFY(page2->pixmap(QWizard::WatermarkPixmap).size() == p3.size());
- QVERIFY(page2->pixmap(QWizard::BackgroundPixmap).size() == p4.size());
+ QCOMPARE(page2->pixmap(QWizard::BannerPixmap).size(), p1.size());
+ QCOMPARE(page2->pixmap(QWizard::LogoPixmap).size(), p2.size());
+ QCOMPARE(page2->pixmap(QWizard::WatermarkPixmap).size(), p3.size());
+ QCOMPARE(page2->pixmap(QWizard::BackgroundPixmap).size(), p4.size());
}
class MyPage1 : public QWizardPage
@@ -571,7 +571,7 @@ void tst_QWizard::addPage()
}
for (int i = 0; i < N; ++i) {
- QVERIFY(pages[i] == wizard.page(i));
+ QCOMPARE(pages[i], wizard.page(i));
}
QVERIFY(!wizard.page(-1));
QVERIFY(!wizard.page(N));
@@ -667,7 +667,7 @@ void tst_QWizard::setPage()
QCOMPARE(wizard.page(-2), page);
QCOMPARE(wizard.startId(), -2);
QCOMPARE(wizard.currentId(), -2);
- QVERIFY(wizard.currentPage() == page);
+ QCOMPARE(wizard.currentPage(), page);
QCOMPARE(wizard.nextId(), 0);
CHECK_VISITED(wizard, QList<int>() << -2);
@@ -679,14 +679,14 @@ void tst_QWizard::setPage()
QCOMPARE(wizard.page(2), page);
QCOMPARE(wizard.startId(), -2);
QCOMPARE(wizard.currentId(), -2);
- QVERIFY(wizard.currentPage() == wizard.page(-2));
+ QCOMPARE(wizard.currentPage(), wizard.page(-2));
QCOMPARE(wizard.nextId(), 0);
CHECK_VISITED(wizard, QList<int>() << -2);
wizard.restart();
QCOMPARE(wizard.startId(), -2);
QCOMPARE(wizard.currentId(), -2);
- QVERIFY(wizard.currentPage() == wizard.page(-2));
+ QCOMPARE(wizard.currentPage(), wizard.page(-2));
QCOMPARE(wizard.nextId(), 0);
CHECK_VISITED(wizard, QList<int>() << -2);
@@ -698,28 +698,28 @@ void tst_QWizard::setPage()
QCOMPARE(wizard.page(-3), page);
QCOMPARE(wizard.startId(), -3);
QCOMPARE(wizard.currentId(), -2);
- QVERIFY(wizard.currentPage() == wizard.page(-2));
+ QCOMPARE(wizard.currentPage(), wizard.page(-2));
QCOMPARE(wizard.nextId(), 0);
CHECK_VISITED(wizard, QList<int>() << -2);
wizard.restart();
QCOMPARE(wizard.startId(), -3);
QCOMPARE(wizard.currentId(), -3);
- QVERIFY(wizard.currentPage() == wizard.page(-3));
+ QCOMPARE(wizard.currentPage(), wizard.page(-3));
QCOMPARE(wizard.nextId(), -2);
CHECK_VISITED(wizard, QList<int>() << -3);
wizard.next();
QCOMPARE(wizard.startId(), -3);
QCOMPARE(wizard.currentId(), -2);
- QVERIFY(wizard.currentPage() == wizard.page(-2));
+ QCOMPARE(wizard.currentPage(), wizard.page(-2));
QCOMPARE(wizard.nextId(), 0);
CHECK_VISITED(wizard, QList<int>() << -3 << -2);
wizard.next();
QCOMPARE(wizard.startId(), -3);
QCOMPARE(wizard.currentId(), 0);
- QVERIFY(wizard.currentPage() == wizard.page(0));
+ QCOMPARE(wizard.currentPage(), wizard.page(0));
QCOMPARE(wizard.nextId(), 2);
CHECK_VISITED(wizard, QList<int>() << -3 << -2 << 0);
@@ -727,7 +727,7 @@ void tst_QWizard::setPage()
wizard.next();
QCOMPARE(wizard.startId(), -3);
QCOMPARE(wizard.currentId(), 2);
- QVERIFY(wizard.currentPage() == wizard.page(2));
+ QCOMPARE(wizard.currentPage(), wizard.page(2));
QCOMPARE(wizard.nextId(), -1);
CHECK_VISITED(wizard, QList<int>() << -3 << -2 << 0 << 2);
}
@@ -735,14 +735,14 @@ void tst_QWizard::setPage()
wizard.back();
QCOMPARE(wizard.startId(), -3);
QCOMPARE(wizard.currentId(), 0);
- QVERIFY(wizard.currentPage() == wizard.page(0));
+ QCOMPARE(wizard.currentPage(), wizard.page(0));
QCOMPARE(wizard.nextId(), 2);
CHECK_VISITED(wizard, QList<int>() << -3 << -2 << 0);
wizard.back();
QCOMPARE(wizard.startId(), -3);
QCOMPARE(wizard.currentId(), -2);
- QVERIFY(wizard.currentPage() == wizard.page(-2));
+ QCOMPARE(wizard.currentPage(), wizard.page(-2));
QCOMPARE(wizard.nextId(), 0);
CHECK_VISITED(wizard, QList<int>() << -3 << -2);
@@ -750,7 +750,7 @@ void tst_QWizard::setPage()
wizard.back();
QCOMPARE(wizard.startId(), -3);
QCOMPARE(wizard.currentId(), -3);
- QVERIFY(wizard.currentPage() == wizard.page(-3));
+ QCOMPARE(wizard.currentPage(), wizard.page(-3));
QCOMPARE(wizard.nextId(), -2);
CHECK_VISITED(wizard, QList<int>() << -3);
}
@@ -759,7 +759,7 @@ void tst_QWizard::setPage()
wizard.restart();
QCOMPARE(wizard.startId(), -3);
QCOMPARE(wizard.currentId(), -3);
- QVERIFY(wizard.currentPage() == wizard.page(-3));
+ QCOMPARE(wizard.currentPage(), wizard.page(-3));
QCOMPARE(wizard.nextId(), -2);
CHECK_VISITED(wizard, QList<int>() << -3);
}
@@ -808,31 +808,31 @@ void tst_QWizard::setStartId()
wizard.restart();
QCOMPARE(wizard.startId(), -2);
QCOMPARE(wizard.currentId(), -2);
- QVERIFY(wizard.currentPage() == wizard.page(-2));
+ QCOMPARE(wizard.currentPage(), wizard.page(-2));
QCOMPARE(wizard.nextId(), 0);
wizard.next();
QCOMPARE(wizard.startId(), -2);
QCOMPARE(wizard.currentId(), 0);
- QVERIFY(wizard.currentPage() == wizard.page(0));
+ QCOMPARE(wizard.currentPage(), wizard.page(0));
QCOMPARE(wizard.nextId(), 1);
wizard.setStartId(INT_MIN);
QCOMPARE(wizard.startId(), INT_MIN);
QCOMPARE(wizard.currentId(), 0);
- QVERIFY(wizard.currentPage() == wizard.page(0));
+ QCOMPARE(wizard.currentPage(), wizard.page(0));
QCOMPARE(wizard.nextId(), 1);
wizard.next();
QCOMPARE(wizard.startId(), INT_MIN);
QCOMPARE(wizard.currentId(), 1);
- QVERIFY(wizard.currentPage() == wizard.page(1));
+ QCOMPARE(wizard.currentPage(), wizard.page(1));
QCOMPARE(wizard.nextId(), INT_MAX);
wizard.next();
QCOMPARE(wizard.startId(), INT_MIN);
QCOMPARE(wizard.currentId(), INT_MAX);
- QVERIFY(wizard.currentPage() == wizard.page(INT_MAX));
+ QCOMPARE(wizard.currentPage(), wizard.page(INT_MAX));
QCOMPARE(wizard.nextId(), -1);
CHECK_VISITED(wizard, QList<int>() << -2 << 0 << 1 << INT_MAX);
}
@@ -1143,12 +1143,12 @@ void tst_QWizard::setOption_ExtendedWatermarkPixmap()
}
if (wizard1.wizardStyle() == QWizard::MacStyle) {
- QVERIFY(i1[0] == i1[1]);
- QVERIFY(i2[0] == i2[1]);
- QVERIFY(i1[0] == i2[0]);
+ QCOMPARE(i1[0], i1[1]);
+ QCOMPARE(i2[0], i2[1]);
+ QCOMPARE(i1[0], i2[0]);
} else {
QVERIFY(i1[0] != i1[1]);
- QVERIFY(i2[0] == i2[1]);
+ QCOMPARE(i2[0], i2[1]);
QVERIFY(i1[0] != i2[0]);
QVERIFY(i1[1] != i2[1]);
}
@@ -2425,19 +2425,19 @@ void tst_QWizard::sideWidget()
QWizard wizard;
wizard.setSideWidget(0);
- QVERIFY(wizard.sideWidget() == 0);
+ QVERIFY(!wizard.sideWidget());
QScopedPointer<QWidget> w1(new QWidget(&wizard));
wizard.setSideWidget(w1.data());
QCOMPARE(wizard.sideWidget(), w1.data());
QWidget *w2 = new QWidget(&wizard);
wizard.setSideWidget(w2);
- QVERIFY(wizard.sideWidget() == w2);
+ QCOMPARE(wizard.sideWidget(), w2);
QVERIFY(w1->parent() != 0);
QCOMPARE(w1->window(), static_cast<QWidget *>(&wizard));
QCOMPARE(w2->window(), static_cast<QWidget *>(&wizard));
w1->setParent(0);
wizard.setSideWidget(0);
- QVERIFY(wizard.sideWidget() == 0);
+ QVERIFY(!wizard.sideWidget());
}
void tst_QWizard::objectNames_data()
@@ -2558,7 +2558,7 @@ void tst_QWizard::task183550_stretchFactor()
page2->disableVerticalExpansion();
wizard.next();
QCOMPARE(wizard.currentPage(), static_cast<QWizardPage*>(page2));
- QVERIFY(page2->treeWidgetHeight() == page2->treeWidgetSizeHintHeight());
+ QCOMPARE(page2->treeWidgetHeight(), page2->treeWidgetSizeHintHeight());
wizard.back();
QCOMPARE(wizard.currentPage(), static_cast<QWizardPage*>(page1));
@@ -2576,7 +2576,7 @@ void tst_QWizard::task183550_stretchFactor()
page2->disableVerticalExpansion();
wizard.next();
QCOMPARE(wizard.currentPage(), static_cast<QWizardPage*>(page2));
- QVERIFY(page2->treeWidgetHeight() == page2->treeWidgetSizeHintHeight());
+ QCOMPARE(page2->treeWidgetHeight(), page2->treeWidgetSizeHintHeight());
}
void tst_QWizard::task161658_alignments()
diff --git a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp
index 4d7f55f37d..c7d1dd0aa1 100644
--- a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp
+++ b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp
@@ -520,7 +520,7 @@ public:
void draw(QPainter *painter)
{
- QVERIFY(sourcePixmap(Qt::LogicalCoordinates).handle() == pixmap.handle());
+ QCOMPARE(sourcePixmap(Qt::LogicalCoordinates).handle(), pixmap.handle());
QVERIFY((painter->worldTransform().type() <= QTransform::TxTranslate) == (sourcePixmap(Qt::DeviceCoordinates).handle() == pixmap.handle()));
++repaints;
@@ -595,7 +595,7 @@ void tst_QGraphicsEffect::deviceCoordinateTranslateCaching()
item->translate(10, 0);
- QTRY_VERIFY(item->numRepaints == numRepaints);
+ QTRY_COMPARE(item->numRepaints, numRepaints);
}
void tst_QGraphicsEffect::inheritOpacity()
diff --git a/tests/auto/widgets/gestures/qgesturerecognizer/BLACKLIST b/tests/auto/widgets/gestures/qgesturerecognizer/BLACKLIST
new file mode 100644
index 0000000000..7f55c2dae0
--- /dev/null
+++ b/tests/auto/widgets/gestures/qgesturerecognizer/BLACKLIST
@@ -0,0 +1,2 @@
+[panGesture:Two finger]
+xcb
diff --git a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
index ca01b27bee..f71308cdaf 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -133,7 +133,6 @@ static bool checkReverseDirection(QGraphicsWidget *widget)
layout->getContentsMargins(&left, &top, &right, &bottom);
widget->setLayoutDirection(Qt::LeftToRight);
QApplication::processEvents();
- const QRectF layoutGeometry = layout->geometry();
QMap<QGraphicsLayoutItem *, QRectF> geometries;
for (int i = 0; i < layout->count(); ++i) {
QGraphicsLayoutItem *item = layout->itemAt(i);
@@ -141,7 +140,7 @@ static bool checkReverseDirection(QGraphicsWidget *widget)
}
widget->setLayoutDirection(Qt::RightToLeft);
QApplication::processEvents();
- layoutGeometry.adjusted(+right, +top, -left, -bottom);
+ const QRectF layoutGeometry = layout->geometry().adjusted(+right, +top, -left, -bottom);
for (int i = 0; i < layout->count(); ++i) {
QGraphicsLayoutItem *item = layout->itemAt(i);
const QRectF rightToLeftGeometry = item->geometry();
@@ -653,7 +652,7 @@ void tst_QGraphicsAnchorLayout::snake()
QCOMPARE(c->geometry(), QRectF(90.0, 200.0, 100.0, 100.0));
QCOMPARE(p.size(), layoutMaximumSize);
- QVERIFY(layoutHasConflict(l) == false);
+ QVERIFY(!layoutHasConflict(l));
// Test QSizePolicy::ExpandFlag, it shouldn't change the extreme
// points of the layout...
@@ -2041,9 +2040,9 @@ void tst_QGraphicsAnchorLayout::graphicsAnchorHandling()
QGraphicsAnchor *invalidAnchor = l->anchor(a, Qt::AnchorTop, l, Qt::AnchorBottom);
// Ensure none of these anchors are accessible.
- QVERIFY(layoutAnchor == 0);
- QVERIFY(itemAnchor == 0);
- QVERIFY(invalidAnchor == 0);
+ QVERIFY(!layoutAnchor);
+ QVERIFY(!itemAnchor);
+ QVERIFY(!invalidAnchor);
// Hook the anchors to a QObject
QObject object;
diff --git a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
index a2108dd494..a58f295575 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
@@ -715,7 +715,7 @@ void tst_QGraphicsAnchorLayout1::testSpecialCases()
widget1->setGeometry(QRectF(0,0,100,100));
QCOMPARE(childWidget->geometry(), QRectF(1,1,98,98));
- QVERIFY(childWidget->parentLayoutItem() == layout1);
+ QCOMPARE(childWidget->parentLayoutItem(), layout1);
QGraphicsWidget *widget2 = new QGraphicsWidget;
TheAnchorLayout *layout2 = new TheAnchorLayout();
widget2->setLayout(layout2);
@@ -739,10 +739,10 @@ void tst_QGraphicsAnchorLayout1::testSpecialCases()
widget2->setGeometry(QRectF(0,0,100,100));
QCOMPARE(childWidget->geometry(), QRectF(1,1,98,98));
- QVERIFY(childWidget->parentLayoutItem() == layout2);
+ QCOMPARE(childWidget->parentLayoutItem(), layout2);
QCOMPARE(widget4->geometry(), QRectF(1,1,98,98));
- QVERIFY(widget4->parentLayoutItem() == layout2);
- QVERIFY(widget4->parentItem() == widget2);
+ QCOMPARE(widget4->parentLayoutItem(), layout2);
+ QCOMPARE(widget4->parentItem(), widget2);
delete widget4;
delete widget3;
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
index 0dd1161dcf..835aeaa4df 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -4274,7 +4274,7 @@ void tst_QGraphicsItem::cursor()
void tst_QGraphicsItem::textControlGetterSetter()
{
QGraphicsTextItem *item = new QGraphicsTextItem;
- QVERIFY(item->textControl()->parent() == item);
+ QCOMPARE(item->textControl()->parent(), item);
QPointer<QWidgetTextControl> control = item->textControl();
delete item;
QVERIFY(!control);
@@ -4285,7 +4285,7 @@ void tst_QGraphicsItem::textControlGetterSetter()
control = new QWidgetTextControl;
item->setTextControl(control);
- QVERIFY(item->textControl() == control);
+ QCOMPARE(item->textControl(), control);
QVERIFY(!control->parent());
QVERIFY(!oldControl);
@@ -5141,19 +5141,19 @@ void tst_QGraphicsItem::paint()
//nominal case, update call paint
tester2.update();
qApp->processEvents();
- QTRY_VERIFY(tester2.painted == 2);
+ QTRY_COMPARE(tester2.painted, 2);
//we remove the item from the scene, number of updates is still the same
tester2.update();
scene2.removeItem(&tester2);
qApp->processEvents();
- QTRY_VERIFY(tester2.painted == 2);
+ QTRY_COMPARE(tester2.painted, 2);
//We re-add the item, the number of paint should increase
scene2.addItem(&tester2);
tester2.update();
qApp->processEvents();
- QTRY_VERIFY(tester2.painted == 3);
+ QTRY_COMPARE(tester2.painted, 3);
}
class HarakiriItem : public QGraphicsRectItem
@@ -5878,7 +5878,7 @@ void tst_QGraphicsItem::itemContainsChildrenInShape()
scene.setItemIndexMethod(QGraphicsScene::NoIndex);
scene.addItem(parent);
- QVERIFY(parent->boundingRectCalls == childOutsideShape->boundingRectCalls);
+ QCOMPARE(parent->boundingRectCalls, childOutsideShape->boundingRectCalls);
int oldParentBoundingRectCalls = parent->boundingRectCalls;
int oldChildBoundingRectCalls = childOutsideShape->boundingRectCalls;
@@ -5886,10 +5886,10 @@ void tst_QGraphicsItem::itemContainsChildrenInShape()
// First test that both items are searched if no optimization flags are set
QGraphicsItem* item = scene.itemAt(25,5);
- QVERIFY(item == childOutsideShape);
+ QCOMPARE(item, childOutsideShape);
QVERIFY(parent->boundingRectCalls > oldParentBoundingRectCalls);
QVERIFY(childOutsideShape->boundingRectCalls > oldChildBoundingRectCalls);
- QVERIFY(parent->boundingRectCalls == childOutsideShape->boundingRectCalls);
+ QCOMPARE(parent->boundingRectCalls, childOutsideShape->boundingRectCalls);
oldParentBoundingRectCalls = parent->boundingRectCalls;
oldChildBoundingRectCalls = childOutsideShape->boundingRectCalls;
@@ -5897,10 +5897,10 @@ void tst_QGraphicsItem::itemContainsChildrenInShape()
// Repeat the test to make sure that no caching/indexing is in effect
item = scene.itemAt(25,5);
- QVERIFY(item == childOutsideShape);
+ QCOMPARE(item, childOutsideShape);
QVERIFY(parent->boundingRectCalls > oldParentBoundingRectCalls);
QVERIFY(childOutsideShape->boundingRectCalls > oldChildBoundingRectCalls);
- QVERIFY(parent->boundingRectCalls == childOutsideShape->boundingRectCalls);
+ QCOMPARE(parent->boundingRectCalls, childOutsideShape->boundingRectCalls);
oldParentBoundingRectCalls = parent->boundingRectCalls;
oldChildBoundingRectCalls = childOutsideShape->boundingRectCalls;
@@ -5912,7 +5912,7 @@ void tst_QGraphicsItem::itemContainsChildrenInShape()
QVERIFY(!(item));
QVERIFY(parent->boundingRectCalls > oldParentBoundingRectCalls);
- QVERIFY(childOutsideShape->boundingRectCalls == oldChildBoundingRectCalls);
+ QCOMPARE(childOutsideShape->boundingRectCalls, oldChildBoundingRectCalls);
QVERIFY(parent->boundingRectCalls > childOutsideShape->boundingRectCalls);
}
@@ -11205,21 +11205,21 @@ void tst_QGraphicsItem::QTBUG_6738_missingUpdateWithSetParent()
child2->setVisible(false);
child2->setParentItem(child);
- QTRY_VERIFY(view.repaints == 1);
+ QTRY_COMPARE(view.repaints, 1);
// test case #2
view.reset();
child3->setOpacity(0.0);
child3->setParentItem(child);
- QTRY_VERIFY(view.repaints == 1);
+ QTRY_COMPARE(view.repaints, 1);
// test case #3
view.reset();
child4->setParentItem(child);
child4->setVisible(false);
- QTRY_VERIFY(view.repaints == 1);
+ QTRY_COMPARE(view.repaints, 1);
}
void tst_QGraphicsItem::QT_2653_fullUpdateDiscardingOpacityUpdate()
@@ -11469,9 +11469,9 @@ void tst_QGraphicsItem::itemDiesDuringDraggingOperation()
QGraphicsSceneDragDropEvent event(QEvent::GraphicsSceneDragMove);
event.setScenePos(item->boundingRect().center());
QApplication::sendEvent(&scene, &event);
- QVERIFY(QGraphicsScenePrivate::get(&scene)->dragDropItem == item);
+ QCOMPARE(QGraphicsScenePrivate::get(&scene)->dragDropItem, item);
delete item;
- QVERIFY(QGraphicsScenePrivate::get(&scene)->dragDropItem == 0);
+ QVERIFY(!QGraphicsScenePrivate::get(&scene)->dragDropItem);
}
void tst_QGraphicsItem::QTBUG_12112_focusItem()
diff --git a/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
index bd104539ac..a2740edc54 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
@@ -948,7 +948,7 @@ void tst_QGraphicsLayout::ownership()
destructedSet.clear();
window->setLayout(0);
- QVERIFY(destructedSet.count() == 0);
+ QCOMPARE(destructedSet.count(), 0);
delete window;
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
index 6a8b690560..8bebd4eddd 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
@@ -1230,8 +1230,8 @@ void tst_QGraphicsLinearLayout::testStretch()
layout->addStretch(2);
layout->addItem(w2);
QCOMPARE(layout->count(), 2);
- QVERIFY(layout->itemAt(0) == w1);
- QVERIFY(layout->itemAt(1) == w2);
+ QCOMPARE(layout->itemAt(0), w1);
+ QCOMPARE(layout->itemAt(1), w2);
layout->activate();
//view->setSceneRect(-50, -50, 800, 800);
diff --git a/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp b/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp
index 84c39bbb98..0f9e8c101e 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp
@@ -102,7 +102,7 @@ void tst_QGraphicsObject::pos()
QCOMPARE(xSpy.count(), 1);
QCOMPARE(ySpy.count(), 1);
- QVERIFY(object.pos() == QPointF(10,10));
+ QCOMPARE(object.pos(), QPointF(10,10));
object.setPos(10, 10);
QCOMPARE(xSpy.count(), 1);
@@ -111,12 +111,12 @@ void tst_QGraphicsObject::pos()
object.setProperty("pos", QPointF(0, 0));
QCOMPARE(xSpy.count(), 2);
QCOMPARE(ySpy.count(), 2);
- QVERIFY(object.property("pos") == QPointF(0,0));
+ QCOMPARE(object.property("pos").toPointF(), QPointF(0,0));
object.setProperty("pos", QPointF(10, 0));
QCOMPARE(xSpy.count(), 3);
QCOMPARE(ySpy.count(), 2);
- QVERIFY(object.property("pos") == QPointF(10,0));
+ QCOMPARE(object.property("pos").toPointF(), QPointF(10,0));
object.setProperty("pos", QPointF(10, 10));
QCOMPARE(xSpy.count(), 3);
@@ -135,7 +135,7 @@ void tst_QGraphicsObject::x()
QCOMPARE(ySpy.count(), 0);
QVERIFY(object.pos() == QPointF(10, 0));
- QVERIFY(object.x() == 10);
+ QCOMPARE(object.x(), qreal(10));
object.setX(10);
QCOMPARE(xSpy.count(), 1);
@@ -144,7 +144,7 @@ void tst_QGraphicsObject::x()
object.setProperty("x", 0);
QCOMPARE(xSpy.count(), 2);
QCOMPARE(ySpy.count(), 0);
- QVERIFY(object.property("x") == 0);
+ QCOMPARE(object.property("x").toDouble(), double(0));
}
void tst_QGraphicsObject::y()
@@ -158,7 +158,7 @@ void tst_QGraphicsObject::y()
QCOMPARE(ySpy.count(), 1);
QVERIFY(object.pos() == QPointF(0, 10));
- QVERIFY(object.y() == 10);
+ QCOMPARE(object.y(), qreal(10));
object.setY(10);
QCOMPARE(xSpy.count(), 0);
@@ -167,79 +167,79 @@ void tst_QGraphicsObject::y()
object.setProperty("y", 0);
QCOMPARE(xSpy.count(), 0);
QCOMPARE(ySpy.count(), 2);
- QVERIFY(object.property("y") == 0);
+ QCOMPARE(object.property("y").toDouble(), qreal(0));
}
void tst_QGraphicsObject::z()
{
MyGraphicsObject object;
QSignalSpy zSpy(&object, SIGNAL(zChanged()));
- QVERIFY(object.zValue() == 0);
+ QCOMPARE(object.zValue(), qreal(0));
object.setZValue(10);
QCOMPARE(zSpy.count(), 1);
- QVERIFY(object.zValue() == 10);
+ QCOMPARE(object.zValue(), qreal(10));
object.setZValue(10);
QCOMPARE(zSpy.count(), 1);
object.setProperty("z", 0);
QCOMPARE(zSpy.count(), 2);
- QVERIFY(object.property("z") == 0);
+ QCOMPARE(object.property("z").toDouble(), double(0));
}
void tst_QGraphicsObject::opacity()
{
MyGraphicsObject object;
QSignalSpy spy(&object, SIGNAL(opacityChanged()));
- QVERIFY(object.opacity() == 1.);
+ QCOMPARE(object.opacity(), 1.);
object.setOpacity(0);
QCOMPARE(spy.count(), 1);
- QVERIFY(object.opacity() == 0.);
+ QCOMPARE(object.opacity(), 0.);
object.setOpacity(0);
QCOMPARE(spy.count(), 1);
object.setProperty("opacity", .5);
QCOMPARE(spy.count(), 2);
- QVERIFY(object.property("opacity") == .5);
+ QCOMPARE(object.property("opacity").toDouble(), .5);
}
void tst_QGraphicsObject::enabled()
{
MyGraphicsObject object;
QSignalSpy spy(&object, SIGNAL(enabledChanged()));
- QVERIFY(object.isEnabled() == true);
+ QVERIFY(object.isEnabled());
object.setEnabled(false);
QCOMPARE(spy.count(), 1);
- QVERIFY(object.isEnabled() == false);
+ QVERIFY(!object.isEnabled());
object.setEnabled(false);
QCOMPARE(spy.count(), 1);
object.setProperty("enabled", true);
QCOMPARE(spy.count(), 2);
- QVERIFY(object.property("enabled") == true);
+ QVERIFY(object.property("enabled").toBool());
}
void tst_QGraphicsObject::visible()
{
MyGraphicsObject object;
QSignalSpy spy(&object, SIGNAL(visibleChanged()));
- QVERIFY(object.isVisible() == true);
+ QVERIFY(object.isVisible());
object.setVisible(false);
QCOMPARE(spy.count(), 1);
- QVERIFY(object.isVisible() == false);
+ QVERIFY(!object.isVisible());
object.setVisible(false);
QCOMPARE(spy.count(), 1);
object.setProperty("visible", true);
QCOMPARE(spy.count(), 2);
- QVERIFY(object.property("visible") == true);
+ QVERIFY(object.property("visible").toBool());
}
class DeleteTester : public QGraphicsObject
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index f3a683fe8b..d8a8ed6b4b 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -97,8 +97,8 @@ private slots:
void paint_2();
void setWidget_data();
void setWidget();
- void eventFilter_data();
- void eventFilter();
+ void testEventFilter_data();
+ void testEventFilter();
void focusInEvent_data();
void focusInEvent();
void focusInEventNoWidget();
@@ -179,6 +179,7 @@ private slots:
void mapToGlobal();
void mapToGlobalWithoutScene();
void QTBUG_43780_visibility();
+ void forwardTouchEvent();
};
// Subclass that exposes the protected functions.
@@ -314,7 +315,7 @@ void tst_QGraphicsProxyWidget::qgraphicsproxywidget()
SubQGraphicsProxyWidget proxy;
proxy.paint(0, 0, 0);
proxy.setWidget(0);
- QVERIFY(proxy.type() == QGraphicsProxyWidget::Type);
+ QCOMPARE(proxy.type(), int(QGraphicsProxyWidget::Type));
QVERIFY(!proxy.widget());
QEvent event(QEvent::None);
proxy.call_eventFilter(0, &event);
@@ -533,7 +534,7 @@ void tst_QGraphicsProxyWidget::setWidget()
}
Q_DECLARE_METATYPE(QEvent::Type)
-void tst_QGraphicsProxyWidget::eventFilter_data()
+void tst_QGraphicsProxyWidget::testEventFilter_data()
{
QTest::addColumn<QEvent::Type>("eventType");
QTest::addColumn<bool>("fromObject"); // big grin evil
@@ -552,7 +553,7 @@ void tst_QGraphicsProxyWidget::eventFilter_data()
}
// protected bool eventFilter(QObject* object, QEvent* event)
-void tst_QGraphicsProxyWidget::eventFilter()
+void tst_QGraphicsProxyWidget::testEventFilter()
{
QFETCH(QEvent::Type, eventType);
QFETCH(bool, fromObject);
@@ -1223,6 +1224,7 @@ void tst_QGraphicsProxyWidget::mousePressReleaseEvent()
QGraphicsScene scene;
QGraphicsView view(&scene);
+ view.resize(500, 500);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
@@ -1231,7 +1233,6 @@ void tst_QGraphicsProxyWidget::mousePressReleaseEvent()
QPushButton *widget = new QPushButton;
QSignalSpy spy(widget, SIGNAL(clicked()));
widget->resize(50, 50);
- view.resize(100, 100);
if (hasWidget) {
proxy->setWidget(widget);
proxy->show();
@@ -3017,36 +3018,36 @@ void tst_QGraphicsProxyWidget::createProxyForChildWidget()
layout->addWidget(rightDial);
window.setLayout(layout);
- QVERIFY(window.graphicsProxyWidget() == 0);
- QVERIFY(checkbox->graphicsProxyWidget() == 0);
+ QVERIFY(!window.graphicsProxyWidget());
+ QVERIFY(!checkbox->graphicsProxyWidget());
QGraphicsProxyWidget *windowProxy = scene.addWidget(&window);
QGraphicsView view(&scene);
view.show();
view.resize(500,500);
- QVERIFY(window.graphicsProxyWidget() == windowProxy);
- QVERIFY(box->graphicsProxyWidget() == 0);
- QVERIFY(checkbox->graphicsProxyWidget() == 0);
+ QCOMPARE(window.graphicsProxyWidget(), windowProxy);
+ QVERIFY(!box->graphicsProxyWidget());
+ QVERIFY(!checkbox->graphicsProxyWidget());
QPointer<QGraphicsProxyWidget> checkboxProxy = windowProxy->createProxyForChildWidget(checkbox);
QGraphicsProxyWidget *boxProxy = box->graphicsProxyWidget();
QVERIFY(boxProxy);
- QVERIFY(checkbox->graphicsProxyWidget() == checkboxProxy);
- QVERIFY(checkboxProxy->parentItem() == boxProxy);
- QVERIFY(boxProxy->parentItem() == windowProxy);
+ QCOMPARE(checkbox->graphicsProxyWidget(), checkboxProxy.data());
+ QCOMPARE(checkboxProxy->parentItem(), boxProxy);
+ QCOMPARE(boxProxy->parentItem(), windowProxy);
QVERIFY(checkboxProxy->mapToScene(QPointF()) == checkbox->mapTo(&window, QPoint()));
- QVERIFY(checkboxProxy->size() == checkbox->size());
- QVERIFY(boxProxy->size() == box->size());
+ QCOMPARE(checkboxProxy->size().toSize(), checkbox->size());
+ QCOMPARE(boxProxy->size().toSize(), box->size());
window.resize(500,500);
- QVERIFY(windowProxy->size() == QSize(500,500));
+ QCOMPARE(windowProxy->size().toSize(), QSize(500,500));
QVERIFY(checkboxProxy->mapToScene(QPointF()) == checkbox->mapTo(&window, QPoint()));
- QVERIFY(checkboxProxy->size() == checkbox->size());
- QVERIFY(boxProxy->size() == box->size());
+ QCOMPARE(checkboxProxy->size().toSize(), checkbox->size());
+ QCOMPARE(boxProxy->size().toSize(), box->size());
QTest::qWait(10);
@@ -3064,9 +3065,9 @@ void tst_QGraphicsProxyWidget::createProxyForChildWidget()
boxProxy->setWidget(0);
- QVERIFY(checkbox->graphicsProxyWidget() == 0);
- QVERIFY(box->graphicsProxyWidget() == 0);
- QVERIFY(checkboxProxy == 0);
+ QVERIFY(!checkbox->graphicsProxyWidget());
+ QVERIFY(!box->graphicsProxyWidget());
+ QVERIFY(checkboxProxy.isNull());
delete boxProxy;
}
@@ -3766,5 +3767,73 @@ void tst_QGraphicsProxyWidget::QTBUG_43780_visibility()
QVERIFY(comboPopup->isVisible());
}
+class TouchWidget : public QWidget
+{
+public:
+ TouchWidget(QWidget *parent = 0) : QWidget(parent) {}
+
+ bool event(QEvent *event)
+ {
+ switch (event->type()) {
+ case QEvent::TouchBegin:
+ case QEvent::TouchUpdate:
+ case QEvent::TouchEnd:
+ event->accept();
+ return true;
+ break;
+ default:
+ break;
+ }
+
+ return QWidget::event(event);
+ }
+};
+
+// QTBUG_45737
+void tst_QGraphicsProxyWidget::forwardTouchEvent()
+{
+ QGraphicsScene *scene = new QGraphicsScene;
+
+ TouchWidget *widget = new TouchWidget;
+
+ widget->setAttribute(Qt::WA_AcceptTouchEvents);
+
+ QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget;
+
+ proxy->setAcceptTouchEvents(true);
+ proxy->setWidget(widget);
+
+ scene->addItem(proxy);
+
+ QGraphicsView *view = new QGraphicsView(scene);
+
+ view->show();
+
+ EventSpy eventSpy(widget);
+
+ QTouchDevice *device = new QTouchDevice;
+ device->setType(QTouchDevice::TouchScreen);
+ QWindowSystemInterface::registerTouchDevice(device);
+
+ QCOMPARE(eventSpy.counts[QEvent::TouchBegin], 0);
+ QCOMPARE(eventSpy.counts[QEvent::TouchUpdate], 0);
+ QCOMPARE(eventSpy.counts[QEvent::TouchEnd], 0);
+
+ QTest::touchEvent(view, device).press(0, QPoint(10, 10), view);
+ QTest::touchEvent(view, device).move(0, QPoint(15, 15), view);
+ QTest::touchEvent(view, device).move(0, QPoint(16, 16), view);
+ QTest::touchEvent(view, device).release(0, QPoint(15, 15), view);
+
+ QApplication::processEvents();
+
+ QCOMPARE(eventSpy.counts[QEvent::TouchBegin], 1);
+ QCOMPARE(eventSpy.counts[QEvent::TouchUpdate], 2);
+ QCOMPARE(eventSpy.counts[QEvent::TouchEnd], 1);
+
+ delete view;
+ delete proxy;
+ delete scene;
+}
+
QTEST_MAIN(tst_QGraphicsProxyWidget)
#include "tst_qgraphicsproxywidget.moc"
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
index 7bd0393760..ae71b0412f 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -1282,33 +1282,16 @@ void tst_QGraphicsScene::removeItem()
view.show();
QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
- QTest::mouseMove(view.viewport(), QPoint(-1, -1));
- {
- QMouseEvent moveEvent(QEvent::MouseMove, view.mapFromScene(hoverItem->scenePos() + QPointF(20, 20)), Qt::NoButton, 0, 0);
- QApplication::sendEvent(view.viewport(), &moveEvent);
- }
- qApp->processEvents(); // update
- qApp->processEvents(); // draw
- QVERIFY(!hoverItem->isHovered);
+ QTest::mouseMove(view.viewport(), view.mapFromScene(hoverItem->scenePos() + QPointF(20, 20)), Qt::NoButton);
+ QTRY_VERIFY(!hoverItem->isHovered);
- {
- QTest::qWait(250);
- QTest::mouseMove(view.viewport(), view.mapFromScene(hoverItem->scenePos()), Qt::NoButton);
- QTest::qWait(10);
- QMouseEvent moveEvent(QEvent::MouseMove, view.mapFromScene(hoverItem->scenePos()), Qt::NoButton, 0, 0);
- QApplication::sendEvent(view.viewport(), &moveEvent);
- }
- qApp->processEvents(); // update
- qApp->processEvents(); // draw
- QVERIFY(hoverItem->isHovered);
+ QTest::mouseMove(view.viewport(), view.mapFromScene(hoverItem->scenePos()), Qt::NoButton);
+ QTRY_VERIFY(hoverItem->isHovered);
scene.removeItem(hoverItem);
hoverItem->setAcceptsHoverEvents(false);
scene.addItem(hoverItem);
- qApp->processEvents(); // <- delayed update is called
- qApp->processEvents(); // <- scene schedules pending update
- qApp->processEvents(); // <- pending update is sent to view
- QVERIFY(!hoverItem->isHovered);
+ QTRY_VERIFY(!hoverItem->isHovered);
}
void tst_QGraphicsScene::focusItem()
@@ -3509,6 +3492,8 @@ void tst_QGraphicsScene::task160653_selectionChanged()
QSignalSpy spy(&scene, SIGNAL(selectionChanged()));
QGraphicsView view(&scene);
+ view.show();
+ QVERIFY(QTest::qWaitForWindowActive(&view));
QTest::mouseClick(
view.viewport(), Qt::LeftButton, 0, view.mapFromScene(scene.items().first()->scenePos()));
QCOMPARE(spy.count(), 1);
@@ -4742,9 +4727,9 @@ void tst_QGraphicsScene::minimumRenderSize()
QTRY_VERIFY(view.repaints > viewRepaints);
viewRepaints = view.repaints;
- QVERIFY(viewRepaints == bigParent->repaints);
- QVERIFY(viewRepaints == smallChild->repaints);
- QVERIFY(viewRepaints == smallerGrandChild->repaints);
+ QCOMPARE(viewRepaints, bigParent->repaints);
+ QCOMPARE(viewRepaints, smallChild->repaints);
+ QCOMPARE(viewRepaints, smallerGrandChild->repaints);
// Setting a minimum render size should cause a repaint
scene.setMinimumRenderSize(0.5);
@@ -4753,9 +4738,9 @@ void tst_QGraphicsScene::minimumRenderSize()
QTRY_VERIFY(view.repaints > viewRepaints);
viewRepaints = view.repaints;
- QVERIFY(viewRepaints == bigParent->repaints);
- QVERIFY(viewRepaints == smallChild->repaints);
- QVERIFY(viewRepaints == smallerGrandChild->repaints);
+ QCOMPARE(viewRepaints, bigParent->repaints);
+ QCOMPARE(viewRepaints, smallChild->repaints);
+ QCOMPARE(viewRepaints, smallerGrandChild->repaints);
// Scaling should cause a repaint of big items only.
view.scale(0.1, 0.1);
@@ -4764,8 +4749,8 @@ void tst_QGraphicsScene::minimumRenderSize()
QTRY_VERIFY(view.repaints > viewRepaints);
viewRepaints = view.repaints;
- QVERIFY(viewRepaints == bigParent->repaints);
- QVERIFY(viewRepaints == smallChild->repaints);
+ QCOMPARE(viewRepaints, bigParent->repaints);
+ QCOMPARE(viewRepaints, smallChild->repaints);
QVERIFY(smallChild->repaints > smallerGrandChild->repaints);
// Scaling further should cause even fewer items to be repainted
@@ -4775,7 +4760,7 @@ void tst_QGraphicsScene::minimumRenderSize()
QTRY_VERIFY(view.repaints > viewRepaints);
viewRepaints = view.repaints;
- QVERIFY(viewRepaints == bigParent->repaints);
+ QCOMPARE(viewRepaints, bigParent->repaints);
QVERIFY(bigParent->repaints > smallChild->repaints);
QVERIFY(smallChild->repaints > smallerGrandChild->repaints);
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST
index be7a7e398b..3cba8bad7e 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST
@@ -1,4 +1,18 @@
[task255529_transformationAnchorMouseAndViewportMargins]
-ubuntu-14.04
+xcb
[cursor]
-ubuntu-14.04
+xcb
+[cursor2]
+xcb
+[rubberBandExtendSelection]
+xcb
+[rotated_rubberBand]
+xcb
+[sendEvent]
+xcb
+[forwardMousePress]
+xcb
+[hoverLeave]
+xcb
+[resizeAnchor]
+xcb
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
index d1d4c1ab86..98473fb5cc 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
@@ -145,7 +145,7 @@ class tst_QGraphicsView : public QObject
public:
tst_QGraphicsView()
- : platformName(qApp->platformName().toLower())
+ : platformName(QGuiApplication::platformName().toLower())
{ }
private slots:
void initTestCase();
@@ -255,7 +255,6 @@ private slots:
void task186827_deleteReplayedItem();
void task207546_focusCrash();
void task210599_unsetDragWhileDragging();
- void task236394_sendShortcutOverrideEvent();
void task239729_noViewUpdate_data();
void task239729_noViewUpdate();
void task239047_fitInViewSmallViewport();
@@ -3369,14 +3368,6 @@ void tst_QGraphicsView::task210599_unsetDragWhileDragging()
QCOMPARE(basePos, view.mapFromScene(0, 0));
}
-void tst_QGraphicsView::task236394_sendShortcutOverrideEvent()
-{
- QGraphicsView view;
- view.show();
- QKeyEvent event(QEvent::ShortcutOverride, Qt::Key_A, 0, QString("A"));
- QApplication::sendEvent(&view, &event);
-}
-
class ChangedListener : public QObject
{
Q_OBJECT
@@ -3525,7 +3516,7 @@ void tst_QGraphicsView::embeddedViews()
v2->QWidget::render(&actual);
QTransform b = item->transform;
- QVERIFY(a == b);
+ QCOMPARE(a, b);
delete v1;
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
index 9b92c34fb5..ec2203e615 100644
--- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -182,14 +182,6 @@ private slots:
void QTBUG_45867_send_itemChildAddedChange_to_parent();
};
-
-static void sendMouseMove(QWidget *widget, const QPoint &point, Qt::MouseButton button = Qt::NoButton, Qt::MouseButtons buttons = 0)
-{
- QTest::mouseMove(widget, point);
- QMouseEvent event(QEvent::MouseMove, point, button, buttons, 0);
- QApplication::sendEvent(widget, &event);
-}
-
// Subclass that exposes the protected functions.
class SubQGraphicsWidget : public QGraphicsWidget {
public:
@@ -197,7 +189,7 @@ public:
: QGraphicsWidget(parent, windowFlags), eventCount(0)
{ }
- void initStyleOption(QStyleOption *option)
+ void initStyleOption(QStyleOption *option) const
{ QGraphicsWidget::initStyleOption(option); }
void call_changeEvent(QEvent* event)
@@ -1110,8 +1102,8 @@ void tst_QGraphicsWidget::initStyleOption()
{
QGraphicsScene scene;
QGraphicsView view(&scene);
+ view.resize(300, 300);
view.show();
- QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
view.setAlignment(Qt::AlignTop | Qt::AlignLeft);
@@ -1133,10 +1125,8 @@ void tst_QGraphicsWidget::initStyleOption()
}
QFETCH(bool, underMouse);
if (underMouse) {
- view.resize(300, 300);
- view.show();
- QVERIFY(QTest::qWaitForWindowActive(&view));
- sendMouseMove(view.viewport(), view.mapFromScene(widget->mapToScene(widget->boundingRect().center())));
+ QCursor::setPos(view.viewport()->mapToGlobal(view.mapFromScene(widget->mapToScene(widget->boundingRect().center()))));
+ QTest::qWait(100);
}
QFETCH(QPalette, palette);
diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
index eed38752d9..3a17f7c690 100644
--- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
@@ -250,6 +250,7 @@ private slots:
void QTBUG39324_settingSameInstanceOfIndexWidget();
void sizeHintChangeTriggersLayout();
void shiftSelectionAfterChangingModelContents();
+ void QTBUG48968_reentrant_updateEditorGeometries();
};
class MyAbstractItemDelegate : public QAbstractItemDelegate
@@ -1036,7 +1037,7 @@ void tst_QAbstractItemView::dragAndDropOnChild()
++successes;
}
- QVERIFY(successes == 0);
+ QCOMPARE(successes, 0);
}
#endif // 0
@@ -1214,7 +1215,7 @@ void tst_QAbstractItemView::setCurrentIndex()
view->setModel(model);
view->setCurrentIndex(model->index(0,0));
- QVERIFY(view->currentIndex() == model->index(0,0));
+ QCOMPARE(view->currentIndex(), model->index(0,0));
view->setCurrentIndex(model->index(1,0));
QVERIFY(view->currentIndex() == model->index(result ? 1 : 0,0));
}
@@ -1990,5 +1991,42 @@ void tst_QAbstractItemView::shiftSelectionAfterChangingModelContents()
QVERIFY(selected.contains(indexE));
}
+void tst_QAbstractItemView::QTBUG48968_reentrant_updateEditorGeometries()
+{
+
+ QStandardItemModel *m = new QStandardItemModel(this);
+ for (int i=0; i<10; ++i) {
+ QStandardItem *item = new QStandardItem(QString("Item number %1").arg(i));
+ item->setEditable(true);
+ for (int j=0; j<5; ++j) {
+ QStandardItem *child = new QStandardItem(QString("Child Item number %1").arg(j));
+ item->setChild(j, 0, child);
+ }
+ m->setItem(i, 0, item);
+ }
+
+ QTreeView tree;
+ tree.setModel(m);
+ tree.setRootIsDecorated(false);
+ QObject::connect(&tree, SIGNAL(doubleClicked(QModelIndex)), &tree, SLOT(setRootIndex(QModelIndex)));
+ tree.show();
+ QTest::qWaitForWindowActive(&tree);
+
+ // Trigger editing idx
+ QModelIndex idx = m->index(1, 0);
+ const QPoint pos = tree.visualRect(idx).center();
+ QTest::mouseClick(tree.viewport(), Qt::LeftButton, Qt::NoModifier, pos);
+ QTest::mouseDClick(tree.viewport(), Qt::LeftButton, Qt::NoModifier, pos);
+
+ // Add more children to idx
+ QStandardItem *item = m->itemFromIndex(idx);
+ for (int j=5; j<10; ++j) {
+ QStandardItem *child = new QStandardItem(QString("Child Item number %1").arg(j));
+ item->setChild(j, 0, child);
+ }
+
+ // No crash, all fine.
+}
+
QTEST_MAIN(tst_QAbstractItemView)
#include "tst_qabstractitemview.moc"
diff --git a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp
index f5e6facaad..6645da727c 100644
--- a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp
+++ b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp
@@ -292,7 +292,7 @@ void tst_QColumnView::grips()
for (int i = 0 ; i < list.count(); ++i) {
if (QAbstractItemView *view = qobject_cast<QAbstractItemView*>(list.at(i))) {
if (view->isVisible())
- QVERIFY(view->cornerWidget() == 0);
+ QVERIFY(!view->cornerWidget());
}
}
}
@@ -587,7 +587,7 @@ void tst_QColumnView::selectAll()
QVERIFY(view.selectionModel()->selectedIndexes().count() > 0);
view.setCurrentIndex(QModelIndex());
- QVERIFY(view.selectionModel()->selectedIndexes().count() == 0);
+ QCOMPARE(view.selectionModel()->selectedIndexes().count(), 0);
}
void tst_QColumnView::clicked()
diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
index 21e4b82366..55fcf04846 100644
--- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
@@ -239,6 +239,8 @@ private slots:
void testStreamWithHide();
void testStylePosition();
+ void sizeHintCrash();
+
protected:
void setupTestData(bool use_reset_model = false);
void additionalInit();
@@ -403,7 +405,7 @@ void tst_QHeaderView::init()
view = new QHeaderView(Qt::Vertical,topLevel);
// Some initial value tests before a model is added
QCOMPARE(view->length(), 0);
- QVERIFY(view->sizeHint() == QSize(0,0));
+ QCOMPARE(view->sizeHint(), QSize(0,0));
QCOMPARE(view->sectionSizeHint(0), -1);
/*
@@ -925,9 +927,9 @@ void tst_QHeaderView::moveSection()
QFETCH(QList<int>, logical);
QFETCH(int, count);
- QVERIFY(from.count() == to.count());
- QVERIFY(from.count() == moved.count());
- QVERIFY(view->count() == logical.count());
+ QCOMPARE(from.count(), to.count());
+ QCOMPARE(from.count(), moved.count());
+ QCOMPARE(view->count(), logical.count());
QSignalSpy spy1(view, SIGNAL(sectionMoved(int,int,int)));
QCOMPARE(view->sectionsMoved(), false);
@@ -1370,15 +1372,15 @@ void tst_QHeaderView::unhideSection()
QCOMPARE(view->sectionsHidden(), false);
view->setSectionHidden(0, true);
QCOMPARE(view->sectionsHidden(), true);
- QVERIFY(view->sectionSize(0) == 0);
+ QCOMPARE(view->sectionSize(0), 0);
view->setSectionResizeMode(QHeaderView::Interactive);
view->setSectionHidden(0, false);
QVERIFY(view->sectionSize(0) > 0);
view->setSectionHidden(0, true);
- QVERIFY(view->sectionSize(0) == 0);
+ QCOMPARE(view->sectionSize(0), 0);
view->setSectionHidden(0, true);
- QVERIFY(view->sectionSize(0) == 0);
+ QCOMPARE(view->sectionSize(0), 0);
view->setSectionResizeMode(QHeaderView::Stretch);
view->setSectionHidden(0, false);
QVERIFY(view->sectionSize(0) > 0);
@@ -1645,7 +1647,7 @@ void tst_QHeaderView::saveRestore()
QByteArray s2 = h2.saveState();
- QVERIFY(s1 == s2);
+ QCOMPARE(s1, s2);
QVERIFY(!h2.restoreState(QByteArrayLiteral("Garbage")));
// QTBUG-40462
@@ -1659,7 +1661,7 @@ void tst_QHeaderView::saveRestore()
int sectionItemsLengthTotal = 0;
for (int i = 0; i < h2.count(); ++i)
sectionItemsLengthTotal += h2.sectionSize(i);
- QVERIFY(sectionItemsLengthTotal == h2.length());
+ QCOMPARE(sectionItemsLengthTotal, h2.length());
// Buggy setting where sum(sectionItems) != length. Check false is returned and this corrupted
// state isn't restored
@@ -1676,8 +1678,8 @@ void tst_QHeaderView::saveRestore()
// Check setting is correctly recognized as corrupted
QVERIFY(!h2.restoreState(settings_buggy_length));
// Check nothing has been actually restored
- QVERIFY(h2.length() == old_length);
- QVERIFY(h2.saveState() == old_state);
+ QCOMPARE(h2.length(), old_length);
+ QCOMPARE(h2.saveState(), old_state);
}
void tst_QHeaderView::defaultSectionSizeTest()
@@ -1699,7 +1701,7 @@ void tst_QHeaderView::defaultSectionSizeTest()
// no hidden Sections
hv->resizeSection(1, 0);
hv->setDefaultSectionSize(defaultSize);
- QVERIFY(hv->sectionSize(1) == defaultSize);
+ QCOMPARE(hv->sectionSize(1), defaultSize);
// with hidden sections
hv->resizeSection(1, 0);
@@ -2277,7 +2279,7 @@ void tst_QHeaderView::QTBUG14242_hideSectionAutoSize()
for (int u = 0; u < hv->count(); ++u)
calced_length += hv->sectionSize(u);
- QVERIFY(calced_length == afterlength);
+ QCOMPARE(calced_length, afterlength);
}
void tst_QHeaderView::ensureNoIndexAtLength()
@@ -2286,9 +2288,9 @@ void tst_QHeaderView::ensureNoIndexAtLength()
QStandardItemModel amodel(4, 4);
qtv.setModel(&amodel);
QHeaderView *hv = qtv.verticalHeader();
- QVERIFY(hv->visualIndexAt(hv->length()) == -1);
+ QCOMPARE(hv->visualIndexAt(hv->length()), -1);
hv->resizeSection(hv->count() - 1, 0);
- QVERIFY(hv->visualIndexAt(hv->length()) == -1);
+ QCOMPARE(hv->visualIndexAt(hv->length()), -1);
}
void tst_QHeaderView::offsetConsistent()
@@ -2307,7 +2309,7 @@ void tst_QHeaderView::offsetConsistent()
hv->hideSection(sectionToHide);
hv->setOffsetToSectionPosition(150);
int offset2 = hv->offset();
- QVERIFY(offset1 == offset2);
+ QCOMPARE(offset1, offset2);
// Ensure that hidden indexes (still) is considered.
hv->resizeSection(sectionToHide, hv->sectionSize(200) * 2);
hv->setOffsetToSectionPosition(800);
@@ -2600,8 +2602,8 @@ void tst_QHeaderView::logicalIndexAtTest()
//qDebug() << "logicalIndexAtTest" << check1 << check2;
const int precalced_check1 = 106327;
const int precalced_check2 = 29856418;
- QVERIFY(precalced_check1 == check1);
- QVERIFY(precalced_check2 == check2);
+ QCOMPARE(precalced_check1, check1);
+ QCOMPARE(precalced_check2, check2);
const int precalced_results[] = { 1145298384, -1710423344, -650981936, 372919464, -1544372176, -426463328, 12124 };
calculateAndCheck(__LINE__, precalced_results);
@@ -2628,8 +2630,8 @@ void tst_QHeaderView::visualIndexAtTest()
//qDebug() << "visualIndexAtTest" << check1 << check2;
const int precalced_check1 = 72665;
const int precalced_check2 = 14015890;
- QVERIFY(precalced_check1 == check1);
- QVERIFY(precalced_check2 == check2);
+ QCOMPARE(precalced_check1, check1);
+ QCOMPARE(precalced_check2, check2);
const int precalced_results[] = { 1145298384, -1710423344, -1457520212, 169223959, 557466160, -324939600, 5453 };
calculateAndCheck(__LINE__, precalced_results);
@@ -2879,5 +2881,15 @@ void tst_QHeaderView::testStylePosition()
QCOMPARE(proxy.lastPosition, QStyleOptionHeader::OnlyOneSection);
}
+void tst_QHeaderView::sizeHintCrash()
+{
+ QTreeView treeView;
+ QStandardItemModel *model = new QStandardItemModel(&treeView);
+ model->appendRow(new QStandardItem("QTBUG-48543"));
+ treeView.setModel(model);
+ treeView.header()->sizeHintForColumn(0);
+ treeView.header()->sizeHintForRow(0);
+}
+
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 439eeff005..25f27cb0c7 100644
--- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
@@ -804,9 +804,9 @@ void tst_QItemDelegate::dateTimeEditor()
dateTimeEditor->setTime(time.addSecs(600));
widget.clearFocus();
- QVERIFY(item1->data(Qt::EditRole).userType() == QMetaType::QTime);
- QVERIFY(item2->data(Qt::EditRole).userType() == QMetaType::QDate);
- QVERIFY(item3->data(Qt::EditRole).userType() == QMetaType::QDateTime);
+ QCOMPARE(item1->data(Qt::EditRole).userType(), int(QMetaType::QTime));
+ QCOMPARE(item2->data(Qt::EditRole).userType(), int(QMetaType::QDate));
+ QCOMPARE(item3->data(Qt::EditRole).userType(), int(QMetaType::QDateTime));
}
// A delegate where we can either enforce a certain widget or use the standard widget.
@@ -901,9 +901,9 @@ void tst_QItemDelegate::dateAndTimeEditorTest2()
s.setData(i1, datetime2);
editor = w.fastEdit(i1);
timeEdit = qobject_cast<QTimeEdit*>(editor);
- QVERIFY(timeEdit == 0);
+ QVERIFY(!timeEdit);
dateEdit = qobject_cast<QDateEdit*>(editor);
- QVERIFY(dateEdit == 0);
+ QVERIFY(!dateEdit);
dateTimeEdit = qobject_cast<QDateTimeEdit*>(editor);
QVERIFY(dateTimeEdit);
QCOMPARE(dateTimeEdit->dateTime(), datetime2);
@@ -1154,7 +1154,7 @@ void tst_QItemDelegate::editorEvent_data()
QTest::newRow("unchecked, tristate, release")
<< (int)(Qt::Unchecked)
- << (int)(defaultFlags | Qt::ItemIsTristate)
+ << (int)(defaultFlags | Qt::ItemIsAutoTristate)
<< true
<< (int)(QEvent::MouseButtonRelease)
<< (int)(Qt::LeftButton)
@@ -1163,7 +1163,7 @@ void tst_QItemDelegate::editorEvent_data()
QTest::newRow("partially checked, tristate, release")
<< (int)(Qt::PartiallyChecked)
- << (int)(defaultFlags | Qt::ItemIsTristate)
+ << (int)(defaultFlags | Qt::ItemIsAutoTristate)
<< true
<< (int)(QEvent::MouseButtonRelease)
<< (int)(Qt::LeftButton)
@@ -1172,7 +1172,7 @@ void tst_QItemDelegate::editorEvent_data()
QTest::newRow("checked, tristate, release")
<< (int)(Qt::Checked)
- << (int)(defaultFlags | Qt::ItemIsTristate)
+ << (int)(defaultFlags | Qt::ItemIsAutoTristate)
<< true
<< (int)(QEvent::MouseButtonRelease)
<< (int)(Qt::LeftButton)
diff --git a/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp b/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp
index 3a6f1f933d..8fd86ea467 100644
--- a/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp
+++ b/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp
@@ -483,6 +483,7 @@ void tst_QItemView::spider()
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
view->setModel(treeModel);
view->show();
+ QVERIFY(QTest::qWaitForWindowActive(view));
#if defined(Q_OS_WINCE)
srandom(0);
#else
@@ -551,7 +552,7 @@ void tst_QItemView::visualRect()
QFETCH(bool, displays);
if (!displays){
- QVERIFY(view->visualRect(topIndex) == QRect());
+ QCOMPARE(view->visualRect(topIndex), QRect());
return;
}
@@ -559,15 +560,15 @@ void tst_QItemView::visualRect()
view->show();
QVERIFY(view->visualRect(topIndex) != QRect());
- QVERIFY(topIndex == view->indexAt(view->visualRect(topIndex).center()));
- QVERIFY(topIndex == view->indexAt(view->visualRect(topIndex).bottomLeft()));
- QVERIFY(topIndex == view->indexAt(view->visualRect(topIndex).bottomRight()));
- QVERIFY(topIndex == view->indexAt(view->visualRect(topIndex).topLeft()));
- QVERIFY(topIndex == view->indexAt(view->visualRect(topIndex).topRight()));
+ QCOMPARE(topIndex, view->indexAt(view->visualRect(topIndex).center()));
+ QCOMPARE(topIndex, view->indexAt(view->visualRect(topIndex).bottomLeft()));
+ QCOMPARE(topIndex, view->indexAt(view->visualRect(topIndex).bottomRight()));
+ QCOMPARE(topIndex, view->indexAt(view->visualRect(topIndex).topLeft()));
+ QCOMPARE(topIndex, view->indexAt(view->visualRect(topIndex).topRight()));
testViews->hideIndexes(view);
QModelIndex hiddenIndex = treeModel->index(1, 0);
- QVERIFY(view->visualRect(hiddenIndex) == QRect());
+ QCOMPARE(view->visualRect(hiddenIndex), QRect());
}
void tst_QItemView::walkScreen(QAbstractItemView *view)
@@ -615,7 +616,7 @@ void walkIndex(QModelIndex index, QAbstractItemView *view)
if (view->indexAt(point) != index) {
qDebug() << "index" << index << "visualRect" << visualRect << point << view->indexAt(point);
}
- QVERIFY(view->indexAt(point) == index);
+ QCOMPARE(view->indexAt(point), index);
}
}
diff --git a/tests/auto/widgets/itemviews/qlistview/qlistview.pro b/tests/auto/widgets/itemviews/qlistview/qlistview.pro
index 0623fc8ede..509303b62e 100644
--- a/tests/auto/widgets/itemviews/qlistview/qlistview.pro
+++ b/tests/auto/widgets/itemviews/qlistview/qlistview.pro
@@ -3,3 +3,4 @@ TARGET = tst_qlistview
QT += widgets gui-private widgets-private core-private testlib
SOURCES += tst_qlistview.cpp
win32:!wince:!winrt: LIBS += -luser32
+linux*: CONFIG += insignificant_test # Crashes
diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
index 1b21096b44..5b206af357 100644
--- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
+++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
@@ -38,6 +38,7 @@
#include <qapplication.h>
#include <qlistview.h>
#include <private/qlistview_p.h>
+#include <private/qcoreapplication_p.h>
#include <qlistwidget.h>
#include <qitemdelegate.h>
#include <qstandarditemmodel.h>
@@ -150,6 +151,7 @@ private slots:
void testViewOptions();
void taskQTBUG_39902_mutualScrollBars_data();
void taskQTBUG_39902_mutualScrollBars();
+ void horizontalScrollingByVerticalWheelEvents();
};
// Testing get/set functions
@@ -1209,7 +1211,7 @@ void tst_QListView::scrollTo()
list << "Short item";
model.setStringList(list);
lv.setModel(&model);
- lv.setFixedSize(100, 200);
+ lv.setFixedSize(110, 200);
topLevel.show();
QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
@@ -2018,8 +2020,7 @@ void tst_QListView::styleOptionViewItem()
public:
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
- QVERIFY(qstyleoption_cast<const QStyleOptionViewItemV4 *>(&option));
- QStyleOptionViewItemV4 opt(option);
+ QStyleOptionViewItem opt(option);
initStyleOption(&opt, index);
QCOMPARE(opt.index, index);
@@ -2445,5 +2446,52 @@ void tst_QListView::taskQTBUG_39902_mutualScrollBars()
QTRY_VERIFY(view->verticalScrollBar()->isVisible());
}
+void tst_QListView::horizontalScrollingByVerticalWheelEvents()
+{
+ QListView lv;
+ lv.setWrapping(true);
+
+ TestDelegate *delegate = new TestDelegate(&lv);
+ delegate->m_sizeHint = QSize(100, 100);
+ lv.setItemDelegate(delegate);
+
+ QtTestModel model;
+ model.colCount = 1;
+ model.rCount = 100;
+
+ lv.setModel(&model);
+
+ lv.resize(300, 300);
+ lv.show();
+ QTest::qWaitForWindowExposed(&lv);
+
+ QPoint globalPos = lv.geometry().center();
+ QPoint pos = lv.viewport()->geometry().center();
+
+ QWheelEvent wheelDownEvent(pos, globalPos, QPoint(0, 0), QPoint(0, -120), -120, Qt::Vertical, 0, 0);
+ QWheelEvent wheelUpEvent(pos, globalPos, QPoint(0, 0), QPoint(0, 120), 120, Qt::Vertical, 0, 0);
+ QWheelEvent wheelLeftDownEvent(pos, globalPos, QPoint(0, 0), QPoint(120, -120), -120, Qt::Vertical, 0, 0);
+
+ int hValue = lv.horizontalScrollBar()->value();
+ QApplication::sendEvent(lv.viewport(), &wheelDownEvent);
+ QVERIFY(lv.horizontalScrollBar()->value() > hValue);
+
+ QApplication::sendEvent(lv.viewport(), &wheelUpEvent);
+ QCOMPARE(lv.horizontalScrollBar()->value(), hValue);
+
+ QApplication::sendEvent(lv.viewport(), &wheelLeftDownEvent);
+ QCOMPARE(lv.horizontalScrollBar()->value(), hValue);
+
+ // ensure that vertical wheel events are not converted when vertical
+ // scroll bar is not visible but vertical scrolling is possible
+ lv.setWrapping(false);
+ lv.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ QApplication::processEvents();
+
+ int vValue = lv.verticalScrollBar()->value();
+ QApplication::sendEvent(lv.viewport(), &wheelDownEvent);
+ QVERIFY(lv.verticalScrollBar()->value() > vValue);
+}
+
QTEST_MAIN(tst_QListView)
#include "tst_qlistview.moc"
diff --git a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
index dcbdbe824a..ecf72613da 100644
--- a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
+++ b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
@@ -427,9 +427,9 @@ void tst_QListWidget::currentItem()
// actual test
QModelIndex currentIndex = testWidget->selectionModel()->currentIndex();
if (currentIndex.isValid())
- QVERIFY(testWidget->currentItem() == testWidget->item(currentIndex.row()));
+ QCOMPARE(testWidget->currentItem(), testWidget->item(currentIndex.row()));
else
- QVERIFY(testWidget->currentItem() == (QListWidgetItem*)0);
+ QCOMPARE(testWidget->currentItem(), (QListWidgetItem*)0);
}
void tst_QListWidget::currentRow()
@@ -742,7 +742,7 @@ void tst_QListWidget::selectedItems()
QFETCH(IntList, selectedRows);
QFETCH(IntList, expectedRows);
- QVERIFY(testWidget->count() == 0);
+ QCOMPARE(testWidget->count(), 0);
//insert items
for (int i=0; i<itemCount; ++i)
@@ -1159,7 +1159,7 @@ void tst_QListWidget::setData()
QFETCH(int, expectedSignalCount);
qRegisterMetaType<QListWidgetItem *>("QListWidgetItem*");
- QVERIFY(roles.count() == values.count());
+ QCOMPARE(roles.count(), values.count());
for (int manipulateModel=0; manipulateModel<2; ++manipulateModel) {
testWidget->clear();
@@ -1711,7 +1711,7 @@ void tst_QListWidget::mimeData()
QVERIFY(data->hasFormat(format));
QVERIFY(data2->hasFormat(format));
- QVERIFY(data->data(format) == data2->data(format));
+ QCOMPARE(data->data(format), data2->data(format));
delete data;
delete data2;
diff --git a/tests/auto/widgets/itemviews/qtableview/BLACKLIST b/tests/auto/widgets/itemviews/qtableview/BLACKLIST
index fc231a4e30..329010a86e 100644
--- a/tests/auto/widgets/itemviews/qtableview/BLACKLIST
+++ b/tests/auto/widgets/itemviews/qtableview/BLACKLIST
@@ -1,2 +1,4 @@
[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 75f77f8107..e5abd6bc46 100644
--- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
@@ -2249,11 +2249,11 @@ void tst_QTableView::resizeColumnsToContents_data()
QTest::addColumn<int>("rowHeight");
QTest::addColumn<int>("columnWidth");
- QTest::newRow("10x10 grid shown 40x40")
- << 10 << 10 << false << 40 << 40 << 40 << 40;
+ QTest::newRow("10x10 grid not shown 60x60")
+ << 10 << 10 << false << 60 << 60 << 60 << 60;
- QTest::newRow("10x10 grid not shown 40x40")
- << 10 << 10 << true << 40 << 40 << 41 << 41;
+ QTest::newRow("10x10 grid shown 60x60")
+ << 10 << 10 << true << 60 << 60 << 61 << 61;
}
void tst_QTableView::resizeColumnsToContents()
@@ -4051,9 +4051,9 @@ void tst_QTableView::mouseWheel()
QWheelEvent verticalEvent(pos, delta, 0, 0, Qt::Vertical);
QWheelEvent horizontalEvent(pos, delta, 0, 0, Qt::Horizontal);
QApplication::sendEvent(view.viewport(), &horizontalEvent);
- QVERIFY(qAbs(view.horizontalScrollBar()->value() - horizontalPositon) < 10);
+ QVERIFY(qAbs(view.horizontalScrollBar()->value() - horizontalPositon) < 15);
QApplication::sendEvent(view.viewport(), &verticalEvent);
- QVERIFY(qAbs(view.verticalScrollBar()->value() - verticalPosition) < 10);
+ QVERIFY(qAbs(view.verticalScrollBar()->value() - verticalPosition) < 15);
}
#endif // !QT_NO_WHEELEVENT
diff --git a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
index 36bc23910c..ea31fd19dd 100644
--- a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
+++ b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
@@ -94,6 +94,7 @@ private slots:
void task262056_sortDuplicate();
void itemWithHeaderItems();
void mimeData();
+ void selectedRowAfterSorting();
private:
QTableWidget *testWidget;
@@ -196,9 +197,9 @@ void tst_QTableWidget::clearContents()
{
QTableWidgetItem *item = new QTableWidgetItem("test");
testWidget->setHorizontalHeaderItem(0, item);
- QVERIFY(testWidget->horizontalHeaderItem(0) == item);
+ QCOMPARE(testWidget->horizontalHeaderItem(0), item);
testWidget->clearContents();
- QVERIFY(testWidget->horizontalHeaderItem(0) == item);
+ QCOMPARE(testWidget->horizontalHeaderItem(0), item);
}
void tst_QTableWidget::clear()
@@ -1559,11 +1560,29 @@ void tst_QTableWidget::mimeData()
QVERIFY(data->hasFormat(format));
QVERIFY(data2->hasFormat(format));
- QVERIFY(data->data(format) == data2->data(format));
+ QCOMPARE(data->data(format), data2->data(format));
delete data;
delete data2;
}
+void tst_QTableWidget::selectedRowAfterSorting()
+{
+ TestTableWidget table(3,3);
+ table.setSelectionBehavior(QAbstractItemView::SelectRows);
+ for (int r = 0; r < 3; r++)
+ for (int c = 0; c < 3; c++)
+ table.setItem(r,c,new QTableWidgetItem(QStringLiteral("0")));
+ QHeaderView *localHorizontalHeader = table.horizontalHeader();
+ localHorizontalHeader->setSortIndicator(1,Qt::DescendingOrder);
+ table.setProperty("sortingEnabled",true);
+ table.selectRow(1);
+ table.item(1,1)->setText("9");
+ QCOMPARE(table.selectedItems().count(),3);
+ foreach (QTableWidgetItem *item, table.selectedItems()) {
+ QCOMPARE(item->row(),0);
+ }
+}
+
QTEST_MAIN(tst_QTableWidget)
#include "tst_qtablewidget.moc"
diff --git a/tests/auto/widgets/itemviews/qtreeview/qtreeview.pro b/tests/auto/widgets/itemviews/qtreeview/qtreeview.pro
index 3abd58e73d..e8406dab7b 100644
--- a/tests/auto/widgets/itemviews/qtreeview/qtreeview.pro
+++ b/tests/auto/widgets/itemviews/qtreeview/qtreeview.pro
@@ -4,3 +4,5 @@ QT += widgets testlib
QT += widgets-private gui-private core-private
SOURCES += tst_qtreeview.cpp
HEADERS += ../../../../shared/fakedirmodel.h
+
+win32: CONFIG += insignificant_test
diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
index 340637513c..033464c9db 100644
--- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
@@ -253,7 +253,6 @@ private slots:
void taskQTBUG_25333_adjustViewOptionsForIndex();
void taskQTBUG_18539_emitLayoutChanged();
void taskQTBUG_8176_emitOnExpandAll();
- void taskQTBUG_34717_collapseAtBottom();
void taskQTBUG_37813_crash();
void taskQTBUG_45697_crash();
void testInitialFocus();
@@ -2365,7 +2364,7 @@ void tst_QTreeView::selectionOrderTest()
void tst_QTreeView::selection()
{
- if (qApp->platformName().toLower() == QLatin1String("wayland"))
+ if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: This causes a crash triggered by setVisible(false)");
QTreeView treeView;
@@ -3076,7 +3075,7 @@ void tst_QTreeView::styleOptionViewItem()
{
class MyDelegate : public QStyledItemDelegate
{
- static QString posToString(QStyleOptionViewItemV4::ViewItemPosition pos) {
+ static QString posToString(QStyleOptionViewItem::ViewItemPosition pos) {
static const char* s_pos[] = { "Invalid", "Beginning", "Middle", "End", "OnlyOne" };
return s_pos[pos];
}
@@ -3089,8 +3088,7 @@ void tst_QTreeView::styleOptionViewItem()
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const
{
- QVERIFY(qstyleoption_cast<const QStyleOptionViewItemV4 *>(&option));
- QStyleOptionViewItemV4 opt(option);
+ QStyleOptionViewItem opt(option);
initStyleOption(&opt, index);
QVERIFY(!opt.text.isEmpty());
@@ -3098,20 +3096,20 @@ void tst_QTreeView::styleOptionViewItem()
//qDebug() << index << opt.text;
if (allCollapsed)
- QCOMPARE(!(opt.features & QStyleOptionViewItemV2::Alternate), !(index.row() % 2));
- QCOMPARE(!(opt.features & QStyleOptionViewItemV2::HasCheckIndicator), !opt.text.contains("Checkable"));
+ QCOMPARE(!(opt.features & QStyleOptionViewItem::Alternate), !(index.row() % 2));
+ QCOMPARE(!(opt.features & QStyleOptionViewItem::HasCheckIndicator), !opt.text.contains("Checkable"));
if (opt.text.contains("Beginning"))
- QCOMPARE(posToString(opt.viewItemPosition), posToString(QStyleOptionViewItemV4::Beginning));
+ QCOMPARE(posToString(opt.viewItemPosition), posToString(QStyleOptionViewItem::Beginning));
if (opt.text.contains("Middle"))
- QCOMPARE(posToString(opt.viewItemPosition), posToString(QStyleOptionViewItemV4::Middle));
+ QCOMPARE(posToString(opt.viewItemPosition), posToString(QStyleOptionViewItem::Middle));
if (opt.text.contains("End"))
- QCOMPARE(posToString(opt.viewItemPosition), posToString(QStyleOptionViewItemV4::End));
+ QCOMPARE(posToString(opt.viewItemPosition), posToString(QStyleOptionViewItem::End));
if (opt.text.contains("OnlyOne"))
- QCOMPARE(posToString(opt.viewItemPosition), posToString(QStyleOptionViewItemV4::OnlyOne));
+ QCOMPARE(posToString(opt.viewItemPosition), posToString(QStyleOptionViewItem::OnlyOne));
if (opt.text.contains("Checked"))
QCOMPARE(opt.checkState, Qt::Checked);
@@ -3657,7 +3655,7 @@ void tst_QTreeView::task202039_closePersistentEditor()
QVERIFY(view.indexWidget(current));
view.closePersistentEditor(current);
- QVERIFY(view.indexWidget(current) == 0);
+ QVERIFY(!view.indexWidget(current));
//here was the bug: closing the persistent editor would not reset the state
//and it was impossible to go into editinon again
@@ -4193,7 +4191,7 @@ void tst_QTreeView::taskQTBUG_25333_adjustViewOptionsForIndex()
#ifdef QT_BUILD_INTERNAL
{
- QStyleOptionViewItemV4 option;
+ QStyleOptionViewItem option;
view.aiv_priv()->adjustViewOptionsForIndex(&option, model.indexFromItem(item1));
@@ -4283,35 +4281,6 @@ void tst_QTreeView::taskQTBUG_8176_emitOnExpandAll()
QCOMPARE(spy2.size(), 1); // item2 is collapsed
}
-// From QTBUG_34717 (QTreeWidget crashes when scrolling to the end
-// of an expanded tree, then collapse all)
-// The test passes simply if it doesn't crash.
-void tst_QTreeView::taskQTBUG_34717_collapseAtBottom()
-{
- QTreeWidget treeWidget;
- treeWidget.header()->setSectionResizeMode(QHeaderView::ResizeToContents);
- treeWidget.setColumnCount(2);
- QTreeWidgetItem *mainItem = new QTreeWidgetItem(&treeWidget, QStringList() << "Root");
- for (int i = 0; i < 200; ++i) {
- QTreeWidgetItem *item = new QTreeWidgetItem(mainItem, QStringList(QString("Item")));
- new QTreeWidgetItem(item, QStringList() << "Child" << "1");
- new QTreeWidgetItem(item, QStringList() << "Child" << "2");
- new QTreeWidgetItem(item, QStringList() << "Child" << "3");
- }
- treeWidget.show();
- treeWidget.expandAll();
- treeWidget.scrollToBottom();
- treeWidget.collapseAll();
-
- treeWidget.setAnimated(true);
- treeWidget.expandAll();
- treeWidget.scrollToBottom();
- mainItem->setExpanded(false);
-
- PublicView *pview = (PublicView*) &treeWidget;
- QVERIFY(pview->sizeHintForColumn(1) >= 0);
-}
-
void tst_QTreeView::testInitialFocus()
{
QTreeWidget treeWidget;
diff --git a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
index 5c881369a0..117c53a2bb 100644
--- a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
+++ b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
@@ -161,6 +161,7 @@ private slots:
void taskQTBUG2844_visualItemRect();
void setChildIndicatorPolicy();
+ void taskQTBUG_34717_collapseAtBottom();
void task20345_sortChildren();
void getMimeDataWithInvalidItem();
@@ -1037,7 +1038,7 @@ void tst_QTreeWidget::checkState()
QCOMPARE(firstChild->checkState(0), Qt::Checked);
QCOMPARE(seccondChild->checkState(0), Qt::Unchecked);
- item->setFlags(item->flags()|Qt::ItemIsTristate);
+ item->setFlags(item->flags()|Qt::ItemIsAutoTristate);
QCOMPARE(item->checkState(0), Qt::PartiallyChecked);
QCOMPARE(firstChild->checkState(0), Qt::Checked);
QCOMPARE(seccondChild->checkState(0), Qt::Unchecked);
@@ -1586,7 +1587,7 @@ void tst_QTreeWidget::scrollToItem()
testWidget->setHeaderLabels(QStringList() << "foo");
testWidget->scrollToItem(search);
- QVERIFY(search->text(0) == "111");
+ QCOMPARE(search->text(0), QLatin1String("111"));
bar = search->parent();
QVERIFY(testWidget->isItemExpanded(bar));
@@ -2287,7 +2288,7 @@ void tst_QTreeWidget::insertExpandedItemsWithSorting()
QCOMPARE(parent->childCount(), childText.count());
QVERIFY(parent->isExpanded());
}
- QVERIFY(tree.model()->rowCount() == parentText.count());
+ QCOMPARE(tree.model()->rowCount(), parentText.count());
// verify that the items are still expanded
foreach (QTreeWidgetItem *item, items) {
@@ -2659,7 +2660,7 @@ void tst_QTreeWidget::sortedIndexOfChild()
tw.sortItems(0, (Qt::SortOrder)sortOrder);
tw.expandAll();
- QVERIFY(itms.count() == expectedIndexes.count());
+ QCOMPARE(itms.count(), expectedIndexes.count());
for (int j = 0; j < expectedIndexes.count(); ++j)
QCOMPARE(top->indexOfChild(itms.at(j)), expectedIndexes.at(j));
}
@@ -3155,11 +3156,11 @@ void tst_QTreeWidget::setSelectionModel()
void tst_QTreeWidget::task217309()
{
QTreeWidgetItem item;
- item.setFlags(item.flags() | Qt::ItemIsTristate);
+ item.setFlags(item.flags() | Qt::ItemIsAutoTristate);
QTreeWidgetItem subitem1;
- subitem1.setFlags(subitem1.flags() | Qt::ItemIsTristate);
+ subitem1.setFlags(subitem1.flags() | Qt::ItemIsAutoTristate);
QTreeWidgetItem subitem2;
- subitem2.setFlags(subitem2.flags() | Qt::ItemIsTristate);
+ subitem2.setFlags(subitem2.flags() | Qt::ItemIsAutoTristate);
item.addChild(&subitem1);
item.addChild(&subitem2);
subitem1.setCheckState(0, Qt::Checked);
@@ -3180,7 +3181,7 @@ void tst_QTreeWidget::nonEditableTristate()
QTreeWidget *tree = new QTreeWidget;
QTreeWidgetItem *item = new QTreeWidgetItem();
tree->insertTopLevelItem(0, item);
- item->setFlags(item->flags() | Qt::ItemIsTristate);
+ item->setFlags(item->flags() | Qt::ItemIsAutoTristate);
item->setCheckState(0, Qt::Unchecked);
QTreeWidgetItem *subitem1 = new QTreeWidgetItem(item);
subitem1->setCheckState(0, Qt::Unchecked);
@@ -3235,7 +3236,7 @@ void tst_QTreeWidget::setCurrentItemExpandsParent()
QTreeWidgetItem *i1 = new QTreeWidgetItem(&w, QStringList() << "parent");
QTreeWidgetItem *i2 = new QTreeWidgetItem(i1, QStringList() << "child");
QVERIFY(!i2->isExpanded());
- QVERIFY(w.currentItem() == 0);
+ QVERIFY(!w.currentItem());
w.setCurrentItem(i2);
QVERIFY(!i2->isExpanded());
QCOMPARE(w.currentItem(), i2);
@@ -3378,9 +3379,41 @@ void tst_QTreeWidget::setChildIndicatorPolicy()
QTRY_COMPARE(delegate.numPaints, 1);
}
+// From QTBUG_34717 (QTreeWidget crashes when scrolling to the end
+// of an expanded tree, then collapse all)
+// The test passes simply if it doesn't crash.
+void tst_QTreeWidget::taskQTBUG_34717_collapseAtBottom()
+{
+ struct PublicTreeWidget: public QTreeWidget
+ {
+ inline int sizeHintForColumn(int column) const { return QTreeWidget::sizeHintForColumn(column); }
+ };
+ PublicTreeWidget treeWidget;
+ treeWidget.header()->setSectionResizeMode(QHeaderView::ResizeToContents);
+ treeWidget.setColumnCount(2);
+ QTreeWidgetItem *mainItem = new QTreeWidgetItem(&treeWidget, QStringList() << "Root");
+ for (int i = 0; i < 200; ++i) {
+ QTreeWidgetItem *item = new QTreeWidgetItem(mainItem, QStringList(QString("Item")));
+ new QTreeWidgetItem(item, QStringList() << "Child" << "1");
+ new QTreeWidgetItem(item, QStringList() << "Child" << "2");
+ new QTreeWidgetItem(item, QStringList() << "Child" << "3");
+ }
+ treeWidget.show();
+ treeWidget.expandAll();
+ treeWidget.scrollToBottom();
+ treeWidget.collapseAll();
+
+ treeWidget.setAnimated(true);
+ treeWidget.expandAll();
+ treeWidget.scrollToBottom();
+ mainItem->setExpanded(false);
+
+ QVERIFY(treeWidget.sizeHintForColumn(1) >= 0);
+}
+
void tst_QTreeWidget::task20345_sortChildren()
{
- if (qApp->platformName().toLower() == QLatin1String("wayland"))
+ if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: This causes a crash triggered by setVisible(false)");
// This test case is considered successful if it is executed (no crash in sorting)
diff --git a/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp b/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp
index 490f87a7ef..c52198fa2c 100644
--- a/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp
+++ b/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp
@@ -1112,13 +1112,13 @@ void tst_QTreeWidgetItemIterator::updateIfModifiedFromWidget()
delete item;
item = *it;
if (expecteditemIsNull) {
- QVERIFY(item == 0);
+ QVERIFY(!item);
} else {
QVERIFY(item);
QCOMPARE(item->text(0), expecteditemvalue);
item = *itRemove;
if (expectedUpdatedCurrent.isNull()) {
- QVERIFY(item == 0);
+ QVERIFY(!item);
} else {
QCOMPARE(item->text(0), expectedUpdatedCurrent);
}
diff --git a/tests/auto/widgets/kernel/qaction/BLACKLIST b/tests/auto/widgets/kernel/qaction/BLACKLIST
index f67a3c471e..1ad524fdbf 100644
--- a/tests/auto/widgets/kernel/qaction/BLACKLIST
+++ b/tests/auto/widgets/kernel/qaction/BLACKLIST
@@ -1,2 +1,2 @@
[setStandardKeys]
-ubuntu-14.04
+linux
diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
index 897128d40e..71b55d71ea 100644
--- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
+++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
@@ -242,7 +242,7 @@ void tst_QAction::setStandardKeys()
QList<QKeySequence> list;
act.setShortcuts(list);
act.setShortcuts(QKeySequence::Copy);
- QVERIFY(act.shortcut() == act.shortcuts().first());
+ QCOMPARE(act.shortcut(), act.shortcuts().first());
QList<QKeySequence> expected;
const QKeySequence ctrlC = QKeySequence(QStringLiteral("CTRL+C"));
diff --git a/tests/auto/widgets/kernel/qactiongroup/BLACKLIST b/tests/auto/widgets/kernel/qactiongroup/BLACKLIST
new file mode 100644
index 0000000000..fdc424b6ac
--- /dev/null
+++ b/tests/auto/widgets/kernel/qactiongroup/BLACKLIST
@@ -0,0 +1,2 @@
+[QTBUG_14292_filesystem]
+linux
diff --git a/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp b/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp
index 8ce9941238..81e5542e91 100644
--- a/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp
+++ b/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp
@@ -42,6 +42,7 @@ class tst_QActionGroup : public QObject
Q_OBJECT
private slots:
+ void cleanup() { QVERIFY(QApplication::topLevelWidgets().isEmpty()); }
void enabledPropagation();
void visiblePropagation();
void exclusive();
@@ -223,7 +224,7 @@ void tst_QActionGroup::unCheckCurrentAction()
current->setChecked(false);
QVERIFY(!action1.isChecked());
QVERIFY(!action2.isChecked());
- QVERIFY(group.checkedAction() == 0);
+ QVERIFY(!group.checkedAction());
}
diff --git a/tests/auto/widgets/kernel/qapplication/BLACKLIST b/tests/auto/widgets/kernel/qapplication/BLACKLIST
new file mode 100644
index 0000000000..6abb1d9988
--- /dev/null
+++ b/tests/auto/widgets/kernel/qapplication/BLACKLIST
@@ -0,0 +1,4 @@
+[quitOnLastWindowClosed]
+osx-10.10
+[touchEventPropagation]
+xcb
diff --git a/tests/auto/widgets/kernel/qapplication/qapplication.pro b/tests/auto/widgets/kernel/qapplication/qapplication.pro
index 3d167827a3..21bfb50aee 100644
--- a/tests/auto/widgets/kernel/qapplication/qapplication.pro
+++ b/tests/auto/widgets/kernel/qapplication/qapplication.pro
@@ -1,7 +1,6 @@
TEMPLATE = subdirs
-SUBDIRS = desktopsettingsaware modal
+!winrt: SUBDIRS = desktopsettingsaware modal
-win32:!wince: SUBDIRS += wincmdline
test.depends += $$SUBDIRS
SUBDIRS += test
diff --git a/tests/auto/widgets/kernel/qapplication/test/BLACKLIST b/tests/auto/widgets/kernel/qapplication/test/BLACKLIST
new file mode 100644
index 0000000000..f4a9cb6166
--- /dev/null
+++ b/tests/auto/widgets/kernel/qapplication/test/BLACKLIST
@@ -0,0 +1,2 @@
+[quitOnLastWindowClosed]
+osx-10.10
diff --git a/tests/auto/widgets/kernel/qapplication/test/test.pro b/tests/auto/widgets/kernel/qapplication/test/test.pro
index b617c228ac..908aa846c0 100644
--- a/tests/auto/widgets/kernel/qapplication/test/test.pro
+++ b/tests/auto/widgets/kernel/qapplication/test/test.pro
@@ -9,7 +9,10 @@ TARGET = ../tst_qapplication
TESTDATA = ../test/test.pro ../tmp/README
-SUBPROGRAMS = desktopsettingsaware modal
-win32:!wince: SUBPROGRAMS += wincmdline
+!winrt {
+ SUBPROGRAMS = desktopsettingsaware modal
+ win32:!wince: SUBPROGRAMS += wincmdline
+
+ for(file, SUBPROGRAMS): TEST_HELPER_INSTALLS += "../$${file}/$${file}"
+}
-for(file, SUBPROGRAMS): TEST_HELPER_INSTALLS += "../$${file}/$${file}"
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index 84956d0a02..878136b4a0 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -62,6 +62,7 @@
#endif
#include <qpa/qwindowsysteminterface.h>
+#include <private/qhighdpiscaling_p.h>
#include "../../../qtest-config.h"
@@ -162,9 +163,6 @@ private slots:
void setAttribute();
- void windowsCommandLine_data();
- void windowsCommandLine();
-
void touchEventPropagation();
void qtbug_12673();
@@ -1160,7 +1158,7 @@ void tst_QApplication::sendPostedEvents()
QMetaObject::invokeMethod(&app, "quit", Qt::QueuedConnection);
QPointer<SendPostedEventsTester> p = tester;
(void) app.exec();
- QVERIFY(p == 0);
+ QVERIFY(p.isNull());
}
void tst_QApplication::thread()
@@ -1178,8 +1176,8 @@ void tst_QApplication::thread()
// *before* the QApplication has a thread
QObject object;
QObject child(&object);
- QVERIFY(object.thread() == currentThread);
- QVERIFY(child.thread() == currentThread);
+ QCOMPARE(object.thread(), currentThread);
+ QCOMPARE(child.thread(), currentThread);
{
int argc = 0;
@@ -1209,8 +1207,8 @@ void tst_QApplication::thread()
QVERIFY(!currentThread->isFinished());
// should still have a thread
- QVERIFY(object.thread() == currentThread);
- QVERIFY(child.thread() == currentThread);
+ QCOMPARE(object.thread(), currentThread);
+ QCOMPARE(child.thread(), currentThread);
// do the test again, making sure that the thread is the same as
// before
@@ -1231,8 +1229,8 @@ void tst_QApplication::thread()
QVERIFY(!currentThread->isFinished());
// should still have a thread
- QVERIFY(object.thread() == currentThread);
- QVERIFY(child.thread() == currentThread);
+ QCOMPARE(object.thread(), currentThread);
+ QCOMPARE(child.thread(), currentThread);
QTestEventLoop::instance().enterLoop(1);
}
@@ -1246,8 +1244,8 @@ void tst_QApplication::thread()
QVERIFY(!currentThread->isFinished());
// should still have a thread
- QVERIFY(object.thread() == currentThread);
- QVERIFY(child.thread() == currentThread);
+ QCOMPARE(object.thread(), currentThread);
+ QCOMPARE(child.thread(), currentThread);
}
class DeleteLaterWidget : public QWidget
@@ -1561,9 +1559,9 @@ void tst_QApplication::focusChanged()
QCOMPARE(spy.at(0).count(), 2);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &le1);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == 0);
+ QCOMPARE(now, &le1);
+ QCOMPARE(now, QApplication::focusWidget());
+ QVERIFY(!old);
spy.clear();
QCOMPARE(spy.count(), 0);
@@ -1571,27 +1569,27 @@ void tst_QApplication::focusChanged()
QCOMPARE(spy.count(), 1);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &pb1);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &le1);
+ QCOMPARE(now, &pb1);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &le1);
spy.clear();
lb1.setFocus();
QCOMPARE(spy.count(), 1);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &lb1);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &pb1);
+ QCOMPARE(now, &lb1);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &pb1);
spy.clear();
lb1.clearFocus();
QCOMPARE(spy.count(), 1);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == 0);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &lb1);
+ QVERIFY(!now);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &lb1);
spy.clear();
QWidget parent2;
@@ -1608,9 +1606,9 @@ void tst_QApplication::focusChanged()
QVERIFY(spy.count() > 0); // one for deactivation, one for activation on Windows
old = qvariant_cast<QWidget*>(spy.at(spy.count()-1).at(0));
now = qvariant_cast<QWidget*>(spy.at(spy.count()-1).at(1));
- QVERIFY(now == &le2);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == 0);
+ QCOMPARE(now, &le2);
+ QCOMPARE(now, QApplication::focusWidget());
+ QVERIFY(!old);
spy.clear();
QTestKeyEvent tab(QTest::Press, Qt::Key_Tab, 0, 0);
@@ -1632,82 +1630,82 @@ void tst_QApplication::focusChanged()
tab.simulate(now);
if (!tabAllControls) {
- QVERIFY(spy.count() == 0);
- QVERIFY(now == QApplication::focusWidget());
+ QCOMPARE(spy.count(), 0);
+ QCOMPARE(now, QApplication::focusWidget());
} else {
QVERIFY(spy.count() > 0);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &pb2);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &le2);
+ QCOMPARE(now, &pb2);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &le2);
spy.clear();
}
if (!tabAllControls) {
- QVERIFY(spy.count() == 0);
- QVERIFY(now == QApplication::focusWidget());
+ QCOMPARE(spy.count(), 0);
+ QCOMPARE(now, QApplication::focusWidget());
} else {
tab.simulate(now);
QVERIFY(spy.count() > 0);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &le2);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &pb2);
+ QCOMPARE(now, &le2);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &pb2);
spy.clear();
}
if (!tabAllControls) {
- QVERIFY(spy.count() == 0);
- QVERIFY(now == QApplication::focusWidget());
+ QCOMPARE(spy.count(), 0);
+ QCOMPARE(now, QApplication::focusWidget());
} else {
backtab.simulate(now);
QVERIFY(spy.count() > 0);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &pb2);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &le2);
+ QCOMPARE(now, &pb2);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &le2);
spy.clear();
}
if (!tabAllControls) {
- QVERIFY(spy.count() == 0);
- QVERIFY(now == QApplication::focusWidget());
+ QCOMPARE(spy.count(), 0);
+ QCOMPARE(now, QApplication::focusWidget());
old = &pb2;
} else {
backtab.simulate(now);
QVERIFY(spy.count() > 0);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &le2);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &pb2);
+ QCOMPARE(now, &le2);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &pb2);
spy.clear();
}
click.simulate(old);
if (!(pb2.focusPolicy() & Qt::ClickFocus)) {
- QVERIFY(spy.count() == 0);
- QVERIFY(now == QApplication::focusWidget());
+ QCOMPARE(spy.count(), 0);
+ QCOMPARE(now, QApplication::focusWidget());
} else {
QVERIFY(spy.count() > 0);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &pb2);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &le2);
+ QCOMPARE(now, &pb2);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &le2);
spy.clear();
click.simulate(old);
QVERIFY(spy.count() > 0);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &le2);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &pb2);
+ QCOMPARE(now, &le2);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &pb2);
spy.clear();
}
@@ -1722,9 +1720,9 @@ void tst_QApplication::focusChanged()
else
old = qvariant_cast<QWidget*>(spy.at(spy.count()-2).at(0));
now = qvariant_cast<QWidget*>(spy.at(spy.count()-1).at(1));
- QVERIFY(now == &le1);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &le2);
+ QCOMPARE(now, &le1);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &le2);
spy.clear();
}
@@ -1933,39 +1931,6 @@ void tst_QApplication::setAttribute()
delete w;
}
-void tst_QApplication::windowsCommandLine_data()
-{
-#if defined(Q_OS_WIN)
- QTest::addColumn<QString>("args");
- QTest::addColumn<QString>("expected");
-
- QTest::newRow("hello world")
- << QString("Hello \"World\"")
- << QString("Hello \"World\"");
- QTest::newRow("sql")
- << QString("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'PNR' AND TABLE_TYPE = 'VIEW' ORDER BY TABLE_NAME")
- << QString("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'PNR' AND TABLE_TYPE = 'VIEW' ORDER BY TABLE_NAME");
-#endif
-}
-
-void tst_QApplication::windowsCommandLine()
-{
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
- QFETCH(QString, args);
- QFETCH(QString, expected);
-
- QProcess testProcess;
- const QString path = QStringLiteral("wincmdline/wincmdline");
- testProcess.start(path, QStringList(args));
- QVERIFY2(testProcess.waitForStarted(),
- qPrintable(QString::fromLatin1("Cannot start '%1': %2").arg(path, testProcess.errorString())));
- QVERIFY(testProcess.waitForFinished(10000));
- QByteArray error = testProcess.readAllStandardError();
- QString procError(error);
- QCOMPARE(procError, expected);
-#endif
-}
-
class TouchEventPropagationTestWidget : public QWidget
{
Q_OBJECT
@@ -2038,8 +2003,10 @@ void tst_QApplication::touchEventPropagation()
QVERIFY(QTest::qWaitForWindowExposed(&window));
// QPA always takes screen positions and since we map the TouchPoint back to QPA's structure first,
// we must ensure there is a screen position in the TouchPoint that maps to a local 0, 0.
- pressedTouchPoints[0].setScreenPos(window.mapToGlobal(QPoint(0, 0)));
- releasedTouchPoints[0].setScreenPos(window.mapToGlobal(QPoint(0, 0)));
+ const QPoint deviceGlobalPos =
+ QHighDpi::toNativePixels(window.mapToGlobal(QPoint(0, 0)), window.windowHandle()->screen());
+ pressedTouchPoints[0].setScreenPos(deviceGlobalPos);
+ releasedTouchPoints[0].setScreenPos(deviceGlobalPos);
QWindowSystemInterface::handleTouchEvent(window.windowHandle(),
0,
@@ -2092,8 +2059,10 @@ void tst_QApplication::touchEventPropagation()
widget.setObjectName("2. widget");
window.show();
QVERIFY(QTest::qWaitForWindowExposed(&window));
- pressedTouchPoints[0].setScreenPos(window.mapToGlobal(QPoint(50, 50)));
- releasedTouchPoints[0].setScreenPos(window.mapToGlobal(QPoint(50, 50)));
+ const QPoint deviceGlobalPos =
+ QHighDpi::toNativePixels(window.mapToGlobal(QPoint(50, 50)), window.windowHandle()->screen());
+ pressedTouchPoints[0].setScreenPos(deviceGlobalPos);
+ releasedTouchPoints[0].setScreenPos(deviceGlobalPos);
QWindowSystemInterface::handleTouchEvent(window.windowHandle(),
0,
diff --git a/tests/auto/widgets/kernel/qapplication/wincmdline/main.cpp b/tests/auto/widgets/kernel/qapplication/wincmdline/main.cpp
deleted file mode 100644
index 2d86b46875..0000000000
--- a/tests/auto/widgets/kernel/qapplication/wincmdline/main.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QApplication>
-#include <stdio.h>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- if (argc > 1)
- fprintf(stderr, "%s", argv[1]);
- else
- fprintf(stderr, "Failed");
- fflush(stderr);
- return 0;
-}
-
diff --git a/tests/auto/widgets/kernel/qapplication/wincmdline/wincmdline.pro b/tests/auto/widgets/kernel/qapplication/wincmdline/wincmdline.pro
deleted file mode 100644
index 3e32a6798d..0000000000
--- a/tests/auto/widgets/kernel/qapplication/wincmdline/wincmdline.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-QT += widgets
-CONFIG -= app_bundle debug_and_release_target
-SOURCES += main.cpp
-DESTDIR = ./
-
diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
index 35a8636f0b..aeaf1e7bf0 100644
--- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
+++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
@@ -48,17 +48,8 @@ class tst_QBoxLayout : public QObject
{
Q_OBJECT
-public:
- tst_QBoxLayout();
- virtual ~tst_QBoxLayout();
-
-public slots:
- void initTestCase();
- void cleanupTestCase();
- void init();
- void cleanup();
-
private slots:
+ void cleanup();
void insertSpacerItem();
void insertLayout();
void sizeHint();
@@ -120,34 +111,15 @@ int CustomLayoutStyle::pixelMetric(PixelMetric metric, const QStyleOption * opti
return QProxyStyle::pixelMetric(metric, option, widget);
}
-
-tst_QBoxLayout::tst_QBoxLayout()
-{
-}
-
-tst_QBoxLayout::~tst_QBoxLayout()
-{
-}
-
-void tst_QBoxLayout::initTestCase()
-{
-}
-
-void tst_QBoxLayout::cleanupTestCase()
-{
-}
-
-void tst_QBoxLayout::init()
-{
-}
-
void tst_QBoxLayout::cleanup()
{
+ QVERIFY(QApplication::topLevelWidgets().isEmpty());
}
void tst_QBoxLayout::insertSpacerItem()
{
- QWidget *window = new QWidget;
+ QWidget window;
+ window.setWindowTitle(QTest::currentTestFunction());
QSpacerItem *spacer1 = new QSpacerItem(20, 10, QSizePolicy::Expanding, QSizePolicy::Expanding);
QSpacerItem *spacer2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Expanding);
@@ -157,44 +129,43 @@ void tst_QBoxLayout::insertSpacerItem()
layout->addSpacerItem(spacer1);
layout->addWidget(new QLineEdit("Baaaaaaaaaaaaaaaaaaaaaaaaar"));
layout->insertSpacerItem(0, spacer2);
- window->setLayout(layout);
+ window.setLayout(layout);
- QVERIFY(layout->itemAt(0) == spacer2);
- QVERIFY(layout->itemAt(2) == spacer1);
+ QCOMPARE(layout->itemAt(0), spacer2);
+ QCOMPARE(layout->itemAt(2), spacer1);
- window->show();
+ window.show();
}
void tst_QBoxLayout::insertLayout()
{
- QWidget *window = new QWidget;
- QVBoxLayout *vbox = new QVBoxLayout(window);
- QVBoxLayout *dummyParentLayout = new QVBoxLayout;
+ QWidget window;
+ QVBoxLayout *vbox = new QVBoxLayout(&window);
+ QScopedPointer<QVBoxLayout> dummyParentLayout(new QVBoxLayout);
QHBoxLayout *subLayout = new QHBoxLayout;
dummyParentLayout->addLayout(subLayout);
- QCOMPARE(subLayout->parent(), dummyParentLayout);
+ QCOMPARE(subLayout->parent(), dummyParentLayout.data());
QCOMPARE(dummyParentLayout->count(), 1);
// add subLayout to another layout
QTest::ignoreMessage(QtWarningMsg, "QLayout::addChildLayout: layout \"\" already has a parent");
vbox->addLayout(subLayout);
QCOMPARE((subLayout->parent() == vbox), (vbox->count() == 1));
-
- delete dummyParentLayout;
- delete window;
}
void tst_QBoxLayout::sizeHint()
{
- QWidget *window = new QWidget;
+ QWidget window;
+ window.setWindowTitle(QTest::currentTestFunction());
QHBoxLayout *lay1 = new QHBoxLayout;
QHBoxLayout *lay2 = new QHBoxLayout;
QLabel *label = new QLabel("widget twooooooooooooooooooooooooooooooooooooooooooooooooooooooo");
lay2->addWidget(label);
lay1->addLayout(lay2);
- window->setLayout(lay1);
- window->show();
+ window.setLayout(lay1);
+ window.show();
+ QTest::qWaitForWindowExposed(&window);
label->setText("foooooooo baaaaaaar");
QSize sh = lay1->sizeHint();
QApplication::processEvents();
@@ -207,24 +178,26 @@ void tst_QBoxLayout::sizeHint()
void tst_QBoxLayout::sizeConstraints()
{
- QWidget *window = new QWidget;
+ QWidget window;
+ window.setWindowTitle(QTest::currentTestFunction());
QHBoxLayout *lay = new QHBoxLayout;
lay->addWidget(new QLabel("foooooooooooooooooooooooooooooooooooo"));
lay->addWidget(new QLabel("baaaaaaaaaaaaaaaaaaaaaaaaaaaaaar"));
lay->setSizeConstraint(QLayout::SetFixedSize);
- window->setLayout(lay);
- window->show();
- QApplication::processEvents();
- QSize sh = window->sizeHint();
+ window.setLayout(lay);
+ window.show();
+ QTest::qWaitForWindowExposed(&window);
+ QSize sh = window.sizeHint();
lay->takeAt(1);
- QVERIFY(sh.width() >= window->sizeHint().width() &&
- sh.height() >= window->sizeHint().height());
+ QVERIFY(sh.width() >= window.sizeHint().width() &&
+ sh.height() >= window.sizeHint().height());
}
void tst_QBoxLayout::setGeometry()
{
QWidget toplevel;
+ toplevel.setWindowTitle(QTest::currentTestFunction());
setFrameless(&toplevel);
QWidget w(&toplevel);
QVBoxLayout *lay = new QVBoxLayout;
@@ -247,33 +220,30 @@ void tst_QBoxLayout::setGeometry()
void tst_QBoxLayout::setStyleShouldChangeSpacing()
{
- QWidget *window = new QWidget;
- QHBoxLayout *hbox = new QHBoxLayout(window);
+ QWidget window;
+ window.setWindowTitle(QTest::currentTestFunction());
+ QHBoxLayout *hbox = new QHBoxLayout(&window);
QPushButton *pb1 = new QPushButton(tr("The spacing between this"));
QPushButton *pb2 = new QPushButton(tr("and this button should depend on the style of the parent widget"));;
pb1->setAttribute(Qt::WA_LayoutUsesWidgetRect);
pb2->setAttribute(Qt::WA_LayoutUsesWidgetRect);
hbox->addWidget(pb1);
hbox->addWidget(pb2);
- CustomLayoutStyle *style1 = new CustomLayoutStyle;
+ QScopedPointer<CustomLayoutStyle> style1(new CustomLayoutStyle);
style1->hspacing = 6;
- window->setStyle(style1);
- window->show();
+ window.setStyle(style1.data());
+ window.show();
+ QTest::qWaitForWindowExposed(&window);
- QTest::qWait(100);
int spacing = pb2->geometry().left() - pb1->geometry().right() - 1;
QCOMPARE(spacing, 6);
- CustomLayoutStyle *style2 = new CustomLayoutStyle();
+ QScopedPointer<CustomLayoutStyle> style2(new CustomLayoutStyle());
style2->hspacing = 10;
- window->setStyle(style2);
+ window.setStyle(style2.data());
QTest::qWait(100);
spacing = pb2->geometry().left() - pb1->geometry().right() - 1;
QCOMPARE(spacing, 10);
-
- delete window;
- delete style1;
- delete style2;
}
void tst_QBoxLayout::taskQTBUG_7103_minMaxWidthNotRespected()
@@ -287,6 +257,7 @@ void tst_QBoxLayout::taskQTBUG_7103_minMaxWidthNotRespected()
layout->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Fixed, QSizePolicy::Expanding));
QWidget widget;
+ widget.setWindowTitle(QTest::currentTestFunction());
widget.setLayout(layout);
widget.show();
QVERIFY(QTest::qWaitForWindowExposed(&widget));
@@ -325,6 +296,7 @@ void tst_QBoxLayout::taskQTBUG_27420_takeAtShouldUnparentLayout()
void tst_QBoxLayout::taskQTBUG_40609_addingWidgetToItsOwnLayout(){
QWidget widget;
+ widget.setWindowTitle(QTest::currentTestFunction());
widget.setObjectName("347b469225a24a0ef05150a");
QVBoxLayout layout(&widget);
layout.setObjectName("ef9e2b42298e0e6420105bb");
@@ -340,6 +312,7 @@ void tst_QBoxLayout::taskQTBUG_40609_addingWidgetToItsOwnLayout(){
void tst_QBoxLayout::taskQTBUG_40609_addingLayoutToItself(){
QWidget widget;
+ widget.setWindowTitle(QTest::currentTestFunction());
widget.setObjectName("fe44e5cb6c08006597126a");
QVBoxLayout layout(&widget);
layout.setObjectName("cc751dd0f50f62b05a62da");
diff --git a/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp b/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp
index b717c1deb1..e94dfa5754 100644
--- a/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp
+++ b/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp
@@ -73,6 +73,7 @@ void tst_QDesktopWidget::init()
void tst_QDesktopWidget::cleanup()
{
+ QVERIFY(QApplication::topLevelWidgets().isEmpty());
}
void tst_QDesktopWidget::numScreens()
diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
index 8588df7afa..e1b494c9f1 100644
--- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
+++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
@@ -60,17 +60,8 @@ class tst_QFormLayout : public QObject
{
Q_OBJECT
-public:
- tst_QFormLayout();
- ~tst_QFormLayout();
-
-public slots:
- void initTestCase();
- void cleanupTestCase();
- void init();
- void cleanup();
-
private slots:
+ void cleanup();
void rowCount();
void buddies();
void getItemPosition();
@@ -132,34 +123,15 @@ private slots:
};
-tst_QFormLayout::tst_QFormLayout()
-{
-}
-
-tst_QFormLayout::~tst_QFormLayout()
-{
-}
-
-void tst_QFormLayout::initTestCase()
-{
-}
-
-void tst_QFormLayout::cleanupTestCase()
-{
-}
-
-void tst_QFormLayout::init()
-{
-}
-
void tst_QFormLayout::cleanup()
{
+ QVERIFY(QApplication::topLevelWidgets().isEmpty());
}
void tst_QFormLayout::rowCount()
{
- QWidget *w = new QWidget;
- QFormLayout *fl = new QFormLayout(w);
+ QWidget w;
+ QFormLayout *fl = new QFormLayout(&w);
fl->addRow(tr("Label 1"), new QLineEdit);
fl->addRow(tr("Label 2"), new QLineEdit);
@@ -174,14 +146,12 @@ void tst_QFormLayout::rowCount()
QCOMPARE(fl->rowCount(), 6);
//TODO: remove items
-
- delete w;
}
void tst_QFormLayout::buddies()
{
- QWidget *w = new QWidget;
- QFormLayout *fl = new QFormLayout(w);
+ QWidget w;
+ QFormLayout *fl = new QFormLayout(&w);
//normal buddy case
QLineEdit *le = new QLineEdit;
@@ -195,23 +165,21 @@ void tst_QFormLayout::buddies()
QLineEdit *le2 = new QLineEdit;
fl->addRow(0, le2);
QWidget *label2 = fl->labelForField(le2);
- QVERIFY(label2 == 0);
+ QVERIFY(!label2);
//no label
QLineEdit *le3 = new QLineEdit;
fl->addRow(le3);
QWidget *label3 = fl->labelForField(le3);
- QVERIFY(label3 == 0);
+ QVERIFY(!label3);
//TODO: empty label?
-
- delete w;
}
void tst_QFormLayout::getItemPosition()
{
- QWidget *w = new QWidget;
- QFormLayout *fl = new QFormLayout(w);
+ QWidget w;
+ QFormLayout *fl = new QFormLayout(&w);
QList<QLabel*> labels;
QList<QLineEdit*> fields;
@@ -249,14 +217,12 @@ void tst_QFormLayout::getItemPosition()
QCOMPARE(row, 2);
QCOMPARE(role, QFormLayout::FieldRole);
}
-
- delete w;
}
void tst_QFormLayout::wrapping()
{
- QWidget *w = new QWidget;
- QFormLayout *fl = new QFormLayout(w);
+ QWidget w;
+ QFormLayout *fl = new QFormLayout(&w);
fl->setRowWrapPolicy(QFormLayout::WrapLongRows);
QLineEdit *le = new QLineEdit;
@@ -264,14 +230,13 @@ void tst_QFormLayout::wrapping()
le->setMinimumWidth(200);
fl->addRow(lbl, le);
- w->setFixedWidth(240);
- w->show();
+ w.setFixedWidth(240);
+ w.setWindowTitle(QTest::currentTestFunction());
+ w.show();
QCOMPARE(le->geometry().y() > lbl->geometry().y(), true);
//TODO: additional tests covering different wrapping cases
-
- delete w;
}
class CustomLayoutStyle : public QProxyStyle
@@ -309,12 +274,12 @@ int CustomLayoutStyle::pixelMetric(PixelMetric metric, const QStyleOption * opti
void tst_QFormLayout::spacing()
{
//TODO: confirm spacing behavior
- QWidget *w = new QWidget;
- CustomLayoutStyle *style = new CustomLayoutStyle;
+ QWidget w;
+ QScopedPointer<CustomLayoutStyle> style(new CustomLayoutStyle);
style->hspacing = 5;
style->vspacing = 10;
- w->setStyle(style);
- QFormLayout *fl = new QFormLayout(w);
+ w.setStyle(style.data());
+ QFormLayout *fl = new QFormLayout(&w);
QCOMPARE(style->hspacing, fl->horizontalSpacing());
QCOMPARE(style->vspacing, fl->verticalSpacing());
@@ -351,12 +316,10 @@ void tst_QFormLayout::spacing()
QCheckBox *checkBox = new QCheckBox(tr("Yes"));
fl->setWidget(0, QFormLayout::LabelRole, label);
fl->setWidget(1, QFormLayout::FieldRole, checkBox);
- w->resize(200, 100);
- w->show();
- QVERIFY(QTest::qWaitForWindowExposed(w));
-
- delete w;
- delete style;
+ w.resize(200, 100);
+ w.setWindowTitle(QTest::currentTestFunction());
+ w.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&w));
}
void tst_QFormLayout::contentsRect()
@@ -366,6 +329,7 @@ void tst_QFormLayout::contentsRect()
QFormLayout form;
w.setLayout(&form);
form.addRow("Label", new QPushButton(&w));
+ w.setWindowTitle(QTest::currentTestFunction());
w.show();
QVERIFY(QTest::qWaitForWindowExposed(&w));
int l, t, r, b;
@@ -425,18 +389,18 @@ void tst_QFormLayout::setFormStyle()
#if 0 // QT_NO_STYLE_PLASTIQUE
widget.setStyle(new QPlastiqueStyle());
- QVERIFY(layout.labelAlignment() == Qt::AlignRight);
+ QCOMPARE(layout.labelAlignment(), Qt::AlignRight);
QVERIFY(layout.formAlignment() == (Qt::AlignLeft | Qt::AlignTop));
- QVERIFY(layout.fieldGrowthPolicy() == QFormLayout::ExpandingFieldsGrow);
- QVERIFY(layout.rowWrapPolicy() == QFormLayout::DontWrapRows);
+ QCOMPARE(layout.fieldGrowthPolicy(), QFormLayout::ExpandingFieldsGrow);
+ QCOMPARE(layout.rowWrapPolicy(), QFormLayout::DontWrapRows);
#endif
widget.setStyle(QStyleFactory::create("windows"));
- QVERIFY(layout.labelAlignment() == Qt::AlignLeft);
+ QCOMPARE(layout.labelAlignment(), Qt::AlignLeft);
QVERIFY(layout.formAlignment() == (Qt::AlignLeft | Qt::AlignTop));
- QVERIFY(layout.fieldGrowthPolicy() == QFormLayout::AllNonFixedFieldsGrow);
- QVERIFY(layout.rowWrapPolicy() == QFormLayout::DontWrapRows);
+ QCOMPARE(layout.fieldGrowthPolicy(), QFormLayout::AllNonFixedFieldsGrow);
+ QCOMPARE(layout.rowWrapPolicy(), QFormLayout::DontWrapRows);
/* can't directly create mac style or qtopia style, since
this test is cross platform.. so create dummy styles that
@@ -444,17 +408,17 @@ void tst_QFormLayout::setFormStyle()
*/
widget.setStyle(new DummyMacStyle());
- QVERIFY(layout.labelAlignment() == Qt::AlignRight);
+ QCOMPARE(layout.labelAlignment(), Qt::AlignRight);
QVERIFY(layout.formAlignment() == (Qt::AlignHCenter | Qt::AlignTop));
- QVERIFY(layout.fieldGrowthPolicy() == QFormLayout::FieldsStayAtSizeHint);
- QVERIFY(layout.rowWrapPolicy() == QFormLayout::DontWrapRows);
+ QCOMPARE(layout.fieldGrowthPolicy(), QFormLayout::FieldsStayAtSizeHint);
+ QCOMPARE(layout.rowWrapPolicy(), QFormLayout::DontWrapRows);
widget.setStyle(new DummyQtopiaStyle());
- QVERIFY(layout.labelAlignment() == Qt::AlignRight);
+ QCOMPARE(layout.labelAlignment(), Qt::AlignRight);
QVERIFY(layout.formAlignment() == (Qt::AlignLeft | Qt::AlignTop));
- QVERIFY(layout.fieldGrowthPolicy() == QFormLayout::AllNonFixedFieldsGrow);
- QVERIFY(layout.rowWrapPolicy() == QFormLayout::WrapLongRows);
+ QCOMPARE(layout.fieldGrowthPolicy(), QFormLayout::AllNonFixedFieldsGrow);
+ QCOMPARE(layout.rowWrapPolicy(), QFormLayout::WrapLongRows);
}
void tst_QFormLayout::setFieldGrowthPolicy()
@@ -479,14 +443,14 @@ void tst_QFormLayout::setFieldGrowthPolicy()
layout.activate();
if (i == 0) {
- QVERIFY(fld1.width() == fld2.width());
- QVERIFY(fld2.width() == fld3.width());
+ QCOMPARE(fld1.width(), fld2.width());
+ QCOMPARE(fld2.width(), fld3.width());
} else if (i == 1) {
- QVERIFY(fld1.width() == fld2.width());
+ QCOMPARE(fld1.width(), fld2.width());
QVERIFY(fld2.width() < fld3.width());
} else {
QVERIFY(fld1.width() < fld2.width());
- QVERIFY(fld2.width() == fld3.width());
+ QCOMPARE(fld2.width(), fld3.width());
}
}
}
@@ -505,33 +469,39 @@ void tst_QFormLayout::setFormAlignment()
void tst_QFormLayout::addRow()
{
- QFormLayout layout;
- QWidget w1, w2, w3;
- QHBoxLayout l1, l2, l3;
- QLabel lbl1, lbl2;
-
- QCOMPARE(layout.rowCount(), 0);
-
- layout.addRow(&lbl1, &w1);
- layout.addRow(&lbl2, &l1);
- layout.addRow("Foo:", &w2);
- layout.addRow("Bar:", &l2);
- layout.addRow(&w3);
- layout.addRow(&l3);
-
- QCOMPARE(layout.rowCount(), 6);
-
- QVERIFY(layout.itemAt(0, QFormLayout::LabelRole)->widget() == &lbl1);
- QVERIFY(layout.itemAt(1, QFormLayout::LabelRole)->widget() == &lbl2);
- QVERIFY(layout.itemAt(2, QFormLayout::LabelRole)->widget()->property("text") == "Foo:");
- QVERIFY(layout.itemAt(3, QFormLayout::LabelRole)->widget()->property("text") == "Bar:");
- QVERIFY(layout.itemAt(4, QFormLayout::LabelRole) == 0);
- QVERIFY(layout.itemAt(5, QFormLayout::LabelRole) == 0);
-
- QVERIFY(layout.itemAt(0, QFormLayout::FieldRole)->widget() == &w1);
- QVERIFY(layout.itemAt(1, QFormLayout::FieldRole)->layout() == &l1);
- QVERIFY(layout.itemAt(2, QFormLayout::FieldRole)->widget() == &w2);
- QVERIFY(layout.itemAt(3, QFormLayout::FieldRole)->layout() == &l2);
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
+ QWidget *w1 = new QWidget(&topLevel);
+ QWidget *w2 = new QWidget(&topLevel);
+ QWidget *w3 = new QWidget(&topLevel);
+ QHBoxLayout *l1 = new QHBoxLayout;
+ QHBoxLayout *l2 = new QHBoxLayout;
+ QHBoxLayout *l3 = new QHBoxLayout;
+ QLabel *lbl1 = new QLabel(&topLevel);
+ QLabel *lbl2 = new QLabel(&topLevel);
+
+ QCOMPARE(layout->rowCount(), 0);
+
+ layout->addRow(lbl1, w1);
+ layout->addRow(lbl2, l1);
+ layout->addRow("Foo:", w2);
+ layout->addRow("Bar:", l2);
+ layout->addRow(w3);
+ layout->addRow(l3);
+
+ QCOMPARE(layout->rowCount(), 6);
+
+ QVERIFY(layout->itemAt(0, QFormLayout::LabelRole)->widget() == lbl1);
+ QVERIFY(layout->itemAt(1, QFormLayout::LabelRole)->widget() == lbl2);
+ QVERIFY(layout->itemAt(2, QFormLayout::LabelRole)->widget()->property("text") == "Foo:");
+ QVERIFY(layout->itemAt(3, QFormLayout::LabelRole)->widget()->property("text") == "Bar:");
+ QVERIFY(layout->itemAt(4, QFormLayout::LabelRole) == 0);
+ QVERIFY(layout->itemAt(5, QFormLayout::LabelRole) == 0);
+
+ QVERIFY(layout->itemAt(0, QFormLayout::FieldRole)->widget() == w1);
+ QVERIFY(layout->itemAt(1, QFormLayout::FieldRole)->layout() == l1);
+ QVERIFY(layout->itemAt(2, QFormLayout::FieldRole)->widget() == w2);
+ QVERIFY(layout->itemAt(3, QFormLayout::FieldRole)->layout() == l2);
// ### should have a third role, FullRowRole?
// QVERIFY(layout.itemAt(4, QFormLayout::FieldRole) == 0);
// QVERIFY(layout.itemAt(5, QFormLayout::FieldRole) == 0);
@@ -539,17 +509,24 @@ void tst_QFormLayout::addRow()
void tst_QFormLayout::insertRow_QWidget_QWidget()
{
- QFormLayout layout;
- QLabel lbl1, lbl2, lbl3, lbl4;
- QLineEdit fld1, fld2, fld3, fld4;
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
+ QLabel *lbl1 = new QLabel(&topLevel);
+ QLabel *lbl2 = new QLabel(&topLevel);
+ QLabel *lbl3 = new QLabel(&topLevel);
+ QLabel *lbl4 = new QLabel(&topLevel);
+ QLineEdit *fld1 = new QLineEdit(&topLevel);
+ QLineEdit *fld2 = new QLineEdit(&topLevel);
+ QLineEdit *fld3 = new QLineEdit(&topLevel);
+ QLineEdit *fld4 = new QLineEdit(&topLevel);
- layout.insertRow(0, &lbl1, &fld1);
- QCOMPARE(layout.rowCount(), 1);
+ layout->insertRow(0, lbl1, fld1);
+ QCOMPARE(layout->rowCount(), 1);
{
int row = -1;
QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
- layout.getWidgetPosition(&lbl1, &row, &role);
+ layout->getWidgetPosition(lbl1, &row, &role);
QCOMPARE(row, 0);
QCOMPARE(int(role), int(QFormLayout::LabelRole));
}
@@ -557,63 +534,68 @@ void tst_QFormLayout::insertRow_QWidget_QWidget()
{
int row = -1;
QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
- layout.getWidgetPosition(&fld1, &row, &role);
+ layout->getWidgetPosition(fld1, &row, &role);
QCOMPARE(row, 0);
QCOMPARE(int(role), int(QFormLayout::FieldRole));
}
// check that negative values append
- layout.insertRow(-2, &lbl2, &fld2);
- QCOMPARE(layout.rowCount(), 2);
+ layout->insertRow(-2, lbl2, fld2);
+ QCOMPARE(layout->rowCount(), 2);
- QVERIFY(layout.itemAt(0, QFormLayout::LabelRole)->widget() == &lbl1);
- QVERIFY(layout.itemAt(1, QFormLayout::LabelRole)->widget() == &lbl2);
+ QVERIFY(layout->itemAt(0, QFormLayout::LabelRole)->widget() == lbl1);
+ QVERIFY(layout->itemAt(1, QFormLayout::LabelRole)->widget() == lbl2);
// check that too large values append
- layout.insertRow(100, &lbl3, &fld3);
- QCOMPARE(layout.rowCount(), 3);
- QCOMPARE(layout.count(), 6);
+ layout->insertRow(100, lbl3, fld3);
+ QCOMPARE(layout->rowCount(), 3);
+ QCOMPARE(layout->count(), 6);
- layout.insertRow(3, (QWidget *)0, (QWidget *)0);
- QCOMPARE(layout.rowCount(), 4);
- QCOMPARE(layout.count(), 6);
+ layout->insertRow(3, (QWidget *)0, (QWidget *)0);
+ QCOMPARE(layout->rowCount(), 4);
+ QCOMPARE(layout->count(), 6);
- layout.insertRow(4, (QWidget *)0, &fld4);
- QCOMPARE(layout.rowCount(), 5);
- QCOMPARE(layout.count(), 7);
+ layout->insertRow(4, (QWidget *)0, fld4);
+ QCOMPARE(layout->rowCount(), 5);
+ QCOMPARE(layout->count(), 7);
- layout.insertRow(5, &lbl4, (QWidget *)0);
- QCOMPARE(layout.rowCount(), 6);
- QCOMPARE(layout.count(), 8);
-
- QVERIFY(layout.itemAt(0, QFormLayout::LabelRole)->widget() == &lbl1);
- QVERIFY(layout.itemAt(1, QFormLayout::LabelRole)->widget() == &lbl2);
- QVERIFY(layout.itemAt(2, QFormLayout::LabelRole)->widget() == &lbl3);
- QVERIFY(layout.itemAt(3, QFormLayout::LabelRole) == 0);
- QVERIFY(layout.itemAt(4, QFormLayout::LabelRole) == 0);
- QVERIFY(layout.itemAt(5, QFormLayout::LabelRole)->widget() == &lbl4);
-
- QVERIFY(layout.itemAt(0, QFormLayout::FieldRole)->widget() == &fld1);
- QVERIFY(layout.itemAt(1, QFormLayout::FieldRole)->widget() == &fld2);
- QVERIFY(layout.itemAt(2, QFormLayout::FieldRole)->widget() == &fld3);
- QVERIFY(layout.itemAt(3, QFormLayout::FieldRole) == 0);
- QVERIFY(layout.itemAt(4, QFormLayout::FieldRole)->widget() == &fld4);
- QVERIFY(layout.itemAt(5, QFormLayout::FieldRole) == 0);
+ layout->insertRow(5, lbl4, (QWidget *)0);
+ QCOMPARE(layout->rowCount(), 6);
+ QCOMPARE(layout->count(), 8);
+
+ QVERIFY(layout->itemAt(0, QFormLayout::LabelRole)->widget() == lbl1);
+ QVERIFY(layout->itemAt(1, QFormLayout::LabelRole)->widget() == lbl2);
+ QVERIFY(layout->itemAt(2, QFormLayout::LabelRole)->widget() == lbl3);
+ QVERIFY(layout->itemAt(3, QFormLayout::LabelRole) == 0);
+ QVERIFY(layout->itemAt(4, QFormLayout::LabelRole) == 0);
+ QVERIFY(layout->itemAt(5, QFormLayout::LabelRole)->widget() == lbl4);
+
+ QVERIFY(layout->itemAt(0, QFormLayout::FieldRole)->widget() == fld1);
+ QVERIFY(layout->itemAt(1, QFormLayout::FieldRole)->widget() == fld2);
+ QVERIFY(layout->itemAt(2, QFormLayout::FieldRole)->widget() == fld3);
+ QVERIFY(layout->itemAt(3, QFormLayout::FieldRole) == 0);
+ QVERIFY(layout->itemAt(4, QFormLayout::FieldRole)->widget() == fld4);
+ QVERIFY(layout->itemAt(5, QFormLayout::FieldRole) == 0);
}
void tst_QFormLayout::insertRow_QWidget_QLayout()
{
- QFormLayout layout;
- QLabel lbl1, lbl2, lbl3, lbl4;
- QHBoxLayout fld1, fld2, fld3, fld4;
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
+ QLabel *lbl1 = new QLabel(&topLevel);
+ QLabel *lbl2 = new QLabel(&topLevel);
+ QLabel *lbl3 = new QLabel(&topLevel);
+ QHBoxLayout *fld1 = new QHBoxLayout;
+ QHBoxLayout *fld2 = new QHBoxLayout;
+ QHBoxLayout *fld3 = new QHBoxLayout;
- layout.insertRow(0, &lbl1, &fld1);
- QCOMPARE(layout.rowCount(), 1);
+ layout->insertRow(0, lbl1, fld1);
+ QCOMPARE(layout->rowCount(), 1);
{
int row = -1;
QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
- layout.getWidgetPosition(&lbl1, &row, &role);
+ layout->getWidgetPosition(lbl1, &row, &role);
QCOMPARE(row, 0);
QCOMPARE(int(role), int(QFormLayout::LabelRole));
}
@@ -621,77 +603,83 @@ void tst_QFormLayout::insertRow_QWidget_QLayout()
{
int row = -1;
QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
- layout.getLayoutPosition(&fld1, &row, &role);
+ layout->getLayoutPosition(fld1, &row, &role);
QCOMPARE(row, 0);
QCOMPARE(int(role), int(QFormLayout::FieldRole));
}
// check that negative values append
- layout.insertRow(-2, &lbl2, &fld2);
- QCOMPARE(layout.rowCount(), 2);
+ layout->insertRow(-2, lbl2, fld2);
+ QCOMPARE(layout->rowCount(), 2);
- QVERIFY(layout.itemAt(0, QFormLayout::LabelRole)->widget() == &lbl1);
- QVERIFY(layout.itemAt(1, QFormLayout::LabelRole)->widget() == &lbl2);
+ QVERIFY(layout->itemAt(0, QFormLayout::LabelRole)->widget() == lbl1);
+ QVERIFY(layout->itemAt(1, QFormLayout::LabelRole)->widget() == lbl2);
// check that too large values append
- layout.insertRow(100, &lbl3, &fld3);
- QCOMPARE(layout.rowCount(), 3);
+ layout->insertRow(100, lbl3, fld3);
+ QCOMPARE(layout->rowCount(), 3);
- QVERIFY(layout.itemAt(0, QFormLayout::LabelRole)->widget() == &lbl1);
- QVERIFY(layout.itemAt(1, QFormLayout::LabelRole)->widget() == &lbl2);
- QVERIFY(layout.itemAt(2, QFormLayout::LabelRole)->widget() == &lbl3);
+ QVERIFY(layout->itemAt(0, QFormLayout::LabelRole)->widget() == lbl1);
+ QVERIFY(layout->itemAt(1, QFormLayout::LabelRole)->widget() == lbl2);
+ QVERIFY(layout->itemAt(2, QFormLayout::LabelRole)->widget() == lbl3);
- QVERIFY(layout.itemAt(0, QFormLayout::FieldRole)->layout() == &fld1);
- QVERIFY(layout.itemAt(1, QFormLayout::FieldRole)->layout() == &fld2);
- QVERIFY(layout.itemAt(2, QFormLayout::FieldRole)->layout() == &fld3);
+ QVERIFY(layout->itemAt(0, QFormLayout::FieldRole)->layout() == fld1);
+ QVERIFY(layout->itemAt(1, QFormLayout::FieldRole)->layout() == fld2);
+ QVERIFY(layout->itemAt(2, QFormLayout::FieldRole)->layout() == fld3);
}
void tst_QFormLayout::insertRow_QString_QWidget()
{
- QFormLayout layout;
- QLineEdit fld1, fld2, fld3;
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
+ QLineEdit *fld1 = new QLineEdit(&topLevel);
+ QLineEdit *fld2 = new QLineEdit(&topLevel);
+ QLineEdit *fld3 = new QLineEdit(&topLevel);
- layout.insertRow(-5, "&Name:", &fld1);
- QLabel *label1 = qobject_cast<QLabel *>(layout.itemAt(0, QFormLayout::LabelRole)->widget());
+ layout->insertRow(-5, "&Name:", fld1);
+ QLabel *label1 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget());
QVERIFY(label1 != 0);
- QVERIFY(label1->buddy() == &fld1);
+ QCOMPARE(label1->buddy(), fld1);
- layout.insertRow(0, "&Email:", &fld2);
- QLabel *label2 = qobject_cast<QLabel *>(layout.itemAt(0, QFormLayout::LabelRole)->widget());
+ layout->insertRow(0, "&Email:", fld2);
+ QLabel *label2 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget());
QVERIFY(label2 != 0);
- QVERIFY(label2->buddy() == &fld2);
+ QCOMPARE(label2->buddy(), fld2);
- layout.insertRow(5, "&Age:", &fld3);
- QLabel *label3 = qobject_cast<QLabel *>(layout.itemAt(2, QFormLayout::LabelRole)->widget());
+ layout->insertRow(5, "&Age:", fld3);
+ QLabel *label3 = qobject_cast<QLabel *>(layout->itemAt(2, QFormLayout::LabelRole)->widget());
QVERIFY(label3 != 0);
- QVERIFY(label3->buddy() == &fld3);
+ QCOMPARE(label3->buddy(), fld3);
}
void tst_QFormLayout::insertRow_QString_QLayout()
{
- QFormLayout layout;
- QHBoxLayout fld1, fld2, fld3;
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
+ QHBoxLayout *fld1 = new QHBoxLayout;
+ QHBoxLayout *fld2 = new QHBoxLayout;
+ QHBoxLayout *fld3 = new QHBoxLayout;
- layout.insertRow(-5, "&Name:", &fld1);
- QLabel *label1 = qobject_cast<QLabel *>(layout.itemAt(0, QFormLayout::LabelRole)->widget());
+ layout->insertRow(-5, "&Name:", fld1);
+ QLabel *label1 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget());
QVERIFY(label1 != 0);
- QVERIFY(label1->buddy() == 0);
+ QVERIFY(!label1->buddy());
- QCOMPARE(layout.rowCount(), 1);
+ QCOMPARE(layout->rowCount(), 1);
- layout.insertRow(0, "&Email:", &fld2);
- QLabel *label2 = qobject_cast<QLabel *>(layout.itemAt(0, QFormLayout::LabelRole)->widget());
+ layout->insertRow(0, "&Email:", fld2);
+ QLabel *label2 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget());
QVERIFY(label2 != 0);
- QVERIFY(label2->buddy() == 0);
+ QVERIFY(!label2->buddy());
- QCOMPARE(layout.rowCount(), 2);
+ QCOMPARE(layout->rowCount(), 2);
- layout.insertRow(5, "&Age:", &fld3);
- QLabel *label3 = qobject_cast<QLabel *>(layout.itemAt(2, QFormLayout::LabelRole)->widget());
+ layout->insertRow(5, "&Age:", fld3);
+ QLabel *label3 = qobject_cast<QLabel *>(layout->itemAt(2, QFormLayout::LabelRole)->widget());
QVERIFY(label3 != 0);
- QVERIFY(label3->buddy() == 0);
+ QVERIFY(!label3->buddy());
- QCOMPARE(layout.rowCount(), 3);
+ QCOMPARE(layout->rowCount(), 3);
}
void tst_QFormLayout::insertRow_QWidget()
@@ -840,39 +828,40 @@ void tst_QFormLayout::setLayout()
void tst_QFormLayout::itemAt()
{
- QFormLayout layout;
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
- QWidget w1;
- QWidget w2;
- QWidget w3;
- QWidget w4;
- QWidget w5;
- QHBoxLayout l6;
+ QWidget *w1 = new QWidget(&topLevel);
+ QWidget *w2 = new QWidget(&topLevel);
+ QWidget *w3 = new QWidget(&topLevel);
+ QWidget *w4 = new QWidget(&topLevel);
+ QWidget *w5 = new QWidget(&topLevel);
+ QHBoxLayout *l6 = new QHBoxLayout;
- layout.setWidget(5, QFormLayout::LabelRole, &w1);
- layout.setWidget(3, QFormLayout::FieldRole, &w2);
- layout.setWidget(3, QFormLayout::LabelRole, &w3);
- layout.addRow(&w4, &w5);
- layout.addRow("Foo:", &l6);
+ layout->setWidget(5, QFormLayout::LabelRole, w1);
+ layout->setWidget(3, QFormLayout::FieldRole, w2);
+ layout->setWidget(3, QFormLayout::LabelRole, w3);
+ layout->addRow(w4, w5);
+ layout->addRow("Foo:", l6);
- QCOMPARE(layout.count(), 7);
+ QCOMPARE(layout->count(), 7);
QBitArray scoreBoard(7);
for (int i = 0; i < 7; ++i) {
- QLayoutItem *item = layout.itemAt(i);
+ QLayoutItem *item = layout->itemAt(i);
QVERIFY(item != 0);
- if (item->widget() == &w1) {
+ if (item->widget() == w1) {
scoreBoard[0] = true;
- } else if (item->widget() == &w2) {
+ } else if (item->widget() == w2) {
scoreBoard[1] = true;
- } else if (item->widget() == &w3) {
+ } else if (item->widget() == w3) {
scoreBoard[2] = true;
- } else if (item->widget() == &w4) {
+ } else if (item->widget() == w4) {
scoreBoard[3] = true;
- } else if (item->widget() == &w5) {
+ } else if (item->widget() == w5) {
scoreBoard[4] = true;
- } else if (item->layout() == &l6) {
+ } else if (item->layout() == l6) {
scoreBoard[5] = true;
} else if (qobject_cast<QLabel *>(item->widget())) {
scoreBoard[6] = true;
@@ -883,26 +872,27 @@ void tst_QFormLayout::itemAt()
void tst_QFormLayout::takeAt()
{
- QFormLayout layout;
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
- QWidget w1;
- QWidget w2;
- QWidget w3;
- QWidget w4;
- QWidget w5;
- QHBoxLayout l6;
+ QWidget *w1 = new QWidget(&topLevel);
+ QWidget *w2 = new QWidget(&topLevel);
+ QWidget *w3 = new QWidget(&topLevel);
+ QWidget *w4 = new QWidget(&topLevel);
+ QWidget *w5 = new QWidget(&topLevel);
+ QHBoxLayout *l6 = new QHBoxLayout;
- layout.setWidget(5, QFormLayout::LabelRole, &w1);
- layout.setWidget(3, QFormLayout::FieldRole, &w2);
- layout.setWidget(3, QFormLayout::LabelRole, &w3);
- layout.addRow(&w4, &w5);
- layout.addRow("Foo:", &l6);
+ layout->setWidget(5, QFormLayout::LabelRole, w1);
+ layout->setWidget(3, QFormLayout::FieldRole, w2);
+ layout->setWidget(3, QFormLayout::LabelRole, w3);
+ layout->addRow(w4, w5);
+ layout->addRow("Foo:", l6);
- QCOMPARE(layout.count(), 7);
+ QCOMPARE(layout->count(), 7);
for (int i = 6; i >= 0; --i) {
- layout.takeAt(0);
- QCOMPARE(layout.count(), i);
+ layout->takeAt(0);
+ QCOMPARE(layout->count(), i);
}
}
@@ -917,6 +907,7 @@ void tst_QFormLayout::layoutAlone()
QHBoxLayout hlay;
layout.setLayout(1, QFormLayout::LabelRole, &hlay);
QCOMPARE(layout.count(), 2);
+ w.setWindowTitle(QTest::currentTestFunction());
w.show();
layout.activate();
QTest::qWait(500);
diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
index 7f3c289fb4..1e67c675ef 100644
--- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
+++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
@@ -60,18 +60,9 @@ class tst_QGridLayout : public QObject
{
Q_OBJECT
-public:
- tst_QGridLayout();
- virtual ~tst_QGridLayout();
-
-
-public slots:
+private slots:
void initTestCase();
- void cleanupTestCase();
- void init();
void cleanup();
-
-private slots:
void getItemPosition();
void itemAtPosition();
void badDistributionBug();
@@ -97,76 +88,72 @@ private slots:
void taskQTBUG_40609_addingLayoutToItself();
void replaceWidget();
void dontCrashWhenExtendsToEnd();
-
-private:
- QWidget *testWidget;
- QGridLayout *testLayout;
- QWidget *w1;
- QWidget *w2;
- QWidget *w3;
- QSpacerItem *sp;
-
- QGridLayout *m_grid;
- QWidget *m_toplevel;
};
-
-tst_QGridLayout::tst_QGridLayout()
+void tst_QGridLayout::initTestCase()
{
- m_grid = 0;
- m_toplevel = 0;
+#ifdef Q_OS_WINCE //disable magic for WindowsCE
+ qApp->setAutoMaximizeThreshold(-1);
+#endif
}
-tst_QGridLayout::~tst_QGridLayout()
+static inline int visibleTopLevelWidgetCount()
{
- delete m_toplevel;
+ int result= 0;
+ foreach (const QWidget *topLevel, QApplication::topLevelWidgets()) {
+ if (topLevel->isVisible())
+ ++result;
+ }
+ return result;
}
-void tst_QGridLayout::initTestCase()
+void tst_QGridLayout::cleanup()
{
-#ifdef Q_OS_WINCE //disable magic for WindowsCE
- qApp->setAutoMaximizeThreshold(-1);
-#endif
- // Create the test class
- testWidget = new QWidget(0);
+ // Verify that no visible top levels are leaked. Cannot check for
+ // topLevelWidgets().isEmpty() here since the data driven test layoutSpacing()
+ // will appear to "leak" top levels due to it creating widgets in the test data.
+ QCOMPARE(visibleTopLevelWidgetCount(), 0);
+}
- testLayout = new QGridLayout(testWidget);
+class ItemTestWidget : public QWidget {
+public:
+ ItemTestWidget();
+
+ QGridLayout *testLayout;
+ QWidget *w1;
+ QWidget *w2;
+ QWidget *w3;
+ QSpacerItem *sp;
+};
+
+ItemTestWidget::ItemTestWidget()
+ : testLayout(new QGridLayout(this))
+ , w1(new QWidget(this))
+ , w2(new QWidget(this))
+ , w3(new QWidget(this))
+ , sp(new QSpacerItem(4, 4))
+{
+ setObjectName("testWidget");
+ setWindowTitle(QTest::currentTestFunction());
- w1 = new QWidget(testWidget);
w1->setPalette(QPalette(Qt::red));
testLayout->addWidget(w1, 0, 0);
- w2 = new QWidget(testWidget);
testLayout->addWidget(w2, 1, 1, 2, 2);
w2->setPalette(QPalette(Qt::green));
- w3 = new QWidget(testWidget);
testLayout->addWidget(w3, 0, 1, 1, 2);
w3->setPalette(QPalette(Qt::blue));
- sp = new QSpacerItem(4, 4);
testLayout->addItem(sp, 1, 3, 2, 1);
-
- testWidget->resize( 200, 200 );
- testWidget->show();
-}
-
-void tst_QGridLayout::cleanupTestCase()
-{
- delete testWidget;
- testWidget = 0;
-}
-
-void tst_QGridLayout::init()
-{
-}
-
-void tst_QGridLayout::cleanup()
-{
}
void tst_QGridLayout::getItemPosition()
{
+ ItemTestWidget testWidget;
+ testWidget.resize(200, 200);
+ testWidget.show();
+
QLayoutItem *item;
int counter = 0;
@@ -175,28 +162,28 @@ void tst_QGridLayout::getItemPosition()
bool seenW3 = false;
bool seenSpacer = false;
- while ((item = testLayout->itemAt(counter))) {
+ while ((item = testWidget.testLayout->itemAt(counter))) {
QWidget *w = item->widget();
int r,c,rs,cs;
- testLayout->getItemPosition(counter, &r, &c, &rs, &cs);
+ testWidget.testLayout->getItemPosition(counter, &r, &c, &rs, &cs);
// qDebug() << "item" << counter << "has" <<r << c << rs << cs;
- if (w == w1) {
+ if (w == testWidget.w1) {
QVERIFY(!seenW1);
seenW1 = true;
QCOMPARE(r, 0);
QCOMPARE(c, 0);
QCOMPARE(rs, 1);
QCOMPARE(cs, 1);
- } else if (w == w2) {
+ } else if (w == testWidget.w2) {
QVERIFY(!seenW2);
seenW2 = true;
QCOMPARE(r, 1);
QCOMPARE(c, 1);
QCOMPARE(rs, 2);
QCOMPARE(cs, 2);
- } else if (w == w3) {
+ } else if (w == testWidget.w3) {
QVERIFY(!seenW3);
seenW3 = true;
QCOMPARE(r, 0);
@@ -223,16 +210,20 @@ void tst_QGridLayout::getItemPosition()
void tst_QGridLayout::itemAtPosition()
{
+ ItemTestWidget testWidget;
+ testWidget.resize(200, 200);
+ testWidget.show();
+
void *table[4][5] = {
- { w1, w3, w3, 0, 0 },
- { 0, w2, w2, sp, 0 },
- { 0, w2, w2, sp, 0 },
+ { testWidget.w1, testWidget.w3,testWidget.w3, 0, 0 },
+ { 0, testWidget.w2, testWidget.w2, testWidget.sp, 0 },
+ { 0, testWidget.w2, testWidget.w2, testWidget.sp, 0 },
{ 0, 0, 0, 0, 0 }
};
for (int row = 0; row < 4; ++row) {
for (int col = 0; col < 5; ++col) {
- QLayoutItem *item = testLayout->itemAtPosition(row, col);
+ QLayoutItem *item = testWidget.testLayout->itemAtPosition(row, col);
QVERIFY(item == table[row][col]
|| (item && item->widget() == table[row][col]));
}
@@ -860,32 +851,31 @@ void tst_QGridLayout::minMaxSize()
}
}
QApplication::setStyle(style);
- if (!m_grid)
- m_grid = new QGridLayout();
- if (!m_toplevel) {
- m_toplevel = new QWidget();
- setFrameless(m_toplevel);
- }
+ QWidget toplevel;
+ toplevel.setWindowTitle(QLatin1String(QTest::currentTestFunction())
+ + QLatin1Char(' ') + QLatin1String(QTest::currentDataTag()));
+ setFrameless(&toplevel);
+ QGridLayout *grid = new QGridLayout;
if (fixedSize.isValid()) {
- m_toplevel->setFixedSize(fixedSize);
+ toplevel.setFixedSize(fixedSize);
} else {
- m_toplevel->setMinimumSize(QSize(0,0));
- m_toplevel->setMaximumSize(QSize(QWIDGETSIZE_MAX,QWIDGETSIZE_MAX));
+ toplevel.setMinimumSize(QSize(0,0));
+ toplevel.setMaximumSize(QSize(QWIDGETSIZE_MAX,QWIDGETSIZE_MAX));
}
// Do a two-pass one using the real testdata, the other pass enables heightForWidth
// on the widget, but the heightForWidth() function just return sizeHint().width()
for (int pass = 0; pass < 2; ++pass) {
- m_toplevel->hide();
+ toplevel.hide();
QApplication::processEvents();
QTest::qWait(20);
// Test if removeItem uninitializes data properly
- while (m_grid->count()) {
- QLayoutItem *item = m_grid->itemAt(0);
- m_grid->removeItem(item);
+ while (grid->count()) {
+ QLayoutItem *item = grid->itemAt(0);
+ grid->removeItem(item);
delete item->widget();
delete item;
}
- m_toplevel->setLayout(m_grid);
+ toplevel.setLayout(grid);
// a layout with a top-level parent widget
QList<QPointer<SizeHinterFrame> > sizehinters;
@@ -899,29 +889,29 @@ void tst_QGridLayout::minMaxSize()
QSizePolicy sp = sh->sizePolicy();
sp.setHorizontalPolicy((QSizePolicy::Policy)sizePolicy);
sh->setSizePolicy(sp);
- sh->setParent(m_toplevel);
+ sh->setParent(&toplevel);
if (si.minSize.isValid())
sh->setMinimumSize(si.minSize);
if (si.maxSize.isValid())
sh->setMaximumSize(si.maxSize);
sizehinters.append(sh);
- m_grid->addWidget(sh, i, j);
+ grid->addWidget(sh, i, j);
}
}
- m_toplevel->show();
- QVERIFY(QTest::qWaitForWindowExposed(m_toplevel));
- m_toplevel->adjustSize();
+ toplevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&toplevel));
+ toplevel.adjustSize();
QTest::qWait(240); // wait for the implicit adjustSize
// If the following fails we might have to wait longer.
// If that does not help there is likely a problem with the implicit adjustSize in show()
if (!fixedSize.isValid()) {
// Note that this can fail if the desktop has large fonts on windows.
- QTRY_COMPARE(m_toplevel->size(), m_toplevel->sizeHint());
+ QTRY_COMPARE(toplevel.size(), toplevel.sizeHint());
}
// We are relying on the order here...
for (int pi = 0; pi < sizehinters.count(); ++pi) {
- QPoint pt = sizehinters.at(pi)->mapTo(m_toplevel, QPoint(0, 0));
+ QPoint pt = sizehinters.at(pi)->mapTo(&toplevel, QPoint(0, 0));
QCOMPARE(pt, sizeinfos.at(pi).expectedPos);
}
}
diff --git a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp
index d661c074ac..4d15ac9a93 100644
--- a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp
+++ b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp
@@ -66,6 +66,7 @@ public:
virtual ~tst_QLayout();
private slots:
+ void cleanup() { QVERIFY(QApplication::topLevelWidgets().isEmpty()); }
void getSetCheck();
void geometry();
void smartMaxSize();
@@ -217,12 +218,12 @@ void tst_QLayout::setLayoutBugs()
}
widget.setLayout(hBoxLayout);
- QVERIFY(widget.layout() == hBoxLayout);
+ QCOMPARE(widget.layout(), hBoxLayout);
QWidget containerWidget(0);
containerWidget.setLayout(widget.layout());
- QVERIFY(widget.layout() == 0);
- QVERIFY(containerWidget.layout() == hBoxLayout);
+ QVERIFY(!widget.layout());
+ QCOMPARE(containerWidget.layout(), hBoxLayout);
}
class MyLayout : public QLayout
diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
index 7b9eaa418f..15aef8d503 100644
--- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
+++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
@@ -72,7 +72,8 @@ public:
TriggerSlot4,
TriggerSlot5,
TriggerSlot6,
- TriggerSlot7
+ TriggerSlot7,
+ SendKeyEvent
};
enum Result {
@@ -84,6 +85,7 @@ public:
Slot5Triggered,
Slot6Triggered,
Slot7Triggered,
+ SentKeyEvent,
Ambiguous
} currentResult;
@@ -104,10 +106,12 @@ public slots:
void ambigSlot7() { currentResult = Ambiguous; ambigResult = Slot7Triggered; }
void statusMessage( const QString& message ) { sbText = message; }
void shortcutDestroyed(QObject* obj);
+ void sendKeyEvent() { sendKeyEvents(edit, Qt::CTRL + Qt::Key_B, 0); currentResult = SentKeyEvent; }
public slots:
void initTestCase();
void cleanupTestCase();
+ void cleanup() { QCOMPARE(QApplication::topLevelWidgets().size(), 1); }
private slots:
void number_data();
@@ -980,6 +984,19 @@ void tst_QShortcut::keypressConsumption()
QVERIFY(edit->toPlainText().endsWith("<Ctrl+I>a"));
clearAllShortcuts();
+ edit->clear();
+ QCOMPARE(edit->toPlainText().size(), 0);
+
+ setupShortcut(edit, "first", SendKeyEvent, "Ctrl+A");
+
+ // Verify reentrancy when a non-shortcut is triggered as part
+ // of shortcut processing.
+ currentResult = NoResult;
+ ambigResult = NoResult;
+ sendKeyEvents(edit, Qt::CTRL + Qt::Key_A, 0);
+ QCOMPARE(currentResult, SentKeyEvent);
+ QCOMPARE(ambigResult, NoResult);
+ QCOMPARE(edit->toPlainText(), QString(QString("<Ctrl+B>")));
}
// ------------------------------------------------------------------
@@ -1181,9 +1198,12 @@ QShortcut *tst_QShortcut::setupShortcut(QWidget *parent, const char *name, int t
normal = SLOT(slotTrig7());
ambig = SLOT(ambigSlot7());
break;
+ case SendKeyEvent:
+ normal = SLOT(sendKeyEvent());
}
connect(cut, SIGNAL(activated()), this, normal);
- connect(cut, SIGNAL(activatedAmbiguously()), this, ambig);
+ if (ambig)
+ connect(cut, SIGNAL(activatedAmbiguously()), this, ambig);
connect(cut, SIGNAL(destroyed(QObject*)), this, SLOT(shortcutDestroyed(QObject*)));
shortcuts.append(cut);
return cut;
diff --git a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp
index 6c88f8731b..0f8c9d1c9e 100644
--- a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp
+++ b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp
@@ -44,6 +44,7 @@ class tst_QSizePolicy : public QObject
Q_OBJECT
private Q_SLOTS:
+ void cleanup() { QVERIFY(QApplication::topLevelWidgets().isEmpty()); }
void qtest();
void defaultValues();
void getSetCheck_data() { data(); }
@@ -51,6 +52,8 @@ private Q_SLOTS:
void dataStream();
void horizontalStretch();
void verticalStretch();
+ void qhash_data() { data(); }
+ void qhash();
private:
void data() const;
};
@@ -149,8 +152,6 @@ void tst_QSizePolicy::getSetCheck()
QCOMPARE(sp.expandingDirections(), ed);
}
-#undef FETCH_TEST_DATA
-
static void makeRow(QSizePolicy sp, QSizePolicy::Policy hp, QSizePolicy::Policy vp,
int hst, int vst, QSizePolicy::ControlType ct, bool hfw, bool wfh,
Qt::Orientations orients)
@@ -314,5 +315,21 @@ void tst_QSizePolicy::verticalStretch()
QCOMPARE(sp.verticalStretch(), 255);
}
+void tst_QSizePolicy::qhash()
+{
+ FETCH_TEST_DATA;
+ Q_UNUSED(ed);
+
+ QSizePolicy sp2(hp, vp, ct);
+ sp2.setVerticalStretch(vst);
+ sp2.setHorizontalStretch(hst);
+ if (hfw) sp2.setHeightForWidth(true);
+ if (wfh) sp2.setWidthForHeight(true);
+ QCOMPARE(sp, sp2);
+ QCOMPARE(qHash(sp), qHash(sp2));
+}
+
+#undef FETCH_TEST_DATA
+
QTEST_MAIN(tst_QSizePolicy)
#include "tst_qsizepolicy.moc"
diff --git a/tests/auto/widgets/kernel/qtooltip/BLACKLIST b/tests/auto/widgets/kernel/qtooltip/BLACKLIST
new file mode 100644
index 0000000000..f8d062cc46
--- /dev/null
+++ b/tests/auto/widgets/kernel/qtooltip/BLACKLIST
@@ -0,0 +1,4 @@
+[whatsThis]
+ubuntu-14.04
+[task183679]
+opensuse-13.1
diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST
index 591aa9e40f..78ccbe302a 100644
--- a/tests/auto/widgets/kernel/qwidget/BLACKLIST
+++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST
@@ -12,7 +12,7 @@ osx
ubuntu-14.04
osx
[focusProxyAndInputMethods]
-ubuntu-14.04
+linux
[touchEventSynthesizedMouseEvent]
ubuntu-14.04
[grabMouse]
@@ -28,73 +28,17 @@ osx
[stackUnder]
osx
[raise]
-osx-10.9
+osx
[widgetAt]
osx
[sheetOpacity]
osx
[resizeEvent]
osx
-[setWindowGeometry:100,123 200x200, flags 0]
-osx-10.10
-[windowMoveResize:100,123 200x200, flags 0]
-osx-10.10
-[setWindowGeometry:100,122 200x200, flags 0]
-osx-10.9
-[windowMoveResize:100,122 200x200, flags 0]
-osx-10.9
-[setWindowGeometry:100,100 824x564, flags 0]
-osx-10.10
-[windowMoveResize:100,100 824x564, flags 0]
-osx-10.10
-[setWindowGeometry:100,100 824x516, flags 0]
-osx-10.10
-[windowMoveResize:100,100 824x516, flags 0]
-osx-10.10
-[setWindowGeometry:100,73 200x0, flags 0]
-osx-10.10
-[windowMoveResize:100,73 200x0, flags 0]
-osx-10.10
-[setWindowGeometry:100,100 824x519, flags 0]
-osx-10.10
-[windowMoveResize:100,100 824x519, flags 0]
-osx-10.10
-[setWindowGeometry:100,100 824x518, flags 0]
-osx-10.10
-[windowMoveResize:100,100 824x518, flags 0]
-osx-10.10
-[setWindowGeometry:100,72 200x0, flags 0]
-osx-10.9
-[windowMoveResize:100,72 200x0, flags 0]
-osx-10.9
-[setWindowGeometry:100,122 952x574, flags 0]
-osx-10.9
-[windowMoveResize:100,122 952x574, flags 0]
-osx-10.9
-[setWindowGeometry:100,122 952x578, flags 0]
-osx-10.9
-[windowMoveResize:100,122 952x578, flags 0]
-osx-10.9
-[setWindowGeometry:100,122 952x576, flags 0]
-osx-10.9
-[windowMoveResize:100,122 952x576, flags 0]
-osx-10.9
-[setWindowGeometry:100,100 824x521, flags 0]
-osx-10.10
-[windowMoveResize:100,100 824x521, flags 0]
-osx-10.10
-[setWindowGeometry:100,122 952x577, flags 0]
-osx-10.9
-[windowMoveResize:100,122 952x577, flags 0]
-osx-10.9
-[setWindowGeometry:100,122 952x580, flags 0]
-osx-10.9
-[windowMoveResize:100,122 952x580, flags 0]
-osx-10.9
-[windowMoveResize:130,72 0x0, flags 0]
-osx-10.9
-[windowMoveResize:130,122 0x200, flags 0]
-osx-10.9
+[setWindowGeometry]
+osx
+[windowMoveResize]
+osx
[childEvents]
osx
[renderInvisible]
@@ -114,9 +58,9 @@ osx
[showMinimizedKeepsFocus]
osx-10.10
[moveWindowInShowEvent:1]
-osx-10.9
+osx
[moveWindowInShowEvent:2]
-osx-10.9
+osx
[taskQTBUG_4055_sendSyntheticEnterLeave]
osx
[syntheticEnterLeave]
@@ -128,10 +72,14 @@ osx-10.10
[hideOpaqueChildWhileHidden]
osx
[resizeStaticContentsChildWidget_QTBUG35282]
-osx-10.9
+osx
[lower]
osx
[setClearAndResizeMask]
osx
[setToolTip]
osx-10.9
+[moveInResizeEvent]
+ubuntu-14.04
+[moveChild:right]
+osx
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index a0d94d2dc9..ddbb4e6d75 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -51,6 +51,7 @@
#include <qdesktopwidget.h>
#include <private/qwidget_p.h>
#include <private/qapplication_p.h>
+#include <private/qhighdpiscaling_p.h>
#include <qcalendarwidget.h>
#include <qmainwindow.h>
#include <qdockwidget.h>
@@ -193,6 +194,19 @@ static QByteArray msgComparisonFailed(T v1, const char *op, T v2)
return s.toLocal8Bit();
}
+// Compare a window position that may go through scaling in the platform plugin with fuzz.
+static inline bool qFuzzyCompareWindowPosition(const QPoint &p1, const QPoint p2, int fuzz)
+{
+ return (p1 - p2).manhattanLength() <= fuzz;
+}
+
+static QString msgPointMismatch(const QPoint &p1, const QPoint p2)
+{
+ QString result;
+ QDebug(&result) << p1 << "!=" << p2 << ", manhattanLength=" << (p1 - p2).manhattanLength();
+ return result;
+}
+
class tst_QWidget : public QObject
{
Q_OBJECT
@@ -613,7 +627,7 @@ void tst_QWidget::getSetCheck()
}
tst_QWidget::tst_QWidget()
- : m_platform(qApp->platformName().toLower())
+ : m_platform(QGuiApplication::platformName().toLower())
, m_windowsAnimationsEnabled(windowsAnimationsEnabled())
{
if (m_windowsAnimationsEnabled) // Disable animations which can interfere with screen grabbing in moveChild(), showAndMoveChild()
@@ -1846,10 +1860,6 @@ void tst_QWidget::activation()
QCOMPARE(QApplication::activeWindow(), &widget1);
widget2.showNormal();
QTest::qWait(waitTime);
-#ifndef Q_OS_WINCE
- if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA)
- QEXPECT_FAIL("", "MS introduced new behavior after XP", Continue);
-#endif
QTest::qWait(waitTime);
QCOMPARE(QApplication::activeWindow(), &widget2);
widget2.hide();
@@ -1905,8 +1915,10 @@ void tst_QWidget::windowState()
widget1.setWindowState(widget1.windowState() ^ Qt::WindowMaximized);
QTest::qWait(100);
+ const int fuzz = int(QHighDpiScaling::factor(widget1.windowHandle()));
QVERIFY(!(widget1.windowState() & Qt::WindowMaximized));
- QTRY_COMPARE(widget1.pos(), pos);
+ QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz),
+ qPrintable(msgPointMismatch(widget1.pos(), pos)));
QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState);
widget1.setWindowState(Qt::WindowMinimized);
@@ -1927,7 +1939,8 @@ void tst_QWidget::windowState()
widget1.setWindowState(widget1.windowState() ^ Qt::WindowMaximized);
QTest::qWait(100);
QVERIFY(!(widget1.windowState() & (Qt::WindowMinimized|Qt::WindowMaximized)));
- QTRY_COMPARE(widget1.pos(), pos);
+ QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz),
+ qPrintable(msgPointMismatch(widget1.pos(), pos)));
QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState);
widget1.setWindowState(Qt::WindowFullScreen);
@@ -1948,7 +1961,8 @@ void tst_QWidget::windowState()
widget1.setWindowState(Qt::WindowNoState);
QTest::qWait(100);
VERIFY_STATE(Qt::WindowNoState);
- QTRY_COMPARE(widget1.pos(), pos);
+ QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz),
+ qPrintable(msgPointMismatch(widget1.pos(), pos)));
QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState);
widget1.setWindowState(Qt::WindowFullScreen);
@@ -1981,7 +1995,8 @@ void tst_QWidget::windowState()
QVERIFY(!(widget1.windowState() & stateMask));
QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState);
- QTRY_COMPARE(widget1.pos(), pos);
+ QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz),
+ qPrintable(msgPointMismatch(widget1.pos(), pos)));
QTRY_COMPARE(widget1.size(), size);
}
@@ -3079,12 +3094,12 @@ void tst_QWidget::saveRestoreGeometry()
const QByteArray four("abca");
const QByteArray garbage("abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc");
- QVERIFY(widget.restoreGeometry(empty) == false);
- QVERIFY(widget.restoreGeometry(one) == false);
- QVERIFY(widget.restoreGeometry(two) == false);
- QVERIFY(widget.restoreGeometry(three) == false);
- QVERIFY(widget.restoreGeometry(four) == false);
- QVERIFY(widget.restoreGeometry(garbage) == false);
+ QVERIFY(!widget.restoreGeometry(empty));
+ QVERIFY(!widget.restoreGeometry(one));
+ QVERIFY(!widget.restoreGeometry(two));
+ QVERIFY(!widget.restoreGeometry(three));
+ QVERIFY(!widget.restoreGeometry(four));
+ QVERIFY(!widget.restoreGeometry(garbage));
QVERIFY(widget.restoreGeometry(savedGeometry));
widget.showNormal();
@@ -3354,7 +3369,7 @@ void tst_QWidget::widgetAt()
#if defined(Q_OS_WINCE)
QEXPECT_FAIL("", "Windows CE does only support rectangular regions", Continue); //See also task 147191
#endif
- QTRY_VERIFY(QApplication::widgetAt(testPos) == w1.data());
+ QTRY_COMPARE(QApplication::widgetAt(testPos), w1.data());
QTRY_VERIFY(QApplication::widgetAt(testPos + QPoint(1, 1)) == w2.data());
}
@@ -3401,24 +3416,24 @@ void tst_QWidget::testDeletionInEventHandlers()
QPointer<Widget> w = new Widget;
w->deleteThis = true;
w->close();
- QVERIFY(w == 0);
+ QVERIFY(w.isNull());
delete w;
// focusOut (crashes)
//w = new Widget;
//w->show();
//w->setFocus();
- //QVERIFY(qApp->focusWidget() == w);
+ //QCOMPARE(qApp->focusWidget(), w);
//w->deleteThis = true;
//w->clearFocus();
- //QVERIFY(w == 0);
+ //QVERIFY(w.isNull());
// key press
w = new Widget;
w->show();
w->deleteThis = true;
QTest::keyPress(w, Qt::Key_A);
- QVERIFY(w == 0);
+ QVERIFY(w.isNull());
delete w;
// key release
@@ -3426,7 +3441,7 @@ void tst_QWidget::testDeletionInEventHandlers()
w->show();
w->deleteThis = true;
QTest::keyRelease(w, Qt::Key_A);
- QVERIFY(w == 0);
+ QVERIFY(w.isNull());
delete w;
// mouse press
@@ -3434,15 +3449,16 @@ void tst_QWidget::testDeletionInEventHandlers()
w->show();
w->deleteThis = true;
QTest::mousePress(w, Qt::LeftButton);
- QVERIFY(w == 0);
+ QVERIFY(w.isNull());
delete w;
// mouse release
w = new Widget;
w->show();
w->deleteThis = true;
- QTest::mouseRelease(w, Qt::LeftButton);
- QVERIFY(w == 0);
+ QMouseEvent me(QEvent::MouseButtonRelease, QPoint(1, 1), Qt::LeftButton, Qt::LeftButton, 0);
+ qApp->notify(w, &me);
+ QVERIFY(w.isNull());
delete w;
// mouse double click
@@ -3450,7 +3466,7 @@ void tst_QWidget::testDeletionInEventHandlers()
w->show();
w->deleteThis = true;
QTest::mouseDClick(w, Qt::LeftButton);
- QVERIFY(w == 0);
+ QVERIFY(w.isNull());
delete w;
// hide event (crashes)
@@ -3458,13 +3474,13 @@ void tst_QWidget::testDeletionInEventHandlers()
//w->show();
//w->deleteThis = true;
//w->hide();
- //QVERIFY(w == 0);
+ //QVERIFY(w.isNull());
// action event
w = new Widget;
w->deleteThis = true;
w->addAction(new QAction(w));
- QVERIFY(w == 0);
+ QVERIFY(w.isNull());
delete w;
// change event
@@ -3472,16 +3488,16 @@ void tst_QWidget::testDeletionInEventHandlers()
w->show();
w->deleteThis = true;
w->setMouseTracking(true);
- QVERIFY(w == 0);
+ QVERIFY(w.isNull());
delete w;
w = new Widget;
w->setMouseTracking(true);
w->show();
w->deleteThis = true;
- QMouseEvent me(QEvent::MouseMove, QPoint(0, 0), Qt::NoButton, Qt::NoButton, Qt::NoModifier);
+ me = QMouseEvent(QEvent::MouseMove, QPoint(0, 0), Qt::NoButton, Qt::NoButton, Qt::NoModifier);
QApplication::sendEvent(w, &me);
- QVERIFY(w == 0);
+ QVERIFY(w.isNull());
delete w;
}
@@ -3675,6 +3691,8 @@ void tst_QWidget::optimizedResizeMove()
void tst_QWidget::optimizedResize_topLevel()
{
+ if (QHighDpiScaling::isActive())
+ QSKIP("Skip due to rounding errors in the regions.");
StaticWidget topLevel;
topLevel.gotPaintEvent = false;
topLevel.show();
@@ -3909,7 +3927,7 @@ void tst_QWidget::winIdChangeEvent()
QCOMPARE(winIdBefore, winIdAfter);
QCOMPARE(child.winIdChangeEventCount(), 3);
// winId is set to zero during reparenting
- QVERIFY(0 == child.m_winIdList[1]);
+ QCOMPARE(WId(0), child.m_winIdList[1]);
}
{
@@ -3949,7 +3967,7 @@ void tst_QWidget::winIdChangeEvent()
QCOMPARE(winIdBefore, winIdAfter);
QCOMPARE(child.winIdChangeEventCount(), 3);
// winId is set to zero during reparenting
- QVERIFY(0 == child.m_winIdList[1]);
+ QCOMPARE(WId(0), child.m_winIdList[1]);
}
}
@@ -4495,7 +4513,7 @@ void tst_QWidget::qobject_castInDestroyedSlot()
QObject::connect(widget, SIGNAL(destroyed(QObject*)), &checker, SLOT(destroyedSlot(QObject*)));
delete widget;
- QVERIFY(checker.wasQWidget == true);
+ QVERIFY(checker.wasQWidget);
}
// Since X11 WindowManager operations are all async, and we have no way to know if the window
@@ -4544,8 +4562,18 @@ void tst_QWidget::setWindowGeometry_data()
QList<int> windowFlags;
windowFlags << 0 << Qt::FramelessWindowHint;
+ const bool skipEmptyRects = (m_platform == QStringLiteral("windows"));
foreach (QList<QRect> l, rects) {
QRect rect = l.first();
+ if (skipEmptyRects) {
+ QList<QRect>::iterator it = l.begin();
+ while (it != l.end()) {
+ if (it->isEmpty())
+ it = l.erase(it);
+ else
+ ++it;
+ }
+ }
foreach (int windowFlag, windowFlags) {
QTest::newRow(QString("%1,%2 %3x%4, flags %5")
.arg(rect.x())
@@ -4594,8 +4622,13 @@ void tst_QWidget::setWindowGeometry()
widget.setGeometry(rect);
widget.showNormal();
- if (rect.isValid())
+ if (rect.isValid()) {
QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ } else {
+ // in case of an invalid rect, wait for the geometry to become
+ // adjusted to the actual (valid) value.
+ QApplication::processEvents();
+ }
QTRY_COMPARE(widget.geometry(), rect);
// setGeometry() while shown
@@ -6007,10 +6040,13 @@ void tst_QWidget::childEvents()
expected =
EventRecorder::EventList()
<< qMakePair(&widget, QEvent::Polish)
+ << qMakePair(&widget, QEvent::PlatformSurface)
<< qMakePair(&widget, QEvent::WinIdChange)
+ << qMakePair(&widget, QEvent::WindowIconChange)
<< qMakePair(&widget, QEvent::Move)
<< qMakePair(&widget, QEvent::Resize)
<< qMakePair(&widget, QEvent::Show)
+ << qMakePair(&widget, QEvent::CursorChange)
<< qMakePair(&widget, QEvent::ShowToParent);
QVERIFY2(spy.eventList() == expected,
@@ -6022,13 +6058,9 @@ void tst_QWidget::childEvents()
EventRecorder::EventList()
<< qMakePair(&widget, QEvent::PolishRequest)
<< qMakePair(&widget, QEvent::Type(QEvent::User + 1))
-#if defined(Q_OS_OSX) || defined(Q_OS_QNX)
<< qMakePair(&widget, QEvent::UpdateLater)
-#endif
<< qMakePair(&widget, QEvent::UpdateRequest);
- if (m_platform == QStringLiteral("windows") || m_platform == QStringLiteral("xcb"))
- QEXPECT_FAIL("", EventRecorder::msgExpectFailQtBug26424(expected, spy.eventList()).constData(), Continue);
QVERIFY2(spy.eventList() == expected,
EventRecorder::msgEventListMismatch(expected, spy.eventList()).constData());
}
@@ -6097,10 +6129,13 @@ void tst_QWidget::childEvents()
<< qMakePair(&widget, QEvent::Polish)
<< qMakePair(&widget, QEvent::ChildPolished)
<< qMakePair(&widget, QEvent::ChildPolished)
+ << qMakePair(&widget, QEvent::PlatformSurface)
<< qMakePair(&widget, QEvent::WinIdChange)
+ << qMakePair(&widget, QEvent::WindowIconChange)
<< qMakePair(&widget, QEvent::Move)
<< qMakePair(&widget, QEvent::Resize)
<< qMakePair(&widget, QEvent::Show)
+ << qMakePair(&widget, QEvent::CursorChange)
<< qMakePair(&widget, QEvent::ShowToParent);
QVERIFY2(spy.eventList() == expected,
@@ -6113,13 +6148,9 @@ void tst_QWidget::childEvents()
<< qMakePair(&widget, QEvent::PolishRequest)
<< qMakePair(&widget, QEvent::Type(QEvent::User + 1))
<< qMakePair(&widget, QEvent::Type(QEvent::User + 2))
-#if defined(Q_OS_OSX) || defined(Q_OS_QNX)
<< qMakePair(&widget, QEvent::UpdateLater)
-#endif
<< qMakePair(&widget, QEvent::UpdateRequest);
- if (m_platform == QStringLiteral("windows") || m_platform == QStringLiteral("xcb"))
- QEXPECT_FAIL("", EventRecorder::msgExpectFailQtBug26424(expected, spy.eventList()).constData(), Continue);
QVERIFY2(spy.eventList() == expected,
EventRecorder::msgEventListMismatch(expected, spy.eventList()).constData());
}
@@ -6190,10 +6221,13 @@ void tst_QWidget::childEvents()
EventRecorder::EventList()
<< qMakePair(&widget, QEvent::Polish)
<< qMakePair(&widget, QEvent::ChildPolished)
+ << qMakePair(&widget, QEvent::PlatformSurface)
<< qMakePair(&widget, QEvent::WinIdChange)
+ << qMakePair(&widget, QEvent::WindowIconChange)
<< qMakePair(&widget, QEvent::Move)
<< qMakePair(&widget, QEvent::Resize)
<< qMakePair(&widget, QEvent::Show)
+ << qMakePair(&widget, QEvent::CursorChange)
<< qMakePair(&widget, QEvent::ShowToParent);
QVERIFY2(spy.eventList() == expected,
@@ -6206,13 +6240,9 @@ void tst_QWidget::childEvents()
<< qMakePair(&widget, QEvent::PolishRequest)
<< qMakePair(&widget, QEvent::Type(QEvent::User + 1))
<< qMakePair(&widget, QEvent::Type(QEvent::User + 2))
-#if defined(Q_OS_OSX) || defined(Q_OS_QNX)
<< qMakePair(&widget, QEvent::UpdateLater)
-#endif
<< qMakePair(&widget, QEvent::UpdateRequest);
- if (m_platform == QStringLiteral("windows") || m_platform == QStringLiteral("xcb"))
- QEXPECT_FAIL("", EventRecorder::msgExpectFailQtBug26424(expected, spy.eventList()).constData(), Continue);
QVERIFY2(spy.eventList() == expected,
EventRecorder::msgEventListMismatch(expected, spy.eventList()).constData());
}
@@ -8957,7 +8987,7 @@ void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave()
int numEnterEvents, numMouseMoveEvents;
};
- QCursor::setPos(QPoint(0,0));
+ QCursor::setPos(QPoint(0,0));
SELParent parent;
parent.move(200, 200);
@@ -8965,8 +8995,7 @@ void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave()
SELChild child(&parent);
child.resize(200, 200);
parent.show();
- QVERIFY(QTest::qWaitForWindowExposed(&parent));
- QTest::qWait(150);
+ QVERIFY(QTest::qWaitForWindowActive(&parent));
QCursor::setPos(child.mapToGlobal(QPoint(100, 100)));
// Make sure the cursor has entered the child.
@@ -9714,8 +9743,9 @@ void tst_QWidget::grabMouse()
QVERIFY(QTest::qWaitForWindowActive(&w));
QStringList expectedLog;
- grabber->grabMouse();
QPoint mousePos = QPoint(w.width() / 2, 10);
+ QTest::mouseMove(w.windowHandle(), mousePos);
+ grabber->grabMouse();
const int step = w.height() / 5;
for ( ; mousePos.y() < w.height() ; mousePos.ry() += step) {
QTest::mouseClick(w.windowHandle(), Qt::LeftButton, 0, mousePos);
@@ -10385,6 +10415,9 @@ public:
void tst_QWidget::keyboardModifiers()
{
KeyboardWidget w;
+ w.resize(300, 300);
+ w.show();
+ QVERIFY(QTest::qWaitForWindowActive(&w));
QTest::mouseClick(&w, Qt::LeftButton, Qt::ControlModifier);
QCOMPARE(w.m_eventCounter, 1);
QCOMPARE(int(w.m_modifiers), int(Qt::ControlModifier));
@@ -10462,7 +10495,7 @@ void tst_QWidget::qmlSetParentHelper()
QWidget child;
QVERIFY(QAbstractDeclarativeData::setWidgetParent);
QAbstractDeclarativeData::setWidgetParent(&child, &parent);
- QVERIFY(child.parentWidget() == &parent);
+ QCOMPARE(child.parentWidget(), &parent);
QAbstractDeclarativeData::setWidgetParent(&child, 0);
QVERIFY(!child.parentWidget());
#else
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 148c2352a5..5188dfbcfa 100644
--- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
+++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
@@ -97,6 +97,8 @@ private slots:
void tst_resize_count();
void tst_move_count();
+
+ void tst_eventfilter_on_toplevel();
};
void tst_QWidget_window::initTestCase()
@@ -336,30 +338,30 @@ void tst_QWidget_window::tst_windowFilePath()
void tst_QWidget_window::tst_showWithoutActivating()
{
-#ifndef Q_DEAD_CODE_FROM_QT4_X11
- QSKIP("This test is X11-only.");
-#else
- QWidget w;
- w.show();
- QVERIFY(QTest::qWaitForWindowExposed(&w));
- QApplication::processEvents();
+ QString platformName = QGuiApplication::platformName().toLower();
+ if (platformName == "cocoa")
+ QSKIP("Cocoa: This fails. Figure out why.");
+ else if (platformName != QStringLiteral("xcb")
+ && platformName != QStringLiteral("windows")
+ && platformName != QStringLiteral("ios"))
+ QSKIP("Qt::WA_ShowWithoutActivating is currently supported only on xcb, windows, and ios platforms.");
+
+ QWidget w1;
+ w1.setAttribute(Qt::WA_ShowWithoutActivating);
+ w1.show();
+ QVERIFY(!QTest::qWaitForWindowActive(&w1));
- QApplication::clipboard();
- QLineEdit *lineEdit = new QLineEdit;
- lineEdit->setAttribute(Qt::WA_ShowWithoutActivating, true);
- lineEdit->show();
- lineEdit->setAttribute(Qt::WA_ShowWithoutActivating, false);
- lineEdit->raise();
- lineEdit->activateWindow();
-
- Window window;
- int revertto;
- QTRY_COMPARE(lineEdit->winId(),
- (XGetInputFocus(QX11Info::display(), &window, &revertto), window) );
- // Note the use of the , before window because we want the XGetInputFocus to be re-executed
- // in each iteration of the inside loop of the QTRY_COMPARE macro
-
-#endif // Q_DEAD_CODE_FROM_QT4_X11
+ QWidget w2;
+ w2.show();
+ QVERIFY(QTest::qWaitForWindowActive(&w2));
+
+ QWidget w3;
+ w3.setAttribute(Qt::WA_ShowWithoutActivating);
+ w3.show();
+ QVERIFY(!QTest::qWaitForWindowActive(&w3));
+
+ w3.activateWindow();
+ QVERIFY(QTest::qWaitForWindowActive(&w3));
}
void tst_QWidget_window::tst_paintEventOnSecondShow()
@@ -762,5 +764,48 @@ void tst_QWidget_window::tst_move_count()
QTRY_VERIFY(move.moveCount >= 1);
}
+class EventFilter : public QObject
+{
+public:
+ int eventCount;
+
+ EventFilter()
+ : QObject(),
+ eventCount(0)
+ {
+ }
+
+ static QEvent::Type filterEventType()
+ {
+ static int type = QEvent::registerEventType();
+ return static_cast<QEvent::Type>(type);
+ }
+
+protected:
+ bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE
+ {
+ if (e->type() == filterEventType())
+ ++eventCount;
+
+ return QObject::eventFilter(o, e);
+ }
+};
+
+void tst_QWidget_window::tst_eventfilter_on_toplevel()
+{
+ QWidget w;
+ EventFilter filter;
+ w.installEventFilter(&filter);
+ w.show();
+ QVERIFY(QTest::qWaitForWindowActive(&w));
+ QVERIFY(w.isWindow());
+ QCOMPARE(filter.eventCount, 0);
+
+ // send an event not handled in a special way by QWidgetWindow::event,
+ // and check that it's received by the event filter
+ QCoreApplication::postEvent(w.windowHandle(), new QEvent(EventFilter::filterEventType()));
+ QTRY_COMPARE(filter.eventCount, 1);
+}
+
QTEST_MAIN(tst_QWidget_window)
#include "tst_qwidget_window.moc"
diff --git a/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp b/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp
index df54d22a2f..207ce00dbf 100644
--- a/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp
+++ b/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp
@@ -55,6 +55,8 @@ class tst_QWidgetAction : public QObject
{
Q_OBJECT
private slots:
+ void initTestCase();
+ void cleanup();
void defaultWidget();
void visibilityUpdate();
void customWidget();
@@ -65,6 +67,19 @@ private slots:
void releaseWidgetCrash();
};
+void tst_QWidgetAction::initTestCase()
+{
+ // Disable menu/combo animations to prevent the alpha widgets from getting in the
+ // way in popup(), failing the top level leak check in cleanup().
+ QApplication::setEffectEnabled(Qt::UI_AnimateMenu, false);
+ QApplication::setEffectEnabled(Qt::UI_AnimateCombo, false);
+}
+
+void tst_QWidgetAction::cleanup()
+{
+ QVERIFY(QApplication::topLevelWidgets().isEmpty());
+}
+
void tst_QWidgetAction::defaultWidget()
{
{
@@ -123,14 +138,14 @@ void tst_QWidgetAction::defaultWidget()
action->setDefaultWidget(combo);
tb1.addAction(action);
- QVERIFY(combo->parent() == &tb1);
+ QCOMPARE(combo->parent(), &tb1);
qApp->processEvents();
qApp->processEvents();
QVERIFY(combo->isVisible());
// not supported, not supposed to work, hence the parent() check
tb2.addAction(action);
- QVERIFY(combo->parent() == &tb1);
+ QCOMPARE(combo->parent(), &tb1);
tb2.removeAction(action);
tb1.removeAction(action);
@@ -141,11 +156,11 @@ void tst_QWidgetAction::defaultWidget()
tb2.addAction(action);
qApp->processEvents(); //the call to hide is delayd by the toolbar layout
qApp->processEvents();
- QVERIFY(combo->parent() == &tb2);
+ QCOMPARE(combo->parent(), &tb2);
QVERIFY(combo->isVisible());
tb1.addAction(action);
- QVERIFY(combo->parent() == &tb2);
+ QCOMPARE(combo->parent(), &tb2);
delete action;
QVERIFY(!combo);
@@ -156,17 +171,17 @@ void tst_QWidgetAction::defaultWidget()
QPointer<QComboBox> combo1 = new QComboBox;
a->setDefaultWidget(combo1);
- QVERIFY(a->defaultWidget() == combo1);
+ QCOMPARE(a->defaultWidget(), combo1.data());
a->setDefaultWidget(combo1);
QVERIFY(combo1);
- QVERIFY(a->defaultWidget() == combo1);
+ QCOMPARE(a->defaultWidget(), combo1.data());
QPointer<QComboBox> combo2 = new QComboBox;
QVERIFY(combo1 != combo2);
a->setDefaultWidget(combo2);
QVERIFY(!combo1);
- QVERIFY(a->defaultWidget() == combo2);
+ QCOMPARE(a->defaultWidget(), combo2.data());
delete a;
QVERIFY(!combo2);
@@ -238,7 +253,7 @@ void tst_QWidgetAction::customWidget()
combos = action->createdWidgets();
QCOMPARE(combos.count(), 2);
- QVERIFY(combos.at(0) == combo1);
+ QCOMPARE(combos.at(0), combo1.data());
QPointer<QComboBox> combo2 = qobject_cast<QComboBox *>(combos.at(1));
QVERIFY(combo2);
@@ -262,7 +277,7 @@ void tst_QWidgetAction::keepOwnership()
{
QToolBar *tb = new QToolBar;
tb->addAction(action);
- QVERIFY(combo->parent() == tb);
+ QCOMPARE(combo->parent(), tb);
delete tb;
}
diff --git a/tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp b/tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp
index 8b566713f9..690ef30f71 100644
--- a/tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp
+++ b/tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp
@@ -84,13 +84,13 @@ void tst_QWidgetsVariant::constructor_invalid()
QTest::ignoreMessage(QtWarningMsg, QRegularExpression("^Trying to construct an instance of an invalid type, type id:"));
QVariant variant(static_cast<QVariant::Type>(typeId));
QVERIFY(!variant.isValid());
- QVERIFY(variant.userType() == QMetaType::UnknownType);
+ QCOMPARE(variant.userType(), int(QMetaType::UnknownType));
}
{
QTest::ignoreMessage(QtWarningMsg, QRegularExpression("^Trying to construct an instance of an invalid type, type id:"));
QVariant variant(typeId, /* copy */ 0);
QVERIFY(!variant.isValid());
- QVERIFY(variant.userType() == QMetaType::UnknownType);
+ QCOMPARE(variant.userType(), int(QMetaType::UnknownType));
}
}
@@ -208,7 +208,7 @@ void tst_QWidgetsVariant::qvariant_cast_QObject_derived()
CustomQWidget customWidget;
QWidget *widget = &customWidget;
QVariant data = QVariant::fromValue(widget);
- QVERIFY(data.userType() == qMetaTypeId<QWidget*>());
+ QCOMPARE(data.userType(), qMetaTypeId<QWidget*>());
QCOMPARE(data.value<QObject*>(), widget);
QCOMPARE(data.value<QWidget*>(), widget);
diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
index 33427788f6..dfc53c9164 100644
--- a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
+++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
@@ -212,7 +212,7 @@ void tst_QWindowContainer::testActivation()
// Under KDE (ubuntu 12.10), we experience that doing two activateWindow in a row
// does not work. The second gets ignored by the window manager, even though the
// timestamp in the xcb connection is unique for both.
- if (QGuiApplication::platformName() == "xcb")
+ if (!QGuiApplication::platformName().compare(QLatin1String("xcb"), Qt::CaseInsensitive))
QTest::qWait(100);
window->requestActivate();
@@ -327,7 +327,7 @@ void tst_QWindowContainer::testDockWidget()
QTest::qWait(1000);
dock->setFloating(false);
- QTRY_VERIFY(window->parent() == mainWindow.window()->windowHandle());
+ QTRY_COMPARE(window->parent(), mainWindow.window()->windowHandle());
}
QTEST_MAIN(tst_QWindowContainer)
diff --git a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp
index 7aa529d5ee..21369d4520 100644
--- a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp
+++ b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp
@@ -214,12 +214,12 @@ void tst_QStyle::testProxyStyle()
QProxyStyle *proxyStyle = new QProxyStyle();
QVERIFY(proxyStyle->baseStyle());
QStyle *style = QStyleFactory::create("Windows");
- QVERIFY(style->proxy() == style);
+ QCOMPARE(style->proxy(), style);
proxyStyle->setBaseStyle(style);
- QVERIFY(style->proxy() == proxyStyle);
- QVERIFY(style->parent() == proxyStyle);
- QVERIFY(proxyStyle->baseStyle() == style);
+ QCOMPARE(style->proxy(), proxyStyle);
+ QCOMPARE(style->parent(), proxyStyle);
+ QCOMPARE(proxyStyle->baseStyle(), style);
QVERIFY(testAllFunctions(proxyStyle));
proxyStyle->setBaseStyle(0);
@@ -236,7 +236,7 @@ void tst_QStyle::testProxyStyle()
QLineEdit edit;
edit.setStyle(&customStyle);
QVERIFY(!customStyle.parent());
- QVERIFY(edit.style()->pixelMetric(QStyle::PM_ButtonIconSize) == 13);
+ QCOMPARE(edit.style()->pixelMetric(QStyle::PM_ButtonIconSize), 13);
}
void tst_QStyle::drawItemPixmap()
diff --git a/tests/auto/widgets/styles/qstyleoption/tst_qstyleoption.cpp b/tests/auto/widgets/styles/qstyleoption/tst_qstyleoption.cpp
index 3c1d4c589b..2e26ba609b 100644
--- a/tests/auto/widgets/styles/qstyleoption/tst_qstyleoption.cpp
+++ b/tests/auto/widgets/styles/qstyleoption/tst_qstyleoption.cpp
@@ -43,7 +43,6 @@ class tst_QStyleOption: public QObject
private slots:
void qstyleoptioncast_data();
void qstyleoptioncast();
- void copyconstructors();
};
// Just a simple container for QStyleOption-pointer
@@ -133,21 +132,6 @@ void tst_QStyleOption::qstyleoptioncast()
delete testOption;
}
-void tst_QStyleOption::copyconstructors()
-{
- QStyleOptionFrame frame;
- QStyleOptionFrameV2 frame2(frame);
- QCOMPARE(frame2.version, int(QStyleOptionFrameV2::Version));
- frame2 = frame;
- QCOMPARE(frame2.version, int(QStyleOptionFrameV2::Version));
-
- QStyleOptionProgressBar bar;
- QStyleOptionProgressBarV2 bar2(bar);
- QCOMPARE(bar2.version, int(QStyleOptionProgressBarV2::Version));
- bar2 = bar;
- QCOMPARE(bar2.version, int(QStyleOptionProgressBarV2::Version));
-}
-
QTEST_MAIN(tst_QStyleOption)
#include "tst_qstyleoption.moc"
diff --git a/tests/auto/widgets/styles/qstylesheetstyle/BLACKLIST b/tests/auto/widgets/styles/qstylesheetstyle/BLACKLIST
new file mode 100644
index 0000000000..cf78fb47c2
--- /dev/null
+++ b/tests/auto/widgets/styles/qstylesheetstyle/BLACKLIST
@@ -0,0 +1,2 @@
+[hoverColors]
+ubuntu-14.04
diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
index 25f7715e3b..a360803c50 100644
--- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
+++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
@@ -178,45 +178,49 @@ void tst_QStyleSheetStyle::numinstances()
void tst_QStyleSheetStyle::widgetsBeforeAppStyleSheet()
{
QPushButton w1; // widget with no stylesheet
+ const QColor red(Qt::red);
+ const QColor white(Qt::white);
qApp->setStyleSheet("* { color: red; }");
- QVERIFY(COLOR(w1) == QColor("red"));
+ QCOMPARE(COLOR(w1), red);
w1.setStyleSheet("color: white");
- QVERIFY(COLOR(w1) == QColor("white"));
+ QCOMPARE(COLOR(w1), white);
qApp->setStyleSheet("");
- QVERIFY(COLOR(w1) == QColor("white"));
+ QCOMPARE(COLOR(w1), white);
w1.setStyleSheet("");
- QVERIFY(COLOR(w1) == APPCOLOR(w1));
+ QCOMPARE(COLOR(w1), APPCOLOR(w1));
}
class FriendlySpinBox : public QSpinBox { friend class tst_QStyleSheetStyle; };
void tst_QStyleSheetStyle::widgetsAfterAppStyleSheet()
{
+ const QColor red(Qt::red);
+ const QColor white(Qt::white);
qApp->setStyleSheet("* { color: red; font-size: 32pt; }");
QPushButton w1;
FriendlySpinBox spin;
- QVERIFY(COLOR(w1) == QColor("red"));
- QVERIFY(COLOR(spin) == QColor("red"));
- QVERIFY(COLOR(*spin.lineEdit()) == QColor("red"));
+ QCOMPARE(COLOR(w1), red);
+ QCOMPARE(COLOR(spin), red);
+ QCOMPARE(COLOR(*spin.lineEdit()), red);
QCOMPARE(FONTSIZE(w1), 32);
QCOMPARE(FONTSIZE(spin), 32);
QCOMPARE(FONTSIZE(*spin.lineEdit()), 32);
w1.setStyleSheet("color: white");
- QVERIFY(COLOR(w1) == QColor("white"));
- QVERIFY(COLOR(spin) == QColor("red"));
- QVERIFY(COLOR(*spin.lineEdit()) == QColor("red"));
+ QCOMPARE(COLOR(w1), white);
+ QCOMPARE(COLOR(spin), red);
+ QCOMPARE(COLOR(*spin.lineEdit()), red);
w1.setStyleSheet("");
- QVERIFY(COLOR(w1) == QColor("red"));
- QVERIFY(COLOR(spin) == QColor("red"));
- QVERIFY(COLOR(*spin.lineEdit()) == QColor("red"));
+ QCOMPARE(COLOR(w1), red);
+ QCOMPARE(COLOR(spin), red);
+ QCOMPARE(COLOR(*spin.lineEdit()), red);
w1.setStyleSheet("color: white");
- QVERIFY(COLOR(w1) == QColor("white"));
+ QCOMPARE(COLOR(w1), white);
qApp->setStyleSheet("");
- QVERIFY(COLOR(w1) == QColor("white"));
- QVERIFY(COLOR(spin) == APPCOLOR(spin));
- QVERIFY(COLOR(*spin.lineEdit()) == APPCOLOR(*spin.lineEdit()));
+ QCOMPARE(COLOR(w1), white);
+ QCOMPARE(COLOR(spin), APPCOLOR(spin));
+ QCOMPARE(COLOR(*spin.lineEdit()), APPCOLOR(*spin.lineEdit()));
w1.setStyleSheet("");
- QVERIFY(COLOR(w1) == APPCOLOR(w1));
+ QCOMPARE(COLOR(w1), APPCOLOR(w1));
// QCOMPARE(FONTSIZE(w1), APPFONTSIZE(w1)); //### task 244261
QCOMPARE(FONTSIZE(spin), APPFONTSIZE(spin));
//QCOMPARE(FONTSIZE(*spin.lineEdit()), APPFONTSIZE(*spin.lineEdit())); //### task 244261
@@ -224,121 +228,135 @@ void tst_QStyleSheetStyle::widgetsAfterAppStyleSheet()
void tst_QStyleSheetStyle::applicationStyleSheet()
{
+ const QColor red(Qt::red);
+ const QColor white(Qt::white);
QPushButton w1;
qApp->setStyleSheet("* { color: red; }");
- QVERIFY(COLOR(w1) == QColor("red"));
+ QCOMPARE(COLOR(w1), red);
qApp->setStyleSheet("* { color: white; }");
- QVERIFY(COLOR(w1) == QColor("white"));
+ QCOMPARE(COLOR(w1), white);
qApp->setStyleSheet("");
- QVERIFY(COLOR(w1) == APPCOLOR(w1));
+ QCOMPARE(COLOR(w1), APPCOLOR(w1));
qApp->setStyleSheet("* { color: red }");
- QVERIFY(COLOR(w1) == QColor("red"));
+ QCOMPARE(COLOR(w1), red);
}
void tst_QStyleSheetStyle::windowStyleSheet()
{
+ const QColor red(Qt::red);
+ const QColor white(Qt::white);
QPushButton w1;
qApp->setStyleSheet("");
w1.setStyleSheet("* { color: red; }");
- QVERIFY(COLOR(w1) == QColor("red"));
+ QCOMPARE(COLOR(w1), red);
w1.setStyleSheet("* { color: white; }");
- QVERIFY(COLOR(w1) == QColor("white"));
+ QCOMPARE(COLOR(w1), white);
w1.setStyleSheet("");
- QVERIFY(COLOR(w1) == APPCOLOR(w1));
+ QCOMPARE(COLOR(w1), APPCOLOR(w1));
w1.setStyleSheet("* { color: red }");
- QVERIFY(COLOR(w1) == QColor("red"));
+ QCOMPARE(COLOR(w1), red);
qApp->setStyleSheet("* { color: green }");
- QVERIFY(COLOR(w1) == QColor("red"));
+ QCOMPARE(COLOR(w1), red);
w1.setStyleSheet("");
- QVERIFY(COLOR(w1) == QColor("green"));
+ QCOMPARE(COLOR(w1), QColor("green"));
qApp->setStyleSheet("");
- QVERIFY(COLOR(w1) == APPCOLOR(w1));
+ QCOMPARE(COLOR(w1), APPCOLOR(w1));
}
void tst_QStyleSheetStyle::widgetStyleSheet()
{
+ const QColor blue(Qt::blue);
+ const QColor red(Qt::red);
+ const QColor white(Qt::white);
QPushButton w1;
QPushButton *pb = new QPushButton(&w1);
QPushButton &w2 = *pb;
qApp->setStyleSheet("");
w1.setStyleSheet("* { color: red }");
- QVERIFY(COLOR(w1) == QColor("red"));
- QVERIFY(COLOR(w2) == QColor("red"));
+ QCOMPARE(COLOR(w1), red);
+ QCOMPARE(COLOR(w2), red);
w2.setStyleSheet("* { color: white }");
- QVERIFY(COLOR(w2) == QColor("white"));
+ QCOMPARE(COLOR(w2), white);
w1.setStyleSheet("* { color: blue }");
- QVERIFY(COLOR(w1) == QColor("blue"));
- QVERIFY(COLOR(w2) == QColor("white"));
+ QCOMPARE(COLOR(w1), blue);
+ QCOMPARE(COLOR(w2), white);
w1.setStyleSheet("");
- QVERIFY(COLOR(w1) == APPCOLOR(w1));
- QVERIFY(COLOR(w2) == QColor("white"));
+ QCOMPARE(COLOR(w1), APPCOLOR(w1));
+ QCOMPARE(COLOR(w2), white);
w2.setStyleSheet("");
- QVERIFY(COLOR(w1) == APPCOLOR(w1));
- QVERIFY(COLOR(w2) == APPCOLOR(w2));
+ QCOMPARE(COLOR(w1), APPCOLOR(w1));
+ QCOMPARE(COLOR(w2), APPCOLOR(w2));
}
void tst_QStyleSheetStyle::reparentWithNoChildStyleSheet()
{
+ const QColor blue(Qt::blue);
+ const QColor red(Qt::red);
+ const QColor white(Qt::white);
QPushButton p1, p2;
QPushButton *pb = new QPushButton(&p1);
QPushButton &c1 = *pb; // child with no stylesheet
qApp->setStyleSheet("");
p1.setStyleSheet("* { color: red }");
- QVERIFY(COLOR(c1) == QColor("red"));
+ QCOMPARE(COLOR(c1), red);
c1.setParent(&p2);
- QVERIFY(COLOR(c1) == APPCOLOR(c1));
+ QCOMPARE(COLOR(c1), APPCOLOR(c1));
p2.setStyleSheet("* { color: white }");
- QVERIFY(COLOR(c1) == QColor("white"));
+ QCOMPARE(COLOR(c1), white);
c1.setParent(&p1);
- QVERIFY(COLOR(c1) == QColor("red"));
+ QCOMPARE(COLOR(c1), red);
qApp->setStyleSheet("* { color: blue }");
c1.setParent(0);
- QVERIFY(COLOR(c1) == QColor("blue"));
+ QCOMPARE(COLOR(c1), blue);
delete pb;
}
void tst_QStyleSheetStyle::reparentWithChildStyleSheet()
{
+ const QColor gray("gray");
+ const QColor white(Qt::white);
qApp->setStyleSheet("");
QPushButton p1, p2;
QPushButton *pb = new QPushButton(&p1);
QPushButton &c1 = *pb;
c1.setStyleSheet("background: gray");
- QVERIFY(BACKGROUND(c1) == QColor("gray"));
+ QCOMPARE(BACKGROUND(c1), gray);
c1.setParent(&p2);
- QVERIFY(BACKGROUND(c1) == QColor("gray"));
+ QCOMPARE(BACKGROUND(c1), gray);
qApp->setStyleSheet("* { color: white }");
c1.setParent(&p1);
- QVERIFY(BACKGROUND(c1) == QColor("gray"));
- QVERIFY(COLOR(c1) == QColor("white"));
+ QCOMPARE(BACKGROUND(c1), gray);
+ QCOMPARE(COLOR(c1), white);
}
void tst_QStyleSheetStyle::repolish()
{
+ const QColor red(Qt::red);
+ const QColor white(Qt::white);
qApp->setStyleSheet("");
QPushButton p1;
p1.setStyleSheet("color: red; background: white");
- QVERIFY(BACKGROUND(p1) == QColor("white"));
+ QCOMPARE(BACKGROUND(p1), white);
p1.setStyleSheet("background: white");
- QVERIFY(COLOR(p1) == APPCOLOR(p1));
+ QCOMPARE(COLOR(p1), APPCOLOR(p1));
p1.setStyleSheet("color: red");
- QVERIFY(COLOR(p1) == QColor("red"));
- QVERIFY(BACKGROUND(p1) == APPBACKGROUND(p1));
+ QCOMPARE(COLOR(p1), red);
+ QCOMPARE(BACKGROUND(p1), APPBACKGROUND(p1));
p1.setStyleSheet("");
- QVERIFY(COLOR(p1) == APPCOLOR(p1));
- QVERIFY(BACKGROUND(p1) == APPBACKGROUND(p1));
+ QCOMPARE(COLOR(p1), APPCOLOR(p1));
+ QCOMPARE(BACKGROUND(p1), APPBACKGROUND(p1));
}
void tst_QStyleSheetStyle::widgetStyle()
@@ -492,12 +510,12 @@ void tst_QStyleSheetStyle::appStyle()
QPointer<QStyle> style2 = QStyleFactory::create("Windows");
qApp->setStyle(style1);
// Basic sanity
- QVERIFY(qApp->style() == style1);
+ QCOMPARE(QApplication::style(), style1.data());
qApp->setStyle(style2);
QVERIFY(style1.isNull()); // qApp must have taken ownership and deleted it
// Setting null should not crash
qApp->setStyle(0);
- QVERIFY(qApp->style() == style2);
+ QCOMPARE(QApplication::style(), style2.data());
// Set the stylesheet
qApp->setStyleSheet("whatever");
@@ -505,7 +523,7 @@ void tst_QStyleSheetStyle::appStyle()
QVERIFY(!sss.isNull());
QCOMPARE(sss->metaObject()->className(), "QStyleSheetStyle"); // must be our proxy now
QVERIFY(!style2.isNull()); // this should exist as it is the base of the proxy
- QVERIFY(sss->baseStyle() == style2);
+ QCOMPARE(sss->baseStyle(), style2.data());
style1 = QStyleFactory::create("Windows");
qApp->setStyle(style1);
QVERIFY(style2.isNull()); // should disappear automatically
@@ -514,16 +532,16 @@ void tst_QStyleSheetStyle::appStyle()
// Update the stylesheet and check nothing changes
sss = (QStyleSheetStyle *)qApp->style();
qApp->setStyleSheet("whatever2");
- QVERIFY(qApp->style() == sss);
- QVERIFY(sss->baseStyle() == style1);
+ QCOMPARE(QApplication::style(), sss.data());
+ QCOMPARE(sss->baseStyle(), style1.data());
// Revert the stylesheet
qApp->setStyleSheet("");
QVERIFY(sss.isNull()); // should have disappeared
- QVERIFY(qApp->style() == style1);
+ QCOMPARE(QApplication::style(), style1.data());
qApp->setStyleSheet("");
- QVERIFY(qApp->style() == style1);
+ QCOMPARE(QApplication::style(), style1.data());
}
void tst_QStyleSheetStyle::dynamicProperty()
@@ -589,21 +607,24 @@ namespace ns {
void tst_QStyleSheetStyle::namespaces()
{
+ const QColor blue(Qt::blue);
+ const QColor red(Qt::red);
+ const QColor white(Qt::white);
ns::PushButton1 pb1;
qApp->setStyleSheet("ns--PushButton1 { background: white }");
- QVERIFY(BACKGROUND(pb1) == QColor("white"));
+ QCOMPARE(BACKGROUND(pb1), white);
qApp->setStyleSheet(".ns--PushButton1 { background: red }");
- QVERIFY(BACKGROUND(pb1) == QColor("red"));
+ QCOMPARE(BACKGROUND(pb1), red);
ns::PushButton2 pb2;
qApp->setStyleSheet("ns--PushButton1 { background: blue}");
- QVERIFY(BACKGROUND(pb2) == QColor("blue"));
+ QCOMPARE(BACKGROUND(pb2), blue);
qApp->setStyleSheet("ns--PushButton2 { background: magenta }");
- QVERIFY(BACKGROUND(pb2) == QColor("magenta"));
+ QCOMPARE(BACKGROUND(pb2), QColor(Qt::magenta));
qApp->setStyleSheet(".PushButtonTwo { background: white; }");
- QVERIFY(BACKGROUND(pb2) == QColor("white"));
+ QCOMPARE(BACKGROUND(pb2), white);
qApp->setStyleSheet(".PushButtonDuo { background: red; }");
- QVERIFY(BACKGROUND(pb2) == QColor("red"));
+ QCOMPARE(BACKGROUND(pb2), red);
}
void tst_QStyleSheetStyle::palettePropagation()
@@ -639,8 +660,8 @@ void tst_QStyleSheetStyle::fontPropagation()
int viewFontSize = FONTSIZE(*popup);
cb.setStyleSheet("QComboBox { font-size: 20pt; }");
- QVERIFY(FONTSIZE(cb) == 20);
- QVERIFY(FONTSIZE(*popup) == viewFontSize);
+ QCOMPARE(FONTSIZE(cb), 20);
+ QCOMPARE(FONTSIZE(*popup), viewFontSize);
QGroupBox gb;
QPushButton *push = new QPushButton(&gb);
QPushButton &pb = *push;
@@ -648,25 +669,25 @@ void tst_QStyleSheetStyle::fontPropagation()
int gbFontSize = FONTSIZE(gb);
gb.setStyleSheet("QGroupBox { font-size: 20pt }");
- QVERIFY(FONTSIZE(gb) == 20);
+ QCOMPARE(FONTSIZE(gb), 20);
QVERIFY(FONTSIZE(pb) == buttonFontSize); // font does not propagate
gb.setStyleSheet("QGroupBox * { font-size: 20pt; }");
- QVERIFY(FONTSIZE(gb) == gbFontSize);
- QVERIFY(FONTSIZE(pb) == 20);
+ QCOMPARE(FONTSIZE(gb), gbFontSize);
+ QCOMPARE(FONTSIZE(pb), 20);
QWidget window;
window.setStyleSheet("* { font-size: 10pt }");
pb.setParent(&window);
QCOMPARE(FONTSIZE(pb), 10);
window.setStyleSheet("");
- QVERIFY(FONTSIZE(pb) == buttonFontSize);
+ QCOMPARE(FONTSIZE(pb), buttonFontSize);
QTabWidget tw;
tw.setStyleSheet("QTabWidget { font-size: 20pt; }");
- QVERIFY(FONTSIZE(tw) == 20);
+ QCOMPARE(FONTSIZE(tw), 20);
QWidget *child = tw.findChild<QWidget *>("qt_tabwidget_tabbar");
QVERIFY2(child, "QTabWidget did not contain a widget named \"qt_tabwidget_tabbar\"");
- QVERIFY(FONTSIZE(*child) == 20);
+ QCOMPARE(FONTSIZE(*child), 20);
}
void tst_QStyleSheetStyle::onWidgetDestroyed()
@@ -1009,6 +1030,8 @@ void tst_QStyleSheetStyle::tabAlignement()
void tst_QStyleSheetStyle::attributesList()
{
+ const QColor blue(Qt::blue);
+ const QColor red(Qt::red);
QWidget w;
QPushButton *p1=new QPushButton(&w);
QPushButton *p2=new QPushButton(&w);
@@ -1019,10 +1042,10 @@ void tst_QStyleSheetStyle::attributesList()
p3->setProperty("prop", QStringList() << "foo" << "bar");
w.setStyleSheet(" QPushButton{ background-color:blue; } QPushButton[prop~=red] { background-color:red; }");
- QCOMPARE(BACKGROUND(*p1) , QColor("red"));
- QCOMPARE(BACKGROUND(*p2) , QColor("red"));
- QCOMPARE(BACKGROUND(*p3) , QColor("blue"));
- QCOMPARE(BACKGROUND(*p4) , QColor("blue"));
+ QCOMPARE(BACKGROUND(*p1) , red);
+ QCOMPARE(BACKGROUND(*p2) , red);
+ QCOMPARE(BACKGROUND(*p3) , blue);
+ QCOMPARE(BACKGROUND(*p4) , blue);
}
void tst_QStyleSheetStyle::minmaxSizes()
@@ -1065,6 +1088,7 @@ void tst_QStyleSheetStyle::minmaxSizes()
void tst_QStyleSheetStyle::task206238_twice()
{
+ const QColor red(Qt::red);
QMainWindow w;
QTabWidget* tw = new QTabWidget;
tw->addTab(new QLabel("foo"), "test");
@@ -1073,12 +1097,12 @@ void tst_QStyleSheetStyle::task206238_twice()
centerOnScreen(&w);
w.show();
QTest::qWait(20);
- QCOMPARE(BACKGROUND(w) , QColor("red"));
- QCOMPARE(BACKGROUND(*tw), QColor("red"));
+ QCOMPARE(BACKGROUND(w) , red);
+ QCOMPARE(BACKGROUND(*tw), red);
w.setStyleSheet("background: red;");
QTest::qWait(20);
- QCOMPARE(BACKGROUND(w) , QColor("red"));
- QCOMPARE(BACKGROUND(*tw), QColor("red"));
+ QCOMPARE(BACKGROUND(w) , red);
+ QCOMPARE(BACKGROUND(*tw), red);
}
void tst_QStyleSheetStyle::transparent()
@@ -1277,9 +1301,9 @@ void tst_QStyleSheetStyle::proxyStyle()
QTest::qWait(100);
// Test for QTBUG-7198 - style sheet overrides custom element size
- QStyleOptionViewItemV4 opt;
+ QStyleOptionViewItem opt;
opt.initFrom(w);
- opt.features |= QStyleOptionViewItemV2::HasCheckIndicator;
+ opt.features |= QStyleOptionViewItem::HasCheckIndicator;
QVERIFY(pb5->style()->subElementRect(QStyle::SE_ItemViewItemCheckIndicator,
&opt, pb5).width() == 3);
delete w;
diff --git a/tests/auto/widgets/util/qcompleter/BLACKLIST b/tests/auto/widgets/util/qcompleter/BLACKLIST
index ffbcc94a1f..fdc424b6ac 100644
--- a/tests/auto/widgets/util/qcompleter/BLACKLIST
+++ b/tests/auto/widgets/util/qcompleter/BLACKLIST
@@ -1,2 +1,2 @@
[QTBUG_14292_filesystem]
-ubuntu-14.04
+linux
diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
index dbfeda8104..e8ac9aa5d2 100644
--- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
@@ -1043,9 +1043,9 @@ void tst_QCompleter::setters()
QAbstractItemModel *oldModel = completer->model();
completer->setModel(dirModel);
QVERIFY(completer->popup()->model() != oldModel);
- QVERIFY(completer->popup()->model() == completer->completionModel());
+ QCOMPARE(completer->popup()->model(), completer->completionModel());
completer->setPopup(new QListView);
- QVERIFY(completer->popup()->model() == completer->completionModel());
+ QCOMPARE(completer->popup()->model(), completer->completionModel());
completer->setModel(new QStringListModel(completer));
QVERIFY(dirModel == 0); // must have been deleted
@@ -1062,7 +1062,7 @@ void tst_QCompleter::modelDeletion()
QStringListModel *listModel = new QStringListModel(list);
completer->setCompletionPrefix("i");
completer->setModel(listModel);
- QVERIFY(completer->completionCount() == 3);
+ QCOMPARE(completer->completionCount(), 3);
QScopedPointer<QListView> view(new QListView);
view->setModel(completer->completionModel());
delete listModel;
@@ -1070,8 +1070,8 @@ void tst_QCompleter::modelDeletion()
view->show();
qApp->processEvents();
view.reset();
- QVERIFY(completer->completionCount() == 0);
- QVERIFY(completer->currentRow() == -1);
+ QCOMPARE(completer->completionCount(), 0);
+ QCOMPARE(completer->currentRow(), -1);
}
void tst_QCompleter::multipleWidgets()
@@ -1098,7 +1098,7 @@ void tst_QCompleter::multipleWidgets()
window.activateWindow();
QApplication::setActiveWindow(&window);
QTest::qWait(50);
- QTRY_VERIFY(qApp->focusWidget() == comboBox);
+ QTRY_COMPARE(QApplication::focusWidget(), comboBox);
comboBox->lineEdit()->setText("it");
QCOMPARE(comboBox->currentText(), QString("it")); // should not complete with setText
QTest::keyPress(comboBox, 'e');
@@ -1111,7 +1111,7 @@ void tst_QCompleter::multipleWidgets()
lineEdit->show();
lineEdit->setFocus();
QTest::qWait(50);
- QTRY_VERIFY(qApp->focusWidget() == lineEdit);
+ QTRY_COMPARE(QApplication::focusWidget(), lineEdit);
lineEdit->setText("it");
QCOMPARE(lineEdit->text(), QString("it")); // should not completer with setText
QCOMPARE(comboBox->currentText(), QString("")); // combo box text must not change!
@@ -1148,13 +1148,13 @@ void tst_QCompleter::focusIn()
lineEdit2->show();
comboBox->setFocus();
- QTRY_VERIFY(completer.widget() == comboBox);
+ QTRY_COMPARE(completer.widget(), comboBox);
lineEdit->setFocus();
- QTRY_VERIFY(completer.widget() == lineEdit);
+ QTRY_COMPARE(completer.widget(), lineEdit);
comboBox->setFocus();
- QTRY_VERIFY(completer.widget() == comboBox);
+ QTRY_COMPARE(completer.widget(), comboBox);
lineEdit2->setFocus();
- QTRY_VERIFY(completer.widget() == comboBox);
+ QTRY_COMPARE(completer.widget(), comboBox);
}
void tst_QCompleter::dynamicSortOrder()
diff --git a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp
index d2e88a1656..58a655321c 100644
--- a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp
+++ b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp
@@ -297,7 +297,7 @@ void tst_QScroller::staticScrollers()
QScrollerProperties sp2 = QScroller::scroller(o2)->scrollerProperties();
// default properties should be the same
- QVERIFY(sp1 == sp2);
+ QCOMPARE(sp1, sp2);
QCOMPARE(QScroller::scroller(o1)->scrollerProperties(), sp1);
diff --git a/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp b/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp
index 7ea63911ae..05511a17a1 100644
--- a/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp
+++ b/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp
@@ -136,7 +136,7 @@ void tst_QSystemTrayIcon::lastWindowClosed()
QTimer::singleShot(2500, &window, SLOT(close()));
QTimer::singleShot(20000, qApp, SLOT(quit())); // in case the test fails
qApp->exec();
- QVERIFY(spy.count() == 1);
+ QCOMPARE(spy.count(), 1);
}
QTEST_MAIN(tst_QSystemTrayIcon)
diff --git a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp b/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp
index 781adeedad..9f03e9b3a0 100644
--- a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp
+++ b/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp
@@ -36,7 +36,22 @@
#include <QAction>
// Temporarily disabling IRIX due to build issuues with GCC
-#if !defined(__sgi) || defined(__sgi) && !defined(__GNUC__)
+#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
@@ -645,22 +660,7 @@ void tst_QUndoGroup::commandTextFormat()
qApp->removeTranslator(&translator);
#endif
}
-
-#else
-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++"); }
-};
-#endif
+#endif // !(SGI && GCC)
QTEST_MAIN(tst_QUndoGroup)
diff --git a/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
index a633ba0cf0..43d6912c6e 100644
--- a/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+++ b/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
@@ -283,9 +283,9 @@ void tst_QAbstractButton::setAutoRepeat()
QTest::qWait(REPEAT_DELAY);
QVERIFY(testWidget->isDown());
QTest::keyRelease(testWidget, Qt::Key_Space);
- QVERIFY(release_count == press_count);
- QVERIFY(toggle_count == 0);
- QVERIFY(press_count == click_count);
+ QCOMPARE(release_count, press_count);
+ QCOMPARE(toggle_count, uint(0));
+ QCOMPARE(press_count, click_count);
QVERIFY(click_count > 1);
break;
case 4:
diff --git a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp
index df69063540..5dec6224ca 100644
--- a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp
+++ b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp
@@ -324,13 +324,13 @@ void tst_QButtonGroup::testSignals()
int expectedId = -2;
- QVERIFY(clickedIdSpy.takeFirst().at(0).toInt() == expectedId);
+ QCOMPARE(clickedIdSpy.takeFirst().at(0).toInt(), expectedId);
QCOMPARE(pressedSpy.count(), 1);
QCOMPARE(pressedIdSpy.count(), 1);
- QVERIFY(pressedIdSpy.takeFirst().at(0).toInt() == expectedId);
+ QCOMPARE(pressedIdSpy.takeFirst().at(0).toInt(), expectedId);
QCOMPARE(releasedSpy.count(), 1);
QCOMPARE(releasedIdSpy.count(), 1);
- QVERIFY(releasedIdSpy.takeFirst().at(0).toInt() == expectedId);
+ QCOMPARE(releasedIdSpy.takeFirst().at(0).toInt(), expectedId);
clickedSpy.clear();
clickedIdSpy.clear();
@@ -344,13 +344,13 @@ void tst_QButtonGroup::testSignals()
QCOMPARE(clickedSpy.count(), 1);
QCOMPARE(clickedIdSpy.count(), 1);
- QVERIFY(clickedIdSpy.takeFirst().at(0).toInt() == 23);
+ QCOMPARE(clickedIdSpy.takeFirst().at(0).toInt(), 23);
QCOMPARE(pressedSpy.count(), 1);
QCOMPARE(pressedIdSpy.count(), 1);
- QVERIFY(pressedIdSpy.takeFirst().at(0).toInt() == 23);
+ QCOMPARE(pressedIdSpy.takeFirst().at(0).toInt(), 23);
QCOMPARE(releasedSpy.count(), 1);
QCOMPARE(releasedIdSpy.count(), 1);
- QVERIFY(releasedIdSpy.takeFirst().at(0).toInt() == 23);
+ QCOMPARE(releasedIdSpy.takeFirst().at(0).toInt(), 23);
QSignalSpy toggledSpy(&buttons, SIGNAL(buttonToggled(QAbstractButton*, bool)));
@@ -427,25 +427,25 @@ void tst_QButtonGroup::checkedButton()
buttons.addButton(&pb1);
buttons.addButton(&pb2, 23);
- QVERIFY(buttons.checkedButton() == 0);
+ QVERIFY(!buttons.checkedButton());
pb1.setChecked(true);
- QVERIFY(buttons.checkedButton() == &pb1);
+ QCOMPARE(buttons.checkedButton(), &pb1);
pb2.setChecked(true);
- QVERIFY(buttons.checkedButton() == &pb2);
+ QCOMPARE(buttons.checkedButton(), &pb2);
pb2.setChecked(false);
- QVERIFY(buttons.checkedButton() == &pb1);
+ QCOMPARE(buttons.checkedButton(), &pb1);
pb1.setChecked(false);
- QVERIFY(buttons.checkedButton() == 0);
+ QVERIFY(!buttons.checkedButton());
buttons.setExclusive(true);
- QVERIFY(buttons.checkedButton() == 0);
+ QVERIFY(!buttons.checkedButton());
pb1.setChecked(true);
- QVERIFY(buttons.checkedButton() == &pb1);
+ QCOMPARE(buttons.checkedButton(), &pb1);
pb2.setChecked(true);
- QVERIFY(buttons.checkedButton() == &pb2);
+ QCOMPARE(buttons.checkedButton(), &pb2);
// checked button cannot be unchecked
pb2.setChecked(false);
- QVERIFY(buttons.checkedButton() == &pb2);
+ QCOMPARE(buttons.checkedButton(), &pb2);
}
class task209485_ButtonDeleter : public QObject
@@ -523,9 +523,9 @@ void tst_QButtonGroup::autoIncrementId()
radio1->setChecked(true);
- QVERIFY(buttons->id(radio1) == -2);
- QVERIFY(buttons->id(radio2) == -3);
- QVERIFY(buttons->id(radio3) == -4);
+ QCOMPARE(buttons->id(radio1), -2);
+ QCOMPARE(buttons->id(radio2), -3);
+ QCOMPARE(buttons->id(radio3), -4);
dlg.show();
}
diff --git a/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp b/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp
index e76e11fc67..5696382fab 100644
--- a/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp
+++ b/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp
@@ -83,9 +83,7 @@ private:
uint press_count;
uint release_count;
int cur_state;
- uint tmp;
QCheckBox *testWidget;
- uint tmp2;
};
tst_QCheckBox::tst_QCheckBox()
@@ -326,7 +324,7 @@ void tst_QCheckBox::isToggleButton()
void tst_QCheckBox::foregroundRole()
{
- QVERIFY(testWidget->foregroundRole() == QPalette::WindowText);
+ QCOMPARE(testWidget->foregroundRole(), QPalette::WindowText);
}
void tst_QCheckBox::minimumSizeHint()
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index 00636e50a8..ae516639a6 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 keyboardSelection();
void setCustomModelAndView();
void updateDelegateOnEditableChange();
+ void respectChangedOwnershipOfItemView();
void task_QTBUG_39088_inputMethodHints();
void task_QTBUG_49831_scrollerNotActivated();
};
@@ -454,7 +455,7 @@ void tst_QComboBox::setPalette()
for (int i = 0; i < comboChildren.size(); ++i) {
QObject *o = comboChildren.at(i);
if (o->isWidgetType()) {
- QVERIFY(((QWidget*)o)->palette() == pal);
+ QCOMPARE(((QWidget*)o)->palette(), pal);
}
}
@@ -463,12 +464,12 @@ void tst_QComboBox::setPalette()
//Setting it on the lineedit should be separate form the combo
testWidget->lineEdit()->setPalette(pal);
QVERIFY(testWidget->palette() != pal);
- QVERIFY(testWidget->lineEdit()->palette() == pal);
+ QCOMPARE(testWidget->lineEdit()->palette(), pal);
pal.setColor(QPalette::Base, Qt::green);
//Setting it on the combo directly should override lineedit
testWidget->setPalette(pal);
- QVERIFY(testWidget->palette() == pal);
- QVERIFY(testWidget->lineEdit()->palette() == pal);
+ QCOMPARE(testWidget->palette(), pal);
+ QCOMPARE(testWidget->lineEdit()->palette(), pal);
}
void tst_QComboBox::sizeAdjustPolicy()
@@ -479,7 +480,7 @@ void tst_QComboBox::sizeAdjustPolicy()
QComboBox *testWidget = topLevel.comboBox();
// test that adding new items will not change the sizehint for AdjustToContentsOnFirstShow
QVERIFY(!testWidget->count());
- QVERIFY(testWidget->sizeAdjustPolicy() == QComboBox::AdjustToContentsOnFirstShow);
+ QCOMPARE(testWidget->sizeAdjustPolicy(), QComboBox::AdjustToContentsOnFirstShow);
QVERIFY(testWidget->isVisible());
QSize firstShow = testWidget->sizeHint();
testWidget->addItem("normal item");
@@ -752,7 +753,7 @@ void tst_QComboBox::insertPolicy()
// First check that there is the right number of entries, or
// we may unwittingly pass
- QVERIFY((int)result.count() == testWidget->count());
+ QCOMPARE((int)result.count(), testWidget->count());
// No need to compare if there are no strings to compare
if (result.count() > 0) {
@@ -797,7 +798,7 @@ void tst_QComboBox::virtualAutocompletion()
QApplication::sendEvent(testWidget, &kr1);
qApp->processEvents(); // Process events to trigger autocompletion
- QTRY_VERIFY(testWidget->currentIndex() == 1);
+ QTRY_COMPARE(testWidget->currentIndex(), 1);
QKeyEvent kp2(QEvent::KeyPress, Qt::Key_O, 0, "o");
QKeyEvent kr2(QEvent::KeyRelease, Qt::Key_O, 0, "o");
@@ -846,7 +847,7 @@ void tst_QComboBox::autoCompletionCaseSensitivity()
testWidget->clearEditText();
QSignalSpy spyReturn(testWidget, SIGNAL(activated(int)));
testWidget->setAutoCompletionCaseSensitivity(Qt::CaseInsensitive);
- QVERIFY(testWidget->autoCompletionCaseSensitivity() == Qt::CaseInsensitive);
+ QCOMPARE(testWidget->autoCompletionCaseSensitivity(), Qt::CaseInsensitive);
QTest::keyClick(testWidget->lineEdit(), Qt::Key_A);
qApp->processEvents();
@@ -880,7 +881,7 @@ void tst_QComboBox::autoCompletionCaseSensitivity()
// case sensitive
testWidget->clearEditText();
testWidget->setAutoCompletionCaseSensitivity(Qt::CaseSensitive);
- QVERIFY(testWidget->autoCompletionCaseSensitivity() == Qt::CaseSensitive);
+ QCOMPARE(testWidget->autoCompletionCaseSensitivity(), Qt::CaseSensitive);
QTest::keyClick(testWidget->lineEdit(), Qt::Key_A);
qApp->processEvents();
QCOMPARE(testWidget->currentText(), QString("aww"));
@@ -1378,7 +1379,7 @@ void tst_QComboBox::textpixmapdata()
QCOMPARE(icon.cacheKey(), icons.at(i).cacheKey());
QPixmap original = icons.at(i).pixmap(1024);
QPixmap pixmap = icon.pixmap(1024);
- QVERIFY(pixmap.toImage() == original.toImage());
+ QCOMPARE(pixmap.toImage(), original.toImage());
}
for (int i = 0; i<text.count(); ++i) {
@@ -1612,7 +1613,7 @@ void tst_QComboBox::setModel()
QCOMPARE(box.currentIndex(), 0);
QVERIFY(box.model() != oldModel);
QVERIFY(box.rootModelIndex() != rootModelIndex);
- QVERIFY(box.rootModelIndex() == QModelIndex());
+ QCOMPARE(box.rootModelIndex(), QModelIndex());
// check that setting the very same model doesn't move the current item
box.setCurrentIndex(1);
@@ -3185,6 +3186,27 @@ void tst_QComboBox::task_QTBUG_39088_inputMethodHints()
QCOMPARE(box.lineEdit()->inputMethodHints(), Qt::ImhNoPredictiveText);
}
+void tst_QComboBox::respectChangedOwnershipOfItemView()
+{
+ QComboBox box1;
+ QComboBox box2;
+ QTableView *v1 = new QTableView;
+ box1.setView(v1);
+
+ QSignalSpy spy1(v1, SIGNAL(destroyed()));
+ box2.setView(v1); // Ownership should now be transferred to box2
+
+
+ QTableView *v2 = new QTableView(&box1);
+ box1.setView(v2); // Here we do not expect v1 to be deleted
+ QApplication::processEvents();
+ QCOMPARE(spy1.count(), 0);
+
+ QSignalSpy spy2(v2, SIGNAL(destroyed()));
+ box1.setView(v1);
+ QCOMPARE(spy2.count(), 1);
+}
+
void tst_QComboBox::task_QTBUG_49831_scrollerNotActivated()
{
QStringList modelData;
diff --git a/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
index d8cb7c01ad..a57553097a 100644
--- a/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+++ b/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
@@ -98,11 +98,11 @@ void tst_QCommandLinkButton::getSetCheck()
QString text("mytext");
QVERIFY(obj1.description().isEmpty());
obj1.setDescription(text);
- QVERIFY(obj1.description() == text);
+ QCOMPARE(obj1.description(), text);
QVERIFY(obj1.text().isEmpty());
obj1.setText(text);
- QVERIFY(obj1.text() == text);
+ QCOMPARE(obj1.text(), text);
QMenu *var1 = new QMenu;
obj1.setMenu(var1);
@@ -236,8 +236,8 @@ void tst_QCommandLinkButton::setAutoRepeat()
QVERIFY( testWidget->isDown() );
QVERIFY( toggle_count == 0 );
QTest::keyRelease( testWidget, Qt::Key_Space );
- QVERIFY(press_count == release_count);
- QVERIFY(release_count == click_count);
+ QCOMPARE(press_count, release_count);
+ QCOMPARE(release_count, click_count);
QVERIFY(press_count > 1);
// #### shouldn't I check here to see if multiple signals have been fired???
diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
index c9ae60dd76..d41398046f 100644
--- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
+++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
@@ -285,6 +285,7 @@ typedef QList<Qt::Key> KeyList;
void tst_QDateTimeEdit::getSetCheck()
{
QDateTimeEdit obj1;
+ QCOMPARE(obj1.inputMethodQuery(Qt::ImHints), QVariant(int(Qt::ImhPreferNumbers)));
obj1.setDisplayFormat("dd/MM/yyyy hh:mm:ss.zzz d/M/yy h:m:s.z AP");
// Section QDateTimeEdit::currentSection()
// void QDateTimeEdit::setCurrentSection(Section)
@@ -306,6 +307,11 @@ void tst_QDateTimeEdit::getSetCheck()
QCOMPARE(QDateTimeEdit::MonthSection, obj1.currentSection());
obj1.setCurrentSection(QDateTimeEdit::YearSection);
QCOMPARE(QDateTimeEdit::YearSection, obj1.currentSection());
+
+ QDateEdit dateEdit;
+ QCOMPARE(dateEdit.inputMethodQuery(Qt::ImHints), QVariant(int(Qt::ImhPreferNumbers)));
+ QTimeEdit timeEdit;
+ QCOMPARE(timeEdit.inputMethodQuery(Qt::ImHints), QVariant(int(Qt::ImhPreferNumbers)));
}
tst_QDateTimeEdit::tst_QDateTimeEdit()
@@ -2416,7 +2422,7 @@ void tst_QDateTimeEdit::displayedSections()
QFETCH(uint, section);
testWidget->setDisplayFormat(format);
- QVERIFY((QDateTimeEdit::Section)section == testWidget->displayedSections());
+ QCOMPARE(QDateTimeEdit::Sections(section), testWidget->displayedSections());
}
void tst_QDateTimeEdit::currentSection_data()
@@ -2460,7 +2466,7 @@ void tst_QDateTimeEdit::currentSection()
if ((QDateTimeEdit::Section)section == QDateTimeEdit::NoSection)
testWidget->setCurrentSection(QDateTimeEdit::YearSection); // Ensure it's not reset (see above)
testWidget->setCurrentSection((QDateTimeEdit::Section)section);
- QVERIFY((QDateTimeEdit::Section)currentSection == testWidget->currentSection());
+ QCOMPARE((QDateTimeEdit::Section)currentSection, testWidget->currentSection());
}
void tst_QDateTimeEdit::readOnly()
@@ -2825,7 +2831,7 @@ void tst_QDateTimeEdit::calendarPopup()
rect = style->subControlRect(QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxArrow, &timeEdit);
QTest::mouseClick(&timeEdit, Qt::LeftButton, 0, QPoint(rect.left()+rect.width()/2, rect.top()+rect.height()/2));
QWidget *wid2 = timeEdit.findChild<QWidget *>("qt_datetimedit_calendar");
- QVERIFY(wid2 == 0);
+ QVERIFY(!wid2);
timeEdit.hide();
@@ -2839,7 +2845,7 @@ void tst_QDateTimeEdit::calendarPopup()
rect = style->subControlRect(QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxArrow, &dateEdit);
QTest::mouseClick(&dateEdit, Qt::LeftButton, 0, QPoint(rect.left()+rect.width()/2, rect.top()+rect.height()/2));
QWidget *wid3 = dateEdit.findChild<QWidget *>("qt_datetimedit_calendar");
- QVERIFY(wid3 == 0);
+ QVERIFY(!wid3);
dateEdit.hide();
}
diff --git a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp
index 38b473e5ae..32412afcd5 100644
--- a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp
+++ b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp
@@ -132,12 +132,12 @@ void tst_QDialogButtonBox::layoutReuse()
QDialogButtonBox *box = new QDialogButtonBox(QDialogButtonBox::Ok);
QPointer<QLayout> layout = box->layout();
box->setCenterButtons(!box->centerButtons());
- QVERIFY(layout == box->layout());
+ QCOMPARE(layout.data(), box->layout());
QEvent event(QEvent::StyleChange);
QApplication::sendEvent(box, &event);
- QVERIFY(layout == box->layout());
+ QCOMPARE(layout.data(), box->layout());
box->setOrientation(box->orientation() == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal);
- QVERIFY(layout == 0);
+ QVERIFY(layout.isNull());
QVERIFY(layout != box->layout());
delete box;
}
diff --git a/tests/auto/widgets/widgets/qdockwidget/BLACKLIST b/tests/auto/widgets/widgets/qdockwidget/BLACKLIST
new file mode 100644
index 0000000000..60adfb9f4b
--- /dev/null
+++ b/tests/auto/widgets/widgets/qdockwidget/BLACKLIST
@@ -0,0 +1,2 @@
+[restoreDockWidget]
+ubuntu-14.04
diff --git a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
index 2bbc2e05b7..713dc6b9b8 100644
--- a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
+++ b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
@@ -40,6 +40,7 @@
#include <qdockwidget.h>
#include <qmainwindow.h>
#include <qlineedit.h>
+#include <qtabbar.h>
#include <QDesktopWidget>
#include <QtGui/QPainter>
#include "private/qdockwidget_p.h"
@@ -68,6 +69,7 @@ private slots:
void allowedAreas();
void toggleViewAction();
void visibilityChanged();
+ void updateTabBarOnVisibilityChanged();
void dockLocationChanged();
void setTitleBarWidget();
void titleBarDoubleClick();
@@ -120,7 +122,7 @@ void tst_QDockWidget::widget()
{
{
QDockWidget dw;
- QVERIFY(dw.widget() == 0);
+ QVERIFY(!dw.widget());
}
{
@@ -130,32 +132,32 @@ void tst_QDockWidget::widget()
dw.setWidget(w1);
QVERIFY(dw.widget() != 0);
- QVERIFY(dw.widget() == w1);
+ QCOMPARE(dw.widget(), w1);
QCOMPARE(w1->parentWidget(), (QWidget*)&dw);
dw.setWidget(0);
- QVERIFY(dw.widget() == 0);
+ QVERIFY(!dw.widget());
dw.setWidget(w2);
QVERIFY(dw.widget() != 0);
- QVERIFY(dw.widget() == w2);
+ QCOMPARE(dw.widget(), w2);
QCOMPARE(w2->parentWidget(), (QWidget*)&dw);
dw.setWidget(0);
- QVERIFY(dw.widget() == 0);
+ QVERIFY(!dw.widget());
dw.setWidget(w1);
QVERIFY(dw.widget() != 0);
- QVERIFY(dw.widget() == w1);
+ QCOMPARE(dw.widget(), w1);
QCOMPARE(w1->parentWidget(), (QWidget*)&dw);
dw.setWidget(w2);
QVERIFY(dw.widget() != 0);
- QVERIFY(dw.widget() == w2);
+ QCOMPARE(dw.widget(), w2);
QCOMPARE(w2->parentWidget(), (QWidget*)&dw);
dw.setWidget(0);
- QVERIFY(dw.widget() == 0);
+ QVERIFY(!dw.widget());
}
{
@@ -165,37 +167,37 @@ void tst_QDockWidget::widget()
dw.setWidget(w1);
QVERIFY(dw.widget() != 0);
- QVERIFY(dw.widget() == w1);
+ QCOMPARE(dw.widget(), w1);
QCOMPARE(w1->parentWidget(), (QWidget*)&dw);
w1->setParent(0);
- QVERIFY(dw.widget() == 0);
+ QVERIFY(!dw.widget());
dw.setWidget(w2);
QVERIFY(dw.widget() != 0);
- QVERIFY(dw.widget() == w2);
+ QCOMPARE(dw.widget(), w2);
QCOMPARE(w2->parentWidget(), (QWidget*)&dw);
w2->setParent(0);
- QVERIFY(dw.widget() == 0);
+ QVERIFY(!dw.widget());
dw.setWidget(w1);
QVERIFY(dw.widget() != 0);
- QVERIFY(dw.widget() == w1);
+ QCOMPARE(dw.widget(), w1);
QCOMPARE(w1->parentWidget(), (QWidget*)&dw);
dw.setWidget(w2);
QVERIFY(dw.widget() != 0);
- QVERIFY(dw.widget() == w2);
+ QCOMPARE(dw.widget(), w2);
QCOMPARE(w2->parentWidget(), (QWidget*)&dw);
w1->setParent(0);
QVERIFY(dw.widget() != 0);
- QVERIFY(dw.widget() == w2);
+ QCOMPARE(dw.widget(), w2);
QCOMPARE(w2->parentWidget(), (QWidget*)&dw);
w2->setParent(0);
- QVERIFY(dw.widget() == 0);
+ QVERIFY(!dw.widget());
delete w1;
delete w2;
}
@@ -586,6 +588,44 @@ void tst_QDockWidget::visibilityChanged()
QCOMPARE(spy.at(0).at(0).toBool(), true);
}
+void tst_QDockWidget::updateTabBarOnVisibilityChanged()
+{
+ // QTBUG49045: Populate tabified dock area with 4 widgets, set the tab
+ // index to 2 (dw2), hide dw0, dw1 and check that the tab index is 0 (dw3).
+ QMainWindow mw;
+ mw.setMinimumSize(400, 400);
+ mw.setWindowTitle(QTest::currentTestFunction());
+ QDockWidget *dw0 = new QDockWidget("d1", &mw);
+ dw0->setAllowedAreas(Qt::LeftDockWidgetArea);
+ mw.addDockWidget(Qt::LeftDockWidgetArea, dw0);
+ QDockWidget *dw1 = new QDockWidget("d2", &mw);
+ dw1->setAllowedAreas(Qt::LeftDockWidgetArea);
+ mw.addDockWidget(Qt::LeftDockWidgetArea, dw1);
+ QDockWidget *dw2 = new QDockWidget("d3", &mw);
+ dw2->setAllowedAreas(Qt::LeftDockWidgetArea);
+ mw.addDockWidget(Qt::LeftDockWidgetArea, dw2);
+ QDockWidget *dw3 = new QDockWidget("d4", &mw);
+ dw3->setAllowedAreas(Qt::LeftDockWidgetArea);
+ mw.addDockWidget(Qt::LeftDockWidgetArea, dw3);
+ mw.tabifyDockWidget(dw0, dw1);
+ mw.tabifyDockWidget(dw1, dw2);
+ mw.tabifyDockWidget(dw2, dw3);
+
+ QTabBar *tabBar = mw.findChild<QTabBar *>();
+ QVERIFY(tabBar);
+ tabBar->setCurrentIndex(2);
+
+ mw.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&mw));
+
+ QCOMPARE(tabBar->currentIndex(), 2);
+
+ dw0->hide();
+ dw1->hide();
+ QTRY_COMPARE(tabBar->count(), 2);
+ QCOMPARE(tabBar->currentIndex(), 0);
+}
+
Q_DECLARE_METATYPE(Qt::DockWidgetArea)
void tst_QDockWidget::dockLocationChanged()
@@ -721,6 +761,9 @@ void tst_QDockWidget::restoreDockWidget()
{
QByteArray geometry;
QByteArray state;
+
+ const bool isXcb = !QGuiApplication::platformName().compare("xcb", Qt::CaseInsensitive);
+
const QString name = QStringLiteral("main");
const QRect availableGeometry = QApplication::desktop()->availableGeometry();
const QSize size = availableGeometry.size() / 5;
@@ -745,11 +788,22 @@ void tst_QDockWidget::restoreDockWidget()
QVERIFY(dock->isFloating());
state = saveWindow.saveState();
geometry = saveWindow.saveGeometry();
+
+ // QTBUG-49832: Delete and recreate the dock; it should be restored to the same position.
+ delete dock;
+ dock = createTestDock(saveWindow);
+ QVERIFY(saveWindow.restoreDockWidget(dock));
+ dock->show();
+ QVERIFY(QTest::qWaitForWindowExposed(dock));
+ QTRY_VERIFY(dock->isFloating());
+ if (!isXcb) // Avoid Window manager positioning issues
+ QTRY_COMPARE(dock->pos(), dockPos);
}
QVERIFY(!geometry.isEmpty());
QVERIFY(!state.isEmpty());
+ // QTBUG-45780: Completely recreate the dock widget from the saved state.
{
QMainWindow restoreWindow;
restoreWindow.setObjectName(name);
@@ -764,7 +818,7 @@ void tst_QDockWidget::restoreDockWidget()
restoreWindow.show();
QVERIFY(QTest::qWaitForWindowExposed(&restoreWindow));
QTRY_VERIFY(dock->isFloating());
- if (!QGuiApplication::platformName().compare("xcb", Qt::CaseInsensitive))
+ if (isXcb)
QSKIP("Skip due to Window manager positioning issues", Abort);
QTRY_COMPARE(dock->pos(), dockPos);
}
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 a75833c89c..00447760ec 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 a75833c89c..00447760ec 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 a75833c89c..00447760ec 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 a75833c89c..00447760ec 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 a75833c89c..00447760ec 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 a75833c89c..00447760ec 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 a75833c89c..00447760ec 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 a75833c89c..00447760ec 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 a75833c89c..00447760ec 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 d656ac56f0..4c809a2c80 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 d656ac56f0..4c809a2c80 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 d656ac56f0..4c809a2c80 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 d656ac56f0..4c809a2c80 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 d656ac56f0..4c809a2c80 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 d656ac56f0..4c809a2c80 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 d656ac56f0..4c809a2c80 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 d656ac56f0..4c809a2c80 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 d656ac56f0..4c809a2c80 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/qlabel/tst_qlabel.cpp b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
index 1d995b5eea..d76dbf6b46 100644
--- a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
+++ b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
@@ -47,13 +47,12 @@
class Widget : public QWidget
{
+ Q_OBJECT
public:
- Widget() { }
-
QList<QEvent::Type> events;
protected:
- bool event(QEvent *ev) {
+ bool event(QEvent *ev) Q_DECL_OVERRIDE {
events.append(ev->type());
return QWidget::event(ev);
}
@@ -62,19 +61,14 @@ protected:
class tst_QLabel : public QObject
{
-Q_OBJECT
-
-public:
- tst_QLabel();
- virtual ~tst_QLabel();
-
+ Q_OBJECT
-public slots:
+private Q_SLOTS:
void initTestCase();
void cleanupTestCase();
void init();
void cleanup();
-private slots:
+
void getSetCheck();
void setText_data();
void setText();
@@ -111,7 +105,6 @@ private:
QLabel *testWidget;
QPointer<Widget> test_box;
QPointer<QLabel> test_label;
- QLineEdit *test_edit;
};
// Testing get/set functions
@@ -144,15 +137,6 @@ void tst_QLabel::getSetCheck()
delete var3;
}
-
-tst_QLabel::tst_QLabel(): test_box(0)
-{
-}
-
-tst_QLabel::~tst_QLabel()
-{
-}
-
void tst_QLabel::initTestCase()
{
// Create the test class
@@ -165,8 +149,7 @@ void tst_QLabel::cleanupTestCase()
{
delete testWidget;
testWidget = 0;
- if (test_box)
- delete test_box;
+ delete test_box;
}
void tst_QLabel::init()
@@ -196,7 +179,7 @@ void tst_QLabel::setBuddy()
test_box = new Widget;
test_label= new QLabel( test_box );
test_label->setText( "&Test with a buddy" );
- test_edit = new QLineEdit( test_box );
+ QWidget *test_edit = new QLineEdit( test_box );
QVBoxLayout *layout = new QVBoxLayout(test_box);
layout->addWidget(test_label);
layout->addWidget(test_edit);
@@ -322,7 +305,7 @@ void tst_QLabel::eventPropagation()
test_label->setText(text);
test_box->events.clear();
test_label->setTextInteractionFlags(Qt::TextInteractionFlags(textInteractionFlags));
- QVERIFY(int(test_label->focusPolicy()) == focusPolicy);
+ QCOMPARE(int(test_label->focusPolicy()), focusPolicy);
QTest::mousePress(test_label, Qt::LeftButton);
QVERIFY(test_box->events.contains(QEvent::MouseButtonPress) == propagation); // should have propagated!
}
diff --git a/tests/auto/widgets/widgets/qlineedit/qlineedit.pro b/tests/auto/widgets/widgets/qlineedit/qlineedit.pro
index 715dcb9550..636208d67a 100644
--- a/tests/auto/widgets/widgets/qlineedit/qlineedit.pro
+++ b/tests/auto/widgets/widgets/qlineedit/qlineedit.pro
@@ -3,3 +3,4 @@ TARGET = tst_qlineedit
QT += gui-private core-private widgets widgets-private testlib
SOURCES += tst_qlineedit.cpp
+osx: LIBS += -framework AppKit
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
index 1d70e8a8ab..b46609c371 100644
--- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
@@ -229,6 +229,7 @@ private slots:
void isModified();
void edited();
+ void fixupDoesNotModify_QTBUG_49295();
void insert();
void setSelection_data();
@@ -1669,7 +1670,7 @@ void tst_QLineEdit::displayText()
testWidget->setEchoMode(mode);
testWidget->setText(insertString);
QCOMPARE(testWidget->displayText(), expectedString);
- QVERIFY(testWidget->echoMode() == mode);
+ QCOMPARE(testWidget->echoMode(), mode);
}
void tst_QLineEdit::passwordEchoOnEdit()
@@ -1839,9 +1840,9 @@ void tst_QLineEdit::maxLength()
// Make sure that the textChanged is not emitted unless the text is actually changed
if (insertString == expectedString) {
- QVERIFY(changed_count == 0);
+ QCOMPARE(changed_count, 0);
} else {
- QVERIFY(changed_count == 1);
+ QCOMPARE(changed_count, 1);
}
}
@@ -1962,7 +1963,7 @@ void tst_QLineEdit::psKeyClick(QTestEventList &keys, Qt::Key key, Qt::KeyboardMo
void tst_QLineEdit::cursorPosition()
{
QLineEdit *testWidget = ensureTestWidget();
- QVERIFY(testWidget->cursorPosition() == 0);
+ QCOMPARE(testWidget->cursorPosition(), 0);
// start with a basic text
QTest::keyClicks(testWidget, "The");
@@ -2208,7 +2209,7 @@ void tst_QLineEdit::selectedText()
testWidget->cursorForward(true, 9);
QVERIFY(testWidget->hasSelectedText());
QCOMPARE(testWidget->selectedText(), QString("Abc defg "));
- QVERIFY(selection_count == 1);
+ QCOMPARE(selection_count, 1);
// reset selection
testWidget->home(false);
@@ -2264,19 +2265,19 @@ void tst_QLineEdit::textChangedAndTextEdited()
QLineEdit *testWidget = ensureTestWidget();
QTest::keyClick(testWidget, Qt::Key_A);
QCOMPARE(changed_count, 1);
- QVERIFY(edited_count == changed_count);
+ QCOMPARE(edited_count, changed_count);
QTest::keyClick(testWidget, 'b');
QCOMPARE(changed_count, 2);
- QVERIFY(edited_count == changed_count);
+ QCOMPARE(edited_count, changed_count);
QTest::keyClick(testWidget, 'c');
QCOMPARE(changed_count, 3);
- QVERIFY(edited_count == changed_count);
+ QCOMPARE(edited_count, changed_count);
QTest::keyClick(testWidget, ' ');
QCOMPARE(changed_count, 4);
- QVERIFY(edited_count == changed_count);
+ QCOMPARE(edited_count, changed_count);
QTest::keyClick(testWidget, 'd');
QCOMPARE(changed_count, 5);
- QVERIFY(edited_count == changed_count);
+ QCOMPARE(edited_count, changed_count);
changed_count = 0;
edited_count = 0;
@@ -2322,27 +2323,27 @@ void tst_QLineEdit::returnPressed()
QLineEdit *testWidget = ensureTestWidget();
QTest::keyClick(testWidget, Qt::Key_Return);
- QVERIFY(return_count == 1);
+ QCOMPARE(return_count, 1);
return_count = 0;
QTest::keyClick(testWidget, 'A');
- QVERIFY(return_count == 0);
+ QCOMPARE(return_count, 0);
QTest::keyClick(testWidget, 'b');
- QVERIFY(return_count == 0);
+ QCOMPARE(return_count, 0);
QTest::keyClick(testWidget, 'c');
- QVERIFY(return_count == 0);
+ QCOMPARE(return_count, 0);
QTest::keyClick(testWidget, ' ');
- QVERIFY(return_count == 0);
+ QCOMPARE(return_count, 0);
QTest::keyClick(testWidget, 'd');
- QVERIFY(return_count == 0);
+ QCOMPARE(return_count, 0);
psKeyClick(testWidget, Qt::Key_Home);
- QVERIFY(return_count == 0);
+ QCOMPARE(return_count, 0);
psKeyClick(testWidget, Qt::Key_End);
- QVERIFY(return_count == 0);
+ QCOMPARE(return_count, 0);
QTest::keyClick(testWidget, Qt::Key_Escape);
- QVERIFY(return_count == 0);
+ QCOMPARE(return_count, 0);
QTest::keyClick(testWidget, Qt::Key_Return);
- QVERIFY(return_count == 1);
+ QCOMPARE(return_count, 1);
}
// int validator that fixes all !isNumber to '0'
@@ -2498,14 +2499,14 @@ void tst_QLineEdit::setValidator()
QCOMPARE(testWidget->validator(), static_cast<const QValidator*>(&iv1));
testWidget->setValidator(0);
- QVERIFY(testWidget->validator() == 0);
+ QVERIFY(!testWidget->validator());
QIntValidator iv2(0, 99, 0);
testWidget->setValidator(&iv2);
QCOMPARE(testWidget->validator(), static_cast<const QValidator *>(&iv2));
testWidget->setValidator(0);
- QVERIFY(testWidget->validator() == 0);
+ QVERIFY(!testWidget->validator());
}
void tst_QLineEdit::setValidator_QIntValidator_data()
@@ -2747,7 +2748,7 @@ void tst_QLineEdit::setAlignment()
QTEST(testWidget, "left");
#endif
#endif
- QVERIFY(testWidget->alignment() == Qt::AlignLeft);
+ QCOMPARE(testWidget->alignment(), Qt::AlignLeft);
testWidget->setText("hcenter");
testWidget->setAlignment(Qt::AlignHCenter);
@@ -2756,7 +2757,7 @@ void tst_QLineEdit::setAlignment()
QTEST(testWidget, "hcenter");
#endif
#endif
- QVERIFY(testWidget->alignment() == Qt::AlignHCenter);
+ QCOMPARE(testWidget->alignment(), Qt::AlignHCenter);
testWidget->setText("right");
testWidget->setAlignment(Qt::AlignRight);
@@ -2765,16 +2766,16 @@ void tst_QLineEdit::setAlignment()
QTEST(testWidget, "right");
#endif
#endif
- QVERIFY(testWidget->alignment() == Qt::AlignRight);
+ QCOMPARE(testWidget->alignment(), Qt::AlignRight);
testWidget->setAlignment(Qt::AlignTop);
- QVERIFY(testWidget->alignment() == Qt::AlignTop);
+ QCOMPARE(testWidget->alignment(), Qt::AlignTop);
testWidget->setAlignment(Qt::AlignBottom);
- QVERIFY(testWidget->alignment() == Qt::AlignBottom);
+ QCOMPARE(testWidget->alignment(), Qt::AlignBottom);
testWidget->setAlignment(Qt::AlignCenter);
- QVERIFY(testWidget->alignment() == Qt::AlignCenter);
+ QCOMPARE(testWidget->alignment(), Qt::AlignCenter);
}
void tst_QLineEdit::isModified()
@@ -2844,6 +2845,29 @@ void tst_QLineEdit::edited()
QVERIFY(testWidget->isModified());
}
+void tst_QLineEdit::fixupDoesNotModify_QTBUG_49295()
+{
+ QLineEdit *testWidget = ensureTestWidget();
+
+ ValidatorWithFixup val;
+ testWidget->setValidator(&val);
+ testWidget->setText("foo");
+ QVERIFY(!testWidget->isModified());
+ QVERIFY(!testWidget->hasAcceptableInput());
+
+ QTest::keyClicks(testWidget, QStringLiteral("bar"));
+ QVERIFY(testWidget->isModified());
+ QVERIFY(!testWidget->hasAcceptableInput());
+
+ // trigger a fixup, which should not reset the modified flag
+ QFocusEvent lostFocus(QEvent::FocusOut);
+ qApp->sendEvent(testWidget, &lostFocus);
+
+ QVERIFY(testWidget->hasAcceptableInput());
+ QEXPECT_FAIL("", "QTBUG-49295: a fixup of a line edit should keep it modified", Continue);
+ QVERIFY(testWidget->isModified());
+}
+
void tst_QLineEdit::insert()
{
QLineEdit *testWidget = ensureTestWidget();
@@ -3082,10 +3106,10 @@ void tst_QLineEdit::maxLengthAndInputMask()
QLineEdit *testWidget = ensureTestWidget();
QVERIFY(testWidget->inputMask().isNull());
testWidget->setMaxLength(10);
- QVERIFY(testWidget->maxLength() == 10);
+ QCOMPARE(testWidget->maxLength(), 10);
testWidget->setInputMask(QString::null);
QVERIFY(testWidget->inputMask().isNull());
- QVERIFY(testWidget->maxLength() == 10);
+ QCOMPARE(testWidget->maxLength(), 10);
}
@@ -4477,7 +4501,7 @@ void tst_QLineEdit::QTBUG1266_setInputMaskEmittingTextEdited()
QSignalSpy spy(&lineEdit, SIGNAL(textEdited(QString)));
lineEdit.setInputMask("AAAA");
lineEdit.setInputMask(QString());
- QVERIFY(spy.count() == 0);
+ QCOMPARE(spy.count(), 0);
}
QTEST_MAIN(tst_QLineEdit)
diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
index 270e5168f7..6282028746 100644
--- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
+++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
@@ -149,6 +149,8 @@ private slots:
void toggleUnifiedTitleAndToolBarOnMac();
#endif
void QTBUG21378_animationFinished();
+ void resizeDocks();
+ void resizeDocks_data();
};
@@ -211,15 +213,15 @@ tst_QMainWindow::tst_QMainWindow()
void tst_QMainWindow::constructor()
{
QMainWindow mw;
- QVERIFY(mw.parentWidget() == 0);
+ QVERIFY(!mw.parentWidget());
QVERIFY(mw.isWindow());
QMainWindow mw2(&mw);
- QVERIFY(mw2.parentWidget() == &mw);
+ QCOMPARE(mw2.parentWidget(), &mw);
QVERIFY(mw2.isWindow());
QMainWindow mw3(&mw, Qt::FramelessWindowHint);
- QVERIFY(mw3.parentWidget() == &mw);
+ QCOMPARE(mw3.parentWidget(), &mw);
QVERIFY(mw3.isWindow());
}
@@ -607,7 +609,7 @@ void tst_QMainWindow::menuBar()
QVERIFY(mw.menuBar() != 0);
//we now call deleteLater on the previous menubar
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(mb1 == 0);
+ QVERIFY(mb1.isNull());
mw.setMenuBar(mb2);
QVERIFY(mw.menuBar() != 0);
@@ -618,7 +620,7 @@ void tst_QMainWindow::menuBar()
QVERIFY(mw.menuBar() != 0);
//we now call deleteLater on the previous menubar
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(mb2 == 0);
+ QVERIFY(mb2.isNull());
mb1 = new QMenuBar;
mw.setMenuBar(mb1);
@@ -631,7 +633,7 @@ void tst_QMainWindow::menuBar()
QCOMPARE(mw.menuBar(), (QMenuBar *)mb2);
//we now call deleteLater on the previous menubar
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(mb1 == 0);
+ QVERIFY(mb1.isNull());
mb1 = new QMenuBar;
mw.setMenuBar(mb1);
@@ -639,7 +641,7 @@ void tst_QMainWindow::menuBar()
QCOMPARE(mw.menuBar(), (QMenuBar *)mb1);
//we now call deleteLater on the previous menubar
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(mb2 == 0);
+ QVERIFY(mb2.isNull());
QPointer<QWidget> topLeftCornerWidget = new QWidget;
mb1->setCornerWidget(topLeftCornerWidget, Qt::TopLeftCorner);
@@ -652,7 +654,7 @@ void tst_QMainWindow::menuBar()
QCOMPARE(mw.menuBar(), (QMenuBar *)mb2);
//we now call deleteLater on the previous menubar
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(mb1 == 0);
+ QVERIFY(mb1.isNull());
QVERIFY(topLeftCornerWidget);
QCOMPARE(mb2->cornerWidget(Qt::TopLeftCorner), static_cast<QWidget *>(topLeftCornerWidget));
@@ -663,8 +665,8 @@ void tst_QMainWindow::menuBar()
QVERIFY(mw.menuBar() != 0);
//we now call deleteLater on the previous menubar
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(mb2 == 0);
+ QVERIFY(mb2.isNull());
QVERIFY(!topLeftCornerWidget);
QVERIFY(!topRightCornerWidget);
}
@@ -692,7 +694,7 @@ void tst_QMainWindow::statusBar()
QVERIFY(mw.statusBar() != 0);
//we now call deleteLater on the previous statusbar
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(sb1 == 0);
+ QVERIFY(sb1.isNull());
mw.setStatusBar(sb2);
QVERIFY(mw.statusBar() != 0);
@@ -703,7 +705,7 @@ void tst_QMainWindow::statusBar()
QVERIFY(mw.statusBar() != 0);
//we now call deleteLater on the previous statusbar
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(sb2 == 0);
+ QVERIFY(sb2.isNull());
sb1 = new QStatusBar;
mw.setStatusBar(sb1);
@@ -718,7 +720,7 @@ void tst_QMainWindow::statusBar()
QCOMPARE(sb2->parentWidget(), (QWidget *)&mw);
//we now call deleteLater on the previous statusbar
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(sb1 == 0);
+ QVERIFY(sb1.isNull());
sb1 = new QStatusBar;
mw.setStatusBar(sb1);
@@ -727,7 +729,7 @@ void tst_QMainWindow::statusBar()
QCOMPARE(sb1->parentWidget(), (QWidget *)&mw);
//we now call deleteLater on the previous statusbar
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(sb2 == 0);
+ QVERIFY(sb2.isNull());
sb2 = new QStatusBar;
mw.setStatusBar(sb2);
@@ -736,7 +738,7 @@ void tst_QMainWindow::statusBar()
QCOMPARE(sb2->parentWidget(), (QWidget *)&mw);
//we now call deleteLater on the previous statusbar
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(sb1 == 0);
+ QVERIFY(sb1.isNull());
}
{
@@ -749,7 +751,7 @@ void tst_QMainWindow::statusBar()
QVERIFY(indexOfSb != -1);
delete sb;
indexOfSb = l->indexOf(sb);
- QVERIFY(indexOfSb == -1);
+ QCOMPARE(indexOfSb, -1);
}
}
@@ -791,7 +793,7 @@ void tst_QMainWindow::centralWidget()
{
{
QMainWindow mw;
- QVERIFY(mw.centralWidget() == 0);
+ QVERIFY(!mw.centralWidget());
}
{
@@ -799,7 +801,7 @@ void tst_QMainWindow::centralWidget()
QPointer<QWidget> w1 = new QWidget;
QPointer<QWidget> w2 = new QWidget;
- QVERIFY(mw.centralWidget() == 0);
+ QVERIFY(!mw.centralWidget());
mw.setCentralWidget(w1);
QVERIFY(mw.centralWidget() != 0);
@@ -812,12 +814,12 @@ void tst_QMainWindow::centralWidget()
QCOMPARE(w2->parentWidget(), (QWidget *)&mw);
mw.setCentralWidget(0);
- QVERIFY(mw.centralWidget() == 0);
+ QVERIFY(!mw.centralWidget());
//we now call deleteLater on the previous central widgets
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(w1 == 0);
- QVERIFY(w2 == 0);
+ QVERIFY(w1.isNull());
+ QVERIFY(w2.isNull());
}
{
@@ -831,7 +833,7 @@ void tst_QMainWindow::centralWidget()
QPointer<QWidget> w1 = new QWidget;
QPointer<QWidget> w2 = new QWidget;
- QVERIFY(mw.centralWidget() == 0);
+ QVERIFY(!mw.centralWidget());
mw.setCentralWidget(w1);
QVERIFY(mw.centralWidget() != 0);
@@ -844,12 +846,12 @@ void tst_QMainWindow::centralWidget()
QCOMPARE(w2->parentWidget(), (QWidget *)&mw);
mw.setCentralWidget(0);
- QVERIFY(mw.centralWidget() == 0);
+ QVERIFY(!mw.centralWidget());
//we now call deleteLater on the previous central widgets
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(w1 == 0);
- QVERIFY(w2 == 0);
+ QVERIFY(w1.isNull());
+ QVERIFY(w2.isNull());
}
}
@@ -860,25 +862,25 @@ void tst_QMainWindow::takeCentralWidget() {
QPointer<QWidget> w1 = new QWidget;
- QVERIFY(mw.centralWidget() == 0);
+ QVERIFY(!mw.centralWidget());
mw.setCentralWidget(w1);
QWidget *oldCentralWidget = mw.takeCentralWidget();
- QVERIFY(oldCentralWidget == w1.data());
+ QCOMPARE(oldCentralWidget, w1.data());
// ensure that takeCentralWidget doesn't end up calling deleteLater
// on the central widget
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(mw.centralWidget() == 0);
+ QVERIFY(!mw.centralWidget());
QVERIFY(!w1.isNull());
- QVERIFY(w1->parent() == 0);
+ QVERIFY(!w1->parent());
mw.setCentralWidget(w1);
// ensure that the deleteLater called by setCentralWidget
// gets executed
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(mw.centralWidget() == w1.data());
+ QCOMPARE(mw.centralWidget(), w1.data());
QPointer<QWidget> w2 = new QWidget;
@@ -887,10 +889,10 @@ void tst_QMainWindow::takeCentralWidget() {
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
QVERIFY(w1.isNull());
- QVERIFY(mw.centralWidget() == w2.data());
+ QCOMPARE(mw.centralWidget(), w2.data());
QWidget *hopefullyW2 = mw.takeCentralWidget();
- QVERIFY(mw.centralWidget() == 0);
+ QVERIFY(!mw.centralWidget());
// ensure that takeCentralWidget doesn't end up calling deleteLater
// on the central widget
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
@@ -1928,9 +1930,9 @@ void tst_QMainWindow::toggleUnifiedTitleAndToolBarOnMac()
mw.show();
QRect frameGeometry = mw.frameGeometry();
mw.setUnifiedTitleAndToolBarOnMac(false);
- QVERIFY(frameGeometry.topLeft() == mw.frameGeometry().topLeft());
+ QCOMPARE(frameGeometry.topLeft(), mw.frameGeometry().topLeft());
mw.setUnifiedTitleAndToolBarOnMac(true);
- QVERIFY(frameGeometry.topLeft() == mw.frameGeometry().topLeft());
+ QCOMPARE(frameGeometry.topLeft(), mw.frameGeometry().topLeft());
}
#endif
@@ -1950,5 +1952,96 @@ void tst_QMainWindow::QTBUG21378_animationFinished()
delete mwClickTimer;
QVERIFY(true);
}
+
+Q_DECLARE_METATYPE(Qt::Orientation)
+
+void tst_QMainWindow::resizeDocks_data()
+{
+ QTest::addColumn<Qt::Orientation>("orientation");
+ QTest::addColumn<QStringList>("docks");
+ QTest::addColumn<QList<int> >("sizes");
+
+ QTest::newRow("1") << Qt::Horizontal
+ << (QStringList() << "blue" << "orange" << "green" << "gray")
+ << (QList<int>() << 190 << 190 << 320 << 160);
+
+ QTest::newRow("2") << Qt::Vertical
+ << (QStringList() << "yellow" << "orange")
+ << (QList<int>() << 147 << 133 );
+
+
+ QTest::newRow("3") << Qt::Horizontal
+ << (QStringList() << "blue" << "yellow")
+ << (QList<int>() << 190 << 600);
+}
+
+void tst_QMainWindow::resizeDocks()
+{
+ AddList addList;
+ addList
+ << AddDockWidget("blue", Qt::LeftDockWidgetArea)
+ << AddDockWidget("red", Qt::TopDockWidgetArea)
+ << AddDockWidget("pink", "red")
+ << AddDockWidget("yellow", Qt::RightDockWidgetArea)
+ << AddDockWidget("orange", Qt::RightDockWidgetArea)
+ << AddDockWidget("green", "orange", Qt::Horizontal)
+ << AddDockWidget("gray", "orange", Qt::Horizontal);
+ /*
+ +--------------------------------+
+ | red/pink |
+ +------+-+-----------------------+
+ | | | yellow |
+ | blue + +--------+------+-------+
+ | | | orange | gray | green |
+ +------+-+--------+------+-------+
+
+ */
+
+ QMainWindow mw(0, Qt::BypassWindowManagerHint);
+ mw.setDockNestingEnabled(true);
+ mw.resize(1800, 600);
+
+ foreach (const AddDockWidget &i, addList)
+ i.apply(&mw);
+
+ foreach (QDockWidget *dw, mw.findChildren<QDockWidget *>())
+ dw->setStyleSheet( "* { background-color: " + dw->objectName() +" }");
+
+ mw.setCentralWidget(new QTextEdit);
+
+ mw.show();
+ QTest::qWaitForWindowExposed(&mw);
+
+ QFETCH(Qt::Orientation, orientation);
+ QFETCH(QStringList, docks);
+ QFETCH(QList<int>, sizes);
+
+ QList<QDockWidget *> list;
+ foreach (const QString &name, docks) {
+ QDockWidget *d = mw.findChild<QDockWidget *>(name);
+ QVERIFY(d);
+ list << d;
+ }
+
+ mw.resizeDocks(list, sizes, orientation);
+
+ qApp->processEvents();
+
+ int totalFromList = 0;
+ int actualTotal = 0;
+ for (int i = 0; i < docks.count(); ++i) {
+ totalFromList += sizes[i];
+ QSize s = list[i]->size();
+ actualTotal += (orientation == Qt::Horizontal) ? s.width() : s.height();
+// qDebug() << list[i] << list[i]->size() << sizes[i];
+ }
+
+ for (int i = 0; i < docks.count(); ++i) {
+ QSize s = list[i]->size();
+ int value = (orientation == Qt::Horizontal) ? s.width() : s.height();
+ QCOMPARE(value, qRound(sizes[i]*actualTotal/double(totalFromList)));
+ }
+}
+
QTEST_MAIN(tst_QMainWindow)
#include "tst_qmainwindow.moc"
diff --git a/tests/auto/widgets/widgets/qmdiarea/BLACKLIST b/tests/auto/widgets/widgets/qmdiarea/BLACKLIST
index b8640e9ac3..63da2e3ae3 100644
--- a/tests/auto/widgets/widgets/qmdiarea/BLACKLIST
+++ b/tests/auto/widgets/widgets/qmdiarea/BLACKLIST
@@ -1,2 +1,5 @@
[updateScrollBars]
osx
+[tileSubWindows]
+osx
+xcb
diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
index 53defce423..e23634c515 100644
--- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
+++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
@@ -377,13 +377,13 @@ void tst_QMdiArea::subWindowActivated()
while (workspace->activeSubWindow() ) {
workspace->activeSubWindow()->close();
qApp->processEvents();
- QVERIFY(activeWindow == workspace->activeSubWindow());
+ QCOMPARE(activeWindow, workspace->activeSubWindow());
QCOMPARE(spy.count(), 1);
spy.clear();
}
- QVERIFY(activeWindow == 0);
- QVERIFY(workspace->activeSubWindow() == 0);
+ QVERIFY(!activeWindow);
+ QVERIFY(!workspace->activeSubWindow());
QCOMPARE(workspace->subWindowList().count(), 0);
{
@@ -432,13 +432,13 @@ void tst_QMdiArea::subWindowActivated()
QCOMPARE(spy.count(), 1);
spy.clear();
QVERIFY( activeWindow == window );
- QVERIFY(workspace->activeSubWindow() == window);
+ QCOMPARE(workspace->activeSubWindow(), window);
window->close();
qApp->processEvents();
QCOMPARE(spy.count(), 1);
spy.clear();
- QVERIFY(workspace->activeSubWindow() == 0);
- QVERIFY( activeWindow == 0 );
+ QVERIFY(!workspace->activeSubWindow());
+ QVERIFY(!activeWindow);
}
}
@@ -518,7 +518,7 @@ void tst_QMdiArea::subWindowActivated2()
#ifdef Q_OS_MAC
QSKIP("QTBUG-25298: This test is unstable on Mac.");
#endif
- if (qApp->platformName().toLower() == QStringLiteral("xcb"))
+ if (!QGuiApplication::platformName().compare(QLatin1String("xcb"), Qt::CaseInsensitive))
QSKIP("QTBUG-25298: Unstable on some X11 window managers");
QTRY_COMPARE(spy.count(), 1);
QVERIFY(!mdiArea.activeSubWindow());
@@ -564,8 +564,8 @@ void tst_QMdiArea::subWindowActivatedWithMinimize()
window1->close();
qApp->processEvents();
- QVERIFY(workspace->activeSubWindow() == 0);
- QVERIFY( activeWindow == 0 );
+ QVERIFY(!workspace->activeSubWindow());
+ QVERIFY(!activeWindow);
QVERIFY( workspace->subWindowList().count() == 0 );
}
@@ -1104,7 +1104,7 @@ void tst_QMdiArea::addAndRemoveWindows()
QVERIFY(window);
qApp->processEvents();
QCOMPARE(workspace.subWindowList().count(), 1);
- QVERIFY(window->windowFlags() == DefaultWindowFlags);
+ QCOMPARE(window->windowFlags(), DefaultWindowFlags);
QCOMPARE(window->size(), workspace.viewport()->size());
}
@@ -1115,7 +1115,7 @@ void tst_QMdiArea::addAndRemoveWindows()
QVERIFY(window);
qApp->processEvents();
QCOMPARE(workspace.subWindowList().count(), 2);
- QVERIFY(window->windowFlags() == DefaultWindowFlags);
+ QCOMPARE(window->windowFlags(), DefaultWindowFlags);
QCOMPARE(window->size(), window->minimumSize());
}
@@ -1127,7 +1127,7 @@ void tst_QMdiArea::addAndRemoveWindows()
QVERIFY(window);
qApp->processEvents();
QCOMPARE(workspace.subWindowList().count(), 3);
- QVERIFY(window->windowFlags() == DefaultWindowFlags);
+ QCOMPARE(window->windowFlags(), DefaultWindowFlags);
QCOMPARE(window->size(), QSize(1500, 1500));
}
@@ -1142,7 +1142,7 @@ void tst_QMdiArea::addAndRemoveWindows()
QMdiSubWindow *window = new QMdiSubWindow;
workspace.addSubWindow(window);
qApp->processEvents();
- QVERIFY(window->windowFlags() == DefaultWindowFlags);
+ QCOMPARE(window->windowFlags(), DefaultWindowFlags);
window->setWidget(new QWidget);
QCOMPARE(workspace.subWindowList().count(), 4);
QTest::ignoreMessage(QtWarningMsg, "QMdiArea::addSubWindow: window is already added");
@@ -1206,7 +1206,7 @@ void tst_QMdiArea::addAndRemoveWindowsWithReparenting()
{
QMdiArea workspace;
QMdiSubWindow window(&workspace);
- QVERIFY(window.windowFlags() == DefaultWindowFlags);
+ QCOMPARE(window.windowFlags(), DefaultWindowFlags);
// 0 because the window list contains widgets and not actual
// windows. Silly, but that's the behavior.
@@ -1219,7 +1219,7 @@ void tst_QMdiArea::addAndRemoveWindowsWithReparenting()
QCOMPARE(workspace.subWindowList().count(), 0);
window.setParent(&workspace);
QCOMPARE(workspace.subWindowList().count(), 1);
- QVERIFY(window.windowFlags() == DefaultWindowFlags);
+ QCOMPARE(window.windowFlags(), DefaultWindowFlags);
QTest::ignoreMessage(QtWarningMsg, "QMdiArea::addSubWindow: window is already added");
workspace.addSubWindow(&window);
diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
index a6caa3d020..db252347ac 100644
--- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
+++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
@@ -191,6 +191,7 @@ private slots:
void fixedMinMaxSize();
#if !defined (Q_OS_MAC) && !defined (Q_OS_WINCE)
void replaceMenuBarWhileMaximized();
+ void closeOnDoubleClick_data();
void closeOnDoubleClick();
#endif
void setFont();
@@ -1793,9 +1794,23 @@ void tst_QMdiSubWindow::replaceMenuBarWhileMaximized()
QVERIFY(!subWindow->maximizedSystemMenuIconWidget());
}
+void tst_QMdiSubWindow::closeOnDoubleClick_data()
+{
+ QTest::addColumn<int>("actionIndex");
+ QTest::addColumn<bool>("expectClosed");
+
+ QTest::newRow("close") << 1 << true;
+ QTest::newRow("disabled-restore-action") << 0 << false; // QTBUG-48493
+}
+
void tst_QMdiSubWindow::closeOnDoubleClick()
{
+ QFETCH(int, actionIndex);
+ QFETCH(bool, expectClosed);
+
QMdiArea mdiArea;
+ mdiArea.setWindowTitle(QLatin1String(QTest::currentTestFunction())
+ + QLatin1Char(' ') + QLatin1String(QTest::currentDataTag()));
QPointer<QMdiSubWindow> subWindow = mdiArea.addSubWindow(new QWidget);
mdiArea.show();
QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
@@ -1807,12 +1822,13 @@ void tst_QMdiSubWindow::closeOnDoubleClick()
QVERIFY(systemMenu);
QVERIFY(systemMenu->isVisible());
- sendMouseDoubleClick(systemMenu, QPoint(10, 10));
+ const QRect actionGeometry = systemMenu->actionGeometry(systemMenu->actions().at(actionIndex));
+ sendMouseDoubleClick(systemMenu, actionGeometry.center());
if (qApp->activePopupWidget() == static_cast<QWidget *>(systemMenu))
systemMenu->hide();
qApp->processEvents();
- QVERIFY(!subWindow || !subWindow->isVisible());
QVERIFY(!systemMenu || !systemMenu->isVisible());
+ QCOMPARE(subWindow.isNull() || !subWindow->isVisible(), expectClosed);
}
#endif
diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
index 46d3177a56..b3f9c54f24 100644
--- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
+++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
@@ -78,6 +78,7 @@ public slots:
private slots:
void getSetCheck();
void addActionsAndClear();
+ void addActionsConnect();
void keyboardNavigation_data();
void keyboardNavigation();
@@ -93,6 +94,7 @@ private slots:
void task208001_stylesheet();
void activeSubMenuPosition();
+ void activeSubMenuPositionExec();
void task242454_sizeHint();
void task176201_clear();
void task250673_activeMultiColumnSubMenuPosition();
@@ -264,6 +266,34 @@ void tst_QMenu::addActionsAndClear()
QCOMPARE(menus[0]->actions().count(), 0);
}
+static void testFunction() { }
+
+void tst_QMenu::addActionsConnect()
+{
+ QMenu menu;
+ const QString text = QLatin1String("bla");
+ const QIcon icon;
+ menu.addAction(text, &menu, SLOT(deleteLater()));
+ menu.addAction(text, &menu, &QMenu::deleteLater);
+ menu.addAction(text, testFunction);
+ menu.addAction(text, &menu, testFunction);
+ menu.addAction(icon, text, &menu, SLOT(deleteLater()));
+ menu.addAction(icon, text, &menu, &QMenu::deleteLater);
+ menu.addAction(icon, text, testFunction);
+ menu.addAction(icon, text, &menu, testFunction);
+#ifndef QT_NO_SHORTCUT
+ const QKeySequence keySequence(Qt::CTRL + Qt::Key_C);
+ menu.addAction(text, &menu, SLOT(deleteLater()), keySequence);
+ menu.addAction(text, &menu, &QMenu::deleteLater, keySequence);
+ menu.addAction(text, testFunction, keySequence);
+ menu.addAction(text, &menu, testFunction, keySequence);
+ menu.addAction(icon, text, &menu, SLOT(deleteLater()), keySequence);
+ menu.addAction(icon, text, &menu, &QMenu::deleteLater, keySequence);
+ menu.addAction(icon, text, testFunction, keySequence);
+ menu.addAction(icon, text, &menu, testFunction, keySequence);
+#endif // !QT_NO_SHORTCUT
+}
+
// We have a separate mouseActivation test for Windows mobile
#ifndef Q_OS_WINCE
void tst_QMenu::mouseActivation()
@@ -334,8 +364,10 @@ void tst_QMenu::keyboardNavigation_data()
QTest::newRow("data9") << Qt::Key(Qt::Key_Down) << Qt::KeyboardModifiers(Qt::NoModifier) << 3 << 0 << false << false<< true;
QTest::newRow("data10") << Qt::Key(Qt::Key_Return) << Qt::KeyboardModifiers(Qt::NoModifier) << 3 << 0 << false << true << false;
- // Test shortcuts.
- QTest::newRow("shortcut0") << Qt::Key(Qt::Key_V) << Qt::KeyboardModifiers(Qt::AltModifier) << 5 << 0 << true << true << false;
+ if (QGuiApplication::platformName().compare(QLatin1String("xcb"), Qt::CaseInsensitive)) {
+ // Test shortcuts.
+ QTest::newRow("shortcut0") << Qt::Key(Qt::Key_V) << Qt::KeyboardModifiers(Qt::AltModifier) << 5 << 0 << true << true << false;
+ }
}
void tst_QMenu::keyboardNavigation()
@@ -513,7 +545,7 @@ void tst_QMenu::onStatusTipTimer()
menu->close(); //goes out of the menu
QCOMPARE(st, QString("sub action"));
- QVERIFY(menu->isVisible() == false);
+ QVERIFY(!menu->isVisible());
m_onStatusTipTimerExecuted = true;
}
@@ -663,6 +695,61 @@ void tst_QMenu::activeSubMenuPosition()
#endif
}
+// QTBUG-49588, QTBUG-48396: activeSubMenuPositionExec() is the same as
+// activeSubMenuPosition(), but uses QMenu::exec(), which produces a different
+// sequence of events. Verify that the sub menu is positioned to the right of the
+// main menu.
+class SubMenuPositionExecMenu : public QMenu
+{
+ Q_OBJECT
+public:
+ SubMenuPositionExecMenu() : QMenu("Menu-Title"), m_timerId(-1), m_timerTick(0)
+ {
+ addAction("Item 1");
+ m_subMenu = addMenu("Submenu");
+ m_subAction = m_subMenu->addAction("Sub-Item1");
+ setActiveAction(m_subMenu->menuAction());
+ }
+
+protected:
+ void showEvent(QShowEvent *e) Q_DECL_OVERRIDE
+ {
+ QVERIFY(m_subMenu->isVisible());
+ QVERIFY2(m_subMenu->x() > x(),
+ (QByteArray::number(m_subMenu->x()) + ' ' + QByteArray::number(x())).constData());
+ m_timerId = startTimer(50);
+ QMenu::showEvent(e);
+ }
+
+ void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE
+ {
+ if (e->timerId() == m_timerId) {
+ switch (m_timerTick++) {
+ case 0:
+ m_subMenu->close();
+ break;
+ case 1:
+ close();
+ break;
+ }
+ }
+ }
+
+private:
+ int m_timerId;
+ int m_timerTick;
+ QMenu *m_subMenu;
+ QAction *m_subAction;
+};
+
+void tst_QMenu::activeSubMenuPositionExec()
+{
+#ifndef Q_OS_WINCE
+ SubMenuPositionExecMenu menu;
+ menu.exec(QGuiApplication::primaryScreen()->availableGeometry().center());
+#endif // !Q_OS_WINCE
+}
+
void tst_QMenu::task242454_sizeHint()
{
QMenu menu;
diff --git a/tests/auto/widgets/widgets/qmenubar/BLACKLIST b/tests/auto/widgets/widgets/qmenubar/BLACKLIST
index 424ab2ceed..4f9508266c 100644
--- a/tests/auto/widgets/widgets/qmenubar/BLACKLIST
+++ b/tests/auto/widgets/widgets/qmenubar/BLACKLIST
@@ -2,5 +2,6 @@
ubuntu-14.04
[taskQTBUG4965_escapeEaten]
ubuntu-14.04
+redhatenterpriselinuxworkstation-6.6
[task256322_highlight]
osx
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
index 31e9c737e2..f787d73a02 100644
--- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
@@ -117,6 +117,7 @@ private slots:
// void check_mouse2();
void check_altPress();
+ void check_altClosePress();
#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE)
void check_shortcutPress();
void check_menuPosition();
@@ -146,7 +147,7 @@ private:
QAction* m_lastSimpleAcceleratorId;
int m_simpleActivatedCount;
- int m_complexTriggerCount['k'];
+ int m_complexTriggerCount[int('k')];
};
// Testing get/set functions
@@ -534,60 +535,60 @@ void tst_QMenuBar::check_accelKeys()
QCOMPARE(m_complexTriggerCount[2], 0);
QCOMPARE(m_complexTriggerCount[3], 0);
QCOMPARE(m_complexTriggerCount[4], 0);
- QCOMPARE(m_complexTriggerCount['a'], 0);
- QCOMPARE(m_complexTriggerCount['b'], 0);
- QCOMPARE(m_complexTriggerCount['c'], 0);
- QCOMPARE(m_complexTriggerCount['d'], 0);
+ QCOMPARE(m_complexTriggerCount[int('a')], 0);
+ QCOMPARE(m_complexTriggerCount[int('b')], 0);
+ QCOMPARE(m_complexTriggerCount[int('c')], 0);
+ QCOMPARE(m_complexTriggerCount[int('d')], 0);
QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_A, Qt::ControlModifier);
QCOMPARE(m_complexTriggerCount[1], 0);
QCOMPARE(m_complexTriggerCount[2], 0);
QCOMPARE(m_complexTriggerCount[3], 0);
QCOMPARE(m_complexTriggerCount[4], 0);
- QCOMPARE(m_complexTriggerCount['a'], 1);
- QCOMPARE(m_complexTriggerCount['b'], 0);
- QCOMPARE(m_complexTriggerCount['c'], 0);
- QCOMPARE(m_complexTriggerCount['d'], 0);
+ QCOMPARE(m_complexTriggerCount[int('a')], 1);
+ QCOMPARE(m_complexTriggerCount[int('b')], 0);
+ QCOMPARE(m_complexTriggerCount[int('c')], 0);
+ QCOMPARE(m_complexTriggerCount[int('d')], 0);
QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_C, Qt::ControlModifier);
QCOMPARE(m_complexTriggerCount[1], 0);
QCOMPARE(m_complexTriggerCount[2], 0);
QCOMPARE(m_complexTriggerCount[3], 0);
QCOMPARE(m_complexTriggerCount[4], 0);
- QCOMPARE(m_complexTriggerCount['a'], 1);
- QCOMPARE(m_complexTriggerCount['b'], 0);
- QCOMPARE(m_complexTriggerCount['c'], 1);
- QCOMPARE(m_complexTriggerCount['d'], 0);
+ QCOMPARE(m_complexTriggerCount[int('a')], 1);
+ QCOMPARE(m_complexTriggerCount[int('b')], 0);
+ QCOMPARE(m_complexTriggerCount[int('c')], 1);
+ QCOMPARE(m_complexTriggerCount[int('d')], 0);
QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_B, Qt::ControlModifier);
QCOMPARE(m_complexTriggerCount[1], 0);
QCOMPARE(m_complexTriggerCount[2], 0);
QCOMPARE(m_complexTriggerCount[3], 0);
QCOMPARE(m_complexTriggerCount[4], 0);
- QCOMPARE(m_complexTriggerCount['a'], 1);
- QCOMPARE(m_complexTriggerCount['b'], 1);
- QCOMPARE(m_complexTriggerCount['c'], 1);
- QCOMPARE(m_complexTriggerCount['d'], 0);
+ QCOMPARE(m_complexTriggerCount[int('a')], 1);
+ QCOMPARE(m_complexTriggerCount[int('b')], 1);
+ QCOMPARE(m_complexTriggerCount[int('c')], 1);
+ QCOMPARE(m_complexTriggerCount[int('d')], 0);
QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_D, Qt::ControlModifier);
QCOMPARE(m_complexTriggerCount[1], 0);
QCOMPARE(m_complexTriggerCount[2], 0);
QCOMPARE(m_complexTriggerCount[3], 0);
QCOMPARE(m_complexTriggerCount[4], 0);
- QCOMPARE(m_complexTriggerCount['a'], 1);
- QCOMPARE(m_complexTriggerCount['b'], 1);
- QCOMPARE(m_complexTriggerCount['c'], 1);
- QCOMPARE(m_complexTriggerCount['d'], 1);
+ QCOMPARE(m_complexTriggerCount[int('a')], 1);
+ QCOMPARE(m_complexTriggerCount[int('b')], 1);
+ QCOMPARE(m_complexTriggerCount[int('c')], 1);
+ QCOMPARE(m_complexTriggerCount[int('d')], 1);
QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_J, Qt::AltModifier);
QCOMPARE(m_complexTriggerCount[1], 0);
QCOMPARE(m_complexTriggerCount[2], 0);
QCOMPARE(m_complexTriggerCount[3], 1);
QCOMPARE(m_complexTriggerCount[4], 0);
- QCOMPARE(m_complexTriggerCount['a'], 1);
- QCOMPARE(m_complexTriggerCount['b'], 1);
- QCOMPARE(m_complexTriggerCount['c'], 1);
- QCOMPARE(m_complexTriggerCount['d'], 1);
+ QCOMPARE(m_complexTriggerCount[int('a')], 1);
+ QCOMPARE(m_complexTriggerCount[int('b')], 1);
+ QCOMPARE(m_complexTriggerCount[int('c')], 1);
+ QCOMPARE(m_complexTriggerCount[int('d')], 1);
}
#endif
@@ -606,10 +607,10 @@ void tst_QMenuBar::check_cursorKeys1()
// the Popupmenu should be visible now
QCOMPARE(m_complexTriggerCount[3], 0);
QCOMPARE(m_complexTriggerCount[4], 0);
- QCOMPARE(m_complexTriggerCount['a'], 0);
- QCOMPARE(m_complexTriggerCount['b'], 0);
- QCOMPARE(m_complexTriggerCount['c'], 0);
- QCOMPARE(m_complexTriggerCount['d'], 0);
+ QCOMPARE(m_complexTriggerCount[int('a')], 0);
+ QCOMPARE(m_complexTriggerCount[int('b')], 0);
+ QCOMPARE(m_complexTriggerCount[int('c')], 0);
+ QCOMPARE(m_complexTriggerCount[int('d')], 0);
// Simulate a cursor key down click
QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down );
@@ -618,10 +619,10 @@ void tst_QMenuBar::check_cursorKeys1()
// Let's see if the correct slot is called...
QCOMPARE(m_complexTriggerCount[3], 0);
QCOMPARE(m_complexTriggerCount[4], 0);
- QCOMPARE(m_complexTriggerCount['a'], 0); // this shouldn't have been called
- QCOMPARE(m_complexTriggerCount['b'], 1); // and this should have been called by a signal now
- QCOMPARE(m_complexTriggerCount['c'], 0);
- QCOMPARE(m_complexTriggerCount['d'], 0);
+ QCOMPARE(m_complexTriggerCount[int('a')], 0); // this shouldn't have been called
+ QCOMPARE(m_complexTriggerCount[int('b')], 1); // and this should have been called by a signal now
+ QCOMPARE(m_complexTriggerCount[int('c')], 0);
+ QCOMPARE(m_complexTriggerCount[int('d')], 0);
}
#endif
@@ -648,10 +649,10 @@ void tst_QMenuBar::check_cursorKeys2()
// Let's see if the correct slot is called...
QCOMPARE(m_complexTriggerCount[3], 0);
QCOMPARE(m_complexTriggerCount[4], 0);
- QCOMPARE(m_complexTriggerCount['a'], 0); // this shouldn't have been caled
- QCOMPARE(m_complexTriggerCount['b'], 0); // and this should have been called by a signal ow
- QCOMPARE(m_complexTriggerCount['c'], 0);
- QCOMPARE(m_complexTriggerCount['d'], 1);
+ QCOMPARE(m_complexTriggerCount[int('a')], 0); // this shouldn't have been caled
+ QCOMPARE(m_complexTriggerCount[int('b')], 0); // and this should have been called by a signal ow
+ QCOMPARE(m_complexTriggerCount[int('c')], 0);
+ QCOMPARE(m_complexTriggerCount[int('d')], 1);
}
#endif
@@ -679,10 +680,10 @@ void tst_QMenuBar::check_cursorKeys3()
// Let's see if the correct slot is called...
QCOMPARE(m_complexTriggerCount[3], 0);
QCOMPARE(m_complexTriggerCount[4], 0);
- QCOMPARE(m_complexTriggerCount['a'], 0); // this shouldn't have been called
- QCOMPARE(m_complexTriggerCount['b'], 1); // and this should have been called by a signal now
- QCOMPARE(m_complexTriggerCount['c'], 0);
- QCOMPARE(m_complexTriggerCount['d'], 0);
+ QCOMPARE(m_complexTriggerCount[int('a')], 0); // this shouldn't have been called
+ QCOMPARE(m_complexTriggerCount[int('b')], 1); // and this should have been called by a signal now
+ QCOMPARE(m_complexTriggerCount[int('c')], 0);
+ QCOMPARE(m_complexTriggerCount[int('d')], 0);
}
#endif
@@ -715,17 +716,17 @@ void tst_QMenuBar::check_homeKey()
// and press ENTER
QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Enter );
// Let's see if the correct slot is called...
-// QVERIFY2( m_complexActionTriggerCount['c'] == 1, "Popupmenu should respond to a Home key" );
- QCOMPARE(m_complexTriggerCount['c'], 1);
+// QVERIFY2( m_complexActionTriggerCount[int('c')] == 1, "Popupmenu should respond to a Home key" );
+ QCOMPARE(m_complexTriggerCount[int('c')], 1);
QCOMPARE(m_complexTriggerCount[3], 0);
QCOMPARE(m_complexTriggerCount[4], 0);
- QCOMPARE(m_complexTriggerCount['a'], 0);
- QCOMPARE(m_complexTriggerCount['b'], 0);
- QCOMPARE(m_complexTriggerCount['d'], 0);
- QCOMPARE(m_complexTriggerCount['e'], 0);
- QCOMPARE(m_complexTriggerCount['f'], 0);
- QCOMPARE(m_complexTriggerCount['g'], 0);
- QCOMPARE(m_complexTriggerCount['h'], 0);
+ QCOMPARE(m_complexTriggerCount[int('a')], 0);
+ QCOMPARE(m_complexTriggerCount[int('b')], 0);
+ QCOMPARE(m_complexTriggerCount[int('d')], 0);
+ QCOMPARE(m_complexTriggerCount[int('e')], 0);
+ QCOMPARE(m_complexTriggerCount[int('f')], 0);
+ QCOMPARE(m_complexTriggerCount[int('g')], 0);
+ QCOMPARE(m_complexTriggerCount[int('h')], 0);
}
/*!
@@ -754,17 +755,17 @@ void tst_QMenuBar::check_endKey()
// and press ENTER
QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Enter );
// Let's see if the correct slot is called...
-// QVERIFY2( m_complexActionTriggerCount['h'] == 1, "Popupmenu should respond to an End key" );
- QCOMPARE(m_complexTriggerCount['h'], 1);//, "Popupmenu should respond to an End key");
+// QVERIFY2( m_complexActionTriggerCount[int('h')] == 1, "Popupmenu should respond to an End key" );
+ QCOMPARE(m_complexTriggerCount[int('h')], 1);//, "Popupmenu should respond to an End key");
QCOMPARE(m_complexTriggerCount[3], 0);
QCOMPARE(m_complexTriggerCount[4], 0);
- QCOMPARE(m_complexTriggerCount['a'], 0);
- QCOMPARE(m_complexTriggerCount['b'], 0);
- QCOMPARE(m_complexTriggerCount['c'], 0);
- QCOMPARE(m_complexTriggerCount['d'], 0);
- QCOMPARE(m_complexTriggerCount['e'], 0);
- QCOMPARE(m_complexTriggerCount['f'], 0);
- QCOMPARE(m_complexTriggerCount['g'], 0);
+ QCOMPARE(m_complexTriggerCount[int('a')], 0);
+ QCOMPARE(m_complexTriggerCount[int('b')], 0);
+ QCOMPARE(m_complexTriggerCount[int('c')], 0);
+ QCOMPARE(m_complexTriggerCount[int('d')], 0);
+ QCOMPARE(m_complexTriggerCount[int('e')], 0);
+ QCOMPARE(m_complexTriggerCount[int('f')], 0);
+ QCOMPARE(m_complexTriggerCount[int('g')], 0);
}
/*!
@@ -808,7 +809,7 @@ void tst_QMenuBar::check_escKey()
// and press ENTER
QTest::keyClick( menu.menus.at(1), Qt::Key_Enter );
// Let's see if the correct slot is called...
- QVERIFY2( m_complexTriggerCount['c'] == 1, "Expected item 2C to be selected" );
+ QVERIFY2(m_complexTriggerCount[int('c')] == 1, "Expected item 2C to be selected");
}
#endif
@@ -978,6 +979,35 @@ void tst_QMenuBar::check_altPress()
QTRY_VERIFY( ::qobject_cast<QMenuBar *>(qApp->focusWidget()) );
}
+// QTBUG-47377: Pressing 'Alt' after opening a menu by pressing 'Alt+Accelerator'
+// should close it and QMenuBar::activeAction() should be 0.
+void tst_QMenuBar::check_altClosePress()
+{
+ const QStyle *style = QApplication::style();
+ if (!style->styleHint(QStyle::SH_MenuBar_AltKeyNavigation) ) {
+ QSKIP(("This test is not supposed to work in the " + style->objectName().toLatin1()
+ + " style. Skipping.").constData());
+ }
+
+ QMainWindow w;
+ w.setWindowTitle(QTest::currentTestFunction());
+ QMenu *menuFile = w.menuBar()->addMenu(tr("&File"));
+ menuFile->addAction("Quit");
+ QMenu *menuEdit = w.menuBar()->addMenu(tr("&Edit"));
+ menuEdit->addAction("Copy");
+
+ w.show();
+ w.move(QGuiApplication::primaryScreen()->availableGeometry().center());
+ QApplication::setActiveWindow(&w);
+ QVERIFY(QTest::qWaitForWindowActive(&w));
+
+ QTest::keyClick(&w, Qt::Key_F, Qt::AltModifier);
+ QTRY_VERIFY(menuFile->isVisible());
+ QTest::keyClick(menuFile, Qt::Key_Alt, Qt::AltModifier);
+ QTRY_VERIFY(!menuFile->isVisible());
+ QTRY_VERIFY(!w.menuBar()->activeAction());
+}
+
// Qt/Mac,WinCE does not use the native popups/menubar
#if !defined(Q_OS_MAC) && !defined(Q_OS_WINCE)
void tst_QMenuBar::check_shortcutPress()
diff --git a/tests/auto/widgets/widgets/qopenglwidget/BLACKLIST b/tests/auto/widgets/widgets/qopenglwidget/BLACKLIST
new file mode 100644
index 0000000000..725b8e93b4
--- /dev/null
+++ b/tests/auto/widgets/widgets/qopenglwidget/BLACKLIST
@@ -0,0 +1,2 @@
+[clearAndGrab]
+opensuse-13.1
diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp
index e9f9c67856..a4a0045265 100644
--- a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp
+++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp
@@ -57,6 +57,8 @@ private slots:
void asViewport();
void requestUpdate();
void fboRedirect();
+ void showHide();
+ void nativeWindow();
};
void tst_QOpenGLWidget::create()
@@ -70,7 +72,7 @@ void tst_QOpenGLWidget::create()
QVERIFY(w->isValid());
QVERIFY(w->context());
- QVERIFY(w->context()->format() == w->format());
+ QCOMPARE(w->context()->format(), w->format());
QVERIFY(w->defaultFramebufferObject() != 0);
}
@@ -81,7 +83,8 @@ public:
: QOpenGLWidget(parent),
m_initCalled(false), m_paintCalled(false), m_resizeCalled(false),
m_resizeOk(false),
- m_w(expectedWidth), m_h(expectedHeight) { }
+ m_w(expectedWidth), m_h(expectedHeight),
+ r(1.0f), g(0.0f), b(0.0f) { }
void initializeGL() Q_DECL_OVERRIDE {
m_initCalled = true;
@@ -89,13 +92,16 @@ public:
}
void paintGL() Q_DECL_OVERRIDE {
m_paintCalled = true;
- glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
+ glClearColor(r, g, b, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
}
void resizeGL(int w, int h) Q_DECL_OVERRIDE {
m_resizeCalled = true;
m_resizeOk = w == m_w && h == m_h;
}
+ void setClearColor(float r, float g, float b) {
+ this->r = r; this->g = g; this->b = b;
+ }
bool m_initCalled;
bool m_paintCalled;
@@ -103,6 +109,7 @@ public:
bool m_resizeOk;
int m_w;
int m_h;
+ float r, g, b;
};
void tst_QOpenGLWidget::clearAndGrab()
@@ -304,7 +311,7 @@ void tst_QOpenGLWidget::asViewport()
// the widget stack.
btn->update();
qApp->processEvents();
- QVERIFY(view->paintCount() == 0);
+ QCOMPARE(view->paintCount(), 0);
}
class PaintCountWidget : public QOpenGLWidget
@@ -355,6 +362,69 @@ void tst_QOpenGLWidget::fboRedirect()
QVERIFY(reportedDefaultFbo != widgetFbo);
}
+void tst_QOpenGLWidget::showHide()
+{
+ QScopedPointer<ClearWidget> w(new ClearWidget(0, 800, 600));
+ w->resize(800, 600);
+ w->show();
+ QTest::qWaitForWindowExposed(w.data());
+
+ w->hide();
+
+ QImage image = w->grabFramebuffer();
+ QVERIFY(!image.isNull());
+ QCOMPARE(image.width(), w->width());
+ QCOMPARE(image.height(), w->height());
+ QVERIFY(image.pixel(30, 40) == qRgb(255, 0, 0));
+
+ w->setClearColor(0, 0, 1);
+ w->show();
+ 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));
+}
+
+void tst_QOpenGLWidget::nativeWindow()
+{
+ QScopedPointer<ClearWidget> w(new ClearWidget(0, 800, 600));
+ w->resize(800, 600);
+ w->show();
+ w->winId();
+ QTest::qWaitForWindowExposed(w.data());
+
+ QImage image = w->grabFramebuffer();
+ QVERIFY(!image.isNull());
+ QCOMPARE(image.width(), w->width());
+ QCOMPARE(image.height(), w->height());
+ QVERIFY(image.pixel(30, 40) == qRgb(255, 0, 0));
+ QVERIFY(w->internalWinId());
+
+ // Now as a native child.
+ QWidget nativeParent;
+ nativeParent.resize(800, 600);
+ nativeParent.setAttribute(Qt::WA_NativeWindow);
+ ClearWidget *child = new ClearWidget(0, 800, 600);
+ child->setClearColor(0, 1, 0);
+ child->setParent(&nativeParent);
+ child->resize(400, 400);
+ child->move(23, 34);
+ nativeParent.show();
+ QTest::qWaitForWindowExposed(&nativeParent);
+
+ QVERIFY(nativeParent.internalWinId());
+ QVERIFY(!child->internalWinId());
+
+ image = child->grabFramebuffer();
+ QVERIFY(!image.isNull());
+ QCOMPARE(image.width(), child->width());
+ QCOMPARE(image.height(), child->height());
+ QVERIFY(image.pixel(30, 40) == qRgb(0, 255, 0));
+}
+
QTEST_MAIN(tst_QOpenGLWidget)
#include "tst_qopenglwidget.moc"
diff --git a/tests/auto/widgets/widgets/qplaintextedit/qplaintextedit.pro b/tests/auto/widgets/widgets/qplaintextedit/qplaintextedit.pro
index e98bae2089..be4102ec75 100644
--- a/tests/auto/widgets/widgets/qplaintextedit/qplaintextedit.pro
+++ b/tests/auto/widgets/widgets/qplaintextedit/qplaintextedit.pro
@@ -9,3 +9,4 @@ INCLUDEPATH += ../
HEADERS +=
SOURCES += tst_qplaintextedit.cpp
+osx: LIBS += -framework AppKit
diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
index e7de6b0b75..2145260013 100644
--- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
+++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
@@ -333,7 +333,7 @@ void tst_QPlainTextEdit::selectAllSetsNotSelection()
QSKIP("Test only relevant for systems with selection");
QApplication::clipboard()->setText(QString("foobar"), QClipboard::Selection);
- QVERIFY(QApplication::clipboard()->text(QClipboard::Selection) == QString("foobar"));
+ QCOMPARE(QApplication::clipboard()->text(QClipboard::Selection), QString("foobar"));
ed->insertPlainText("Hello World");
ed->selectAll();
@@ -905,13 +905,13 @@ void tst_QPlainTextEdit::mouseCursorShape()
{
// always show an IBeamCursor, see change 170146
QVERIFY(!ed->isReadOnly());
- QVERIFY(ed->viewport()->cursor().shape() == Qt::IBeamCursor);
+ QCOMPARE(ed->viewport()->cursor().shape(), Qt::IBeamCursor);
ed->setReadOnly(true);
- QVERIFY(ed->viewport()->cursor().shape() == Qt::IBeamCursor);
+ QCOMPARE(ed->viewport()->cursor().shape(), Qt::IBeamCursor);
ed->setPlainText("Foo");
- QVERIFY(ed->viewport()->cursor().shape() == Qt::IBeamCursor);
+ QCOMPARE(ed->viewport()->cursor().shape(), Qt::IBeamCursor);
}
#endif
@@ -1324,7 +1324,7 @@ void tst_QPlainTextEdit::preserveCharFormatAfterSetPlainText()
QTextBlock block = ed->document()->begin();
block = block.next();
QCOMPARE(block.text(), QString("This should still be blue"));
- QVERIFY(block.begin().fragment().charFormat().foreground().color() == QColor(Qt::blue));
+ QCOMPARE(block.begin().fragment().charFormat().foreground().color(), QColor(Qt::blue));
}
void tst_QPlainTextEdit::extraSelections()
@@ -1444,7 +1444,7 @@ void tst_QPlainTextEdit::wordWrapProperty()
doc->setDocumentLayout(new QPlainTextDocumentLayout(doc));
edit.setDocument(doc);
edit.setWordWrapMode(QTextOption::NoWrap);
- QVERIFY(doc->defaultTextOption().wrapMode() == QTextOption::NoWrap);
+ QCOMPARE(doc->defaultTextOption().wrapMode(), QTextOption::NoWrap);
}
{
QPlainTextEdit edit;
@@ -1452,18 +1452,18 @@ void tst_QPlainTextEdit::wordWrapProperty()
doc->setDocumentLayout(new QPlainTextDocumentLayout(doc));
edit.setWordWrapMode(QTextOption::NoWrap);
edit.setDocument(doc);
- QVERIFY(doc->defaultTextOption().wrapMode() == QTextOption::NoWrap);
+ QCOMPARE(doc->defaultTextOption().wrapMode(), QTextOption::NoWrap);
}
}
void tst_QPlainTextEdit::lineWrapProperty()
{
- QVERIFY(ed->wordWrapMode() == QTextOption::WrapAtWordBoundaryOrAnywhere);
- QVERIFY(ed->lineWrapMode() == QPlainTextEdit::WidgetWidth);
+ QCOMPARE(ed->wordWrapMode(), QTextOption::WrapAtWordBoundaryOrAnywhere);
+ QCOMPARE(ed->lineWrapMode(), QPlainTextEdit::WidgetWidth);
ed->setLineWrapMode(QPlainTextEdit::NoWrap);
- QVERIFY(ed->lineWrapMode() == QPlainTextEdit::NoWrap);
- QVERIFY(ed->wordWrapMode() == QTextOption::WrapAtWordBoundaryOrAnywhere);
- QVERIFY(ed->document()->defaultTextOption().wrapMode() == QTextOption::NoWrap);
+ QCOMPARE(ed->lineWrapMode(), QPlainTextEdit::NoWrap);
+ QCOMPARE(ed->wordWrapMode(), QTextOption::WrapAtWordBoundaryOrAnywhere);
+ QCOMPARE(ed->document()->defaultTextOption().wrapMode(), QTextOption::NoWrap);
}
void tst_QPlainTextEdit::selectionChanged()
@@ -1560,7 +1560,7 @@ void tst_QPlainTextEdit::findWithRegExp()
bool found = ed->find(rx);
- QVERIFY(found == true);
+ QVERIFY(found);
QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text"));
}
@@ -1574,7 +1574,7 @@ void tst_QPlainTextEdit::findBackwardWithRegExp()
bool found = ed->find(rx, QTextDocument::FindBackward);
- QVERIFY(found == true);
+ QVERIFY(found);
QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("arbit"));
}
@@ -1586,7 +1586,7 @@ void tst_QPlainTextEdit::findWithRegExpReturnsFalseIfNoMoreResults()
bool found = ed->find(rx);
- QVERIFY(found == false);
+ QVERIFY(!found);
QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text"));
}
#endif
diff --git a/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp b/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp
index 4a5f9d535b..5455ebb830 100644
--- a/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp
+++ b/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp
@@ -267,7 +267,7 @@ void tst_QProgressBar::sizeHint()
//test if the sizeHint is big enough
QFontMetrics fm = bar.fontMetrics();
- QStyleOptionProgressBarV2 opt;
+ QStyleOptionProgressBar opt;
bar.initStyleOption(&opt);
QSize size = QSize(9 * 7 + fm.width(QLatin1Char('0')) * 4, fm.height() + 8);
size= bar.style()->sizeFromContents(QStyle::CT_ProgressBar, &opt, size, &bar);
diff --git a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
index 4fd8b99acf..44a554ad82 100644
--- a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+++ b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
@@ -227,8 +227,8 @@ void tst_QPushButton::autoRepeat()
QVERIFY( testWidget->isDown() );
QVERIFY( toggle_count == 0 );
QTest::keyRelease( testWidget, Qt::Key_Space );
- QVERIFY(press_count == release_count);
- QVERIFY(release_count == click_count);
+ QCOMPARE(press_count, release_count);
+ QCOMPARE(release_count, click_count);
QVERIFY(press_count > 1);
// #### shouldn't I check here to see if multiple signals have been fired???
diff --git a/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp b/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp
index 40e13c8e8d..ce6afc0a57 100644
--- a/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp
+++ b/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp
@@ -166,8 +166,8 @@ void tst_QScrollArea::checkHFW_Task_197736()
scrollArea.setWidgetResizable(false);
scrollArea.resize(QSize(100,100));
w->resize(QSize(200,200));
- QVERIFY(w->width() == 200);
- QVERIFY(w->height() == 200);
+ QCOMPARE(w->width(), 200);
+ QCOMPARE(w->height(), 200);
}
QTEST_MAIN(tst_QScrollArea)
diff --git a/tests/auto/widgets/widgets/qsizegrip/BLACKLIST b/tests/auto/widgets/widgets/qsizegrip/BLACKLIST
new file mode 100644
index 0000000000..2c874bcb57
--- /dev/null
+++ b/tests/auto/widgets/widgets/qsizegrip/BLACKLIST
@@ -0,0 +1,2 @@
+[hideAndShowOnWindowStateChange:Qt::Window]
+xcb
diff --git a/tests/auto/widgets/widgets/qspinbox/BLACKLIST b/tests/auto/widgets/widgets/qspinbox/BLACKLIST
new file mode 100644
index 0000000000..5bf6c3beed
--- /dev/null
+++ b/tests/auto/widgets/widgets/qspinbox/BLACKLIST
@@ -0,0 +1,3 @@
+[editingFinished]
+osx-10.8
+osx-10.9
diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
index 05dd834c76..34b05c5291 100644
--- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
+++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
@@ -165,6 +165,7 @@ Q_DECLARE_METATYPE(QLocale::Country)
void tst_QSpinBox::getSetCheck()
{
QSpinBox obj1;
+ QCOMPARE(obj1.inputMethodQuery(Qt::ImHints), QVariant(int(Qt::ImhDigitsOnly)));
// int QSpinBox::singleStep()
// void QSpinBox::setSingleStep(int)
obj1.setSingleStep(0);
@@ -202,6 +203,7 @@ void tst_QSpinBox::getSetCheck()
QCOMPARE(INT_MAX, obj1.value());
QDoubleSpinBox obj2;
+ QCOMPARE(obj2.inputMethodQuery(Qt::ImHints), QVariant(int(Qt::ImhFormattedNumbersOnly)));
// double QDoubleSpinBox::singleStep()
// void QDoubleSpinBox::setSingleStep(double)
obj2.setSingleStep(0.0);
diff --git a/tests/auto/widgets/widgets/qtabbar/BLACKLIST b/tests/auto/widgets/widgets/qtabbar/BLACKLIST
new file mode 100644
index 0000000000..5a3f33e3e4
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtabbar/BLACKLIST
@@ -0,0 +1,3 @@
+[sizeHints]
+ubuntu-14.04
+redhatenterpriselinuxworkstation-6.6
diff --git a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp
index fffbbc2ec7..a991f18110 100644
--- a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp
+++ b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp
@@ -165,7 +165,7 @@ void tst_QTabWidget::init()
tw = new QTabWidget(0);
QCOMPARE(tw->count(), 0);
QCOMPARE(tw->currentIndex(), -1);
- QVERIFY(tw->currentWidget() == NULL);
+ QVERIFY(!tw->currentWidget());
}
void tst_QTabWidget::cleanup()
@@ -208,7 +208,7 @@ void tst_QTabWidget::addRemoveTab()
QCOMPARE(tw->count(), 0);
tw->removeTab(-1);
QCOMPARE(tw->count(), 0);
- QVERIFY(tw->widget(-1) == 0);
+ QVERIFY(!tw->widget(-1));
QWidget *w = new QWidget();
int index = tw->addTab(w, LABEL);
@@ -216,7 +216,7 @@ void tst_QTabWidget::addRemoveTab()
QCOMPARE(tw->indexOf(w), index);
QCOMPARE(tw->count(), 1);
- QVERIFY(tw->widget(index) == w);
+ QCOMPARE(tw->widget(index), w);
QCOMPARE(tw->tabText(index), QString(LABEL));
removePage(index);
@@ -238,7 +238,7 @@ void tst_QTabWidget::tabPosition()
void tst_QTabWidget::tabEnabled()
{
// Test bad arguments
- QVERIFY(tw->isTabEnabled(-1) == false);
+ QVERIFY(!tw->isTabEnabled(-1));
tw->setTabEnabled(-1, false);
int index = addPage();
@@ -333,21 +333,21 @@ void tst_QTabWidget::currentWidget()
{
// Test bad arguments
tw->setCurrentWidget(NULL);
- QVERIFY(tw->currentWidget() == NULL);
+ QVERIFY(!tw->currentWidget());
int index = addPage();
QWidget *w = tw->widget(index);
- QVERIFY(tw->currentWidget() == w);
+ QCOMPARE(tw->currentWidget(), w);
QCOMPARE(tw->currentIndex(), index);
tw->setCurrentWidget(NULL);
- QVERIFY(tw->currentWidget() == w);
+ QCOMPARE(tw->currentWidget(), w);
QCOMPARE(tw->currentIndex(), index);
int index2 = addPage();
QWidget *w2 = tw->widget(index2);
Q_UNUSED(w2);
- QVERIFY(tw->currentWidget() == w);
+ QCOMPARE(tw->currentWidget(), w);
QCOMPARE(tw->currentIndex(), index);
removePage(index2);
@@ -372,7 +372,7 @@ void tst_QTabWidget::currentIndex()
QCOMPARE(tw->currentIndex(), firstIndex);
QCOMPARE(spy.count(), 1);
QList<QVariant> arguments = spy.takeFirst();
- QVERIFY(arguments.at(0).toInt() == firstIndex);
+ QCOMPARE(arguments.at(0).toInt(), firstIndex);
int index = addPage();
QCOMPARE(tw->currentIndex(), firstIndex);
@@ -380,19 +380,19 @@ void tst_QTabWidget::currentIndex()
QCOMPARE(tw->currentIndex(), index);
QCOMPARE(spy.count(), 1);
arguments = spy.takeFirst();
- QVERIFY(arguments.at(0).toInt() == index);
+ QCOMPARE(arguments.at(0).toInt(), index);
removePage(index);
QCOMPARE(tw->currentIndex(), firstIndex);
QCOMPARE(spy.count(), 1);
arguments = spy.takeFirst();
- QVERIFY(arguments.at(0).toInt() == firstIndex);
+ QCOMPARE(arguments.at(0).toInt(), firstIndex);
removePage(firstIndex);
QCOMPARE(tw->currentIndex(), -1);
QCOMPARE(spy.count(), 1);
arguments = spy.takeFirst();
- QVERIFY(arguments.at(0).toInt() == -1);
+ QCOMPARE(arguments.at(0).toInt(), -1);
}
void tst_QTabWidget::cornerWidget()
@@ -400,24 +400,24 @@ void tst_QTabWidget::cornerWidget()
// Test bad arguments
tw->setCornerWidget(NULL, Qt::TopRightCorner);
- QVERIFY(tw->cornerWidget(Qt::TopLeftCorner) == 0);
- QVERIFY(tw->cornerWidget(Qt::TopRightCorner) == 0);
- QVERIFY(tw->cornerWidget(Qt::BottomLeftCorner) == 0);
- QVERIFY(tw->cornerWidget(Qt::BottomRightCorner) == 0);
+ QVERIFY(!tw->cornerWidget(Qt::TopLeftCorner));
+ QVERIFY(!tw->cornerWidget(Qt::TopRightCorner));
+ QVERIFY(!tw->cornerWidget(Qt::BottomLeftCorner));
+ QVERIFY(!tw->cornerWidget(Qt::BottomRightCorner));
QWidget *w = new QWidget(0);
tw->setCornerWidget(w, Qt::TopLeftCorner);
QCOMPARE(w->parent(), (QObject *)tw);
- QVERIFY(tw->cornerWidget(Qt::TopLeftCorner) == w);
+ QCOMPARE(tw->cornerWidget(Qt::TopLeftCorner), w);
tw->setCornerWidget(w, Qt::TopRightCorner);
- QVERIFY(tw->cornerWidget(Qt::TopRightCorner) == w);
+ QCOMPARE(tw->cornerWidget(Qt::TopRightCorner), w);
tw->setCornerWidget(w, Qt::BottomLeftCorner);
- QVERIFY(tw->cornerWidget(Qt::BottomLeftCorner) == w);
+ QCOMPARE(tw->cornerWidget(Qt::BottomLeftCorner), w);
tw->setCornerWidget(w, Qt::BottomRightCorner);
- QVERIFY(tw->cornerWidget(Qt::BottomRightCorner) == w);
+ QCOMPARE(tw->cornerWidget(Qt::BottomRightCorner), w);
tw->setCornerWidget(0, Qt::TopRightCorner);
- QVERIFY(tw->cornerWidget(Qt::TopRightCorner) == 0);
+ QVERIFY(!tw->cornerWidget(Qt::TopRightCorner));
QCOMPARE(w->isHidden(), true);
}
diff --git a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp
index aaa7348bdf..adc768f828 100644
--- a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp
+++ b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp
@@ -141,14 +141,14 @@ void tst_QTextBrowser::noReloadOnAnchorJump()
browser->setSource(url);
QCOMPARE(browser->htmlLoadAttempts, 1);
QVERIFY(!browser->toPlainText().isEmpty());
- QVERIFY(browser->source() == url);
+ QCOMPARE(browser->source(), url);
}
void tst_QTextBrowser::bgColorOnSourceChange()
{
browser->setSource(QUrl::fromLocalFile("pagewithbg.html"));
QVERIFY(browser->document()->rootFrame()->frameFormat().hasProperty(QTextFormat::BackgroundBrush));
- QVERIFY(browser->document()->rootFrame()->frameFormat().background().color() == Qt::blue);
+ QCOMPARE(browser->document()->rootFrame()->frameFormat().background().color(), QColor(Qt::blue));
browser->setSource(QUrl::fromLocalFile("pagewithoutbg.html"));
QVERIFY(!browser->document()->rootFrame()->frameFormat().hasProperty(QTextFormat::BackgroundBrush));
@@ -167,13 +167,13 @@ void tst_QTextBrowser::forwardButton()
QVERIFY(!forwardEmissions.isEmpty());
QVariant val = forwardEmissions.takeLast()[0];
- QVERIFY(val.type() == QVariant::Bool);
- QVERIFY(val.toBool() == false);
+ QCOMPARE(val.type(), QVariant::Bool);
+ QVERIFY(!val.toBool());
QVERIFY(!backwardEmissions.isEmpty());
val = backwardEmissions.takeLast()[0];
- QVERIFY(val.type() == QVariant::Bool);
- QVERIFY(val.toBool() == false);
+ QCOMPARE(val.type(), QVariant::Bool);
+ QVERIFY(!val.toBool());
QVERIFY(browser->historyTitle(-1).isEmpty());
QCOMPARE(browser->historyUrl(0), QUrl::fromLocalFile("pagewithbg.html"));
@@ -185,13 +185,13 @@ void tst_QTextBrowser::forwardButton()
QVERIFY(!forwardEmissions.isEmpty());
val = forwardEmissions.takeLast()[0];
- QVERIFY(val.type() == QVariant::Bool);
- QVERIFY(val.toBool() == false);
+ QCOMPARE(val.type(), QVariant::Bool);
+ QVERIFY(!val.toBool());
QVERIFY(!backwardEmissions.isEmpty());
val = backwardEmissions.takeLast()[0];
- QVERIFY(val.type() == QVariant::Bool);
- QVERIFY(val.toBool() == true);
+ QCOMPARE(val.type(), QVariant::Bool);
+ QVERIFY(val.toBool());
QCOMPARE(browser->historyTitle(-1), QString("Page With BG"));
QCOMPARE(browser->historyTitle(0), QString("Sample Anchor"));
@@ -201,13 +201,13 @@ void tst_QTextBrowser::forwardButton()
QVERIFY(!forwardEmissions.isEmpty());
val = forwardEmissions.takeLast()[0];
- QVERIFY(val.type() == QVariant::Bool);
- QVERIFY(val.toBool() == true);
+ QCOMPARE(val.type(), QVariant::Bool);
+ QVERIFY(val.toBool());
QVERIFY(!backwardEmissions.isEmpty());
val = backwardEmissions.takeLast()[0];
- QVERIFY(val.type() == QVariant::Bool);
- QVERIFY(val.toBool() == false);
+ QCOMPARE(val.type(), QVariant::Bool);
+ QVERIFY(!val.toBool());
QVERIFY(browser->historyTitle(-1).isEmpty());
QCOMPARE(browser->historyTitle(0), QString("Page With BG"));
@@ -217,13 +217,13 @@ void tst_QTextBrowser::forwardButton()
QVERIFY(!forwardEmissions.isEmpty());
val = forwardEmissions.takeLast()[0];
- QVERIFY(val.type() == QVariant::Bool);
- QVERIFY(val.toBool() == false);
+ QCOMPARE(val.type(), QVariant::Bool);
+ QVERIFY(!val.toBool());
QVERIFY(!backwardEmissions.isEmpty());
val = backwardEmissions.takeLast()[0];
- QVERIFY(val.type() == QVariant::Bool);
- QVERIFY(val.toBool() == true);
+ QCOMPARE(val.type(), QVariant::Bool);
+ QVERIFY(val.toBool());
}
void tst_QTextBrowser::viewportPositionInHistory()
@@ -244,29 +244,29 @@ void tst_QTextBrowser::relativeLinks()
QSignalSpy sourceChangedSpy(browser, SIGNAL(sourceChanged(QUrl)));
browser->setSource(QUrl("subdir/../qtextbrowser.html"));
QVERIFY(!browser->document()->isEmpty());
- QVERIFY(sourceChangedSpy.count() == 1);
+ QCOMPARE(sourceChangedSpy.count(), 1);
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("subdir/../qtextbrowser.html"));
browser->setSource(QUrl("subdir/index.html"));
QVERIFY(!browser->document()->isEmpty());
- QVERIFY(sourceChangedSpy.count() == 1);
+ QCOMPARE(sourceChangedSpy.count(), 1);
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("subdir/index.html"));
browser->setSource(QUrl("anchor.html"));
QVERIFY(!browser->document()->isEmpty());
- QVERIFY(sourceChangedSpy.count() == 1);
+ QCOMPARE(sourceChangedSpy.count(), 1);
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("anchor.html"));
browser->setSource(QUrl("subdir/index.html"));
QVERIFY(!browser->document()->isEmpty());
- QVERIFY(sourceChangedSpy.count() == 1);
+ QCOMPARE(sourceChangedSpy.count(), 1);
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("subdir/index.html"));
// using QUrl::fromLocalFile()
browser->setSource(QUrl::fromLocalFile("anchor.html"));
QVERIFY(!browser->document()->isEmpty());
- QVERIFY(sourceChangedSpy.count() == 1);
+ QCOMPARE(sourceChangedSpy.count(), 1);
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("file:anchor.html"));
browser->setSource(QUrl("subdir/../qtextbrowser.html"));
QVERIFY(!browser->document()->isEmpty());
- QVERIFY(sourceChangedSpy.count() == 1);
+ QCOMPARE(sourceChangedSpy.count(), 1);
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("subdir/../qtextbrowser.html"));
}
@@ -446,13 +446,13 @@ void tst_QTextBrowser::sourceInsideLoadResource()
void tst_QTextBrowser::textInteractionFlags_vs_readOnly()
{
QVERIFY(browser->isReadOnly());
- QVERIFY(browser->textInteractionFlags() == Qt::TextBrowserInteraction);
+ QCOMPARE(browser->textInteractionFlags(), Qt::TextBrowserInteraction);
browser->setReadOnly(true);
- QVERIFY(browser->textInteractionFlags() == Qt::TextBrowserInteraction);
+ QCOMPARE(browser->textInteractionFlags(), Qt::TextBrowserInteraction);
browser->setReadOnly(false);
- QVERIFY(browser->textInteractionFlags() == Qt::TextEditorInteraction);
+ QCOMPARE(browser->textInteractionFlags(), Qt::TextEditorInteraction);
browser->setReadOnly(true);
- QVERIFY(browser->textInteractionFlags() == Qt::TextBrowserInteraction);
+ QCOMPARE(browser->textInteractionFlags(), Qt::TextBrowserInteraction);
}
void tst_QTextBrowser::anchorsWithSelfBuiltHtml()
@@ -525,7 +525,7 @@ void tst_QTextBrowser::loadResourceOnRelativeLocalFiles()
QVERIFY(!browser->toPlainText().isEmpty());
QVariant v = browser->loadResource(QTextDocument::HtmlResource, QUrl("../anchor.html"));
QVERIFY(v.isValid());
- QVERIFY(v.type() == QVariant::ByteArray);
+ QCOMPARE(v.type(), QVariant::ByteArray);
QVERIFY(!v.toByteArray().isEmpty());
}
@@ -658,7 +658,7 @@ void tst_QTextBrowser::urlEncoding()
QCOMPARE(spy.count(), 1);
QUrl url = spy.at(0).at(0).toUrl();
- QVERIFY(url.toEncoded() == QByteArray("http://www.google.com/q=%22"));
+ QCOMPARE(url.toEncoded(), QByteArray("http://www.google.com/q=%22"));
delete browser;
}
diff --git a/tests/auto/widgets/widgets/qtextedit/qtextedit.pro b/tests/auto/widgets/widgets/qtextedit/qtextedit.pro
index 6e0fff17d5..8b39ab59b7 100644
--- a/tests/auto/widgets/widgets/qtextedit/qtextedit.pro
+++ b/tests/auto/widgets/widgets/qtextedit/qtextedit.pro
@@ -4,3 +4,5 @@ TARGET = tst_qtextedit
QT += widgets widgets-private gui-private core-private testlib
SOURCES += tst_qtextedit.cpp
+
+osx: LIBS += -framework AppKit
diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
index 35a6a8e4e0..0cc812cbca 100644
--- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
+++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
@@ -398,12 +398,13 @@ void tst_QTextEdit::cleanup()
void tst_QTextEdit::inlineAttributesOnInsert()
{
- QVERIFY(ed->textCursor().charFormat().foreground().color() != Qt::blue);
+ const QColor blue(Qt::blue);
+ QVERIFY(ed->textCursor().charFormat().foreground().color() != blue);
- ed->setTextColor(Qt::blue);
+ ed->setTextColor(blue);
QTest::keyClick(ed, Qt::Key_A);
- QVERIFY(ed->textCursor().charFormat().foreground().color() == Qt::blue);
+ QCOMPARE(ed->textCursor().charFormat().foreground().color(), blue);
}
void tst_QTextEdit::inlineAttributesOnSelection()
@@ -457,7 +458,7 @@ void tst_QTextEdit::autoBulletList1()
QTest::keyClicks(ed, "*This should become a list");
QVERIFY(ed->textCursor().currentList());
- QVERIFY(ed->textCursor().currentList()->format().style() == QTextListFormat::ListDisc);
+ QCOMPARE(ed->textCursor().currentList()->format().style(), QTextListFormat::ListDisc);
}
void tst_QTextEdit::autoBulletList2()
@@ -582,7 +583,7 @@ void tst_QTextEdit::selectAllSetsNotSelection()
}
QApplication::clipboard()->setText(QString("foobar"), QClipboard::Selection);
- QVERIFY(QApplication::clipboard()->text(QClipboard::Selection) == QString("foobar"));
+ QCOMPARE(QApplication::clipboard()->text(QClipboard::Selection), QString("foobar"));
ed->insertPlainText("Hello World");
ed->selectAll();
@@ -867,11 +868,12 @@ void tst_QTextEdit::appendShouldUseCurrentFormat()
fmt.setFontItalic(true);
ed->setCurrentCharFormat(fmt);
ed->append("Hello");
+ const QColor blue(Qt::blue);
QTextCursor cursor(ed->document());
QVERIFY(cursor.movePosition(QTextCursor::NextCharacter));
- QVERIFY(cursor.charFormat().foreground().color() != Qt::blue);
+ QVERIFY(cursor.charFormat().foreground().color() != blue);
QVERIFY(!cursor.charFormat().fontItalic());
QVERIFY(cursor.movePosition(QTextCursor::NextBlock));
@@ -883,7 +885,7 @@ void tst_QTextEdit::appendShouldUseCurrentFormat()
}
QVERIFY(cursor.movePosition(QTextCursor::NextCharacter));
- QVERIFY(cursor.charFormat().foreground().color() == Qt::blue);
+ QCOMPARE(cursor.charFormat().foreground().color(), blue);
QVERIFY(cursor.charFormat().fontItalic());
}
@@ -1211,7 +1213,7 @@ void tst_QTextEdit::lineWrapModes()
{
ed->setLineWrapMode(QTextEdit::NoWrap);
// NoWrap at the same time as having all lines that are all left aligned means we optimize to only layout once. The effect is that the width is always 0
- QVERIFY(ed->document()->pageSize().width() == qreal(0));
+ QCOMPARE(ed->document()->pageSize().width(), qreal(0));
QTextCursor cursor = QTextCursor(ed->document());
cursor.insertText(QString("A simple line"));
@@ -1237,13 +1239,13 @@ void tst_QTextEdit::mouseCursorShape()
{
// always show an IBeamCursor, see change 170146
QVERIFY(!ed->isReadOnly());
- QVERIFY(ed->viewport()->cursor().shape() == Qt::IBeamCursor);
+ QCOMPARE(ed->viewport()->cursor().shape(), Qt::IBeamCursor);
ed->setReadOnly(true);
- QVERIFY(ed->viewport()->cursor().shape() == Qt::IBeamCursor);
+ QCOMPARE(ed->viewport()->cursor().shape(), Qt::IBeamCursor);
ed->setPlainText("Foo");
- QVERIFY(ed->viewport()->cursor().shape() == Qt::IBeamCursor);
+ QCOMPARE(ed->viewport()->cursor().shape(), Qt::IBeamCursor);
}
#endif
@@ -1661,7 +1663,7 @@ void tst_QTextEdit::preserveCharFormatAfterSetPlainText()
QTextBlock block = ed->document()->begin();
block = block.next();
QCOMPARE(block.text(), QString("This should still be blue"));
- QVERIFY(block.begin().fragment().charFormat().foreground().color() == QColor(Qt::blue));
+ QCOMPARE(block.begin().fragment().charFormat().foreground().color(), QColor(Qt::blue));
}
void tst_QTextEdit::extraSelections()
@@ -1796,25 +1798,25 @@ void tst_QTextEdit::wordWrapProperty()
QTextDocument *doc = new QTextDocument(&edit);
edit.setDocument(doc);
edit.setWordWrapMode(QTextOption::NoWrap);
- QVERIFY(doc->defaultTextOption().wrapMode() == QTextOption::NoWrap);
+ QCOMPARE(doc->defaultTextOption().wrapMode(), QTextOption::NoWrap);
}
{
QTextEdit edit;
QTextDocument *doc = new QTextDocument(&edit);
edit.setWordWrapMode(QTextOption::NoWrap);
edit.setDocument(doc);
- QVERIFY(doc->defaultTextOption().wrapMode() == QTextOption::NoWrap);
+ QCOMPARE(doc->defaultTextOption().wrapMode(), QTextOption::NoWrap);
}
}
void tst_QTextEdit::lineWrapProperty()
{
- QVERIFY(ed->wordWrapMode() == QTextOption::WrapAtWordBoundaryOrAnywhere);
- QVERIFY(ed->lineWrapMode() == QTextEdit::WidgetWidth);
+ QCOMPARE(ed->wordWrapMode(), QTextOption::WrapAtWordBoundaryOrAnywhere);
+ QCOMPARE(ed->lineWrapMode(), QTextEdit::WidgetWidth);
ed->setLineWrapMode(QTextEdit::NoWrap);
- QVERIFY(ed->lineWrapMode() == QTextEdit::NoWrap);
- QVERIFY(ed->wordWrapMode() == QTextOption::WrapAtWordBoundaryOrAnywhere);
- QVERIFY(ed->document()->defaultTextOption().wrapMode() == QTextOption::NoWrap);
+ QCOMPARE(ed->lineWrapMode(), QTextEdit::NoWrap);
+ QCOMPARE(ed->wordWrapMode(), QTextOption::WrapAtWordBoundaryOrAnywhere);
+ QCOMPARE(ed->document()->defaultTextOption().wrapMode(), QTextOption::NoWrap);
}
void tst_QTextEdit::selectionChanged()
@@ -2122,7 +2124,7 @@ void tst_QTextEdit::setDocumentPreservesPalette()
QTextDocument *newDoc = new QTextDocument(ed);
ed->setDocument(newDoc);
- QVERIFY(control->document() == newDoc);
+ QCOMPARE(control->document(), newDoc);
QVERIFY(whitePal.color(QPalette::Active, QPalette::Text)
== control->palette().color(QPalette::Active, QPalette::Text));
}
@@ -2525,7 +2527,7 @@ void tst_QTextEdit::findWithRegExp()
bool found = ed->find(rx);
- QVERIFY(found == true);
+ QVERIFY(found);
QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text"));
}
@@ -2539,7 +2541,7 @@ void tst_QTextEdit::findBackwardWithRegExp()
bool found = ed->find(rx, QTextDocument::FindBackward);
- QVERIFY(found == true);
+ QVERIFY(found);
QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("arbit"));
}
@@ -2551,7 +2553,7 @@ void tst_QTextEdit::findWithRegExpReturnsFalseIfNoMoreResults()
bool found = ed->find(rx);
- QVERIFY(found == false);
+ QVERIFY(!found);
QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text"));
}
#endif
diff --git a/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp b/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp
index 24de35ce89..e653a85d96 100644
--- a/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp
+++ b/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp
@@ -67,6 +67,7 @@ private slots:
void allowedAreas();
void orientation();
void addAction();
+ void addActionConnect();
void insertAction();
void addSeparator();
void insertSeparator();
@@ -361,6 +362,23 @@ void tst_QToolBar::addAction()
}
}
+static void testFunction() { }
+
+void tst_QToolBar::addActionConnect()
+{
+ QToolBar tb;
+ const QString text = QLatin1String("bla");
+ const QIcon icon;
+ tb.addAction(text, &tb, SLOT(deleteLater()));
+ tb.addAction(text, &tb, &QMenu::deleteLater);
+ tb.addAction(text, testFunction);
+ tb.addAction(text, &tb, testFunction);
+ tb.addAction(icon, text, &tb, SLOT(deleteLater()));
+ tb.addAction(icon, text, &tb, &QMenu::deleteLater);
+ tb.addAction(icon, text, testFunction);
+ tb.addAction(icon, text, &tb, testFunction);
+}
+
void tst_QToolBar::insertAction()
{
QToolBar tb;
@@ -495,13 +513,13 @@ void tst_QToolBar::insertWidget()
QToolBar tb;
QPointer<QWidget> widget = new QWidget;
QAction *action = tb.addWidget(widget);
- QVERIFY(action->parent() == &tb);
+ QCOMPARE(action->parent(), &tb);
QToolBar tb2;
tb.removeAction(action);
tb2.addAction(action);
QVERIFY(widget && widget->parent() == &tb2);
- QVERIFY(action->parent() == &tb2);
+ QCOMPARE(action->parent(), &tb2);
}
}
@@ -960,10 +978,10 @@ void tst_QToolBar::actionOwnership()
QToolBar *tb2 = new QToolBar;
QPointer<QAction> action = tb1->addAction("test");
- QVERIFY(action->parent() == tb1);
+ QCOMPARE(action->parent(), tb1);
tb2->addAction(action);
- QVERIFY(action->parent() == tb1);
+ QCOMPARE(action->parent(), tb1);
delete tb1;
QVERIFY(!action);
@@ -974,13 +992,13 @@ void tst_QToolBar::actionOwnership()
QToolBar *tb2 = new QToolBar;
QPointer<QAction> action = tb1->addAction("test");
- QVERIFY(action->parent() == tb1);
+ QCOMPARE(action->parent(), tb1);
tb1->removeAction(action);
- QVERIFY(action->parent() == tb1);
+ QCOMPARE(action->parent(), tb1);
tb2->addAction(action);
- QVERIFY(action->parent() == tb1);
+ QCOMPARE(action->parent(), tb1);
delete tb1;
QVERIFY(!action);
diff --git a/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp
index 03fbae2e57..0d1abe5032 100644
--- a/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp
+++ b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp
@@ -170,10 +170,10 @@ void tst_QToolButton::collapseTextOnPriority()
QStyleOptionToolButton option;
button.initStyleOption(&option);
- QVERIFY(option.toolButtonStyle == Qt::ToolButtonTextBesideIcon);
+ QCOMPARE(option.toolButtonStyle, Qt::ToolButtonTextBesideIcon);
action.setPriority(QAction::LowPriority);
button.initStyleOption(&option);
- QVERIFY(option.toolButtonStyle == Qt::ToolButtonIconOnly);
+ QCOMPARE(option.toolButtonStyle, Qt::ToolButtonIconOnly);
}