diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2009-09-15 23:45:32 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2009-09-15 23:45:32 (GMT) |
commit | 4e2163a5c4eec9eeacf8c7260dbf8fb7c74d2b44 (patch) | |
tree | 31d86c91c526563302887e756ce5f7876f274223 /tests | |
parent | adfb5c6160b37a917f20b301366567c208ae52a0 (diff) | |
parent | dcd4b15595a63864ee59a19d80f1ba33b4821aa3 (diff) | |
download | Qt-4e2163a5c4eec9eeacf8c7260dbf8fb7c74d2b44.zip Qt-4e2163a5c4eec9eeacf8c7260dbf8fb7c74d2b44.tar.gz Qt-4e2163a5c4eec9eeacf8c7260dbf8fb7c74d2b44.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into 4.6
Diffstat (limited to 'tests')
28 files changed, 950 insertions, 22 deletions
diff --git a/tests/auto/linguist/lupdate/testdata/good/backslashes/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/backslashes/project.ts.result index f2d109b..d3a5fdf 100644 --- a/tests/auto/linguist/lupdate/testdata/good/backslashes/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/backslashes/project.ts.result @@ -4,7 +4,7 @@ <context> <name>QApplication</name> <message> - <location filename="../src/main.cpp" line="10"/> + <location filename="../src/main.cpp" line="51"/> <source>QT_LAYOUT_DIRECTION</source> <comment>Translate this string to the string 'LTR' in left-to-right languages or to 'RTL' in right-to-left languages (such as Hebrew and Arabic) to get proper widget layout.</comment> <translation type="unfinished"></translation> diff --git a/tests/auto/linguist/lupdate/testdata/good/parseui/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parseui/project.ts.result index 93adae4..b27d239 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parseui/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/parseui/project.ts.result @@ -4,12 +4,12 @@ <context> <name>FindDialog</name> <message> - <location filename="project.ui" line="48"/> + <location filename="project.ui" line="55"/> <source>Qt Assistant - Finn text</source> <translation type="unfinished"></translation> </message> <message utf8="true"> - <location filename="project.ui" line="51"/> + <location filename="project.ui" line="58"/> <source>Finn tekst - Der Bjørn möchte auch mal.</source> <translation type="unfinished"></translation> </message> diff --git a/tests/auto/macplist/tst_macplist.cpp b/tests/auto/macplist/tst_macplist.cpp index 7a2b1d8..aa52b95 100644 --- a/tests/auto/macplist/tst_macplist.cpp +++ b/tests/auto/macplist/tst_macplist.cpp @@ -171,7 +171,6 @@ void tst_MacPlist::test_plist() QVERIFY(dir.cdUp()); QVERIFY(dir.cdUp()); QVERIFY(dir.cdUp()); - QVERIFY(dir.cdUp()); QVERIFY(dir.cd(QLatin1String("app"))); QVERIFY(dir.cd(QLatin1String("app.app"))); QVERIFY(dir.cd(QLatin1String("Contents"))); diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index 810be04..da97c7d 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -2371,7 +2371,7 @@ void tst_QComboBox::task260974_menuItemRectangleForComboBoxPopup() comboBox.showPopup(); QTest::qWait(100); - QVERIFY(style.discoveredRect.width() <= comboBox.width()); + QTRY_VERIFY(style.discoveredRect.width() <= comboBox.width()); } } diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index 059ad33..5bb3746 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -1079,9 +1079,15 @@ void tst_QGraphicsAnchorLayout::delete_anchor() QVERIFY(anchor1); QGraphicsAnchor *anchor2 = l->anchor(w3, Qt::AnchorRight, l, Qt::AnchorRight); QVERIFY(anchor2); + QGraphicsAnchor *anchor3 = l->anchor(l, Qt::AnchorRight, w3, Qt::AnchorRight); + QVERIFY(anchor3); + QGraphicsAnchor *anchor4 = l->anchor(l, Qt::AnchorRight, w3, Qt::AnchorRight); + QVERIFY(anchor4); - // should be the same object + // should all be the same object QCOMPARE(anchor1, anchor2); + QCOMPARE(anchor2, anchor3); + QCOMPARE(anchor3, anchor4); // check if removal works delete anchor1; diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp index d5205cd..ba3783b 100644 --- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp @@ -41,6 +41,7 @@ #include <QtTest/QtTest> +#include <QtGui/qdesktopwidget.h> #include <QtGui/qgraphicseffect.h> #include <QtGui/qgraphicsview.h> #include <QtGui/qgraphicsscene.h> @@ -369,6 +370,11 @@ void tst_QGraphicsEffect::opacity() void tst_QGraphicsEffect::grayscale() { + if (qApp->desktop()->depth() < 24) { + QSKIP("Test only works on 32 bit displays", SkipAll); + return; + } + QGraphicsScene scene(0, 0, 100, 100); QGraphicsRectItem *item = scene.addRect(0, 0, 50, 50); @@ -412,6 +418,11 @@ void tst_QGraphicsEffect::grayscale() void tst_QGraphicsEffect::colorize() { + if (qApp->desktop()->depth() < 24) { + QSKIP("Test only works on 32 bit displays", SkipAll); + return; + } + QGraphicsScene scene(0, 0, 100, 100); QGraphicsRectItem *item = scene.addRect(0, 0, 50, 50); diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 5e8f4c4..304330e 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -293,6 +293,8 @@ private slots: void setActivePanelOnInactiveScene(); void activationOnShowHide(); void moveWhileDeleting(); + void ensureDirtySceneTransform(); + void focusScope(); // task specific tests below me void task141694_textItemEnsureVisible(); @@ -7665,6 +7667,11 @@ void tst_QGraphicsItem::subFocus() QVERIFY(!rect->hasFocus()); QVERIFY(!rect2->hasFocus()); QVERIFY(rect3->hasFocus()); + + delete rect2; + QCOMPARE(text->focusItem(), (QGraphicsItem *)0); + QCOMPARE(text2->focusItem(), (QGraphicsItem *)0); + QCOMPARE(rect->focusItem(), (QGraphicsItem *)0); } void tst_QGraphicsItem::focusProxyDeletion() @@ -8156,5 +8163,192 @@ void tst_QGraphicsItem::moveWhileDeleting() delete rect; } +class MyRectItem : public QGraphicsWidget +{ + Q_OBJECT +public: + MyRectItem(QGraphicsItem *parent = 0) : QGraphicsWidget(parent) + { + + } + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) + { + painter->setBrush(brush); + painter->drawRect(boundingRect()); + } + void move() + { + setPos(-100,-100); + topLevel->collidingItems(Qt::IntersectsItemBoundingRect); + } +public: + QGraphicsItem *topLevel; + QBrush brush; +}; + + +void tst_QGraphicsItem::ensureDirtySceneTransform() +{ + QGraphicsScene scene; + + MyRectItem *topLevel = new MyRectItem; + topLevel->setGeometry(0, 0, 100, 100); + topLevel->setPos(-50, -50); + topLevel->brush = QBrush(QColor(Qt::black)); + scene.addItem(topLevel); + + MyRectItem *parent = new MyRectItem; + parent->topLevel = topLevel; + parent->setGeometry(0, 0, 100, 100); + parent->setPos(0, 0); + parent->brush = QBrush(QColor(Qt::magenta)); + parent->setObjectName("parent"); + scene.addItem(parent); + + MyRectItem *child = new MyRectItem(parent); + child->setGeometry(0, 0, 80, 80); + child->setPos(10, 10); + child->setObjectName("child"); + child->brush = QBrush(QColor(Qt::blue)); + + MyRectItem *child2 = new MyRectItem(parent); + child2->setGeometry(0, 0, 80, 80); + child2->setPos(15, 15); + child2->setObjectName("child2"); + child2->brush = QBrush(QColor(Qt::green)); + + MyRectItem *child3 = new MyRectItem(parent); + child3->setGeometry(0, 0, 80, 80); + child3->setPos(20, 20); + child3->setObjectName("child3"); + child3->brush = QBrush(QColor(Qt::gray)); + + QGraphicsView view(&scene); + view.show(); + QTRY_COMPARE(QApplication::activeWindow(), &view); + + //We move the parent + parent->move(); + QApplication::processEvents(); + + //We check if all items moved + QCOMPARE(child->pos(), QPointF(10, 10)); + QCOMPARE(child2->pos(), QPointF(15, 15)); + QCOMPARE(child3->pos(), QPointF(20, 20)); + + QCOMPARE(child->sceneBoundingRect(), QRectF(-90, -90, 80, 80)); + QCOMPARE(child2->sceneBoundingRect(), QRectF(-85, -85, 80, 80)); + QCOMPARE(child3->sceneBoundingRect(), QRectF(-80, -80, 80, 80)); + + QCOMPARE(child->sceneTransform(), QTransform::fromTranslate(-90, -90)); + QCOMPARE(child2->sceneTransform(), QTransform::fromTranslate(-85, -85)); + QCOMPARE(child3->sceneTransform(), QTransform::fromTranslate(-80, -80)); +} + +void tst_QGraphicsItem::focusScope() +{ + // ItemIsFocusScope is an internal feature (for now). + QGraphicsScene scene; + + QGraphicsRectItem *scope3 = new QGraphicsRectItem; + scope3->setData(0, "scope3"); + scope3->setFlags(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemIsFocusScope); + scope3->setFocus(); + QVERIFY(!scope3->focusScopeItem()); + QCOMPARE(scope3->focusItem(), (QGraphicsItem *)scope3); + + QGraphicsRectItem *scope2 = new QGraphicsRectItem; + scope2->setData(0, "scope2"); + scope2->setFlags(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemIsFocusScope); + scope2->setFocus(); + QVERIFY(!scope2->focusScopeItem()); + scope3->setParentItem(scope2); + QCOMPARE(scope2->focusScopeItem(), (QGraphicsItem *)scope3); + QCOMPARE(scope2->focusItem(), (QGraphicsItem *)scope3); + + QGraphicsRectItem *scope1 = new QGraphicsRectItem; + scope1->setData(0, "scope1"); + scope1->setFlags(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemIsFocusScope); + scope1->setFocus(); + QVERIFY(!scope1->focusScopeItem()); + scope2->setParentItem(scope1); + + QCOMPARE(scope1->focusItem(), (QGraphicsItem *)scope3); + QCOMPARE(scope2->focusItem(), (QGraphicsItem *)scope3); + QCOMPARE(scope3->focusItem(), (QGraphicsItem *)scope3); + QCOMPARE(scope1->focusScopeItem(), (QGraphicsItem *)scope2); + QCOMPARE(scope2->focusScopeItem(), (QGraphicsItem *)scope3); + QCOMPARE(scope3->focusScopeItem(), (QGraphicsItem *)0); + + scene.addItem(scope1); + + QEvent windowActivate(QEvent::WindowActivate); + qApp->sendEvent(&scene, &windowActivate); + scene.setFocus(); + + QCOMPARE(scope1->focusItem(), (QGraphicsItem *)scope3); + QCOMPARE(scope2->focusItem(), (QGraphicsItem *)scope3); + QCOMPARE(scope3->focusItem(), (QGraphicsItem *)scope3); + QCOMPARE(scope1->focusScopeItem(), (QGraphicsItem *)scope2); + QCOMPARE(scope2->focusScopeItem(), (QGraphicsItem *)scope3); + QCOMPARE(scope3->focusScopeItem(), (QGraphicsItem *)0); + + QVERIFY(scope3->hasFocus()); + + scope3->hide(); + QVERIFY(scope2->hasFocus()); + scope2->hide(); + QVERIFY(scope1->hasFocus()); + scope2->show(); + QVERIFY(scope2->hasFocus()); + scope3->show(); + QVERIFY(scope3->hasFocus()); + scope1->hide(); + QVERIFY(!scope3->hasFocus()); + scope1->show(); + QVERIFY(scope3->hasFocus()); + scope3->clearFocus(); + QVERIFY(scope2->hasFocus()); + scope2->clearFocus(); + QVERIFY(scope1->hasFocus()); + scope2->hide(); + scope2->show(); + QVERIFY(!scope2->hasFocus()); + QVERIFY(scope3->hasFocus()); + + QGraphicsRectItem *rect4 = new QGraphicsRectItem; + rect4->setData(0, "rect4"); + rect4->setParentItem(scope3); + + QGraphicsRectItem *rect5 = new QGraphicsRectItem; + rect5->setData(0, "rect5"); + rect5->setFlags(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemIsFocusScope); + rect5->setFocus(); + rect5->setParentItem(rect4); + QCOMPARE(scope3->focusScopeItem(), (QGraphicsItem *)rect5); + QVERIFY(rect5->hasFocus()); + + rect4->setParentItem(0); + QCOMPARE(scope3->focusScopeItem(), (QGraphicsItem *)0); + QVERIFY(!scope3->hasFocus()); + + QGraphicsRectItem *rectA = new QGraphicsRectItem; + QGraphicsRectItem *scopeA = new QGraphicsRectItem(rectA); + scopeA->setFlags(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemIsFocusScope); + scopeA->setFocus(); + QGraphicsRectItem *scopeB = new QGraphicsRectItem(scopeA); + scopeB->setFlags(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemIsFocusScope); + scopeB->setFocus(); + + scene.addItem(rectA); + QVERIFY(rect5->hasFocus()); + QVERIFY(!scopeB->hasFocus()); + + scopeA->setFocus(); + QVERIFY(scopeB->hasFocus()); + QCOMPARE(scopeB->focusItem(), (QGraphicsItem *)scopeB); +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 626a691..c86d9e3 100644 --- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -1507,7 +1507,7 @@ void tst_QGraphicsProxyWidget::scrollUpdate() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif - QTRY_COMPARE(view.npaints, 1); + QTRY_VERIFY(view.npaints >= 1); QTest::qWait(20); widget->paintEventRegion = QRegion(); widget->npaints = 0; diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index 6998684..07d7cce 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -264,6 +264,8 @@ private slots: void inputMethod_data(); void inputMethod(); void dispatchHoverOnPress(); + void initialFocus_data(); + void initialFocus(); // task specific tests below me void task139710_bspTreeCrash(); @@ -3822,5 +3824,61 @@ void tst_QGraphicsScene::dispatchHoverOnPress() } } +void tst_QGraphicsScene::initialFocus_data() +{ + QTest::addColumn<bool>("activeScene"); + QTest::addColumn<bool>("explicitSetFocus"); + QTest::addColumn<bool>("isPanel"); + QTest::addColumn<bool>("shouldHaveFocus"); + + QTest::newRow("inactive scene, normal item") << false << false << false << false; + QTest::newRow("inactive scene, panel item") << false << false << true << false; + QTest::newRow("inactive scene, normal item, explicit focus") << false << true << false << true; + QTest::newRow("inactive scene, panel, explicit focus") << false << true << true << true; + QTest::newRow("active scene, normal item") << true << false << false << false; + QTest::newRow("active scene, panel item") << true << false << true << false; + QTest::newRow("active scene, normal item, explicit focus") << true << true << false << true; + QTest::newRow("active scene, panel, explicit focus") << true << true << true << true; +} + +void tst_QGraphicsScene::initialFocus() +{ + QFETCH(bool, activeScene); + QFETCH(bool, explicitSetFocus); + QFETCH(bool, isPanel); + QFETCH(bool, shouldHaveFocus); + + QGraphicsRectItem *rect = new QGraphicsRectItem; + rect->setFlag(QGraphicsItem::ItemIsFocusable); + QVERIFY(!rect->hasFocus()); + + if (isPanel) + rect->setFlag(QGraphicsItem::ItemIsPanel); + + // Setting focus on an item before adding to the scene will ensure + // it gets focus when the scene is activated. + if (explicitSetFocus) + rect->setFocus(); + + QGraphicsScene scene; + QVERIFY(!scene.isActive()); + + if (activeScene) { + QEvent windowActivate(QEvent::WindowActivate); + qApp->sendEvent(&scene, &windowActivate); + scene.setFocus(); + } + + scene.addItem(rect); + + if (!activeScene) { + QEvent windowActivate(QEvent::WindowActivate); + qApp->sendEvent(&scene, &windowActivate); + scene.setFocus(); + } + + QCOMPARE(rect->hasFocus(), shouldHaveFocus); +} + QTEST_MAIN(tst_QGraphicsScene) #include "tst_qgraphicsscene.moc" diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index 6c1ac54..5cb9173 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -3072,9 +3072,11 @@ void tst_QGraphicsView::scrollAfterResize_data() QTest::addColumn<QTransform>("x2"); QTest::addColumn<QTransform>("x3"); - int frameWidth = qApp->style()->pixelMetric(QStyle::PM_DefaultFrameWidth); - int extent = qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent); - int inside = qApp->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents); + QPlastiqueStyle style; + + int frameWidth = style.pixelMetric(QStyle::PM_DefaultFrameWidth); + int extent = style.pixelMetric(QStyle::PM_ScrollBarExtent); + int inside = style.styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents); int viewportWidth = 300; int scrollBarIndent = viewportWidth - extent - (inside ? 4 : 2)*frameWidth; @@ -3095,7 +3097,9 @@ void tst_QGraphicsView::scrollAfterResize() QFETCH(QTransform, x2); QFETCH(QTransform, x3); + QPlastiqueStyle style; QGraphicsView view; + view.setStyle(&style); if (reverse) view.setLayoutDirection(Qt::RightToLeft); diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp index 8630021..cab8fda 100644 --- a/tests/auto/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/qimagereader/tst_qimagereader.cpp @@ -167,6 +167,10 @@ private slots: void task255627_setNullScaledSize_data(); void task255627_setNullScaledSize(); + + void testIgnoresFormatAndExtension_data(); + void testIgnoresFormatAndExtension(); + }; static const QLatin1String prefix(SRCDIR "/images/"); @@ -225,6 +229,7 @@ void tst_QImageReader::readImage_data() QTest::newRow("PPM: runners") << QString("runners.ppm") << true << QByteArray("ppm"); QTest::newRow("PPM: test") << QString("test.ppm") << true << QByteArray("ppm"); QTest::newRow("XBM: gnus") << QString("gnus.xbm") << true << QByteArray("xbm"); + #if defined QTEST_HAVE_JPEG QTest::newRow("JPEG: beavis") << QString("beavis.jpg") << true << QByteArray("jpeg"); #endif @@ -1495,5 +1500,71 @@ void tst_QImageReader::pixelCompareWithBaseline() } } + +void tst_QImageReader::testIgnoresFormatAndExtension_data() +{ + QTest::addColumn<QString>("name"); + QTest::addColumn<QString>("extension"); + QTest::addColumn<QString>("expected"); + + QTest::newRow("black.png") << "black" << "png" << "png"; + QTest::newRow("black.xpm") << "black" << "xpm" << "xpm"; + QTest::newRow("colorful.bmp") << "colorful" << "bmp" << "bmp"; + QTest::newRow("image.ppm") << "image" << "ppm" << "ppm"; + QTest::newRow("image.pbm") << "image" << "pbm" << "pbm"; + QTest::newRow("image.pgm") << "image" << "pgm" << "pgm"; + +#if defined QTEST_HAVE_GIF + QTest::newRow("bat1.gif") << "bat1" << "gif" << "gif"; +#endif + +#if defined QTEST_HAVE_JPEG + QTest::newRow("beavis.jpg") << "beavis" << "jpg" << "jpeg"; +#endif + +#if defined QTEST_HAVE_MNG + QTest::newRow("fire.mng") << "fire" << "mng" << "mng"; +#endif + +#if defined QTEST_HAVE_TIFF + QTest::newRow("image_100dpi.tif") << "image_100dpi" << "tif" << "tiff"; +#endif +} + + +void tst_QImageReader::testIgnoresFormatAndExtension() +{ + QFETCH(QString, name); + QFETCH(QString, extension); + QFETCH(QString, expected); + + QList<QByteArray> formats = QImageReader::supportedImageFormats(); + QString fileNameBase = "images/" + name + "."; + + foreach (const QByteArray &f, formats) { + if (f == extension) + continue; + QFile tmp(QDir::tempPath() + "/" + name + "_" + expected + "." + f); + + QFile::copy(fileNameBase + extension, QFileInfo(tmp).absoluteFilePath()); + + QString format; + QImage image; + { + // image reader needs to be scoped for the remove() to work.. + QImageReader r; + r.setFileName(QFileInfo(tmp).absoluteFilePath()); + r.setDecideFormatFromContent(true); + format = r.format(); + r.read(&image); + } + + tmp.remove(); + + QVERIFY(!image.isNull()); + QCOMPARE(format, expected); + } +} + QTEST_MAIN(tst_QImageReader) #include "tst_qimagereader.moc" diff --git a/tests/auto/qprocess/tst_qprocess.cpp b/tests/auto/qprocess/tst_qprocess.cpp index 0291f66..cff6487 100644 --- a/tests/auto/qprocess/tst_qprocess.cpp +++ b/tests/auto/qprocess/tst_qprocess.cpp @@ -1164,7 +1164,7 @@ void tst_QProcess::softExitInSlots() SoftExitProcess proc(i); proc.start(appName); proc.write("OLEBOLE", 8); // include the \0 - QTestEventLoop::instance().enterLoop(1); + QTestEventLoop::instance().enterLoop(10); QCOMPARE(proc.state(), QProcess::NotRunning); QVERIFY(proc.waitedForFinished); } diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 86caddb..04b7b39 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -9236,13 +9236,15 @@ void tst_QWidget::destroyBackingStore() w.reset(); w.update(); - QApplication::processEvents(); delete qt_widget_private(&w)->topData()->backingStore; qt_widget_private(&w)->topData()->backingStore = 0; qt_widget_private(&w)->topData()->backingStore = new QWidgetBackingStore(&w); w.update(); QApplication::processEvents(); +#ifdef Q_WS_QWS + QApplication::processEvents(); +#endif QCOMPARE(w.numPaintEvents, 1); // Check one more time, because the second time around does more caching. @@ -9293,6 +9295,7 @@ void tst_QWidget::inputFocus_task257832() if (!context) QSKIP("No input context", SkipSingle); widget->setFocus(); + widget->winId(); // make sure, widget has been created context->setFocusWidget(widget); QCOMPARE(context->focusWidget(), static_cast<QWidget*>(widget)); widget->setReadOnly(true); diff --git a/tests/auto/uic/tst_uic.cpp b/tests/auto/uic/tst_uic.cpp index c4759e2..60367b9 100644 --- a/tests/auto/uic/tst_uic.cpp +++ b/tests/auto/uic/tst_uic.cpp @@ -55,16 +55,16 @@ class tst_uic : public QObject public: tst_uic(); - + private Q_SLOTS: void initTestCase(); - + void run(); void run_data() const; void compare(); void compare_data() const; - + void cleanupTestCase(); private: @@ -105,8 +105,8 @@ void tst_uic::initTestCase() qDebug() << msg; process.terminate(); - QCOMPARE(QFileInfo(QLatin1String("baseline")).exists(), true); - QCOMPARE(QFileInfo(QLatin1String("generated_ui")).exists(), true); + QCOMPARE(QFileInfo(QLatin1String(SRCDIR "baseline")).exists(), true); + QCOMPARE(QFileInfo(QLatin1String(SRCDIR "generated_ui")).exists(), true); } void tst_uic::run() @@ -163,23 +163,23 @@ void tst_uic::compare() QFile genFile(generatedFile); if (!orgFile.open(QIODevice::ReadOnly | QIODevice::Text)) { - QString err(QLatin1String("Could not read file: %1...")); + QString err(QLatin1String("Could not read file: %1...")); QFAIL(err.arg(orgFile.fileName()).toUtf8()); } if (!genFile.open(QIODevice::ReadOnly | QIODevice::Text)) { - QString err(QLatin1String("Could not read file: %1...")); + QString err(QLatin1String("Could not read file: %1...")); QFAIL(err.arg(genFile.fileName()).toUtf8()); } originalFile = orgFile.readAll(); originalFile.replace(QRegExp(QLatin1String("Created:.{0,25}[\\d]{4,4}")), ""); originalFile.replace(QRegExp(QLatin1String("by: Qt User Interface Compiler version [.\\d]{5,5}")), ""); - + generatedFile = genFile.readAll(); generatedFile.replace(QRegExp(QLatin1String("Created:.{0,25}[\\d]{4,4}")), ""); generatedFile.replace(QRegExp(QLatin1String("by: Qt User Interface Compiler version [.\\d]{5,5}")), ""); - + QCOMPARE(generatedFile, originalFile); } diff --git a/tests/auto/uic/uic.pro b/tests/auto/uic/uic.pro index 411a993..355cb56 100644 --- a/tests/auto/uic/uic.pro +++ b/tests/auto/uic/uic.pro @@ -5,4 +5,4 @@ SOURCES += tst_uic.cpp TARGET = tst_uic # This test is not run on wince (I think) -DEFINES += SRCDIR=\\\"$$PWD\\\" +DEFINES += SRCDIR=\\\"$$PWD/\\\" diff --git a/tests/manual/qcursor/allcursors/allcursors.pro b/tests/manual/qcursor/allcursors/allcursors.pro new file mode 100644 index 0000000..8e7da30 --- /dev/null +++ b/tests/manual/qcursor/allcursors/allcursors.pro @@ -0,0 +1,16 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2009-08-05T17:13:23 +# +#------------------------------------------------- + +TARGET = tst_allcursors +TEMPLATE = app + + +SOURCES += main.cpp\ + mainwindow.cpp + +HEADERS += mainwindow.h + +FORMS += mainwindow.ui diff --git a/tests/manual/qcursor/allcursors/main.cpp b/tests/manual/qcursor/allcursors/main.cpp new file mode 100644 index 0000000..9fb7510 --- /dev/null +++ b/tests/manual/qcursor/allcursors/main.cpp @@ -0,0 +1,13 @@ +#include <QtGui/QApplication> +#include "mainwindow.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.showFullScreen(); +#ifdef QT_KEYPAD_NAVIGATION + QApplication::setNavigationMode(Qt::NavigationModeCursorForceVisible); +#endif + return a.exec(); +} diff --git a/tests/manual/qcursor/allcursors/mainwindow.cpp b/tests/manual/qcursor/allcursors/mainwindow.cpp new file mode 100644 index 0000000..0046ddb --- /dev/null +++ b/tests/manual/qcursor/allcursors/mainwindow.cpp @@ -0,0 +1,43 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +#include <QTimer> +#include <QBitmap> +#include <QImage> +#include <QPainter> +#include <QKeyEvent> +#include <QPoint> + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::keyPressEvent(QKeyEvent* event) +{ + QPoint off(0, 0); + switch (event->key()) { + case Qt::Key_Up: + off.setY(-4); + break; + case Qt::Key_Down: + off.setY(4); + break; + case Qt::Key_Left: + off.setX(-4); + break; + case Qt::Key_Right: + off.setX(4); + break; + default: + return QMainWindow::keyPressEvent(event); + } + off += QCursor::pos(); + QCursor::setPos(off); +} diff --git a/tests/manual/qcursor/allcursors/mainwindow.h b/tests/manual/qcursor/allcursors/mainwindow.h new file mode 100644 index 0000000..e5c731c --- /dev/null +++ b/tests/manual/qcursor/allcursors/mainwindow.h @@ -0,0 +1,28 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QtGui/QMainWindow> + +class QTimer; + +namespace Ui +{ + class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private: + void keyPressEvent(QKeyEvent* event); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/tests/manual/qcursor/allcursors/mainwindow.ui b/tests/manual/qcursor/allcursors/mainwindow.ui new file mode 100644 index 0000000..55ff78c --- /dev/null +++ b/tests/manual/qcursor/allcursors/mainwindow.ui @@ -0,0 +1,210 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>240</width> + <height>320</height> + </rect> + </property> + <property name="windowTitle"> + <string>MainWindow</string> + </property> + <widget class="QWidget" name="centralwidget"> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Arrow</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="label_2"> + <property name="cursor"> + <cursorShape>UpArrowCursor</cursorShape> + </property> + <property name="text"> + <string>up arrow</string> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QLabel" name="label_3"> + <property name="cursor"> + <cursorShape>CrossCursor</cursorShape> + </property> + <property name="text"> + <string>cross</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_4"> + <property name="cursor"> + <cursorShape>WaitCursor</cursorShape> + </property> + <property name="text"> + <string>wait</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLabel" name="label_5"> + <property name="cursor"> + <cursorShape>IBeamCursor</cursorShape> + </property> + <property name="text"> + <string>ibeam</string> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QLabel" name="label_6"> + <property name="cursor"> + <cursorShape>SizeVerCursor</cursorShape> + </property> + <property name="text"> + <string>sizever</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_7"> + <property name="cursor"> + <cursorShape>SizeHorCursor</cursorShape> + </property> + <property name="text"> + <string>sizehor</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLabel" name="label_8"> + <property name="cursor"> + <cursorShape>SizeFDiagCursor</cursorShape> + </property> + <property name="text"> + <string>sizebdiag</string> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QLabel" name="label_9"> + <property name="cursor"> + <cursorShape>SizeBDiagCursor</cursorShape> + </property> + <property name="text"> + <string>sizefdiag</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_10"> + <property name="cursor"> + <cursorShape>SizeAllCursor</cursorShape> + </property> + <property name="text"> + <string>sizeall</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLabel" name="label_11"> + <property name="cursor"> + <cursorShape>BlankCursor</cursorShape> + </property> + <property name="text"> + <string>blank</string> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QLabel" name="label_12"> + <property name="cursor"> + <cursorShape>SplitVCursor</cursorShape> + </property> + <property name="text"> + <string>splitv</string> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="label_13"> + <property name="cursor"> + <cursorShape>SplitHCursor</cursorShape> + </property> + <property name="text"> + <string>splith</string> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QLabel" name="label_14"> + <property name="cursor"> + <cursorShape>PointingHandCursor</cursorShape> + </property> + <property name="text"> + <string>pointhand</string> + </property> + </widget> + </item> + <item row="4" column="2"> + <widget class="QLabel" name="label_15"> + <property name="cursor"> + <cursorShape>ForbiddenCursor</cursorShape> + </property> + <property name="text"> + <string>forbidden</string> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QLabel" name="label_16"> + <property name="cursor"> + <cursorShape>WhatsThisCursor</cursorShape> + </property> + <property name="text"> + <string>whatsthis</string> + </property> + </widget> + </item> + <item row="5" column="1"> + <widget class="QLabel" name="label_19"> + <property name="cursor"> + <cursorShape>BusyCursor</cursorShape> + </property> + <property name="text"> + <string>busy</string> + </property> + </widget> + </item> + <item row="6" column="0"> + <widget class="QLabel" name="label_17"> + <property name="cursor"> + <cursorShape>OpenHandCursor</cursorShape> + </property> + <property name="text"> + <string>openhand</string> + </property> + </widget> + </item> + <item row="6" column="1"> + <widget class="QLabel" name="label_18"> + <property name="cursor"> + <cursorShape>ClosedHandCursor</cursorShape> + </property> + <property name="text"> + <string>closehand</string> + </property> + </widget> + </item> + </layout> + </widget> + </widget> + <resources/> + <connections/> +</ui> diff --git a/tests/manual/qcursor/grab_override/data/monkey_on_64x64.png b/tests/manual/qcursor/grab_override/data/monkey_on_64x64.png Binary files differnew file mode 100644 index 0000000..990f604 --- /dev/null +++ b/tests/manual/qcursor/grab_override/data/monkey_on_64x64.png diff --git a/tests/manual/qcursor/grab_override/grab_override.pro b/tests/manual/qcursor/grab_override/grab_override.pro new file mode 100644 index 0000000..c0f69be --- /dev/null +++ b/tests/manual/qcursor/grab_override/grab_override.pro @@ -0,0 +1,18 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2009-08-05T17:13:23 +# +#------------------------------------------------- + +TARGET = t_cursors +TEMPLATE = app + + +SOURCES += main.cpp\ + mainwindow.cpp + +HEADERS += mainwindow.h + +FORMS += mainwindow.ui + +RESOURCES += images.qrc diff --git a/tests/manual/qcursor/grab_override/images.qrc b/tests/manual/qcursor/grab_override/images.qrc new file mode 100644 index 0000000..1d0cb92 --- /dev/null +++ b/tests/manual/qcursor/grab_override/images.qrc @@ -0,0 +1,6 @@ +<!DOCTYPE RCC> +<RCC version="1.0"> + <qresource prefix="/"> + <file>data/monkey_on_64x64.png</file> + </qresource> +</RCC> diff --git a/tests/manual/qcursor/grab_override/main.cpp b/tests/manual/qcursor/grab_override/main.cpp new file mode 100644 index 0000000..9fb7510 --- /dev/null +++ b/tests/manual/qcursor/grab_override/main.cpp @@ -0,0 +1,13 @@ +#include <QtGui/QApplication> +#include "mainwindow.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.showFullScreen(); +#ifdef QT_KEYPAD_NAVIGATION + QApplication::setNavigationMode(Qt::NavigationModeCursorForceVisible); +#endif + return a.exec(); +} diff --git a/tests/manual/qcursor/grab_override/mainwindow.cpp b/tests/manual/qcursor/grab_override/mainwindow.cpp new file mode 100644 index 0000000..27dd0e7 --- /dev/null +++ b/tests/manual/qcursor/grab_override/mainwindow.cpp @@ -0,0 +1,100 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +#include <QTimer> +#include <QBitmap> +#include <QImage> +#include <QPainter> +#include <QKeyEvent> + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), ui(new Ui::MainWindow) +{ + ui->setupUi(this); + QPixmap pix(":/data/monkey_on_64x64.png"); + + QImage mask(16, 16, QImage::Format_MonoLSB); + QImage bw(16, 16, QImage::Format_MonoLSB); + mask.fill(0); + bw.fill(0); + for (int x = 0; x < 16; x++) { + bw.setPixel(x, x, 1); + bw.setPixel(x, 15 - x, 1); + mask.setPixel(x, x, 1); + mask.setPixel(x, 15 - x, 1); + if (x > 0 && x < 15) { + mask.setPixel(x - 1, x, 1); + mask.setPixel(x + 1, x, 1); + mask.setPixel(x - 1, 15 - x, 1); + mask.setPixel(x + 1, 15 - x, 1); + } + } + + ccurs = QCursor(pix); + bcurs = QCursor(QBitmap::fromImage(bw), QBitmap::fromImage(mask)); + ui->label->setCursor(ccurs); + + timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(toggleOverrideCursor())); + timer->start(2000); + + override = 0; +} + +MainWindow::~MainWindow() +{ + delete timer; + delete ui; +} + +void MainWindow::toggleOverrideCursor() +{ + switch (override) { + case 0: + QApplication::setOverrideCursor(Qt::BusyCursor); + break; + case 1: + QApplication::restoreOverrideCursor(); + break; + case 2: + ui->label->grabMouse(Qt::ForbiddenCursor); + break; + case 3: + case 5: + ui->label->releaseMouse(); + break; + case 4: + ui->label->grabMouse(); + break; + case 6: + ui->label->setCursor(bcurs); + break; + case 7: + ui->label->setCursor(ccurs); + break; + } + override = (override + 1) % 8; +} + +void MainWindow::keyPressEvent(QKeyEvent* event) +{ + QPoint off(0, 0); + switch (event->key()) { + case Qt::Key_Up: + off.setY(-4); + break; + case Qt::Key_Down: + off.setY(4); + break; + case Qt::Key_Left: + off.setX(-4); + break; + case Qt::Key_Right: + off.setX(4); + break; + default: + return QMainWindow::keyPressEvent(event); + } + off += QCursor::pos(); + QCursor::setPos(off); +} diff --git a/tests/manual/qcursor/grab_override/mainwindow.h b/tests/manual/qcursor/grab_override/mainwindow.h new file mode 100644 index 0000000..0b1f694 --- /dev/null +++ b/tests/manual/qcursor/grab_override/mainwindow.h @@ -0,0 +1,35 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QtGui/QMainWindow> + +class QTimer; + +namespace Ui +{ + class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private slots: + void toggleOverrideCursor(); + +private: + void keyPressEvent(QKeyEvent* event); + + Ui::MainWindow *ui; + QTimer *timer; + int override; + + QCursor ccurs; + QCursor bcurs; +}; + +#endif // MAINWINDOW_H diff --git a/tests/manual/qcursor/grab_override/mainwindow.ui b/tests/manual/qcursor/grab_override/mainwindow.ui new file mode 100644 index 0000000..bf35536 --- /dev/null +++ b/tests/manual/qcursor/grab_override/mainwindow.ui @@ -0,0 +1,97 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>240</width> + <height>320</height> + </rect> + </property> + <property name="windowTitle"> + <string>MainWindow</string> + </property> + <widget class="QWidget" name="centralWidget"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QSplitter" name="splitter_2"> + <property name="frameShape"> + <enum>QFrame::NoFrame</enum> + </property> + <property name="midLineWidth"> + <number>1</number> + </property> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <widget class="QLabel" name="label"> + <property name="frameShape"> + <enum>QFrame::Box</enum> + </property> + <property name="text"> + <string>Custom</string> + </property> + </widget> + <widget class="QSplitter" name="splitter"> + <property name="frameShape"> + <enum>QFrame::NoFrame</enum> + </property> + <property name="midLineWidth"> + <number>1</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <widget class="QLabel" name="label_2"> + <property name="cursor"> + <cursorShape>ForbiddenCursor</cursorShape> + </property> + <property name="frameShape"> + <enum>QFrame::Box</enum> + </property> + <property name="text"> + <string>Forbidden</string> + </property> + </widget> + <widget class="QLabel" name="label_3"> + <property name="cursor"> + <cursorShape>WaitCursor</cursorShape> + </property> + <property name="frameShape"> + <enum>QFrame::Box</enum> + </property> + <property name="text"> + <string>Wait</string> + </property> + </widget> + </widget> + </widget> + </item> + </layout> + </widget> + <widget class="QMenuBar" name="menuBar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>240</width> + <height>21</height> + </rect> + </property> + </widget> + <widget class="QToolBar" name="mainToolBar"> + <attribute name="toolBarArea"> + <enum>TopToolBarArea</enum> + </attribute> + <attribute name="toolBarBreak"> + <bool>false</bool> + </attribute> + </widget> + <widget class="QStatusBar" name="statusBar"/> + </widget> + <layoutdefault spacing="6" margin="11"/> + <resources/> + <connections/> +</ui> diff --git a/tests/manual/qcursor/qcursor.pro b/tests/manual/qcursor/qcursor.pro new file mode 100644 index 0000000..af082a4 --- /dev/null +++ b/tests/manual/qcursor/qcursor.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs + +SUBDIRS = allcursors grab_override |