diff options
author | Janne Anttila <janne.anttila@digia.com> | 2009-09-24 10:23:50 (GMT) |
---|---|---|
committer | Janne Anttila <janne.anttila@digia.com> | 2009-09-24 10:23:50 (GMT) |
commit | 135e02d11becc8ee434524756d85221244c185ee (patch) | |
tree | b9acabb3424321fa3eb5f6390e0f87c3fdee91f7 /tests | |
parent | 39d0ded8f6e94df2a08876ee1cf00253ef2b7de3 (diff) | |
parent | d57e2f4d01534f44dde629b71398783777fdad4e (diff) | |
download | Qt-135e02d11becc8ee434524756d85221244c185ee.zip Qt-135e02d11becc8ee434524756d85221244c185ee.tar.gz Qt-135e02d11becc8ee434524756d85221244c185ee.tar.bz2 |
Merge branch '4.6' of git@scm.dev.troll.no:qt/qt into 4.6
Diffstat (limited to 'tests')
46 files changed, 553 insertions, 261 deletions
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecontexts/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecontexts/main.cpp index 7e81b84..25c2c0d 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecontexts/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/parsecontexts/main.cpp @@ -262,6 +262,15 @@ QString C2::foo() } +namespace Fooish { + Q_DECLARE_TR_FUNCTIONS(Bears::And::Spiders) +} + +void Fooish::bar() +{ + return tr("whatever the context", "Bears::And::Spiders"); +} + int main(int /*argc*/, char ** /*argv*/) { return 0; diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecontexts/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecontexts/project.ts.result index 9b00d53..2f21de2 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecontexts/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/parsecontexts/project.ts.result @@ -102,6 +102,15 @@ </message> </context> <context> + <name>Bears::And::Spiders</name> + <message> + <location filename="main.cpp" line="271"/> + <source>whatever the context</source> + <comment>Bears::And::Spiders</comment> + <translation type="unfinished"></translation> + </message> +</context> +<context> <name>C1</name> <message> <location filename="main.cpp" line="230"/> diff --git a/tests/auto/q3table/tst_q3table.cpp b/tests/auto/q3table/tst_q3table.cpp index 1fe4412..770bf4d 100644 --- a/tests/auto/q3table/tst_q3table.cpp +++ b/tests/auto/q3table/tst_q3table.cpp @@ -51,6 +51,8 @@ #include <q3table.h> #include <qlayout.h> +#include "../../shared/util.h" + #define WAITS 1 #ifdef WAITS #endif @@ -499,6 +501,8 @@ void tst_Q3Table::pageUpDownNavigation() void tst_Q3Table::simpleKeyboardNavigation() { + QApplication::setActiveWindow(testWidget); + QTRY_COMPARE(QApplication::activeWindow(), testWidget); QWidget *w; // Test for task #24726 @@ -519,6 +523,7 @@ void tst_Q3Table::simpleKeyboardNavigation() // After the first keyevent, the table starts editing the item w = testWidget->cellWidget(0, 0); + QVERIFY(w); #ifdef WAITS QTest::qWait(50); @@ -1201,12 +1206,17 @@ void tst_Q3Table::editCheck() EditCheckQ3Table table(10, 10, 0); table.show(); + QApplication::setActiveWindow(&table); QTest::qWaitForWindowShown(&table); + QTRY_COMPARE(QApplication::activeWindow(), &table); table.setCurrentCell(0, 0); #ifdef WAITS QTest::qWait(50); #endif QTest::keyClick(table.viewport(), Qt::Key_T); +#ifdef WAITS + QTest::qWait(50); +#endif // After the first keyevent, the table starts editing the item QLineEdit *le = qFindChild<QLineEdit *>(testWidget->viewport(), "qt_lineeditor"); #ifdef WAITS @@ -1333,6 +1343,9 @@ void tst_Q3Table::valueChanged() testWidget->setItem(0, 0, ti); connect(testWidget,SIGNAL(valueChanged(int,int)),this,SLOT(onValueChanged(int,int))); testWidget->show(); + QApplication::setActiveWindow(testWidget); + QTest::qWaitForWindowShown(testWidget); + QTRY_COMPARE(QApplication::activeWindow(), testWidget); #ifdef WAITS QTest::qWait(50); #endif @@ -1340,6 +1353,7 @@ void tst_Q3Table::valueChanged() #ifdef WAITS QTest::qWait(50); #endif + QTRY_VERIFY(qApp->focusWidget()); QTest::keyClick(qApp->focusWidget(), Qt::Key_Enter); #ifdef WAITS QTest::qWait(50); @@ -1379,7 +1393,9 @@ void tst_Q3Table::dateTimeEdit() TimeTableItem *ti = new TimeTableItem(testWidget); testWidget->setItem(0, 0, ti); testWidget->show(); - QTest::qWaitForWindowShown(&testWidget); + QApplication::setActiveWindow(testWidget); + QTest::qWaitForWindowShown(testWidget); + QTRY_COMPARE(QApplication::activeWindow(), testWidget); #ifdef WAITS QTest::qWait(50); #endif @@ -1387,6 +1403,7 @@ void tst_Q3Table::dateTimeEdit() #ifdef WAITS QTest::qWait(50); #endif + QTRY_VERIFY(qApp->focusWidget()); QTest::keyClick(qApp->focusWidget(), Qt::Key_Enter); #ifdef WAITS QTest::qWait(50); diff --git a/tests/auto/q3textbrowser/tst_q3textbrowser.cpp b/tests/auto/q3textbrowser/tst_q3textbrowser.cpp index 9a9f55c..b4c7e0d 100644 --- a/tests/auto/q3textbrowser/tst_q3textbrowser.cpp +++ b/tests/auto/q3textbrowser/tst_q3textbrowser.cpp @@ -97,6 +97,7 @@ void tst_Q3TextBrowser::setFont() { QFont f("Courier", 6); testWidget->setFont(f); + f = f.resolve(testWidget->font()); QVERIFY(testWidget->font() == f); } diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp index c53fca8..abcacef 100644 --- a/tests/auto/qapplication/tst_qapplication.cpp +++ b/tests/auto/qapplication/tst_qapplication.cpp @@ -154,7 +154,7 @@ public: void tst_QApplication::sendEventsOnProcessEvents() { int argc = 0; - QApplication app(argc, 0); + QApplication app(argc, 0, QApplication::GuiServer); EventSpy spy; app.installEventFilter(&spy); diff --git a/tests/auto/qaudiodeviceid/qaudiodeviceid.pro b/tests/auto/qaudiodeviceid/qaudiodeviceid.pro deleted file mode 100644 index e0c7d4d..0000000 --- a/tests/auto/qaudiodeviceid/qaudiodeviceid.pro +++ /dev/null @@ -1,7 +0,0 @@ -load(qttest_p4) - -DEFINES += SRCDIR=\\\"$$PWD/\\\" - -SOURCES += tst_qaudiodeviceid.cpp - -QT = core multimedia diff --git a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp index 45912e2..7b9a422 100644 --- a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp +++ b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp @@ -77,7 +77,7 @@ private: void tst_QAudioDeviceInfo::initTestCase() { // Only perform tests if audio output device exists! - QList<QAudioDeviceId> devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput); + QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput); if(devices.size() > 0) available = true; else { @@ -90,7 +90,7 @@ void tst_QAudioDeviceInfo::checkAvailableDefaultInput() { // Only perform tests if audio input device exists! bool storeAvailable = available; - QList<QAudioDeviceId> devices = QAudioDeviceInfo::deviceList(QAudio::AudioInput); + QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::deviceList(QAudio::AudioInput); if(devices.size() > 0) available = true; else { @@ -111,9 +111,9 @@ void tst_QAudioDeviceInfo::checkAvailableDefaultOutput() void tst_QAudioDeviceInfo::outputList() { if(available) { - QList<QAudioDeviceId> devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput); + QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput); QVERIFY(devices.size() > 0); - device = new QAudioDeviceInfo(devices.at(0), this); + device = new QAudioDeviceInfo(devices.at(0)); } } diff --git a/tests/auto/qaudioinput/qaudioinput.pro b/tests/auto/qaudioinput/qaudioinput.pro index 8a03749..f545a11 100644 --- a/tests/auto/qaudioinput/qaudioinput.pro +++ b/tests/auto/qaudioinput/qaudioinput.pro @@ -1,7 +1,15 @@ load(qttest_p4) -DEFINES += SRCDIR=\\\"$$PWD/\\\" - SOURCES += tst_qaudioinput.cpp QT = core multimedia + +wince* { + deploy.sources += 4.wav + DEPLOYMENT = deploy + DEFINES += SRCDIR=\\\"\\\" + QT += gui +} else { + DEFINES += SRCDIR=\\\"$$PWD/\\\" +} + diff --git a/tests/auto/qaudioinput/tst_qaudioinput.cpp b/tests/auto/qaudioinput/tst_qaudioinput.cpp index bf11961..7331072 100644 --- a/tests/auto/qaudioinput/tst_qaudioinput.cpp +++ b/tests/auto/qaudioinput/tst_qaudioinput.cpp @@ -75,7 +75,7 @@ void tst_QAudioInput::initTestCase() format.setSampleType(QAudioFormat::UnSignedInt); // Only perform tests if audio input device exists! - QList<QAudioDeviceId> devices = QAudioDeviceInfo::deviceList(QAudio::AudioInput); + QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::deviceList(QAudio::AudioInput); if(devices.size() > 0) available = true; else { diff --git a/tests/auto/qaudiooutput/qaudiooutput.pro b/tests/auto/qaudiooutput/qaudiooutput.pro index 6c07c64..8657edb 100644 --- a/tests/auto/qaudiooutput/qaudiooutput.pro +++ b/tests/auto/qaudiooutput/qaudiooutput.pro @@ -1,12 +1,14 @@ load(qttest_p4) -DEFINES += SRCDIR=\\\"$$PWD/\\\" - SOURCES += tst_qaudiooutput.cpp QT = core multimedia -wince*: { - deploy.sources += 4.wav - DEPLOYMENT = deploy +wince* { + deploy.sources += 4.wav + DEPLOYMENT = deploy + DEFINES += SRCDIR=\\\"\\\" + QT += gui +} else { + DEFINES += SRCDIR=\\\"$$PWD/\\\" } diff --git a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp index 6356fb3..b45a57e 100644 --- a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp +++ b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp @@ -78,7 +78,7 @@ void tst_QAudioOutput::initTestCase() format.setSampleType(QAudioFormat::UnSignedInt); // Only perform tests if audio output device exists! - QList<QAudioDeviceId> devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput); + QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput); if(devices.size() > 0) available = true; else { @@ -117,37 +117,37 @@ void tst_QAudioOutput::notifyInterval() void tst_QAudioOutput::pullFile() { if(available) { - QFile filename(SRCDIR "4.wav"); - QVERIFY(filename.exists()); - filename.open(QIODevice::ReadOnly); + QFile file(SRCDIR "4.wav"); + QVERIFY(file.exists()); + file.open(QIODevice::ReadOnly); QSignalSpy readSignal(audio, SIGNAL(notify())); audio->setNotifyInterval(100); - audio->start(&filename); + audio->start(&file); QTestEventLoop::instance().enterLoop(1); + QCOMPARE(audio->totalTime(), qint64(692250)); // 4.wav is a little less than 700ms, so notify should fire 6 times! QVERIFY(readSignal.count() >= 6); - QVERIFY(audio->totalTime() == 692250); audio->stop(); - filename.close(); + file.close(); } } void tst_QAudioOutput::pushFile() { if(available) { - QFile filename(SRCDIR "4.wav"); - QVERIFY(filename.exists()); - filename.open(QIODevice::ReadOnly); + QFile file(SRCDIR "4.wav"); + QVERIFY(file.exists()); + file.open(QIODevice::ReadOnly); - const qint64 fileSize = filename.size(); + const qint64 fileSize = file.size(); QIODevice* feed = audio->start(0); char* buffer = new char[fileSize]; - filename.read(buffer, fileSize); + file.read(buffer, fileSize); qint64 counter=0; qint64 written=0; @@ -162,7 +162,7 @@ void tst_QAudioOutput::pushFile() QVERIFY(audio->totalTime() == 692250); audio->stop(); - filename.close(); + file.close(); delete [] buffer; delete audio; } diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index b549af6..8dfe836 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -77,6 +77,9 @@ #include <qabstractitemview.h> #include "../../shared/util.h" #include <qstyleditemdelegate.h> +#ifndef QT_NO_STYLE_WINDOWS +#include <qwindowsstyle.h> +#endif //TESTED_CLASS= //TESTED_FILES= @@ -2140,7 +2143,7 @@ void tst_QComboBox::task247863_keyBoardSelection() combo.addItem( QLatin1String("222")); combo.show(); QApplication::setActiveWindow(&combo); - QTRY_COMPARE(QApplication::activeWindow(), &combo); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&combo)); QSignalSpy spy(&combo, SIGNAL(activated(const QString &))); qApp->setEffectEnabled(Qt::UI_AnimateCombo, false); @@ -2161,7 +2164,7 @@ void tst_QComboBox::task220195_keyBoardSelection2() combo.addItem( QLatin1String("foo3")); combo.show(); QApplication::setActiveWindow(&combo); - QTRY_COMPARE(QApplication::activeWindow(), &combo); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&combo)); combo.setCurrentIndex(-1); QVERIFY(combo.currentText().isNull()); @@ -2353,6 +2356,9 @@ void tst_QComboBox::subControlRectsWithOffset() void tst_QComboBox::task260974_menuItemRectangleForComboBoxPopup() { +#ifdef QT_NO_STYLE_WINDOWS + QSKIP("test depends on windows style", QTest::SkipAll); +#else class TestStyle: public QWindowsStyle { public: @@ -2385,6 +2391,7 @@ void tst_QComboBox::task260974_menuItemRectangleForComboBoxPopup() QTRY_VERIFY(style.discoveredRect.width() <= comboBox.width()); } +#endif } QTEST_MAIN(tst_QComboBox) diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp index 1baae90..43205e1 100644 --- a/tests/auto/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/qcompleter/tst_qcompleter.cpp @@ -1011,6 +1011,7 @@ void tst_QCompleter::multipleWidgets() QWidget window; window.show(); QApplication::setActiveWindow(&window); + QTest::qWaitForWindowShown(&window); QTRY_VERIFY(qApp->activeWindow() == &window); QFocusEvent focusIn(QEvent::FocusIn); @@ -1022,9 +1023,6 @@ void tst_QCompleter::multipleWidgets() comboBox->setFocus(); comboBox->show(); window.activateWindow(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&window); -#endif QApplication::setActiveWindow(&window); QTest::qWait(50); QTRY_VERIFY(qApp->focusWidget() == comboBox); diff --git a/tests/auto/qcopchannel/tst_qcopchannel.cpp b/tests/auto/qcopchannel/tst_qcopchannel.cpp index 93d037e..9a3be6c 100644 --- a/tests/auto/qcopchannel/tst_qcopchannel.cpp +++ b/tests/auto/qcopchannel/tst_qcopchannel.cpp @@ -49,6 +49,7 @@ #include <QCopChannel> #include <QProcess> +#include "../../shared/util.h" class tst_QCopChannel : public QObject { @@ -110,7 +111,7 @@ void tst_QCopChannel::sendreceivemp() testSend(channelName, "msg", "data"); QApplication::processEvents(); - QCOMPARE(spy.count(), 1); + QTRY_COMPARE(spy.count(), 1); QList<QVariant> args = spy.takeFirst(); QCOMPARE(args.at(0).toString(), QString("msg")); @@ -134,7 +135,7 @@ void tst_QCopChannel::sendreceivesp() QCOMPARE(spy.count(), 0); QCopChannel::send(channelName, "msg", "data"); QApplication::processEvents(); - QCOMPARE(spy.count(), 1); + QTRY_COMPARE(spy.count(), 1); QList<QVariant> args = spy.takeFirst(); QCOMPARE(args.at(0).toString(), QString("msg")); diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp index 18875e7..d6225cd 100644 --- a/tests/auto/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp @@ -1039,7 +1039,10 @@ void tst_QFiledialog::focus() QNonNativeFileDialog fd; fd.setDirectory(QDir::currentPath()); fd.show(); + QApplication::setActiveWindow(&fd); + QTest::qWaitForWindowShown(&fd); QTRY_COMPARE(fd.isVisible(), true); + QTRY_COMPARE(QApplication::activeWindow(), &fd); qApp->processEvents(); // make sure the tests work with focus follows mouse diff --git a/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index 489a1ed..32cbed3 100644 --- a/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -487,6 +487,9 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() timer.start(3000); eventLoop.exec(); QCOMPARE(fileChangedSpy.count(), 0); +#ifdef Q_OS_WINCE + QEXPECT_FAIL("poller", "Directory does not get updated on file removal(See #137910)", Abort); +#endif #if defined(Q_OS_SYMBIAN) && defined(Q_CC_RVCT) // Since native watcher is always used in real devices, this poller issue is irrelevant // Symbian file system does not change modification time on a directory when a file inside is changed diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index 385fb3e..2c4a253 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -64,6 +64,7 @@ private slots: void example(); void setSpacing(); void hardComplexS60(); + void stability(); void delete_anchor(); void conflicts(); void sizePolicy(); @@ -986,10 +987,26 @@ void tst_QGraphicsAnchorLayout::setSpacing() } -void tst_QGraphicsAnchorLayout::hardComplexS60() +/*! + Taken from "hard" complex case, found at + https://cwiki.nokia.com/S60QTUI/AnchorLayoutComplexCases + + This layout has a special property, since it has two possible solutions for its minimum size. + + For instance, when it is in its minimum size - the layout have two possible solutions: + 1. c.width == 10, e.width == 10 and g.width == 10 + (all others have width 0) + 2. d.width == 10 and g.width == 10 + (all others have width 0) + + It also has several solutions for preferred size. +*/ +static QGraphicsAnchorLayout *createAmbiguousS60Layout() { - // Test for "hard" complex case, taken from wiki - // https://cwiki.nokia.com/S60QTUI/AnchorLayoutComplexCases + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + l->setContentsMargins(0, 0, 0, 0); + l->setSpacing(0); + QSizeF min(0, 10); QSizeF pref(50, 10); QSizeF max(100, 10); @@ -1002,9 +1019,6 @@ void tst_QGraphicsAnchorLayout::hardComplexS60() QGraphicsWidget *f = createItem(min, pref, max, "f"); QGraphicsWidget *g = createItem(min, pref, max, "g"); - QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; - l->setContentsMargins(0, 0, 0, 0); - //<!-- Trunk --> setAnchor(l, l, Qt::AnchorLeft, a, Qt::AnchorLeft, 10); setAnchor(l, a, Qt::AnchorRight, b, Qt::AnchorLeft, 10); @@ -1034,7 +1048,12 @@ void tst_QGraphicsAnchorLayout::hardComplexS60() setAnchor(l, a, Qt::AnchorBottom, d, Qt::AnchorBottom, 0); setAnchor(l, f, Qt::AnchorBottom, g, Qt::AnchorTop, 0); setAnchor(l, g, Qt::AnchorBottom, l, Qt::AnchorBottom, 0); + return l; +} +void tst_QGraphicsAnchorLayout::hardComplexS60() +{ + QGraphicsAnchorLayout *l = createAmbiguousS60Layout(); QCOMPARE(l->count(), 7); QGraphicsWidget *p = new QGraphicsWidget(0, Qt::Window); @@ -1050,6 +1069,40 @@ void tst_QGraphicsAnchorLayout::hardComplexS60() } +void tst_QGraphicsAnchorLayout::stability() +{ + QVector<QRectF> geometries; + geometries.resize(7); + QGraphicsWidget *p = new QGraphicsWidget(0, Qt::Window); + bool sameAsPreviousArrangement = true; + // it usually fails after 3-4 iterations + for (int pass = 0; pass < 20 && sameAsPreviousArrangement; ++pass) { + // In case we need to "scramble" the heap allocator to provoke this bug. + //static const int primes[] = {2, 3, 5, 13, 89, 233, 1597, 28657, 514229}; // fibo primes + //const int primeCount = sizeof(primes)/sizeof(int); + //int alloc = primes[pass % primeCount] + pass; + //void *mem = qMalloc(alloc); + //qFree(mem); + QGraphicsAnchorLayout *l = createAmbiguousS60Layout(); + p->setLayout(l); + QSizeF layoutMinimumSize = l->effectiveSizeHint(Qt::MinimumSize); + l->setGeometry(QRectF(QPointF(0,0), layoutMinimumSize)); + QApplication::processEvents(); + for (int i = l->count() - 1; i >=0 && sameAsPreviousArrangement; --i) { + QRectF geom = l->itemAt(i)->geometry(); + if (pass != 0) { + sameAsPreviousArrangement = (geometries[i] == geom); + } + geometries[i] = geom; + } + p->setLayout(0); // uninstalls and deletes the layout + QApplication::processEvents(); + } + delete p; + QEXPECT_FAIL("", "The layout have several solutions, but which solution it picks is not stable", Continue); + QCOMPARE(sameAsPreviousArrangement, true); +} + void tst_QGraphicsAnchorLayout::delete_anchor() { QGraphicsScene scene; diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp index ba3783b..0201bc4 100644 --- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp @@ -48,6 +48,8 @@ #include <QtGui/qgraphicsitem.h> #include <QtGui/qstyleoption.h> +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES= @@ -261,10 +263,8 @@ void tst_QGraphicsEffect::draw() QGraphicsView view(&scene); view.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif - QTest::qWait(100); + QTest::qWaitForWindowShown(&view); + QTRY_VERIFY(item->numRepaints > 0); item->reset(); // Make sure installing the effect triggers a repaint. @@ -361,10 +361,8 @@ void tst_QGraphicsEffect::opacity() QGraphicsView view(&scene); view.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif - QTest::qWait(100); + QTest::qWaitForWindowShown(&view); + QTRY_VERIFY(effect->numRepaints > 0); QCOMPARE(effect->m_opacity, qreal(0.5)); } diff --git a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp index 4a664a4..a5d79de 100644 --- a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp +++ b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp @@ -46,6 +46,8 @@ #include <qgraphicswidget.h> #include <qgraphicsscene.h> #include <qgraphicsview.h> +#include <qapplication.h> +#include <qplastiquestyle.h> class tst_QGraphicsLinearLayout : public QObject { Q_OBJECT @@ -141,6 +143,9 @@ public: // It is only called once. void tst_QGraphicsLinearLayout::initTestCase() { + // since the style will influence the results, we have to ensure + // that the tests are run using the same style on all platforms + QApplication::setStyle(new QPlastiqueStyle); } // This will be called after the last test function is executed. diff --git a/tests/auto/qheaderview/tst_qheaderview.cpp b/tests/auto/qheaderview/tst_qheaderview.cpp index 0be895b..920231d 100644 --- a/tests/auto/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/qheaderview/tst_qheaderview.cpp @@ -1434,7 +1434,8 @@ void tst_QHeaderView::focusPolicy() widget.show(); widget.setFocus(Qt::OtherFocusReason); - QTest::qWait(100); + QApplication::setActiveWindow(&widget); + QTest::qWaitForWindowShown(&widget); widget.activateWindow(); QTest::qWait(100); diff --git a/tests/auto/qlabel/qlabel.pro b/tests/auto/qlabel/qlabel.pro index c274b4a..6d55c13 100644 --- a/tests/auto/qlabel/qlabel.pro +++ b/tests/auto/qlabel/qlabel.pro @@ -3,7 +3,7 @@ SOURCES += tst_qlabel.cpp wince*:{ DEFINES += SRCDIR=\\\"\\\" -} !symbian { +} else:!symbian { DEFINES += SRCDIR=\\\"$$PWD/\\\" } diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index a5bac37..d7f453e 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -440,7 +440,9 @@ void tst_QMenu::overrideMenuAction() m->addAction(aQuit); w.show(); + QApplication::setActiveWindow(&w); w.setFocus(); + QTest::qWaitForWindowShown(&w); QTRY_VERIFY(w.hasFocus()); //test of the action inside the menu diff --git a/tests/auto/qpainter/qpainter.pro b/tests/auto/qpainter/qpainter.pro index 1b3659d..c8446d1 100644 --- a/tests/auto/qpainter/qpainter.pro +++ b/tests/auto/qpainter/qpainter.pro @@ -9,7 +9,7 @@ wince*|symbian*: { wince* { DEFINES += SRCDIR=\\\".\\\" -} !symbian { +} else:!symbian { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/qprogressbar/tst_qprogressbar.cpp b/tests/auto/qprogressbar/tst_qprogressbar.cpp index ea9798b..d86094d 100644 --- a/tests/auto/qprogressbar/tst_qprogressbar.cpp +++ b/tests/auto/qprogressbar/tst_qprogressbar.cpp @@ -48,6 +48,8 @@ #include <qtimer.h> #include <QStyleFactory> +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES= diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp index b92e140..f86e81d 100644 --- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp @@ -55,10 +55,10 @@ public: int duration() const { return -1; /* not time driven */ } protected: - void updateCurrentTime(int msecs) + void updateCurrentTime() { - QPropertyAnimation::updateCurrentTime(msecs); - if (msecs >= QPropertyAnimation::duration()) + QPropertyAnimation::updateCurrentTime(); + if (currentTime() >= QPropertyAnimation::duration() || currentLoop() >= 1) stop(); } }; @@ -239,7 +239,7 @@ void tst_QPropertyAnimation::statesAndSignals() { QFETCH(bool, uncontrolled); QPropertyAnimation *anim; - if (uncontrolled) + if (uncontrolled) anim = new UncontrolledAnimation; else anim = new DummyPropertyAnimation; diff --git a/tests/auto/qs60mainapplication/qs60mainapplication.pro b/tests/auto/qs60mainapplication/qs60mainapplication.pro new file mode 100644 index 0000000..bbd6c30 --- /dev/null +++ b/tests/auto/qs60mainapplication/qs60mainapplication.pro @@ -0,0 +1,4 @@ +load(qttest_p4) +SOURCES += tst_qs60mainapplication.cpp + +symbian:LIBS += -lapparc -leikcore -lcone -lavkon diff --git a/tests/auto/qaudiodeviceid/tst_qaudiodeviceid.cpp b/tests/auto/qs60mainapplication/tst_qs60mainapplication.cpp index 02e475e..78fcb86 100644 --- a/tests/auto/qaudiodeviceid/tst_qaudiodeviceid.cpp +++ b/tests/auto/qs60mainapplication/tst_qs60mainapplication.cpp @@ -39,80 +39,95 @@ ** ****************************************************************************/ -#include <QtTest/QtTest> -#include <QtCore/qlocale.h> -#include <qaudiodeviceid.h> -#include <qaudiodeviceinfo.h> -#include <QStringList> -#include <QList> +#include <QtTest/QtTest> +#include <QtGui/QS60MainApplication> +#include <QtGui/QS60MainDocument> +#include <QtGui/QS60MainAppUi> +//TESTED_CLASS= +//TESTED_FILES= -class tst_QAudioDeviceId : public QObject +class tst_QS60MainApplication : public QObject { Q_OBJECT -public: - tst_QAudioDeviceId(QObject* parent=0) : QObject(parent) {} - -private slots: +public slots: void initTestCase(); - void checkNull(); - void checkEquality(); - -private: - bool available; + void cleanupTestCase(); + void init(); + void cleanup(); +private slots: + void customQS60MainApplication(); }; -void tst_QAudioDeviceId::initTestCase() +void tst_QS60MainApplication::initTestCase() { - // Only perform tests if audio output device exists! - QList<QAudioDeviceId> devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput); - if(devices.size() > 0) - available = true; - else { - qWarning()<<"NOTE: no audio output device found, no test will be performed"; - available = false; - } } -void tst_QAudioDeviceId::checkNull() +void tst_QS60MainApplication::cleanupTestCase() { - if(available) { - // Default constructed is null. - QAudioDeviceId deviceId0; - QVERIFY(deviceId0.isNull()); - - // Null is transferred - QAudioDeviceId deviceId1(deviceId0); - QVERIFY(deviceId1.isNull()); - } } -void tst_QAudioDeviceId::checkEquality() +void tst_QS60MainApplication::init() { - if(available) { - QAudioDeviceId deviceId0; - QAudioDeviceId deviceId1; +} - // Null ids are equivalent - QVERIFY(deviceId0 == deviceId1); - QVERIFY(!(deviceId0 != deviceId1)); +void tst_QS60MainApplication::cleanup() +{ +} - deviceId1 = QAudioDeviceInfo::defaultOutputDevice(); +#ifdef Q_WS_S60 +bool appUiConstructed = false; - // Different - QVERIFY(deviceId0 != deviceId1); - QVERIFY(!(deviceId0 == deviceId1)); +class CustomMainAppUi : public QS60MainAppUi +{ +public: + CustomMainAppUi() + { + appUiConstructed = true; + } +}; - // Same - deviceId0 = deviceId1; +class CustomMainDocument : public QS60MainDocument +{ +public: + CustomMainDocument(CEikApplication &eikApp) + : QS60MainDocument(eikApp) + { + } + CEikAppUi *CreateAppUiL() + { + return new (ELeave) CustomMainAppUi; + } +}; - QVERIFY(deviceId0 == deviceId1); - QVERIFY(!(deviceId0 != deviceId1)); +class CustomMainApplication : public QS60MainApplication +{ +protected: + CApaDocument *CreateDocumentL() + { + return new (ELeave) CustomMainDocument(*this); } +}; + +CApaApplication *factory() +{ + return new (ELeave) CustomMainApplication; } +#endif // Q_WS_S60 -QTEST_MAIN(tst_QAudioDeviceId) +void tst_QS60MainApplication::customQS60MainApplication() +{ +#ifndef Q_WS_S60 + QSKIP("This is an S60-only test", SkipAll); +#else + int argc = 1; + char *argv = "tst_qs60mainapplication"; + QApplication app(factory, argc, &argv); + QVERIFY(appUiConstructed); +#endif +} -#include "tst_qaudiodeviceid.moc" +QTEST_APPLESS_MAIN(tst_QS60MainApplication) +#include "tst_qs60mainapplication.moc" diff --git a/tests/auto/qscriptengine/qscriptengine.pro b/tests/auto/qscriptengine/qscriptengine.pro index f72c070..d4c0f4c 100644 --- a/tests/auto/qscriptengine/qscriptengine.pro +++ b/tests/auto/qscriptengine/qscriptengine.pro @@ -12,5 +12,4 @@ wince*|symbian*: { symbian: { TARGET.UID3 = 0xE0340006 DEFINES += SYMBIAN_SRCDIR_UID=$$lower($$replace(TARGET.UID3,"0x","")) - TARGET.EPOCHEAPSIZE="0x100000 0x1000000 // Min 1Mb, max 16Mb" } diff --git a/tests/auto/qscriptextqobject/qscriptextqobject.pro b/tests/auto/qscriptextqobject/qscriptextqobject.pro index 9da7f47..140a4e6 100644 --- a/tests/auto/qscriptextqobject/qscriptextqobject.pro +++ b/tests/auto/qscriptextqobject/qscriptextqobject.pro @@ -1,7 +1,3 @@ load(qttest_p4) QT = core gui script SOURCES += tst_qscriptextqobject.cpp - -symbian: { - TARGET.EPOCHEAPSIZE="0x100000 0x1000000 // Min 1Mb, max 16Mb" -} diff --git a/tests/auto/qscriptjstestsuite/qscriptjstestsuite.pro b/tests/auto/qscriptjstestsuite/qscriptjstestsuite.pro index 06b861e..07a4672 100644 --- a/tests/auto/qscriptjstestsuite/qscriptjstestsuite.pro +++ b/tests/auto/qscriptjstestsuite/qscriptjstestsuite.pro @@ -1,12 +1,10 @@ load(qttest_p4) QT = core script SOURCES += tst_qscriptjstestsuite.cpp -symbian { - TARGET.EPOCHEAPSIZE = 0x020000 0xA00000 -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} -wince*|symbian*: { + +!symbian: DEFINES += SRCDIR=\\\"$$PWD\\\" + +wince*|symbian: { testFiles.sources = tests testFiles.path = . DEPLOYMENT += testFiles diff --git a/tests/auto/qscriptv8testsuite/qscriptv8testsuite.pro b/tests/auto/qscriptv8testsuite/qscriptv8testsuite.pro index 3f641b5..03e26bd 100644 --- a/tests/auto/qscriptv8testsuite/qscriptv8testsuite.pro +++ b/tests/auto/qscriptv8testsuite/qscriptv8testsuite.pro @@ -8,5 +8,3 @@ testFiles.sources = tests testFiles.path = . DEPLOYMENT += testFiles } - -symbian:TARGET.EPOCHEAPSIZE = 0x00020000 0x02000000 diff --git a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp index 209e68b..b14d6f8 100644 --- a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp +++ b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp @@ -169,10 +169,10 @@ public: int duration() const { return -1; /* not time driven */ } protected: - void updateCurrentTime(int msecs) + void updateCurrentTime() { - QPropertyAnimation::updateCurrentTime(msecs); - if (msecs >= QPropertyAnimation::duration()) + QPropertyAnimation::updateCurrentTime(); + if (currentTime() >= QPropertyAnimation::duration()) stop(); } }; diff --git a/tests/auto/qspinbox/tst_qspinbox.cpp b/tests/auto/qspinbox/tst_qspinbox.cpp index 80f185a..69347c4 100644 --- a/tests/auto/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/qspinbox/tst_qspinbox.cpp @@ -752,8 +752,8 @@ void tst_QSpinBox::editingFinished() testFocusWidget->show(); QApplication::setActiveWindow(testFocusWidget); + QTest::qWaitForWindowShown(testFocusWidget); box->activateWindow(); - QTest::qWait(100);//qApp->processEvents(); box->setFocus(); QTRY_COMPARE(qApp->focusWidget(), box); diff --git a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp index 073afae..49e087f 100644 --- a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp +++ b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp @@ -1037,8 +1037,6 @@ void tst_QSqlTableModel::insertBeforeDelete() model.setEditStrategy(QSqlTableModel::OnManualSubmit); QVERIFY_SQL(model, select()); - qDebug() << model.rowCount(); - QSqlRecord rec = model.record(); rec.setValue(0, 4); rec.setValue(1, QString("bill")); diff --git a/tests/auto/qstackedlayout/tst_qstackedlayout.cpp b/tests/auto/qstackedlayout/tst_qstackedlayout.cpp index cdf84811..51f6c03 100644 --- a/tests/auto/qstackedlayout/tst_qstackedlayout.cpp +++ b/tests/auto/qstackedlayout/tst_qstackedlayout.cpp @@ -353,8 +353,9 @@ void tst_QStackedLayout::keepFocusAfterSetCurrent() stackLayout->setCurrentIndex(0); testWidget->show(); - QTest::qWait(25); QApplication::setActiveWindow(testWidget); + QTest::qWaitForWindowShown(testWidget); + QApplication::processEvents(); edit1->setFocus(); edit1->activateWindow(); diff --git a/tests/auto/qstyle/tst_qstyle.cpp b/tests/auto/qstyle/tst_qstyle.cpp index 8526be1..56776d7 100644 --- a/tests/auto/qstyle/tst_qstyle.cpp +++ b/tests/auto/qstyle/tst_qstyle.cpp @@ -219,7 +219,7 @@ void tst_QStyle::testStyleFactory() foreach (QString styleName , keys) { QStyle *style = QStyleFactory::create(styleName); - QVERIFY(style != 0); + QVERIFY2(style != 0, qPrintable(QString::fromLatin1("Fail to load style '%1'").arg(styleName))); delete style; } } diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp index e7d804a..15ed56b 100644 --- a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -95,6 +95,7 @@ private slots: void embeddedFonts(); void opaquePaintEvent_data(); void opaquePaintEvent(); + void complexWidgetFocus(); void task188195_baseBackground(); void task232085_spinBoxLineEditBg(); @@ -973,10 +974,11 @@ void tst_QStyleSheetStyle::background() void tst_QStyleSheetStyle::tabAlignement() { QTabWidget tabWidget; - tabWidget.show(); - QTest::qWait(50); tabWidget.addTab(new QLabel("tab1"),"tab1"); tabWidget.resize(QSize(400,400)); + tabWidget.show(); + QTest::qWaitForWindowShown(&tabWidget); + QTest::qWait(50); QTabBar *bar = qFindChild<QTabBar*>(&tabWidget); QVERIFY(bar); //check the tab is on the right @@ -1447,6 +1449,54 @@ void tst_QStyleSheetStyle::opaquePaintEvent() QCOMPARE(cl.autoFillBackground(), !styled ); } +void tst_QStyleSheetStyle::complexWidgetFocus() +{ + // This test is a simplified version of the focusColors() test above. + + // Tests if colors can be changed by altering the focus of the widget. + // To avoid messy pixel-by-pixel comparison, we assume that the goal + // is reached if at least ten pixels of the right color can be found in + // the image. + // For this reason, we use unusual and extremely ugly colors! :-) + + QDialog frame; + frame.setStyleSheet("*:focus { background: black; color: black } " + "QSpinBox::up-arrow:focus, QSpinBox::down-arrow:focus { width: 7px; height: 7px; background: #ff0084 } " + "QComboBox::down-arrow:focus { width: 7px; height: 7px; background: #ff0084 }" + "QSlider::handle:horizontal:focus { width: 7px; height: 7px; background: #ff0084 } "); + + QList<QWidget *> widgets; + widgets << new QSpinBox; + widgets << new QComboBox; + widgets << new QSlider(Qt::Horizontal); + + QLayout* layout = new QGridLayout; + layout->addWidget(new QLineEdit); // Avoids initial focus. + foreach (QWidget *widget, widgets) + layout->addWidget(widget); + frame.setLayout(layout); + + frame.show(); + QTest::qWaitForWindowShown(&frame); + QApplication::setActiveWindow(&frame); + foreach (QWidget *widget, widgets) { + widget->setFocus(); + QApplication::processEvents(); + + QImage image(frame.width(), frame.height(), QImage::Format_ARGB32); + frame.render(&image); + if (image.depth() < 24) { + QSKIP("Test doesn't support color depth < 24", SkipAll); + } + + QVERIFY2(testForColors(image, QColor(0xff, 0x00, 0x84)), + (QString::fromLatin1(widget->metaObject()->className()) + + " did not contain text color #ff0084, using style " + + QString::fromLatin1(qApp->style()->metaObject()->className())) + .toLocal8Bit().constData()); + } +} + void tst_QStyleSheetStyle::task188195_baseBackground() { QTreeView tree; diff --git a/tests/auto/qsvggenerator/qsvggenerator.pro b/tests/auto/qsvggenerator/qsvggenerator.pro index 450bcd3..1ccf8e9 100644 --- a/tests/auto/qsvggenerator/qsvggenerator.pro +++ b/tests/auto/qsvggenerator/qsvggenerator.pro @@ -15,6 +15,6 @@ wince*|symbian { wince* { DEFINES += SRCDIR=\\\"\\\" -} !symbian { +} else:!symbian { DEFINES += SRCDIR=\\\"$$PWD/\\\" } diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index ce13d31..f5d5040 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -2908,11 +2908,11 @@ void tst_QTableView::tabFocus() QLineEdit *edit = new QLineEdit(&window); window.show(); + QApplication::setActiveWindow(&window); QTest::qWaitForWindowShown(&window); window.setFocus(); QTest::qWait(100); window.activateWindow(); - QApplication::setActiveWindow(&window); QTest::qWait(100); qApp->processEvents(); diff --git a/tests/auto/qtextbrowser/tst_qtextbrowser.cpp b/tests/auto/qtextbrowser/tst_qtextbrowser.cpp index 1f06dcf..829d580 100644 --- a/tests/auto/qtextbrowser/tst_qtextbrowser.cpp +++ b/tests/auto/qtextbrowser/tst_qtextbrowser.cpp @@ -63,10 +63,8 @@ class TestBrowser : public QTextBrowser public: inline TestBrowser() : htmlLoadAttempts(0) { show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(this); -#endif QApplication::setActiveWindow(this); + QTest::qWaitForWindowShown(this); activateWindow(); setFocus(); QTest::qWait(50); diff --git a/tests/auto/qtextcursor/tst_qtextcursor.cpp b/tests/auto/qtextcursor/tst_qtextcursor.cpp index 88ecc73..d910c8d 100644 --- a/tests/auto/qtextcursor/tst_qtextcursor.cpp +++ b/tests/auto/qtextcursor/tst_qtextcursor.cpp @@ -147,6 +147,8 @@ private slots: void task244408_wordUnderCursor_data(); void task244408_wordUnderCursor(); + void adjustCursorsOnInsert(); + private: int blockCount(); @@ -1658,5 +1660,97 @@ void tst_QTextCursor::task244408_wordUnderCursor() QCOMPARE(cursor.selectedText(), expected); } +void tst_QTextCursor::adjustCursorsOnInsert() +{ + cursor.insertText("Some text before "); + int posBefore = cursor.position(); + cursor.insertText("selected text"); + int posAfter = cursor.position(); + cursor.insertText(" some text afterwards"); + + QTextCursor selection = cursor; + selection.setPosition(posBefore); + selection.setPosition(posAfter, QTextCursor::KeepAnchor); + + cursor.setPosition(posBefore-1); + cursor.insertText(QLatin1String("x")); + QCOMPARE(selection.anchor(), posBefore+1); + QCOMPARE(selection.position(), posAfter+1); + doc->undo(); + + cursor.setPosition(posBefore); + cursor.insertText(QLatin1String("x")); + QCOMPARE(selection.anchor(), posBefore+1); + QCOMPARE(selection.position(), posAfter+1); + doc->undo(); + + cursor.setPosition(posBefore+1); + cursor.insertText(QLatin1String("x")); + QCOMPARE(selection.anchor(), posBefore); + QCOMPARE(selection.position(), posAfter+1); + doc->undo(); + + cursor.setPosition(posAfter-1); + cursor.insertText(QLatin1String("x")); + QCOMPARE(selection.anchor(), posBefore); + QCOMPARE(selection.position(), posAfter+1); + doc->undo(); + + cursor.setPosition(posAfter); + cursor.insertText(QLatin1String("x")); + QCOMPARE(selection.anchor(), posBefore); + QCOMPARE(selection.position(), posAfter); + doc->undo(); + + cursor.setPosition(posAfter+1); + cursor.insertText(QLatin1String("x")); + QCOMPARE(selection.anchor(), posBefore); + QCOMPARE(selection.position(), posAfter); + doc->undo(); + + selection.setPosition(posAfter); + selection.setPosition(posBefore, QTextCursor::KeepAnchor); + + cursor.setPosition(posBefore-1); + cursor.insertText(QLatin1String("x")); + QCOMPARE(selection.position(), posBefore+1); + QCOMPARE(selection.anchor(), posAfter+1); + doc->undo(); + + cursor.setPosition(posBefore); + cursor.insertText(QLatin1String("x")); + QCOMPARE(selection.position(), posBefore+1); + QCOMPARE(selection.anchor(), posAfter+1); + doc->undo(); + + cursor.setPosition(posBefore+1); + cursor.insertText(QLatin1String("x")); + QCOMPARE(selection.position(), posBefore); + QCOMPARE(selection.anchor(), posAfter+1); + doc->undo(); + + cursor.setPosition(posAfter-1); + cursor.insertText(QLatin1String("x")); + QCOMPARE(selection.position(), posBefore); + QCOMPARE(selection.anchor(), posAfter+1); + doc->undo(); + + cursor.setPosition(posAfter); + cursor.insertText(QLatin1String("x")); + QCOMPARE(selection.position(), posBefore); + QCOMPARE(selection.anchor(), posAfter+1); + doc->undo(); + + cursor.setPosition(posAfter+1); + cursor.insertText(QLatin1String("x")); + QCOMPARE(selection.position(), posBefore); + QCOMPARE(selection.anchor(), posAfter); + doc->undo(); + + + + +} + QTEST_MAIN(tst_QTextCursor) #include "tst_qtextcursor.moc" diff --git a/tests/auto/qtextedit/qtextedit.pro b/tests/auto/qtextedit/qtextedit.pro index 02f5dcb..3efabad 100644 --- a/tests/auto/qtextedit/qtextedit.pro +++ b/tests/auto/qtextedit/qtextedit.pro @@ -13,7 +13,7 @@ wince*|symbian*: { wince* { DEFINES += SRCDIR=\\\"./\\\" -} !symbian { +} else:!symbian { DEFINES += SRCDIR=\\\"$$PWD/\\\" } diff --git a/tests/auto/qtooltip/tst_qtooltip.cpp b/tests/auto/qtooltip/tst_qtooltip.cpp index 2ad74a3..283effa 100644 --- a/tests/auto/qtooltip/tst_qtooltip.cpp +++ b/tests/auto/qtooltip/tst_qtooltip.cpp @@ -112,13 +112,14 @@ void tst_QToolTip::task183679() Widget_task183679 widget; widget.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&widget); -#endif + QApplication::setActiveWindow(&widget); + QTest::qWaitForWindowShown(&widget); + QTest::qWait(30); + widget.showDelayedToolTip(100); QTest::qWait(300); - QVERIFY(QToolTip::isVisible()); + QTRY_VERIFY(QToolTip::isVisible()); QTest::keyPress(&widget, key); diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 6cfa23b..2e66da2 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -2000,7 +2000,7 @@ void tst_QWidget::showMaximized() QWidget widget; widget.setGeometry(0, 0, 10, 10); widget.showMaximized(); - QVERIFY(widget.size().width() > 20 && widget.size().height() > 20); + QTRY_VERIFY(widget.size().width() > 20 && widget.size().height() > 20); } #ifdef QT3_SUPPORT @@ -2304,8 +2304,8 @@ void tst_QWidget::showMinimizedKeepsFocus() QCOMPARE(qApp->focusWidget(), static_cast<QWidget*>(0)); window.showMinimized(); - QTest::qWait(100); - QVERIFY(window.isMinimized()); + QTest::qWait(30); + QTRY_VERIFY(window.isMinimized()); #ifdef Q_WS_QWS QEXPECT_FAIL("", "QWS does not implement showMinimized()", Continue); #endif @@ -2796,10 +2796,12 @@ void tst_QWidget::raise() QTest::qWait(50); UpdateWidget *onTop = new UpdateWidget(&topLevel); + onTop->reset(); onTop->resize(topLevel.size()); onTop->setAutoFillBackground(true); onTop->show(); QTest::qWait(50); + QTRY_VERIFY(onTop->numPaintEvents > 0); onTop->reset(); // Reset all the children. @@ -2933,7 +2935,7 @@ void tst_QWidget::stackUnder() if (expectedPaintEvents == 1 && child->numPaintEvents == 2) QEXPECT_FAIL(0, "Mac and Windows issues double repaints for Z-Order change", Continue); #endif - QCOMPARE(child->numPaintEvents, expectedPaintEvents); + QTRY_COMPARE(child->numPaintEvents, expectedPaintEvents); QCOMPARE(child->numZOrderChangeEvents, 0); child->reset(); } @@ -3072,7 +3074,7 @@ void tst_QWidget::saveRestoreGeometry() widget.resize(size); widget.show(); QTest::qWaitForWindowShown(&widget); - QTest::qWait(10); + QApplication::processEvents(); QTRY_COMPARE(widget.pos(), position); QCOMPARE(widget.size(), size); @@ -3099,7 +3101,7 @@ void tst_QWidget::saveRestoreGeometry() QVERIFY(widget.restoreGeometry(savedGeometry)); widget.show(); QTest::qWaitForWindowShown(&widget); - QTest::qWait(10); + QApplication::processEvents(); QTRY_COMPARE(widget.pos(), position); QCOMPARE(widget.size(), size); @@ -3114,7 +3116,8 @@ void tst_QWidget::saveRestoreGeometry() widget.resize(size); widget.show(); QTest::qWaitForWindowShown(&widget); - QTest::qWait(10); + QTest::qWait(100); + QTRY_COMPARE(widget.geometry().size(), size); QRect geom; @@ -3122,56 +3125,68 @@ void tst_QWidget::saveRestoreGeometry() savedGeometry = widget.saveGeometry(); geom = widget.geometry(); widget.setWindowState(widget.windowState() | Qt::WindowFullScreen); - QTest::qWait(10); QTRY_VERIFY((widget.windowState() & Qt::WindowFullScreen)); + QTest::qWait(100); QVERIFY(widget.restoreGeometry(savedGeometry)); - QTest::qWait(10); + QTest::qWait(20); + QTRY_VERIFY(!(widget.windowState() & Qt::WindowFullScreen)); QTRY_COMPARE(widget.geometry(), geom); - QVERIFY(!(widget.windowState() & Qt::WindowFullScreen)); //Restore to full screen widget.setWindowState(widget.windowState() | Qt::WindowFullScreen); - QTest::qWait(10); + QTest::qWait(20); QTRY_VERIFY((widget.windowState() & Qt::WindowFullScreen)); + QTest::qWait(200); savedGeometry = widget.saveGeometry(); geom = widget.geometry(); widget.setWindowState(widget.windowState() ^ Qt::WindowFullScreen); - QTest::qWait(10); - QTRY_VERIFY(widget.restoreGeometry(savedGeometry)); - QTest::qWait(10); + QTest::qWait(20); + QTRY_VERIFY(!(widget.windowState() & Qt::WindowFullScreen)); + QTest::qWait(200); + QVERIFY(widget.restoreGeometry(savedGeometry)); + QTest::qWait(20); + QTRY_VERIFY((widget.windowState() & Qt::WindowFullScreen)); QTRY_COMPARE(widget.geometry(), geom); QVERIFY((widget.windowState() & Qt::WindowFullScreen)); widget.setWindowState(widget.windowState() ^ Qt::WindowFullScreen); - QTest::qWait(10); + QTest::qWait(20); + QTRY_VERIFY(!(widget.windowState() & Qt::WindowFullScreen)); + QTest::qWait(20); //Restore from Maximised widget.move(position); widget.resize(size); - QTest::qWait(10); + QTest::qWait(20); + QTRY_COMPARE(widget.size(), size); + QTest::qWait(200); savedGeometry = widget.saveGeometry(); geom = widget.geometry(); widget.setWindowState(widget.windowState() | Qt::WindowMaximized); - QTest::qWait(10); + QTest::qWait(20); QTRY_VERIFY((widget.windowState() & Qt::WindowMaximized)); - QVERIFY(widget.geometry() != geom); + QTRY_VERIFY(widget.geometry() != geom); + QTest::qWait(100); QVERIFY(widget.restoreGeometry(savedGeometry)); - QTest::qWait(10); - QCOMPARE(widget.geometry(), geom); + QTest::qWait(20); + QTRY_COMPARE(widget.geometry(), geom); QVERIFY(!(widget.windowState() & Qt::WindowMaximized)); //Restore to maximised widget.setWindowState(widget.windowState() | Qt::WindowMaximized); - QTest::qWait(10); + QTest::qWait(20); QTRY_VERIFY((widget.windowState() & Qt::WindowMaximized)); + QTest::qWait(200); geom = widget.geometry(); savedGeometry = widget.saveGeometry(); widget.setWindowState(widget.windowState() ^ Qt::WindowMaximized); - QTest::qWait(10); - QTRY_VERIFY(widget.restoreGeometry(savedGeometry)); - QTest::qWait(10); + QTest::qWait(20); + QTRY_VERIFY(!(widget.windowState() & Qt::WindowMaximized)); + QTest::qWait(200); + QVERIFY(widget.restoreGeometry(savedGeometry)); + QTest::qWait(20); + QTRY_VERIFY((widget.windowState() & Qt::WindowMaximized)); QTRY_COMPARE(widget.geometry(), geom); - QVERIFY((widget.windowState() & Qt::WindowMaximized)); } } @@ -3231,8 +3246,8 @@ void tst_QWidget::restoreVersion1Geometry() QTest::qWait(100); if (expectedWindowState == Qt::WindowNoState) { - QCOMPARE(widget.pos(), expectedPosition); - QCOMPARE(widget.size(), expectedSize); + QTRY_COMPARE(widget.pos(), expectedPosition); + QTRY_COMPARE(widget.size(), expectedSize); } widget.showNormal(); @@ -4883,6 +4898,11 @@ void tst_QWidget::setWindowGeometry_data() void tst_QWidget::setWindowGeometry() { +#ifdef Q_WS_X11 + //Since WindowManager operation are all assync, and we have no way to know if the window + // manager has finished playing with the window geometry, this test can't be reliable. + QSKIP("Window Manager behaviour are too random for this test", SkipAll); +#endif QFETCH(QList<QRect>, rects); QFETCH(int, windowFlags); QRect rect = rects.takeFirst(); @@ -5030,6 +5050,11 @@ void tst_QWidget::windowMoveResize_data() void tst_QWidget::windowMoveResize() { +#ifdef Q_WS_X11 + //Since WindowManager operation are all assync, and we have no way to know if the window + // manager has finished playing with the window geometry, this test can't be reliable. + QSKIP("Window Manager behaviour are too random for this test", SkipAll); +#endif #ifdef Q_OS_IRIX QSKIP("4DWM issues on IRIX makes this test fail", SkipAll); #endif @@ -5253,14 +5278,19 @@ public: const QRegion r = QRegion(region); \ for (int i = 0; i < r.rects().size(); ++i) { \ const QRect rect = r.rects().at(i); \ - const QPixmap pixmap = QPixmap::grabWindow(QDesktopWidget().winId(), \ + for (int t = 0; t < 5; t++) { \ + const QPixmap pixmap = QPixmap::grabWindow(QDesktopWidget().winId(), \ rect.left(), rect.top(), \ rect.width(), rect.height()); \ - QCOMPARE(pixmap.size(), rect.size()); \ - QPixmap expectedPixmap(pixmap); /* ensure equal formats */ \ - expectedPixmap.fill(color); \ - QCOMPARE(pixmap.toImage().pixel(0,0), QColor(color).rgb()); \ - QCOMPARE(pixmap, expectedPixmap); \ + QCOMPARE(pixmap.size(), rect.size()); \ + QPixmap expectedPixmap(pixmap); /* ensure equal formats */ \ + expectedPixmap.fill(color); \ + if (pixmap.toImage().pixel(0,0) != QColor(color).rgb() && t < 4 ) \ + { QTest::qWait(200); continue; } \ + QCOMPARE(pixmap.toImage().pixel(0,0), QColor(color).rgb()); \ + QCOMPARE(pixmap, expectedPixmap); \ + break; \ + } \ } \ } @@ -5300,8 +5330,8 @@ void tst_QWidget::moveChild() #ifdef QT_MAC_USE_COCOA QEXPECT_FAIL(0, "Cocoa compositor paints the entire content view, even when opaque", Continue); #endif - QCOMPARE(parent.r, QRegion(parent.rect()) - child.geometry()); - QCOMPARE(child.r, QRegion(child.rect())); + QTRY_COMPARE(parent.r, QRegion(parent.rect()) - child.geometry()); + QTRY_COMPARE(child.r, QRegion(child.rect())); VERIFY_COLOR(child.geometry().translated(tlwOffset), child.color); VERIFY_COLOR(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), @@ -5316,7 +5346,7 @@ void tst_QWidget::moveChild() QPoint pos = child.pos() + offset; child.move(pos); QTest::qWait(100); - QCOMPARE(pos, child.pos()); + QTRY_COMPARE(pos, child.pos()); QCOMPARE(parent.r, QRegion(oldGeometry) - child.geometry()); #if !defined(Q_WS_MAC) @@ -7364,8 +7394,8 @@ void tst_QWidget::repaintWhenChildDeleted() #endif w.show(); QTest::qWaitForWindowShown(&w); - QTest::qWait(30); - QCOMPARE(w.r, QRegion(w.rect())); + QTest::qWait(10); + QTRY_COMPARE(w.r, QRegion(w.rect())); w.r = QRegion(); { @@ -7373,13 +7403,13 @@ void tst_QWidget::repaintWhenChildDeleted() ColorWidget child(&w, Qt::blue); child.setGeometry(10, 10, 10, 10); child.show(); - QTest::qWait(100); - QCOMPARE(child.r, QRegion(child.rect())); + QTest::qWait(10); + QTRY_COMPARE(child.r, QRegion(child.rect())); w.r = QRegion(); } - QTest::qWait(100); - QCOMPARE(w.r, QRegion(10, 10, 10, 10)); + QTest::qWait(10); + QTRY_COMPARE(w.r, QRegion(10, 10, 10, 10)); } // task 175114 @@ -7431,8 +7461,10 @@ void tst_QWidget::updateWhileMinimized() // Filter out activation change and focus events to avoid update() calls in QWidget. widget.updateOnActivationChangeAndFocusIn = false; widget.show(); + widget.reset(); QTest::qWaitForWindowShown(&widget); QApplication::processEvents(); + QTRY_VERIFY(widget.numPaintEvents > 0); // Minimize window. widget.showMinimized(); @@ -8044,10 +8076,8 @@ void tst_QWidget::resizeInPaintEvent() QWidget window; UpdateWidget widget(&window); window.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&window); -#endif - QTest::qWait(100); + QTest::qWaitForWindowShown(&window); + QTRY_VERIFY(widget.numPaintEvents > 0); widget.reset(); QCOMPARE(widget.numPaintEvents, 0); @@ -8059,9 +8089,9 @@ void tst_QWidget::resizeInPaintEvent() QCOMPARE(widget.numPaintEvents, 1); widget.numPaintEvents = 0; - QTest::qWait(100); + QTest::qWait(10); // Make sure the resize triggers another update. - QCOMPARE(widget.numPaintEvents, 1); + QTRY_COMPARE(widget.numPaintEvents, 1); } #endif @@ -8571,8 +8601,7 @@ void tst_QWidget::setClearAndResizeMask() topLevel.resize(150, 150); topLevel.show(); QTest::qWaitForWindowShown(&topLevel); - QTest::qWait(40); - + QTRY_VERIFY(topLevel.numPaintEvents > 0); topLevel.reset(); // Mask top-level widget @@ -8589,20 +8618,20 @@ void tst_QWidget::setClearAndResizeMask() // Clear top-level mask topLevel.clearMask(); QCOMPARE(topLevel.mask(), QRegion()); - QTest::qWait(100); + QTest::qWait(10); QRegion outsideOldMask(topLevel.rect()); outsideOldMask -= topLevelMask; #if defined(Q_WS_WIN) || defined(Q_WS_X11) // We don't control what's happening on other platforms. // and ensure that the top-level gets an update for the area outside the old mask. QTRY_VERIFY(topLevel.numPaintEvents > 0); - QCOMPARE(topLevel.paintedRegion, outsideOldMask); + QTRY_COMPARE(topLevel.paintedRegion, outsideOldMask); #endif UpdateWidget child(&topLevel); child.setAutoFillBackground(true); // NB! Opaque child. child.resize(100, 100); child.show(); - QTest::qWait(50); + QTest::qWait(10); child.reset(); topLevel.reset(); @@ -8630,10 +8659,10 @@ void tst_QWidget::setClearAndResizeMask() // Clear child widget mask child.clearMask(); - QCOMPARE(child.mask(), QRegion()); - QTest::qWait(50); + QTRY_COMPARE(child.mask(), QRegion()); + QTest::qWait(10); // and ensure that that the child widget gets an update for the area outside the old mask. - QCOMPARE(child.numPaintEvents, 1); + QTRY_COMPARE(child.numPaintEvents, 1); outsideOldMask = child.rect(); #ifndef Q_WS_MAC // Mac always issues a full update when calling setMask, and we cannot force it to not do so. @@ -8648,10 +8677,10 @@ void tst_QWidget::setClearAndResizeMask() // Mask child widget with a mask that is bigger than the rect child.setMask(QRegion(0, 0, 1000, 1000)); - QTest::qWait(50); + QTest::qWait(10); #ifdef Q_WS_MAC // Mac always issues a full update when calling setMask, and we cannot force it to not do so. - QCOMPARE(child.numPaintEvents, 1); + QTRY_COMPARE(child.numPaintEvents, 1); #else // and ensure that we don't get any updates at all. QCOMPARE(child.numPaintEvents, 0); @@ -8660,10 +8689,10 @@ void tst_QWidget::setClearAndResizeMask() // ...and the same applies when clearing the mask. child.clearMask(); - QTest::qWait(50); + QTest::qWait(10); #ifdef Q_WS_MAC // Mac always issues a full update when calling setMask, and we cannot force it to not do so. - QVERIFY(child.numPaintEvents > 0); + QTRY_VERIFY(child.numPaintEvents > 0); #else QCOMPARE(child.numPaintEvents, 0); #endif @@ -8726,10 +8755,9 @@ void tst_QWidget::maskedUpdate() grandChild.setMask(grandChildMask); topLevel.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&topLevel); -#endif - QTest::qWait(200); + QTest::qWaitForWindowShown(&topLevel); + QTRY_VERIFY(topLevel.numPaintEvents > 0); + #define RESET_WIDGETS \ topLevel.reset(); \ @@ -8747,29 +8775,29 @@ void tst_QWidget::maskedUpdate() // TopLevel update. RESET_WIDGETS; topLevel.update(); - QTest::qWait(100); + QTest::qWait(10); - QCOMPARE(topLevel.paintedRegion, topLevelMask); - QCOMPARE(child.paintedRegion, childMask); - QCOMPARE(grandChild.paintedRegion, grandChildMask); + QTRY_COMPARE(topLevel.paintedRegion, topLevelMask); + QTRY_COMPARE(child.paintedRegion, childMask); + QTRY_COMPARE(grandChild.paintedRegion, grandChildMask); // Child update. RESET_WIDGETS; child.update(); - QTest::qWait(100); + QTest::qWait(10); - QCOMPARE(topLevel.paintedRegion, childMask.translated(child.pos())); - QCOMPARE(child.paintedRegion, childMask); - QCOMPARE(grandChild.paintedRegion, grandChildMask); + QTRY_COMPARE(topLevel.paintedRegion, childMask.translated(child.pos())); + QTRY_COMPARE(child.paintedRegion, childMask); + QTRY_COMPARE(grandChild.paintedRegion, grandChildMask); // GrandChild update. RESET_WIDGETS; grandChild.update(); - QTest::qWait(100); + QTest::qWait(10); - QCOMPARE(topLevel.paintedRegion, grandChildMask.translated(grandChild.mapTo(&topLevel, QPoint()))); - QCOMPARE(child.paintedRegion, grandChildMask.translated(grandChild.pos())); - QCOMPARE(grandChild.paintedRegion, grandChildMask); + QTRY_COMPARE(topLevel.paintedRegion, grandChildMask.translated(grandChild.mapTo(&topLevel, QPoint()))); + QTRY_COMPARE(child.paintedRegion, grandChildMask.translated(grandChild.pos())); + QTRY_COMPARE(grandChild.paintedRegion, grandChildMask); topLevel.setAttribute(Qt::WA_OpaquePaintEvent); child.setAttribute(Qt::WA_OpaquePaintEvent); @@ -8781,41 +8809,41 @@ void tst_QWidget::maskedUpdate() // TopLevel update. RESET_WIDGETS; topLevel.update(); - QTest::qWait(100); + QTest::qWait(10); QRegion expectedTopLevelUpdate = topLevelMask; expectedTopLevelUpdate -= childMask.translated(child.pos()); // Subtract opaque children. - QCOMPARE(topLevel.paintedRegion, expectedTopLevelUpdate); - QCOMPARE(child.paintedRegion, QRegion()); - QCOMPARE(grandChild.paintedRegion, QRegion()); + QTRY_COMPARE(topLevel.paintedRegion, expectedTopLevelUpdate); + QTRY_COMPARE(child.paintedRegion, QRegion()); + QTRY_COMPARE(grandChild.paintedRegion, QRegion()); // Child update. RESET_WIDGETS; child.update(); - QTest::qWait(100); + QTest::qWait(10); - QCOMPARE(topLevel.paintedRegion, QRegion()); + QTRY_COMPARE(topLevel.paintedRegion, QRegion()); QRegion expectedChildUpdate = childMask; expectedChildUpdate -= grandChildMask.translated(grandChild.pos()); // Subtract oapque children. - QCOMPARE(child.paintedRegion, expectedChildUpdate); - QCOMPARE(grandChild.paintedRegion, QRegion()); + QTRY_COMPARE(child.paintedRegion, expectedChildUpdate); + QTRY_COMPARE(grandChild.paintedRegion, QRegion()); // GrandChild update. RESET_WIDGETS; grandChild.update(); - QTest::qWait(100); + QTest::qWait(10); - QCOMPARE(topLevel.paintedRegion, QRegion()); - QCOMPARE(child.paintedRegion, QRegion()); - QCOMPARE(grandChild.paintedRegion, grandChildMask); + QTRY_COMPARE(topLevel.paintedRegion, QRegion()); + QTRY_COMPARE(child.paintedRegion, QRegion()); + QTRY_COMPARE(grandChild.paintedRegion, grandChildMask); // GrandChild update. CLEAR_MASK(grandChild); grandChild.update(); - QTest::qWait(100); + QTest::qWait(10); - QCOMPARE(topLevel.paintedRegion, QRegion()); - QCOMPARE(child.paintedRegion, QRegion()); + QTRY_COMPARE(topLevel.paintedRegion, QRegion()); + QTRY_COMPARE(child.paintedRegion, QRegion()); QRegion expectedGrandChildUpdate = grandChild.rect(); // Clip with parent's mask. expectedGrandChildUpdate &= childMask.translated(-grandChild.pos()); @@ -8824,36 +8852,36 @@ void tst_QWidget::maskedUpdate() // GrandChild update. CLEAR_MASK(child); grandChild.update(); - QTest::qWait(100); + QTest::qWait(10); - QCOMPARE(topLevel.paintedRegion, QRegion()); - QCOMPARE(child.paintedRegion, QRegion()); + QTRY_COMPARE(topLevel.paintedRegion, QRegion()); + QTRY_COMPARE(child.paintedRegion, QRegion()); expectedGrandChildUpdate = grandChild.rect(); // Clip with parent's mask. expectedGrandChildUpdate &= topLevelMask.translated(-grandChild.mapTo(&topLevel, QPoint())); - QCOMPARE(grandChild.paintedRegion, expectedGrandChildUpdate); + QTRY_COMPARE(grandChild.paintedRegion, expectedGrandChildUpdate); // Child update. RESET_WIDGETS; child.update(); - QTest::qWait(100); + QTest::qWait(10); - QCOMPARE(topLevel.paintedRegion, QRegion()); + QTRY_COMPARE(topLevel.paintedRegion, QRegion()); expectedChildUpdate = child.rect(); // Clip with parent's mask. expectedChildUpdate &= topLevelMask.translated(-child.pos()); expectedChildUpdate -= grandChild.geometry(); // Subtract opaque children. - QCOMPARE(child.paintedRegion, expectedChildUpdate); - QCOMPARE(grandChild.paintedRegion, QRegion()); + QTRY_COMPARE(child.paintedRegion, expectedChildUpdate); + QTRY_COMPARE(grandChild.paintedRegion, QRegion()); // GrandChild update. CLEAR_MASK(topLevel); grandChild.update(); - QTest::qWait(100); + QTest::qWait(10); - QCOMPARE(topLevel.paintedRegion, QRegion()); - QCOMPARE(child.paintedRegion, QRegion()); - QCOMPARE(grandChild.paintedRegion, QRegion(grandChild.rect())); // Full update. + QTRY_COMPARE(topLevel.paintedRegion, QRegion()); + QTRY_COMPARE(child.paintedRegion, QRegion()); + QTRY_COMPARE(grandChild.paintedRegion, QRegion(grandChild.rect())); // Full update. } #if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) @@ -9138,16 +9166,15 @@ void tst_QWidget::rectOutsideCoordinatesLimit_task144779() main.show(); QTest::qWaitForWindowShown(&main); - QTest::qWait(10); + QTest::qWait(50); QCursor::setPos(main.pos()); //get the cursor out of the picture QTest::qWait(50); - QPixmap pixmap = QPixmap::grabWindow(main.winId()); QPixmap correct(main.size()); correct.fill(Qt::green); QRect center(100, 100, 200, 200); // to avoid the decorations - QCOMPARE(pixmap.toImage().copy(center), correct.toImage().copy(center)); + QTRY_COMPARE(QPixmap::grabWindow(main.winId()).toImage().copy(center), correct.toImage().copy(center)); } void tst_QWidget::inputFocus_task257832() @@ -9206,9 +9233,10 @@ void tst_QWidget::activateWindow() mainwindow->setCentralWidget(label); mainwindow->setVisible(true); mainwindow->activateWindow(); + QTest::qWaitForWindowShown(mainwindow); qApp->processEvents(); - QVERIFY(mainwindow->isActiveWindow()); + QTRY_VERIFY(mainwindow->isActiveWindow()); // Create second mainwindow and set it active QMainWindow* mainwindow2 = new QMainWindow(); @@ -9218,16 +9246,16 @@ void tst_QWidget::activateWindow() mainwindow2->activateWindow(); qApp->processEvents(); - QVERIFY(!mainwindow->isActiveWindow()); - QVERIFY(mainwindow2->isActiveWindow()); + QTRY_VERIFY(!mainwindow->isActiveWindow()); + QTRY_VERIFY(mainwindow2->isActiveWindow()); // Revert first mainwindow back to visible active mainwindow->setVisible(true); mainwindow->activateWindow(); qApp->processEvents(); - QVERIFY(mainwindow->isActiveWindow()); - QVERIFY(!mainwindow2->isActiveWindow()); + QTRY_VERIFY(mainwindow->isActiveWindow()); + QTRY_VERIFY(!mainwindow2->isActiveWindow()); } #ifdef Q_OS_SYMBIAN diff --git a/tests/benchmarks/qanimation/rectanimation.cpp b/tests/benchmarks/qanimation/rectanimation.cpp index e5f2f57..5522847 100644 --- a/tests/benchmarks/qanimation/rectanimation.cpp +++ b/tests/benchmarks/qanimation/rectanimation.cpp @@ -73,9 +73,9 @@ int RectAnimation::duration() const } -void RectAnimation::updateCurrentTime(int msecs) +void RectAnimation::updateCurrentTime() { - qreal progress = m_easing.valueForProgress( qreal(msecs) / qreal(m_dura) ); + qreal progress = m_easing.valueForProgress( currentTime() / qreal(m_dura) ); QRect now; now.setCoords(interpolateInteger(m_start.left(), m_end.left(), progress), interpolateInteger(m_start.top(), m_end.top(), progress), diff --git a/tests/benchmarks/qanimation/rectanimation.h b/tests/benchmarks/qanimation/rectanimation.h index 84ec97d..995becb 100644 --- a/tests/benchmarks/qanimation/rectanimation.h +++ b/tests/benchmarks/qanimation/rectanimation.h @@ -58,7 +58,7 @@ public: void setDuration(int d); int duration() const; - virtual void updateCurrentTime(int msecs); + virtual void updateCurrentTime(); virtual void updateState(QAbstractAnimation::State state); private: |