diff options
Diffstat (limited to 'tests/auto/widgets')
8 files changed, 93 insertions, 45 deletions
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index fbd368d077..16ff118a3f 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -483,11 +483,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); } } @@ -889,7 +889,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(); } @@ -927,7 +927,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; diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp index 1e9cbe6578..cca150eb54 100644 --- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp @@ -81,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 @@ -171,7 +177,7 @@ void tst_QFileDialog2::cleanupSettingsFile() void tst_QFileDialog2::initTestCase() { - QVERIFY(tempDir.isValid()); + QVERIFY2(tempDir.isValid(), qPrintable(tempDir.errorString())); QStandardPaths::setTestModeEnabled(true); cleanupSettingsFile(); } @@ -243,13 +249,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; @@ -307,7 +313,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); @@ -849,7 +855,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; @@ -1108,6 +1114,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"); @@ -1209,7 +1216,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); diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp index bbe027fbc6..a70be695ef 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -173,7 +173,7 @@ void tst_QFileSystemModel::cleanup() void tst_QFileSystemModel::initTestCase() { - QVERIFY(m_tempDir.isValid()); + QVERIFY2(m_tempDir.isValid(), qPrintable(m_tempDir.errorString())); flatDirTestPath = m_tempDir.path(); } @@ -318,7 +318,7 @@ 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); @@ -819,7 +819,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); diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index f066f526eb..b7804da4ad 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -149,6 +149,7 @@ private slots: void spacing(); void testScrollToWithHidden(); void testViewOptions(); + void taskQTBUG_39902_mutualScrollBars_data(); void taskQTBUG_39902_mutualScrollBars(); void horizontalScrollingByVerticalWheelEvents(); }; @@ -2361,8 +2362,21 @@ private: QStyle* m_oldStyle; }; +void tst_QListView::taskQTBUG_39902_mutualScrollBars_data() +{ + QTest::addColumn<QAbstractItemView::ScrollMode>("horizontalScrollMode"); + QTest::addColumn<QAbstractItemView::ScrollMode>("verticalScrollMode"); + QTest::newRow("per item / per item") << QAbstractItemView::ScrollPerItem << QAbstractItemView::ScrollPerItem; + QTest::newRow("per pixel / per item") << QAbstractItemView::ScrollPerPixel << QAbstractItemView::ScrollPerItem; + QTest::newRow("per item / per pixel") << QAbstractItemView::ScrollPerItem << QAbstractItemView::ScrollPerPixel; + QTest::newRow("per pixel / per pixel") << QAbstractItemView::ScrollPerPixel << QAbstractItemView::ScrollPerPixel; +} + void tst_QListView::taskQTBUG_39902_mutualScrollBars() { + QFETCH(QAbstractItemView::ScrollMode, horizontalScrollMode); + QFETCH(QAbstractItemView::ScrollMode, verticalScrollMode); + QWidget window; window.resize(400, 300); QListView *view = new QListView(&window); @@ -2374,6 +2388,9 @@ void tst_QListView::taskQTBUG_39902_mutualScrollBars() model.setData(model.index(i, 0), itemSize, Qt::SizeHintRole); view->setModel(&model); + view->setVerticalScrollMode(verticalScrollMode); + view->setHorizontalScrollMode(horizontalScrollMode); + window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); // make sure QListView is done with layouting the items (1/10 sec, like QListView) @@ -2414,7 +2431,7 @@ void tst_QListView::taskQTBUG_39902_mutualScrollBars() QTRY_VERIFY(view->horizontalScrollBar()->isVisible()); QTRY_VERIFY(view->verticalScrollBar()->isVisible()); - // now remove just one single pixel in with -> both scroll bars will show up since they depend on each other + // now remove just one single pixel in width -> both scroll bars will show up since they depend on each other view->resize(itemSize.width() + view->frameWidth() * 2 - 1, model.rowCount() * itemSize.height() + view->frameWidth() * 2); QTRY_VERIFY(view->horizontalScrollBar()->isVisible()); QTRY_VERIFY(view->verticalScrollBar()->isVisible()); @@ -2423,6 +2440,11 @@ void tst_QListView::taskQTBUG_39902_mutualScrollBars() view->resize(itemSize.width() + view->frameWidth() * 2, model.rowCount() * itemSize.height() + view->frameWidth() * 2); QTRY_VERIFY(!view->horizontalScrollBar()->isVisible()); QTRY_VERIFY(!view->verticalScrollBar()->isVisible()); + + // now remove just one single pixel in height -> both scroll bars will show up since they depend on each other + view->resize(itemSize.width() + view->frameWidth() * 2, model.rowCount() * itemSize.height() + view->frameWidth() * 2 - 1); + QTRY_VERIFY(view->horizontalScrollBar()->isVisible()); + QTRY_VERIFY(view->verticalScrollBar()->isVisible()); } void tst_QListView::horizontalScrollingByVerticalWheelEvents() diff --git a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp index 6d2b2ea964..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; @@ -1565,5 +1566,23 @@ void tst_QTableWidget::mimeData() 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/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp index 4bdb299213..5188dfbcfa 100644 --- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp @@ -338,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)); + + QWidget w2; + w2.show(); + QVERIFY(QTest::qWaitForWindowActive(&w2)); + + QWidget w3; + w3.setAttribute(Qt::WA_ShowWithoutActivating); + w3.show(); + QVERIFY(!QTest::qWaitForWindowActive(&w3)); - 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 + w3.activateWindow(); + QVERIFY(QTest::qWaitForWindowActive(&w3)); } void tst_QWidget_window::tst_paintEventOnSecondShow() diff --git a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp b/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp index f19ef391ff..781adeedad 100644 --- a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp +++ b/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp @@ -193,9 +193,7 @@ private slots: void deleteStack(); void checkSignals(); void addStackAndDie(); -#ifndef QT_NO_PROCESS void commandTextFormat(); -#endif }; tst_QUndoGroup::tst_QUndoGroup() @@ -599,9 +597,11 @@ void tst_QUndoGroup::addStackAndDie() delete stack; } -#ifndef QT_NO_PROCESS void tst_QUndoGroup::commandTextFormat() { +#ifdef QT_NO_PROCESS + QSKIP("No QProcess available"); +#else QString binDir = QLibraryInfo::location(QLibraryInfo::BinariesPath); if (QProcess::execute(binDir + "/lrelease -version") != 0) @@ -643,8 +643,8 @@ void tst_QUndoGroup::commandTextFormat() QCOMPARE(redo_action->text(), QString("redo-prefix append redo-suffix")); qApp->removeTranslator(&translator); -} #endif +} #else class tst_QUndoGroup : public QObject diff --git a/tests/auto/widgets/util/qundostack/tst_qundostack.cpp b/tests/auto/widgets/util/qundostack/tst_qundostack.cpp index 29bc14f372..2c8a9a3ee5 100644 --- a/tests/auto/widgets/util/qundostack/tst_qundostack.cpp +++ b/tests/auto/widgets/util/qundostack/tst_qundostack.cpp @@ -239,9 +239,7 @@ private slots: void macroBeginEnd(); void compression(); void undoLimit(); -#ifndef QT_NO_PROCESS void commandTextFormat(); -#endif void separateUndoText(); }; @@ -2958,9 +2956,11 @@ void tst_QUndoStack::undoLimit() true); // redoChanged } -#ifndef QT_NO_PROCESS void tst_QUndoStack::commandTextFormat() { +#ifdef QT_NO_PROCESS + QSKIP("No QProcess available"); +#else QString binDir = QLibraryInfo::location(QLibraryInfo::BinariesPath); if (QProcess::execute(binDir + "/lrelease -version") != 0) @@ -2999,8 +2999,8 @@ void tst_QUndoStack::commandTextFormat() QCOMPARE(redo_action->text(), QString("redo-prefix append redo-suffix")); qApp->removeTranslator(&translator); -} #endif +} void tst_QUndoStack::separateUndoText() { |