diff options
author | Jason McDonald <jason.mcdonald@nokia.com> | 2010-06-15 06:43:34 (GMT) |
---|---|---|
committer | Jason McDonald <jason.mcdonald@nokia.com> | 2010-06-15 06:43:34 (GMT) |
commit | a01ce81cc2d03c64f326af8f5a7f622dc197af7e (patch) | |
tree | 91a259b01b79da456f9478ccce6da08a10523bd3 /tests | |
parent | a8e6efd6086e3c7f2d88d22c9e4b1cd7e02a8d8f (diff) | |
parent | ba3b0feb65ab69214aded7c2f78caece175d59a3 (diff) | |
download | Qt-a01ce81cc2d03c64f326af8f5a7f622dc197af7e.zip Qt-a01ce81cc2d03c64f326af8f5a7f622dc197af7e.tar.gz Qt-a01ce81cc2d03c64f326af8f5a7f622dc197af7e.tar.bz2 |
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.6
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qimagereader/tst_qimagereader.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qlocalsocket/tst_qlocalsocket.cpp | 49 | ||||
-rw-r--r-- | tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp | 111 |
3 files changed, 146 insertions, 18 deletions
diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp index 99244c2..fc2582f 100644 --- a/tests/auto/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/qimagereader/tst_qimagereader.cpp @@ -1763,14 +1763,14 @@ void tst_QImageReader::testIgnoresFormatAndExtension() QFETCH(QString, expected); QList<QByteArray> formats = QImageReader::supportedImageFormats(); - QString fileNameBase = "images/" + name + "."; + QString fileNameBase = prefix + name + "."; foreach (const QByteArray &f, formats) { if (f == extension) continue; QFile tmp(QDir::tempPath() + "/" + name + "_" + expected + "." + f); - QFile::copy(fileNameBase + extension, QFileInfo(tmp).absoluteFilePath()); + QVERIFY(QFile::copy(fileNameBase + extension, QFileInfo(tmp).absoluteFilePath())); QString format; QImage image; diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp index d2cba6e..9c09917 100644 --- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp @@ -115,7 +115,8 @@ private slots: void writeToClientAndDisconnect(); void debug(); void bytesWrittenSignal(); - + void syncDisconnectNotify(); + void asyncDisconnectNotify(); #ifdef Q_OS_SYMBIAN private: @@ -996,16 +997,9 @@ void tst_QLocalSocket::writeToClientAndDisconnect() clientSocket->close(); server.close(); - // Wait for the client to notice the broken connection. - int timeout = 5000; - do { - const int timestep = 100; - QTest::qWait(timestep); - timeout -= timestep; - } while (!readChannelFinishedSpy.count() && timeout > 0); - - QCOMPARE(readChannelFinishedSpy.count(), 1); + QTRY_COMPARE(readChannelFinishedSpy.count(), 1); QCOMPARE(client.read(buffer, sizeof(buffer)), (qint64)sizeof(buffer)); + client.waitForDisconnected(); QCOMPARE(client.state(), QLocalSocket::UnconnectedState); } @@ -1061,6 +1055,41 @@ void tst_QLocalSocket::bytesWrittenSignal() QVERIFY(writeThread.wait(2000)); } +void tst_QLocalSocket::syncDisconnectNotify() +{ +#ifdef Q_OS_SYMBIAN + unlink("syncDisconnectNotify"); +#endif + + QLocalServer server; + QVERIFY(server.listen("syncDisconnectNotify")); + QLocalSocket client; + client.connectToServer("syncDisconnectNotify"); + QVERIFY(server.waitForNewConnection()); + QLocalSocket* serverSocket = server.nextPendingConnection(); + QVERIFY(serverSocket); + delete serverSocket; + QCOMPARE(client.waitForReadyRead(), false); +} + +void tst_QLocalSocket::asyncDisconnectNotify() +{ +#ifdef Q_OS_SYMBIAN + unlink("asyncDisconnectNotify"); +#endif + + QLocalServer server; + QVERIFY(server.listen("asyncDisconnectNotify")); + QLocalSocket client; + QSignalSpy disconnectedSpy(&client, SIGNAL(disconnected())); + client.connectToServer("asyncDisconnectNotify"); + QVERIFY(server.waitForNewConnection()); + QLocalSocket* serverSocket = server.nextPendingConnection(); + QVERIFY(serverSocket); + delete serverSocket; + QTRY_VERIFY(!disconnectedSpy.isEmpty()); +} + #ifdef Q_OS_SYMBIAN void tst_QLocalSocket::unlink(QString name) { diff --git a/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp b/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp index c60af5e..a562fbe 100644 --- a/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp +++ b/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp @@ -71,6 +71,10 @@ private slots: void isAtWordStart(); void fastConstructor(); void isAtBoundaryLine(); + void toNextBoundary_data(); + void toNextBoundary(); + void toPreviousBoundary_data(); + void toPreviousBoundary(); }; tst_QTextBoundaryFinder::tst_QTextBoundaryFinder() @@ -292,25 +296,120 @@ void tst_QTextBoundaryFinder::fastConstructor() void tst_QTextBoundaryFinder::isAtBoundaryLine() { - // idx 0 1 2 3 4 5 - // break? - - - + - + + // idx 0 1 2 3 4 5 6 + // break? - - - - + - + QChar s[] = { 0x0061, 0x00AD, 0x0062, 0x0009, 0x0063, 0x0064 }; QString text(s, sizeof(s)/sizeof(s[0])); - qDebug() << "text = " << text << ", length = " << text.length(); +// qDebug() << "text = " << text << ", length = " << text.length(); QTextBoundaryFinder finder(QTextBoundaryFinder::Line, text.constData(), text.length(), /*buffer*/0, /*buffer size*/0); finder.setPosition(0); - QVERIFY(!finder.isAtBoundary()); + QVERIFY(finder.isAtBoundary()); finder.setPosition(1); QVERIFY(!finder.isAtBoundary()); finder.setPosition(2); QVERIFY(!finder.isAtBoundary()); finder.setPosition(3); - QVERIFY(finder.isAtBoundary()); - finder.setPosition(4); QVERIFY(!finder.isAtBoundary()); + finder.setPosition(4); + QVERIFY(finder.isAtBoundary()); finder.setPosition(5); + QVERIFY(!finder.isAtBoundary()); + finder.setPosition(6); QVERIFY(finder.isAtBoundary()); } +Q_DECLARE_METATYPE(QList<int>) + +void tst_QTextBoundaryFinder::toNextBoundary_data() +{ + QTest::addColumn<QString>("text"); + QTest::addColumn<int>("type"); + QTest::addColumn< QList<int> >("boundaries"); + + QList<int> boundaries; + boundaries << 0 << 3 << 4 << 7 << 8 << 11 << 12 << 13 << 16 << 17 << 20 << 21 << 24 << 25; + QTest::newRow("Line") << QString("Aaa bbb ccc. Ddd eee fff.") << int(QTextBoundaryFinder::Word) \ + << boundaries; + + boundaries.clear(); + boundaries << 0 << 13 << 25; + QTest::newRow("Line") << QString("Aaa bbb ccc. Ddd eee fff.") << int(QTextBoundaryFinder::Sentence) \ + << boundaries; + + boundaries.clear(); + boundaries << 0 << 4 << 8 << 13 << 17 << 21 << 25; + QTest::newRow("Line") << QString("Aaa bbb ccc. Ddd eee fff.") << int(QTextBoundaryFinder::Line) \ + << boundaries; + + boundaries.clear(); + boundaries << 0 << 5 << 9 << 15 << 17 << 21 << 28; + QTest::newRow("Line") << QString::fromUtf8("Diga-nos qualé a sua opinião") << int(QTextBoundaryFinder::Line) + << boundaries; + +} + +void tst_QTextBoundaryFinder::toNextBoundary() +{ + QFETCH(QString, text); + QFETCH(int, type); + QFETCH(QList<int>, boundaries); + + QList<int> foundBoundaries; + QTextBoundaryFinder boundaryFinder(QTextBoundaryFinder::BoundaryType(type), text); + boundaryFinder.toStart(); + for(int next = 0; next != -1; next = boundaryFinder.toNextBoundary()) + foundBoundaries << next; + QCOMPARE(boundaries, foundBoundaries); +} + +void tst_QTextBoundaryFinder::toPreviousBoundary_data() +{ + QTest::addColumn<QString>("text"); + QTest::addColumn<int>("type"); + QTest::addColumn< QList<int> >("boundaries"); + + QList<int> boundaries; + boundaries << 25 << 24 << 21 << 20 << 17 << 16 << 13 << 12 << 11 << 8 << 7 << 4 << 3 << 0; + QTest::newRow("Line") << QString("Aaa bbb ccc. Ddd eee fff.") << int(QTextBoundaryFinder::Word) + << boundaries; + + boundaries.clear(); + boundaries << 25 << 13 << 0; + QTest::newRow("Line") << QString("Aaa bbb ccc. Ddd eee fff.") << int(QTextBoundaryFinder::Sentence) + << boundaries; + + boundaries.clear(); + boundaries << 25 << 21 << 17 << 13 << 8 << 4 << 0; + QTest::newRow("Line") << QString("Aaa bbb ccc. Ddd eee fff.") << int(QTextBoundaryFinder::Line) + << boundaries; + + boundaries.clear(); + boundaries << 28 << 21 << 17 << 15 << 9 << 5 << 0; + QTest::newRow("Line") << QString::fromUtf8("Diga-nos qualé a sua opinião") << int(QTextBoundaryFinder::Line) + << boundaries; + +} + +void tst_QTextBoundaryFinder::toPreviousBoundary() +{ + QFETCH(QString, text); + QFETCH(int, type); + QFETCH(QList<int>, boundaries); + + QList<int> foundBoundaries; + QTextBoundaryFinder boundaryFinder(QTextBoundaryFinder::BoundaryType(type), text); + boundaryFinder.toEnd(); + for (int previous = boundaryFinder.position(); + previous != -1; + previous = boundaryFinder.toPreviousBoundary()) + { + foundBoundaries << previous; + } + QCOMPARE(boundaries, foundBoundaries); +} + + + + QTEST_MAIN(tst_QTextBoundaryFinder) #include "tst_qtextboundaryfinder.moc" |