summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/linguist/lrelease/tst_lrelease.cpp13
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp49
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.h51
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp2/project.ts.result24
-rw-r--r--tests/auto/qanimationgroup/tst_qanimationgroup.cpp84
-rw-r--r--tests/auto/qcombobox/tst_qcombobox.cpp31
-rw-r--r--tests/auto/qcssparser/tst_qcssparser.cpp3
-rw-r--r--tests/auto/qfile/largefile/tst_largefile.cpp35
-rw-r--r--tests/auto/qfile/tst_qfile.cpp166
-rw-r--r--tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp326
-rw-r--r--tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp64
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp74
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp220
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp72
-rw-r--r--tests/auto/qlabel/tst_qlabel.cpp8
-rw-r--r--tests/auto/qlineedit/tst_qlineedit.cpp16
-rw-r--r--tests/auto/qlistview/tst_qlistview.cpp27
-rw-r--r--tests/auto/qlocalsocket/tst_qlocalsocket.cpp10
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp479
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp14
-rw-r--r--tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp136
-rw-r--r--tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp20
-rw-r--r--tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp506
-rw-r--r--tests/auto/qstringbuilder1/stringbuilder.cpp26
-rw-r--r--tests/auto/qtableview/tst_qtableview.cpp19
-rw-r--r--tests/auto/qtextdocumentfragment/tst_qtextdocumentfragment.cpp10
-rw-r--r--tests/auto/qtreeview/tst_qtreeview.cpp4
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp5
-rw-r--r--tests/auto/qwidgetaction/tst_qwidgetaction.cpp2
-rw-r--r--tests/auto/uiloader/baseline/css_itemview_task258382.ui179
-rw-r--r--tests/auto/xmlpatternsxqts/test/test.pro2
-rw-r--r--tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro2
32 files changed, 1509 insertions, 1168 deletions
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;
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp
index eaa271aea2..7ddb68fbb1 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp
+++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp
@@ -63,3 +63,52 @@ 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");
+}
+
+
+
+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/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..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,4 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0">
+<context>
+ <name>NameSpace::ToBeUsed</name>
+ <message>
+ <location filename="main.cpp" line="113"/>
+ <source>NameSpace::ToBeUsed</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>TopLevel</name>
+ <message>
+ <location filename="main.cpp" line="82"/>
+ <source>TopLevel</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>TopLevel2</name>
+ <message>
+ <location filename="main.cpp" line="94"/>
+ <source>TopLevel2</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
</TS>
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<QAbstractAnimation::State>(groupStateChangedSpy.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(1).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(1).first()),
QAnimationGroup::Stopped);
QCOMPARE(group.state(), QAnimationGroup::Stopped);
@@ -180,9 +180,9 @@ void tst_QAnimationGroup::emptyGroup()
group.start();
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(2).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(2).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(3).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(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);
diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp
index 51a7ff8142..18ebddcdaa 100644
--- a/tests/auto/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/qcombobox/tst_qcombobox.cpp
@@ -57,6 +57,7 @@
#include <qtreewidget.h>
#include <qtablewidget.h>
#include <qscrollbar.h>
+#include <qboxlayout.h>
#ifdef Q_WS_MAC
#include <qmacstyle_mac.h>
#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());
+ QTRY_COMPARE(spy.count(), 1);
+}
QTEST_MAIN(tst_QComboBox)
#include "tst_qcombobox.moc"
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/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<int>(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()
diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp
index 55cc286848..b3d6fd917e 100644
--- a/tests/auto/qfile/tst_qfile.cpp
+++ b/tests/auto/qfile/tst_qfile.cpp
@@ -91,6 +91,10 @@
#define STDERR_FILENO 2
#endif
+#ifndef QT_OPEN_BINARY
+#define QT_OPEN_BINARY 0
+#endif
+
Q_DECLARE_METATYPE(QFile::FileError)
//TESTED_CLASS=
@@ -211,6 +215,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()
@@ -226,6 +305,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()
@@ -254,6 +335,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()
@@ -1958,53 +2044,71 @@ void tst_QFile::fullDisk()
void tst_QFile::writeLargeDataBlock_data()
{
QTest::addColumn<QString>("fileName");
+ QTest::addColumn<int>("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)));
- }
- // 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)))));
- }
+ 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);
+ }
+
+ 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()
diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
index c8a9facc2b..c7ed309a2b 100644
--- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -79,13 +79,12 @@ private slots:
void delete_anchor();
void conflicts();
void sizePolicy();
- void expandingSequence();
- void expandingSequenceFairDistribution();
- void expandingParallel();
void floatConflict();
void infiniteMaxSizes();
void simplifiableUnfeasible();
void simplificationVsOrder();
+ void parallelSimplificationOfCenter();
+ void simplificationVsRedundance();
};
class RectWidget : public QGraphicsWidget
@@ -342,8 +341,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;
@@ -1609,217 +1610,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");
@@ -1882,6 +1672,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");
//<!-- Trunk -->
setAnchor(l, l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0);
@@ -1889,34 +1680,32 @@ 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);
-
- a->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
- c->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+ setAnchor(l, b, Qt::AnchorHorizontalCenter, e, Qt::AnchorLeft, 0);
+ setAnchor(l, e, Qt::AnchorRight, c, Qt::AnchorHorizontalCenter, 0);
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));
- 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()
@@ -1951,7 +1740,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 +1768,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;
@@ -2014,5 +1803,68 @@ 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));
+}
+
+/*
+ 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"
diff --git a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
index 1c7a159e34..0fbd0692ce 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()
{
@@ -419,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);
@@ -516,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;
}
@@ -694,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;
}
@@ -896,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) )
@@ -1664,6 +1661,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);
@@ -1684,7 +1693,7 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout()
// Create dummy widgets
QList<QGraphicsWidget *> 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;
}
@@ -1704,19 +1713,18 @@ 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) {
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
-/*
// Test mirrored mode
widget->setLayoutDirection(Qt::RightToLeft);
layout->activate();
@@ -1728,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;
}
@@ -2212,8 +2223,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) {
@@ -2430,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 );
@@ -2497,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);
@@ -3053,8 +3063,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..
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 3bc6db5472..d65c6ecdb2 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;
}
@@ -9677,5 +9680,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"
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index 0589994841..9a561ebc11 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();
@@ -267,6 +268,7 @@ private slots:
void initialFocus_data();
void initialFocus();
void polishItems();
+ void isActive();
// task specific tests below me
void task139710_bspTreeCrash();
@@ -1453,6 +1455,13 @@ void tst_QGraphicsScene::focusItemLostFocus()
item->clearFocus();
}
+class ClearTestItem : public QGraphicsRectItem
+{
+public:
+ ~ClearTestItem() { qDeleteAll(items); }
+ QList<QGraphicsItem *> items;
+};
+
void tst_QGraphicsScene::clear()
{
QGraphicsScene scene;
@@ -1463,6 +1472,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()
@@ -1514,6 +1536,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;
@@ -3110,6 +3152,7 @@ void tst_QGraphicsScene::tabFocus_sceneWithFocusableItems()
QVERIFY(!view->viewport()->hasFocus());
QVERIFY(!scene.hasFocus());
QVERIFY(!item->hasFocus());
+ QCOMPARE(scene.focusItem(), static_cast<QGraphicsItem *>(item));
// Check that the correct item regains focus.
widget.show();
@@ -3117,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<QGraphicsItem *>(item));
QVERIFY(item->hasFocus());
}
@@ -3910,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<QWidget *>(&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"
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;
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<bool>("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("<b>rich text</b>") << (int)Qt::LinksAccessibleByMouse << (int)Qt::NoFocus << false;
- QTest::newRow("rich text2") << QString("<b>rich text</b>") << (int)Qt::TextSelectableByKeyboard << (int)Qt::ClickFocus << false;
+ QTest::newRow("rich text1") << QString("<b>rich text</b>") << (int)Qt::LinksAccessibleByMouse << (int)Qt::NoFocus << true;
+ QTest::newRow("rich text2") << QString("<b>rich text</b>") << (int)Qt::TextSelectableByKeyboard << (int)Qt::ClickFocus << true;
QTest::newRow("rich text3") << QString("<b>rich text</b>") << (int)Qt::TextSelectableByMouse << (int)Qt::ClickFocus << false;
QTest::newRow("rich text4") << QString("<b>rich text</b>") << (int)Qt::NoTextInteraction << (int)Qt::NoFocus << true;
- QTest::newRow("rich text4") << QString("<b>rich text</b>") << (int)Qt::LinksAccessibleByKeyboard << (int)Qt::StrongFocus << false;
+ QTest::newRow("rich text4") << QString("<b>rich text</b>") << (int)Qt::LinksAccessibleByKeyboard << (int)Qt::StrongFocus << true;
if (!test_box)
test_box = new Widget;
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"
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp
index a5ff153b7c..1c8fecf96b 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
@@ -1787,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));
}
@@ -1861,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
@@ -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"
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
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<int>("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<bool>("serverSendsContentLength");
- QTest::addColumn<bool>("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<int>("loopCount");
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index 003a494987..8b713496e6 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<QLine>("line");
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<QAbstractAnimation::State>(spy1.last().at(1)), TestAnimation::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Running);
QCOMPARE(spy2.count(), 1);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().at(1)), TestAnimation::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Running);
QCOMPARE(spy3.count(), 1);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().at(1)), TestAnimation::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Running);
QCOMPARE(spy4.count(), 1);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().at(1)), TestAnimation::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Running);
group.setCurrentTime(1500); //anim1 should be finished
QCOMPARE(group.state(), QAnimationGroup::Running);
QCOMPARE(spy1.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().at(1)), TestAnimation::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(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<QAbstractAnimation::State>(spy2.last().at(1)), TestAnimation::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(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<QAbstractAnimation::State>(spy3.last().at(1)), TestAnimation::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Stopped);
QCOMPARE(spy4.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().at(1)), TestAnimation::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(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<QAbstractAnimation::State>(spy3.last().at(1)), TestAnimation::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Running);
QCOMPARE(spy4.count(), 1);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().at(1)), TestAnimation::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(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<QAbstractAnimation::State>(spy2.last().at(1)), TestAnimation::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(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<QAbstractAnimation::State>(spy1.last().at(1)), TestAnimation::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(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<QAbstractAnimation::State>(spy1.last().at(1)), TestAnimation::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Stopped);
QCOMPARE(spy2.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().at(1)), TestAnimation::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Stopped);
QCOMPARE(spy3.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().at(1)), TestAnimation::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Stopped);
QCOMPARE(spy4.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().at(1)), TestAnimation::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(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<QAbstractAnimation::State>(groupStateChangedSpy.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(childStateChangedSpy.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(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<QAbstractAnimation::State>(stateChangedSpy1.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(1).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(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<QAbstractAnimation::State>(stateChangedSpy1.at(1).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(1).first()),
QAnimationGroup::Stopped);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(2).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(2).first()),
QAnimationGroup::Running);
QCOMPARE(stateChangedSpy2.count(), 4);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(2).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(2).first()),
QAnimationGroup::Stopped);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(3).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(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<QAbstractAnimation::State>(stateChangedSpy1.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(1).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(1).first()),
QAnimationGroup::Stopped);
QCOMPARE(stateChangedSpy2.count(), 1);
QCOMPARE(finishedSpy2.count(), 0);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()),
QAnimationGroup::Running);
QCOMPARE(stateChangedSpy3.count(), 1);
QCOMPARE(finishedSpy3.count(), 0);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy3.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy3.at(0).first()),
QAnimationGroup::Running);
@@ -762,9 +762,9 @@ void tst_QParallelAnimationGroup::stopUncontrolledAnimations()
group.start();
QCOMPARE(stateChangedSpy.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(1).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(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<QAbstractAnimation::State>(spy.last().at(1)), TestAnimation::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy.last().first()), TestAnimation::Running);
group.setCurrentTime(250); //end of first animation
QCOMPARE(spy.count(), 2); //the animation should have been stopped
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy.last().at(1)), TestAnimation::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(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<QAbstractAnimation::State>(firstChange.first()), QAbstractAnimation::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(firstChange.last()), QAbstractAnimation::Stopped);
//new state
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(firstChange.last()), QAbstractAnimation::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(firstChange.first()), QAbstractAnimation::Running);
//let's check the first state change
const QVariantList secondChange = spy.last();
//old state
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(secondChange.first()), QAbstractAnimation::Running);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(secondChange.last()), QAbstractAnimation::Running);
//new state
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(secondChange.last()), QAbstractAnimation::Stopped);
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(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<QVariant> args = spy.at(i);
QAbstractAnimation::State st = expectedStates.at(i);
- QAbstractAnimation::State actual = qVariantValue<QAbstractAnimation::State>(args.value(1));
+ QAbstractAnimation::State actual = qVariantValue<QAbstractAnimation::State>(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<QAbstractAnimation::State>(a1StateChangedSpy.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(1).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(1).first()),
QAnimationGroup::Paused);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(2).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(2).first()),
QAnimationGroup::Stopped);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(3).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(3).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(4).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(4).first()),
QAnimationGroup::Stopped);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(1).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(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<QAbstractAnimation::State>(seqStateChangedSpy.at(2).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(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<QAbstractAnimation::State>(seqStateChangedSpy.at(3).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(3).first()),
QAnimationGroup::Paused);
group.stop();
QCOMPARE(seqStateChangedSpy.count(), 5); // Running,Paused,Running,Paused,Stopped
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(4).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(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<QAbstractAnimation::State>(animsStateChanged[i]->at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(1).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(1).first()),
QAnimationGroup::Stopped);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(2).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(2).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(3).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(3).first()),
QAnimationGroup::Stopped);
}
QCOMPARE(seqStateChangedSpy.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(1).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(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<QAbstractAnimation::State>(groupStateChangedSpy.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(childStateChangedSpy.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(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<QAbstractAnimation::State>(stateChangedSpy2.at(2).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(2).first()),
QAnimationGroup::Stopped);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(3).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(3).first()),
QAnimationGroup::Running);
group.stop();
@@ -1359,9 +1359,9 @@ void tst_QSequentialAnimationGroup::zeroDurationAnimation()
group.start();
QCOMPARE(stateChangedSpy.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(0).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(1).at(1)),
+ QCOMPARE(qVariantValue<QAbstractAnimation::State>(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<QAbstractAnimation*>(&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<QAbstractAnimation> 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);
}
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
}
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;
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("<div style='font-family: \"Foo Bar\";'>Test</div>");
QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar"));
+
+ setHtml("<div style='font-family: \"Foo Bar\";'>Test</div>");
+ QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar"));
+
+ setHtml("<div style='font-family: Foo\n Bar;'>Test</div>");
+ QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar"));
+
+ setHtml("<div style='font-family: Foo\n Bar, serif, \"bar foo\";'>Test</div>");
+ QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar,serif,bar foo"));
+
}
void tst_QTextDocumentFragment::defaultFont()
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)
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"));
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;
}
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>437</width>
+ <height>352</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">::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; }</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QTreeWidget" name="treeWidget">
+ <column>
+ <property name="text">
+ <string>1</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>New Column</string>
+ </property>
+ </column>
+ <item>
+ <property name="text">
+ <string>New Item</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>New Item</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>New Item</string>
+ </property>
+ <item>
+ <property name="text">
+ <string>New Subitem</string>
+ </property>
+ <item>
+ <property name="text">
+ <string>New Subitem</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>New Item</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>New Item</string>
+ </property>
+ </item>
+ </item>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QTableWidget" name="tableWidget">
+ <row>
+ <property name="text">
+ <string>New Row</string>
+ </property>
+ </row>
+ <row>
+ <property name="text">
+ <string>New Row</string>
+ </property>
+ </row>
+ <row>
+ <property name="text">
+ <string>New Row</string>
+ </property>
+ </row>
+ <row>
+ <property name="text">
+ <string>New Row</string>
+ </property>
+ </row>
+ <row>
+ <property name="text">
+ <string>New Row</string>
+ </property>
+ </row>
+ <column>
+ <property name="text">
+ <string>New Column</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>New Column</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>New Column</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>New Column</string>
+ </property>
+ </column>
+ <item row="0" column="0">
+ <property name="text">
+ <string>mljkh mh mjl</string>
+ </property>
+ </item>
+ <item row="0" column="1">
+ <property name="text">
+ <string>h jlh mjklh </string>
+ </property>
+ </item>
+ <item row="0" column="2">
+ <property name="text">
+ <string>mjklh mlhj mjlh m</string>
+ </property>
+ </item>
+ <item row="1" column="3">
+ <property name="text">
+ <string>mlhj lmhj </string>
+ </property>
+ </item>
+ <item row="2" column="0">
+ <property name="text">
+ <string>mlkj l</string>
+ </property>
+ </item>
+ <item row="2" column="1">
+ <property name="text">
+ <string>mlkj </string>
+ </property>
+ </item>
+ <item row="2" column="2">
+ <property name="text">
+ <string>mlkj lmkj </string>
+ </property>
+ </item>
+ <item row="2" column="3">
+ <property name="text">
+ <string>mlkhj mlh</string>
+ </property>
+ </item>
+ <item row="3" column="1">
+ <property name="text">
+ <string>mlkj lmkj </string>
+ </property>
+ </item>
+ <item row="4" column="0">
+ <property name="text">
+ <string>mlkj lmkj </string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
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 \