From 6f52892206b155451e7b24cdbb1b4ab6569153e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 20 Oct 2009 15:39:06 +0200 Subject: Get file position when attaching an open file descriptor to QFile This was already being done when attaching to FILE* streams. Doing the same here makes the API consistent and more usable. Namely, one can use QFile::pos() to obtain the file position. Test case verifies this doesn't break support for sequential files. More thorough test case included in large file support test. Reviewed-by: Thiago Macieira --- tests/auto/qfile/tst_qfile.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index 19fbecd239..bbb62805b0 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -187,6 +187,8 @@ private slots: void mapOpenMode_data(); void mapOpenMode(); + void openStandardStreams(); + // --- Task related tests below this line void task167217(); @@ -2634,5 +2636,58 @@ void tst_QFile::openDirectory() QVERIFY(!f1.open(QIODevice::ReadOnly|QIODevice::Unbuffered)); } +void tst_QFile::openStandardStreams() +{ + // Using file descriptors + { + QFile in; + in.open(STDIN_FILENO, QIODevice::ReadOnly); + QCOMPARE( in.pos(), (qint64)0 ); + QCOMPARE( in.size(), (qint64)0 ); + QVERIFY( in.isSequential() ); + } + + { + QFile out; + out.open(STDOUT_FILENO, QIODevice::WriteOnly); + QCOMPARE( out.pos(), (qint64)0 ); + QCOMPARE( out.size(), (qint64)0 ); + QVERIFY( out.isSequential() ); + } + + { + QFile err; + err.open(STDERR_FILENO, QIODevice::WriteOnly); + QCOMPARE( err.pos(), (qint64)0 ); + QCOMPARE( err.size(), (qint64)0 ); + QVERIFY( err.isSequential() ); + } + + // Using streams + { + QFile in; + in.open(stdin, QIODevice::ReadOnly); + QCOMPARE( in.pos(), (qint64)0 ); + QCOMPARE( in.size(), (qint64)0 ); + QVERIFY( in.isSequential() ); + } + + { + QFile out; + out.open(stdout, QIODevice::WriteOnly); + QCOMPARE( out.pos(), (qint64)0 ); + QCOMPARE( out.size(), (qint64)0 ); + QVERIFY( out.isSequential() ); + } + + { + QFile err; + err.open(stderr, QIODevice::WriteOnly); + QCOMPARE( err.pos(), (qint64)0 ); + QCOMPARE( err.size(), (qint64)0 ); + QVERIFY( err.isSequential() ); + } +} + QTEST_MAIN(tst_QFile) #include "tst_qfile.moc" -- cgit v1.2.3 From c6651f91b8f31d94ef37aa41cc2fd76d97e990e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 20 Oct 2009 16:28:22 +0200 Subject: Adding a test case for large file support The test case creates a (tentatively sparse) very large file with scattered data and uses it to test various aspects of large file support in QFile. Reviewed-by: Thiago Macieira --- tests/auto/qfile/largefile/largefile.pro | 4 + tests/auto/qfile/largefile/tst_largefile.cpp | 492 +++++++++++++++++++++++++++ tests/auto/qfile/qfile.pro | 2 +- 3 files changed, 497 insertions(+), 1 deletion(-) create mode 100644 tests/auto/qfile/largefile/largefile.pro create mode 100644 tests/auto/qfile/largefile/tst_largefile.cpp (limited to 'tests/auto') diff --git a/tests/auto/qfile/largefile/largefile.pro b/tests/auto/qfile/largefile/largefile.pro new file mode 100644 index 0000000000..0f968659a1 --- /dev/null +++ b/tests/auto/qfile/largefile/largefile.pro @@ -0,0 +1,4 @@ +load(qttest_p4) + +QT = core +SOURCES += tst_largefile.cpp diff --git a/tests/auto/qfile/largefile/tst_largefile.cpp b/tests/auto/qfile/largefile/tst_largefile.cpp new file mode 100644 index 0000000000..398ca3f34d --- /dev/null +++ b/tests/auto/qfile/largefile/tst_largefile.cpp @@ -0,0 +1,492 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include + +#include +#include + +#ifdef Q_OS_WIN + +#include +#include + +#ifndef FSCTL_SET_SPARSE +// MinGW doesn't define this. +#define FSCTL_SET_SPARSE (0x900C4) +#endif + +#endif // Q_OS_WIN + +class tst_LargeFile + : public QObject +{ + Q_OBJECT + +public: + tst_LargeFile() + : blockSize(1 << 12) + , maxSizeBits() + , largeFile("qt_largefile.tmp") + , fd_(-1) + , stream_(0) + { + #if defined(QT_LARGEFILE_SUPPORT) && !defined(Q_OS_MAC) + maxSizeBits = 36; // 64 GiB + #elif defined(Q_OS_MAC) + // HFS+ does not support sparse files, so we limit file size for the test + // on Mac OS. + maxSizeBits = 32; // 4 GiB + #else + maxSizeBits = 24; // 16 MiB + #endif + } + +private: + void sparseFileData(); + QByteArray const &getDataBlock(int index, qint64 position); + +private slots: + // The LargeFile test case was designed to be run in order as a single unit + + void initTestCase(); + void cleanupTestCase(); + + void init(); + void cleanup(); + + // Create and fill large file + void createSparseFile(); + void fillFileSparsely(); + void closeSparseFile(); + + // Verify file was created + void fileCreated(); + + // Positioning in large files + void filePositioning(); + void fdPositioning(); + void streamPositioning(); + + // Read data from file + void openFileForReading(); + void readFile(); + + // Map/unmap large file + void mapFile(); + void mapOffsetOverflow(); + + void closeFile() { largeFile.close(); } + + // Test data + void fillFileSparsely_data() { sparseFileData(); } + void filePositioning_data() { sparseFileData(); } + void fdPositioning_data() { sparseFileData(); } + void streamPositioning_data() { sparseFileData(); } + void readFile_data() { sparseFileData(); } + void mapFile_data() { sparseFileData(); } + +private: + const int blockSize; + int maxSizeBits; + + QFile largeFile; + + QVector generatedBlocks; + + int fd_; + FILE *stream_; +}; + +/* + Convenience function to hide reinterpret_cast when copying a POD directly + into a QByteArray. + */ +template +static inline void appendRaw(QByteArray &array, T data) +{ + array.append(reinterpret_cast(&data), sizeof(T)); +} + +/* + Pad array with filler up to size. On return, array.size() returns size. + */ +static inline void topUpWith(QByteArray &array, QByteArray filler, int size) +{ + Q_ASSERT(filler.size() > 0); + + for (int i = (size - array.size()) / filler.size(); i > 0; --i) + array.append(filler); + + if (array.size() < size) { + Q_ASSERT(size - array.size() < filler.size()); + array.append(filler.left(size - array.size())); + } +} + +/* + Generate a unique data block containing identifiable data. Unaligned, + overlapping and partial blocks should not compare equal. + */ +static inline QByteArray generateDataBlock(int blockSize, QString text, qint64 userBits = -1) +{ + QByteArray block; + block.reserve(blockSize); + + // Use of counter and randomBits means content of block will be dependent + // on the generation order. For (file-)systems that do not support sparse + // files, these can be removed so the test file can be reused and doesn't + // have to be generated for every run. + + static qint64 counter = 0; + + qint64 randomBits = ((qint64)qrand() << 32) + | ((qint64)qrand() & 0x00000000ffffffff); + + appendRaw(block, randomBits); + appendRaw(block, userBits); + appendRaw(block, counter); + appendRaw(block, (qint32)0xdeadbeef); + appendRaw(block, blockSize); + + QByteArray userContent = text.toUtf8(); + appendRaw(block, userContent.size()); + block.append(userContent); + appendRaw(block, (qint64)0); + + // size, so far + appendRaw(block, block.size()); + + QByteArray filler("0123456789"); + block.append(filler.right(10 - block.size() % 10)); + topUpWith(block, filler, blockSize - 2 * sizeof(qint64)); + + appendRaw(block, counter); + appendRaw(block, userBits); + appendRaw(block, randomBits); + + Q_ASSERT( block.size() >= blockSize ); + block.resize(blockSize); + + ++counter; + return block; +} + +/* + Generates data blocks the first time they are requested. Keeps copies for reuse. + */ +QByteArray const &tst_LargeFile::getDataBlock(int index, qint64 position) +{ + if (index >= generatedBlocks.size()) + generatedBlocks.resize(index + 1); + + if (generatedBlocks[index].isNull()) { + QString text = QString("Current %1-byte block (index = %2) " + "starts %3 bytes into the file '%4'.") + .arg(blockSize) + .arg(index) + .arg(position) + .arg(largeFile.fileName()); + + generatedBlocks[index] = generateDataBlock(blockSize, text, (qint64)1 << index); + } + + return generatedBlocks[index]; +} + +void tst_LargeFile::initTestCase() +{ + QVERIFY( !largeFile.exists() || largeFile.remove() ); +} + +void tst_LargeFile::cleanupTestCase() +{ + largeFile.close(); + QVERIFY( !largeFile.exists() || largeFile.remove() ); +} + +void tst_LargeFile::init() +{ + fd_ = -1; + stream_ = 0; +} + +void tst_LargeFile::cleanup() +{ + if (-1 != fd_) + QT_CLOSE(fd_); + if (stream_) + ::fclose(stream_); +} + +void tst_LargeFile::sparseFileData() +{ + QTest::addColumn("index"); + QTest::addColumn("position"); + QTest::addColumn("block"); + + QTest::newRow(QString("block[%1] @%2)") + .arg(0).arg(0) + .toLocal8Bit().constData()) + << 0 << (qint64)0 << getDataBlock(0, 0); + + // While on Linux sparse files scale well, on Windows, testing at every + // power of 2 leads to very large files. i += 4 gives us a good coverage + // without taxing too much on resources. + for (int index = 12; index <= maxSizeBits; index += 4) { + qint64 position = (qint64)1 << index; + QByteArray block = getDataBlock(index, position); + + QTest::newRow( + QString("block[%1] @%2)") + .arg(index).arg(position) + .toLocal8Bit().constData()) + << index << position << block; + } +} + +void tst_LargeFile::createSparseFile() +{ +#if defined(Q_OS_WIN) + // 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(largeFile.fileName().toLocal8Bit().constData(), + GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0); + QVERIFY( INVALID_HANDLE_VALUE != handle ); + + DWORD bytes; + if (!::DeviceIoControl(handle, FSCTL_SET_SPARSE, NULL, 0, NULL, 0, + &bytes, NULL)) { + QWARN("Unable to set test file as sparse. " + "Limiting test file to 16MiB."); + maxSizeBits = 24; + } + + int fd = ::_open_osfhandle((intptr_t)handle, 0); + QVERIFY( -1 != fd ); + QVERIFY( largeFile.open(fd, QIODevice::WriteOnly) ); +#else // !Q_OS_WIN + QVERIFY( largeFile.open(QIODevice::WriteOnly) ); +#endif +} + +void tst_LargeFile::closeSparseFile() +{ +#if defined(Q_OS_WIN) + int fd = largeFile.handle(); +#endif + + largeFile.close(); + +#if defined(Q_OS_WIN) + if (-1 != fd) + ::_close(fd); +#endif +} + +void tst_LargeFile::fillFileSparsely() +{ + QFETCH( qint64, position ); + QFETCH( QByteArray, block ); + QCOMPARE( block.size(), blockSize ); + + QVERIFY( largeFile.seek(position) ); + QCOMPARE( largeFile.pos(), position ); + + QCOMPARE( largeFile.write(block), (qint64)blockSize ); + QCOMPARE( largeFile.pos(), position + blockSize ); + QVERIFY( largeFile.flush() ); +} + +void tst_LargeFile::fileCreated() +{ + QFileInfo info(largeFile); + + QVERIFY( info.exists() ); + QVERIFY( info.isFile() ); + QVERIFY( info.size() >= ((qint64)1 << maxSizeBits) + blockSize ); +} + +void tst_LargeFile::filePositioning() +{ + QFETCH( qint64, position ); + + QFile file(largeFile.fileName()); + QVERIFY( file.open(QIODevice::ReadOnly) ); + + QVERIFY( file.seek(position) ); + QCOMPARE( file.pos(), position ); +} + +void tst_LargeFile::fdPositioning() +{ + QFETCH( qint64, position ); + + fd_ = QT_OPEN(largeFile.fileName().toLocal8Bit().constData(), + QT_OPEN_RDONLY | QT_OPEN_LARGEFILE); + QVERIFY( -1 != fd_ ); + + QFile file; + QVERIFY( file.open(fd_, QIODevice::ReadOnly) ); + QCOMPARE( file.pos(), (qint64)0 ); + QVERIFY( file.seek(position) ); + QCOMPARE( file.pos(), position ); + + file.close(); + + QCOMPARE( QT_LSEEK(fd_, QT_OFF_T(0), SEEK_SET), QT_OFF_T(0) ); + QCOMPARE( QT_LSEEK(fd_, QT_OFF_T(position), SEEK_SET), QT_OFF_T(position) ); + + QVERIFY( file.open(fd_, QIODevice::ReadOnly) ); + QCOMPARE( QT_LSEEK(fd_, QT_OFF_T(0), SEEK_CUR), QT_OFF_T(position) ); + QCOMPARE( file.pos(), position ); + QVERIFY( file.seek(0) ); + QCOMPARE( file.pos(), (qint64)0 ); + + file.close(); + + QVERIFY( !QT_CLOSE(fd_) ); + fd_ = -1; +} + +void tst_LargeFile::streamPositioning() +{ + QFETCH( qint64, position ); + + stream_ = QT_FOPEN(largeFile.fileName().toLocal8Bit().constData(), "rb"); + QVERIFY( 0 != stream_ ); + + QFile file; + QVERIFY( file.open(stream_, QIODevice::ReadOnly) ); + QCOMPARE( file.pos(), (qint64)0 ); + QVERIFY( file.seek(position) ); + QCOMPARE( file.pos(), position ); + + file.close(); + + QVERIFY( !QT_FSEEK(stream_, QT_OFF_T(0), SEEK_SET) ); + QCOMPARE( QT_FTELL(stream_), QT_OFF_T(0) ); + QVERIFY( !QT_FSEEK(stream_, QT_OFF_T(position), SEEK_SET) ); + QCOMPARE( QT_FTELL(stream_), QT_OFF_T(position) ); + + QVERIFY( file.open(stream_, QIODevice::ReadOnly) ); + QCOMPARE( QT_FTELL(stream_), QT_OFF_T(position) ); + QCOMPARE( file.pos(), position ); + QVERIFY( file.seek(0) ); + QCOMPARE( file.pos(), (qint64)0 ); + + file.close(); + + QVERIFY( !::fclose(stream_) ); + stream_ = 0; +} + +void tst_LargeFile::openFileForReading() +{ + QVERIFY( largeFile.open(QIODevice::ReadOnly) ); +} + +void tst_LargeFile::readFile() +{ + QFETCH( qint64, position ); + QFETCH( QByteArray, block ); + QCOMPARE( block.size(), blockSize ); + + QVERIFY( largeFile.size() >= position + blockSize ); + + QVERIFY( largeFile.seek(position) ); + QCOMPARE( largeFile.pos(), position ); + + QCOMPARE( largeFile.read(blockSize), block ); + QCOMPARE( largeFile.pos(), position + blockSize ); +} + +void tst_LargeFile::mapFile() +{ + QFETCH( qint64, position ); + QFETCH( QByteArray, block ); + QCOMPARE( block.size(), blockSize ); + + // Keep full block mapped to facilitate OS and/or internal reuse by Qt. + uchar *baseAddress = largeFile.map(position, blockSize); + QVERIFY( baseAddress ); + QVERIFY( qEqual(block.begin(), block.end(), reinterpret_cast(baseAddress)) ); + + for (int offset = 1; offset < blockSize; ++offset) { + uchar *address = largeFile.map(position + offset, blockSize - offset); + + QVERIFY( address ); + if ( !qEqual(block.begin() + offset, block.end(), reinterpret_cast(address)) ) { + qDebug() << "Expected:" << block.toHex(); + qDebug() << "Actual :" << QByteArray(reinterpret_cast(address), blockSize).toHex(); + QVERIFY(false); + } + + QVERIFY( largeFile.unmap( address ) ); + } + + QVERIFY( largeFile.unmap( baseAddress ) ); +} + +void tst_LargeFile::mapOffsetOverflow() +{ + // Out-of-range mappings should fail, and not silently clip the offset + for (int i = 50; i < 63; ++i) { + uchar *address = 0; + + address = largeFile.map(((qint64)1 << i), blockSize); + QVERIFY( !address ); + + address = largeFile.map(((qint64)1 << i) + blockSize, blockSize); + QVERIFY( !address ); + } +} + +QTEST_APPLESS_MAIN(tst_LargeFile) +#include "tst_largefile.moc" + diff --git a/tests/auto/qfile/qfile.pro b/tests/auto/qfile/qfile.pro index eebfcdafe9..f70f75025b 100644 --- a/tests/auto/qfile/qfile.pro +++ b/tests/auto/qfile/qfile.pro @@ -5,5 +5,5 @@ wince*:{ SUBDIRS = test stdinprocess } - +SUBDIRS += largefile -- cgit v1.2.3 From d0fa7d4b30fa34fe2a684c331213528c193da85f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 22 Oct 2009 20:18:21 +0200 Subject: Windows doesn't #define STD{IN,OUT,ERR}_FILENO Reviewed-by: Markus Goetz --- tests/auto/qfile/tst_qfile.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index bbb62805b0..4971762631 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -79,6 +79,18 @@ # define SRCDIR "" #endif +#ifndef STDIN_FILENO +#define STDIN_FILENO 0 +#endif + +#ifndef STDOUT_FILENO +#define STDOUT_FILENO 1 +#endif + +#ifndef STDERR_FILENO +#define STDERR_FILENO 2 +#endif + Q_DECLARE_METATYPE(QFile::FileError) //TESTED_CLASS= -- cgit v1.2.3 From b402b8c4216ebb2d7db1e7e6cd33a45d1af422e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 23 Oct 2009 11:48:51 +0200 Subject: Fix the LargeFile test for Windows The test assumed fileName was stable, but it is documented behaviour that this can be reset when a file descriptor or FILE* stream is associated with a QFile. This was the case on Windows. --- tests/auto/qfile/largefile/tst_largefile.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qfile/largefile/tst_largefile.cpp b/tests/auto/qfile/largefile/tst_largefile.cpp index 398ca3f34d..d2bbffe082 100644 --- a/tests/auto/qfile/largefile/tst_largefile.cpp +++ b/tests/auto/qfile/largefile/tst_largefile.cpp @@ -72,7 +72,6 @@ public: tst_LargeFile() : blockSize(1 << 12) , maxSizeBits() - , largeFile("qt_largefile.tmp") , fd_(-1) , stream_(0) { @@ -231,7 +230,7 @@ QByteArray const &tst_LargeFile::getDataBlock(int index, qint64 position) .arg(blockSize) .arg(index) .arg(position) - .arg(largeFile.fileName()); + .arg("qt_largefile.tmp"); generatedBlocks[index] = generateDataBlock(blockSize, text, (qint64)1 << index); } @@ -241,13 +240,17 @@ QByteArray const &tst_LargeFile::getDataBlock(int index, qint64 position) void tst_LargeFile::initTestCase() { - QVERIFY( !largeFile.exists() || largeFile.remove() ); + QFile file("qt_largefile.tmp"); + QVERIFY( !file.exists() || file.remove() ); } void tst_LargeFile::cleanupTestCase() { - largeFile.close(); - QVERIFY( !largeFile.exists() || largeFile.remove() ); + if (largeFile.isOpen()) + largeFile.close(); + + QFile file("qt_largefile.tmp"); + QVERIFY( !file.exists() || file.remove() ); } void tst_LargeFile::init() @@ -295,7 +298,7 @@ void tst_LargeFile::createSparseFile() #if defined(Q_OS_WIN) // 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(largeFile.fileName().toLocal8Bit().constData(), + HANDLE handle = ::CreateFileA("qt_largefile.tmp", GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0); QVERIFY( INVALID_HANDLE_VALUE != handle ); @@ -311,6 +314,7 @@ void tst_LargeFile::createSparseFile() QVERIFY( -1 != fd ); QVERIFY( largeFile.open(fd, QIODevice::WriteOnly) ); #else // !Q_OS_WIN + largeFile.setFileName("qt_largefile.tmp"); QVERIFY( largeFile.open(QIODevice::WriteOnly) ); #endif } @@ -345,7 +349,7 @@ void tst_LargeFile::fillFileSparsely() void tst_LargeFile::fileCreated() { - QFileInfo info(largeFile); + QFileInfo info("qt_largefile.tmp"); QVERIFY( info.exists() ); QVERIFY( info.isFile() ); @@ -356,7 +360,7 @@ void tst_LargeFile::filePositioning() { QFETCH( qint64, position ); - QFile file(largeFile.fileName()); + QFile file("qt_largefile.tmp"); QVERIFY( file.open(QIODevice::ReadOnly) ); QVERIFY( file.seek(position) ); @@ -367,7 +371,7 @@ void tst_LargeFile::fdPositioning() { QFETCH( qint64, position ); - fd_ = QT_OPEN(largeFile.fileName().toLocal8Bit().constData(), + fd_ = QT_OPEN("qt_largefile.tmp", QT_OPEN_RDONLY | QT_OPEN_LARGEFILE); QVERIFY( -1 != fd_ ); @@ -398,7 +402,7 @@ void tst_LargeFile::streamPositioning() { QFETCH( qint64, position ); - stream_ = QT_FOPEN(largeFile.fileName().toLocal8Bit().constData(), "rb"); + stream_ = QT_FOPEN("qt_largefile.tmp", "rb"); QVERIFY( 0 != stream_ ); QFile file; @@ -428,6 +432,7 @@ void tst_LargeFile::streamPositioning() void tst_LargeFile::openFileForReading() { + largeFile.setFileName("qt_largefile.tmp"); QVERIFY( largeFile.open(QIODevice::ReadOnly) ); } -- cgit v1.2.3 From 45a09e31ebb25d3ad4f63ae02f0a0b464577761e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 23 Oct 2009 15:02:05 +0200 Subject: Extending QFile::size test to cover files opened with fd and FILE* Also changed tested type from int to qint64, so we'll be able to see clipping issues, although there are no large files in this test, yet. Reviewed-by: Markus Goetz --- tests/auto/qfile/tst_qfile.cpp | 51 +++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 8 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index 4971762631..55cc286848 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -117,6 +117,7 @@ private slots: void openUnbuffered(); void size_data(); void size(); + void sizeNoExist(); void seek(); void setSize(); void setSizeSeek(); @@ -452,23 +453,57 @@ void tst_QFile::openUnbuffered() void tst_QFile::size_data() { QTest::addColumn("filename"); - QTest::addColumn("size"); + QTest::addColumn("size"); - QTest::newRow( "exist01" ) << QString(SRCDIR "testfile.txt") << 245; - QTest::newRow( "nonexist01" ) << QString("foo.txt") << 0; + QTest::newRow( "exist01" ) << QString(SRCDIR "testfile.txt") << (qint64)245; #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) // Only test UNC on Windows./ - QTest::newRow("unc") << "//" + QString(QtNetworkSettings::winServerName() + "/testsharewritable/test.pri") << 34; + QTest::newRow("unc") << "//" + QString(QtNetworkSettings::winServerName() + "/testsharewritable/test.pri") << (qint64)34; #endif } void tst_QFile::size() { QFETCH( QString, filename ); - QFile f( filename ); - QTEST( (int)f.size(), "size" ); - if (f.open(QFile::ReadOnly)) - QTEST( (int)f.size(), "size" ); + QFETCH( qint64, size ); + + { + QFile f( filename ); + QCOMPARE( f.size(), size ); + + QVERIFY( f.open(QIODevice::ReadOnly) ); + QCOMPARE( f.size(), size ); + } + + { + QFile f; + int fd = QT_OPEN(filename.toLocal8Bit().constData(), QT_OPEN_RDONLY); + QVERIFY( fd != -1 ); + QVERIFY( f.open(fd, QIODevice::ReadOnly) ); + QCOMPARE( f.size(), size ); + + f.close(); + QT_CLOSE(fd); + } + + { + QFile f; + FILE* stream = QT_FOPEN(filename.toLocal8Bit().constData(), "rb"); + QVERIFY( stream ); + QVERIFY( f.open(stream, QIODevice::ReadOnly) ); + QCOMPARE( f.size(), size ); + + f.close(); + fclose(stream); + } +} + +void tst_QFile::sizeNoExist() +{ + QFile file("nonexist01"); + QVERIFY( !file.exists() ); + QCOMPARE( file.size(), (qint64)0 ); + QVERIFY( !file.open(QIODevice::ReadOnly) ); } void tst_QFile::seek() -- cgit v1.2.3 From 4204fdcc04e20eabd19704f2235ba06afa84605e Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 29 Oct 2009 17:32:57 +0100 Subject: Avoid infinite loop when laying out text with unconvertible chars When the stringToCMap() fails, it can be because it did not have enough space in the layout, or it can because of other errors. In order to implement "try-again" processing in a simple way, we had an infinite loop which assumed that stringToCMap() would always succeed in the second run (which would be the case if the only possible error was "not enough space".) Since there are other possible failures not related to the number of glyphs, you could easily get into an infinite loop here, e.g. when laying out text that contains the Byte Order Mark. The fix changes the implementation to explictly try stringToCMap() twice at max, and is also how it's implemented in the default qtextengine.cpp. Task-number: QTBUG-4680 Reviewed-by: Trond Conflicts: src/gui/text/qtextengine_mac.cpp tests/auto/qtextlayout/tst_qtextlayout.cpp --- tests/auto/qtextlayout/tst_qtextlayout.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp index a5fed4e27f..b02a70455c 100644 --- a/tests/auto/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp @@ -119,6 +119,7 @@ private slots: void smallTextLengthWordWrap(); void smallTextLengthWrapAtWordBoundaryOrAnywhere(); void testLineBreakingAllSpaces(); + void lineWidthFromBOM(); private: @@ -1277,5 +1278,18 @@ void tst_QTextLayout::widthOfTabs() QCOMPARE(qRound(engine.width(0, 5)), qRound(engine.boundingBox(0, 5).width)); } +void tst_QTextLayout::lineWidthFromBOM() +{ + const QString string(QChar(0xfeff)); // BYTE ORDER MARK + QTextLayout layout(string); + layout.beginLayout(); + QTextLine line = layout.createLine(); + line.setLineWidth(INT_MAX / 256); + layout.endLayout(); + + // Don't spin into an infinite loop + } + + QTEST_MAIN(tst_QTextLayout) #include "tst_qtextlayout.moc" -- cgit v1.2.3 From 764d195bfa252775702bffc93989a35d0c19f035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 29 Oct 2009 15:32:03 +0100 Subject: Turns out 64-bit fseek/ftell are not available on VS 2003/2002... Not when linking dynamically to the CRT (/MT). So we can't rely on them. The declarations for those are also not on the standard headers. Reverts "(MSVC 2002/2003) Use 64-bit versions of ftell and fseek", fixes return type of QT_FTELL and skips known failures on large-file test case. --- tests/auto/qfile/largefile/tst_largefile.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qfile/largefile/tst_largefile.cpp b/tests/auto/qfile/largefile/tst_largefile.cpp index d2bbffe082..53dbc127a8 100644 --- a/tests/auto/qfile/largefile/tst_largefile.cpp +++ b/tests/auto/qfile/largefile/tst_largefile.cpp @@ -402,6 +402,11 @@ void tst_LargeFile::streamPositioning() { QFETCH( qint64, position ); +#if defined(QT_LARGEFILE_SUPPORT) && defined(Q_CC_MSVC) && _MSC_VER < 1400 + if (position >= (qint64)1 << 31) + QSKIP("MSVC 2003 doesn't have 64 bit versions of fseek/ftell.", SkipSingle); +#endif + stream_ = QT_FOPEN("qt_largefile.tmp", "rb"); QVERIFY( 0 != stream_ ); -- cgit v1.2.3 From be651bb65e952743f4bc31a970750be501bcf978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Mon, 2 Nov 2009 11:31:01 +0100 Subject: Enable the RightToLeft (mirrored) test for basic layout tests. --- tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp index 1c7a159e34..1a19162dc9 100644 --- a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp +++ b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp @@ -1715,8 +1715,6 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout() QCOMPARE(widgets[item.index]->geometry(), item.rect); } - // ###: not supported yet -/* // Test mirrored mode widget->setLayoutDirection(Qt::RightToLeft); layout->activate(); @@ -1731,7 +1729,7 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout() QCOMPARE(widgets[item.index]->geometry(), mirroredRect); delete widgets[item.index]; } -*/ + delete widget; } -- cgit v1.2.3 From 83b5ae49a1778a815a98dd7094822588e82aef3c Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Mon, 2 Nov 2009 11:51:53 +0100 Subject: QNetworkReply autotests: move performance tests to benchmarks Move the performance tests from tests/auto/qnetworkreply to tests/benchmarks/qnetworkreply, because they belong there and they were crashing from time to time. Reviewed-by: Markus Goetz --- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 479 ------------------------- 1 file changed, 479 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 7adb67f115..0b61dcd6f6 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -227,12 +227,6 @@ private Q_SLOTS: void rateControl_data(); void rateControl(); - void downloadPerformance(); - void uploadPerformance(); - void performanceControlRate(); - void httpUploadPerformance(); - void httpDownloadPerformance_data(); - void httpDownloadPerformance(); void downloadProgress_data(); void downloadProgress(); @@ -413,93 +407,6 @@ public slots: } }; -class FixedSizeDataGenerator : public QIODevice -{ - Q_OBJECT - enum { Idle, Started, Stopped } state; -public: - FixedSizeDataGenerator(qint64 size) : state(Idle) - { open(ReadOnly | Unbuffered); - toBeGeneratedTotalCount = toBeGeneratedCount = size; - } - - virtual qint64 bytesAvailable() const - { - return state == Started ? toBeGeneratedCount + QIODevice::bytesAvailable() : 0; - } - - virtual bool isSequential() const{ - return false; - } - - virtual bool reset() const{ - return false; - } - - qint64 size() const { - return toBeGeneratedTotalCount; - } - -public slots: - void start() { state = Started; emit readyRead(); } - -protected: - virtual qint64 readData(char *data, qint64 maxlen) - { - memset(data, '@', maxlen); - - if (toBeGeneratedCount <= 0) { - return -1; - } - - qint64 n = qMin(maxlen, toBeGeneratedCount); - toBeGeneratedCount -= n; - - if (toBeGeneratedCount <= 0) { - // make sure this is a queued connection! - emit readChannelFinished(); - } - - return n; - } - virtual qint64 writeData(const char *, qint64) - { return -1; } - - qint64 toBeGeneratedCount; - qint64 toBeGeneratedTotalCount; -}; - - -class DataGenerator: public QIODevice -{ - Q_OBJECT - enum { Idle, Started, Stopped } state; -public: - DataGenerator() : state(Idle) - { open(ReadOnly); } - - virtual bool isSequential() const { return true; } - virtual qint64 bytesAvailable() const { return state == Started ? 1024*1024 : 0; } - -public slots: - void start() { state = Started; emit readyRead(); } - void stop() { state = Stopped; emit readyRead(); } - -protected: - virtual qint64 readData(char *data, qint64 maxlen) - { - if (state == Stopped) - return -1; // EOF - - // return as many bytes as are wanted - memset(data, '@', maxlen); - return maxlen; - } - virtual qint64 writeData(const char *, qint64) - { return -1; } -}; - - class SocketPair: public QObject { @@ -692,255 +599,6 @@ protected: } }; -class TimedSender: public QThread -{ - Q_OBJECT - qint64 totalBytes; - QSemaphore ready; - QByteArray dataToSend; - QTcpSocket *client; - int timeout; - int port; -public: - int transferRate; - TimedSender(int ms) - : totalBytes(0), timeout(ms), port(-1), transferRate(-1) - { - dataToSend = QByteArray(16*1024, '@'); - start(); - ready.acquire(); - } - - inline int serverPort() const { return port; } - -private slots: - void writeMore() - { - while (client->bytesToWrite() < 128 * 1024) { - writePacket(dataToSend); - } - } - -protected: - void run() - { - QTcpServer server; - server.listen(); - port = server.serverPort(); - ready.release(); - - server.waitForNewConnection(-1); - client = server.nextPendingConnection(); - - writeMore(); - connect(client, SIGNAL(bytesWritten(qint64)), SLOT(writeMore()), Qt::DirectConnection); - - QEventLoop eventLoop; - QTimer::singleShot(timeout, &eventLoop, SLOT(quit())); - - QTime timer; - timer.start(); - eventLoop.exec(); - disconnect(client, SIGNAL(bytesWritten(qint64)), this, 0); - - // wait for the connection to shut down - client->disconnectFromHost(); - if (!client->waitForDisconnected(10000)) - return; - - transferRate = totalBytes * 1000 / timer.elapsed(); - qDebug() << "TimedSender::run" << "receive rate:" << (transferRate / 1024) << "kB/s in" - << timer.elapsed() << "ms"; - } - - void writePacket(const QByteArray &array) - { - client->write(array); - totalBytes += array.size(); - } -}; - -class ThreadedDataReader: public QThread -{ - Q_OBJECT - // used to make the constructor only return after the tcp server started listening - QSemaphore ready; - QTcpSocket *client; - int timeout; - int port; -public: - qint64 transferRate; - ThreadedDataReader() - : port(-1), transferRate(-1) - { - start(); - ready.acquire(); - } - - inline int serverPort() const { return port; } - -protected: - void run() - { - QTcpServer server; - server.listen(); - port = server.serverPort(); - ready.release(); - - server.waitForNewConnection(-1); - client = server.nextPendingConnection(); - - QEventLoop eventLoop; - DataReader reader(client, false); - QObject::connect(client, SIGNAL(disconnected()), &eventLoop, SLOT(quit())); - - QTime timer; - timer.start(); - eventLoop.exec(); - qint64 elapsed = timer.elapsed(); - - transferRate = reader.totalBytes * 1000 / elapsed; - qDebug() << "ThreadedDataReader::run" << "send rate:" << (transferRate / 1024) << "kB/s in" << elapsed << "msec"; - } -}; - -class ThreadedDataReaderHttpServer: public QThread -{ - Q_OBJECT - // used to make the constructor only return after the tcp server started listening - QSemaphore ready; - QTcpSocket *client; - int timeout; - int port; -public: - qint64 transferRate; - ThreadedDataReaderHttpServer() - : port(-1), transferRate(-1) - { - start(); - ready.acquire(); - } - - inline int serverPort() const { return port; } - -protected: - void run() - { - QTcpServer server; - server.listen(); - port = server.serverPort(); - ready.release(); - - server.waitForNewConnection(-1); - client = server.nextPendingConnection(); - client->write("HTTP/1.0 200 OK\r\n"); - client->write("Content-length: 0\r\n"); - client->write("\r\n"); - client->flush(); - - QCoreApplication::processEvents(); - - QEventLoop eventLoop; - DataReader reader(client, false); - QObject::connect(client, SIGNAL(disconnected()), &eventLoop, SLOT(quit())); - - QTime timer; - timer.start(); - eventLoop.exec(); - qint64 elapsed = timer.elapsed(); - - transferRate = reader.totalBytes * 1000 / elapsed; - qDebug() << "ThreadedDataReaderHttpServer::run" << "send rate:" << (transferRate / 1024) << "kB/s in" << elapsed << "msec"; - } -}; - -class HttpDownloadPerformanceClient : QObject { - Q_OBJECT; - QIODevice *device; - public: - HttpDownloadPerformanceClient (QIODevice *dev) : device(dev){ - connect(dev, SIGNAL(readyRead()), this, SLOT(readyReadSlot())); - } - - public slots: - void readyReadSlot() { - device->readAll(); - } - -}; - -class HttpDownloadPerformanceServer : QObject { - Q_OBJECT; - qint64 dataSize; - qint64 dataSent; - QTcpServer server; - QTcpSocket *client; - bool serverSendsContentLength; - bool chunkedEncoding; - -public: - HttpDownloadPerformanceServer (qint64 ds, bool sscl, bool ce) : dataSize(ds), dataSent(0), - client(0), serverSendsContentLength(sscl), chunkedEncoding(ce) { - server.listen(); - connect(&server, SIGNAL(newConnection()), this, SLOT(newConnectionSlot())); - } - - int serverPort() { - return server.serverPort(); - } - -public slots: - - void newConnectionSlot() { - client = server.nextPendingConnection(); - client->setParent(this); - connect(client, SIGNAL(readyRead()), this, SLOT(readyReadSlot())); - connect(client, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWrittenSlot(qint64))); - } - - void readyReadSlot() { - client->readAll(); - client->write("HTTP/1.0 200 OK\n"); - if (serverSendsContentLength) - client->write(QString("Content-Length: " + QString::number(dataSize) + "\n").toAscii()); - if (chunkedEncoding) - client->write(QString("Transfer-Encoding: chunked\n").toAscii()); - client->write("Connection: close\n\n"); - } - - void bytesWrittenSlot(qint64 amount) { - Q_UNUSED(amount); - if (dataSent == dataSize && client) { - // close eventually - - // chunked encoding: we have to send a last "empty" chunk - if (chunkedEncoding) - client->write(QString("0\r\n\r\n").toAscii()); - - client->disconnectFromHost(); - server.close(); - client = 0; - return; - } - - // send data - if (client && client->bytesToWrite() < 100*1024 && dataSent < dataSize) { - qint64 amount = qMin(qint64(16*1024), dataSize - dataSent); - QByteArray data(amount, '@'); - - if (chunkedEncoding) { - client->write(QString(QString("%1").arg(amount,0,16).toUpper() + "\r\n").toAscii()); - client->write(data.constData(), amount); - client->write(QString("\r\n").toAscii()); - } else { - client->write(data.constData(), amount); - } - - dataSent += amount; - } - } -}; - tst_QNetworkReply::tst_QNetworkReply() { @@ -3311,7 +2969,6 @@ void tst_QNetworkReply::ioPostToHttpEmtpyUploadProgress() server.close(); } - void tst_QNetworkReply::rateControl_data() { QTest::addColumn("rate"); @@ -3365,142 +3022,6 @@ void tst_QNetworkReply::rateControl() QVERIFY(sender.transferRate <= maxRate); } -void tst_QNetworkReply::downloadPerformance() -{ - // unlike the above function, this one tries to send as fast as possible - // and measures how fast it was. - TimedSender sender(5000); - QNetworkRequest request("debugpipe://127.0.0.1:" + QString::number(sender.serverPort()) + "/?bare=1"); - QNetworkReplyPtr reply = manager.get(request); - DataReader reader(reply, false); - - QTime loopTime; - connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); - loopTime.start(); - QTestEventLoop::instance().enterLoop(40); - int elapsedTime = loopTime.elapsed(); - sender.wait(); - - qint64 receivedBytes = reader.totalBytes; - qDebug() << "tst_QNetworkReply::downloadPerformance" << "receive rate:" << (receivedBytes * 1000 / elapsedTime / 1024) << "kB/s and" - << elapsedTime << "ms"; -} - -void tst_QNetworkReply::uploadPerformance() -{ - ThreadedDataReader reader; - DataGenerator generator; - - - QNetworkRequest request("debugpipe://127.0.0.1:" + QString::number(reader.serverPort()) + "/?bare=1"); - QNetworkReplyPtr reply = manager.put(request, &generator); - generator.start(); - connect(&reader, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); - QTimer::singleShot(5000, &generator, SLOT(stop())); - - QTestEventLoop::instance().enterLoop(30); - QCOMPARE(reply->error(), QNetworkReply::NoError); - QVERIFY(!QTestEventLoop::instance().timeout()); -} - -void tst_QNetworkReply::httpUploadPerformance() -{ -#ifdef Q_OS_SYMBIAN - // SHow some mercy for non-desktop platform/s - enum {UploadSize = 4*1024*1024}; // 4 MB -#else - enum {UploadSize = 128*1024*1024}; // 128 MB -#endif - ThreadedDataReaderHttpServer reader; - FixedSizeDataGenerator generator(UploadSize); - - QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(reader.serverPort()) + "/?bare=1")); - request.setHeader(QNetworkRequest::ContentLengthHeader,UploadSize); - - QNetworkReplyPtr reply = manager.put(request, &generator); - - connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); - - QTime time; - generator.start(); - time.start(); - QTestEventLoop::instance().enterLoop(40); - QCOMPARE(reply->error(), QNetworkReply::NoError); - QVERIFY(!QTestEventLoop::instance().timeout()); - - qint64 elapsed = time.elapsed(); - qDebug() << "tst_QNetworkReply::httpUploadPerformance" << elapsed << "msec, " - << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec"; - - reader.exit(); - reader.wait(); -} - - -void tst_QNetworkReply::performanceControlRate() -{ - // this is a control comparison for the other two above - // it does the same thing, but instead bypasses the QNetworkAccess system - qDebug() << "The following are the maximum transfer rates that we can get in this system" - " (bypassing QNetworkAccess)"; - - TimedSender sender(5000); - QTcpSocket sink; - sink.connectToHost("127.0.0.1", sender.serverPort()); - DataReader reader(&sink, false); - - QTime loopTime; - connect(&sink, SIGNAL(disconnected()), &QTestEventLoop::instance(), SLOT(exitLoop())); - loopTime.start(); - QTestEventLoop::instance().enterLoop(40); - int elapsedTime = loopTime.elapsed(); - sender.wait(); - - qint64 receivedBytes = reader.totalBytes; - qDebug() << "tst_QNetworkReply::performanceControlRate" << "receive rate:" << (receivedBytes * 1000 / elapsedTime / 1024) << "kB/s and" - << elapsedTime << "ms"; -} - -void tst_QNetworkReply::httpDownloadPerformance_data() -{ - QTest::addColumn("serverSendsContentLength"); - QTest::addColumn("chunkedEncoding"); - - QTest::newRow("Server sends no Content-Length") << false << false; - QTest::newRow("Server sends Content-Length") << true << false; - QTest::newRow("Server uses chunked encoding") << false << true; - -} - -void tst_QNetworkReply::httpDownloadPerformance() -{ - QFETCH(bool, serverSendsContentLength); - QFETCH(bool, chunkedEncoding); -#ifdef Q_OS_SYMBIAN - // Show some mercy to non-desktop platform/s - enum {UploadSize = 4*1024*1024}; // 4 MB -#else - enum {UploadSize = 128*1024*1024}; // 128 MB -#endif - HttpDownloadPerformanceServer server(UploadSize, serverSendsContentLength, chunkedEncoding); - - QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(server.serverPort()) + "/?bare=1")); - QNetworkReplyPtr reply = manager.get(request); - - connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); - HttpDownloadPerformanceClient client(reply); - - QTime time; - time.start(); - QTestEventLoop::instance().enterLoop(40); - QCOMPARE(reply->error(), QNetworkReply::NoError); - QVERIFY(!QTestEventLoop::instance().timeout()); - - qint64 elapsed = time.elapsed(); - qDebug() << "tst_QNetworkReply::httpDownloadPerformance" << elapsed << "msec, " - << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec"; -} - void tst_QNetworkReply::downloadProgress_data() { QTest::addColumn("loopCount"); -- cgit v1.2.3 From e6da35f6055d3ae7acf38d89456d3047f055a9cd Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 2 Nov 2009 14:07:15 +0100 Subject: QStyleSheetStyle: ItemViews: Fixes drawing of items and branches. I am not sure why the code was there, but after some testing, it is better to remove it: - While painting the branch, we should not look at the ::item pseudo class at all. - Items specific stuff is drawn in PE_PanelItemViewItem, not PE_PanelItemViewRow - Selection is handled his way by the native style. background-color is not for selection and should not depends on SH_ItemView_ShowDecorationSelected Reviewed-by: Thierry Task-number: QTBUG-5228 Task-number: 258382 Task-number: QTBUG-4338 --- .../uiloader/baseline/css_itemview_task258382.ui | 179 +++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 tests/auto/uiloader/baseline/css_itemview_task258382.ui (limited to 'tests/auto') diff --git a/tests/auto/uiloader/baseline/css_itemview_task258382.ui b/tests/auto/uiloader/baseline/css_itemview_task258382.ui new file mode 100644 index 0000000000..11c56b4ba2 --- /dev/null +++ b/tests/auto/uiloader/baseline/css_itemview_task258382.ui @@ -0,0 +1,179 @@ + + + Form + + + + 0 + 0 + 437 + 352 + + + + Form + + + ::item { border: 1px solid black; background-color: purple; } +::item {margin-left: 20px; } + +QAbstractItemView { selection-background-color: red; +show-decoration- selected: 0; + } + +::item:selected { background-color: yellow; } + + + + + + + 1 + + + + + New Column + + + + + New Item + + + + + New Item + + + + + New Item + + + + New Subitem + + + + New Subitem + + + + + New Item + + + + + New Item + + + + + + + + + + + New Row + + + + + New Row + + + + + New Row + + + + + New Row + + + + + New Row + + + + + New Column + + + + + New Column + + + + + New Column + + + + + New Column + + + + + mljkh mh mjl + + + + + h jlh mjklh + + + + + mjklh mlhj mjlh m + + + + + mlhj lmhj + + + + + mlkj l + + + + + mlkj + + + + + mlkj lmkj + + + + + mlkhj mlh + + + + + mlkj lmkj + + + + + mlkj lmkj + + + + + + + + + -- cgit v1.2.3 From 8d01f436451071a917c147a96a979ccdaee106f9 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 2 Nov 2009 14:49:33 +0100 Subject: QCSSParser: Fixes the way spaces are handled in font family. We cannot simplify spaces because a font may have several spaces in its name. If we only add spaces when needed when merging tokens, we don't need to simplyfy the string later The CSS tokenizer will already make sure that spaces are removed if there is no quotes (btw, the CSS specification says that there must be quotes if there is spaces, but we tollerate if there is no quotes) Reviewed-by: Jocelyn Turcotte Task-number: QTBUG-4344 Task-number: 258586 --- tests/auto/qcssparser/tst_qcssparser.cpp | 3 +++ tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qcssparser/tst_qcssparser.cpp b/tests/auto/qcssparser/tst_qcssparser.cpp index 150f131f02..3580252c7f 100644 --- a/tests/auto/qcssparser/tst_qcssparser.cpp +++ b/tests/auto/qcssparser/tst_qcssparser.cpp @@ -1556,8 +1556,11 @@ void tst_QCssParser::extractFontFamily_data() QTest::newRow("shorthand") << "font: 12pt Times New Roman" << QString("Times New Roman"); QTest::newRow("shorthand multiple quote") << "font: 12pt invalid, \"Times New Roman\" " << QString("Times New Roman"); QTest::newRow("shorthand multiple") << "font: 12pt invalid, Times New Roman " << QString("Times New Roman"); + QTest::newRow("invalid spaces") << "font-family: invalid spaces, Times New Roman " << QString("Times New Roman"); + QTest::newRow("invalid spaces quotes") << "font-family: 'invalid spaces', 'Times New Roman' " << QString("Times New Roman"); } + void tst_QCssParser::extractFontFamily() { QFETCH(QString, css); diff --git a/tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp index 8c4d8fdabd..4dc732cd60 100644 --- a/tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp +++ b/tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp @@ -2197,6 +2197,16 @@ void tst_QTextDocumentFragment::html_quotedFontFamily() setHtml("
Test
"); QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar")); + + setHtml("
Test
"); + QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar")); + + setHtml("
Test
"); + QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar")); + + setHtml("
Test
"); + QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar,serif,bar foo")); + } void tst_QTextDocumentFragment::defaultFont() -- cgit v1.2.3 From 8abe466caa1b38f4cc1f95fba83d5e61e611e931 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 2 Nov 2009 15:45:49 +0100 Subject: Make the combobox emit activated when it loses focus Task-number: QTBUG-1071 Reviewed-by: ogoffart --- tests/auto/qcombobox/tst_qcombobox.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index 51a7ff8142..06c632de6f 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -57,6 +57,7 @@ #include #include #include +#include #ifdef Q_WS_MAC #include #elif defined Q_WS_X11 @@ -154,6 +155,7 @@ private slots: void removeItem(); void resetModel(); void keyBoardNavigationWithMouse(); + void task_QTBUG_1071_changingFocusEmitsActivated(); protected slots: void onEditTextChanged( const QString &newString ); @@ -813,21 +815,25 @@ void tst_QComboBox::autoCompletionCaseSensitivity() // case insensitive testWidget->clearEditText(); + QSignalSpy spyReturn(testWidget, SIGNAL(activated(int))); testWidget->setAutoCompletionCaseSensitivity(Qt::CaseInsensitive); QVERIFY(testWidget->autoCompletionCaseSensitivity() == Qt::CaseInsensitive); QTest::keyClick(testWidget->lineEdit(), Qt::Key_A); qApp->processEvents(); QCOMPARE(testWidget->currentText(), QString("aww")); + QCOMPARE(spyReturn.count(), 0); QTest::keyClick(testWidget->lineEdit(), Qt::Key_B); qApp->processEvents(); // autocompletions preserve userkey-case from 4.2 QCOMPARE(testWidget->currentText(), QString("abCDEF")); + QCOMPARE(spyReturn.count(), 0); QTest::keyClick(testWidget->lineEdit(), Qt::Key_Enter); qApp->processEvents(); QCOMPARE(testWidget->currentText(), QString("aBCDEF")); // case restored to item's case + QCOMPARE(spyReturn.count(), 1); testWidget->clearEditText(); QTest::keyClick(testWidget->lineEdit(), 'c'); @@ -2500,6 +2506,31 @@ void tst_QComboBox::keyBoardNavigationWithMouse() QTRY_COMPARE(combo.currentText(), QString::number(final)); } +void tst_QComboBox::task_QTBUG_1071_changingFocusEmitsActivated() +{ + QWidget w; + QVBoxLayout layout(&w); + QComboBox cb; + cb.setEditable(true); + QSignalSpy spy(&cb, SIGNAL(activated(int))); + cb.addItem("0"); + cb.addItem("1"); + cb.addItem("2"); + QLineEdit edit; + layout.add(&cb); + layout.add(&edit); + + w.show(); + QTest::qWaitForWindowShown(&w); + cb.clearEditText(); + cb.setFocus(); + QApplication::processEvents(); + QTest::keyClick(0, '1'); + QCOMPARE(spy.count(), 0); + edit.setFocus(); + QTRY_VERIFY(edit.hasFocus()); + QCOMPARE(spy.count(), 1); +} QTEST_MAIN(tst_QComboBox) #include "tst_qcombobox.moc" -- cgit v1.2.3 From 11dea4a8b227801c110f791f350632bf6f0c958d Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 2 Nov 2009 15:25:19 +0100 Subject: Fixed spacing display in QListView with wrapped text. The spacing was not being substracted from the viewport width when calculating the available space for items. Auto-test included. Reviewed-by: Olivier Task-number: QTBUG-2678 --- tests/auto/qlistview/tst_qlistview.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index a5ff153b7c..246f09232a 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -121,6 +121,7 @@ private slots: void taskQTBUG_2233_scrollHiddenItems(); void taskQTBUG_633_changeModelData(); void taskQTBUG_435_deselectOnViewportClick(); + void taskQTBUG_2678_spacingAndWrappedText(); }; // Testing get/set functions @@ -1876,5 +1877,19 @@ void tst_QListView::taskQTBUG_435_deselectOnViewportClick() QVERIFY(!view.selectionModel()->hasSelection()); } +void tst_QListView::taskQTBUG_2678_spacingAndWrappedText() +{ + static const QString lorem("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."); + QStringListModel model(QStringList() << lorem << lorem << "foo" << lorem << "bar" << lorem << lorem); + QListView w; + w.setModel(&model); + w.setViewMode(QListView::ListMode); + w.setWordWrap(true); + w.setSpacing(10); + w.show(); + QTest::qWaitForWindowShown(&w); + QCOMPARE(w.horizontalScrollBar()->minimum(), w.horizontalScrollBar()->maximum()); +} + QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" -- cgit v1.2.3 From e7a10b00be3e4aa197900ecf424e6d44b07248ae Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 20 Oct 2009 18:03:10 +0300 Subject: Fixed QGraphicsScene::clear() not to crash if related top level items happen to delete each others. Merge-Request: 1863 Reviewed-by: Andreas Reviewed-by: Olivier --- tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index 0589994841..4f76dddf74 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -1453,6 +1453,13 @@ void tst_QGraphicsScene::focusItemLostFocus() item->clearFocus(); } +class ClearTestItem : public QGraphicsRectItem +{ +public: + ~ClearTestItem() { qDeleteAll(items); } + QList items; +}; + void tst_QGraphicsScene::clear() { QGraphicsScene scene; @@ -1463,6 +1470,19 @@ void tst_QGraphicsScene::clear() scene.clear(); QVERIFY(scene.items().isEmpty()); QCOMPARE(scene.sceneRect(), QRectF(0, 0, 100, 100)); + + ClearTestItem *firstItem = new ClearTestItem; + QGraphicsItem *secondItem = new QGraphicsRectItem; + firstItem->items += secondItem; + + scene.setItemIndexMethod(QGraphicsScene::NoIndex); + scene.addItem(firstItem); + scene.addItem(secondItem); + QCOMPARE(scene.items().at(0), firstItem); + QCOMPARE(scene.items().at(1), secondItem); + // must not crash even if firstItem deletes secondItem + scene.clear(); + QVERIFY(scene.items().isEmpty()); } void tst_QGraphicsScene::setFocusItem() -- cgit v1.2.3 From 553d7f7416eca57b63992a453ceb3b333749c11a Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 28 Oct 2009 16:15:06 +0200 Subject: Introduced QGraphicsItem::ItemSendsScenePositionChanges and QGraphicsItem::ItemScenePositionHasChanged Merge-Request: 1945 Reviewed-By: Andreas --- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 74 ++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 684ad4f890..1081fd5b7a 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -401,6 +401,7 @@ private slots: void modality_clickFocus(); void modality_keyEvents(); void itemIsInFront(); + void scenePosChange(); // task specific tests below me void task141694_textItemEnsureVisible(); @@ -4229,6 +4230,8 @@ protected: break; case QGraphicsItem::ItemOpacityHasChanged: break; + case QGraphicsItem::ItemScenePositionHasChanged: + break; } return itemChangeReturnValue.isValid() ? itemChangeReturnValue : value; } @@ -9691,5 +9694,76 @@ void tst_QGraphicsItem::itemIsInFront() QCOMPARE(qt_closestItemFirst(rect1child1_2, rect2child1), false); } +class ScenePosChangeTester : public ItemChangeTester +{ +public: + ScenePosChangeTester() + { } + ScenePosChangeTester(QGraphicsItem *parent) : ItemChangeTester(parent) + { } +}; + +void tst_QGraphicsItem::scenePosChange() +{ + ScenePosChangeTester* root = new ScenePosChangeTester; + ScenePosChangeTester* child1 = new ScenePosChangeTester(root); + ScenePosChangeTester* grandChild1 = new ScenePosChangeTester(child1); + ScenePosChangeTester* child2 = new ScenePosChangeTester(root); + ScenePosChangeTester* grandChild2 = new ScenePosChangeTester(child2); + + child1->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true); + grandChild2->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true); + + QGraphicsScene scene; + scene.addItem(root); + + // ignore uninteresting changes + child1->clear(); + child2->clear(); + grandChild1->clear(); + grandChild2->clear(); + + // move whole tree + root->moveBy(1.0, 1.0); + QCOMPARE(child1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 1); + QCOMPARE(grandChild1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0); + QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0); + QCOMPARE(grandChild2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 1); + + // move subtree + child2->moveBy(1.0, 1.0); + QCOMPARE(child1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 1); + QCOMPARE(grandChild1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0); + QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0); + QCOMPARE(grandChild2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 2); + + // reparent + grandChild2->setParentItem(child1); + child1->moveBy(1.0, 1.0); + QCOMPARE(child1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 2); + QCOMPARE(grandChild1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0); + QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0); + QCOMPARE(grandChild2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 3); + + // change flags + grandChild1->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true); + grandChild2->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false); + QCoreApplication::processEvents(); // QGraphicsScenePrivate::_q_updateScenePosDescendants() + child1->moveBy(1.0, 1.0); + QCOMPARE(child1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 3); + QCOMPARE(grandChild1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 1); + QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0); + QCOMPARE(grandChild2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 3); + + // remove + scene.removeItem(grandChild1); + delete grandChild2; grandChild2 = 0; + QCoreApplication::processEvents(); // QGraphicsScenePrivate::_q_updateScenePosDescendants() + root->moveBy(1.0, 1.0); + QCOMPARE(child1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 4); + QCOMPARE(grandChild1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 1); + QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0); +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" -- cgit v1.2.3 From b22f7a8af0a781885a64d0cd1001192c99872aef Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Thu, 29 Oct 2009 17:55:06 +0100 Subject: QLocalSocket test: stabilize test by calling waitFor... function ... to make sure bytes are availabe to read Reviewed-by: Aleksandar Sasha Babic --- tests/auto/qlocalsocket/tst_qlocalsocket.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp index ab7b0ac144..5ead049215 100644 --- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp @@ -587,14 +587,16 @@ void tst_QLocalSocket::readBufferOverflow() char buffer[dataBufferSize]; memset(buffer, 0, dataBufferSize); serverSocket->write(buffer, dataBufferSize); - serverSocket->flush(); + serverSocket->waitForBytesWritten(); + // wait until the first 128 bytes are ready to read QVERIFY(client.waitForReadyRead()); QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize)); -#if defined(QT_LOCALSOCKET_TCP) || defined(Q_OS_SYMBIAN) - QTest::qWait(250); -#endif + // wait until the second 128 bytes are ready to read + QVERIFY(client.waitForReadyRead()); QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize)); + // no more bytes available + QVERIFY(client.bytesAvailable() == 0); } // QLocalSocket/Server can take a name or path, check that it works as expected -- cgit v1.2.3 From 9bd330756bc8e0fac9919da0b1068096ee91cb24 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 3 Nov 2009 15:09:09 +0100 Subject: Pressing return in a QWizard would erase the active password entry. When echo mode was set to PasswordEchoOnEdit in a QLineEdit, and its text selected, pressing the return key would erase the text and start editing it instead of validating the password. Auto-test included. Reviewed-by: Olivier Task-number: QTBUG-4401 --- tests/auto/qlineedit/tst_qlineedit.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp index c6769596f8..b4dfbbad47 100644 --- a/tests/auto/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/qlineedit/tst_qlineedit.cpp @@ -260,6 +260,7 @@ private slots: void task233101_cursorPosAfterInputMethod(); void task241436_passwordEchoOnEditRestoreEchoMode(); void task248948_redoRemovedSelection(); + void taskQTBUG_4401_enterKeyClearsPassword(); protected slots: #ifdef QT3_SUPPORT @@ -3532,5 +3533,20 @@ void tst_QLineEdit::task248948_redoRemovedSelection() QCOMPARE(testWidget->text(), QLatin1String("ab")); } +void tst_QLineEdit::taskQTBUG_4401_enterKeyClearsPassword() +{ + QString password("Wanna guess?"); + + testWidget->setText(password); + testWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit); + testWidget->setFocus(); + testWidget->selectAll(); + QApplication::setActiveWindow(testWidget); + QTRY_VERIFY(testWidget->hasFocus()); + + QTest::keyPress(testWidget, Qt::Key_Enter); + QTRY_COMPARE(testWidget->text(), password); +} + QTEST_MAIN(tst_QLineEdit) #include "tst_qlineedit.moc" -- cgit v1.2.3 From 950cd9b3c1ae6a1b462d596a62aea92f9c231afb Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 4 Nov 2009 09:43:55 +0100 Subject: Stabilize tests --- tests/auto/qlistview/tst_qlistview.cpp | 12 ++++++------ tests/auto/qtreeview/tst_qtreeview.cpp | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index 246f09232a..1c8fecf96b 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -1788,13 +1788,13 @@ void tst_QListView::task262152_setModelColumnNavigate() view.show(); QTest::qWaitForWindowShown(&view); - QTest::qWait(100); + QTest::qWait(120); QTest::keyClick(&view, Qt::Key_Down); - QTest::qWait(100); - QCOMPARE(view.currentIndex(), model.index(1,1)); + QTest::qWait(30); + QTRY_COMPARE(view.currentIndex(), model.index(1,1)); QTest::keyClick(&view, Qt::Key_Down); - QTest::qWait(100); - QCOMPARE(view.currentIndex(), model.index(2,1)); + QTest::qWait(30); + QTRY_COMPARE(view.currentIndex(), model.index(2,1)); } @@ -1862,7 +1862,7 @@ void tst_QListView::taskQTBUG_435_deselectOnViewportClick() view.setSelectionMode(QAbstractItemView::ExtendedSelection); view.selectAll(); QCOMPARE(view.selectionModel()->selectedIndexes().count(), model.rowCount()); - + QPoint p = view.visualRect(model.index(model.rowCount() - 1)).center() + QPoint(0, 20); //first the left button diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index 90e6c5ca83..58f059b7d8 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -3669,11 +3669,11 @@ void tst_QTreeView::doubleClickedWithSpans() //end the previous edition QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, p); - QTest::qWait(100); + QTest::qWait(150); QTest::mousePress(view.viewport(), Qt::LeftButton, 0, p); QTest::mouseDClick(view.viewport(), Qt::LeftButton, 0, p); QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, p); - QCOMPARE(spy.count(), 2); + QTRY_COMPARE(spy.count(), 2); } QTEST_MAIN(tst_QTreeView) -- cgit v1.2.3 From ff1bd9c821aa1e314d6ca738204cdd0ae60a8369 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 4 Nov 2009 14:04:40 +0100 Subject: Fix crash in QMenu when using QWidgetAction If the QWidgetAction is not the first in a menu, it crashed. This is because when the QEvent::ActionRemoved is sent, the event->before() is not set. We need to find another way to clean up the widgetItems list. This basically revert 4b6ab00e6d68c7 Reviewed-by: Thierry --- tests/auto/qwidgetaction/tst_qwidgetaction.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qwidgetaction/tst_qwidgetaction.cpp b/tests/auto/qwidgetaction/tst_qwidgetaction.cpp index 50b3337592..d25738fc38 100644 --- a/tests/auto/qwidgetaction/tst_qwidgetaction.cpp +++ b/tests/auto/qwidgetaction/tst_qwidgetaction.cpp @@ -395,7 +395,9 @@ void tst_QWidgetAction::releaseWidgetCrash() QMainWindow *w = new QMainWindow; QAction *a = new CrashedAction(w); QMenu *menu = w->menuBar()->addMenu("Test"); + menu->addAction("foo"); menu->addAction(a); + menu->addAction("bar"); delete w; } -- cgit v1.2.3 From 3ac785411d860e48e14f6b2542b666a6d508cff1 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 4 Nov 2009 15:40:28 +0100 Subject: Result API review with Jasmin QAbstractAnimation: currentTime returns the "complete" current time currentLoopTime() returns the time inside the current loop add setPaused(bool) for consistency with QTimeLine stateChanged: newState passed as first paramater (before oldState) for consistency with the reset of Qt QAnimationGroup: rename clearAnimations to clear rename insertAnimationAt to insertAnimation rename takeAnimationAt to takeAnimation QSequentialAnimationGroup: rename insertPauseAt to insertPause --- .../tst_qparallelanimationgroup.cpp | 136 +++--- .../qpropertyanimation/tst_qpropertyanimation.cpp | 20 +- .../tst_qsequentialanimationgroup.cpp | 506 ++++++++++----------- 3 files changed, 331 insertions(+), 331 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp index 8d937e9ab5..a26e0eb61f 100644 --- a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp +++ b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp @@ -119,8 +119,8 @@ class TestAnimation : public QVariantAnimation Q_OBJECT public: virtual void updateCurrentValue(const QVariant &value) { Q_UNUSED(value)}; - virtual void updateState(QAbstractAnimation::State oldState, - QAbstractAnimation::State newState) + virtual void updateState(QAbstractAnimation::State newState, + QAbstractAnimation::State oldState) { Q_UNUSED(oldState) Q_UNUSED(newState) @@ -135,8 +135,8 @@ public: TestAnimation2(int duration, QAbstractAnimation *animation) : QVariantAnimation(animation), m_duration(duration) {} virtual void updateCurrentValue(const QVariant &value) { Q_UNUSED(value)}; - virtual void updateState(QAbstractAnimation::State oldState, - QAbstractAnimation::State newState) + virtual void updateState(QAbstractAnimation::State newState, + QAbstractAnimation::State oldState) { Q_UNUSED(oldState) Q_UNUSED(newState) @@ -223,33 +223,33 @@ void tst_QParallelAnimationGroup::setCurrentTime() QCOMPARE(notTimeDriven->state(), QAnimationGroup::Stopped); QCOMPARE(loopsForever->state(), QAnimationGroup::Stopped); - QCOMPARE(group.currentTime(), 1); - QCOMPARE(a1_p_o1->currentTime(), 1); - QCOMPARE(a1_p_o2->currentTime(), 1); - QCOMPARE(a1_p_o3->currentTime(), 1); - QCOMPARE(notTimeDriven->currentTime(), 1); - QCOMPARE(loopsForever->currentTime(), 1); + QCOMPARE(group.currentLoopTime(), 1); + QCOMPARE(a1_p_o1->currentLoopTime(), 1); + QCOMPARE(a1_p_o2->currentLoopTime(), 1); + QCOMPARE(a1_p_o3->currentLoopTime(), 1); + QCOMPARE(notTimeDriven->currentLoopTime(), 1); + QCOMPARE(loopsForever->currentLoopTime(), 1); // Current time = 250 group.setCurrentTime(250); - QCOMPARE(group.currentTime(), 250); - QCOMPARE(a1_p_o1->currentTime(), 250); - QCOMPARE(a1_p_o2->currentTime(), 0); + QCOMPARE(group.currentLoopTime(), 250); + QCOMPARE(a1_p_o1->currentLoopTime(), 250); + QCOMPARE(a1_p_o2->currentLoopTime(), 0); QCOMPARE(a1_p_o2->currentLoop(), 1); - QCOMPARE(a1_p_o3->currentTime(), 250); - QCOMPARE(notTimeDriven->currentTime(), 250); - QCOMPARE(loopsForever->currentTime(), 0); + QCOMPARE(a1_p_o3->currentLoopTime(), 250); + QCOMPARE(notTimeDriven->currentLoopTime(), 250); + QCOMPARE(loopsForever->currentLoopTime(), 0); QCOMPARE(loopsForever->currentLoop(), 1); // Current time = 251 group.setCurrentTime(251); - QCOMPARE(group.currentTime(), 251); - QCOMPARE(a1_p_o1->currentTime(), 250); - QCOMPARE(a1_p_o2->currentTime(), 1); + QCOMPARE(group.currentLoopTime(), 251); + QCOMPARE(a1_p_o1->currentLoopTime(), 250); + QCOMPARE(a1_p_o2->currentLoopTime(), 1); QCOMPARE(a1_p_o2->currentLoop(), 1); - QCOMPARE(a1_p_o3->currentTime(), 250); - QCOMPARE(notTimeDriven->currentTime(), 251); - QCOMPARE(loopsForever->currentTime(), 1); + QCOMPARE(a1_p_o3->currentLoopTime(), 250); + QCOMPARE(notTimeDriven->currentLoopTime(), 251); + QCOMPARE(loopsForever->currentLoopTime(), 1); } void tst_QParallelAnimationGroup::stateChanged() @@ -278,18 +278,18 @@ void tst_QParallelAnimationGroup::stateChanged() group.start(); //all the animations should be started QCOMPARE(spy1.count(), 1); - QCOMPARE(qVariantValue(spy1.last().at(1)), TestAnimation::Running); + QCOMPARE(qVariantValue(spy1.last().first()), TestAnimation::Running); QCOMPARE(spy2.count(), 1); - QCOMPARE(qVariantValue(spy2.last().at(1)), TestAnimation::Running); + QCOMPARE(qVariantValue(spy2.last().first()), TestAnimation::Running); QCOMPARE(spy3.count(), 1); - QCOMPARE(qVariantValue(spy3.last().at(1)), TestAnimation::Running); + QCOMPARE(qVariantValue(spy3.last().first()), TestAnimation::Running); QCOMPARE(spy4.count(), 1); - QCOMPARE(qVariantValue(spy4.last().at(1)), TestAnimation::Running); + QCOMPARE(qVariantValue(spy4.last().first()), TestAnimation::Running); group.setCurrentTime(1500); //anim1 should be finished QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(spy1.count(), 2); - QCOMPARE(qVariantValue(spy1.last().at(1)), TestAnimation::Stopped); + QCOMPARE(qVariantValue(spy1.last().first()), TestAnimation::Stopped); QCOMPARE(spy2.count(), 1); //no change QCOMPARE(spy3.count(), 1); //no change QCOMPARE(spy4.count(), 1); //no change @@ -298,7 +298,7 @@ void tst_QParallelAnimationGroup::stateChanged() QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(spy1.count(), 2); //no change QCOMPARE(spy2.count(), 2); - QCOMPARE(qVariantValue(spy2.last().at(1)), TestAnimation::Stopped); + QCOMPARE(qVariantValue(spy2.last().first()), TestAnimation::Stopped); QCOMPARE(spy3.count(), 1); //no change QCOMPARE(spy4.count(), 1); //no change @@ -307,9 +307,9 @@ void tst_QParallelAnimationGroup::stateChanged() QCOMPARE(spy1.count(), 2); //no change QCOMPARE(spy2.count(), 2); //no change QCOMPARE(spy3.count(), 2); - QCOMPARE(qVariantValue(spy3.last().at(1)), TestAnimation::Stopped); + QCOMPARE(qVariantValue(spy3.last().first()), TestAnimation::Stopped); QCOMPARE(spy4.count(), 2); - QCOMPARE(qVariantValue(spy4.last().at(1)), TestAnimation::Stopped); + QCOMPARE(qVariantValue(spy4.last().first()), TestAnimation::Stopped); //cleanup spy1.clear(); @@ -326,22 +326,22 @@ void tst_QParallelAnimationGroup::stateChanged() QCOMPARE(spy1.count(), 0); QCOMPARE(spy2.count(), 0); QCOMPARE(spy3.count(), 1); - QCOMPARE(qVariantValue(spy3.last().at(1)), TestAnimation::Running); + QCOMPARE(qVariantValue(spy3.last().first()), TestAnimation::Running); QCOMPARE(spy4.count(), 1); - QCOMPARE(qVariantValue(spy4.last().at(1)), TestAnimation::Running); + QCOMPARE(qVariantValue(spy4.last().first()), TestAnimation::Running); group.setCurrentTime(1500); //anim2 should be started QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(spy1.count(), 0); //no change QCOMPARE(spy2.count(), 1); - QCOMPARE(qVariantValue(spy2.last().at(1)), TestAnimation::Running); + QCOMPARE(qVariantValue(spy2.last().first()), TestAnimation::Running); QCOMPARE(spy3.count(), 1); //no change QCOMPARE(spy4.count(), 1); //no change group.setCurrentTime(500); //anim1 is finally also started QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(spy1.count(), 1); - QCOMPARE(qVariantValue(spy1.last().at(1)), TestAnimation::Running); + QCOMPARE(qVariantValue(spy1.last().first()), TestAnimation::Running); QCOMPARE(spy2.count(), 1); //no change QCOMPARE(spy3.count(), 1); //no change QCOMPARE(spy4.count(), 1); //no change @@ -349,13 +349,13 @@ void tst_QParallelAnimationGroup::stateChanged() group.setCurrentTime(0); //everything should be stopped QCOMPARE(group.state(), QAnimationGroup::Stopped); QCOMPARE(spy1.count(), 2); - QCOMPARE(qVariantValue(spy1.last().at(1)), TestAnimation::Stopped); + QCOMPARE(qVariantValue(spy1.last().first()), TestAnimation::Stopped); QCOMPARE(spy2.count(), 2); - QCOMPARE(qVariantValue(spy2.last().at(1)), TestAnimation::Stopped); + QCOMPARE(qVariantValue(spy2.last().first()), TestAnimation::Stopped); QCOMPARE(spy3.count(), 2); - QCOMPARE(qVariantValue(spy3.last().at(1)), TestAnimation::Stopped); + QCOMPARE(qVariantValue(spy3.last().first()), TestAnimation::Stopped); QCOMPARE(spy4.count(), 2); - QCOMPARE(qVariantValue(spy4.last().at(1)), TestAnimation::Stopped); + QCOMPARE(qVariantValue(spy4.last().first()), TestAnimation::Stopped); } void tst_QParallelAnimationGroup::clearGroup() @@ -375,9 +375,9 @@ void tst_QParallelAnimationGroup::clearGroup() children[i] = group.animationAt(i); } - group.clearAnimations(); + group.clear(); QCOMPARE(group.animationCount(), 0); - QCOMPARE(group.currentTime(), 0); + QCOMPARE(group.currentLoopTime(), 0); for (int i = 0; i < animationCount; ++i) QVERIFY(children[i].isNull()); } @@ -460,9 +460,9 @@ void tst_QParallelAnimationGroup::updateChildrenWithRunningGroup() QCOMPARE(groupStateChangedSpy.count(), 1); QCOMPARE(childStateChangedSpy.count(), 1); - QCOMPARE(qVariantValue(groupStateChangedSpy.at(0).at(1)), + QCOMPARE(qVariantValue(groupStateChangedSpy.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(childStateChangedSpy.at(0).at(1)), + QCOMPARE(qVariantValue(childStateChangedSpy.at(0).first()), QAnimationGroup::Running); // starting directly a running child will not have any effect @@ -501,13 +501,13 @@ void tst_QParallelAnimationGroup::deleteChildrenWithRunningGroup() QCOMPARE(anim1->state(), QAnimationGroup::Running); QTest::qWait(80); - QVERIFY(group.currentTime() > 0); + QVERIFY(group.currentLoopTime() > 0); delete anim1; QVERIFY(group.animationCount() == 0); QCOMPARE(group.duration(), 0); QCOMPARE(group.state(), QAnimationGroup::Stopped); - QCOMPARE(group.currentTime(), 0); //that's the invariant + QCOMPARE(group.currentLoopTime(), 0); //that's the invariant } void tst_QParallelAnimationGroup::startChildrenWithStoppedGroup() @@ -622,11 +622,11 @@ void tst_QParallelAnimationGroup::startGroupWithRunningChild() anim2.start(); anim2.pause(); - QCOMPARE(qVariantValue(stateChangedSpy1.at(0).at(1)), + QCOMPARE(qVariantValue(stateChangedSpy1.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(stateChangedSpy2.at(0).at(1)), + QCOMPARE(qVariantValue(stateChangedSpy2.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(stateChangedSpy2.at(1).at(1)), + QCOMPARE(qVariantValue(stateChangedSpy2.at(1).first()), QAnimationGroup::Paused); QCOMPARE(group.state(), QAnimationGroup::Stopped); @@ -636,15 +636,15 @@ void tst_QParallelAnimationGroup::startGroupWithRunningChild() group.start(); QCOMPARE(stateChangedSpy1.count(), 3); - QCOMPARE(qVariantValue(stateChangedSpy1.at(1).at(1)), + QCOMPARE(qVariantValue(stateChangedSpy1.at(1).first()), QAnimationGroup::Stopped); - QCOMPARE(qVariantValue(stateChangedSpy1.at(2).at(1)), + QCOMPARE(qVariantValue(stateChangedSpy1.at(2).first()), QAnimationGroup::Running); QCOMPARE(stateChangedSpy2.count(), 4); - QCOMPARE(qVariantValue(stateChangedSpy2.at(2).at(1)), + QCOMPARE(qVariantValue(stateChangedSpy2.at(2).first()), QAnimationGroup::Stopped); - QCOMPARE(qVariantValue(stateChangedSpy2.at(3).at(1)), + QCOMPARE(qVariantValue(stateChangedSpy2.at(3).first()), QAnimationGroup::Running); QCOMPARE(group.state(), QAnimationGroup::Running); @@ -687,19 +687,19 @@ void tst_QParallelAnimationGroup::zeroDurationAnimation() group.start(); QCOMPARE(stateChangedSpy1.count(), 2); QCOMPARE(finishedSpy1.count(), 1); - QCOMPARE(qVariantValue(stateChangedSpy1.at(0).at(1)), + QCOMPARE(qVariantValue(stateChangedSpy1.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(stateChangedSpy1.at(1).at(1)), + QCOMPARE(qVariantValue(stateChangedSpy1.at(1).first()), QAnimationGroup::Stopped); QCOMPARE(stateChangedSpy2.count(), 1); QCOMPARE(finishedSpy2.count(), 0); - QCOMPARE(qVariantValue(stateChangedSpy1.at(0).at(1)), + QCOMPARE(qVariantValue(stateChangedSpy1.at(0).first()), QAnimationGroup::Running); QCOMPARE(stateChangedSpy3.count(), 1); QCOMPARE(finishedSpy3.count(), 0); - QCOMPARE(qVariantValue(stateChangedSpy3.at(0).at(1)), + QCOMPARE(qVariantValue(stateChangedSpy3.at(0).first()), QAnimationGroup::Running); @@ -762,9 +762,9 @@ void tst_QParallelAnimationGroup::stopUncontrolledAnimations() group.start(); QCOMPARE(stateChangedSpy.count(), 2); - QCOMPARE(qVariantValue(stateChangedSpy.at(0).at(1)), + QCOMPARE(qVariantValue(stateChangedSpy.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(stateChangedSpy.at(1).at(1)), + QCOMPARE(qVariantValue(stateChangedSpy.at(1).first()), QAnimationGroup::Stopped); QCOMPARE(group.state(), QAnimationGroup::Running); @@ -915,9 +915,9 @@ void tst_QParallelAnimationGroup::loopCount() group.setCurrentTime(currentGroupTime); - QCOMPARE(anim1.currentTime(), expected1.time); - QCOMPARE(anim2.currentTime(), expected2.time); - QCOMPARE(anim3.currentTime(), expected3.time); + QCOMPARE(anim1.currentLoopTime(), expected1.time); + QCOMPARE(anim2.currentLoopTime(), expected2.time); + QCOMPARE(anim3.currentLoopTime(), expected3.time); if (expected1.state >=0) QCOMPARE(int(anim1.state()), expected1.state); @@ -968,22 +968,22 @@ void tst_QParallelAnimationGroup::pauseResume() QCOMPARE(anim->state(), QAnimationGroup::Running); QCOMPARE(spy.count(), 1); spy.clear(); - const int currentTime = group.currentTime(); - QCOMPARE(anim->currentTime(), currentTime); + const int currentTime = group.currentLoopTime(); + QCOMPARE(anim->currentLoopTime(), currentTime); group.pause(); QCOMPARE(group.state(), QAnimationGroup::Paused); - QCOMPARE(group.currentTime(), currentTime); + QCOMPARE(group.currentLoopTime(), currentTime); QCOMPARE(anim->state(), QAnimationGroup::Paused); - QCOMPARE(anim->currentTime(), currentTime); + QCOMPARE(anim->currentLoopTime(), currentTime); QCOMPARE(spy.count(), 1); spy.clear(); group.resume(); QCOMPARE(group.state(), QAnimationGroup::Running); - QCOMPARE(group.currentTime(), currentTime); + QCOMPARE(group.currentLoopTime(), currentTime); QCOMPARE(anim->state(), QAnimationGroup::Running); - QCOMPARE(anim->currentTime(), currentTime); + QCOMPARE(anim->currentLoopTime(), currentTime); QCOMPARE(spy.count(), 1); group.stop(); @@ -991,10 +991,10 @@ void tst_QParallelAnimationGroup::pauseResume() new TestAnimation2(500, &group); group.start(); QCOMPARE(spy.count(), 1); //the animation should have been started - QCOMPARE(qVariantValue(spy.last().at(1)), TestAnimation::Running); + QCOMPARE(qVariantValue(spy.last().first()), TestAnimation::Running); group.setCurrentTime(250); //end of first animation QCOMPARE(spy.count(), 2); //the animation should have been stopped - QCOMPARE(qVariantValue(spy.last().at(1)), TestAnimation::Stopped); + QCOMPARE(qVariantValue(spy.last().first()), TestAnimation::Stopped); group.pause(); QCOMPARE(spy.count(), 2); //this shouldn't have changed group.resume(); diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp index 56c1ced81b..f41fff128a 100644 --- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp @@ -225,7 +225,7 @@ void tst_QPropertyAnimation::setCurrentTime() animation.setLoopCount(loopCount); animation.setCurrentTime(currentTime); - QCOMPARE(animation.currentTime(), testCurrentTime); + QCOMPARE(animation.currentLoopTime(), testCurrentTime); QCOMPARE(animation.currentLoop(), testCurrentLoop); } @@ -280,7 +280,7 @@ void tst_QPropertyAnimation::statesAndSignals() QCOMPARE(anim->state(), QAnimationGroup::Stopped); QCOMPARE(runningSpy.count(), 1); //anim must have stopped QCOMPARE(finishedSpy.count(), 0); - QCOMPARE(anim->currentTime(), 0); + QCOMPARE(anim->currentLoopTime(), 0); QCOMPARE(anim->currentLoop(), 0); QCOMPARE(currentLoopSpy.count(), 2); runningSpy.clear(); @@ -291,7 +291,7 @@ void tst_QPropertyAnimation::statesAndSignals() QCOMPARE(runningSpy.count(), 2); //started and stopped again runningSpy.clear(); QCOMPARE(finishedSpy.count(), 1); - QCOMPARE(anim->currentTime(), 100); + QCOMPARE(anim->currentLoopTime(), 100); QCOMPARE(anim->currentLoop(), 2); QCOMPARE(currentLoopSpy.count(), 4); @@ -312,7 +312,7 @@ void tst_QPropertyAnimation::statesAndSignals() QCOMPARE(anim->currentLoop(), 2); QCOMPARE(runningSpy.count(), 1); // anim has stopped QCOMPARE(finishedSpy.count(), 2); - QCOMPARE(anim->currentTime(), 100); + QCOMPARE(anim->currentLoopTime(), 100); delete anim; } @@ -864,16 +864,16 @@ void tst_QPropertyAnimation::zeroDurationStart() //let's check the first state change const QVariantList firstChange = spy.first(); //old state - QCOMPARE(qVariantValue(firstChange.first()), QAbstractAnimation::Stopped); + QCOMPARE(qVariantValue(firstChange.last()), QAbstractAnimation::Stopped); //new state - QCOMPARE(qVariantValue(firstChange.last()), QAbstractAnimation::Running); + QCOMPARE(qVariantValue(firstChange.first()), QAbstractAnimation::Running); //let's check the first state change const QVariantList secondChange = spy.last(); //old state - QCOMPARE(qVariantValue(secondChange.first()), QAbstractAnimation::Running); + QCOMPARE(qVariantValue(secondChange.last()), QAbstractAnimation::Running); //new state - QCOMPARE(qVariantValue(secondChange.last()), QAbstractAnimation::Stopped); + QCOMPARE(qVariantValue(secondChange.first()), QAbstractAnimation::Stopped); } #define Pause 1 @@ -1171,9 +1171,9 @@ public: innerAnim->start(); } - void updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState) + void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) { - QPropertyAnimation::updateState(oldState, newState); + QPropertyAnimation::updateState(newState, oldState); if (newState == QAbstractAnimation::Stopped) delete innerAnim; } diff --git a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp index f6afc5b7de..28fccac428 100644 --- a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp +++ b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp @@ -87,7 +87,7 @@ private slots: void currentAnimation(); void currentAnimationWithZeroDuration(); void insertAnimation(); - void clearAnimations(); + void clear(); void pauseResume(); }; @@ -134,8 +134,8 @@ class TestAnimation : public QVariantAnimation Q_OBJECT public: virtual void updateCurrentValue(const QVariant &value) { Q_UNUSED(value)}; - virtual void updateState(QAbstractAnimation::State oldState, - QAbstractAnimation::State newState) + virtual void updateState(QAbstractAnimation::State newState, + QAbstractAnimation::State oldState) { Q_UNUSED(oldState) Q_UNUSED(newState) @@ -208,119 +208,119 @@ void tst_QSequentialAnimationGroup::setCurrentTime() QCOMPARE(sequence2->state(), QAnimationGroup::Stopped); QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped); - QCOMPARE(group.currentTime(), 1); - QCOMPARE(sequence->currentTime(), 1); - QCOMPARE(a1_s_o1->currentTime(), 1); - QCOMPARE(a2_s_o1->currentTime(), 0); - QCOMPARE(a3_s_o1->currentTime(), 0); - QCOMPARE(a1_s_o2->currentTime(), 0); - QCOMPARE(a1_s_o3->currentTime(), 0); + QCOMPARE(group.currentLoopTime(), 1); + QCOMPARE(sequence->currentLoopTime(), 1); + QCOMPARE(a1_s_o1->currentLoopTime(), 1); + QCOMPARE(a2_s_o1->currentLoopTime(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 0); + QCOMPARE(a1_s_o2->currentLoopTime(), 0); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); // Current time = 250 group.setCurrentTime(250); - QCOMPARE(group.currentTime(), 250); - QCOMPARE(sequence->currentTime(), 250); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentTime(), 0); - QCOMPARE(a3_s_o1->currentTime(), 0); - QCOMPARE(a1_s_o2->currentTime(), 0); - QCOMPARE(a1_s_o3->currentTime(), 0); + QCOMPARE(group.currentLoopTime(), 250); + QCOMPARE(sequence->currentLoopTime(), 250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 0); + QCOMPARE(a1_s_o2->currentLoopTime(), 0); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); // Current time = 251 group.setCurrentTime(251); - QCOMPARE(group.currentTime(), 251); - QCOMPARE(sequence->currentTime(), 251); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentTime(), 1); + QCOMPARE(group.currentLoopTime(), 251); + QCOMPARE(sequence->currentLoopTime(), 251); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 1); QCOMPARE(a2_s_o1->currentLoop(), 0); - QCOMPARE(a3_s_o1->currentTime(), 0); - QCOMPARE(sequence2->currentTime(), 0); - QCOMPARE(a1_s_o2->currentTime(), 0); - QCOMPARE(a1_s_o3->currentTime(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 0); + QCOMPARE(sequence2->currentLoopTime(), 0); + QCOMPARE(a1_s_o2->currentLoopTime(), 0); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); // Current time = 750 group.setCurrentTime(750); - QCOMPARE(group.currentTime(), 750); - QCOMPARE(sequence->currentTime(), 750); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentTime(), 0); + QCOMPARE(group.currentLoopTime(), 750); + QCOMPARE(sequence->currentLoopTime(), 750); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 0); QCOMPARE(a2_s_o1->currentLoop(), 2); - QCOMPARE(a3_s_o1->currentTime(), 0); - QCOMPARE(sequence2->currentTime(), 0); - QCOMPARE(a1_s_o2->currentTime(), 0); - QCOMPARE(a1_s_o3->currentTime(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 0); + QCOMPARE(sequence2->currentLoopTime(), 0); + QCOMPARE(a1_s_o2->currentLoopTime(), 0); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); // Current time = 1000 group.setCurrentTime(1000); - QCOMPARE(group.currentTime(), 1000); - QCOMPARE(sequence->currentTime(), 1000); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentTime(), 250); + QCOMPARE(group.currentLoopTime(), 1000); + QCOMPARE(sequence->currentLoopTime(), 1000); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); QCOMPARE(a2_s_o1->currentLoop(), 2); - QCOMPARE(a3_s_o1->currentTime(), 0); - QCOMPARE(sequence2->currentTime(), 0); - QCOMPARE(a1_s_o2->currentTime(), 0); - QCOMPARE(a1_s_o3->currentTime(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 0); + QCOMPARE(sequence2->currentLoopTime(), 0); + QCOMPARE(a1_s_o2->currentLoopTime(), 0); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); // Current time = 1010 group.setCurrentTime(1010); - QCOMPARE(group.currentTime(), 1010); - QCOMPARE(sequence->currentTime(), 1010); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentTime(), 250); + QCOMPARE(group.currentLoopTime(), 1010); + QCOMPARE(sequence->currentLoopTime(), 1010); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); QCOMPARE(a2_s_o1->currentLoop(), 2); - QCOMPARE(a3_s_o1->currentTime(), 10); - QCOMPARE(sequence2->currentTime(), 0); - QCOMPARE(a1_s_o2->currentTime(), 0); - QCOMPARE(a1_s_o3->currentTime(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 10); + QCOMPARE(sequence2->currentLoopTime(), 0); + QCOMPARE(a1_s_o2->currentLoopTime(), 0); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); // Current time = 1250 group.setCurrentTime(1250); - QCOMPARE(group.currentTime(), 1250); - QCOMPARE(sequence->currentTime(), 1250); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentTime(), 250); + QCOMPARE(group.currentLoopTime(), 1250); + QCOMPARE(sequence->currentLoopTime(), 1250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); QCOMPARE(a2_s_o1->currentLoop(), 2); - QCOMPARE(a3_s_o1->currentTime(), 250); - QCOMPARE(sequence2->currentTime(), 0); - QCOMPARE(a1_s_o2->currentTime(), 0); - QCOMPARE(a1_s_o3->currentTime(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 250); + QCOMPARE(sequence2->currentLoopTime(), 0); + QCOMPARE(a1_s_o2->currentLoopTime(), 0); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); // Current time = 1500 group.setCurrentTime(1500); - QCOMPARE(group.currentTime(), 1500); - QCOMPARE(sequence->currentTime(), 1250); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentTime(), 250); + QCOMPARE(group.currentLoopTime(), 1500); + QCOMPARE(sequence->currentLoopTime(), 1250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); QCOMPARE(a2_s_o1->currentLoop(), 2); - QCOMPARE(a3_s_o1->currentTime(), 250); - QCOMPARE(sequence2->currentTime(), 250); - QCOMPARE(a1_s_o2->currentTime(), 250); - QCOMPARE(a1_s_o3->currentTime(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 250); + QCOMPARE(sequence2->currentLoopTime(), 250); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); // Current time = 1750 group.setCurrentTime(1750); - QCOMPARE(group.currentTime(), 1750); - QCOMPARE(sequence->currentTime(), 1250); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentTime(), 250); + QCOMPARE(group.currentLoopTime(), 1750); + QCOMPARE(sequence->currentLoopTime(), 1250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); QCOMPARE(a2_s_o1->currentLoop(), 2); - QCOMPARE(a3_s_o1->currentTime(), 250); - QCOMPARE(sequence2->currentTime(), 500); - QCOMPARE(a1_s_o2->currentTime(), 250); - QCOMPARE(a1_s_o3->currentTime(), 250); + QCOMPARE(a3_s_o1->currentLoopTime(), 250); + QCOMPARE(sequence2->currentLoopTime(), 500); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(a1_s_o3->currentLoopTime(), 250); // Current time = 2000 group.setCurrentTime(2000); - QCOMPARE(group.currentTime(), 1750); - QCOMPARE(sequence->currentTime(), 1250); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentTime(), 250); + QCOMPARE(group.currentLoopTime(), 1750); + QCOMPARE(sequence->currentLoopTime(), 1250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); QCOMPARE(a2_s_o1->currentLoop(), 2); - QCOMPARE(a3_s_o1->currentTime(), 250); - QCOMPARE(sequence2->currentTime(), 500); - QCOMPARE(a1_s_o2->currentTime(), 250); - QCOMPARE(a1_s_o3->currentTime(), 250); + QCOMPARE(a3_s_o1->currentLoopTime(), 250); + QCOMPARE(sequence2->currentLoopTime(), 500); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(a1_s_o3->currentLoopTime(), 250); } void tst_QSequentialAnimationGroup::setCurrentTimeWithUncontrolledAnimation() @@ -357,40 +357,40 @@ void tst_QSequentialAnimationGroup::setCurrentTimeWithUncontrolledAnimation() QCOMPARE(notTimeDriven->state(), QAnimationGroup::Stopped); QCOMPARE(loopsForever->state(), QAnimationGroup::Stopped); - QCOMPARE(group.currentTime(), 1); - QCOMPARE(sequence->currentTime(), 1); - QCOMPARE(a1_s_o1->currentTime(), 1); - QCOMPARE(a1_s_o2->currentTime(), 0); - QCOMPARE(notTimeDriven->currentTime(), 0); - QCOMPARE(loopsForever->currentTime(), 0); + QCOMPARE(group.currentLoopTime(), 1); + QCOMPARE(sequence->currentLoopTime(), 1); + QCOMPARE(a1_s_o1->currentLoopTime(), 1); + QCOMPARE(a1_s_o2->currentLoopTime(), 0); + QCOMPARE(notTimeDriven->currentLoopTime(), 0); + QCOMPARE(loopsForever->currentLoopTime(), 0); // Current time = 250 group.setCurrentTime(250); - QCOMPARE(group.currentTime(), 250); - QCOMPARE(sequence->currentTime(), 250); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a1_s_o2->currentTime(), 0); - QCOMPARE(notTimeDriven->currentTime(), 0); - QCOMPARE(loopsForever->currentTime(), 0); + QCOMPARE(group.currentLoopTime(), 250); + QCOMPARE(sequence->currentLoopTime(), 250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a1_s_o2->currentLoopTime(), 0); + QCOMPARE(notTimeDriven->currentLoopTime(), 0); + QCOMPARE(loopsForever->currentLoopTime(), 0); // Current time = 500 group.setCurrentTime(500); - QCOMPARE(group.currentTime(), 500); - QCOMPARE(sequence->currentTime(), 500); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a1_s_o2->currentTime(), 250); - QCOMPARE(notTimeDriven->currentTime(), 0); - QCOMPARE(loopsForever->currentTime(), 0); + QCOMPARE(group.currentLoopTime(), 500); + QCOMPARE(sequence->currentLoopTime(), 500); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(notTimeDriven->currentLoopTime(), 0); + QCOMPARE(loopsForever->currentLoopTime(), 0); QCOMPARE(group.currentAnimation(), notTimeDriven); // Current time = 505 group.setCurrentTime(505); - QCOMPARE(group.currentTime(), 505); - QCOMPARE(sequence->currentTime(), 500); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a1_s_o2->currentTime(), 250); - QCOMPARE(notTimeDriven->currentTime(), 5); - QCOMPARE(loopsForever->currentTime(), 0); + QCOMPARE(group.currentLoopTime(), 505); + QCOMPARE(sequence->currentLoopTime(), 500); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(notTimeDriven->currentLoopTime(), 5); + QCOMPARE(loopsForever->currentLoopTime(), 0); QCOMPARE(group.currentAnimation(), notTimeDriven); QCOMPARE(sequence->state(), QAnimationGroup::Stopped); QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped); @@ -400,12 +400,12 @@ void tst_QSequentialAnimationGroup::setCurrentTimeWithUncontrolledAnimation() // Current time = 750 (end of notTimeDriven animation) group.setCurrentTime(750); - QCOMPARE(group.currentTime(), 750); - QCOMPARE(sequence->currentTime(), 500); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a1_s_o2->currentTime(), 250); - QCOMPARE(notTimeDriven->currentTime(), 250); - QCOMPARE(loopsForever->currentTime(), 0); + QCOMPARE(group.currentLoopTime(), 750); + QCOMPARE(sequence->currentLoopTime(), 500); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(notTimeDriven->currentLoopTime(), 250); + QCOMPARE(loopsForever->currentLoopTime(), 0); QCOMPARE(group.currentAnimation(), loopsForever); QCOMPARE(sequence->state(), QAnimationGroup::Stopped); QCOMPARE(a1_s_o1->state(), QAnimationGroup::Stopped); @@ -415,13 +415,13 @@ void tst_QSequentialAnimationGroup::setCurrentTimeWithUncontrolledAnimation() // Current time = 800 (as notTimeDriven was finished at 750, loopsforever should still run) group.setCurrentTime(800); - QCOMPARE(group.currentTime(), 800); + QCOMPARE(group.currentLoopTime(), 800); QCOMPARE(group.currentAnimation(), loopsForever); - QCOMPARE(sequence->currentTime(), 500); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a1_s_o2->currentTime(), 250); - QCOMPARE(notTimeDriven->currentTime(), 250); - QCOMPARE(loopsForever->currentTime(), 50); + QCOMPARE(sequence->currentLoopTime(), 500); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(notTimeDriven->currentLoopTime(), 250); + QCOMPARE(loopsForever->currentLoopTime(), 50); loopsForever->stop(); // this should stop the group @@ -466,26 +466,26 @@ void tst_QSequentialAnimationGroup::seekingForwards() QCOMPARE(a1_s_o2->state(), QAnimationGroup::Stopped); QCOMPARE(a1_s_o3->state(), QAnimationGroup::Stopped); - QCOMPARE(group.currentTime(), 1); - QCOMPARE(sequence->currentTime(), 1); - QCOMPARE(a1_s_o1->currentTime(), 1); - QCOMPARE(a2_s_o1->currentTime(), 0); - QCOMPARE(a3_s_o1->currentTime(), 0); - QCOMPARE(sequence2->currentTime(), 0); - QCOMPARE(a1_s_o2->currentTime(), 0); - QCOMPARE(a1_s_o3->currentTime(), 0); + QCOMPARE(group.currentLoopTime(), 1); + QCOMPARE(sequence->currentLoopTime(), 1); + QCOMPARE(a1_s_o1->currentLoopTime(), 1); + QCOMPARE(a2_s_o1->currentLoopTime(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 0); + QCOMPARE(sequence2->currentLoopTime(), 0); + QCOMPARE(a1_s_o2->currentLoopTime(), 0); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); // Current time = 1500 group.setCurrentTime(1500); - QCOMPARE(group.currentTime(), 1500); - QCOMPARE(sequence->currentTime(), 1250); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentTime(), 250); + QCOMPARE(group.currentLoopTime(), 1500); + QCOMPARE(sequence->currentLoopTime(), 1250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); QCOMPARE(a2_s_o1->currentLoop(), 2); - QCOMPARE(a3_s_o1->currentTime(), 250); - QCOMPARE(sequence2->currentTime(), 250); - QCOMPARE(a1_s_o2->currentTime(), 250); - QCOMPARE(a1_s_o3->currentTime(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 250); + QCOMPARE(sequence2->currentLoopTime(), 250); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); // this will restart the group group.start(); @@ -499,15 +499,15 @@ void tst_QSequentialAnimationGroup::seekingForwards() // Current time = 1750 group.setCurrentTime(1750); - QCOMPARE(group.currentTime(), 1750); - QCOMPARE(sequence->currentTime(), 1250); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentTime(), 250); + QCOMPARE(group.currentLoopTime(), 1750); + QCOMPARE(sequence->currentLoopTime(), 1250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); QCOMPARE(a2_s_o1->currentLoop(), 2); - QCOMPARE(a3_s_o1->currentTime(), 250); - QCOMPARE(sequence2->currentTime(), 500); - QCOMPARE(a1_s_o2->currentTime(), 250); - QCOMPARE(a1_s_o3->currentTime(), 250); + QCOMPARE(a3_s_o1->currentLoopTime(), 250); + QCOMPARE(sequence2->currentLoopTime(), 500); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(a1_s_o3->currentLoopTime(), 250); } void tst_QSequentialAnimationGroup::seekingBackwards() @@ -537,15 +537,15 @@ void tst_QSequentialAnimationGroup::seekingBackwards() // Current time = 1600 group.setCurrentTime(1600); - QCOMPARE(group.currentTime(), 1600); - QCOMPARE(sequence->currentTime(), 1250); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentTime(), 250); + QCOMPARE(group.currentLoopTime(), 1600); + QCOMPARE(sequence->currentLoopTime(), 1250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); QCOMPARE(a2_s_o1->currentLoop(), 2); - QCOMPARE(a3_s_o1->currentTime(), 250); - QCOMPARE(sequence2->currentTime(), 350); - QCOMPARE(a1_s_o2->currentTime(), 250); - QCOMPARE(a1_s_o3->currentTime(), 100); + QCOMPARE(a3_s_o1->currentLoopTime(), 250); + QCOMPARE(sequence2->currentLoopTime(), 350); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(a1_s_o3->currentLoopTime(), 100); QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(sequence->state(), QAnimationGroup::Stopped); @@ -556,22 +556,22 @@ void tst_QSequentialAnimationGroup::seekingBackwards() // Seeking backwards, current time = 1 group.setCurrentTime(1); - QCOMPARE(group.currentTime(), 1); - QCOMPARE(sequence->currentTime(), 1); - QCOMPARE(a1_s_o1->currentTime(), 1); + QCOMPARE(group.currentLoopTime(), 1); + QCOMPARE(sequence->currentLoopTime(), 1); + QCOMPARE(a1_s_o1->currentLoopTime(), 1); QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children," "hence they don't reset from their current animation", Continue); - QCOMPARE(a2_s_o1->currentTime(), 0); + QCOMPARE(a2_s_o1->currentLoopTime(), 0); QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children," "hence they don't reset from their current animation", Continue); QCOMPARE(a2_s_o1->currentLoop(), 0); QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children," "hence they don't reset from their current animation", Continue); - QCOMPARE(a3_s_o1->currentTime(), 0); - QCOMPARE(sequence2->currentTime(), 0); - QCOMPARE(a1_s_o2->currentTime(), 0); - QCOMPARE(a1_s_o3->currentTime(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 0); + QCOMPARE(sequence2->currentLoopTime(), 0); + QCOMPARE(a1_s_o2->currentLoopTime(), 0); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(sequence->state(), QAnimationGroup::Running); @@ -582,15 +582,15 @@ void tst_QSequentialAnimationGroup::seekingBackwards() // Current time = 2000 group.setCurrentTime(2000); - QCOMPARE(group.currentTime(), 1750); - QCOMPARE(sequence->currentTime(), 1250); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentTime(), 250); + QCOMPARE(group.currentLoopTime(), 1750); + QCOMPARE(sequence->currentLoopTime(), 1250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); QCOMPARE(a2_s_o1->currentLoop(), 2); - QCOMPARE(a3_s_o1->currentTime(), 250); - QCOMPARE(sequence2->currentTime(), 500); - QCOMPARE(a1_s_o2->currentTime(), 250); - QCOMPARE(a1_s_o3->currentTime(), 250); + QCOMPARE(a3_s_o1->currentLoopTime(), 250); + QCOMPARE(sequence2->currentLoopTime(), 500); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(a1_s_o3->currentLoopTime(), 250); QCOMPARE(group.state(), QAnimationGroup::Stopped); QCOMPARE(sequence->state(), QAnimationGroup::Stopped); @@ -612,7 +612,7 @@ static bool compareStates(const QSignalSpy& spy, const StateList &expectedStates } QList args = spy.at(i); QAbstractAnimation::State st = expectedStates.at(i); - QAbstractAnimation::State actual = qVariantValue(args.value(1)); + QAbstractAnimation::State actual = qVariantValue(args.first()); if (equals && actual != st) { equals = false; break; @@ -672,14 +672,14 @@ void tst_QSequentialAnimationGroup::pauseAndResume() // Current time = 1751 group.setCurrentTime(1751); - QCOMPARE(group.currentTime(), 1751); - QCOMPARE(sequence->currentTime(), 751); + QCOMPARE(group.currentLoopTime(), 1751); + QCOMPARE(sequence->currentLoopTime(), 751); QCOMPARE(sequence->currentLoop(), 1); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentTime(), 250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); QCOMPARE(a2_s_o1->currentLoop(), 1); QCOMPARE(a3_s_o1->currentLoop(), 0); - QCOMPARE(a3_s_o1->currentTime(), 1); + QCOMPARE(a3_s_o1->currentLoopTime(), 1); QCOMPARE(group.state(), QAnimationGroup::Paused); QCOMPARE(sequence->state(), QAnimationGroup::Paused); @@ -696,20 +696,20 @@ void tst_QSequentialAnimationGroup::pauseAndResume() << QAbstractAnimation::Running << QAbstractAnimation::Stopped))); - QCOMPARE(qVariantValue(a1StateChangedSpy.at(0).at(1)), + QCOMPARE(qVariantValue(a1StateChangedSpy.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(a1StateChangedSpy.at(1).at(1)), + QCOMPARE(qVariantValue(a1StateChangedSpy.at(1).first()), QAnimationGroup::Paused); - QCOMPARE(qVariantValue(a1StateChangedSpy.at(2).at(1)), + QCOMPARE(qVariantValue(a1StateChangedSpy.at(2).first()), QAnimationGroup::Stopped); - QCOMPARE(qVariantValue(a1StateChangedSpy.at(3).at(1)), + QCOMPARE(qVariantValue(a1StateChangedSpy.at(3).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(a1StateChangedSpy.at(4).at(1)), + QCOMPARE(qVariantValue(a1StateChangedSpy.at(4).first()), QAnimationGroup::Stopped); - QCOMPARE(qVariantValue(seqStateChangedSpy.at(0).at(1)), + QCOMPARE(qVariantValue(seqStateChangedSpy.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(seqStateChangedSpy.at(1).at(1)), + QCOMPARE(qVariantValue(seqStateChangedSpy.at(1).first()), QAnimationGroup::Paused); group.resume(); @@ -720,17 +720,17 @@ void tst_QSequentialAnimationGroup::pauseAndResume() QCOMPARE(a2_s_o1->state(), QAnimationGroup::Stopped); QCOMPARE(a3_s_o1->state(), QAnimationGroup::Running); - QVERIFY(group.currentTime() >= 1751); - QVERIFY(sequence->currentTime() >= 751); + QVERIFY(group.currentLoopTime() >= 1751); + QVERIFY(sequence->currentLoopTime() >= 751); QCOMPARE(sequence->currentLoop(), 1); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentTime(), 250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); QCOMPARE(a2_s_o1->currentLoop(), 1); QCOMPARE(a3_s_o1->currentLoop(), 0); - QVERIFY(a3_s_o1->currentTime() >= 1); + QVERIFY(a3_s_o1->currentLoopTime() >= 1); QCOMPARE(seqStateChangedSpy.count(), 3); // Running,Paused,Running - QCOMPARE(qVariantValue(seqStateChangedSpy.at(2).at(1)), + QCOMPARE(qVariantValue(seqStateChangedSpy.at(2).first()), QAnimationGroup::Running); group.pause(); @@ -741,23 +741,23 @@ void tst_QSequentialAnimationGroup::pauseAndResume() QCOMPARE(a2_s_o1->state(), QAnimationGroup::Stopped); QCOMPARE(a3_s_o1->state(), QAnimationGroup::Paused); - QVERIFY(group.currentTime() >= 1751); - QVERIFY(sequence->currentTime() >= 751); + QVERIFY(group.currentLoopTime() >= 1751); + QVERIFY(sequence->currentLoopTime() >= 751); QCOMPARE(sequence->currentLoop(), 1); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentTime(), 250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); QCOMPARE(a2_s_o1->currentLoop(), 1); QCOMPARE(a3_s_o1->currentLoop(), 0); - QVERIFY(a3_s_o1->currentTime() >= 1); + QVERIFY(a3_s_o1->currentLoopTime() >= 1); QCOMPARE(seqStateChangedSpy.count(), 4); // Running,Paused,Running,Paused - QCOMPARE(qVariantValue(seqStateChangedSpy.at(3).at(1)), + QCOMPARE(qVariantValue(seqStateChangedSpy.at(3).first()), QAnimationGroup::Paused); group.stop(); QCOMPARE(seqStateChangedSpy.count(), 5); // Running,Paused,Running,Paused,Stopped - QCOMPARE(qVariantValue(seqStateChangedSpy.at(4).at(1)), + QCOMPARE(qVariantValue(seqStateChangedSpy.at(4).first()), QAnimationGroup::Stopped); } @@ -797,20 +797,20 @@ void tst_QSequentialAnimationGroup::restart() for (int i = 0; i < 3; i++) { QCOMPARE(animsStateChanged[i]->count(), 4); - QCOMPARE(qVariantValue(animsStateChanged[i]->at(0).at(1)), + QCOMPARE(qVariantValue(animsStateChanged[i]->at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(animsStateChanged[i]->at(1).at(1)), + QCOMPARE(qVariantValue(animsStateChanged[i]->at(1).first()), QAnimationGroup::Stopped); - QCOMPARE(qVariantValue(animsStateChanged[i]->at(2).at(1)), + QCOMPARE(qVariantValue(animsStateChanged[i]->at(2).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(animsStateChanged[i]->at(3).at(1)), + QCOMPARE(qVariantValue(animsStateChanged[i]->at(3).first()), QAnimationGroup::Stopped); } QCOMPARE(seqStateChangedSpy.count(), 2); - QCOMPARE(qVariantValue(seqStateChangedSpy.at(0).at(1)), + QCOMPARE(qVariantValue(seqStateChangedSpy.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(seqStateChangedSpy.at(1).at(1)), + QCOMPARE(qVariantValue(seqStateChangedSpy.at(1).first()), QAnimationGroup::Stopped); QCOMPARE(seqCurrentAnimChangedSpy.count(), 6); @@ -855,15 +855,15 @@ void tst_QSequentialAnimationGroup::looping() // Current time = 1750 group.setCurrentTime(1750); - QCOMPARE(group.currentTime(), 1750); - QCOMPARE(sequence->currentTime(), 750); + QCOMPARE(group.currentLoopTime(), 1750); + QCOMPARE(sequence->currentLoopTime(), 750); QCOMPARE(sequence->currentLoop(), 1); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentTime(), 250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); QCOMPARE(a2_s_o1->currentLoop(), 1); // this animation is at the beginning because it is the current one inside sequence QCOMPARE(a3_s_o1->currentLoop(), 0); - QCOMPARE(a3_s_o1->currentTime(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 0); QCOMPARE(sequence->currentAnimation(), a3_s_o1); QCOMPARE(group.state(), QAnimationGroup::Paused); @@ -890,16 +890,16 @@ void tst_QSequentialAnimationGroup::looping() // Looping, current time = duration + 1 group.setCurrentTime(group.duration() + 1); - QCOMPARE(group.currentTime(), 1); + QCOMPARE(group.currentLoopTime(), 1); QCOMPARE(group.currentLoop(), 1); - QCOMPARE(sequence->currentTime(), 1); + QCOMPARE(sequence->currentLoopTime(), 1); QCOMPARE(sequence->currentLoop(), 0); - QCOMPARE(a1_s_o1->currentTime(), 1); - QCOMPARE(a2_s_o1->currentTime(), 250); + QCOMPARE(a1_s_o1->currentLoopTime(), 1); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); QCOMPARE(a2_s_o1->currentLoop(), 1); // this animation is at the end because it was run on the previous loop QCOMPARE(a3_s_o1->currentLoop(), 0); - QCOMPARE(a3_s_o1->currentTime(), 250); + QCOMPARE(a3_s_o1->currentLoopTime(), 250); QCOMPARE(group.state(), QAnimationGroup::Paused); QCOMPARE(sequence->state(), QAnimationGroup::Paused); @@ -934,7 +934,7 @@ void tst_QSequentialAnimationGroup::startDelay() QTest::qWait(500); - QVERIFY(group.currentTime() == 375); + QVERIFY(group.currentLoopTime() == 375); QCOMPARE(group.state(), QAnimationGroup::Stopped); } @@ -958,9 +958,9 @@ void tst_QSequentialAnimationGroup::clearGroup() children[i] = group.animationAt(i); } - group.clearAnimations(); + group.clear(); QCOMPARE(group.animationCount(), 0); - QCOMPARE(group.currentTime(), 0); + QCOMPARE(group.currentLoopTime(), 0); for (int i = 0; i < animationCount; ++i) QVERIFY(children[i].isNull()); } @@ -1130,9 +1130,9 @@ void tst_QSequentialAnimationGroup::updateChildrenWithRunningGroup() QCOMPARE(groupStateChangedSpy.count(), 1); QCOMPARE(childStateChangedSpy.count(), 1); - QCOMPARE(qVariantValue(groupStateChangedSpy.at(0).at(1)), + QCOMPARE(qVariantValue(groupStateChangedSpy.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(childStateChangedSpy.at(0).at(1)), + QCOMPARE(qVariantValue(childStateChangedSpy.at(0).first()), QAnimationGroup::Running); // starting directly a running child will not have any effect @@ -1171,13 +1171,13 @@ void tst_QSequentialAnimationGroup::deleteChildrenWithRunningGroup() QCOMPARE(anim1->state(), QAnimationGroup::Running); QTest::qWait(100); - QVERIFY(group.currentTime() > 0); + QVERIFY(group.currentLoopTime() > 0); delete anim1; QCOMPARE(group.animationCount(), 0); QCOMPARE(group.duration(), 0); QCOMPARE(group.state(), QAnimationGroup::Stopped); - QCOMPARE(group.currentTime(), 0); //that's the invariant + QCOMPARE(group.currentLoopTime(), 0); //that's the invariant } void tst_QSequentialAnimationGroup::startChildrenWithStoppedGroup() @@ -1320,9 +1320,9 @@ void tst_QSequentialAnimationGroup::startGroupWithRunningChild() QCOMPARE(anim2->state(), QAnimationGroup::Running); QCOMPARE(stateChangedSpy2.count(), 4); - QCOMPARE(qVariantValue(stateChangedSpy2.at(2).at(1)), + QCOMPARE(qVariantValue(stateChangedSpy2.at(2).first()), QAnimationGroup::Stopped); - QCOMPARE(qVariantValue(stateChangedSpy2.at(3).at(1)), + QCOMPARE(qVariantValue(stateChangedSpy2.at(3).first()), QAnimationGroup::Running); group.stop(); @@ -1359,9 +1359,9 @@ void tst_QSequentialAnimationGroup::zeroDurationAnimation() group.start(); QCOMPARE(stateChangedSpy.count(), 2); - QCOMPARE(qVariantValue(stateChangedSpy.at(0).at(1)), + QCOMPARE(qVariantValue(stateChangedSpy.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(stateChangedSpy.at(1).at(1)), + QCOMPARE(qVariantValue(stateChangedSpy.at(1).first()), QAnimationGroup::Stopped); QCOMPARE(anim1->state(), QAnimationGroup::Stopped); @@ -1426,14 +1426,14 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation() group.start(); QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(notTimeDriven.state(), QAnimationGroup::Running); - QCOMPARE(group.currentTime(), 0); - QCOMPARE(notTimeDriven.currentTime(), 0); + QCOMPARE(group.currentLoopTime(), 0); + QCOMPARE(notTimeDriven.currentLoopTime(), 0); QTest::qWait(300); //wait for the end of notTimeDriven QCOMPARE(notTimeDriven.state(), QAnimationGroup::Stopped); - const int actualDuration = notTimeDriven.currentTime(); + const int actualDuration = notTimeDriven.currentLoopTime(); QCOMPARE(group.state(), QAnimationGroup::Stopped); - QCOMPARE(group.currentTime(), actualDuration); + QCOMPARE(group.currentLoopTime(), actualDuration); QCOMPARE(spy.count(), 1); //2nd case: @@ -1444,7 +1444,7 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation() group.setCurrentTime(300); QCOMPARE(group.state(), QAnimationGroup::Stopped); - QCOMPARE(notTimeDriven.currentTime(), actualDuration); + QCOMPARE(notTimeDriven.currentLoopTime(), actualDuration); QCOMPARE(group.currentAnimation(), static_cast(&anim)); //3rd case: @@ -1453,8 +1453,8 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation() group.start(); QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(notTimeDriven.state(), QAnimationGroup::Running); - QCOMPARE(group.currentTime(), 0); - QCOMPARE(notTimeDriven.currentTime(), 0); + QCOMPARE(group.currentLoopTime(), 0); + QCOMPARE(notTimeDriven.currentLoopTime(), 0); QCOMPARE(animStateChangedSpy.count(), 0); @@ -1467,12 +1467,12 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation() QTest::qWait(300); //wait for the end of anim QCOMPARE(anim.state(), QAnimationGroup::Stopped); - QCOMPARE(anim.currentTime(), anim.duration()); + QCOMPARE(anim.currentLoopTime(), anim.duration()); //we should simply be at the end QCOMPARE(spy.count(), 1); QCOMPARE(animStateChangedSpy.count(), 2); - QCOMPARE(group.currentTime(), notTimeDriven.currentTime() + anim.currentTime()); + QCOMPARE(group.currentLoopTime(), notTimeDriven.currentLoopTime() + anim.currentLoopTime()); } void tst_QSequentialAnimationGroup::addRemoveAnimation() @@ -1481,48 +1481,48 @@ void tst_QSequentialAnimationGroup::addRemoveAnimation() QSequentialAnimationGroup group; QCOMPARE(group.duration(), 0); - QCOMPARE(group.currentTime(), 0); + QCOMPARE(group.currentLoopTime(), 0); QAbstractAnimation *anim1 = new QPropertyAnimation; group.addAnimation(anim1); QCOMPARE(group.duration(), 250); - QCOMPARE(group.currentTime(), 0); + QCOMPARE(group.currentLoopTime(), 0); QCOMPARE(group.currentAnimation(), anim1); //let's append an animation QAbstractAnimation *anim2 = new QPropertyAnimation; group.addAnimation(anim2); QCOMPARE(group.duration(), 500); - QCOMPARE(group.currentTime(), 0); + QCOMPARE(group.currentLoopTime(), 0); QCOMPARE(group.currentAnimation(), anim1); //let's prepend an animation QAbstractAnimation *anim0 = new QPropertyAnimation; - group.insertAnimationAt(0, anim0); + group.insertAnimation(0, anim0); QCOMPARE(group.duration(), 750); - QCOMPARE(group.currentTime(), 0); + QCOMPARE(group.currentLoopTime(), 0); QCOMPARE(group.currentAnimation(), anim0); //anim0 has become the new currentAnimation group.setCurrentTime(300); //anim0 | anim1 | anim2 - QCOMPARE(group.currentTime(), 300); + QCOMPARE(group.currentLoopTime(), 300); QCOMPARE(group.currentAnimation(), anim1); - QCOMPARE(anim1->currentTime(), 50); + QCOMPARE(anim1->currentLoopTime(), 50); group.removeAnimation(anim0); //anim1 | anim2 - QCOMPARE(group.currentTime(), 50); + QCOMPARE(group.currentLoopTime(), 50); QCOMPARE(group.currentAnimation(), anim1); - QCOMPARE(anim1->currentTime(), 50); + QCOMPARE(anim1->currentLoopTime(), 50); group.setCurrentTime(0); - group.insertAnimationAt(0, anim0); //anim0 | anim1 | anim2 + group.insertAnimation(0, anim0); //anim0 | anim1 | anim2 group.setCurrentTime(300); - QCOMPARE(group.currentTime(), 300); + QCOMPARE(group.currentLoopTime(), 300); QCOMPARE(group.currentAnimation(), anim1); - QCOMPARE(anim1->currentTime(), 50); + QCOMPARE(anim1->currentLoopTime(), 50); group.removeAnimation(anim1); //anim0 | anim2 - QCOMPARE(group.currentTime(), 250); + QCOMPARE(group.currentLoopTime(), 250); QCOMPARE(group.currentAnimation(), anim2); - QCOMPARE(anim0->currentTime(), 250); + QCOMPARE(anim0->currentLoopTime(), 250); } void tst_QSequentialAnimationGroup::currentAnimation() @@ -1595,15 +1595,15 @@ class SequentialAnimationGroup : public QSequentialAnimationGroup { Q_OBJECT public slots: - void clearAnimations() + void clear() { - QSequentialAnimationGroup::clearAnimations(); + QSequentialAnimationGroup::clear(); } void refill() { stop(); - clearAnimations(); + clear(); new DummyPropertyAnimation(this); start(); } @@ -1611,11 +1611,11 @@ public slots: }; -void tst_QSequentialAnimationGroup::clearAnimations() +void tst_QSequentialAnimationGroup::clear() { SequentialAnimationGroup group; QPointer anim1 = new DummyPropertyAnimation(&group); - group.connect(anim1, SIGNAL(finished()), SLOT(clearAnimations())); + group.connect(anim1, SIGNAL(finished()), SLOT(clear())); new DummyPropertyAnimation(&group); QCOMPARE(group.animationCount(), 2); @@ -1623,7 +1623,7 @@ void tst_QSequentialAnimationGroup::clearAnimations() QTest::qWait(anim1->duration() + 100); QCOMPARE(group.animationCount(), 0); QCOMPARE(group.state(), QAbstractAnimation::Stopped); - QCOMPARE(group.currentTime(), 0); + QCOMPARE(group.currentLoopTime(), 0); anim1 = new DummyPropertyAnimation(&group); group.connect(anim1, SIGNAL(finished()), SLOT(refill())); @@ -1649,22 +1649,22 @@ void tst_QSequentialAnimationGroup::pauseResume() QCOMPARE(anim->state(), QAnimationGroup::Running); QCOMPARE(spy.count(), 1); spy.clear(); - const int currentTime = group.currentTime(); - QCOMPARE(anim->currentTime(), currentTime); + const int currentTime = group.currentLoopTime(); + QCOMPARE(anim->currentLoopTime(), currentTime); group.pause(); QCOMPARE(group.state(), QAnimationGroup::Paused); - QCOMPARE(group.currentTime(), currentTime); + QCOMPARE(group.currentLoopTime(), currentTime); QCOMPARE(anim->state(), QAnimationGroup::Paused); - QCOMPARE(anim->currentTime(), currentTime); + QCOMPARE(anim->currentLoopTime(), currentTime); QCOMPARE(spy.count(), 1); spy.clear(); group.resume(); QCOMPARE(group.state(), QAnimationGroup::Running); - QCOMPARE(group.currentTime(), currentTime); + QCOMPARE(group.currentLoopTime(), currentTime); QCOMPARE(anim->state(), QAnimationGroup::Running); - QCOMPARE(anim->currentTime(), currentTime); + QCOMPARE(anim->currentLoopTime(), currentTime); QCOMPARE(spy.count(), 1); } -- cgit v1.2.3 From 90b26c211bca82e252dcd31ffa1ef6834bbb6060 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Wed, 4 Nov 2009 14:10:47 +0100 Subject: Make QStringBuilder respect codecForCStrings Now, it's a real drop-in replacement, with no known feature regressions :) Reviewed-By: hjk --- tests/auto/qstringbuilder1/stringbuilder.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qstringbuilder1/stringbuilder.cpp b/tests/auto/qstringbuilder1/stringbuilder.cpp index f35d4d20d5..9dc467e5cc 100644 --- a/tests/auto/qstringbuilder1/stringbuilder.cpp +++ b/tests/auto/qstringbuilder1/stringbuilder.cpp @@ -41,8 +41,15 @@ #define LITERAL "some literal" +// "some literal", but replacing all vocals by their umlauted UTF-8 string :) +#define UTF8_LITERAL "s\xc3\xb6m\xc3\xab l\xc3\xaft\xc3\xabr\xc3\xa4l" + void runScenario() { + // set codec for C strings to 0, enforcing Latin1 + QTextCodec::setCodecForCStrings(0); + QVERIFY(!QTextCodec::codecForCStrings()); + QLatin1Literal l1literal(LITERAL); QLatin1String l1string(LITERAL); QString string(l1string); @@ -75,5 +82,24 @@ void runScenario() QCOMPARE(r, r2); r = string P ba; QCOMPARE(r, r2); + + // now test with codec for C strings set + QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); + QVERIFY(QTextCodec::codecForCStrings()); + QCOMPARE(QTextCodec::codecForCStrings()->name(), QByteArray("UTF-8")); + + string = QString::fromUtf8(UTF8_LITERAL); + r2 = QString::fromUtf8(UTF8_LITERAL UTF8_LITERAL); + ba = UTF8_LITERAL; + + r = string P UTF8_LITERAL; + QCOMPARE(r.size(), r2.size()); + QCOMPARE(r, r2); + r = UTF8_LITERAL P string; + QCOMPARE(r, r2); + r = ba P string; + QCOMPARE(r, r2); + r = string P ba; + QCOMPARE(r, r2); #endif } -- cgit v1.2.3 From df12ef0e1fa327103b09e9a817d83b8c8d3035d7 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 3 Nov 2009 17:08:08 +0100 Subject: fix bogus "Class '' lacks Q_OBJECT macro" the optimization not to look for parent definitions if we already knew that there would be none did not consider that we only know that the leaf node is missing, not any intermediate nodes. --- .../lupdate/testdata/good/parsecpp2/main.cpp | 30 +++++++++++++ .../lupdate/testdata/good/parsecpp2/main.h | 51 ++++++++++++++++++++++ .../testdata/good/parsecpp2/project.ts.result | 16 +++++++ 3 files changed, 97 insertions(+) create mode 100644 tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.h (limited to 'tests/auto') diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp index eaa271aea2..d720b8ff52 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp @@ -63,3 +63,33 @@ line c++ comment } (with brace) #define This is another // comment in } define \ something } comment } // complain here + + + +// Nested class in same file +class TopLevel { + Q_OBJECT + + class Nested; +}; + +class TopLevel::Nested { + void foo(); +}; + +TopLevel::Nested::foo() +{ + TopLevel::tr("TopLevel"); +} + +// Nested class in other file +#include "main.h" + +class TopLevel2::Nested { + void foo(); +}; + +TopLevel2::Nested::foo() +{ + TopLevel2::tr("TopLevel2"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.h b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.h new file mode 100644 index 0000000000..54a76ab3aa --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.h @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// IMPORTANT!!!! If you want to add testdata to this file, +// always add it to the end in order to not change the linenumbers of translations!!! + +class TopLevel2 { + Q_OBJECT + + class Nested; +}; + + diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/project.ts.result index 07a7469f10..ef5adb22c3 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/project.ts.result @@ -1,4 +1,20 @@ + + TopLevel + + + TopLevel + + + + + TopLevel2 + + + TopLevel2 + + + -- cgit v1.2.3 From 21f0f9157802f011bb02b96fd79057084039ae2b Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 4 Nov 2009 10:48:20 +0100 Subject: introduce delayed resolution of aliases this has two effects: - using-declarations which use forward-declared classes work without collecting the forward declarations, as the resolution happens at a place where the class definition must have been encountered already - it should be a bit faster --- .../linguist/lupdate/testdata/good/parsecpp2/main.cpp | 19 +++++++++++++++++++ .../lupdate/testdata/good/parsecpp2/project.ts.result | 8 ++++++++ 2 files changed, 27 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp index d720b8ff52..7ddb68fbb1 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp @@ -93,3 +93,22 @@ TopLevel2::Nested::foo() { TopLevel2::tr("TopLevel2"); } + + + +namespace NameSpace { +class ToBeUsed; +} + +// using statement before class definition +using NameSpace::ToBeUsed; + +class NameSpace::ToBeUsed { + Q_OBJECT + void caller(); +}; + +void ToBeUsed::caller() +{ + tr("NameSpace::ToBeUsed"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/project.ts.result index ef5adb22c3..6f48e27021 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/project.ts.result @@ -1,6 +1,14 @@ + + NameSpace::ToBeUsed + + + NameSpace::ToBeUsed + + + TopLevel -- cgit v1.2.3 From 9a88c8808f8e084e77ee22f907366250f3a0ad2a Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 4 Nov 2009 12:17:03 +0100 Subject: add -markuntranslated option maemo *really* want it, so pushing it in now ... --- tests/auto/linguist/lrelease/tst_lrelease.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/linguist/lrelease/tst_lrelease.cpp b/tests/auto/linguist/lrelease/tst_lrelease.cpp index 39de8a15fa..93cb97c5fa 100644 --- a/tests/auto/linguist/lrelease/tst_lrelease.cpp +++ b/tests/auto/linguist/lrelease/tst_lrelease.cpp @@ -60,6 +60,7 @@ private slots: void mixedcodecs(); void compressed(); void idbased(); + void markuntranslated(); void dupes(); private: @@ -210,6 +211,18 @@ void tst_lrelease::idbased() QCOMPARE(qtTrId("untranslated_id"), QString::fromAscii("This has no translation.")); } +void tst_lrelease::markuntranslated() +{ + QVERIFY(!QProcess::execute(binDir + "/lrelease -markuntranslated # -idbased testdata/idbased.ts")); + + QTranslator translator; + QVERIFY(translator.load("testdata/idbased.qm")); + qApp->installTranslator(&translator); + + QCOMPARE(qtTrId("test_id"), QString::fromAscii("This is a test string.")); + QCOMPARE(qtTrId("untranslated_id"), QString::fromAscii("#This has no translation.")); +} + void tst_lrelease::dupes() { QProcess proc; -- cgit v1.2.3 From eda773316824cbb1aa7bdba402e568340b79b4f3 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 4 Nov 2009 18:42:33 +0000 Subject: tst_qwidget widgetAt now does not leave widget lowered if test fails Task-number: QTBUG-5396 Reviewed-by: axis --- tests/auto/qwidget/tst_qwidget.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 3d801cced9..e027dd1bf4 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -3328,9 +3328,10 @@ void tst_QWidget::widgetAt() w2->lower(); qApp->processEvents(); QTRY_VERIFY((wr = QApplication::widgetAt(100, 100))); - QCOMPARE(wr->objectName(), QString("w1")); - + const bool match = (wr->objectName() == QString("w1")); w2->raise(); + QVERIFY(match); + qApp->processEvents(); QTRY_VERIFY((wr = QApplication::widgetAt(100, 100))); QCOMPARE(wr->objectName(), QString("w2")); -- cgit v1.2.3 From d1ffc7422e71e42a329f7a9c78b6e584109169f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 4 Nov 2009 13:42:08 +0100 Subject: Extending tst_QFile::writeLargeDataBlock test To test not only native, but fd and FILE* backends as well. Moved expensive generation of large block into a separate function that caches the result. Reviewed-by: Peter Hartmann --- tests/auto/qfile/tst_qfile.cpp | 164 +++++++++++++++++++++++++++++++++-------- 1 file changed, 134 insertions(+), 30 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index 19fbecd239..338ab9c573 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -79,6 +79,10 @@ # define SRCDIR "" #endif +#ifndef QT_OPEN_BINARY +#define QT_OPEN_BINARY 0 +#endif + Q_DECLARE_METATYPE(QFile::FileError) //TESTED_CLASS= @@ -196,6 +200,81 @@ public: // disabled this test for the moment... it hangs void invalidFile_data(); void invalidFile(); + +private: + enum FileType { OpenQFile, OpenFd, OpenStream }; + + bool openFd(QFile &file, QIODevice::OpenMode mode) + { + int fdMode = QT_OPEN_LARGEFILE | QT_OPEN_BINARY; + + // File will be truncated if in Write mode. + if (mode & QIODevice::WriteOnly) + fdMode |= QT_OPEN_WRONLY | QT_OPEN_TRUNC; + if (mode & QIODevice::ReadOnly) + fdMode |= QT_OPEN_RDONLY; + + fd_ = QT_OPEN(qPrintable(file.fileName()), fdMode); + + return (-1 != fd_) && file.open(fd_, mode); + } + + bool openStream(QFile &file, QIODevice::OpenMode mode) + { + char const *streamMode = ""; + + // File will be truncated if in Write mode. + if (mode & QIODevice::WriteOnly) + streamMode = "wb+"; + else if (mode & QIODevice::ReadOnly) + streamMode = "rb"; + + stream_ = QT_FOPEN(qPrintable(file.fileName()), streamMode); + + return stream_ && file.open(stream_, mode); + } + + bool openFile(QFile &file, QIODevice::OpenMode mode, FileType type = OpenQFile) + { + if (mode & QIODevice::WriteOnly && !file.exists()) + { + // Make sure the file exists + QFile createFile(file.fileName()); + if (!createFile.open(QIODevice::ReadWrite)) + return false; + } + + // Note: openFd and openStream will truncate the file if write mode. + switch (type) + { + case OpenQFile: + return file.open(mode); + + case OpenFd: + return openFd(file, mode); + + case OpenStream: + return openStream(file, mode); + } + + return false; + } + + void closeFile(QFile &file) + { + file.close(); + + if (-1 != fd_) + QT_CLOSE(fd_); + if (stream_) + ::fclose(stream_); + + fd_ = -1; + stream_ = 0; + } + + int fd_; + FILE *stream_; }; tst_QFile::tst_QFile() @@ -211,6 +290,8 @@ void tst_QFile::init() { // TODO: Add initialization code here. // This will be executed immediately before each test is run. + fd_ = -1; + stream_ = 0; } void tst_QFile::cleanup() @@ -239,6 +320,11 @@ void tst_QFile::cleanup() QFile::remove("existing-file.txt"); QFile::remove("file-renamed-once.txt"); QFile::remove("file-renamed-twice.txt"); + + if (-1 != fd_) + QT_CLOSE(fd_); + if (stream_) + ::fclose(stream_); } void tst_QFile::initTestCase() @@ -1909,53 +1995,71 @@ void tst_QFile::fullDisk() void tst_QFile::writeLargeDataBlock_data() { QTest::addColumn("fileName"); + QTest::addColumn("type"); + + QTest::newRow("localfile-QFile") << "./largeblockfile.txt" << (int)OpenQFile; + QTest::newRow("localfile-Fd") << "./largeblockfile.txt" << (int)OpenFd; + QTest::newRow("localfile-Stream") << "./largeblockfile.txt" << (int)OpenStream; - QTest::newRow("localfile") << QString("./largeblockfile.txt"); #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) // Some semi-randomness to avoid collisions. QTest::newRow("unc file") << QString("//" + QtNetworkSettings::winServerName() + "/TESTSHAREWRITABLE/largefile-%1-%2.txt") .arg(QHostInfo::localHostName()) - .arg(QTime::currentTime().msec()); + .arg(QTime::currentTime().msec()) << (int)OpenQFile; #endif } -void tst_QFile::writeLargeDataBlock() +static QByteArray getLargeDataBlock() { - QFETCH(QString, fileName); + static QByteArray array; - // Generate a 64MB array with well defined contents. - QByteArray array; + if (array.isNull()) + { #if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) - int resizeSize = 1024 * 1024; // WinCE and Symbian do not have much space + int resizeSize = 1024 * 1024; // WinCE and Symbian do not have much space #else - int resizeSize = 64 * 1024 * 1024; + int resizeSize = 64 * 1024 * 1024; #endif - array.resize(resizeSize); - for (int i = 0; i < array.size(); ++i) - array[i] = uchar(i); + array.resize(resizeSize); + for (int i = 0; i < array.size(); ++i) + array[i] = uchar(i); + } - // Remove and open the target file - QFile file(fileName); - file.remove(); - if (file.open(QFile::WriteOnly)) { - QCOMPARE(file.write(array), qint64(array.size())); - file.close(); - QVERIFY(file.open(QFile::ReadOnly)); - array.clear(); - array = file.readAll(); - file.remove(); - } else { - QFAIL(qPrintable(QString("Couldn't open file for writing: [%1]").arg(fileName))); + return array; +} + +void tst_QFile::writeLargeDataBlock() +{ + QFETCH(QString, fileName); + QFETCH( int, type ); + + QByteArray const originalData = getLargeDataBlock(); + + { + QFile file(fileName); + + QVERIFY2( openFile(file, QIODevice::WriteOnly, (FileType)type), + qPrintable(QString("Couldn't open file for writing: [%1]").arg(fileName)) ); + QCOMPARE( file.write(originalData), (qint64)originalData.size() ); + QVERIFY( file.flush() ); + + closeFile(file); } - // Check that we got the right content - QCOMPARE(array.size(), resizeSize); - for (int i = 0; i < array.size(); ++i) { - if (array[i] != char(i)) { - QFAIL(qPrintable(QString("Wrong contents! Char at %1 = %2, expected %3") - .arg(i).arg(int(uchar(array[i]))).arg(int(uchar(i))))); - } + + QByteArray readData; + + { + QFile file(fileName); + + QVERIFY2( openFile(file, QIODevice::ReadOnly, (FileType)type), + qPrintable(QString("Couldn't open file for reading: [%1]").arg(fileName)) ); + readData = file.readAll(); + closeFile(file); } + + QCOMPARE( readData, originalData ); + QVERIFY( QFile::remove(fileName) ); } void tst_QFile::readFromWriteOnlyFile() -- cgit v1.2.3 From 5c1c3e0366ce6992a514148815ef25b3f1f6f66b Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Wed, 4 Nov 2009 14:45:32 -0300 Subject: QGAL: add names to the items in some tests Those are useful when dumping the graph in dot format for debugging. Signed-off-by: Caio Marcelo de Oliveira Filho Reviewed-by: Eduardo M. Fleury --- tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp | 8 ++++---- tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index c8a9facc2b..09e2ee2c3d 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -1951,7 +1951,7 @@ void tst_QGraphicsAnchorLayout::simplifiableUnfeasible() if (hasSimplification) QVERIFY(!usedSimplex(l, Qt::Horizontal)); - // Now we make it valid again + // Now we make it valid b->setMinimumWidth(100); l->invalidate(); @@ -1979,9 +1979,9 @@ void tst_QGraphicsAnchorLayout::simplificationVsOrder() QSizeF pref(20, 10); QSizeF max(50, 10); - QGraphicsWidget *a = createItem(min, pref, max); - QGraphicsWidget *b = createItem(min, pref, max); - QGraphicsWidget *c = createItem(min, pref, max); + QGraphicsWidget *a = createItem(min, pref, max, "A"); + QGraphicsWidget *b = createItem(min, pref, max, "B"); + QGraphicsWidget *c = createItem(min, pref, max, "C"); QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; diff --git a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp index 1c7a159e34..2d6b44ba87 100644 --- a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp +++ b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp @@ -162,10 +162,14 @@ Q_DECLARE_METATYPE(AnchorItemSizeHintList) class TestWidget : public QGraphicsWidget { public: - inline TestWidget(QGraphicsItem *parent = 0) + inline TestWidget(QGraphicsItem *parent = 0, const QString &name = QString()) : QGraphicsWidget(parent) { setContentsMargins( 0,0,0,0 ); + if (name.isEmpty()) + setData(0, QString::fromAscii("w%1").arg(int(this))); + else + setData(0, name); } ~TestWidget() { @@ -1684,7 +1688,7 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout() // Create dummy widgets QList widgets; for (int i = 0; i < widgetCount; ++i) { - TestWidget *w = new TestWidget; + TestWidget *w = new TestWidget(0, QString::fromAscii("W%1").arg(i)); widgets << w; } -- cgit v1.2.3 From 33faaf6fa1775dc74bb61acde8a48eae2b9f2635 Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Mon, 19 Oct 2009 16:36:53 -0300 Subject: QGAL: Do not restrict maximum size of layout anchors This commit improves the way QGAL handles setups where most anchors or items do not have explicit maximum sizes. By default the internal layout anchors and others, have maximum size of QWIDGETSIZE_MAX. It happens though that this value is rather arbitrary but yet, can restrict the size of other paths in the layout. For instance, in the setup below, where the maximum sizes of A and B is not set: ________ ________ | | item A | | item B | | o---o--------o---o--------o---o | |________| |________| | | | | (layout structural anchor) | o-----------------------------o | | the bottom path, of maximum size QWIDGETSIZE_MAX, restricts the lenght of the path at the top, of maximum size of 2 x QWIDGETSIZE_MAX. This introduces the need of fair distribution in the path A-B. While that's not an issue when the path is simplified to a single anchor, it may lead to unbalanced distributions if such simplification is not possible. As this case may arise when we have center anchors in the top path, it may appear in real-world cases. To work around that, we do not limit the maximum width of the layout anchor or parallel anchors that may have taken its place. The practical result in the example above is that the sizeAtMaximum will be set at 2 x QWIDGETSIZE_MAX, with a good distribution of A and B. On the other hand, this oversized layout is not a problem because the effectiveSizeHint code enforces the respect of QWIDGETSIZE_MAX. That means the layout will interpolate only between zero and QWIDGETSIZE_MAX even though its internal maximum size is twice that value. Signed-off-by: Eduardo M. Fleury Reviewed-by: Caio Marcelo de Oliveira Filho --- tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index 09e2ee2c3d..ce1ffadd85 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -1896,15 +1896,15 @@ void tst_QGraphicsAnchorLayout::infiniteMaxSizes() QGraphicsWidget p; p.setLayout(l); + QCOMPARE(int(p.effectiveSizeHint(Qt::MaximumSize).width()), + QWIDGETSIZE_MAX); + p.resize(200, 10); QCOMPARE(a->geometry(), QRectF(0, 0, 50, 10)); QCOMPARE(b->geometry(), QRectF(50, 0, 50, 10)); QCOMPARE(c->geometry(), QRectF(100, 0, 50, 10)); QCOMPARE(d->geometry(), QRectF(150, 0, 50, 10)); - if (!hasSimplification) - QEXPECT_FAIL("", "Without simplification there is no fair distribution.", Abort); - p.resize(1000, 10); QCOMPARE(a->geometry(), QRectF(0, 0, 450, 10)); QCOMPARE(b->geometry(), QRectF(450, 0, 50, 10)); -- cgit v1.2.3 From 56c04b7f546babf5bbe64a6d0175f635cb2fd204 Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Thu, 29 Oct 2009 16:19:59 -0300 Subject: QGAL: Update infiniteSizes test to avoid simplification The infiniteSizes test is supposed to work w/o simplification, to ensure that I'm adding a central anchor. With this anchor we force the problem to go to the simplex solver and expect it to solve things fine anyway. Signed-off-by: Eduardo M. Fleury Reviewed-by: Caio Marcelo de Oliveira Filho --- tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index ce1ffadd85..00bfe65cfe 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -1882,6 +1882,7 @@ void tst_QGraphicsAnchorLayout::infiniteMaxSizes() QGraphicsWidget *b = createItem(min, pref, max, "b"); QGraphicsWidget *c = createItem(min, pref, max, "c"); QGraphicsWidget *d = createItem(min, pref, max, "d"); + QGraphicsWidget *e = createItem(min, pref, max, "e"); // setAnchor(l, l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0); @@ -1889,6 +1890,8 @@ void tst_QGraphicsAnchorLayout::infiniteMaxSizes() setAnchor(l, b, Qt::AnchorRight, c, Qt::AnchorLeft, 0); setAnchor(l, c, Qt::AnchorRight, d, Qt::AnchorLeft, 0); setAnchor(l, d, Qt::AnchorRight, l, Qt::AnchorRight, 0); + setAnchor(l, b, Qt::AnchorHorizontalCenter, e, Qt::AnchorLeft, 0); + setAnchor(l, e, Qt::AnchorRight, c, Qt::AnchorHorizontalCenter, 0); a->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); c->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); -- cgit v1.2.3 From d4d6901d82476e92f4c318d8d6e9da5d3410920f Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Tue, 27 Oct 2009 18:34:01 -0300 Subject: QGAL (Test): Disable simplification test when that is off Prevent failures when the test is run with QT_ANCHORLAYOUT_NO_SIMPLIFICATION Signed-off-by: Eduardo M. Fleury Reviewed-by: Caio Marcelo de Oliveira Filho --- tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index 00bfe65cfe..53e27dc8da 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -342,8 +342,10 @@ void tst_QGraphicsAnchorLayout::layoutDirection() QCOMPARE(checkReverseDirection(p), true); - QVERIFY(usedSimplex(l, Qt::Horizontal)); - QVERIFY(!usedSimplex(l, Qt::Vertical)); + if (hasSimplification) { + QVERIFY(usedSimplex(l, Qt::Horizontal)); + QVERIFY(!usedSimplex(l, Qt::Vertical)); + } delete p; delete view; -- cgit v1.2.3 From 6c758ba18ded5ed1ac518777cb59e519142d292c Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Tue, 27 Oct 2009 17:29:02 -0300 Subject: QGAL: Avoid false assertions due to floating point precision errors Signed-off-by: Eduardo M. Fleury Reviewed-by: Caio Marcelo de Oliveira Filho --- .../tst_qgraphicsanchorlayout1.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp index 2d6b44ba87..a7ce9be79f 100644 --- a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp +++ b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp @@ -1668,6 +1668,18 @@ inline QGraphicsLayoutItem *getItem( return widgets[index]; } +static QRectF truncate(QRectF original) +{ + QRectF result; + + result.setX(qRound(original.x() * 1000000) / 1000000.0); + result.setY(qRound(original.y() * 1000000) / 1000000.0); + result.setWidth(qRound(original.width() * 1000000) / 1000000.0); + result.setHeight(qRound(original.height() * 1000000) / 1000000.0); + + return result; +} + void tst_QGraphicsAnchorLayout1::testBasicLayout() { QFETCH(QSizeF, size); @@ -1716,7 +1728,10 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout() // Validate for (int i = 0; i < result.count(); ++i) { const BasicLayoutTestResult item = result[i]; - QCOMPARE(widgets[item.index]->geometry(), item.rect); + QRectF expected = truncate(item.rect); + QRectF actual = truncate(widgets[item.index]->geometry()); + + QCOMPARE(expected, actual); } // ###: not supported yet -- cgit v1.2.3 From 95ec02845997c2dee796c680186c46ab29e5e9ce Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Wed, 4 Nov 2009 16:11:58 -0300 Subject: QGAL (test): Test parent widget size besides children sizes Sometimes a test fails due to a wrong child size and we spend a lot of time trying to understand why but, in fact the problem is in the parent size. This commit adds a test to check whether the parent widget was properly resized. Signed-off-by: Eduardo M. Fleury Reviewed-by: Caio Marcelo de Oliveira Filho --- .../qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp index a7ce9be79f..57e5c41be9 100644 --- a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp +++ b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp @@ -1720,10 +1720,8 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout() widget->setLayout(layout); widget->setContentsMargins(0,0,0,0); - widget->setMinimumSize(size); - widget->setMaximumSize(size); - -// QTest::qWait(500); // layouting is asynchronous.. + widget->resize(size); + QCOMPARE(widget->size(), size); // Validate for (int i = 0; i < result.count(); ++i) { @@ -2231,8 +2229,8 @@ void tst_QGraphicsAnchorLayout1::testRemoveCenterAnchor() widget->setLayout(layout); widget->setContentsMargins(0,0,0,0); - widget->setMinimumSize(size); - widget->setMaximumSize(size); + widget->resize(size); + QCOMPARE(widget->size(), size); // Validate for (int i = 0; i < result.count(); ++i) { @@ -3072,8 +3070,8 @@ void tst_QGraphicsAnchorLayout1::testComplexCases() widget->setLayout(layout); widget->setContentsMargins(0,0,0,0); - widget->setMinimumSize(size); - widget->setMaximumSize(size); + widget->resize(size); + QCOMPARE(widget->size(), size); // QTest::qWait(500); // layouting is asynchronous.. -- cgit v1.2.3 From 77f81c95635ecac0fc3516b4a4b71f84ffb56bfd Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Wed, 4 Nov 2009 11:37:53 -0300 Subject: QGAL (test): Remove expanding tests After the removal of the expanding size hint support. Signed-off-by: Eduardo M. Fleury Reviewed-by: Caio Marcelo de Oliveira Filho --- .../tst_qgraphicsanchorlayout.cpp | 238 +-------------------- 1 file changed, 10 insertions(+), 228 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index 53e27dc8da..cc96edbee3 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -79,9 +79,6 @@ private slots: void delete_anchor(); void conflicts(); void sizePolicy(); - void expandingSequence(); - void expandingSequenceFairDistribution(); - void expandingParallel(); void floatConflict(); void infiniteMaxSizes(); void simplifiableUnfeasible(); @@ -1611,217 +1608,6 @@ void tst_QGraphicsAnchorLayout::conflicts() delete p; } -void tst_QGraphicsAnchorLayout::expandingSequence() -{ - QSizeF min(10, 10); - QSizeF pref(50, 10); - QSizeF max(100, 10); - - QGraphicsWidget *a = createItem(min, pref, max, "a"); - QGraphicsWidget *b = createItem(min, pref, max, "b"); - - b->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - - QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; - l->setContentsMargins(0, 0, 0, 0); - - // horizontal - setAnchor(l, l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0); - setAnchor(l, a, Qt::AnchorRight, b, Qt::AnchorLeft, 0); - setAnchor(l, b, Qt::AnchorRight, l, Qt::AnchorRight, 0); - - // vertical - l->addAnchors(l, a, Qt::Vertical); - l->addAnchors(l, b, Qt::Vertical); - - QCOMPARE(l->count(), 2); - - QGraphicsWidget p; - p.setLayout(l); - - QSizeF layoutMinimumSize = l->effectiveSizeHint(Qt::MinimumSize); - QCOMPARE(layoutMinimumSize.width(), qreal(20)); - - QSizeF layoutExpandedSize(pref.width() + max.width(), layoutMinimumSize.height()); - p.resize(layoutExpandedSize); - - QCOMPARE(a->geometry().size(), pref); - QCOMPARE(b->geometry().size(), max); - - QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize); - QCOMPARE(layoutMaximumSize.width(), qreal(200)); - - if (hasSimplification) { - QVERIFY(!usedSimplex(l, Qt::Horizontal)); - QVERIFY(!usedSimplex(l, Qt::Vertical)); - } -} - -void tst_QGraphicsAnchorLayout::expandingSequenceFairDistribution() -{ - QSizeF min(10, 10); - QSizeF pref(50, 10); - QSizeF max(100, 10); - - QGraphicsWidget *a = createItem(min, pref, max, "a"); - QGraphicsWidget *b = createItem(min, pref, max, "b"); - QGraphicsWidget *c = createItem(min, pref, max, "c"); - QGraphicsWidget *d = createItem(min, pref, max, "d"); - - b->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - d->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - - QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; - l->setContentsMargins(0, 0, 0, 0); - - // horizontal - setAnchor(l, l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0); - setAnchor(l, a, Qt::AnchorRight, b, Qt::AnchorLeft, 0); - setAnchor(l, b, Qt::AnchorRight, c, Qt::AnchorLeft, 0); - setAnchor(l, c, Qt::AnchorRight, d, Qt::AnchorLeft, 0); - setAnchor(l, d, Qt::AnchorRight, l, Qt::AnchorRight, 0); - - // vertical - l->addAnchors(l, a, Qt::Vertical); - l->addAnchors(l, b, Qt::Vertical); - l->addAnchors(l, c, Qt::Vertical); - l->addAnchors(l, d, Qt::Vertical); - - QCOMPARE(l->count(), 4); - - QGraphicsWidget p; - p.setLayout(l); - - QSizeF layoutMinimumSize = l->effectiveSizeHint(Qt::MinimumSize); - QCOMPARE(layoutMinimumSize.width(), qreal(40)); - - QSizeF layoutPartialExpandedSize((2 * pref.width()) + (2 * (pref.width() + 10)), - layoutMinimumSize.height()); - p.resize(layoutPartialExpandedSize); - - QCOMPARE(a->geometry().size(), pref); - QCOMPARE(b->geometry().size(), pref + QSizeF(10, 0)); - QCOMPARE(c->geometry().size(), pref); - QCOMPARE(d->geometry().size(), pref + QSizeF(10, 0)); - - QSizeF layoutExpandedSize((2 * pref.width()) + (2 * max.width()), - layoutMinimumSize.height()); - p.resize(layoutExpandedSize); - - QCOMPARE(a->geometry().size(), pref); - QCOMPARE(b->geometry().size(), max); - QCOMPARE(c->geometry().size(), pref); - QCOMPARE(d->geometry().size(), max); - - QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize); - QCOMPARE(layoutMaximumSize.width(), qreal(400)); - - if (hasSimplification) { - QVERIFY(!usedSimplex(l, Qt::Horizontal)); - QVERIFY(!usedSimplex(l, Qt::Vertical)); - } - - // Now we change D to have more "room for growth" from its preferred size - // to its maximum size. We expect a proportional fair distribution. Note that - // this seems to not conform with what QGraphicsLinearLayout does. - d->setMaximumSize(QSizeF(150, 10)); - - QSizeF newLayoutExpandedSize((2 * pref.width()) + (max.width() + 150), - layoutMinimumSize.height()); - p.resize(newLayoutExpandedSize); - - QCOMPARE(a->geometry().size(), pref); - QCOMPARE(b->geometry().size(), max); - QCOMPARE(c->geometry().size(), pref); - QCOMPARE(d->geometry().size(), QSizeF(150, 10)); - - QSizeF newLayoutPartialExpandedSize((4 * pref.width()) + 75, - layoutMinimumSize.height()); - p.resize(newLayoutPartialExpandedSize); - - QCOMPARE(a->geometry().size(), pref); - QCOMPARE(b->geometry().size(), pref + QSizeF(25, 0)); - QCOMPARE(c->geometry().size(), pref); - QCOMPARE(d->geometry().size(), pref + QSizeF(50, 0)); - - if (hasSimplification) { - QVERIFY(!usedSimplex(l, Qt::Horizontal)); - QVERIFY(!usedSimplex(l, Qt::Vertical)); - } -} - -void tst_QGraphicsAnchorLayout::expandingParallel() -{ - QSizeF min(10, 10); - QSizeF pref(50, 10); - QSizeF max(100, 10); - QSizeF max2(100, 50); - - QGraphicsWidget *a = createItem(min, pref, max, "a"); - QGraphicsWidget *b = createItem(min, pref, max, "b"); - QGraphicsWidget *c = createItem(min, pref, max2, "c"); - - b->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - - QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; - l->setContentsMargins(0, 0, 0, 0); - - // horizontal - setAnchor(l, l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0); - setAnchor(l, l, Qt::AnchorLeft, b, Qt::AnchorLeft, 0); - - setAnchor(l, a, Qt::AnchorRight, c, Qt::AnchorLeft, 0); - setAnchor(l, b, Qt::AnchorRight, c, Qt::AnchorLeft, 0); - - setAnchor(l, c, Qt::AnchorRight, l, Qt::AnchorRight, 0); - - // vertical - l->addAnchors(l, c, Qt::Vertical); - setAnchor(l, l, Qt::AnchorTop, a, Qt::AnchorTop, 0); - setAnchor(l, a, Qt::AnchorBottom, c, Qt::AnchorVerticalCenter, 0); - setAnchor(l, b, Qt::AnchorTop, c, Qt::AnchorVerticalCenter, 0); - setAnchor(l, b, Qt::AnchorBottom, l, Qt::AnchorBottom, 0); - - QCOMPARE(l->count(), 3); - - QGraphicsWidget p; - p.setLayout(l); - - QSizeF layoutMinimumSize = l->effectiveSizeHint(Qt::MinimumSize); - QCOMPARE(layoutMinimumSize.width(), qreal(20)); - - QSizeF layoutExpandedSize(pref.width() + max.width(), layoutMinimumSize.height()); - p.resize(layoutExpandedSize); - - QCOMPARE(a->geometry().size(), max); - QCOMPARE(b->geometry().size(), max); - QCOMPARE(c->geometry().size(), QSizeF(pref.width(), 20)); - - QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize); - QCOMPARE(layoutMaximumSize.width(), qreal(200)); - - // - // Change the parallel connection to a paralell connection of b with a center... - // - QGraphicsAnchor *anchor = l->anchor(b, Qt::AnchorRight, c, Qt::AnchorLeft); - delete anchor; - setAnchor(l, b, Qt::AnchorRight, a, Qt::AnchorHorizontalCenter, 0); - a->setMaximumSize(max + QSizeF(100, 0)); - - QSizeF newLayoutMinimumSize = l->effectiveSizeHint(Qt::MinimumSize); - QCOMPARE(newLayoutMinimumSize.width(), qreal(30)); - - QSizeF newLayoutExpandedSize = layoutExpandedSize + QSizeF(100, 0); - p.resize(newLayoutExpandedSize); - - QCOMPARE(a->geometry().size(), max + QSizeF(100, 0)); - QCOMPARE(b->geometry().size(), max); - QCOMPARE(c->geometry().size(), QSizeF(pref.width(), 20)); - - QSizeF newLayoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize); - QCOMPARE(newLayoutMaximumSize.width(), qreal(300)); -} - void tst_QGraphicsAnchorLayout::floatConflict() { QGraphicsWidget *a = createItem(QSizeF(80,10), QSizeF(90,10), QSizeF(100,10), "a"); @@ -1895,9 +1681,6 @@ void tst_QGraphicsAnchorLayout::infiniteMaxSizes() setAnchor(l, b, Qt::AnchorHorizontalCenter, e, Qt::AnchorLeft, 0); setAnchor(l, e, Qt::AnchorRight, c, Qt::AnchorHorizontalCenter, 0); - a->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - c->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - QGraphicsWidget p; p.setLayout(l); @@ -1911,17 +1694,16 @@ void tst_QGraphicsAnchorLayout::infiniteMaxSizes() QCOMPARE(d->geometry(), QRectF(150, 0, 50, 10)); p.resize(1000, 10); - QCOMPARE(a->geometry(), QRectF(0, 0, 450, 10)); - QCOMPARE(b->geometry(), QRectF(450, 0, 50, 10)); - QCOMPARE(c->geometry(), QRectF(500, 0, 450, 10)); - QCOMPARE(d->geometry(), QRectF(950, 0, 50, 10)); - - qreal expMaxSize = (QWIDGETSIZE_MAX - 100.0) / 2; - p.resize(QWIDGETSIZE_MAX, 10); - QCOMPARE(a->geometry(), QRectF(0, 0, expMaxSize, 10)); - QCOMPARE(b->geometry(), QRectF(expMaxSize, 0, 50, 10)); - QCOMPARE(c->geometry(), QRectF(expMaxSize + 50, 0, expMaxSize, 10)); - QCOMPARE(d->geometry(), QRectF(QWIDGETSIZE_MAX - 50, 0, 50, 10)); + QCOMPARE(a->geometry(), QRectF(0, 0, 250, 10)); + QCOMPARE(b->geometry(), QRectF(250, 0, 250, 10)); + QCOMPARE(c->geometry(), QRectF(500, 0, 250, 10)); + QCOMPARE(d->geometry(), QRectF(750, 0, 250, 10)); + + p.resize(40000, 10); + QCOMPARE(a->geometry(), QRectF(0, 0, 10000, 10)); + QCOMPARE(b->geometry(), QRectF(10000, 0, 10000, 10)); + QCOMPARE(c->geometry(), QRectF(20000, 0, 10000, 10)); + QCOMPARE(d->geometry(), QRectF(30000, 0, 10000, 10)); } void tst_QGraphicsAnchorLayout::simplifiableUnfeasible() -- cgit v1.2.3 From 91c09562ed9c6eb1bd3a4dbd84a8cc64647751ee Mon Sep 17 00:00:00 2001 From: Derick Hawcroft Date: Thu, 5 Nov 2009 10:35:48 +1000 Subject: Fix retrieval of SQL type "TIME" information for PostgreSQL PostgreSQL can store/retieve the millisecond part of type "TIME" , so allow it in the API level. Task-number: QTBUG-5251 Reviewed-by: Bill King --- tests/auto/qsqlquery/tst_qsqlquery.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp index 3463153214..87774a3250 100644 --- a/tests/auto/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp @@ -194,6 +194,8 @@ private slots: void sqlServerReturn0_data() { generic_data(); } void sqlServerReturn0(); + void QTBUG_5251_data() { generic_data("QPSQL"); } + void QTBUG_5251(); private: // returns all database connections @@ -2880,5 +2882,35 @@ void tst_QSqlQuery::sqlServerReturn0() QVERIFY_SQL(q, next()); } +void tst_QSqlQuery::QTBUG_5251() +{ + QFETCH( QString, dbName ); + QSqlDatabase db = QSqlDatabase::database( dbName ); + CHECK_DATABASE( db ); + + if (!db.driverName().startsWith( "QPSQL" )) return; + + QSqlQuery q(db); + q.exec("DROP TABLE " + qTableName("timetest")); + QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("timetest") + " (t TIME)")); + QVERIFY_SQL(q, exec("INSERT INTO " + qTableName("timetest") + " VALUES ('1:2:3.666')")); + + QSqlTableModel timetestModel(0,db); + timetestModel.setEditStrategy(QSqlTableModel::OnManualSubmit); + timetestModel.setTable(qTableName("timetest")); + QVERIFY_SQL(timetestModel, select()); + + QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("01:02:03.666")); + QVERIFY_SQL(timetestModel,setData(timetestModel.index(0, 0), QTime(0,12,34,500))); + QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("00:12:34.500")); + QVERIFY_SQL(timetestModel, submitAll()); + QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("00:12:34.500")); + + QVERIFY_SQL(q, exec("UPDATE " + qTableName("timetest") + " SET t = '0:11:22.33'")); + QVERIFY_SQL(timetestModel, select()); + QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("00:11:22.330")); + +} + QTEST_MAIN( tst_QSqlQuery ) #include "tst_qsqlquery.moc" -- cgit v1.2.3 From aa58293b57a05cd52b36ba14a05958dceb65c603 Mon Sep 17 00:00:00 2001 From: Bill King Date: Thu, 5 Nov 2009 14:21:36 +1000 Subject: Cascade delete to cleanup autotest properly. Task-number: QTBUG-5373 --- tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp index e045c1021f..8c840cd1d5 100644 --- a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp +++ b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp @@ -184,8 +184,8 @@ void tst_QSqlRelationalTableModel::dropTestTables( QSqlDatabase db ) << qTableName("casetest1" ); tst_Databases::safeDropTables( db, tableNames ); - db.exec("DROP SCHEMA "+qTableName("QTBUG_5373")); - db.exec("DROP SCHEMA "+qTableName("QTBUG_5373_s2")); + db.exec("DROP SCHEMA "+qTableName("QTBUG_5373")+" CASCADE"); + db.exec("DROP SCHEMA "+qTableName("QTBUG_5373_s2")+" CASCADE"); } void tst_QSqlRelationalTableModel::init() -- cgit v1.2.3 From f1a56f4db2f6d6c395ac6e7023b6e9184140d571 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 5 Nov 2009 11:40:27 +0200 Subject: Fixed symbian-abld build problems with xmlpatternsxqts Qmake generators for symbian can't handle .depends for SUBDIRS values, instead relying on the order of subdirs. Reordered the subdirs as a hot fix to get test case to build before qmake can be properly fixed. Also removed duplicate inclusion of xmlpatterns.pri, which was causing compile time warnings due to duplicate MACRO statements in mmps. Reviewed-by: Janne Koskinen --- tests/auto/xmlpatternsxqts/test/test.pro | 2 -- tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/xmlpatternsxqts/test/test.pro b/tests/auto/xmlpatternsxqts/test/test.pro index 603ae65b26..a69838af5e 100644 --- a/tests/auto/xmlpatternsxqts/test/test.pro +++ b/tests/auto/xmlpatternsxqts/test/test.pro @@ -24,5 +24,3 @@ win32 { else: DESTDIR = ../release } TARGET = tst_xmlpatternsxqts - -include (../../xmlpatterns.pri) diff --git a/tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro b/tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro index a3b13da9c4..39267c8de6 100644 --- a/tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro +++ b/tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro @@ -1,10 +1,10 @@ TEMPLATE = subdirs -SUBDIRS = test contains(QT_CONFIG,xmlpatterns) { SUBDIRS += lib !wince*:lib.file = lib/lib.pro test.depends = lib } +SUBDIRS += test # Needed on the win32-g++ setup and on the test machine arsia. INCLUDEPATH += $$QT_BUILD_TREE/include/QtXmlPatterns/private \ -- cgit v1.2.3 From e7dc9a35aa7b0e16457526647a8884ff3b4da4fe Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 5 Nov 2009 11:08:11 +0100 Subject: Fix textControl so that it ignores mouse press events when needed This fixes the issue in the itemviews that the selection would not change when clicking on rich text labels. Task-number: QTBUG-4516 Reviewed-by: ogoffart --- tests/auto/qtableview/tst_qtableview.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index 227ca6f254..f571e8a87d 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -197,6 +197,7 @@ private slots: void task259308_scrollVerticalHeaderSwappedSections(); void task191545_dragSelectRows(); void taskQTBUG_5062_spansInconsistency(); + void taskQTBUG_4516_clickOnRichTextLabel(); void mouseWheel_data(); void mouseWheel(); @@ -3885,6 +3886,24 @@ void tst_QTableView::taskQTBUG_5062_spansInconsistency() VERIFY_SPANS_CONSISTENCY(&view); } +void tst_QTableView::taskQTBUG_4516_clickOnRichTextLabel() +{ + QTableView view; + QStandardItemModel model(5,5); + view.setModel(&model); + QLabel label("rich text"); + label.setTextFormat(Qt::RichText); + view.setIndexWidget(model.index(1,1), &label); + view.setCurrentIndex(model.index(0,0)); + QCOMPARE(view.currentIndex(), model.index(0,0)); + + QTest::mouseClick(&label, Qt::LeftButton); + QCOMPARE(view.currentIndex(), model.index(1,1)); + + +} + + void tst_QTableView::changeHeaderData() { QTableView view; -- cgit v1.2.3 From ec13cf30f10dabce37af3ce9d6763066e8cf4cc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Thu, 5 Nov 2009 11:21:31 +0100 Subject: Removed the FBO stacking behaviour and the test attached to it. Having this behaviour in QGLFrameBufferObject complicates alot of things and isn't really necessary. Reviewed-by: Tom Cooksey --- tests/auto/qgl/tst_qgl.cpp | 105 --------------------------------------------- 1 file changed, 105 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index e9f0476e0b..c680decc01 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -82,7 +82,6 @@ private slots: void glPBufferRendering(); void glWidgetReparent(); void glWidgetRenderPixmap(); - void stackedFBOs(); void colormap(); void fboFormat(); void testDontCrashOnDanglingResources(); @@ -1226,110 +1225,6 @@ void tst_QGL::glWidgetRenderPixmap() QCOMPARE(fb, reference); } - -// When using multiple FBOs at the same time, unbinding one FBO should re-bind the -// previous. I.e. It should be possible to have a stack of FBOs where pop'ing there -// top re-binds the one underneeth. -void tst_QGL::stackedFBOs() -{ - if (!QGLFramebufferObject::hasOpenGLFramebufferObjects()) - QSKIP("QGLFramebufferObject not supported on this platform", SkipSingle); - - QGLWidget glw; - glw.show(); - -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&glw); -#endif - QTest::qWait(200); - - glw.makeCurrent(); - - // No multisample with combined depth/stencil attachment: - QGLFramebufferObjectFormat fboFormat; - fboFormat.setAttachment(QGLFramebufferObject::CombinedDepthStencil); - - // Don't complicate things by using NPOT: - QGLFramebufferObject *fbo1 = new QGLFramebufferObject(128, 128, fboFormat); - QGLFramebufferObject *fbo2 = new QGLFramebufferObject(128, 128, fboFormat); - QGLFramebufferObject *fbo3 = new QGLFramebufferObject(128, 128, fboFormat); - - glClearColor(1.0, 0.0, 1.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - - fbo1->bind(); - glClearColor(1.0, 0.0, 0.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - - fbo2->bind(); - glClearColor(0.0, 1.0, 0.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - - fbo3->bind(); - glClearColor(0.0, 0.0, 1.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - glScissor(32, 32, 64, 64); - glEnable(GL_SCISSOR_TEST); - glClearColor(0.0, 1.0, 1.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - fbo3->release(); - - // Scissor rect & test should be left untouched by the fbo release... - glClearColor(0.0, 0.0, 0.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - fbo2->release(); - - glClearColor(1.0, 1.0, 1.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - fbo1->release(); - - glClearColor(1.0, 1.0, 0.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - - glw.swapBuffers(); - - QImage widgetFB = glw.grabFrameBuffer(false).convertToFormat(QImage::Format_RGB32); - QImage fb1 = fbo1->toImage().convertToFormat(QImage::Format_RGB32); - QImage fb2 = fbo2->toImage().convertToFormat(QImage::Format_RGB32); - QImage fb3 = fbo3->toImage().convertToFormat(QImage::Format_RGB32); - - delete fbo1; - delete fbo2; - delete fbo3; - - QImage widgetReference(widgetFB.size(), widgetFB.format()); - QImage fb1Reference(fb1.size(), fb1.format()); - QImage fb2Reference(fb2.size(), fb2.format()); - QImage fb3Reference(fb3.size(), fb3.format()); - - QPainter widgetReferencePainter(&widgetReference); - QPainter fb1ReferencePainter(&fb1Reference); - QPainter fb2ReferencePainter(&fb2Reference); - QPainter fb3ReferencePainter(&fb3Reference); - - widgetReferencePainter.fillRect(0, 0, widgetReference.width(), widgetReference.height(), Qt::magenta); - fb1ReferencePainter.fillRect(0, 0, fb1Reference.width(), fb1Reference.height(), Qt::red); - fb2ReferencePainter.fillRect(0, 0, fb2Reference.width(), fb2Reference.height(), Qt::green); - fb3ReferencePainter.fillRect(0, 0, fb3Reference.width(), fb3Reference.height(), Qt::blue); - - // Flip y-coords to match GL for the widget (which can be any size) - widgetReferencePainter.fillRect(32, glw.height() - 96, 64, 64, Qt::yellow); - fb1ReferencePainter.fillRect(32, 32, 64, 64, Qt::white); - fb2ReferencePainter.fillRect(32, 32, 64, 64, Qt::black); - fb3ReferencePainter.fillRect(32, 32, 64, 64, Qt::cyan); - - widgetReferencePainter.end(); - fb1ReferencePainter.end(); - fb2ReferencePainter.end(); - fb3ReferencePainter.end(); - - QCOMPARE(widgetFB, widgetReference); - QCOMPARE(fb1, fb1Reference); - QCOMPARE(fb2, fb2Reference); - QCOMPARE(fb3, fb3Reference); -} - - class ColormapExtended : public QGLColormap { public: -- cgit v1.2.3 From ff87ab95b42c87528c4dff16382a5894c6ddd4c3 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 5 Nov 2009 11:44:17 +0100 Subject: Fix autotest to match API changes --- tests/auto/qanimationgroup/tst_qanimationgroup.cpp | 84 +++++++++++----------- 1 file changed, 42 insertions(+), 42 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qanimationgroup/tst_qanimationgroup.cpp b/tests/auto/qanimationgroup/tst_qanimationgroup.cpp index 81c51eddde..b4e4a491fd 100644 --- a/tests/auto/qanimationgroup/tst_qanimationgroup.cpp +++ b/tests/auto/qanimationgroup/tst_qanimationgroup.cpp @@ -165,9 +165,9 @@ void tst_QAnimationGroup::emptyGroup() QCOMPARE(groupStateChangedSpy.count(), 2); - QCOMPARE(qVariantValue(groupStateChangedSpy.at(0).at(1)), + QCOMPARE(qVariantValue(groupStateChangedSpy.at(0).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(groupStateChangedSpy.at(1).at(1)), + QCOMPARE(qVariantValue(groupStateChangedSpy.at(1).first()), QAnimationGroup::Stopped); QCOMPARE(group.state(), QAnimationGroup::Stopped); @@ -180,9 +180,9 @@ void tst_QAnimationGroup::emptyGroup() group.start(); - QCOMPARE(qVariantValue(groupStateChangedSpy.at(2).at(1)), + QCOMPARE(qVariantValue(groupStateChangedSpy.at(2).first()), QAnimationGroup::Running); - QCOMPARE(qVariantValue(groupStateChangedSpy.at(3).at(1)), + QCOMPARE(qVariantValue(groupStateChangedSpy.at(3).first()), QAnimationGroup::Stopped); QCOMPARE(group.state(), QAnimationGroup::Stopped); @@ -259,54 +259,54 @@ void tst_QAnimationGroup::setCurrentTime() QCOMPARE(notTimeDriven->state(), QAnimationGroup::Stopped); QCOMPARE(loopsForever->state(), QAnimationGroup::Stopped); - QCOMPARE(group.currentTime(), 1); - QCOMPARE(sequence->currentTime(), 1); - QCOMPARE(a1_s_o1->currentTime(), 1); - QCOMPARE(a2_s_o1->currentTime(), 0); - QCOMPARE(a3_s_o1->currentTime(), 0); - QCOMPARE(a1_s_o2->currentTime(), 1); - QCOMPARE(a1_s_o3->currentTime(), 0); - QCOMPARE(a1_p_o1->currentTime(), 1); - QCOMPARE(a1_p_o2->currentTime(), 1); - QCOMPARE(a1_p_o3->currentTime(), 1); - QCOMPARE(notTimeDriven->currentTime(), 1); - QCOMPARE(loopsForever->currentTime(), 1); + QCOMPARE(group.currentLoopTime(), 1); + QCOMPARE(sequence->currentLoopTime(), 1); + QCOMPARE(a1_s_o1->currentLoopTime(), 1); + QCOMPARE(a2_s_o1->currentLoopTime(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 0); + QCOMPARE(a1_s_o2->currentLoopTime(), 1); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); + QCOMPARE(a1_p_o1->currentLoopTime(), 1); + QCOMPARE(a1_p_o2->currentLoopTime(), 1); + QCOMPARE(a1_p_o3->currentLoopTime(), 1); + QCOMPARE(notTimeDriven->currentLoopTime(), 1); + QCOMPARE(loopsForever->currentLoopTime(), 1); // Current time = 250 group.setCurrentTime(250); - QCOMPARE(group.currentTime(), 250); - QCOMPARE(sequence->currentTime(), 250); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentTime(), 0); - QCOMPARE(a3_s_o1->currentTime(), 0); - QCOMPARE(a1_s_o2->currentTime(), 250); - QCOMPARE(a1_s_o3->currentTime(), 0); - QCOMPARE(a1_p_o1->currentTime(), 250); - QCOMPARE(a1_p_o2->currentTime(), 0); + QCOMPARE(group.currentLoopTime(), 250); + QCOMPARE(sequence->currentLoopTime(), 250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 0); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); + QCOMPARE(a1_p_o1->currentLoopTime(), 250); + QCOMPARE(a1_p_o2->currentLoopTime(), 0); QCOMPARE(a1_p_o2->currentLoop(), 1); - QCOMPARE(a1_p_o3->currentTime(), 250); - QCOMPARE(notTimeDriven->currentTime(), 250); - QCOMPARE(loopsForever->currentTime(), 0); + QCOMPARE(a1_p_o3->currentLoopTime(), 250); + QCOMPARE(notTimeDriven->currentLoopTime(), 250); + QCOMPARE(loopsForever->currentLoopTime(), 0); QCOMPARE(loopsForever->currentLoop(), 1); QCOMPARE(sequence->currentAnimation(), a2_s_o1); // Current time = 251 group.setCurrentTime(251); - QCOMPARE(group.currentTime(), 251); - QCOMPARE(sequence->currentTime(), 251); - QCOMPARE(a1_s_o1->currentTime(), 250); - QCOMPARE(a2_s_o1->currentTime(), 1); + QCOMPARE(group.currentLoopTime(), 251); + QCOMPARE(sequence->currentLoopTime(), 251); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 1); QCOMPARE(a2_s_o1->currentLoop(), 0); - QCOMPARE(a3_s_o1->currentTime(), 0); - QCOMPARE(sequence2->currentTime(), 251); - QCOMPARE(a1_s_o2->currentTime(), 250); - QCOMPARE(a1_s_o3->currentTime(), 1); - QCOMPARE(a1_p_o1->currentTime(), 250); - QCOMPARE(a1_p_o2->currentTime(), 1); + QCOMPARE(a3_s_o1->currentLoopTime(), 0); + QCOMPARE(sequence2->currentLoopTime(), 251); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(a1_s_o3->currentLoopTime(), 1); + QCOMPARE(a1_p_o1->currentLoopTime(), 250); + QCOMPARE(a1_p_o2->currentLoopTime(), 1); QCOMPARE(a1_p_o2->currentLoop(), 1); - QCOMPARE(a1_p_o3->currentTime(), 250); - QCOMPARE(notTimeDriven->currentTime(), 251); - QCOMPARE(loopsForever->currentTime(), 1); + QCOMPARE(a1_p_o3->currentLoopTime(), 250); + QCOMPARE(notTimeDriven->currentLoopTime(), 251); + QCOMPARE(loopsForever->currentLoopTime(), 1); QCOMPARE(sequence->currentAnimation(), a2_s_o1); } @@ -356,7 +356,7 @@ void tst_QAnimationGroup::addChildTwice() parent->addAnimation(subGroup); QCOMPARE(parent->animationCount(), 1); - parent->clearAnimations(); + parent->clear(); QCOMPARE(parent->animationCount(), 0); -- cgit v1.2.3 From 4bf7f90a27377f439e86d6175e5e3cdebd131be0 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Thu, 5 Nov 2009 12:12:22 +0100 Subject: Always set a clip on the painter in QGraphicsView. This allows items to check painter->clipRegion() to find out what the imposed clip is, in order to cull elements that don't need to be painted. This is an alternative approach to getting the same information from QStyleOptionGraphicsItem::exposedRect. It's better because it's a pull operation, but it's slightly worse because it doesn't include the complete system clip, and because QRegion has integer resolution only (whereas QGraphicsItem's coordinate uses qreal. A better approach may be to access QPainter's combined clip region; this option is open for future versions of Qt. Original patch by Warwick (which is why he's on reviewed-by), but the patch was modified to operate in device instead of logical coordinates. Reviewed-by: jasplin Reviewed-by: Warwick Allison --- tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 72 ++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index f07453cea4..9c6aa393e6 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -217,6 +217,7 @@ private slots: void update(); void inputMethodSensitivity(); void inputContextReset(); + void defaultClipIntersectToView(); // task specific tests below me void task172231_untransformableItems(); @@ -3692,6 +3693,77 @@ 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; -- cgit v1.2.3 From d456ac11027f7573aa32745a8bc972d2b83926f4 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 5 Nov 2009 14:17:56 +0100 Subject: Add test for QEventTransition when filtering on a QApplication instance Test for 8ec037effce7f515fffed6b05c011e385fb52593. Reviewed-by: Gunnar --- tests/auto/qstatemachine/tst_qstatemachine.cpp | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index 9a2b2edf1a..fd39515a98 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -208,6 +208,7 @@ private slots: void task260403_clonedSignals(); void postEventFromOtherThread(); + void eventFilterForApplication(); }; tst_QStateMachine::tst_QStateMachine() @@ -4276,5 +4277,35 @@ void tst_QStateMachine::postEventFromOtherThread() QTRY_COMPARE(finishedSpy.count(), 1); } +void tst_QStateMachine::eventFilterForApplication() +{ + QStateMachine machine; + + QState *s1 = new QState(&machine); + { + machine.setInitialState(s1); + } + + QState *s2 = new QState(&machine); + + QEventTransition *transition = new QEventTransition(QCoreApplication::instance(), + QEvent::ApplicationActivate); + transition->setTargetState(s2); + s1->addTransition(transition); + + machine.start(); + QCoreApplication::processEvents(); + + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s1)); + + QCoreApplication::postEvent(QCoreApplication::instance(), + new QEvent(QEvent::ApplicationActivate)); + QCoreApplication::processEvents(); + + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s2)); +} + QTEST_MAIN(tst_QStateMachine) #include "tst_qstatemachine.moc" -- cgit v1.2.3 From 24675593113167bfffcb4791e9c3e0865a0c3244 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Thu, 5 Nov 2009 14:38:35 +0100 Subject: Improve the reliability of tst_QGridLayout::minMaxSize() As indicated by the comments, if the test fails, the timeouts may need to be increased. Since this is failing on the test cluster, where CPU time is limited, doubling the timeouts seems to do the trick. Reviewed-by: Richard Moe Gustavsen --- tests/auto/qgridlayout/tst_qgridlayout.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qgridlayout/tst_qgridlayout.cpp b/tests/auto/qgridlayout/tst_qgridlayout.cpp index 7c320be2ef..46e2a03c32 100644 --- a/tests/auto/qgridlayout/tst_qgridlayout.cpp +++ b/tests/auto/qgridlayout/tst_qgridlayout.cpp @@ -920,9 +920,9 @@ void tst_QGridLayout::minMaxSize() #if defined(Q_WS_X11) qt_x11_wait_for_window_manager(m_toplevel); // wait for the show #endif - QTest::qWait(20); + QTest::qWait(40); m_toplevel->adjustSize(); - QTest::qWait(120); // wait for the implicit adjustSize + QTest::qWait(240); // wait for the implicit adjustSize // If the following fails we might have to wait longer. // If that does not help there is likely a problem with the implicit adjustSize in show() if (!fixedSize.isValid()) { -- cgit v1.2.3 From c4d8d7fd35c8ac7fd2c14208e5e7ca0a35c101e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 5 Nov 2009 16:15:26 +0100 Subject: Switch large file test to using Unbuffered mode ... so we test the file engine directly and detect file-system errors earlier. --- tests/auto/qfile/largefile/tst_largefile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qfile/largefile/tst_largefile.cpp b/tests/auto/qfile/largefile/tst_largefile.cpp index 53dbc127a8..8ab3275c0c 100644 --- a/tests/auto/qfile/largefile/tst_largefile.cpp +++ b/tests/auto/qfile/largefile/tst_largefile.cpp @@ -312,10 +312,10 @@ void tst_LargeFile::createSparseFile() int fd = ::_open_osfhandle((intptr_t)handle, 0); QVERIFY( -1 != fd ); - QVERIFY( largeFile.open(fd, QIODevice::WriteOnly) ); + QVERIFY( largeFile.open(fd, QIODevice::WriteOnly | QIODevice::Unbuffered) ); #else // !Q_OS_WIN largeFile.setFileName("qt_largefile.tmp"); - QVERIFY( largeFile.open(QIODevice::WriteOnly) ); + QVERIFY( largeFile.open(QIODevice::WriteOnly | QIODevice::Unbuffered) ); #endif } -- cgit v1.2.3 From 3c0b6de86ce044ce6f3f4a445d1de90b4e7bb1d9 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 6 Nov 2009 10:10:46 +0100 Subject: Updated testcase since soft-light algorithm rewrite. The SVG standard changed the algorithm which implies some changes to the results as well. Reviewed-by: Kim --- tests/auto/qpainter/tst_qpainter.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 8ed83cb851..bcdbe56671 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -4193,9 +4193,9 @@ void tst_QPainter::extendedBlendModes() QVERIFY(testCompositionMode(255, 255, 255, QPainter::CompositionMode_SoftLight)); QVERIFY(testCompositionMode( 0, 0, 0, QPainter::CompositionMode_SoftLight)); - QVERIFY(testCompositionMode(127, 127, 127, QPainter::CompositionMode_SoftLight)); - QVERIFY(testCompositionMode( 63, 63, 86, QPainter::CompositionMode_SoftLight)); - QVERIFY(testCompositionMode(127, 63, 63, QPainter::CompositionMode_SoftLight)); + QVERIFY(testCompositionMode(127, 127, 126, QPainter::CompositionMode_SoftLight)); + QVERIFY(testCompositionMode( 63, 63, 39, QPainter::CompositionMode_SoftLight)); + QVERIFY(testCompositionMode(127, 63, 62, QPainter::CompositionMode_SoftLight)); QVERIFY(testCompositionMode(255, 255, 0, QPainter::CompositionMode_Difference)); QVERIFY(testCompositionMode( 0, 0, 0, QPainter::CompositionMode_Difference)); -- cgit v1.2.3 From f8a0b7b9ea2e077be7167c58d4eac27360d4cee6 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 5 Nov 2009 13:11:03 +0100 Subject: QGraphicsView: Fixes QGraphicsView::focusItem when scene is not active When scene is not active, returns the item that would get the focus if the scene became active. This is more consistant with Qt 4.5 behaviour Reviewed-by: Andreas --- tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index 4f76dddf74..c81bd644ce 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -225,6 +225,7 @@ private slots: void focusItem(); void focusItemLostFocus(); void setFocusItem(); + void setFocusItem_inactive(); void mouseGrabberItem(); void hoverEvents_siblings(); void hoverEvents_parentChild(); @@ -1534,6 +1535,26 @@ void tst_QGraphicsScene::setFocusItem() QVERIFY(!item2->hasFocus()); } +void tst_QGraphicsScene::setFocusItem_inactive() +{ + QGraphicsScene scene; + QGraphicsItem *item = scene.addText("Qt"); + QVERIFY(!scene.focusItem()); + QVERIFY(!scene.hasFocus()); + scene.setFocusItem(item); + QVERIFY(!scene.hasFocus()); + QVERIFY(!scene.focusItem()); + item->setFlag(QGraphicsItem::ItemIsFocusable); + + for (int i = 0; i < 3; ++i) { + scene.setFocusItem(item); + QCOMPARE(scene.focusItem(), item); + QVERIFY(!item->hasFocus()); + } + +} + + void tst_QGraphicsScene::mouseGrabberItem() { QGraphicsScene scene; @@ -3130,6 +3151,7 @@ void tst_QGraphicsScene::tabFocus_sceneWithFocusableItems() QVERIFY(!view->viewport()->hasFocus()); QVERIFY(!scene.hasFocus()); QVERIFY(!item->hasFocus()); + QCOMPARE(scene.focusItem(), static_cast(item)); // Check that the correct item regains focus. widget.show(); -- cgit v1.2.3 From d9c226c72105ef221c766cb9f616d10329197880 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 5 Nov 2009 15:36:15 +0100 Subject: Fix QGraphicsScene::isActive if the view is shown while the window is active. We need to make sure the active state is preserved if graphicsview are dinamically shown/hide while window is active. Or if scene is changed with setScene. This fixes KRunner focus regressions Reviewed-by: Andreas Task-number: QTBUG-5281 --- tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 178 +++++++++++++++++++++++ 1 file changed, 178 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index c81bd644ce..9a561ebc11 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -268,6 +268,7 @@ private slots: void initialFocus_data(); void initialFocus(); void polishItems(); + void isActive(); // task specific tests below me void task139710_bspTreeCrash(); @@ -3159,8 +3160,10 @@ void tst_QGraphicsScene::tabFocus_sceneWithFocusableItems() widget.activateWindow(); QTest::qWaitForWindowShown(&widget); QTRY_VERIFY(view->hasFocus()); + QTRY_VERIFY(scene.isActive()); QVERIFY(view->viewport()->hasFocus()); QVERIFY(scene.hasFocus()); + QCOMPARE(scene.focusItem(), static_cast(item)); QVERIFY(item->hasFocus()); } @@ -3952,5 +3955,180 @@ void tst_QGraphicsScene::polishItems() QMetaObject::invokeMethod(&scene,"_q_polishItems"); } +void tst_QGraphicsScene::isActive() +{ + QGraphicsScene scene1; + QVERIFY(!scene1.isActive()); + QGraphicsScene scene2; + QVERIFY(!scene2.isActive()); + + { + QWidget toplevel1; + QHBoxLayout *layout = new QHBoxLayout; + toplevel1.setLayout(layout); + QGraphicsView *view1 = new QGraphicsView(&scene1); + QGraphicsView *view2 = new QGraphicsView(&scene2); + layout->addWidget(view1); + layout->addWidget(view2); + + QVERIFY(!scene1.isActive()); + QVERIFY(!scene2.isActive()); + + view1->setVisible(false); + + toplevel1.show(); + QApplication::setActiveWindow(&toplevel1); + QTest::qWaitForWindowShown(&toplevel1); + QTRY_COMPARE(QApplication::activeWindow(), &toplevel1); + + QVERIFY(!scene1.isActive()); //it is hidden; + QVERIFY(scene2.isActive()); + + view1->show(); + QVERIFY(scene1.isActive()); + QVERIFY(scene2.isActive()); + + view2->hide(); + + QVERIFY(scene1.isActive()); + QVERIFY(!scene2.isActive()); + + toplevel1.hide(); + QTest::qWait(12); + QTRY_VERIFY(!scene1.isActive()); + QTRY_VERIFY(!scene2.isActive()); + + toplevel1.show(); + QApplication::setActiveWindow(&toplevel1); + QApplication::processEvents(); + QTRY_COMPARE(QApplication::activeWindow(), &toplevel1); + + QTRY_VERIFY(scene1.isActive()); + QTRY_VERIFY(!scene2.isActive()); + + view2->show(); + QVERIFY(scene1.isActive()); + QVERIFY(scene2.isActive()); + } + + QVERIFY(!scene1.isActive()); + QVERIFY(!scene2.isActive()); + + { + QWidget toplevel2; + QHBoxLayout *layout = new QHBoxLayout; + toplevel2.setLayout(layout); + QGraphicsView *view1 = new QGraphicsView(&scene1); + QGraphicsView *view2 = new QGraphicsView(); + layout->addWidget(view1); + layout->addWidget(view2); + + QVERIFY(!scene1.isActive()); + QVERIFY(!scene2.isActive()); + + toplevel2.show(); + QApplication::setActiveWindow(&toplevel2); + QTest::qWaitForWindowShown(&toplevel2); + QTRY_COMPARE(QApplication::activeWindow(), &toplevel2); + + QVERIFY(scene1.isActive()); + QVERIFY(!scene2.isActive()); + + view2->setScene(&scene2); + + QVERIFY(scene1.isActive()); + QVERIFY(scene2.isActive()); + + view1->setScene(&scene2); + QVERIFY(!scene1.isActive()); + QVERIFY(scene2.isActive()); + + view1->hide(); + QVERIFY(!scene1.isActive()); + QVERIFY(scene2.isActive()); + + view1->setScene(&scene1); + QVERIFY(!scene1.isActive()); + QVERIFY(scene2.isActive()); + + view1->show(); + + view1->show(); + QVERIFY(scene1.isActive()); + QVERIFY(scene2.isActive()); + + view2->hide(); + QVERIFY(scene1.isActive()); + QVERIFY(!scene2.isActive()); + + QGraphicsView topLevelView; + topLevelView.show(); + QApplication::setActiveWindow(&topLevelView); + QTest::qWaitForWindowShown(&topLevelView); + QTRY_COMPARE(QApplication::activeWindow(), static_cast(&topLevelView)); + + QVERIFY(!scene1.isActive()); + QVERIFY(!scene2.isActive()); + + topLevelView.setScene(&scene1); + QVERIFY(scene1.isActive()); + QVERIFY(!scene2.isActive()); + + view2->show(); + QVERIFY(scene1.isActive()); + QVERIFY(!scene2.isActive()); + + view1->hide(); + QVERIFY(scene1.isActive()); + QVERIFY(!scene2.isActive()); + + QApplication::setActiveWindow(&toplevel2); + QTRY_COMPARE(QApplication::activeWindow(), &toplevel2); + + QVERIFY(!scene1.isActive()); + QVERIFY(scene2.isActive()); + + + } + + QVERIFY(!scene1.isActive()); + QVERIFY(!scene2.isActive()); + + { + QWidget toplevel3; + QHBoxLayout *layout = new QHBoxLayout; + toplevel3.setLayout(layout); + QGraphicsView *view1 = new QGraphicsView(&scene1); + QGraphicsView *view2 = new QGraphicsView(&scene2); + layout->addWidget(view1); + + QVERIFY(!scene1.isActive()); + QVERIFY(!scene2.isActive()); + + toplevel3.show(); + QApplication::setActiveWindow(&toplevel3); + QTest::qWaitForWindowShown(&toplevel3); + QTRY_COMPARE(QApplication::activeWindow(), &toplevel3); + + QVERIFY(scene1.isActive()); + QVERIFY(!scene2.isActive()); + + layout->addWidget(view2); + QApplication::processEvents(); + QVERIFY(scene1.isActive()); + QVERIFY(scene2.isActive()); + + view1->setParent(0); + QVERIFY(!scene1.isActive()); + QVERIFY(scene2.isActive()); + delete view1; + } + + QVERIFY(!scene1.isActive()); + QVERIFY(!scene2.isActive()); + +} + + QTEST_MAIN(tst_QGraphicsScene) #include "tst_qgraphicsscene.moc" -- cgit v1.2.3 From 9b500e9a09907f05002bd0e57869c5312ae101db Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 6 Nov 2009 12:59:35 +0100 Subject: Fix QPainter::setPen(pen with color but no style) on non-extended. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was working with a QImage but not with a QPixmap, which is obviously a bug. In addition, it broke WebCore::GraphicsContext::setPlatformStrokeColor which does exactly what I put in the unittest: get pen, set color, set pen. This commit fixes the wrong color in the underline of the links in http://www.davidfaure.fr/kde/link_underline_color.html in QtWebkit. Merge-request: 1995 Reviewed-by: Samuel Rødal --- tests/auto/qpainter/tst_qpainter.cpp | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index bcdbe56671..4d2c6266ba 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -239,9 +239,12 @@ private slots: void taskQT4444_dontOverflowDashOffset(); void painterBegin(); + void setPenColorOnImage(); + void setPenColorOnPixmap(); private: void fillData(); + void setPenColor(QPainter& p); QColor baseColor( int k, int intensity=255 ); QImage getResImage( const QString &dir, const QString &addition, const QString &extension ); QBitmap getBitmap( const QString &dir, const QString &filename, bool mask ); @@ -4352,5 +4355,41 @@ void tst_QPainter::painterBegin() QVERIFY(!p.end()); } +void tst_QPainter::setPenColor(QPainter& p) +{ + p.setPen(Qt::NoPen); + + // Setting color, then style + // Should work even though the pen is "NoPen with color", temporarily. + QPen newPen(p.pen()); + newPen.setColor(Qt::red); + QCOMPARE(p.pen().style(), newPen.style()); + QCOMPARE(p.pen().style(), Qt::NoPen); + p.setPen(newPen); + + QCOMPARE(p.pen().color().name(), QString("#ff0000")); + + QPen newPen2(p.pen()); + newPen2.setStyle(Qt::SolidLine); + p.setPen(newPen2); + + QCOMPARE(p.pen().color().name(), QString("#ff0000")); +} + +void tst_QPainter::setPenColorOnImage() +{ + QImage img(QSize(10, 10), QImage::Format_ARGB32_Premultiplied); + QPainter p(&img); + setPenColor(p); +} + +void tst_QPainter::setPenColorOnPixmap() +{ + QPixmap pix(10, 10); + QPainter p(&pix); + setPenColor(p); +} + QTEST_MAIN(tst_QPainter) + #include "tst_qpainter.moc" -- cgit v1.2.3 From 4ad6343be52b757fd354cd92874bca944d2ede49 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Fri, 6 Nov 2009 15:15:05 +0100 Subject: Add preliminary QAccessibleImage interface As requested by the Maemo team. --- tests/auto/qaccessibility/tst_qaccessibility.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp index 9f2e4e7afb..25c2649e43 100644 --- a/tests/auto/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp @@ -4034,6 +4034,27 @@ void tst_QAccessibility::labelTest() delete acc_label; delete label; QTestAccessibility::clearEvents(); + + QPixmap testPixmap(50, 50); + testPixmap.fill(); + + QLabel imageLabel; + imageLabel.setPixmap(testPixmap); + imageLabel.setToolTip("Test Description"); + + acc_label = QAccessible::queryAccessibleInterface(&imageLabel); + QVERIFY(acc_label); + + QAccessibleImageInterface *imageInterface = acc_label->imageInterface(); + QVERIFY(imageInterface); + + QCOMPARE(imageInterface->imageSize(), testPixmap.size()); + QCOMPARE(imageInterface->imageDescription(), QString::fromLatin1("Test Description")); + QCOMPARE(imageInterface->imagePosition(QAccessible2::RelativeToParent), imageLabel.geometry()); + + delete acc_label; + + QTestAccessibility::clearEvents(); #else QSKIP("Test needs accessibility support.", SkipAll); #endif -- cgit v1.2.3 From 98e0b95581f46b94773a55195e0e67a466c333ed Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Thu, 5 Nov 2009 15:18:35 +0100 Subject: API review: QRegExp::numCaptures() -> QRegExp::captureCount() QRegExp::numCaptures() is marked as obsolete. Replaced all usage in Qt and test-cases. Reviewed-by: Andreas Aardal Hanssen --- tests/auto/qregexp/tst_qregexp.cpp | 28 +++++++++++++------------- tests/auto/qscriptengine/tst_qscriptengine.cpp | 2 +- tests/auto/qtextdocument/tst_qtextdocument.cpp | 10 ++++----- 3 files changed, 20 insertions(+), 20 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qregexp/tst_qregexp.cpp b/tests/auto/qregexp/tst_qregexp.cpp index 86d831e8ad..e3053865cf 100644 --- a/tests/auto/qregexp/tst_qregexp.cpp +++ b/tests/auto/qregexp/tst_qregexp.cpp @@ -628,7 +628,7 @@ void tst_QRegExp::capturedTexts() QRegExp rx7("([A-Za-z_])([A-Za-z_0-9]*)"); rx7.setCaseSensitivity(Qt::CaseSensitive); rx7.setPatternSyntax(QRegExp::RegExp); - QCOMPARE(rx7.numCaptures(), 2); + QCOMPARE(rx7.captureCount(), 2); int pos = rx7.indexIn("(10 + delta4) * 32"); QCOMPARE(pos, 6); @@ -1177,36 +1177,36 @@ void tst_QRegExp::prepareEngineOptimization() QCOMPARE(rx1.capturedTexts(), QStringList() << "" << "" << "" << ""); QCOMPARE(rx1.matchedLength(), -1); QCOMPARE(rx1.matchedLength(), -1); - QCOMPARE(rx1.numCaptures(), 3); + QCOMPARE(rx1.captureCount(), 3); QCOMPARE(rx1.exactMatch("foo"), true); QCOMPARE(rx1.matchedLength(), 3); QCOMPARE(rx1.capturedTexts(), QStringList() << "foo" << "f" << "o" << "o"); - QCOMPARE(rx1.numCaptures(), 3); + QCOMPARE(rx1.captureCount(), 3); QCOMPARE(rx1.matchedLength(), 3); QCOMPARE(rx1.capturedTexts(), QStringList() << "foo" << "f" << "o" << "o"); QCOMPARE(rx1.pos(3), 2); QCOMPARE(rx1.exactMatch("foo"), true); - QCOMPARE(rx1.numCaptures(), 3); + QCOMPARE(rx1.captureCount(), 3); QCOMPARE(rx1.matchedLength(), 3); QCOMPARE(rx1.capturedTexts(), QStringList() << "foo" << "f" << "o" << "o"); QCOMPARE(rx1.pos(3), 2); QRegExp rx2 = rx1; - QCOMPARE(rx1.numCaptures(), 3); + QCOMPARE(rx1.captureCount(), 3); QCOMPARE(rx1.matchedLength(), 3); QCOMPARE(rx1.capturedTexts(), QStringList() << "foo" << "f" << "o" << "o"); QCOMPARE(rx1.pos(3), 2); - QCOMPARE(rx2.numCaptures(), 3); + QCOMPARE(rx2.captureCount(), 3); QCOMPARE(rx2.matchedLength(), 3); QCOMPARE(rx2.capturedTexts(), QStringList() << "foo" << "f" << "o" << "o"); QCOMPARE(rx2.pos(3), 2); QCOMPARE(rx1.exactMatch("fo"), true); - QCOMPARE(rx1.numCaptures(), 3); + QCOMPARE(rx1.captureCount(), 3); QCOMPARE(rx1.matchedLength(), 2); QCOMPARE(rx1.capturedTexts(), QStringList() << "fo" << "f" << "o" << ""); QCOMPARE(rx1.pos(2), 1); @@ -1245,25 +1245,25 @@ void tst_QRegExp::prepareEngineOptimization() rx11.setPatternSyntax(QRegExp::Wildcard); QVERIFY(!rx11.isValid()); - QCOMPARE(rx11.numCaptures(), 0); + QCOMPARE(rx11.captureCount(), 0); QCOMPARE(rx11.matchedLength(), -1); rx11.setPatternSyntax(QRegExp::RegExp); QVERIFY(!rx11.isValid()); - QCOMPARE(rx11.numCaptures(), 0); + QCOMPARE(rx11.captureCount(), 0); QCOMPARE(rx11.matchedLength(), -1); rx11.setPattern("(foo)"); QVERIFY(rx11.isValid()); - QCOMPARE(rx11.numCaptures(), 1); + QCOMPARE(rx11.captureCount(), 1); QCOMPARE(rx11.matchedLength(), -1); QCOMPARE(rx11.indexIn("ofoo"), 1); - QCOMPARE(rx11.numCaptures(), 1); + QCOMPARE(rx11.captureCount(), 1); QCOMPARE(rx11.matchedLength(), 3); rx11.setPatternSyntax(QRegExp::RegExp); - QCOMPARE(rx11.numCaptures(), 1); + QCOMPARE(rx11.captureCount(), 1); QCOMPARE(rx11.matchedLength(), 3); /* @@ -1278,11 +1278,11 @@ void tst_QRegExp::prepareEngineOptimization() QCOMPARE(rx11.matchedLength(), 3); rx11.setPatternSyntax(QRegExp::Wildcard); - QCOMPARE(rx11.numCaptures(), 0); + QCOMPARE(rx11.captureCount(), 0); QCOMPARE(rx11.matchedLength(), -1); rx11.setPatternSyntax(QRegExp::RegExp); - QCOMPARE(rx11.numCaptures(), 1); + QCOMPARE(rx11.captureCount(), 1); QCOMPARE(rx11.matchedLength(), -1); } diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index 804534fe47..8eaad78470 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -4485,7 +4485,7 @@ void tst_QScriptEngine::qRegExpInport() QScriptValue result = func.call(QScriptValue(), QScriptValueList() << string << rexp); rx.indexIn(string); - for (int i = 0; i <= rx.numCaptures(); i++) { + for (int i = 0; i <= rx.captureCount(); i++) { QCOMPARE(result.property(i).toString(), rx.cap(i)); } } diff --git a/tests/auto/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp index 5237438686..1d54409513 100644 --- a/tests/auto/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp @@ -1721,21 +1721,21 @@ void tst_QTextDocument::capitalizationHtmlInExport() const QString smallcaps = doc->toHtml(); QVERIFY(re.exactMatch(doc->toHtml())); - QCOMPARE(re.numCaptures(), 1); + QCOMPARE(re.captureCount(), 1); QCOMPARE(re.cap(1).trimmed(), QString("font-variant:small-caps;")); cf.setFontCapitalization(QFont::AllUppercase); cursor.mergeCharFormat(cf); const QString uppercase = doc->toHtml(); QVERIFY(re.exactMatch(doc->toHtml())); - QCOMPARE(re.numCaptures(), 1); + QCOMPARE(re.captureCount(), 1); QCOMPARE(re.cap(1).trimmed(), QString("text-transform:uppercase;")); cf.setFontCapitalization(QFont::AllLowercase); cursor.mergeCharFormat(cf); const QString lowercase = doc->toHtml(); QVERIFY(re.exactMatch(doc->toHtml())); - QCOMPARE(re.numCaptures(), 1); + QCOMPARE(re.captureCount(), 1); QCOMPARE(re.cap(1).trimmed(), QString("text-transform:lowercase;")); doc->setHtml(smallcaps); @@ -1761,14 +1761,14 @@ void tst_QTextDocument::wordspacingHtmlExport() cursor.mergeCharFormat(cf); QVERIFY(re.exactMatch(doc->toHtml())); - QCOMPARE(re.numCaptures(), 1); + QCOMPARE(re.captureCount(), 1); QCOMPARE(re.cap(1).trimmed(), QString("word-spacing:4px;")); cf.setFontWordSpacing(-8.5); cursor.mergeCharFormat(cf); QVERIFY(re.exactMatch(doc->toHtml())); - QCOMPARE(re.numCaptures(), 1); + QCOMPARE(re.captureCount(), 1); QCOMPARE(re.cap(1).trimmed(), QString("word-spacing:-8.5px;")); } -- cgit v1.2.3 From e53c26b52c890f242491e0dfed4201313d98f720 Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Fri, 6 Nov 2009 09:33:33 +0100 Subject: API review: Rename functions numColors(), setNumColors() and numBytes() QPaintDevice and QImage used the functions numColors(), setNumColors(), and numBytes(). However, this is not consistent with the rest of the Qt API which uses *Count() and set*Count(). Removed all usage of these functions inside Qt and test-cases. Reviewed-by: Andreas Aardal Hanssen --- tests/auto/qdatastream/tst_qdatastream.cpp | 2 +- tests/auto/qimage/tst_qimage.cpp | 24 ++++++++++++------------ tests/auto/qimagewriter/tst_qimagewriter.cpp | 2 +- tests/auto/qitemdelegate/tst_qitemdelegate.cpp | 2 +- tests/auto/qpainter/tst_qpainter.cpp | 4 ++-- tests/auto/qpixmap/tst_qpixmap.cpp | 6 +++--- 6 files changed, 20 insertions(+), 20 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qdatastream/tst_qdatastream.cpp b/tests/auto/qdatastream/tst_qdatastream.cpp index 56fc53a235..7535645d1e 100644 --- a/tests/auto/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/qdatastream/tst_qdatastream.cpp @@ -1461,7 +1461,7 @@ void tst_QDataStream::readQImage(QDataStream *s) QVERIFY(d12.width() == ref.width()); QVERIFY(d12.height() == ref.height()); QVERIFY(d12.depth() == ref.depth()); - QVERIFY(d12.numColors() == ref.numColors()); + QVERIFY(d12.colorCount() == ref.colorCount()); #ifdef QT3_SUPPORT QVERIFY(d12.hasAlphaBuffer() == ref.hasAlphaBuffer()); #else diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp index e15ae8a645..da4e85d074 100644 --- a/tests/auto/qimage/tst_qimage.cpp +++ b/tests/auto/qimage/tst_qimage.cpp @@ -104,7 +104,7 @@ private slots: void setPixel_data(); void setPixel(); - void setNumColors(); + void setColorCount(); void setColor(); void rasterClipping(); @@ -155,7 +155,7 @@ void tst_QImage::create() #endif //QImage image(7000000, 7000000, 8, 256, QImage::IgnoreEndian); QImage image(7000000, 7000000, QImage::Format_Indexed8); - image.setNumColors(256); + image.setColorCount(256); cr = !image.isNull(); #if !defined(Q_WS_QWS) && !defined(Q_OS_WINCE) } catch (...) { @@ -242,7 +242,7 @@ void tst_QImage::convertBitOrder() QSKIP("Qt compiled without Qt3Support", SkipAll); #else QImage i(9,5,1,2,QImage::LittleEndian); - qMemSet(i.bits(), 0, i.numBytes()); + qMemSet(i.bits(), 0, i.byteCount()); i.setDotsPerMeterX(9); i.setDotsPerMeterY(5); @@ -258,7 +258,7 @@ void tst_QImage::convertBitOrder() QVERIFY(i.dotsPerMeterY() == ni.dotsPerMeterY()); QVERIFY(i.depth() == ni.depth()); QVERIFY(i.size() == ni.size()); - QVERIFY(i.numColors() == ni.numColors()); + QVERIFY(i.colorCount() == ni.colorCount()); #endif } @@ -365,7 +365,7 @@ void tst_QImage::setAlphaChannel() QImage alphaChannel; if (gray) { alphaChannel = QImage(width, height, QImage::Format_Indexed8); - alphaChannel.setNumColors(256); + alphaChannel.setColorCount(256); for (int i=0; i<256; ++i) alphaChannel.setColor(i, qRgb(i, i, i)); alphaChannel.fill(alpha); @@ -927,7 +927,7 @@ void tst_QImage::rotate() original.fill(qRgb(255,255,255)); if (format == QImage::Format_Indexed8) { - original.setNumColors(256); + original.setColorCount(256); for (int i = 0; i < 255; ++i) original.setColor(i, qRgb(0, i, i)); } @@ -1196,23 +1196,23 @@ void tst_QImage::convertToFormatPreserveText() } #endif // QT_NO_IMAGE_TEXT -void tst_QImage::setNumColors() +void tst_QImage::setColorCount() { QImage img(0, 0, QImage::Format_Indexed8); - QTest::ignoreMessage(QtWarningMsg, "QImage::setNumColors: null image"); - img.setNumColors(256); - QCOMPARE(img.numColors(), 0); + QTest::ignoreMessage(QtWarningMsg, "QImage::setColorCount: null image"); + img.setColorCount(256); + QCOMPARE(img.colorCount(), 0); } void tst_QImage::setColor() { QImage img(0, 0, QImage::Format_Indexed8); img.setColor(0, qRgba(18, 219, 108, 128)); - QCOMPARE(img.numColors(), 0); + QCOMPARE(img.colorCount(), 0); QImage img2(1, 1, QImage::Format_Indexed8); img2.setColor(0, qRgba(18, 219, 108, 128)); - QCOMPARE(img2.numColors(), 1); + QCOMPARE(img2.colorCount(), 1); } /* Just some sanity checking that we don't draw outside the buffer of diff --git a/tests/auto/qimagewriter/tst_qimagewriter.cpp b/tests/auto/qimagewriter/tst_qimagewriter.cpp index 584a0602bb..ab5572dc58 100644 --- a/tests/auto/qimagewriter/tst_qimagewriter.cpp +++ b/tests/auto/qimagewriter/tst_qimagewriter.cpp @@ -546,7 +546,7 @@ void tst_QImageWriter::saveWithNoFormat() QFETCH(QImageWriter::ImageWriterError, error); QImage niceImage(64, 64, QImage::Format_ARGB32); - qMemSet(niceImage.bits(), 0, niceImage.numBytes()); + qMemSet(niceImage.bits(), 0, niceImage.byteCount()); QImageWriter writer(fileName /* , 0 - no format! */); if (error != 0) { diff --git a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp index 426887d7cf..a2770d49d3 100644 --- a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp +++ b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp @@ -877,7 +877,7 @@ void tst_QItemDelegate::decoration() } case QVariant::Image: { QImage img(size, QImage::Format_Mono); - qMemSet(img.bits(), 0, img.numBytes()); + qMemSet(img.bits(), 0, img.byteCount()); value = img; break; } diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 4d2c6266ba..003a494987 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -2918,7 +2918,7 @@ void tst_QPainter::monoImages() QImage img(2, 2, format); - if (img.numColors() > 0) { + if (img.colorCount() > 0) { img.setColor(0, QColor(colorPairs[j][0]).rgba()); img.setColor(1, QColor(colorPairs[j][1]).rgba()); } @@ -2940,7 +2940,7 @@ void tst_QPainter::monoImages() // should not change the image QCOMPARE(original, img); - if (img.numColors() == 0) + if (img.colorCount() == 0) continue; for (int k = 0; k < 2; ++k) { diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 8e02c74e25..d7f042edea 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -293,7 +293,7 @@ void tst_QPixmap::setAlphaChannel() QRgb expected = alpha == 0 ? 0 : qRgba(red, green, blue, alpha); for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) { - if (result.numColors() > 0) { + if (result.colorCount() > 0) { ok &= result.pixelIndex(x, y) == expected; } else { ok &= result.pixel(x, y) == expected; @@ -330,7 +330,7 @@ void tst_QPixmap::fromImage() QImage image(37, 16, format); - if (image.numColors() == 2) { + if (image.colorCount() == 2) { image.setColor(0, QColor(Qt::color0).rgba()); image.setColor(1, QColor(Qt::color1).rgba()); } @@ -731,7 +731,7 @@ void tst_QPixmap::testMetrics() void tst_QPixmap::createMaskFromColor() { QImage image(3, 3, QImage::Format_Indexed8); - image.setNumColors(10); + image.setColorCount(10); image.setColor(0, 0xffffffff); image.setColor(1, 0xff000000); image.setColor(2, 0xffff0000); -- cgit v1.2.3 From 46f73ebb2a71e953edde644acd4e378b15dadb35 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 6 Nov 2009 16:55:45 +0100 Subject: Fix autotests that expected QTextControl to always eat mouse events Reviewed-by: ogoffart --- tests/auto/qlabel/tst_qlabel.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qlabel/tst_qlabel.cpp b/tests/auto/qlabel/tst_qlabel.cpp index 9eae9c9b53..9d957a5b60 100644 --- a/tests/auto/qlabel/tst_qlabel.cpp +++ b/tests/auto/qlabel/tst_qlabel.cpp @@ -328,14 +328,14 @@ void tst_QLabel::eventPropagation_data() QTest::addColumn("propagation"); QTest::newRow("plain text1") << QString("plain text") << int(Qt::LinksAccessibleByMouse) << int(Qt::NoFocus) << true; - QTest::newRow("plain text2") << QString("plain text") << (int)Qt::TextSelectableByKeyboard << (int)Qt::ClickFocus << false; + QTest::newRow("plain text2") << QString("plain text") << (int)Qt::TextSelectableByKeyboard << (int)Qt::ClickFocus << true; QTest::newRow("plain text3") << QString("plain text") << (int)Qt::TextSelectableByMouse << (int)Qt::ClickFocus << false; QTest::newRow("plain text4") << QString("plain text") << (int)Qt::NoTextInteraction << (int)Qt::NoFocus << true; - QTest::newRow("rich text1") << QString("rich text") << (int)Qt::LinksAccessibleByMouse << (int)Qt::NoFocus << false; - QTest::newRow("rich text2") << QString("rich text") << (int)Qt::TextSelectableByKeyboard << (int)Qt::ClickFocus << false; + QTest::newRow("rich text1") << QString("rich text") << (int)Qt::LinksAccessibleByMouse << (int)Qt::NoFocus << true; + QTest::newRow("rich text2") << QString("rich text") << (int)Qt::TextSelectableByKeyboard << (int)Qt::ClickFocus << true; QTest::newRow("rich text3") << QString("rich text") << (int)Qt::TextSelectableByMouse << (int)Qt::ClickFocus << false; QTest::newRow("rich text4") << QString("rich text") << (int)Qt::NoTextInteraction << (int)Qt::NoFocus << true; - QTest::newRow("rich text4") << QString("rich text") << (int)Qt::LinksAccessibleByKeyboard << (int)Qt::StrongFocus << false; + QTest::newRow("rich text4") << QString("rich text") << (int)Qt::LinksAccessibleByKeyboard << (int)Qt::StrongFocus << true; if (!test_box) test_box = new Widget; -- cgit v1.2.3 From cd58bc13a4a37543d76a79b3cee7cd95bde0a14b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 6 Nov 2009 17:24:43 +0100 Subject: stabilize test --- tests/auto/qcombobox/tst_qcombobox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index 06c632de6f..18ebddcdaa 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -2529,7 +2529,7 @@ void tst_QComboBox::task_QTBUG_1071_changingFocusEmitsActivated() QCOMPARE(spy.count(), 0); edit.setFocus(); QTRY_VERIFY(edit.hasFocus()); - QCOMPARE(spy.count(), 1); + QTRY_COMPARE(spy.count(), 1); } QTEST_MAIN(tst_QComboBox) -- cgit v1.2.3 From f2f7ad1e0a73ef28aee406de358e1308f817bf6d Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Thu, 5 Nov 2009 14:44:04 -0300 Subject: QGAL (Test): Add test where center anchor is simplified by parallel We were not handling the case where a parallel anchor is created to simplify a central anchor. Unfortunately no tests had shown that case yet. Signed-off-by: Eduardo M. Fleury Reviewed-by: Caio Marcelo de Oliveira Filho --- .../tst_qgraphicsanchorlayout.cpp | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index cc96edbee3..8b52674cff 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -83,6 +83,7 @@ private slots: void infiniteMaxSizes(); void simplifiableUnfeasible(); void simplificationVsOrder(); + void parallelSimplificationOfCenter(); }; class RectWidget : public QGraphicsWidget @@ -1801,5 +1802,30 @@ void tst_QGraphicsAnchorLayout::simplificationVsOrder() } } +void tst_QGraphicsAnchorLayout::parallelSimplificationOfCenter() +{ + QSizeF min(10, 10); + QSizeF pref(20, 10); + QSizeF max(50, 10); + + QGraphicsWidget *a = createItem(min, pref, max, "A"); + QGraphicsWidget *b = createItem(min, pref, max, "B"); + + QGraphicsWidget parent; + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout(&parent); + l->setContentsMargins(0, 0, 0, 0); + + l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); + l->addAnchor(l, Qt::AnchorRight, a, Qt::AnchorRight); + + l->addAnchor(a, Qt::AnchorHorizontalCenter, b, Qt::AnchorLeft); + l->addAnchor(b, Qt::AnchorRight, a, Qt::AnchorRight); + + parent.resize(l->effectiveSizeHint(Qt::PreferredSize)); + + QCOMPARE(a->geometry(), QRectF(0, 0, 40, 10)); + QCOMPARE(b->geometry(), QRectF(20, 0, 20, 10)); +} + QTEST_MAIN(tst_QGraphicsAnchorLayout) #include "tst_qgraphicsanchorlayout.moc" -- cgit v1.2.3 From 92b51d119325adc7cef518c1260c71904fc68c40 Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Thu, 5 Nov 2009 20:11:37 -0300 Subject: QGAL (Test): Enable remaining tests in 'qgraphicsanchorlayout1' Some tests were still disabled because were not supported somewhere in the past. Signed-off-by: Eduardo M. Fleury Reviewed-by: Caio Marcelo de Oliveira Filho --- .../tst_qgraphicsanchorlayout1.cpp | 25 ++++++++-------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp index 57e5c41be9..0fbd0692ce 100644 --- a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp +++ b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp @@ -423,7 +423,6 @@ void tst_QGraphicsAnchorLayout1::testAddAndRemoveAnchor() layout->setAnchor(layout, Qt::AnchorLeft, widget5, Qt::AnchorTop, 10); QCOMPARE( layout->count(), 4 ); - // ###: NOT SUPPORTED // anchor two edges of a widget (to define width / height) QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): Cannot anchor the item to itself"); layout->setAnchor(widget5, Qt::AnchorLeft, widget5, Qt::AnchorRight, 10); @@ -520,8 +519,6 @@ void tst_QGraphicsAnchorLayout1::testIsValid() widget->setLayout(layout); widget->setGeometry(QRectF(0,0,100,100)); - // ###: this shall change once isValid() is ready - // QCOMPARE(layout->isValid(), false); QCOMPARE(layout->isValid(), true); delete widget; } @@ -698,9 +695,8 @@ void tst_QGraphicsAnchorLayout1::testSpecialCases() layout2->setAnchor(widget1, Qt::AnchorRight, layout2, Qt::AnchorRight, 1); layout2->setAnchor(widget1, Qt::AnchorBottom, layout2, Qt::AnchorBottom, 1); - // ###: uncomment when simplification bug is solved - //widget->setGeometry(QRectF(0,0,100,100)); - //QCOMPARE(widget1->geometry(), QRectF(51,2,47,96)); + widget->setGeometry(QRectF(0,0,100,100)); + QCOMPARE(widget1->geometry(), QRectF(51,2,47,96)); delete widget; } @@ -900,9 +896,6 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout_data() << BasicData(-1, Qt::AnchorLeft, 1, Qt::AnchorRight, 20) ; - // ### SIMPLIFICATION BUG FOR ITEM 1 - // ### remove this when bug is solved - theResult << BasicResult(0, QRectF(10, 10, 180, 80) ) << BasicResult(1, QRectF(10, 80, 10, 10) ) @@ -1732,8 +1725,6 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout() QCOMPARE(expected, actual); } - // ###: not supported yet -/* // Test mirrored mode widget->setLayoutDirection(Qt::RightToLeft); layout->activate(); @@ -1745,10 +1736,13 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout() if (mirroredRect.isValid()){ mirroredRect.moveLeft(size.width()-item.rect.width()-item.rect.left()); } - QCOMPARE(widgets[item.index]->geometry(), mirroredRect); + QRectF expected = truncate(mirroredRect); + QRectF actual = truncate(widgets[item.index]->geometry()); + + QCOMPARE(expected, actual); delete widgets[item.index]; } -*/ + delete widget; } @@ -2447,6 +2441,8 @@ void tst_QGraphicsAnchorLayout1::testDoubleSizePolicy_data() QTest::newRow("double size policy: expanding-preferred") << sizePolicy1 << sizePolicy2 << width1 << width2; } + // QGAL handling of ignored flag is different + if (0) { QSizePolicy sizePolicy1( QSizePolicy::Ignored, QSizePolicy::Ignored ); QSizePolicy sizePolicy2( QSizePolicy::Preferred, QSizePolicy::Preferred ); @@ -2514,9 +2510,6 @@ void tst_QGraphicsAnchorLayout1::testDoubleSizePolicy_data() void tst_QGraphicsAnchorLayout1::testDoubleSizePolicy() { - // ### Size policy is not yet supported - return; - QFETCH(QSizePolicy, policy1); QFETCH(QSizePolicy, policy2); QFETCH(qreal, width1); -- cgit v1.2.3 From 5f46db57f3baed15bfca2b4725e400808eabb7e5 Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Thu, 5 Nov 2009 23:49:43 -0300 Subject: QGAL (Test): redundant anchors shouldn't harm simplification Adds a simple test to check whether redundant anchors avoid simplification to happen. In this case, the use of addCornerAnchors generate redundant anchors. Signed-off-by: Caio Marcelo de Oliveira Filho Reviewed-by: Eduardo M. Fleury --- .../tst_qgraphicsanchorlayout.cpp | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index 8b52674cff..c7ed309a2b 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -84,6 +84,7 @@ private slots: void simplifiableUnfeasible(); void simplificationVsOrder(); void parallelSimplificationOfCenter(); + void simplificationVsRedundance(); }; class RectWidget : public QGraphicsWidget @@ -1827,5 +1828,43 @@ void tst_QGraphicsAnchorLayout::parallelSimplificationOfCenter() QCOMPARE(b->geometry(), QRectF(20, 0, 20, 10)); } +/* + Test whether redundance of anchors (in this case by using addCornerAnchors), will + prevent simplification to take place when it should. +*/ +void tst_QGraphicsAnchorLayout::simplificationVsRedundance() +{ + QSizeF min(10, 10); + QSizeF pref(20, 10); + QSizeF max(50, 30); + + QGraphicsWidget *a = createItem(min, pref, max, "A"); + QGraphicsWidget *b = createItem(min, pref, max, "B"); + QGraphicsWidget *c = createItem(min, pref, max, "C"); + + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + + l->addCornerAnchors(a, Qt::TopLeftCorner, l, Qt::TopLeftCorner); + l->addCornerAnchors(a, Qt::BottomLeftCorner, l, Qt::BottomLeftCorner); + + l->addCornerAnchors(b, Qt::TopLeftCorner, a, Qt::TopRightCorner); + l->addCornerAnchors(b, Qt::TopRightCorner, l, Qt::TopRightCorner); + + l->addCornerAnchors(c, Qt::TopLeftCorner, b, Qt::BottomLeftCorner); + l->addCornerAnchors(c, Qt::BottomLeftCorner, a, Qt::BottomRightCorner); + l->addCornerAnchors(c, Qt::TopRightCorner, b, Qt::BottomRightCorner); + l->addCornerAnchors(c, Qt::BottomRightCorner, l, Qt::BottomRightCorner); + + l->effectiveSizeHint(Qt::MinimumSize); + + QCOMPARE(layoutHasConflict(l), false); + + if (!hasSimplification) + QEXPECT_FAIL("", "Test depends on simplification.", Abort); + + QCOMPARE(usedSimplex(l, Qt::Horizontal), false); + QCOMPARE(usedSimplex(l, Qt::Vertical), false); +} + QTEST_MAIN(tst_QGraphicsAnchorLayout) #include "tst_qgraphicsanchorlayout.moc" -- cgit v1.2.3 From 28f490b3edb7a47aa27db5ea427d91e082a59f18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 6 Nov 2009 14:53:28 +0100 Subject: Improving reliability and information from the large file test Saw a couple of sporadic failures on Windows platforms. Debug output should help find what's happening. Once the fillFileSparsely test fails, there's no point in trying to read what we failed to write so maximum tested size is reset on a failed write. Reviewed-by: Markus Goetz --- tests/auto/qfile/largefile/tst_largefile.cpp | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qfile/largefile/tst_largefile.cpp b/tests/auto/qfile/largefile/tst_largefile.cpp index 8ab3275c0c..9105063e73 100644 --- a/tests/auto/qfile/largefile/tst_largefile.cpp +++ b/tests/auto/qfile/largefile/tst_largefile.cpp @@ -339,12 +339,47 @@ void tst_LargeFile::fillFileSparsely() QFETCH( QByteArray, block ); QCOMPARE( block.size(), blockSize ); + static int lastKnownGoodIndex = 0; + struct ScopeGuard { + ScopeGuard(tst_LargeFile* test) + : this_(test) + , failed(true) + { + QFETCH( int, index ); + index_ = index; + } + + ~ScopeGuard() + { + if (failed) { + this_->maxSizeBits = lastKnownGoodIndex; + QWARN( qPrintable( + QString("QFile::error %1: '%2'. Maximum size bits reset to %3.") + .arg(this_->largeFile.error()) + .arg(this_->largeFile.errorString()) + .arg(this_->maxSizeBits)) ); + } else + lastKnownGoodIndex = qMax(index_, lastKnownGoodIndex); + } + + private: + tst_LargeFile * const this_; + int index_; + + public: + bool failed; + }; + + ScopeGuard resetMaxSizeBitsOnFailure(this); + QVERIFY( largeFile.seek(position) ); QCOMPARE( largeFile.pos(), position ); QCOMPARE( largeFile.write(block), (qint64)blockSize ); QCOMPARE( largeFile.pos(), position + blockSize ); QVERIFY( largeFile.flush() ); + + resetMaxSizeBitsOnFailure.failed = false; } void tst_LargeFile::fileCreated() -- cgit v1.2.3 From 8437faaadab1d7bf8861e1d6575f4e1bff04b005 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 6 Nov 2009 15:59:55 +1000 Subject: Crash on bug QTBUG-5493 --- tests/auto/qpainter/tst_qpainter.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 4d2c6266ba..02c73c05fb 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -101,6 +101,8 @@ private slots: void saveAndRestore_data(); void saveAndRestore(); + void drawBorderPixmap(); + void drawLine_data(); void drawLine(); void drawLine_clipped(); @@ -973,6 +975,18 @@ void tst_QPainter::initFrom() delete widget; } +void tst_QPainter::drawBorderPixmap() +{ + QPixmap src(79,79); + src.fill(Qt::transparent); + + QImage pm(200,200,QImage::Format_RGB32); + QPainter p(&pm); + p.setTransform(QTransform(-1,0,0,-1,173.5,153.5)); + qDrawBorderPixmap(&p, QRect(0,0,75,105), QMargins(39,39,39,39), src, QRect(0,0,79,79), QMargins(39,39,39,39), + QTileRules(Qt::StretchTile,Qt::StretchTile), 0); +} + void tst_QPainter::drawLine_data() { QTest::addColumn("line"); -- cgit v1.2.3 From 9e0c2d6f00cb1195bf7bc1eae34a6f8f9b43191f Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Fri, 6 Nov 2009 11:37:33 +0100 Subject: API review: Rename numDigits() and setNumDigits() QLCDNumber doesn't follow the API convention of *Count and set*Count(). Introduce properly named functions, and obsolete the old ones. Reviewed-by: Andreas Aardal Hanssen --- tests/auto/qlcdnumber/tst_qlcdnumber.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qlcdnumber/tst_qlcdnumber.cpp b/tests/auto/qlcdnumber/tst_qlcdnumber.cpp index c18ce24175..3f52c708db 100644 --- a/tests/auto/qlcdnumber/tst_qlcdnumber.cpp +++ b/tests/auto/qlcdnumber/tst_qlcdnumber.cpp @@ -74,14 +74,14 @@ tst_QLCDNumber::~tst_QLCDNumber() void tst_QLCDNumber::getSetCheck() { QLCDNumber obj1; - // int QLCDNumber::numDigits() - // void QLCDNumber::setNumDigits(int) - obj1.setNumDigits(0); - QCOMPARE(0, obj1.numDigits()); - obj1.setNumDigits(INT_MIN); - QCOMPARE(0, obj1.numDigits()); // Range<0, 99> - obj1.setNumDigits(INT_MAX); - QCOMPARE(99, obj1.numDigits()); // Range<0, 99> + // int QLCDNumber::digitCount() + // void QLCDNumber::setDigitCount(int) + obj1.setDigitCount(0); + QCOMPARE(0, obj1.digitCount()); + obj1.setDigitCount(INT_MIN); + QCOMPARE(0, obj1.digitCount()); // Range<0, 99> + obj1.setDigitCount(INT_MAX); + QCOMPARE(99, obj1.digitCount()); // Range<0, 99> } QTEST_MAIN(tst_QLCDNumber) -- cgit v1.2.3 From 4ad31892d735e6f1a7afffbf0bf8028663855adb Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Fri, 6 Nov 2009 12:04:15 +0100 Subject: API review: Rename numRects() -> rectCount() QRegion::numRects() is marked obsolete. Removed all usage of the old function inside Qt and test-cases. Reviewed-by: Andreas Aardal Hanssen --- tests/auto/qregion/tst_qregion.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qregion/tst_qregion.cpp b/tests/auto/qregion/tst_qregion.cpp index e5a3151120..582b5e8df3 100644 --- a/tests/auto/qregion/tst_qregion.cpp +++ b/tests/auto/qregion/tst_qregion.cpp @@ -88,8 +88,8 @@ private slots: void operator_xor_data(); void operator_xor(); - void numRects_data(); - void numRects(); + void rectCount_data(); + void rectCount(); void isEmpty_data(); void isEmpty(); @@ -554,7 +554,7 @@ void tst_QRegion::operator_plus() qDebug() << "expected" << expected; } QCOMPARE(r1 + r2, expected); - if (r2.numRects() == 1) { + if (r2.rectCount() == 1) { if (r1 + r2.boundingRect() != expected) { qDebug() << "r1 + QRect(r2)" << (r1 + r2.boundingRect()); qDebug() << "expected" << expected; @@ -567,7 +567,7 @@ void tst_QRegion::operator_plus() qDebug() << "expected" << expected; } QCOMPARE(r2 + r1, expected); - if (r1.numRects() == 1) { + if (r1.rectCount() == 1) { if (r1 + r2.boundingRect() != expected) { qDebug() << "r2 + QRect(r1)" << (r2 + r1.boundingRect()); qDebug() << "expected" << expected; @@ -582,7 +582,7 @@ void tst_QRegion::operator_plus() qDebug() << "expected" << expected; } QCOMPARE(result1, expected); - if (r2.numRects() == 1) { + if (r2.rectCount() == 1) { result1 = r1; result1 += r2.boundingRect(); if (result1 != expected) { @@ -599,7 +599,7 @@ void tst_QRegion::operator_plus() qDebug() << "expected" << expected; } QCOMPARE(result2, expected); - if (r1.numRects() == 1) { + if (r1.rectCount() == 1) { result2 = r2; result2 += r1.boundingRect(); if (result2 != expected) { @@ -802,7 +802,7 @@ void tst_QRegion::operator_xor() QCOMPARE(dest, expected); } -void tst_QRegion::numRects_data() +void tst_QRegion::rectCount_data() { QTest::addColumn("region"); QTest::addColumn("expected"); @@ -818,12 +818,12 @@ void tst_QRegion::numRects_data() QTest::newRow("2 rects") << dest << rects.size(); } -void tst_QRegion::numRects() +void tst_QRegion::rectCount() { QFETCH(QRegion, region); QFETCH(int, expected); - QCOMPARE(region.numRects(), expected); + QCOMPARE(region.rectCount(), expected); } void tst_QRegion::isEmpty_data() @@ -850,7 +850,7 @@ void tst_QRegion::isEmpty() QVERIFY(region.isEmpty()); QCOMPARE(region, QRegion()); - QCOMPARE(region.numRects(), 0); + QCOMPARE(region.rectCount(), 0); QCOMPARE(region.boundingRect(), QRect()); QVERIFY(region.rects().isEmpty()); } -- cgit v1.2.3 From 4454669fc238171239f8a2f202ec7e26e7409776 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Fri, 6 Nov 2009 13:35:46 +0100 Subject: QNetworkCookie: Add the dot prefix of the domain while adding to the jar instead than when parsing the cookie header. This corrects the bug QT-2379, happening in the following sequence: parseCookie -> setCookieUrl -> toRawForm -> parseCookie where a default domain would now also have a dot prefix, and shouldn't. QT-2379 Reviewed-by: Peter Hartmann --- tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp | 39 +++++++++------------- .../qnetworkcookiejar/tst_qnetworkcookiejar.cpp | 18 ++++++++-- 2 files changed, 32 insertions(+), 25 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp index 3c4ddd497c..94857d7b4d 100644 --- a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp +++ b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp @@ -234,7 +234,7 @@ void tst_QNetworkCookie::parseSingleCookie_data() QTest::newRow("path-with-utf8-2") << "a=b;path=/R%C3%A9sum%C3%A9" << cookie; cookie.setPath(QString()); - cookie.setDomain(".qt.nokia.com"); + cookie.setDomain("qt.nokia.com"); QTest::newRow("plain-domain1") << "a=b;domain=qt.nokia.com" << cookie; QTest::newRow("plain-domain2") << "a=b; domain=qt.nokia.com " << cookie; QTest::newRow("plain-domain3") << "a=b;domain=QT.NOKIA.COM" << cookie; @@ -247,32 +247,25 @@ void tst_QNetworkCookie::parseSingleCookie_data() QTest::newRow("dot-domain4") << "a=b; Domain = .QT.NOKIA.COM" << cookie; cookie.setDomain(QString::fromUtf8(".d\303\270gn\303\245pent.troll.no")); - QTest::newRow("idn-domain1") << "a=b;domain=xn--dgnpent-gxa2o.troll.no" << cookie; - QTest::newRow("idn-domain2") << "a=b;domain=d\303\270gn\303\245pent.troll.no" << cookie; - QTest::newRow("idn-domain3") << "a=b;domain=XN--DGNPENT-GXA2O.TROLL.NO" << cookie; - QTest::newRow("idn-domain4") << "a=b;domain=D\303\230GN\303\205PENT.troll.NO" << cookie; - QTest::newRow("idn-domain5") << "a=b;domain = D\303\230GN\303\205PENT.troll.NO" << cookie; - - cookie.setDomain(QString::fromUtf8(".d\303\270gn\303\245pent.troll.no")); - QTest::newRow("dot-idn-domain1") << "a=b;domain=.xn--dgnpent-gxa2o.troll.no" << cookie; - QTest::newRow("dot-idn-domain2") << "a=b;domain=.d\303\270gn\303\245pent.troll.no" << cookie; - QTest::newRow("dot-idn-domain3") << "a=b;domain=.XN--DGNPENT-GXA2O.TROLL.NO" << cookie; - QTest::newRow("dot-idn-domain4") << "a=b;domain=.D\303\230GN\303\205PENT.troll.NO" << cookie; + QTest::newRow("idn-domain1") << "a=b;domain=.xn--dgnpent-gxa2o.troll.no" << cookie; + QTest::newRow("idn-domain2") << "a=b;domain=.d\303\270gn\303\245pent.troll.no" << cookie; + QTest::newRow("idn-domain3") << "a=b;domain=.XN--DGNPENT-GXA2O.TROLL.NO" << cookie; + QTest::newRow("idn-domain4") << "a=b;domain=.D\303\230GN\303\205PENT.troll.NO" << cookie; cookie.setDomain(".qt.nokia.com"); cookie.setPath("/"); - QTest::newRow("two-fields") << "a=b;domain=qt.nokia.com;path=/" << cookie; - QTest::newRow("two-fields2") << "a=b; domain=qt.nokia.com; path=/" << cookie; - QTest::newRow("two-fields3") << "a=b; domain=qt.nokia.com ; path=/ " << cookie; - QTest::newRow("two-fields4") << "a=b;path=/; domain=qt.nokia.com" << cookie; - QTest::newRow("two-fields5") << "a=b; path=/ ; domain=qt.nokia.com" << cookie; - QTest::newRow("two-fields6") << "a=b; path= / ; domain =qt.nokia.com" << cookie; + QTest::newRow("two-fields") << "a=b;domain=.qt.nokia.com;path=/" << cookie; + QTest::newRow("two-fields2") << "a=b; domain=.qt.nokia.com; path=/" << cookie; + QTest::newRow("two-fields3") << "a=b; domain=.qt.nokia.com ; path=/ " << cookie; + QTest::newRow("two-fields4") << "a=b;path=/; domain=.qt.nokia.com" << cookie; + QTest::newRow("two-fields5") << "a=b; path=/ ; domain=.qt.nokia.com" << cookie; + QTest::newRow("two-fields6") << "a=b; path= / ; domain =.qt.nokia.com" << cookie; cookie.setSecure(true); - QTest::newRow("three-fields") << "a=b;domain=qt.nokia.com;path=/;secure" << cookie; - QTest::newRow("three-fields2") << "a=b;secure;path=/;domain=qt.nokia.com" << cookie; - QTest::newRow("three-fields3") << "a=b;secure;domain=qt.nokia.com; path=/" << cookie; - QTest::newRow("three-fields4") << "a = b;secure;domain=qt.nokia.com; path=/" << cookie; + QTest::newRow("three-fields") << "a=b;domain=.qt.nokia.com;path=/;secure" << cookie; + QTest::newRow("three-fields2") << "a=b;secure;path=/;domain=.qt.nokia.com" << cookie; + QTest::newRow("three-fields3") << "a=b;secure;domain=.qt.nokia.com; path=/" << cookie; + QTest::newRow("three-fields4") << "a = b;secure;domain=.qt.nokia.com; path=/" << cookie; cookie = QNetworkCookie(); cookie.setName("a"); @@ -664,7 +657,7 @@ void tst_QNetworkCookie::parseMultipleCookies_data() cookie.setName("baz"); cookie.setDomain(".qt.nokia.com"); list.prepend(cookie); - QTest::newRow("complex-2") << "baz=bar; path=/; domain=qt.nokia.com, c=d,a=,foo=bar; path=/" << list; + QTest::newRow("complex-2") << "baz=bar; path=/; domain=.qt.nokia.com, c=d,a=,foo=bar; path=/" << list; // cookies obtained from the network: cookie = QNetworkCookie("id", "51706646077999719"); diff --git a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp index 9b9c56a5f9..ff7e78e544 100644 --- a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp +++ b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp @@ -120,7 +120,7 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data() cookie.setName("a"); cookie.setPath("/"); - cookie.setDomain("www.foo.tld"); + cookie.setDomain(".foo.tld"); result += cookie; QTest::newRow("just-add") << preset << cookie << "http://www.foo.tld" << result << true; @@ -148,6 +148,20 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data() cookie.setPath("/"); QTest::newRow("diff-path-order") << preset << cookie << "http://www.foo.tld" << result << true; + preset.clear(); + result.clear(); + QNetworkCookie finalCookie = cookie; + cookie.setDomain("foo.tld"); + finalCookie.setDomain(".foo.tld"); + result += finalCookie; + QTest::newRow("should-add-dot-prefix") << preset << cookie << "http://www.foo.tld" << result << true; + + result.clear(); + cookie.setDomain(""); + finalCookie.setDomain("www.foo.tld"); + result += finalCookie; + QTest::newRow("should-set-default-domain") << preset << cookie << "http://www.foo.tld" << result << true; + // security test: result.clear(); preset.clear(); @@ -159,7 +173,7 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data() QTest::newRow("security-path-1") << preset << cookie << "http://www.foo.tld" << result << false; // setting the defaults: - QNetworkCookie finalCookie = cookie; + finalCookie = cookie; finalCookie.setPath("/something/"); cookie.setPath(""); cookie.setDomain(""); -- cgit v1.2.3