diff options
author | Justin McPherson <justin.mcpherson@nokia.com> | 2010-04-22 23:54:51 (GMT) |
---|---|---|
committer | Justin McPherson <justin.mcpherson@nokia.com> | 2010-04-22 23:54:51 (GMT) |
commit | 478e914638f2131d1547c4e2dc4659723657194d (patch) | |
tree | c9f63e6bd79dce411ae059b1bb65a66db6584264 /tests | |
parent | 6b30ee9d2219308605e0d1b15ea1c74dc5cb67fe (diff) | |
parent | 4894e6dd57c31e0196c6fdae4d1b2fb16b9f1b16 (diff) | |
download | Qt-478e914638f2131d1547c4e2dc4659723657194d.zip Qt-478e914638f2131d1547c4e2dc4659723657194d.tar.gz Qt-478e914638f2131d1547c4e2dc4659723657194d.tar.bz2 |
Merge branch '4.7' of ../../qt/4.7 into 4.7
Conflicts:
demos/multimedia/player/player.pro
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/collections/tst_collections.cpp | 1 | ||||
-rw-r--r-- | tests/auto/qdialog/tst_qdialog.cpp | 8 | ||||
-rw-r--r-- | tests/auto/qdiriterator/tst_qdiriterator.cpp | 10 | ||||
-rw-r--r-- | tests/auto/qfiledialog/tst_qfiledialog.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 38 | ||||
-rw-r--r-- | tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 28 | ||||
-rw-r--r-- | tests/auto/qhostinfo/tst_qhostinfo.cpp | 45 | ||||
-rw-r--r-- | tests/auto/qicon/tst_qicon.cpp | 23 | ||||
-rw-r--r-- | tests/auto/qitemmodel/tst_qitemmodel.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qlistview/tst_qlistview.cpp | 31 | ||||
-rw-r--r-- | tests/auto/qthread/tst_qthread.cpp | 4 | ||||
-rw-r--r-- | tests/benchmarks/corelib/kernel/qobject/main.cpp | 9 | ||||
-rw-r--r-- | tests/benchmarks/corelib/kernel/qobject/object.cpp | 3 | ||||
-rw-r--r-- | tests/benchmarks/corelib/kernel/qobject/object.h | 1 |
14 files changed, 176 insertions, 29 deletions
diff --git a/tests/auto/collections/tst_collections.cpp b/tests/auto/collections/tst_collections.cpp index e7b01a1..d092c34 100644 --- a/tests/auto/collections/tst_collections.cpp +++ b/tests/auto/collections/tst_collections.cpp @@ -2260,7 +2260,6 @@ void tst_Collections::qstring() QVERIFY(s.isNull()); QVERIFY(s.toLocal8Bit().size() == 0); QVERIFY(s.toLocal8Bit().isEmpty()); - QVERIFY(!s.toLocal8Bit().isNull()); s = "first-ascii"; QVERIFY(s.toAscii() == "first-ascii"); diff --git a/tests/auto/qdialog/tst_qdialog.cpp b/tests/auto/qdialog/tst_qdialog.cpp index 86f87b8..8b6aee6 100644 --- a/tests/auto/qdialog/tst_qdialog.cpp +++ b/tests/auto/qdialog/tst_qdialog.cpp @@ -447,7 +447,7 @@ void tst_QDialog::deleteInExec() } #ifndef QT_NO_EXCEPTIONS -class QDialogTestException { }; +class QDialogTestException : public std::exception { }; class ExceptionDialog : public QDialog { @@ -471,11 +471,17 @@ void tst_QDialog::throwInExec() try { ExceptionDialog dialog; QMetaObject::invokeMethod(&dialog, "throwException", Qt::QueuedConnection); + QMetaObject::invokeMethod(&dialog, "reject", Qt::QueuedConnection); (void) dialog.exec(); } catch(...) { ++caughtExceptions; } +#ifdef Q_OS_SYMBIAN + //on symbian, the event loop absorbs exceptions + QCOMPARE(caughtExceptions, 0); +#else QCOMPARE(caughtExceptions, 1); +#endif } #else void tst_QDialog::throwInExec() diff --git a/tests/auto/qdiriterator/tst_qdiriterator.cpp b/tests/auto/qdiriterator/tst_qdiriterator.cpp index c1db8f2..1a873b8 100644 --- a/tests/auto/qdiriterator/tst_qdiriterator.cpp +++ b/tests/auto/qdiriterator/tst_qdiriterator.cpp @@ -85,11 +85,13 @@ private: // convenience functions return false; } - bool createFile(const QString &fileName) + enum Cleanup { DoDelete, DontDelete }; + bool createFile(const QString &fileName, Cleanup cleanup = DoDelete) { QFile file(fileName); if (file.open(QIODevice::WriteOnly)) { - createdFiles << fileName; + if (cleanup == DoDelete) + createdFiles << fileName; return true; } return false; @@ -131,9 +133,9 @@ tst_QDirIterator::tst_QDirIterator() createDirectory("entrylist"); createDirectory("entrylist/directory"); - createFile("entrylist/file"); + createFile("entrylist/file", DontDelete); createFile("entrylist/writable"); - createFile("entrylist/directory/dummy"); + createFile("entrylist/directory/dummy", DontDelete); createDirectory("recursiveDirs"); createDirectory("recursiveDirs/dir1"); diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp index 9adb4fc..38a1ee7 100644 --- a/tests/auto/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp @@ -548,7 +548,7 @@ void tst_QFiledialog::completer() // ### FIXME: This will fail on Symbian on some tests and some environments until the file engine and QFileSystemModel // are fixed to properly capitalize paths, so that some folders are not duplicated in QFileSystemModel. #if defined(Q_OS_SYMBIAN) - QSKIP("This will fail on Symbian on some tests and some environments until the file engine and QFileSystemModel are fixed to properly capitalize paths") + QSKIP("This will fail on Symbian on some tests and some environments until the file engine and QFileSystemModel are fixed to properly capitalize paths", SkipAll); #endif QTRY_COMPARE(cModel->rowCount(), expected); } QT_CATCH(...) { diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 03ce45a..e2f7f18 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -62,6 +62,7 @@ #include <QVBoxLayout> #include <QGraphicsEffect> #include <QInputContext> +#include <QPushButton> #include "../../shared/util.h" @@ -426,6 +427,7 @@ private slots: void itemIsInFront(); void scenePosChange(); void updateMicroFocus(); + void textItem_shortcuts(); // task specific tests below me void task141694_textItemEnsureVisible(); @@ -10060,6 +10062,42 @@ void tst_QGraphicsItem::updateMicroFocus() QTRY_COMPARE(ic2.nbUpdates, 0); } +void tst_QGraphicsItem::textItem_shortcuts() +{ + QWidget w; + QVBoxLayout l; + w.setLayout(&l); + QGraphicsScene scene; + QGraphicsView view(&scene); + l.addWidget(&view); + QPushButton b("Push Me"); + l.addWidget(&b); + + QGraphicsTextItem *item = scene.addText("Troll Text"); + item->setFlag(QGraphicsItem::ItemIsFocusable); + item->setTextInteractionFlags(Qt::TextEditorInteraction); + w.show(); + QTest::qWaitForWindowShown(&w); + + item->setFocus(); + QTRY_VERIFY(item->hasFocus()); + QVERIFY(item->textCursor().selectedText().isEmpty()); + + // Shortcut should work (select all) + QTest::keyClick(&view, Qt::Key_A, Qt::ControlModifier); + QTRY_COMPARE(item->textCursor().selectedText(), item->toPlainText()); + QTextCursor tc = item->textCursor(); + tc.clearSelection(); + item->setTextCursor(tc); + QVERIFY(item->textCursor().selectedText().isEmpty()); + + // Shortcut should also work if the text item has the focus and another widget + // has the same shortcut. + b.setShortcut(QKeySequence("CTRL+A")); + QTest::keyClick(&view, Qt::Key_A, Qt::ControlModifier); + QTRY_COMPARE(item->textCursor().selectedText(), item->toPlainText()); +} + void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor() { struct Item : public QGraphicsTextItem diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index 1c19fab..5e889f4 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -239,6 +239,7 @@ private slots: void QTBUG_4151_clipAndIgnore_data(); void QTBUG_4151_clipAndIgnore(); void QTBUG_5859_exposedRect(); + void QTBUG_7438_cursor(); }; void tst_QGraphicsView::initTestCase() @@ -4063,5 +4064,32 @@ void tst_QGraphicsView::QTBUG_5859_exposedRect() QCOMPARE(item.lastExposedRect, scene.lastBackgroundExposedRect); } +void tst_QGraphicsView::QTBUG_7438_cursor() +{ +#ifndef QT_NO_CURSOR +#if defined(Q_OS_WINCE) + QSKIP("Qt/CE does not have regular cursor support", SkipAll); +#endif + QGraphicsScene scene; + QGraphicsItem *item = scene.addRect(QRectF(-10, -10, 20, 20)); + item->setFlag(QGraphicsItem::ItemIsMovable); + + QGraphicsView view(&scene); + view.setFixedSize(400, 400); + view.show(); + QTest::qWaitForWindowShown(&view); + + QCOMPARE(view.viewport()->cursor().shape(), QCursor().shape()); + view.viewport()->setCursor(Qt::PointingHandCursor); + QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); + sendMouseMove(view.viewport(), view.mapFromScene(0, 0)); + QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); + sendMousePress(view.viewport(), view.mapFromScene(0, 0)); + QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); + sendMouseRelease(view.viewport(), view.mapFromScene(0, 0)); + QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); +#endif +} + QTEST_MAIN(tst_QGraphicsView) #include "tst_qgraphicsview.moc" diff --git a/tests/auto/qhostinfo/tst_qhostinfo.cpp b/tests/auto/qhostinfo/tst_qhostinfo.cpp index 4282062..c336746 100644 --- a/tests/auto/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/qhostinfo/tst_qhostinfo.cpp @@ -128,6 +128,7 @@ private slots: void threadSafety(); void multipleSameLookups(); + void multipleDifferentLookups_data(); void multipleDifferentLookups(); void cache(); @@ -441,36 +442,46 @@ void tst_QHostInfo::multipleSameLookups() for (int i = 0; i < COUNT; i++) QHostInfo::lookupHost("localhost", this, SLOT(resultsReady(const QHostInfo))); - QTRY_VERIFY(lookupsDoneCounter == COUNT); - - // spin two seconds more to see if it is not more :) - QTestEventLoop::instance().enterLoop(2); - QTRY_VERIFY(lookupsDoneCounter == COUNT); + QElapsedTimer timer; + timer.start(); + while (timer.elapsed() < 10000 && lookupsDoneCounter < COUNT) { + QTestEventLoop::instance().enterLoop(2); + } + QCOMPARE(lookupsDoneCounter, COUNT); } // this test is for the multi-threaded QHostInfo rewrite. It is about getting results at all, // not about getting correct IPs +void tst_QHostInfo::multipleDifferentLookups_data() +{ + QTest::addColumn<int>("repeats"); + QTest::newRow("1") << 1; + QTest::newRow("2") << 2; + QTest::newRow("5") << 5; + QTest::newRow("10") << 10; +} + void tst_QHostInfo::multipleDifferentLookups() { QStringList hostnameList; hostnameList << "www.ovi.com" << "www.nokia.com" << "qt.nokia.com" << "www.trolltech.com" << "troll.no" - << "www.qtcentre.org" << "forum.nokia.com" << "www.forum.nokia.com" << "wiki.forum.nokia.com" - << "www.nokia.no" << "nokia.de" << "127.0.0.1" << "----"; + << "www.qtcentre.org" << "forum.nokia.com" << "www.nokia.com" << "wiki.forum.nokia.com" + << "www.nokia.com" << "nokia.de" << "127.0.0.1" << "----"; + QFETCH(int, repeats); const int COUNT = hostnameList.size(); lookupsDoneCounter = 0; for (int i = 0; i < hostnameList.size(); i++) - QHostInfo::lookupHost(hostnameList.at(i), this, SLOT(resultsReady(const QHostInfo))); - - // give some time - QTestEventLoop::instance().enterLoop(5); - // try_verify gives some more time - QTRY_VERIFY(lookupsDoneCounter == COUNT); + for (int j = 0; j < repeats; ++j) + QHostInfo::lookupHost(hostnameList.at(i), this, SLOT(resultsReady(const QHostInfo))); - // spin two seconds more to see if it is not more than expected - QTestEventLoop::instance().enterLoop(2); - QTRY_VERIFY(lookupsDoneCounter == COUNT); + QElapsedTimer timer; + timer.start(); + while (timer.elapsed() < 10000 && lookupsDoneCounter < repeats*COUNT) { + QTestEventLoop::instance().enterLoop(2); + } + QCOMPARE(lookupsDoneCounter, repeats*COUNT); } void tst_QHostInfo::cache() @@ -517,7 +528,7 @@ void tst_QHostInfo::resultsReady(const QHostInfo &hi) lookupDone = true; lookupResults = hi; lookupsDoneCounter++; - QTestEventLoop::instance().exitLoop(); + QMetaObject::invokeMethod(&QTestEventLoop::instance(), "exitLoop", Qt::QueuedConnection); } QTEST_MAIN(tst_QHostInfo) diff --git a/tests/auto/qicon/tst_qicon.cpp b/tests/auto/qicon/tst_qicon.cpp index fae9cc0..e68664c 100644 --- a/tests/auto/qicon/tst_qicon.cpp +++ b/tests/auto/qicon/tst_qicon.cpp @@ -76,6 +76,7 @@ private slots: void svg(); void addFile(); void availableSizes(); + void name(); void streamAvailableSizes_data(); void streamAvailableSizes(); void fromTheme(); @@ -550,6 +551,28 @@ void tst_QIcon::availableSizes() } } +void tst_QIcon::name() +{ + { + // No name if icon does not come from a theme + QIcon icon(":/image.png"); + QString name = icon.name(); + QVERIFY(name.isEmpty()); + } + + { + // Getting the name of an icon coming from a theme should work + QString searchPath = QLatin1String(":/icons"); + QIcon::setThemeSearchPaths(QStringList() << searchPath); + QString themeName("testtheme"); + QIcon::setThemeName(themeName); + + QIcon icon = QIcon::fromTheme("appointment-new"); + QString name = icon.name(); + QCOMPARE(name, QLatin1String("appointment-new")); + } +} + void tst_QIcon::streamAvailableSizes_data() { QTest::addColumn<QIcon>("icon"); diff --git a/tests/auto/qitemmodel/tst_qitemmodel.cpp b/tests/auto/qitemmodel/tst_qitemmodel.cpp index f466045..d36df9c 100644 --- a/tests/auto/qitemmodel/tst_qitemmodel.cpp +++ b/tests/auto/qitemmodel/tst_qitemmodel.cpp @@ -452,7 +452,7 @@ void checkChildren(QAbstractItemModel *currentModel, const QModelIndex &parent, QCOMPARE(index.column(), c); QCOMPARE(currentModel->data(index, Qt::DisplayRole).isValid(), true); - // If the next test fails here is some somewhat usefull debug you play with. + // If the next test fails here is some somewhat useful debug you play with. /* if (currentModel->parent(index) != parent) { qDebug() << r << c << currentDepth << currentModel->data(index).toString() diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index f5c32cd..330f803 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -124,6 +124,7 @@ private slots: void taskQTBUG_2678_spacingAndWrappedText(); void taskQTBUG_5877_skippingItemInPageDownUp(); void taskQTBUG_9455_wrongScrollbarRanges(); + void styleOptionViewItem(); }; // Testing get/set functions @@ -1971,5 +1972,35 @@ void tst_QListView::taskQTBUG_9455_wrongScrollbarRanges() QCOMPARE(w.verticalScrollBar()->maximum(), w.contentsSize().height() - w.viewport()->geometry().height()); } +void tst_QListView::styleOptionViewItem() +{ + class MyDelegate : public QStyledItemDelegate + { + public: + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const + { + QVERIFY(qstyleoption_cast<const QStyleOptionViewItemV4 *>(&option)); + QStyleOptionViewItemV4 opt(option); + initStyleOption(&opt, index); + + QCOMPARE(opt.index, index); + + QStyledItemDelegate::paint(painter, option, index); + } + }; + + QListView view; + QStandardItemModel model; + view.setModel(&model); + MyDelegate delegate; + view.setItemDelegate(&delegate); + model.appendRow(QList<QStandardItem*>() + << new QStandardItem("Beginning") << new QStandardItem("Middle") << new QStandardItem("Middle") << new QStandardItem("End") ); + + // Run test + view.showMaximized(); + QApplication::processEvents(); +} + QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" diff --git a/tests/auto/qthread/tst_qthread.cpp b/tests/auto/qthread/tst_qthread.cpp index 9a4397e..7a5b053 100644 --- a/tests/auto/qthread/tst_qthread.cpp +++ b/tests/auto/qthread/tst_qthread.cpp @@ -442,9 +442,9 @@ void tst_QThread::exit() thread2.object = 0; thread2.code = 53; thread2.result = 0; + QMutexLocker locker2(&thread2.mutex); thread2.start(); thread2.exit(thread2.code); - QMutexLocker locker2(&thread2.mutex); thread2.cond.wait(locker2.mutex()); QVERIFY(thread2.wait(five_minutes)); QCOMPARE(thread2.result, thread2.code); @@ -514,9 +514,9 @@ void tst_QThread::quit() Quit_Thread thread2; thread2.object = 0; thread2.result = -1; + QMutexLocker locker2(&thread2.mutex); thread2.start(); thread2.quit(); - QMutexLocker locker2(&thread2.mutex); thread2.cond.wait(locker2.mutex()); QVERIFY(thread2.wait(five_minutes)); QCOMPARE(thread2.result, 0); diff --git a/tests/benchmarks/corelib/kernel/qobject/main.cpp b/tests/benchmarks/corelib/kernel/qobject/main.cpp index 7f24ebd..8d05fcd 100644 --- a/tests/benchmarks/corelib/kernel/qobject/main.cpp +++ b/tests/benchmarks/corelib/kernel/qobject/main.cpp @@ -69,6 +69,7 @@ void QObjectBenchmark::signal_slot_benchmark_data() QTest::newRow("simple function") << 0; QTest::newRow("single signal/slot") << 1; QTest::newRow("multi signal/slot") << 2; + QTest::newRow("unconnected signal") << 3; } void QObjectBenchmark::signal_slot_benchmark() @@ -110,9 +111,13 @@ void QObjectBenchmark::signal_slot_benchmark() QBENCHMARK { singleObject.emitSignal0(); } - } else { + } else if (type == 2) { QBENCHMARK { - multiObject.emitSignal0(); + multiObject.emitSignal0(); + } + } else if (type == 3) { + QBENCHMARK { + singleObject.emitSignal1(); } } } diff --git a/tests/benchmarks/corelib/kernel/qobject/object.cpp b/tests/benchmarks/corelib/kernel/qobject/object.cpp index d775a32..3920e97 100644 --- a/tests/benchmarks/corelib/kernel/qobject/object.cpp +++ b/tests/benchmarks/corelib/kernel/qobject/object.cpp @@ -42,6 +42,9 @@ void Object::emitSignal0() { emit signal0(); } +void Object::emitSignal1() +{ emit signal1(); } + void Object::slot0() { } diff --git a/tests/benchmarks/corelib/kernel/qobject/object.h b/tests/benchmarks/corelib/kernel/qobject/object.h index 7e4933f..8f8fbe9 100644 --- a/tests/benchmarks/corelib/kernel/qobject/object.h +++ b/tests/benchmarks/corelib/kernel/qobject/object.h @@ -48,6 +48,7 @@ class Object : public QObject Q_OBJECT public: void emitSignal0(); + void emitSignal1(); signals: void signal0(); void signal1(); |