diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-11-13 11:42:54 (GMT) |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-11-13 11:42:54 (GMT) |
commit | 3286c4d489905d27183a9ba18048c11a5af8913c (patch) | |
tree | 392cc7137ffd69b305272f672db55a73be4f1dae /tests | |
parent | 1bc1e5c0b76a92594c5254e72d25165879e753d2 (diff) | |
parent | 6b651e5f69b656c6c6fa05b6a81674a4fd56a160 (diff) | |
download | Qt-3286c4d489905d27183a9ba18048c11a5af8913c.zip Qt-3286c4d489905d27183a9ba18048c11a5af8913c.tar.gz Qt-3286c4d489905d27183a9ba18048c11a5af8913c.tar.bz2 |
Merge remote branch 'mainline/4.6' into 4.6
Diffstat (limited to 'tests')
24 files changed, 384 insertions, 183 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index ad58d30..da1f7ca 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -136,6 +136,7 @@ SUBDIRS += \ qfocusevent \ qfocusframe \ qfont \ + qfontcombobox \ qfontdatabase \ qfontdialog \ qfontmetrics \ diff --git a/tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp b/tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp index 5033a50..99a263b 100644 --- a/tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp +++ b/tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp @@ -71,6 +71,8 @@ private slots: void viewportCrash(); void task214488_layoutDirection_data(); void task214488_layoutDirection(); + void wheelEvent_data(); + void wheelEvent(); }; tst_QAbstractScrollArea::tst_QAbstractScrollArea() @@ -296,10 +298,10 @@ public: setAttribute(Qt::WA_DropSiteRegistered, true); - startTimer(2000); + startTimer(200); } - void timerEvent(QTimerEvent *event) + void timerEvent(QTimerEvent *) { // should not crash. (void)new QScrollArea(this); @@ -385,5 +387,96 @@ void tst_QAbstractScrollArea::patternBackground() QCOMPARE(image.pixel(QPoint(20,20)) , QColor(Qt::red).rgb()); } +Q_DECLARE_METATYPE(QWheelEvent *); + +void tst_QAbstractScrollArea::wheelEvent_data() +{ + QTest::addColumn<QSize>("widgetSize"); + QTest::addColumn<QPoint>("initialOffset"); + QTest::addColumn<QWheelEvent *>("event"); + QTest::addColumn<int>("movedX"); // -1 , 0 , or 1 + QTest::addColumn<int>("movedY"); + + QPoint pos(100,100); + int delta =-120; + + QTest::newRow("1") << QSize(600,600) << QPoint(50,50) + << new QWheelEvent(pos, delta, 0, 0, Qt::Horizontal) << 1 << 0; + + QTest::newRow("2") << QSize(600,600) << QPoint(50,50) + << new QWheelEvent(pos, delta, 0, 0, Qt::Vertical) << 0 << 1; + + QTest::newRow("3") << QSize(600,600) << QPoint(50,50) + << new QWheelEvent(pos, -delta, 0, 0, Qt::Horizontal) << -1 << 0; + + QTest::newRow("4") << QSize(600,600) << QPoint(50,50) + << new QWheelEvent(pos, -delta, 0, 0, Qt::Vertical) << 0 << -1; + + QTest::newRow("5") << QSize(20,600) << QPoint(0,50) + << new QWheelEvent(pos, delta, 0, 0, Qt::Horizontal) << 0 << 1; + + QTest::newRow("6") << QSize(20,600) << QPoint(0,50) + << new QWheelEvent(pos, delta, 0, 0, Qt::Vertical) << 0 << 1; + + QTest::newRow("7") << QSize(20,600) << QPoint(0,50) + << new QWheelEvent(pos, -delta, 0, 0, Qt::Horizontal) << 0 << -1; + + QTest::newRow("8") << QSize(20,600) << QPoint(0,50) + << new QWheelEvent(pos, -delta, 0, 0, Qt::Vertical) << 0 << -1; + + QTest::newRow("9") << QSize(600,20) << QPoint(50,0) + << new QWheelEvent(pos, delta, 0, 0, Qt::Horizontal) << 1 << 0; + + QTest::newRow("a") << QSize(600,20) << QPoint(50,0) + << new QWheelEvent(pos, delta, 0, 0, Qt::Vertical) << 1 << 0; + + QTest::newRow("b") << QSize(600,20) << QPoint(50,0) + << new QWheelEvent(pos, -delta, 0, 0, Qt::Horizontal) << -1 << 0; + + QTest::newRow("c") << QSize(600,20) << QPoint(50,0) + << new QWheelEvent(pos, -delta, 0, 0, Qt::Vertical) << -1 << 0; +} + + + + +void tst_QAbstractScrollArea::wheelEvent() +{ + QFETCH(QSize, widgetSize); + QFETCH(QPoint, initialOffset); + QFETCH(QWheelEvent *, event); + QFETCH(int, movedX); + QFETCH(int, movedY); + + QScrollArea scrollArea; + scrollArea.resize(200, 200); + QLabel widget("H e l l o"); + widget.resize(widgetSize); + scrollArea.setWidget(&widget); + scrollArea.show(); + QTest::qWait(20); + + scrollArea.verticalScrollBar()->setValue(initialOffset.y()); + scrollArea.horizontalScrollBar()->setValue(initialOffset.x()); + + QCOMPARE(scrollArea.verticalScrollBar()->value(), initialOffset.y()); + QCOMPARE(scrollArea.horizontalScrollBar()->value(), initialOffset.x()); + + QApplication::sendEvent(scrollArea.viewport(), event); + + if(movedX == 0) + QCOMPARE(scrollArea.horizontalScrollBar()->value(), initialOffset.x()); + else + QVERIFY(movedX * scrollArea.horizontalScrollBar()->value() > movedX * initialOffset.x()); + + if(movedY == 0) + QCOMPARE(scrollArea.verticalScrollBar()->value(), initialOffset.y()); + else + QVERIFY(movedY * scrollArea.verticalScrollBar()->value() > movedY * initialOffset.y()); + + delete event; +} + + QTEST_MAIN(tst_QAbstractScrollArea) #include "tst_qabstractscrollarea.moc" diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index 18ebddc..cc59b62 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -2517,8 +2517,8 @@ void tst_QComboBox::task_QTBUG_1071_changingFocusEmitsActivated() cb.addItem("1"); cb.addItem("2"); QLineEdit edit; - layout.add(&cb); - layout.add(&edit); + layout.addWidget(&cb); + layout.addWidget(&edit); w.show(); QTest::qWaitForWindowShown(&w); diff --git a/tests/auto/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/qcoreapplication/tst_qcoreapplication.cpp index c5f06e2..3c61f81 100644 --- a/tests/auto/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/qcoreapplication/tst_qcoreapplication.cpp @@ -58,6 +58,7 @@ private slots: #endif void applicationPid(); void globalPostedEventsCount(); + void processEventsAlwaysSendsPostedEvents(); }; class EventSpy : public QObject @@ -488,5 +489,40 @@ void tst_QCoreApplication::globalPostedEventsCount() QCOMPARE(x.globalPostedEventsCount, expected); } +class ProcessEventsAlwaysSendsPostedEventsObject : public QObject +{ +public: + int counter; + + inline ProcessEventsAlwaysSendsPostedEventsObject() + : counter(0) + { } + + bool event(QEvent *event) + { + if (event->type() == QEvent::User) + ++counter; + return QObject::event(event); + } +}; + +void tst_QCoreApplication::processEventsAlwaysSendsPostedEvents() +{ + int argc = 1; + char *argv[] = { "tst_qcoreapplication" }; + QCoreApplication app(argc, argv); + + ProcessEventsAlwaysSendsPostedEventsObject object; + QTime t; + t.start(); + int i = 1; + do { + QCoreApplication::postEvent(&object, new QEvent(QEvent::User)); + QCoreApplication::processEvents(); + QCOMPARE(object.counter, i); + ++i; + } while (t.elapsed() < 3000); +} + QTEST_APPLESS_MAIN(tst_QCoreApplication) #include "tst_qcoreapplication.moc" diff --git a/tests/auto/qdatastream/qdatastream.pro b/tests/auto/qdatastream/qdatastream.pro index 5b90357..c132073 100644 --- a/tests/auto/qdatastream/qdatastream.pro +++ b/tests/auto/qdatastream/qdatastream.pro @@ -12,7 +12,7 @@ QT += svg wince*: { - addFiles.sources = datastream.q42 gearflowers.svg + addFiles.sources = datastream.q42 tests2.svg addFiles.path = . DEPLOYMENT += addFiles DEFINES += SRCDIR=\\\"\\\" diff --git a/tests/auto/qdatastream/tst_qdatastream.cpp b/tests/auto/qdatastream/tst_qdatastream.cpp index 7535645..24447ea 100644 --- a/tests/auto/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/qdatastream/tst_qdatastream.cpp @@ -320,8 +320,7 @@ void tst_QDataStream::getSetCheck() tst_QDataStream::tst_QDataStream() { - svgFile = QLatin1String(SRCDIR) + QLatin1String("/") + - QLatin1String(SVGFILE); + svgFile = QLatin1String(SRCDIR SVGFILE); } tst_QDataStream::~tst_QDataStream() diff --git a/tests/auto/qdockwidget/tst_qdockwidget.cpp b/tests/auto/qdockwidget/tst_qdockwidget.cpp index e62ba8c..c9a7f1c 100644 --- a/tests/auto/qdockwidget/tst_qdockwidget.cpp +++ b/tests/auto/qdockwidget/tst_qdockwidget.cpp @@ -87,12 +87,14 @@ private slots: void dockLocationChanged(); void setTitleBarWidget(); void titleBarDoubleClick(); + void restoreStateOfFloating(); // task specific tests: void task165177_deleteFocusWidget(); void task169808_setFloating(); void task237438_setFloatingCrash(); void task248604_infiniteResize(); void task258459_visibilityChanged(); + void taskQTBUG_1665_closableChanged(); }; // Testing get/set functions @@ -612,6 +614,7 @@ void tst_QDockWidget::dockLocationChanged() QMainWindow mw; QDockWidget dw; + dw.setObjectName("dock1"); QSignalSpy spy(&dw, SIGNAL(dockLocationChanged(Qt::DockWidgetArea))); mw.addDockWidget(Qt::LeftDockWidgetArea, &dw); @@ -636,6 +639,7 @@ void tst_QDockWidget::dockLocationChanged() QCOMPARE(spy.count(), 0); QDockWidget dw2; + dw2.setObjectName("dock2"); mw.addDockWidget(Qt::TopDockWidgetArea, &dw2); mw.tabifyDockWidget(&dw2, &dw); QCOMPARE(spy.count(), 1); @@ -657,6 +661,12 @@ void tst_QDockWidget::dockLocationChanged() QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)), Qt::TopDockWidgetArea); spy.clear(); + + QByteArray ba = mw.saveState(); + mw.restoreState(ba); + QCOMPARE(spy.count(), 1); + QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)), + Qt::TopDockWidgetArea); } void tst_QDockWidget::featuresChanged() @@ -714,6 +724,21 @@ void tst_QDockWidget::titleBarDoubleClick() QCOMPARE(win.dockWidgetArea(&dock), Qt::TopDockWidgetArea); } +void tst_QDockWidget::restoreStateOfFloating() +{ + QMainWindow mw; + QDockWidget dock; + dock.setObjectName("dock1"); + mw.addDockWidget(Qt::TopDockWidgetArea, &dock); + QVERIFY(!dock.isFloating()); + QByteArray ba = mw.saveState(); + dock.setFloating(true); + QVERIFY(dock.isFloating()); + QVERIFY(mw.restoreState(ba)); + QVERIFY(!dock.isFloating()); +} + + void tst_QDockWidget::task165177_deleteFocusWidget() { QMainWindow mw; @@ -834,5 +859,22 @@ void tst_QDockWidget::task258459_visibilityChanged() QCOMPARE(spy2.first().first().toBool(), true); //dock1 is visible } +void tst_QDockWidget::taskQTBUG_1665_closableChanged() +{ + QDockWidget dock; + dock.show(); + QTest::qWaitForWindowShown(&dock); + + if (dock.windowFlags() & Qt::FramelessWindowHint) + QSKIP("this machine doesn't support native dock widget", SkipAll); + + QVERIFY(dock.windowFlags() & Qt::WindowCloseButtonHint); + + //now let's remove the closable attribute + dock.setFeatures(dock.features() ^ QDockWidget::DockWidgetClosable); + QVERIFY(!(dock.windowFlags() & Qt::WindowCloseButtonHint)); +} + + QTEST_MAIN(tst_QDockWidget) #include "tst_qdockwidget.moc" diff --git a/tests/auto/qfile/largefile/largefile.pro b/tests/auto/qfile/largefile/largefile.pro index 0f96865..d67cb46 100644 --- a/tests/auto/qfile/largefile/largefile.pro +++ b/tests/auto/qfile/largefile/largefile.pro @@ -2,3 +2,5 @@ load(qttest_p4) QT = core SOURCES += tst_largefile.cpp + +wince*: SOURCES += $$QT_SOURCE_TREE/src/corelib/kernel/qfunctions_wince.cpp diff --git a/tests/auto/qfile/largefile/tst_largefile.cpp b/tests/auto/qfile/largefile/tst_largefile.cpp index 9105063..980f4ba 100644 --- a/tests/auto/qfile/largefile/tst_largefile.cpp +++ b/tests/auto/qfile/largefile/tst_largefile.cpp @@ -54,7 +54,10 @@ #ifdef Q_OS_WIN #include <windows.h> + +#ifndef Q_OS_WINCE #include <io.h> +#endif #ifndef FSCTL_SET_SPARSE // MinGW doesn't define this. @@ -295,7 +298,7 @@ void tst_LargeFile::sparseFileData() void tst_LargeFile::createSparseFile() { -#if defined(Q_OS_WIN) +#if defined(Q_OS_WIN32) // On Windows platforms, we must explicitly set the file to be sparse, // so disk space is not allocated for the full file when writing to it. HANDLE handle = ::CreateFileA("qt_largefile.tmp", @@ -313,7 +316,7 @@ void tst_LargeFile::createSparseFile() int fd = ::_open_osfhandle((intptr_t)handle, 0); QVERIFY( -1 != fd ); QVERIFY( largeFile.open(fd, QIODevice::WriteOnly | QIODevice::Unbuffered) ); -#else // !Q_OS_WIN +#else // !Q_OS_WIN32 largeFile.setFileName("qt_largefile.tmp"); QVERIFY( largeFile.open(QIODevice::WriteOnly | QIODevice::Unbuffered) ); #endif @@ -321,13 +324,13 @@ void tst_LargeFile::createSparseFile() void tst_LargeFile::closeSparseFile() { -#if defined(Q_OS_WIN) +#if defined(Q_OS_WIN32) int fd = largeFile.handle(); #endif largeFile.close(); -#if defined(Q_OS_WIN) +#if defined(Q_OS_WIN32) if (-1 != fd) ::_close(fd); #endif diff --git a/tests/auto/qfile/test/test.pro b/tests/auto/qfile/test/test.pro index 46f63b3..faaa927 100644 --- a/tests/auto/qfile/test/test.pro +++ b/tests/auto/qfile/test/test.pro @@ -14,6 +14,7 @@ wince*|symbian { } wince* { + SOURCES += $$QT_SOURCE_TREE/src/corelib/kernel/qfunctions_wince.cpp # needed for QT_OPEN DEFINES += SRCDIR=\\\"\\\" } else:symbian { # do not define SRCDIR at all diff --git a/tests/auto/qfont/tst_qfont.cpp b/tests/auto/qfont/tst_qfont.cpp index fa76e44..5622e10 100644 --- a/tests/auto/qfont/tst_qfont.cpp +++ b/tests/auto/qfont/tst_qfont.cpp @@ -395,6 +395,13 @@ void tst_QFont::compare() font.setOverline(false); QVERIFY( font == font2 ); QVERIFY(!(font < font2)); + + font.setCapitalization(QFont::SmallCaps); + QVERIFY( font != font2 ); + QCOMPARE(font < font2,!(font2 < font)); + font.setCapitalization(QFont::MixedCase); + QVERIFY( font == font2 ); + QVERIFY(!(font < font2)); } #if defined(Q_WS_X11) diff --git a/tests/auto/qfontcombobox/tst_qfontcombobox.cpp b/tests/auto/qfontcombobox/tst_qfontcombobox.cpp index 7045c19..b974ecab 100644 --- a/tests/auto/qfontcombobox/tst_qfontcombobox.cpp +++ b/tests/auto/qfontcombobox/tst_qfontcombobox.cpp @@ -153,7 +153,7 @@ void tst_QFontComboBox::currentFont() if (oldCurrentFont != box.currentFont()) { //the signal may be emit twice if there is a foundry into brackets - QVERIFY(spy0.count() >= 1); + QCOMPARE(spy0.count(),1); } } @@ -286,6 +286,10 @@ void tst_QFontComboBox::currentFontChanged() if (box.model()->rowCount() > 2) { QTest::keyPress(&box, Qt::Key_Down); QCOMPARE(spy0.count(), 1); + + QFont f( "Sans Serif" ); + box.setCurrentFont(f); + QCOMPARE(spy0.count(), 2); } else qWarning("Not enough fonts installed on test system. Consider adding some"); } diff --git a/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp b/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp index 55294d5..9991ab4 100644 --- a/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp +++ b/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp @@ -46,6 +46,8 @@ #include <QtGui/qgraphicsitem.h> #include <QtGui/qstyleoption.h> +#include <private/qgraphicseffect_p.h> + //TESTED_CLASS= //TESTED_FILES= @@ -54,13 +56,12 @@ class CustomItem : public QGraphicsRectItem public: CustomItem(qreal x, qreal y, qreal width, qreal height) : QGraphicsRectItem(x, y, width, height), numRepaints(0), - m_painter(0), m_styleOption(0) + m_painter(0) {} void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { m_painter = painter; - m_styleOption = option; ++numRepaints; QGraphicsRectItem::paint(painter, option, widget); } @@ -69,12 +70,10 @@ public: { numRepaints = 0; m_painter = 0; - m_styleOption = 0; } int numRepaints; QPainter *m_painter; - const QStyleOption *m_styleOption; }; class CustomEffect : public QGraphicsEffect @@ -84,7 +83,7 @@ public: : QGraphicsEffect(), numRepaints(0), m_margin(10), m_sourceChanged(false), m_sourceBoundingRectChanged(false), doNothingInDraw(false), storeDeviceDependentStuff(false), - m_painter(0), m_styleOption(0), m_source(0) + m_painter(0), m_source(0) {} QRectF boundingRectFor(const QRectF &rect) const @@ -96,7 +95,6 @@ public: m_sourceChanged = false; m_sourceBoundingRectChanged = false; m_painter = 0; - m_styleOption = 0; m_source = 0; deviceCoordinatesPixmap = QPixmap(); deviceRect = QRect(); @@ -112,20 +110,19 @@ public: int margin() const { return m_margin; } - void draw(QPainter *painter, QGraphicsEffectSource *source) + void draw(QPainter *painter) { ++numRepaints; if (storeDeviceDependentStuff) { - deviceCoordinatesPixmap = source->pixmap(Qt::DeviceCoordinates); - deviceRect = source->deviceRect(); - sourceDeviceBoundingRect = source->boundingRect(Qt::DeviceCoordinates); + deviceCoordinatesPixmap = source()->pixmap(Qt::DeviceCoordinates); + deviceRect = QRect(0, 0, painter->device()->width(), painter->device()->height()); + sourceDeviceBoundingRect = source()->boundingRect(Qt::DeviceCoordinates); } if (doNothingInDraw) return; - m_source = source; + m_source = source(); m_painter = painter; - m_styleOption = source->styleOption(); - source->draw(painter); + source()->draw(painter); } void sourceChanged() @@ -141,7 +138,6 @@ public: bool doNothingInDraw; bool storeDeviceDependentStuff; QPainter *m_painter; - const QStyleOption *m_styleOption; QGraphicsEffectSource *m_source; QPixmap deviceCoordinatesPixmap; QRect deviceRect; @@ -227,8 +223,6 @@ void tst_QGraphicsEffectSource::styleOption() QTest::qWait(50); QCOMPARE(item->numRepaints, 1); QCOMPARE(effect->numRepaints, 1); - QVERIFY(effect->m_styleOption); - QCOMPARE(effect->m_styleOption, item->m_styleOption); } void tst_QGraphicsEffectSource::isPixmap() @@ -291,10 +285,6 @@ void tst_QGraphicsEffectSource::boundingRect() void tst_QGraphicsEffectSource::deviceRect() { - QTest::ignoreMessage(QtWarningMsg, "QGraphicsEffectSource::deviceRect: Not yet implemented, lacking device context"); - QCOMPARE(effect->source()->deviceRect(), QRect()); - - // We can at least check that the rect was correct in QGraphicsEffect::draw. effect->storeDeviceDependentStuff = true; effect->source()->update(); QTest::qWait(50); @@ -332,13 +322,13 @@ public: return src.adjusted(-10, -10, 10, 10); } - void draw(QPainter *, QGraphicsEffectSource *source) { - pix = source->pixmap(coordinateMode, &offset, padMode); + void draw(QPainter *) { + pix = source()->pixmap(coordinateMode, &offset, padMode); } QPixmap pix; QPoint offset; - QGraphicsEffectSource::PixmapPadMode padMode; + QGraphicsEffect::PixmapPadMode padMode; Qt::CoordinateSystem coordinateMode; }; @@ -351,32 +341,32 @@ void tst_QGraphicsEffectSource::pixmapPadding_data() QTest::addColumn<uint>("ulPixel"); QTest::newRow("log,nopad") << int(Qt::LogicalCoordinates) - << int(QGraphicsEffectSource::NoExpandPadMode) + << int(QGraphicsEffect::NoPad) << QSize(10, 10) << QPoint(0, 0) << 0xffff0000u; QTest::newRow("log,transparent") << int(Qt::LogicalCoordinates) - << int(QGraphicsEffectSource::ExpandToTransparentBorderPadMode) + << int(QGraphicsEffect::PadToTransparentBorder) << QSize(14, 14) << QPoint(-2, -2) << 0x00000000u; QTest::newRow("log,effectrect") << int(Qt::LogicalCoordinates) - << int(QGraphicsEffectSource::ExpandToEffectRectPadMode) + << int(QGraphicsEffect::PadToEffectiveBoundingRect) << QSize(30, 30) << QPoint(-10, -10) << 0x00000000u; QTest::newRow("dev,nopad") << int(Qt::DeviceCoordinates) - << int(QGraphicsEffectSource::NoExpandPadMode) + << int(QGraphicsEffect::NoPad) << QSize(20, 20) << QPoint(40, 40) << 0xffff0000u; QTest::newRow("dev,transparent") << int(Qt::DeviceCoordinates) - << int(QGraphicsEffectSource::ExpandToTransparentBorderPadMode) + << int(QGraphicsEffect::PadToTransparentBorder) << QSize(24, 24) << QPoint(38, 38) << 0x00000000u; QTest::newRow("dev,effectrect") << int(Qt::DeviceCoordinates) - << int(QGraphicsEffectSource::ExpandToEffectRectPadMode) + << int(QGraphicsEffect::PadToEffectiveBoundingRect) << QSize(40, 40) << QPoint(30, 30) << 0x00000000u; @@ -404,7 +394,7 @@ void tst_QGraphicsEffectSource::pixmapPadding() QFETCH(QSize, size); QFETCH(uint, ulPixel); - effect->padMode = (QGraphicsEffectSource::PixmapPadMode) padMode; + effect->padMode = (QGraphicsEffect::PixmapPadMode) padMode; effect->coordinateMode = (Qt::CoordinateSystem) coordinateMode; scene->render(&dummyPainter, scene->itemsBoundingRect(), scene->itemsBoundingRect()); diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index e33c7b6..cd1eedd 100644 --- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -399,7 +399,7 @@ void tst_QGraphicsGridLayout::columnAlignment() widget->resize(widget->effectiveSizeHint(Qt::MaximumSize)); view.show(); widget->show(); - QApplication::processEvents(); + QApplication::sendPostedEvents(0, 0); // Check default QCOMPARE(layout->columnAlignment(0), 0); QCOMPARE(layout->columnAlignment(1), 0); @@ -414,7 +414,7 @@ void tst_QGraphicsGridLayout::columnAlignment() layout->setAlignment(layout->itemAt(1,1), Qt::AlignRight); layout->setAlignment(layout->itemAt(1,2), Qt::AlignLeft); - QApplication::processEvents(); // process LayoutRequest + QApplication::sendPostedEvents(0, 0); // process LayoutRequest /* +----------+------------+---------+ | Left | HCenter | Right | @@ -846,7 +846,7 @@ void tst_QGraphicsGridLayout::rowAlignment() widget->resize(300, 400); view.show(); widget->show(); - QApplication::processEvents(); + QApplication::sendPostedEvents(0, 0); // Check default QCOMPARE(layout->rowAlignment(0), 0); QCOMPARE(layout->rowAlignment(1), 0); @@ -869,7 +869,7 @@ void tst_QGraphicsGridLayout::rowAlignment() layout->setAlignment(layout->itemAt(1,0), Qt::AlignTop); layout->setAlignment(layout->itemAt(2,0), Qt::AlignHCenter); - QApplication::processEvents(); // process LayoutRequest + QApplication::sendPostedEvents(0, 0); // process LayoutRequest QCOMPARE(layout->alignment(layout->itemAt(0,0)), Qt::AlignRight); //Qt::AlignRight | Qt::AlignBottom QCOMPARE(layout->itemAt(0,0)->geometry(), QRectF(50, 50, 50, 50)); @@ -1834,7 +1834,7 @@ void tst_QGraphicsGridLayout::defaultStretchFactors() desc.apply(layout, item); } - QApplication::processEvents(); + QApplication::sendPostedEvents(0, 0); widget->show(); view.show(); @@ -1842,7 +1842,7 @@ void tst_QGraphicsGridLayout::defaultStretchFactors() if (newSize.isValid()) widget->resize(newSize); - QApplication::processEvents(); + QApplication::sendPostedEvents(0, 0); for (i = 0; i < expectedSizes.count(); ++i) { QSizeF itemSize = layout->itemAt(i)->geometry().size(); QCOMPARE(itemSize, expectedSizes.at(i)); @@ -1994,7 +1994,7 @@ void tst_QGraphicsGridLayout::alignment2() desc.apply(layout, item); } - QApplication::processEvents(); + QApplication::sendPostedEvents(0, 0); widget->show(); view.resize(400,300); @@ -2002,7 +2002,7 @@ void tst_QGraphicsGridLayout::alignment2() if (newSize.isValid()) widget->resize(newSize); - QApplication::processEvents(); + QApplication::sendPostedEvents(0, 0); for (i = 0; i < expectedGeometries.count(); ++i) { QRectF itemRect = layout->itemAt(i)->geometry(); QCOMPARE(itemRect, expectedGeometries.at(i)); diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index d65c6ec..27c6809 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -413,6 +413,7 @@ private slots: void task243707_addChildBeforeParent(); void task197802_childrenVisibility(); void QTBUG_4233_updateCachedWithSceneRect(); + void QTBUG_5418_textItemSetDefaultColor(); private: QList<QGraphicsItem *> paintedItems; @@ -9751,5 +9752,62 @@ void tst_QGraphicsItem::scenePosChange() QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0); } +void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor() +{ + struct Item : public QGraphicsTextItem + { + bool painted; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *opt, QWidget *wid) + { + painted = true; + QGraphicsTextItem::paint(painter, opt, wid); + } + }; + + Item *i = new Item; + i->painted = false; + i->setPlainText("I AM A TROLL"); + + QGraphicsScene scene; + QGraphicsView view(&scene); + view.show(); + QTest::qWaitForWindowShown(&view); + scene.addItem(i); + QApplication::processEvents(); + QTRY_VERIFY(i->painted); + QApplication::processEvents(); + + i->painted = false; + QColor col(Qt::red); + i->setDefaultTextColor(col); + QApplication::processEvents(); + QTRY_VERIFY(i->painted); //check that changing the color force an update + + i->painted = false; + QImage image(400, 200, QImage::Format_RGB32); + image.fill(0); + QPainter painter(&image); + scene.render(&painter); + painter.end(); + QVERIFY(i->painted); + + int numRedPixel = 0; + QRgb rgb = col.rgb(); + for (int y = 0; y < image.height(); ++y) { + for (int x = 0; x < image.width(); ++x) { + // Because of antialiasing we allow a certain range of errors here. + QRgb pixel = image.pixel(x, y); + if (qAbs((int)(pixel & 0xff) - (int)(rgb & 0xff)) + + qAbs((int)((pixel & 0xff00) >> 8) - (int)((rgb & 0xff00) >> 8)) + + qAbs((int)((pixel & 0xff0000) >> 16) - (int)((rgb & 0xff0000) >> 16)) <= 50) { + if (++numRedPixel >= 10) { + return; + } + } + } + } + QCOMPARE(numRedPixel, -1); //color not found, FAIL! +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" diff --git a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp index 546f92d..d3087dc 100644 --- a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp +++ b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp @@ -664,16 +664,16 @@ void tst_QGraphicsLinearLayout::invalidate() widget->show(); layout.setContentsMargins(1, 2, 3, 4); - qApp->processEvents(); + QApplication::sendPostedEvents(0, 0); QCOMPARE(layout.layoutRequest, 1); layout.setOrientation(Qt::Vertical); - qApp->processEvents(); + QApplication::sendPostedEvents(0, 0); QCOMPARE(layout.layoutRequest, 2); for (int i = 0; i < count; ++i) layout.invalidate(); // Event is compressed, should only get one layoutrequest - qApp->processEvents(); + QApplication::sendPostedEvents(0, 0); QCOMPARE(layout.layoutRequest, count ? 3 : 2); delete widget; } diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index 9c6aa39..f07453c 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -217,7 +217,6 @@ private slots: void update(); void inputMethodSensitivity(); void inputContextReset(); - void defaultClipIntersectToView(); // task specific tests below me void task172231_untransformableItems(); @@ -3693,77 +3692,6 @@ void tst_QGraphicsView::inputContextReset() QCOMPARE(inputContext.resets, 0); } -class ViewClipTester : public QGraphicsView -{ -public: - ViewClipTester(QGraphicsScene *scene = 0) - : QGraphicsView(scene) - { } - QRegion clipRegion; - -protected: - void drawBackground(QPainter *painter, const QRectF &rect) - { - clipRegion = painter->clipRegion(); - } -}; - -class ItemClipTester : public QGraphicsRectItem -{ -public: - ItemClipTester() : QGraphicsRectItem(0, 0, 20, 20) - { - setBrush(Qt::blue); - } - QRegion clipRegion; - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) - { - clipRegion = painter->clipRegion(); - QGraphicsRectItem::paint(painter, option, widget); - } -}; - -void tst_QGraphicsView::defaultClipIntersectToView() -{ - QGraphicsScene scene; - ItemClipTester *tester = new ItemClipTester; - scene.addItem(tester); - - ViewClipTester view(&scene); - view.setAlignment(Qt::AlignTop | Qt::AlignLeft); - view.setFrameStyle(0); - view.resize(200, 200); - view.show(); - QTRY_COMPARE(QApplication::activeWindow(), (QWidget *)&view); - - QRect viewRect(0, 0, 200, 200); - QCOMPARE(view.clipRegion, QRegion(viewRect)); - QCOMPARE(tester->clipRegion, QRegion(viewRect)); - - view.viewport()->update(0, 0, 5, 5); - view.viewport()->update(10, 10, 5, 5); - qApp->processEvents(); - viewRect = QRect(0, 0, 15, 15); - QCOMPARE(view.clipRegion, QRegion(viewRect)); - QCOMPARE(tester->clipRegion, QRegion(viewRect)); - - view.scale(2, 2); - qApp->processEvents(); - - viewRect.moveTop(-viewRect.height()); - viewRect = QRect(0, 0, 100, 100); - QCOMPARE(view.clipRegion, QRegion(viewRect)); - QCOMPARE(tester->clipRegion, QRegion(viewRect)); - - view.viewport()->update(0, 0, 5, 5); - view.viewport()->update(10, 10, 5, 5); - qApp->processEvents(); - viewRect = QRect(0, 0, 8, 8); - QCOMPARE(view.clipRegion, QRegion(viewRect)); - QCOMPARE(tester->clipRegion, QRegion(viewRect)); -} - void tst_QGraphicsView::task253415_reconnectUpdateSceneOnSceneChanged() { QGraphicsView view; diff --git a/tests/auto/qgridlayout/tst_qgridlayout.cpp b/tests/auto/qgridlayout/tst_qgridlayout.cpp index 46e2a03..313dc95 100644 --- a/tests/auto/qgridlayout/tst_qgridlayout.cpp +++ b/tests/auto/qgridlayout/tst_qgridlayout.cpp @@ -268,7 +268,7 @@ void tst_QGridLayout::setMinAndMaxSize() leftChild.setMinimumSize(100, 100); leftChild.setMaximumSize(200, 200); layout.addWidget(&leftChild, 0, 0); - QApplication::processEvents(); + QApplication::sendPostedEvents(0, 0); QCOMPARE(widget.minimumSize(), leftChild.minimumSize()); QCOMPARE(widget.maximumSize(), leftChild.maximumSize()); @@ -277,7 +277,7 @@ void tst_QGridLayout::setMinAndMaxSize() rightChild.setMinimumSize(100, 100); rightChild.setMaximumSize(200, 200); layout.addWidget(&rightChild, 0, 2); - QApplication::processEvents(); + QApplication::sendPostedEvents(0, 0); QCOMPARE(widget.minimumWidth(), leftChild.minimumWidth() + rightChild.minimumWidth()); @@ -293,7 +293,7 @@ void tst_QGridLayout::setMinAndMaxSize() layout.setColumnMinimumWidth(1, colMin); QCOMPARE(layout.columnMinimumWidth(1), colMin); - QApplication::processEvents(); + QApplication::sendPostedEvents(0, 0); QCOMPARE(widget.minimumWidth(), leftChild.minimumWidth() + rightChild.minimumWidth() + colMin); QCOMPARE(widget.maximumWidth(), @@ -306,7 +306,7 @@ void tst_QGridLayout::setMinAndMaxSize() layout.setColumnStretch(1,1); - QApplication::processEvents(); + QApplication::sendPostedEvents(0, 0); QCOMPARE(widget.minimumWidth(), leftChild.minimumWidth() + rightChild.minimumWidth() + colMin); QCOMPARE(widget.maximumWidth(), QLAYOUTSIZE_MAX); @@ -318,7 +318,7 @@ void tst_QGridLayout::setMinAndMaxSize() layout.setColumnStretch(1,0); - QApplication::processEvents(); + QApplication::sendPostedEvents(0, 0); QCOMPARE(widget.minimumWidth(), leftChild.minimumWidth() + rightChild.minimumWidth() + colMin); QCOMPARE(widget.maximumWidth(), @@ -335,7 +335,7 @@ void tst_QGridLayout::setMinAndMaxSize() static const int spacerS = 250; QSpacerItem *spacer = new QSpacerItem(spacerS, spacerS); layout.addItem(spacer, 0, 1); - QApplication::processEvents(); + QApplication::sendPostedEvents(0, 0); QCOMPARE(widget.minimumWidth(), leftChild.minimumWidth() + rightChild.minimumWidth() + spacerS); @@ -348,7 +348,7 @@ void tst_QGridLayout::setMinAndMaxSize() spacer->changeSize(spacerS, spacerS, QSizePolicy::Fixed, QSizePolicy::Minimum); layout.invalidate(); - QApplication::processEvents(); + QApplication::sendPostedEvents(0, 0); QCOMPARE(widget.minimumWidth(), leftChild.minimumWidth() + rightChild.minimumWidth() + spacerS); QCOMPARE(widget.maximumWidth(), @@ -358,13 +358,13 @@ void tst_QGridLayout::setMinAndMaxSize() layout.removeItem(spacer); rightChild.hide(); - QApplication::processEvents(); + QApplication::sendPostedEvents(0, 0); QCOMPARE(widget.minimumSize(), leftChild.minimumSize()); QCOMPARE(widget.maximumSize(), leftChild.maximumSize()); rightChild.show(); layout.removeWidget(&rightChild); - QApplication::processEvents(); + QApplication::sendPostedEvents(0, 0); QCOMPARE(widget.minimumSize(), leftChild.minimumSize()); QCOMPARE(widget.maximumSize(), leftChild.maximumSize()); @@ -373,7 +373,7 @@ void tst_QGridLayout::setMinAndMaxSize() bottomChild.setMinimumSize(100, 100); bottomChild.setMaximumSize(200, 200); layout.addWidget(&bottomChild, 1, 0); - QApplication::processEvents(); + QApplication::sendPostedEvents(0, 0); QCOMPARE(widget.minimumHeight(), leftChild.minimumHeight() + bottomChild.minimumHeight()); @@ -385,13 +385,13 @@ void tst_QGridLayout::setMinAndMaxSize() qMax(leftChild.maximumWidth(), bottomChild.maximumWidth())); bottomChild.hide(); - QApplication::processEvents(); + QApplication::sendPostedEvents(0, 0); QCOMPARE(widget.minimumSize(), leftChild.minimumSize()); QCOMPARE(widget.maximumSize(), leftChild.maximumSize()); bottomChild.show(); layout.removeWidget(&bottomChild); - QApplication::processEvents(); + QApplication::sendPostedEvents(0, 0); QCOMPARE(widget.minimumSize(), leftChild.minimumSize()); QCOMPARE(widget.maximumSize(), leftChild.maximumSize()); } @@ -423,7 +423,7 @@ void tst_QGridLayout::spacingAndSpacers() SizeHinter leftChild(100,100); leftChild.setPalette(QPalette(Qt::red)); layout.addWidget(&leftChild, 0, 0); - QApplication::processEvents(); + QApplication::sendPostedEvents(0, 0); expectedSizeHint = leftChild.sizeHint(); QCOMPARE(widget.sizeHint(), expectedSizeHint); @@ -431,7 +431,7 @@ void tst_QGridLayout::spacingAndSpacers() SizeHinter rightChild(200,100); rightChild.setPalette(QPalette(Qt::green)); layout.addWidget(&rightChild, 0, 2); - QApplication::processEvents(); + QApplication::sendPostedEvents(0, 0); QCOMPARE(rightChild.sizeHint(), QSize(200,100)); expectedSizeHint += QSize(rightChild.sizeHint().width(), 0); @@ -440,11 +440,11 @@ void tst_QGridLayout::spacingAndSpacers() layout.setColumnMinimumWidth(1, 100); widget.adjustSize(); expectedSizeHint += QSize(100,0); - QApplication::processEvents(); + QApplication::sendPostedEvents(0, 0); QCOMPARE(widget.sizeHint(), expectedSizeHint); rightChild.hide(); - QApplication::processEvents(); + QApplication::sendPostedEvents(0, 0); expectedSizeHint -= QSize(rightChild.sizeHint().width(), 0); QCOMPARE(widget.sizeHint(), expectedSizeHint); @@ -459,12 +459,12 @@ void tst_QGridLayout::spacingAndSpacers() leftChild.setMaximumWidth(200); rightChild.setMaximumWidth(200); - QApplication::processEvents(); + QApplication::sendPostedEvents(0, 0); QCOMPARE(widget.maximumWidth(), leftChild.maximumWidth() + rightChild.maximumWidth()); #endif layout.removeWidget(&rightChild); - QApplication::processEvents(); + QApplication::sendPostedEvents(0, 0); QCOMPARE(widget.sizeHint(), expectedSizeHint); diff --git a/tests/auto/qkeysequence/tst_qkeysequence.cpp b/tests/auto/qkeysequence/tst_qkeysequence.cpp index 1c257bf..bc9ae6c 100644 --- a/tests/auto/qkeysequence/tst_qkeysequence.cpp +++ b/tests/auto/qkeysequence/tst_qkeysequence.cpp @@ -119,6 +119,7 @@ private slots: void symetricConstructors_data(); void symetricConstructors(); void checkMultipleNames(); + void mnemonic_data(); void mnemonic(); void toString_data(); void toString(); @@ -133,6 +134,7 @@ private slots: void translated_data(); void translated(); + void initTestCase(); private: QTranslator *ourTranslator; @@ -299,7 +301,7 @@ void tst_QKeySequence::standardKeys_data() QTest::newRow("findNext") << (int)QKeySequence::FindNext<< QString("F3"); QTest::newRow("findPrevious") << (int)QKeySequence::FindPrevious << QString("SHIFT+F3"); QTest::newRow("close") << (int)QKeySequence::Close<< QString("CTRL+F4"); - QTest::newRow("replace") << (int)QKeySequence::Replace<< QString("CTRL+H"); + QTest::newRow("replace") << (int)QKeySequence::Replace<< QString("CTRL+H"); #endif QTest::newRow("bold") << (int)QKeySequence::Bold << QString("CTRL+B"); QTest::newRow("italic") << (int)QKeySequence::Italic << QString("CTRL+I"); @@ -357,17 +359,50 @@ void tst_QKeySequence::keyBindings() } + +void tst_QKeySequence::mnemonic_data() +{ + QTest::addColumn<QString>("string"); + QTest::addColumn<QString>("key"); + QTest::addColumn<bool>("warning"); + + QTest::newRow("1") << QString::fromLatin1("&bonjour") << QString::fromLatin1("ALT+B") << false; + QTest::newRow("2") << QString::fromLatin1("&&bonjour") << QString() << false; + QTest::newRow("3") << QString::fromLatin1("&&bon&jour") << QString::fromLatin1("ALT+J") << false; + QTest::newRow("4") << QString::fromLatin1("&&bon&jo&ur") << QString::fromLatin1("ALT+J") << true; + QTest::newRow("5") << QString::fromLatin1("b&on&&jour") << QString::fromLatin1("ALT+O") << false; + QTest::newRow("6") << QString::fromLatin1("bonjour") << QString() << false; + QTest::newRow("7") << QString::fromLatin1("&&&bonjour") << QString::fromLatin1("ALT+B") << false; + QTest::newRow("8") << QString::fromLatin1("bonjour&&&") << QString() << false; + QTest::newRow("9") << QString::fromLatin1("bo&&nj&o&&u&r") << QString::fromLatin1("ALT+O") << true; + QTest::newRow("10") << QString::fromLatin1("BON&JOUR") << QString::fromLatin1("ALT+J") << false; + QTest::newRow("11") << QString::fromUtf8("bonjour") << QString() << false; +} + void tst_QKeySequence::mnemonic() { #ifdef Q_WS_MAC QSKIP("mnemonics are not used on Mac OS X", SkipAll); #endif - QKeySequence k = QKeySequence::mnemonic("&Foo"); - QVERIFY(k == QKeySequence("ALT+F")); - k = QKeySequence::mnemonic("&& &x"); - QVERIFY(k == QKeySequence("ALT+X")); + QFETCH(QString, string); + QFETCH(QString, key); + QFETCH(bool, warning); + +#ifndef QT_NO_DEBUG + if (warning) { + QString str = QString::fromLatin1("QKeySequence::mnemonic: \"%1\" contains multiple occurences of '&'").arg(string); + QTest::ignoreMessage(QtWarningMsg, qPrintable(str)); + // qWarning(qPrintable(str)); + } +#endif + QKeySequence seq = QKeySequence::mnemonic(string); + QKeySequence res = QKeySequence(key); + + QCOMPARE(seq, res); } + + void tst_QKeySequence::toString_data() { QTest::addColumn<QString>("strSequence"); diff --git a/tests/auto/qlistwidget/tst_qlistwidget.cpp b/tests/auto/qlistwidget/tst_qlistwidget.cpp index 5c6ed54..cb8f1e9 100644 --- a/tests/auto/qlistwidget/tst_qlistwidget.cpp +++ b/tests/auto/qlistwidget/tst_qlistwidget.cpp @@ -879,7 +879,7 @@ void tst_QListWidget::moveItemsPriv() for (int r = 0; r < rowCount; ++r) new QListWidgetItem(QString::number(r), testWidget); - QListModel *model = dynamic_cast<QListModel *>(testWidget->model()); + QListModel *model = qobject_cast<QListModel *>(testWidget->model()); QVERIFY(model); QSignalSpy beginMoveSpy(model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); QSignalSpy movedSpy(model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); diff --git a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp index f319891..b99760e 100644 --- a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp +++ b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp @@ -321,7 +321,7 @@ struct RefCounted instanceCount.ref(); } - RefCounted(RefCounted const &other) + RefCounted(RefCounted const &) : ref(0) { instanceCount.ref(); @@ -335,6 +335,7 @@ struct RefCounted RefCounted &operator=(RefCounted const &) { + return *this; } QAtomicInt ref; @@ -413,27 +414,6 @@ void tst_QScopedPointer::comparison() QCOMPARE( int(RefCounted::instanceCount), 0 ); { - // QCustomScopedPointer is an internal helper class -- it is unsupported! - - RefCounted *a = new RefCounted; - RefCounted *b = new RefCounted; - - QCOMPARE( int(RefCounted::instanceCount), 2 ); - - QCustomScopedPointer<RefCounted> pa1(a); - QCustomScopedPointer<RefCounted> pa2(a); - QCustomScopedPointer<RefCounted> pb(b); - - scopedPointerComparisonTest(pa1, pa2, pb); - - pa2.take(); - - QCOMPARE( int(RefCounted::instanceCount), 2 ); - } - - QCOMPARE( int(RefCounted::instanceCount), 0 ); - - { // QScopedSharedPointer is an internal helper class -- it is unsupported! RefCounted *a = new RefCounted; @@ -441,13 +421,9 @@ void tst_QScopedPointer::comparison() QCOMPARE( int(RefCounted::instanceCount), 2 ); - a->ref.ref(); - QScopedSharedPointer<RefCounted> pa1(a); - a->ref.ref(); - QScopedSharedPointer<RefCounted> pa2(a); - b->ref.ref(); - QScopedSharedPointer<RefCounted> pb(b); - + QSharedDataPointer<RefCounted> pa1(a); + QSharedDataPointer<RefCounted> pa2(a); + QSharedDataPointer<RefCounted> pb(b); QCOMPARE( int(a->ref), 2 ); QCOMPARE( int(b->ref), 1 ); diff --git a/tests/auto/qvideosurfaceformat/tst_qvideosurfaceformat.cpp b/tests/auto/qvideosurfaceformat/tst_qvideosurfaceformat.cpp index a47cb48..2b78d20 100644 --- a/tests/auto/qvideosurfaceformat/tst_qvideosurfaceformat.cpp +++ b/tests/auto/qvideosurfaceformat/tst_qvideosurfaceformat.cpp @@ -292,13 +292,13 @@ void tst_QVideoSurfaceFormat::frameRate_data() QTest::addColumn<qreal>("frameRate"); QTest::newRow("null") - << 0.0; + << qreal(0.0); QTest::newRow("1/1") - << 1.0; + << qreal(1.0); QTest::newRow("24/1") - << 24.0; + << qreal(24.0); QTest::newRow("15/2") - << 7.5; + << qreal(7.5); } void tst_QVideoSurfaceFormat::frameRate() @@ -583,7 +583,7 @@ void tst_QVideoSurfaceFormat::compare() QCOMPARE(format1 == format2, false); QCOMPARE(format1 != format2, true); - format2.setFrameRate(7.50001); + format2.setFrameRate(qreal(7.50001)); // Equal. QCOMPARE(format1 == format2, true); diff --git a/tests/manual/windowflags/previewwindow.cpp b/tests/manual/windowflags/previewwindow.cpp index 78f9fcb..31e8b3e 100644 --- a/tests/manual/windowflags/previewwindow.cpp +++ b/tests/manual/windowflags/previewwindow.cpp @@ -103,8 +103,18 @@ PreviewWindow::PreviewWindow(QWidget *parent) closeButton = new QPushButton(tr("&Close")); connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); + showNormalButton = new QPushButton(tr("Show normal")); + connect(showNormalButton, SIGNAL(clicked()), this, SLOT(showNormal())); + showMaximizedButton = new QPushButton(tr("Show maximized")); + connect(showMaximizedButton, SIGNAL(clicked()), this, SLOT(showMaximized())); + showFullScreenButton = new QPushButton(tr("Show fullscreen")); + connect(showFullScreenButton, SIGNAL(clicked()), this, SLOT(showFullScreen())); + QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(textEdit); + layout->addWidget(showNormalButton); + layout->addWidget(showMaximizedButton); + layout->addWidget(showFullScreenButton); layout->addWidget(closeButton); setLayout(layout); @@ -129,8 +139,18 @@ PreviewDialog::PreviewDialog(QWidget *parent) closeButton = new QPushButton(tr("&Close")); connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); + showNormalButton = new QPushButton(tr("Show normal")); + connect(showNormalButton, SIGNAL(clicked()), this, SLOT(showNormal())); + showMaximizedButton = new QPushButton(tr("Show maximized")); + connect(showMaximizedButton, SIGNAL(clicked()), this, SLOT(showMaximized())); + showFullScreenButton = new QPushButton(tr("Show fullscreen")); + connect(showFullScreenButton, SIGNAL(clicked()), this, SLOT(showFullScreen())); + QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(textEdit); + layout->addWidget(showNormalButton); + layout->addWidget(showMaximizedButton); + layout->addWidget(showFullScreenButton); layout->addWidget(closeButton); setLayout(layout); diff --git a/tests/manual/windowflags/previewwindow.h b/tests/manual/windowflags/previewwindow.h index fdd21d7..fbf822b 100644 --- a/tests/manual/windowflags/previewwindow.h +++ b/tests/manual/windowflags/previewwindow.h @@ -62,6 +62,9 @@ public: private: QTextEdit *textEdit; QPushButton *closeButton; + QPushButton *showNormalButton; + QPushButton *showMaximizedButton; + QPushButton *showFullScreenButton; }; class PreviewDialog : public QDialog @@ -76,6 +79,9 @@ public: private: QTextEdit *textEdit; QPushButton *closeButton; + QPushButton *showNormalButton; + QPushButton *showMaximizedButton; + QPushButton *showFullScreenButton; }; #endif |