summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorKurt Korbatits <kurt.korbatits@nokia.com>2009-11-10 13:01:07 +1000
committerKurt Korbatits <kurt.korbatits@nokia.com>2009-11-10 13:01:07 +1000
commit8df98549a4d84b5877e50318140c2041e17632fb (patch)
tree0c55d5ef4d8380ec45c6457a40b033dc45cbd579 /tests/auto
parentf55c317e377aaf0b3e24904e88dc1c4a6e15a20a (diff)
parent9a6de1fa0db0da8c4fa5eb904ef6d78cc619e332 (diff)
Merge branch '4.6' of ../qt into 4.6
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/qaccessibility/tst_qaccessibility.cpp21
-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/qdatastream/tst_qdatastream.cpp2
-rw-r--r--tests/auto/qfile/largefile/largefile.pro4
-rw-r--r--tests/auto/qfile/largefile/tst_largefile.cpp537
-rw-r--r--tests/auto/qfile/qfile.pro2
-rw-r--r--tests/auto/qfile/tst_qfile.cpp284
-rw-r--r--tests/auto/qgl/tst_qgl.cpp105
-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/qgridlayout/tst_qgridlayout.cpp4
-rw-r--r--tests/auto/qimage/tst_qimage.cpp24
-rw-r--r--tests/auto/qimagewriter/tst_qimagewriter.cpp2
-rw-r--r--tests/auto/qitemdelegate/tst_qitemdelegate.cpp2
-rw-r--r--tests/auto/qlabel/tst_qlabel.cpp8
-rw-r--r--tests/auto/qlcdnumber/tst_qlcdnumber.cpp16
-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/qnetworkcookie/tst_qnetworkcookie.cpp39
-rw-r--r--tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp18
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp479
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp63
-rw-r--r--tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp136
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp6
-rw-r--r--tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp20
-rw-r--r--tests/auto/qregexp/tst_qregexp.cpp28
-rw-r--r--tests/auto/qregion/tst_qregion.cpp20
-rw-r--r--tests/auto/qscriptengine/tst_qscriptengine.cpp2
-rw-r--r--tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp506
-rw-r--r--tests/auto/qsqlquery/tst_qsqlquery.cpp34
-rw-r--r--tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp4
-rw-r--r--tests/auto/qstatemachine/tst_qstatemachine.cpp31
-rw-r--r--tests/auto/qstringbuilder1/stringbuilder.cpp26
-rw-r--r--tests/auto/qtableview/tst_qtableview.cpp19
-rw-r--r--tests/auto/qtextdocument/tst_qtextdocument.cpp10
-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
52 files changed, 2348 insertions, 1372 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/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp
index 9f2e4e7afb..25c2649e43 100644
--- a/tests/auto/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp
@@ -4034,6 +4034,27 @@ void tst_QAccessibility::labelTest()
delete acc_label;
delete label;
QTestAccessibility::clearEvents();
+
+ QPixmap testPixmap(50, 50);
+ testPixmap.fill();
+
+ QLabel imageLabel;
+ imageLabel.setPixmap(testPixmap);
+ imageLabel.setToolTip("Test Description");
+
+ acc_label = QAccessible::queryAccessibleInterface(&imageLabel);
+ QVERIFY(acc_label);
+
+ QAccessibleImageInterface *imageInterface = acc_label->imageInterface();
+ QVERIFY(imageInterface);
+
+ QCOMPARE(imageInterface->imageSize(), testPixmap.size());
+ QCOMPARE(imageInterface->imageDescription(), QString::fromLatin1("Test Description"));
+ QCOMPARE(imageInterface->imagePosition(QAccessible2::RelativeToParent), imageLabel.geometry());
+
+ delete acc_label;
+
+ QTestAccessibility::clearEvents();
#else
QSKIP("Test needs accessibility support.", SkipAll);
#endif
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/qdatastream/tst_qdatastream.cpp b/tests/auto/qdatastream/tst_qdatastream.cpp
index 56fc53a235..7535645d1e 100644
--- a/tests/auto/qdatastream/tst_qdatastream.cpp
+++ b/tests/auto/qdatastream/tst_qdatastream.cpp
@@ -1461,7 +1461,7 @@ void tst_QDataStream::readQImage(QDataStream *s)
QVERIFY(d12.width() == ref.width());
QVERIFY(d12.height() == ref.height());
QVERIFY(d12.depth() == ref.depth());
- QVERIFY(d12.numColors() == ref.numColors());
+ QVERIFY(d12.colorCount() == ref.colorCount());
#ifdef QT3_SUPPORT
QVERIFY(d12.hasAlphaBuffer() == ref.hasAlphaBuffer());
#else
diff --git a/tests/auto/qfile/largefile/largefile.pro b/tests/auto/qfile/largefile/largefile.pro
new file mode 100644
index 0000000000..0f968659a1
--- /dev/null
+++ b/tests/auto/qfile/largefile/largefile.pro
@@ -0,0 +1,4 @@
+load(qttest_p4)
+
+QT = core
+SOURCES += tst_largefile.cpp
diff --git a/tests/auto/qfile/largefile/tst_largefile.cpp b/tests/auto/qfile/largefile/tst_largefile.cpp
new file mode 100644
index 0000000000..9105063e73
--- /dev/null
+++ b/tests/auto/qfile/largefile/tst_largefile.cpp
@@ -0,0 +1,537 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QTest>
+
+#include <QtAlgorithms>
+#include <QFile>
+#include <QFileInfo>
+#include <qplatformdefs.h>
+
+#include <QDebug>
+
+#include <cstdlib>
+#include <cstdio>
+
+#ifdef Q_OS_WIN
+
+#include <windows.h>
+#include <io.h>
+
+#ifndef FSCTL_SET_SPARSE
+// MinGW doesn't define this.
+#define FSCTL_SET_SPARSE (0x900C4)
+#endif
+
+#endif // Q_OS_WIN
+
+class tst_LargeFile
+ : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_LargeFile()
+ : blockSize(1 << 12)
+ , maxSizeBits()
+ , fd_(-1)
+ , stream_(0)
+ {
+ #if defined(QT_LARGEFILE_SUPPORT) && !defined(Q_OS_MAC)
+ maxSizeBits = 36; // 64 GiB
+ #elif defined(Q_OS_MAC)
+ // HFS+ does not support sparse files, so we limit file size for the test
+ // on Mac OS.
+ maxSizeBits = 32; // 4 GiB
+ #else
+ maxSizeBits = 24; // 16 MiB
+ #endif
+ }
+
+private:
+ void sparseFileData();
+ QByteArray const &getDataBlock(int index, qint64 position);
+
+private slots:
+ // The LargeFile test case was designed to be run in order as a single unit
+
+ void initTestCase();
+ void cleanupTestCase();
+
+ void init();
+ void cleanup();
+
+ // Create and fill large file
+ void createSparseFile();
+ void fillFileSparsely();
+ void closeSparseFile();
+
+ // Verify file was created
+ void fileCreated();
+
+ // Positioning in large files
+ void filePositioning();
+ void fdPositioning();
+ void streamPositioning();
+
+ // Read data from file
+ void openFileForReading();
+ void readFile();
+
+ // Map/unmap large file
+ void mapFile();
+ void mapOffsetOverflow();
+
+ void closeFile() { largeFile.close(); }
+
+ // Test data
+ void fillFileSparsely_data() { sparseFileData(); }
+ void filePositioning_data() { sparseFileData(); }
+ void fdPositioning_data() { sparseFileData(); }
+ void streamPositioning_data() { sparseFileData(); }
+ void readFile_data() { sparseFileData(); }
+ void mapFile_data() { sparseFileData(); }
+
+private:
+ const int blockSize;
+ int maxSizeBits;
+
+ QFile largeFile;
+
+ QVector<QByteArray> generatedBlocks;
+
+ int fd_;
+ FILE *stream_;
+};
+
+/*
+ Convenience function to hide reinterpret_cast when copying a POD directly
+ into a QByteArray.
+ */
+template <class T>
+static inline void appendRaw(QByteArray &array, T data)
+{
+ array.append(reinterpret_cast<char *>(&data), sizeof(T));
+}
+
+/*
+ Pad array with filler up to size. On return, array.size() returns size.
+ */
+static inline void topUpWith(QByteArray &array, QByteArray filler, int size)
+{
+ Q_ASSERT(filler.size() > 0);
+
+ for (int i = (size - array.size()) / filler.size(); i > 0; --i)
+ array.append(filler);
+
+ if (array.size() < size) {
+ Q_ASSERT(size - array.size() < filler.size());
+ array.append(filler.left(size - array.size()));
+ }
+}
+
+/*
+ Generate a unique data block containing identifiable data. Unaligned,
+ overlapping and partial blocks should not compare equal.
+ */
+static inline QByteArray generateDataBlock(int blockSize, QString text, qint64 userBits = -1)
+{
+ QByteArray block;
+ block.reserve(blockSize);
+
+ // Use of counter and randomBits means content of block will be dependent
+ // on the generation order. For (file-)systems that do not support sparse
+ // files, these can be removed so the test file can be reused and doesn't
+ // have to be generated for every run.
+
+ static qint64 counter = 0;
+
+ qint64 randomBits = ((qint64)qrand() << 32)
+ | ((qint64)qrand() & 0x00000000ffffffff);
+
+ appendRaw(block, randomBits);
+ appendRaw(block, userBits);
+ appendRaw(block, counter);
+ appendRaw(block, (qint32)0xdeadbeef);
+ appendRaw(block, blockSize);
+
+ QByteArray userContent = text.toUtf8();
+ appendRaw(block, userContent.size());
+ block.append(userContent);
+ appendRaw(block, (qint64)0);
+
+ // size, so far
+ appendRaw(block, block.size());
+
+ QByteArray filler("0123456789");
+ block.append(filler.right(10 - block.size() % 10));
+ topUpWith(block, filler, blockSize - 2 * sizeof(qint64));
+
+ appendRaw(block, counter);
+ appendRaw(block, userBits);
+ appendRaw(block, randomBits);
+
+ Q_ASSERT( block.size() >= blockSize );
+ block.resize(blockSize);
+
+ ++counter;
+ return block;
+}
+
+/*
+ Generates data blocks the first time they are requested. Keeps copies for reuse.
+ */
+QByteArray const &tst_LargeFile::getDataBlock(int index, qint64 position)
+{
+ if (index >= generatedBlocks.size())
+ generatedBlocks.resize(index + 1);
+
+ if (generatedBlocks[index].isNull()) {
+ QString text = QString("Current %1-byte block (index = %2) "
+ "starts %3 bytes into the file '%4'.")
+ .arg(blockSize)
+ .arg(index)
+ .arg(position)
+ .arg("qt_largefile.tmp");
+
+ generatedBlocks[index] = generateDataBlock(blockSize, text, (qint64)1 << index);
+ }
+
+ return generatedBlocks[index];
+}
+
+void tst_LargeFile::initTestCase()
+{
+ QFile file("qt_largefile.tmp");
+ QVERIFY( !file.exists() || file.remove() );
+}
+
+void tst_LargeFile::cleanupTestCase()
+{
+ if (largeFile.isOpen())
+ largeFile.close();
+
+ QFile file("qt_largefile.tmp");
+ QVERIFY( !file.exists() || file.remove() );
+}
+
+void tst_LargeFile::init()
+{
+ fd_ = -1;
+ stream_ = 0;
+}
+
+void tst_LargeFile::cleanup()
+{
+ if (-1 != fd_)
+ QT_CLOSE(fd_);
+ if (stream_)
+ ::fclose(stream_);
+}
+
+void tst_LargeFile::sparseFileData()
+{
+ QTest::addColumn<int>("index");
+ QTest::addColumn<qint64>("position");
+ QTest::addColumn<QByteArray>("block");
+
+ QTest::newRow(QString("block[%1] @%2)")
+ .arg(0).arg(0)
+ .toLocal8Bit().constData())
+ << 0 << (qint64)0 << getDataBlock(0, 0);
+
+ // While on Linux sparse files scale well, on Windows, testing at every
+ // power of 2 leads to very large files. i += 4 gives us a good coverage
+ // without taxing too much on resources.
+ for (int index = 12; index <= maxSizeBits; index += 4) {
+ qint64 position = (qint64)1 << index;
+ QByteArray block = getDataBlock(index, position);
+
+ QTest::newRow(
+ QString("block[%1] @%2)")
+ .arg(index).arg(position)
+ .toLocal8Bit().constData())
+ << index << position << block;
+ }
+}
+
+void tst_LargeFile::createSparseFile()
+{
+#if defined(Q_OS_WIN)
+ // On Windows platforms, we must explicitly set the file to be sparse,
+ // so disk space is not allocated for the full file when writing to it.
+ HANDLE handle = ::CreateFileA("qt_largefile.tmp",
+ GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
+ QVERIFY( INVALID_HANDLE_VALUE != handle );
+
+ DWORD bytes;
+ if (!::DeviceIoControl(handle, FSCTL_SET_SPARSE, NULL, 0, NULL, 0,
+ &bytes, NULL)) {
+ QWARN("Unable to set test file as sparse. "
+ "Limiting test file to 16MiB.");
+ maxSizeBits = 24;
+ }
+
+ int fd = ::_open_osfhandle((intptr_t)handle, 0);
+ QVERIFY( -1 != fd );
+ QVERIFY( largeFile.open(fd, QIODevice::WriteOnly | QIODevice::Unbuffered) );
+#else // !Q_OS_WIN
+ largeFile.setFileName("qt_largefile.tmp");
+ QVERIFY( largeFile.open(QIODevice::WriteOnly | QIODevice::Unbuffered) );
+#endif
+}
+
+void tst_LargeFile::closeSparseFile()
+{
+#if defined(Q_OS_WIN)
+ int fd = largeFile.handle();
+#endif
+
+ largeFile.close();
+
+#if defined(Q_OS_WIN)
+ if (-1 != fd)
+ ::_close(fd);
+#endif
+}
+
+void tst_LargeFile::fillFileSparsely()
+{
+ QFETCH( qint64, position );
+ QFETCH( QByteArray, block );
+ QCOMPARE( block.size(), blockSize );
+
+ 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()
+{
+ QFileInfo info("qt_largefile.tmp");
+
+ QVERIFY( info.exists() );
+ QVERIFY( info.isFile() );
+ QVERIFY( info.size() >= ((qint64)1 << maxSizeBits) + blockSize );
+}
+
+void tst_LargeFile::filePositioning()
+{
+ QFETCH( qint64, position );
+
+ QFile file("qt_largefile.tmp");
+ QVERIFY( file.open(QIODevice::ReadOnly) );
+
+ QVERIFY( file.seek(position) );
+ QCOMPARE( file.pos(), position );
+}
+
+void tst_LargeFile::fdPositioning()
+{
+ QFETCH( qint64, position );
+
+ fd_ = QT_OPEN("qt_largefile.tmp",
+ QT_OPEN_RDONLY | QT_OPEN_LARGEFILE);
+ QVERIFY( -1 != fd_ );
+
+ QFile file;
+ QVERIFY( file.open(fd_, QIODevice::ReadOnly) );
+ QCOMPARE( file.pos(), (qint64)0 );
+ QVERIFY( file.seek(position) );
+ QCOMPARE( file.pos(), position );
+
+ file.close();
+
+ QCOMPARE( QT_LSEEK(fd_, QT_OFF_T(0), SEEK_SET), QT_OFF_T(0) );
+ QCOMPARE( QT_LSEEK(fd_, QT_OFF_T(position), SEEK_SET), QT_OFF_T(position) );
+
+ QVERIFY( file.open(fd_, QIODevice::ReadOnly) );
+ QCOMPARE( QT_LSEEK(fd_, QT_OFF_T(0), SEEK_CUR), QT_OFF_T(position) );
+ QCOMPARE( file.pos(), position );
+ QVERIFY( file.seek(0) );
+ QCOMPARE( file.pos(), (qint64)0 );
+
+ file.close();
+
+ QVERIFY( !QT_CLOSE(fd_) );
+ fd_ = -1;
+}
+
+void tst_LargeFile::streamPositioning()
+{
+ QFETCH( qint64, position );
+
+#if defined(QT_LARGEFILE_SUPPORT) && defined(Q_CC_MSVC) && _MSC_VER < 1400
+ if (position >= (qint64)1 << 31)
+ QSKIP("MSVC 2003 doesn't have 64 bit versions of fseek/ftell.", SkipSingle);
+#endif
+
+ stream_ = QT_FOPEN("qt_largefile.tmp", "rb");
+ QVERIFY( 0 != stream_ );
+
+ QFile file;
+ QVERIFY( file.open(stream_, QIODevice::ReadOnly) );
+ QCOMPARE( file.pos(), (qint64)0 );
+ QVERIFY( file.seek(position) );
+ QCOMPARE( file.pos(), position );
+
+ file.close();
+
+ QVERIFY( !QT_FSEEK(stream_, QT_OFF_T(0), SEEK_SET) );
+ QCOMPARE( QT_FTELL(stream_), QT_OFF_T(0) );
+ QVERIFY( !QT_FSEEK(stream_, QT_OFF_T(position), SEEK_SET) );
+ QCOMPARE( QT_FTELL(stream_), QT_OFF_T(position) );
+
+ QVERIFY( file.open(stream_, QIODevice::ReadOnly) );
+ QCOMPARE( QT_FTELL(stream_), QT_OFF_T(position) );
+ QCOMPARE( file.pos(), position );
+ QVERIFY( file.seek(0) );
+ QCOMPARE( file.pos(), (qint64)0 );
+
+ file.close();
+
+ QVERIFY( !::fclose(stream_) );
+ stream_ = 0;
+}
+
+void tst_LargeFile::openFileForReading()
+{
+ largeFile.setFileName("qt_largefile.tmp");
+ QVERIFY( largeFile.open(QIODevice::ReadOnly) );
+}
+
+void tst_LargeFile::readFile()
+{
+ QFETCH( qint64, position );
+ QFETCH( QByteArray, block );
+ QCOMPARE( block.size(), blockSize );
+
+ QVERIFY( largeFile.size() >= position + blockSize );
+
+ QVERIFY( largeFile.seek(position) );
+ QCOMPARE( largeFile.pos(), position );
+
+ QCOMPARE( largeFile.read(blockSize), block );
+ QCOMPARE( largeFile.pos(), position + blockSize );
+}
+
+void tst_LargeFile::mapFile()
+{
+ QFETCH( qint64, position );
+ QFETCH( QByteArray, block );
+ QCOMPARE( block.size(), blockSize );
+
+ // Keep full block mapped to facilitate OS and/or internal reuse by Qt.
+ uchar *baseAddress = largeFile.map(position, blockSize);
+ QVERIFY( baseAddress );
+ QVERIFY( qEqual(block.begin(), block.end(), reinterpret_cast<char*>(baseAddress)) );
+
+ for (int offset = 1; offset < blockSize; ++offset) {
+ uchar *address = largeFile.map(position + offset, blockSize - offset);
+
+ QVERIFY( address );
+ if ( !qEqual(block.begin() + offset, block.end(), reinterpret_cast<char*>(address)) ) {
+ qDebug() << "Expected:" << block.toHex();
+ qDebug() << "Actual :" << QByteArray(reinterpret_cast<char*>(address), blockSize).toHex();
+ QVERIFY(false);
+ }
+
+ QVERIFY( largeFile.unmap( address ) );
+ }
+
+ QVERIFY( largeFile.unmap( baseAddress ) );
+}
+
+void tst_LargeFile::mapOffsetOverflow()
+{
+ // Out-of-range mappings should fail, and not silently clip the offset
+ for (int i = 50; i < 63; ++i) {
+ uchar *address = 0;
+
+ address = largeFile.map(((qint64)1 << i), blockSize);
+ QVERIFY( !address );
+
+ address = largeFile.map(((qint64)1 << i) + blockSize, blockSize);
+ QVERIFY( !address );
+ }
+}
+
+QTEST_APPLESS_MAIN(tst_LargeFile)
+#include "tst_largefile.moc"
+
diff --git a/tests/auto/qfile/qfile.pro b/tests/auto/qfile/qfile.pro
index eebfcdafe9..f70f75025b 100644
--- a/tests/auto/qfile/qfile.pro
+++ b/tests/auto/qfile/qfile.pro
@@ -5,5 +5,5 @@ wince*:{
SUBDIRS = test stdinprocess
}
-
+SUBDIRS += largefile
diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp
index 19fbecd239..b3d6fd917e 100644
--- a/tests/auto/qfile/tst_qfile.cpp
+++ b/tests/auto/qfile/tst_qfile.cpp
@@ -79,6 +79,22 @@
# define SRCDIR ""
#endif
+#ifndef STDIN_FILENO
+#define STDIN_FILENO 0
+#endif
+
+#ifndef STDOUT_FILENO
+#define STDOUT_FILENO 1
+#endif
+
+#ifndef STDERR_FILENO
+#define STDERR_FILENO 2
+#endif
+
+#ifndef QT_OPEN_BINARY
+#define QT_OPEN_BINARY 0
+#endif
+
Q_DECLARE_METATYPE(QFile::FileError)
//TESTED_CLASS=
@@ -105,6 +121,7 @@ private slots:
void openUnbuffered();
void size_data();
void size();
+ void sizeNoExist();
void seek();
void setSize();
void setSizeSeek();
@@ -187,6 +204,8 @@ private slots:
void mapOpenMode_data();
void mapOpenMode();
+ void openStandardStreams();
+
// --- Task related tests below this line
void task167217();
@@ -196,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()
@@ -211,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()
@@ -239,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()
@@ -438,23 +539,57 @@ void tst_QFile::openUnbuffered()
void tst_QFile::size_data()
{
QTest::addColumn<QString>("filename");
- QTest::addColumn<int>("size");
+ QTest::addColumn<qint64>("size");
- QTest::newRow( "exist01" ) << QString(SRCDIR "testfile.txt") << 245;
- QTest::newRow( "nonexist01" ) << QString("foo.txt") << 0;
+ QTest::newRow( "exist01" ) << QString(SRCDIR "testfile.txt") << (qint64)245;
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
// Only test UNC on Windows./
- QTest::newRow("unc") << "//" + QString(QtNetworkSettings::winServerName() + "/testsharewritable/test.pri") << 34;
+ QTest::newRow("unc") << "//" + QString(QtNetworkSettings::winServerName() + "/testsharewritable/test.pri") << (qint64)34;
#endif
}
void tst_QFile::size()
{
QFETCH( QString, filename );
- QFile f( filename );
- QTEST( (int)f.size(), "size" );
- if (f.open(QFile::ReadOnly))
- QTEST( (int)f.size(), "size" );
+ QFETCH( qint64, size );
+
+ {
+ QFile f( filename );
+ QCOMPARE( f.size(), size );
+
+ QVERIFY( f.open(QIODevice::ReadOnly) );
+ QCOMPARE( f.size(), size );
+ }
+
+ {
+ QFile f;
+ int fd = QT_OPEN(filename.toLocal8Bit().constData(), QT_OPEN_RDONLY);
+ QVERIFY( fd != -1 );
+ QVERIFY( f.open(fd, QIODevice::ReadOnly) );
+ QCOMPARE( f.size(), size );
+
+ f.close();
+ QT_CLOSE(fd);
+ }
+
+ {
+ QFile f;
+ FILE* stream = QT_FOPEN(filename.toLocal8Bit().constData(), "rb");
+ QVERIFY( stream );
+ QVERIFY( f.open(stream, QIODevice::ReadOnly) );
+ QCOMPARE( f.size(), size );
+
+ f.close();
+ fclose(stream);
+ }
+}
+
+void tst_QFile::sizeNoExist()
+{
+ QFile file("nonexist01");
+ QVERIFY( !file.exists() );
+ QCOMPARE( file.size(), (qint64)0 );
+ QVERIFY( !file.open(QIODevice::ReadOnly) );
}
void tst_QFile::seek()
@@ -1909,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()
@@ -2634,5 +2787,58 @@ void tst_QFile::openDirectory()
QVERIFY(!f1.open(QIODevice::ReadOnly|QIODevice::Unbuffered));
}
+void tst_QFile::openStandardStreams()
+{
+ // Using file descriptors
+ {
+ QFile in;
+ in.open(STDIN_FILENO, QIODevice::ReadOnly);
+ QCOMPARE( in.pos(), (qint64)0 );
+ QCOMPARE( in.size(), (qint64)0 );
+ QVERIFY( in.isSequential() );
+ }
+
+ {
+ QFile out;
+ out.open(STDOUT_FILENO, QIODevice::WriteOnly);
+ QCOMPARE( out.pos(), (qint64)0 );
+ QCOMPARE( out.size(), (qint64)0 );
+ QVERIFY( out.isSequential() );
+ }
+
+ {
+ QFile err;
+ err.open(STDERR_FILENO, QIODevice::WriteOnly);
+ QCOMPARE( err.pos(), (qint64)0 );
+ QCOMPARE( err.size(), (qint64)0 );
+ QVERIFY( err.isSequential() );
+ }
+
+ // Using streams
+ {
+ QFile in;
+ in.open(stdin, QIODevice::ReadOnly);
+ QCOMPARE( in.pos(), (qint64)0 );
+ QCOMPARE( in.size(), (qint64)0 );
+ QVERIFY( in.isSequential() );
+ }
+
+ {
+ QFile out;
+ out.open(stdout, QIODevice::WriteOnly);
+ QCOMPARE( out.pos(), (qint64)0 );
+ QCOMPARE( out.size(), (qint64)0 );
+ QVERIFY( out.isSequential() );
+ }
+
+ {
+ QFile err;
+ err.open(stderr, QIODevice::WriteOnly);
+ QCOMPARE( err.pos(), (qint64)0 );
+ QCOMPARE( err.size(), (qint64)0 );
+ QVERIFY( err.isSequential() );
+ }
+}
+
QTEST_MAIN(tst_QFile)
#include "tst_qfile.moc"
diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp
index e9f0476e0b..c680decc01 100644
--- a/tests/auto/qgl/tst_qgl.cpp
+++ b/tests/auto/qgl/tst_qgl.cpp
@@ -82,7 +82,6 @@ private slots:
void glPBufferRendering();
void glWidgetReparent();
void glWidgetRenderPixmap();
- void stackedFBOs();
void colormap();
void fboFormat();
void testDontCrashOnDanglingResources();
@@ -1226,110 +1225,6 @@ void tst_QGL::glWidgetRenderPixmap()
QCOMPARE(fb, reference);
}
-
-// When using multiple FBOs at the same time, unbinding one FBO should re-bind the
-// previous. I.e. It should be possible to have a stack of FBOs where pop'ing there
-// top re-binds the one underneeth.
-void tst_QGL::stackedFBOs()
-{
- if (!QGLFramebufferObject::hasOpenGLFramebufferObjects())
- QSKIP("QGLFramebufferObject not supported on this platform", SkipSingle);
-
- QGLWidget glw;
- glw.show();
-
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&glw);
-#endif
- QTest::qWait(200);
-
- glw.makeCurrent();
-
- // No multisample with combined depth/stencil attachment:
- QGLFramebufferObjectFormat fboFormat;
- fboFormat.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
-
- // Don't complicate things by using NPOT:
- QGLFramebufferObject *fbo1 = new QGLFramebufferObject(128, 128, fboFormat);
- QGLFramebufferObject *fbo2 = new QGLFramebufferObject(128, 128, fboFormat);
- QGLFramebufferObject *fbo3 = new QGLFramebufferObject(128, 128, fboFormat);
-
- glClearColor(1.0, 0.0, 1.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
-
- fbo1->bind();
- glClearColor(1.0, 0.0, 0.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
-
- fbo2->bind();
- glClearColor(0.0, 1.0, 0.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
-
- fbo3->bind();
- glClearColor(0.0, 0.0, 1.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
- glScissor(32, 32, 64, 64);
- glEnable(GL_SCISSOR_TEST);
- glClearColor(0.0, 1.0, 1.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
- fbo3->release();
-
- // Scissor rect & test should be left untouched by the fbo release...
- glClearColor(0.0, 0.0, 0.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
- fbo2->release();
-
- glClearColor(1.0, 1.0, 1.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
- fbo1->release();
-
- glClearColor(1.0, 1.0, 0.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
-
- glw.swapBuffers();
-
- QImage widgetFB = glw.grabFrameBuffer(false).convertToFormat(QImage::Format_RGB32);
- QImage fb1 = fbo1->toImage().convertToFormat(QImage::Format_RGB32);
- QImage fb2 = fbo2->toImage().convertToFormat(QImage::Format_RGB32);
- QImage fb3 = fbo3->toImage().convertToFormat(QImage::Format_RGB32);
-
- delete fbo1;
- delete fbo2;
- delete fbo3;
-
- QImage widgetReference(widgetFB.size(), widgetFB.format());
- QImage fb1Reference(fb1.size(), fb1.format());
- QImage fb2Reference(fb2.size(), fb2.format());
- QImage fb3Reference(fb3.size(), fb3.format());
-
- QPainter widgetReferencePainter(&widgetReference);
- QPainter fb1ReferencePainter(&fb1Reference);
- QPainter fb2ReferencePainter(&fb2Reference);
- QPainter fb3ReferencePainter(&fb3Reference);
-
- widgetReferencePainter.fillRect(0, 0, widgetReference.width(), widgetReference.height(), Qt::magenta);
- fb1ReferencePainter.fillRect(0, 0, fb1Reference.width(), fb1Reference.height(), Qt::red);
- fb2ReferencePainter.fillRect(0, 0, fb2Reference.width(), fb2Reference.height(), Qt::green);
- fb3ReferencePainter.fillRect(0, 0, fb3Reference.width(), fb3Reference.height(), Qt::blue);
-
- // Flip y-coords to match GL for the widget (which can be any size)
- widgetReferencePainter.fillRect(32, glw.height() - 96, 64, 64, Qt::yellow);
- fb1ReferencePainter.fillRect(32, 32, 64, 64, Qt::white);
- fb2ReferencePainter.fillRect(32, 32, 64, 64, Qt::black);
- fb3ReferencePainter.fillRect(32, 32, 64, 64, Qt::cyan);
-
- widgetReferencePainter.end();
- fb1ReferencePainter.end();
- fb2ReferencePainter.end();
- fb3ReferencePainter.end();
-
- QCOMPARE(widgetFB, widgetReference);
- QCOMPARE(fb1, fb1Reference);
- QCOMPARE(fb2, fb2Reference);
- QCOMPARE(fb3, fb3Reference);
-}
-
-
class ColormapExtended : public QGLColormap
{
public:
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/qgridlayout/tst_qgridlayout.cpp b/tests/auto/qgridlayout/tst_qgridlayout.cpp
index 7c320be2ef..46e2a03c32 100644
--- a/tests/auto/qgridlayout/tst_qgridlayout.cpp
+++ b/tests/auto/qgridlayout/tst_qgridlayout.cpp
@@ -920,9 +920,9 @@ void tst_QGridLayout::minMaxSize()
#if defined(Q_WS_X11)
qt_x11_wait_for_window_manager(m_toplevel); // wait for the show
#endif
- QTest::qWait(20);
+ QTest::qWait(40);
m_toplevel->adjustSize();
- QTest::qWait(120); // wait for the implicit adjustSize
+ QTest::qWait(240); // wait for the implicit adjustSize
// If the following fails we might have to wait longer.
// If that does not help there is likely a problem with the implicit adjustSize in show()
if (!fixedSize.isValid()) {
diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp
index e15ae8a645..da4e85d074 100644
--- a/tests/auto/qimage/tst_qimage.cpp
+++ b/tests/auto/qimage/tst_qimage.cpp
@@ -104,7 +104,7 @@ private slots:
void setPixel_data();
void setPixel();
- void setNumColors();
+ void setColorCount();
void setColor();
void rasterClipping();
@@ -155,7 +155,7 @@ void tst_QImage::create()
#endif
//QImage image(7000000, 7000000, 8, 256, QImage::IgnoreEndian);
QImage image(7000000, 7000000, QImage::Format_Indexed8);
- image.setNumColors(256);
+ image.setColorCount(256);
cr = !image.isNull();
#if !defined(Q_WS_QWS) && !defined(Q_OS_WINCE)
} catch (...) {
@@ -242,7 +242,7 @@ void tst_QImage::convertBitOrder()
QSKIP("Qt compiled without Qt3Support", SkipAll);
#else
QImage i(9,5,1,2,QImage::LittleEndian);
- qMemSet(i.bits(), 0, i.numBytes());
+ qMemSet(i.bits(), 0, i.byteCount());
i.setDotsPerMeterX(9);
i.setDotsPerMeterY(5);
@@ -258,7 +258,7 @@ void tst_QImage::convertBitOrder()
QVERIFY(i.dotsPerMeterY() == ni.dotsPerMeterY());
QVERIFY(i.depth() == ni.depth());
QVERIFY(i.size() == ni.size());
- QVERIFY(i.numColors() == ni.numColors());
+ QVERIFY(i.colorCount() == ni.colorCount());
#endif
}
@@ -365,7 +365,7 @@ void tst_QImage::setAlphaChannel()
QImage alphaChannel;
if (gray) {
alphaChannel = QImage(width, height, QImage::Format_Indexed8);
- alphaChannel.setNumColors(256);
+ alphaChannel.setColorCount(256);
for (int i=0; i<256; ++i)
alphaChannel.setColor(i, qRgb(i, i, i));
alphaChannel.fill(alpha);
@@ -927,7 +927,7 @@ void tst_QImage::rotate()
original.fill(qRgb(255,255,255));
if (format == QImage::Format_Indexed8) {
- original.setNumColors(256);
+ original.setColorCount(256);
for (int i = 0; i < 255; ++i)
original.setColor(i, qRgb(0, i, i));
}
@@ -1196,23 +1196,23 @@ void tst_QImage::convertToFormatPreserveText()
}
#endif // QT_NO_IMAGE_TEXT
-void tst_QImage::setNumColors()
+void tst_QImage::setColorCount()
{
QImage img(0, 0, QImage::Format_Indexed8);
- QTest::ignoreMessage(QtWarningMsg, "QImage::setNumColors: null image");
- img.setNumColors(256);
- QCOMPARE(img.numColors(), 0);
+ QTest::ignoreMessage(QtWarningMsg, "QImage::setColorCount: null image");
+ img.setColorCount(256);
+ QCOMPARE(img.colorCount(), 0);
}
void tst_QImage::setColor()
{
QImage img(0, 0, QImage::Format_Indexed8);
img.setColor(0, qRgba(18, 219, 108, 128));
- QCOMPARE(img.numColors(), 0);
+ QCOMPARE(img.colorCount(), 0);
QImage img2(1, 1, QImage::Format_Indexed8);
img2.setColor(0, qRgba(18, 219, 108, 128));
- QCOMPARE(img2.numColors(), 1);
+ QCOMPARE(img2.colorCount(), 1);
}
/* Just some sanity checking that we don't draw outside the buffer of
diff --git a/tests/auto/qimagewriter/tst_qimagewriter.cpp b/tests/auto/qimagewriter/tst_qimagewriter.cpp
index 584a0602bb..ab5572dc58 100644
--- a/tests/auto/qimagewriter/tst_qimagewriter.cpp
+++ b/tests/auto/qimagewriter/tst_qimagewriter.cpp
@@ -546,7 +546,7 @@ void tst_QImageWriter::saveWithNoFormat()
QFETCH(QImageWriter::ImageWriterError, error);
QImage niceImage(64, 64, QImage::Format_ARGB32);
- qMemSet(niceImage.bits(), 0, niceImage.numBytes());
+ qMemSet(niceImage.bits(), 0, niceImage.byteCount());
QImageWriter writer(fileName /* , 0 - no format! */);
if (error != 0) {
diff --git a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
index 426887d7cf..a2770d49d3 100644
--- a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
@@ -877,7 +877,7 @@ void tst_QItemDelegate::decoration()
}
case QVariant::Image: {
QImage img(size, QImage::Format_Mono);
- qMemSet(img.bits(), 0, img.numBytes());
+ qMemSet(img.bits(), 0, img.byteCount());
value = img;
break;
}
diff --git a/tests/auto/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/qlcdnumber/tst_qlcdnumber.cpp b/tests/auto/qlcdnumber/tst_qlcdnumber.cpp
index c18ce24175..3f52c708db 100644
--- a/tests/auto/qlcdnumber/tst_qlcdnumber.cpp
+++ b/tests/auto/qlcdnumber/tst_qlcdnumber.cpp
@@ -74,14 +74,14 @@ tst_QLCDNumber::~tst_QLCDNumber()
void tst_QLCDNumber::getSetCheck()
{
QLCDNumber obj1;
- // int QLCDNumber::numDigits()
- // void QLCDNumber::setNumDigits(int)
- obj1.setNumDigits(0);
- QCOMPARE(0, obj1.numDigits());
- obj1.setNumDigits(INT_MIN);
- QCOMPARE(0, obj1.numDigits()); // Range<0, 99>
- obj1.setNumDigits(INT_MAX);
- QCOMPARE(99, obj1.numDigits()); // Range<0, 99>
+ // int QLCDNumber::digitCount()
+ // void QLCDNumber::setDigitCount(int)
+ obj1.setDigitCount(0);
+ QCOMPARE(0, obj1.digitCount());
+ obj1.setDigitCount(INT_MIN);
+ QCOMPARE(0, obj1.digitCount()); // Range<0, 99>
+ obj1.setDigitCount(INT_MAX);
+ QCOMPARE(99, obj1.digitCount()); // Range<0, 99>
}
QTEST_MAIN(tst_QLCDNumber)
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/qnetworkcookie/tst_qnetworkcookie.cpp b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp
index 3c4ddd497c..94857d7b4d 100644
--- a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp
+++ b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp
@@ -234,7 +234,7 @@ void tst_QNetworkCookie::parseSingleCookie_data()
QTest::newRow("path-with-utf8-2") << "a=b;path=/R%C3%A9sum%C3%A9" << cookie;
cookie.setPath(QString());
- cookie.setDomain(".qt.nokia.com");
+ cookie.setDomain("qt.nokia.com");
QTest::newRow("plain-domain1") << "a=b;domain=qt.nokia.com" << cookie;
QTest::newRow("plain-domain2") << "a=b; domain=qt.nokia.com " << cookie;
QTest::newRow("plain-domain3") << "a=b;domain=QT.NOKIA.COM" << cookie;
@@ -247,32 +247,25 @@ void tst_QNetworkCookie::parseSingleCookie_data()
QTest::newRow("dot-domain4") << "a=b; Domain = .QT.NOKIA.COM" << cookie;
cookie.setDomain(QString::fromUtf8(".d\303\270gn\303\245pent.troll.no"));
- QTest::newRow("idn-domain1") << "a=b;domain=xn--dgnpent-gxa2o.troll.no" << cookie;
- QTest::newRow("idn-domain2") << "a=b;domain=d\303\270gn\303\245pent.troll.no" << cookie;
- QTest::newRow("idn-domain3") << "a=b;domain=XN--DGNPENT-GXA2O.TROLL.NO" << cookie;
- QTest::newRow("idn-domain4") << "a=b;domain=D\303\230GN\303\205PENT.troll.NO" << cookie;
- QTest::newRow("idn-domain5") << "a=b;domain = D\303\230GN\303\205PENT.troll.NO" << cookie;
-
- cookie.setDomain(QString::fromUtf8(".d\303\270gn\303\245pent.troll.no"));
- QTest::newRow("dot-idn-domain1") << "a=b;domain=.xn--dgnpent-gxa2o.troll.no" << cookie;
- QTest::newRow("dot-idn-domain2") << "a=b;domain=.d\303\270gn\303\245pent.troll.no" << cookie;
- QTest::newRow("dot-idn-domain3") << "a=b;domain=.XN--DGNPENT-GXA2O.TROLL.NO" << cookie;
- QTest::newRow("dot-idn-domain4") << "a=b;domain=.D\303\230GN\303\205PENT.troll.NO" << cookie;
+ QTest::newRow("idn-domain1") << "a=b;domain=.xn--dgnpent-gxa2o.troll.no" << cookie;
+ QTest::newRow("idn-domain2") << "a=b;domain=.d\303\270gn\303\245pent.troll.no" << cookie;
+ QTest::newRow("idn-domain3") << "a=b;domain=.XN--DGNPENT-GXA2O.TROLL.NO" << cookie;
+ QTest::newRow("idn-domain4") << "a=b;domain=.D\303\230GN\303\205PENT.troll.NO" << cookie;
cookie.setDomain(".qt.nokia.com");
cookie.setPath("/");
- QTest::newRow("two-fields") << "a=b;domain=qt.nokia.com;path=/" << cookie;
- QTest::newRow("two-fields2") << "a=b; domain=qt.nokia.com; path=/" << cookie;
- QTest::newRow("two-fields3") << "a=b; domain=qt.nokia.com ; path=/ " << cookie;
- QTest::newRow("two-fields4") << "a=b;path=/; domain=qt.nokia.com" << cookie;
- QTest::newRow("two-fields5") << "a=b; path=/ ; domain=qt.nokia.com" << cookie;
- QTest::newRow("two-fields6") << "a=b; path= / ; domain =qt.nokia.com" << cookie;
+ QTest::newRow("two-fields") << "a=b;domain=.qt.nokia.com;path=/" << cookie;
+ QTest::newRow("two-fields2") << "a=b; domain=.qt.nokia.com; path=/" << cookie;
+ QTest::newRow("two-fields3") << "a=b; domain=.qt.nokia.com ; path=/ " << cookie;
+ QTest::newRow("two-fields4") << "a=b;path=/; domain=.qt.nokia.com" << cookie;
+ QTest::newRow("two-fields5") << "a=b; path=/ ; domain=.qt.nokia.com" << cookie;
+ QTest::newRow("two-fields6") << "a=b; path= / ; domain =.qt.nokia.com" << cookie;
cookie.setSecure(true);
- QTest::newRow("three-fields") << "a=b;domain=qt.nokia.com;path=/;secure" << cookie;
- QTest::newRow("three-fields2") << "a=b;secure;path=/;domain=qt.nokia.com" << cookie;
- QTest::newRow("three-fields3") << "a=b;secure;domain=qt.nokia.com; path=/" << cookie;
- QTest::newRow("three-fields4") << "a = b;secure;domain=qt.nokia.com; path=/" << cookie;
+ QTest::newRow("three-fields") << "a=b;domain=.qt.nokia.com;path=/;secure" << cookie;
+ QTest::newRow("three-fields2") << "a=b;secure;path=/;domain=.qt.nokia.com" << cookie;
+ QTest::newRow("three-fields3") << "a=b;secure;domain=.qt.nokia.com; path=/" << cookie;
+ QTest::newRow("three-fields4") << "a = b;secure;domain=.qt.nokia.com; path=/" << cookie;
cookie = QNetworkCookie();
cookie.setName("a");
@@ -664,7 +657,7 @@ void tst_QNetworkCookie::parseMultipleCookies_data()
cookie.setName("baz");
cookie.setDomain(".qt.nokia.com");
list.prepend(cookie);
- QTest::newRow("complex-2") << "baz=bar; path=/; domain=qt.nokia.com, c=d,a=,foo=bar; path=/" << list;
+ QTest::newRow("complex-2") << "baz=bar; path=/; domain=.qt.nokia.com, c=d,a=,foo=bar; path=/" << list;
// cookies obtained from the network:
cookie = QNetworkCookie("id", "51706646077999719");
diff --git a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
index 9b9c56a5f9..ff7e78e544 100644
--- a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
+++ b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
@@ -120,7 +120,7 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data()
cookie.setName("a");
cookie.setPath("/");
- cookie.setDomain("www.foo.tld");
+ cookie.setDomain(".foo.tld");
result += cookie;
QTest::newRow("just-add") << preset << cookie << "http://www.foo.tld" << result << true;
@@ -148,6 +148,20 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data()
cookie.setPath("/");
QTest::newRow("diff-path-order") << preset << cookie << "http://www.foo.tld" << result << true;
+ preset.clear();
+ result.clear();
+ QNetworkCookie finalCookie = cookie;
+ cookie.setDomain("foo.tld");
+ finalCookie.setDomain(".foo.tld");
+ result += finalCookie;
+ QTest::newRow("should-add-dot-prefix") << preset << cookie << "http://www.foo.tld" << result << true;
+
+ result.clear();
+ cookie.setDomain("");
+ finalCookie.setDomain("www.foo.tld");
+ result += finalCookie;
+ QTest::newRow("should-set-default-domain") << preset << cookie << "http://www.foo.tld" << result << true;
+
// security test:
result.clear();
preset.clear();
@@ -159,7 +173,7 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data()
QTest::newRow("security-path-1") << preset << cookie << "http://www.foo.tld" << result << false;
// setting the defaults:
- QNetworkCookie finalCookie = cookie;
+ finalCookie = cookie;
finalCookie.setPath("/something/");
cookie.setPath("");
cookie.setDomain("");
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 8ed83cb851..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();
@@ -239,9 +241,12 @@ private slots:
void taskQT4444_dontOverflowDashOffset();
void painterBegin();
+ void setPenColorOnImage();
+ void setPenColorOnPixmap();
private:
void fillData();
+ void setPenColor(QPainter& p);
QColor baseColor( int k, int intensity=255 );
QImage getResImage( const QString &dir, const QString &addition, const QString &extension );
QBitmap getBitmap( const QString &dir, const QString &filename, bool mask );
@@ -970,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");
@@ -2915,7 +2932,7 @@ void tst_QPainter::monoImages()
QImage img(2, 2, format);
- if (img.numColors() > 0) {
+ if (img.colorCount() > 0) {
img.setColor(0, QColor(colorPairs[j][0]).rgba());
img.setColor(1, QColor(colorPairs[j][1]).rgba());
}
@@ -2937,7 +2954,7 @@ void tst_QPainter::monoImages()
// should not change the image
QCOMPARE(original, img);
- if (img.numColors() == 0)
+ if (img.colorCount() == 0)
continue;
for (int k = 0; k < 2; ++k) {
@@ -4193,9 +4210,9 @@ void tst_QPainter::extendedBlendModes()
QVERIFY(testCompositionMode(255, 255, 255, QPainter::CompositionMode_SoftLight));
QVERIFY(testCompositionMode( 0, 0, 0, QPainter::CompositionMode_SoftLight));
- QVERIFY(testCompositionMode(127, 127, 127, QPainter::CompositionMode_SoftLight));
- QVERIFY(testCompositionMode( 63, 63, 86, QPainter::CompositionMode_SoftLight));
- QVERIFY(testCompositionMode(127, 63, 63, QPainter::CompositionMode_SoftLight));
+ QVERIFY(testCompositionMode(127, 127, 126, QPainter::CompositionMode_SoftLight));
+ QVERIFY(testCompositionMode( 63, 63, 39, QPainter::CompositionMode_SoftLight));
+ QVERIFY(testCompositionMode(127, 63, 62, QPainter::CompositionMode_SoftLight));
QVERIFY(testCompositionMode(255, 255, 0, QPainter::CompositionMode_Difference));
QVERIFY(testCompositionMode( 0, 0, 0, QPainter::CompositionMode_Difference));
@@ -4352,5 +4369,41 @@ void tst_QPainter::painterBegin()
QVERIFY(!p.end());
}
+void tst_QPainter::setPenColor(QPainter& p)
+{
+ p.setPen(Qt::NoPen);
+
+ // Setting color, then style
+ // Should work even though the pen is "NoPen with color", temporarily.
+ QPen newPen(p.pen());
+ newPen.setColor(Qt::red);
+ QCOMPARE(p.pen().style(), newPen.style());
+ QCOMPARE(p.pen().style(), Qt::NoPen);
+ p.setPen(newPen);
+
+ QCOMPARE(p.pen().color().name(), QString("#ff0000"));
+
+ QPen newPen2(p.pen());
+ newPen2.setStyle(Qt::SolidLine);
+ p.setPen(newPen2);
+
+ QCOMPARE(p.pen().color().name(), QString("#ff0000"));
+}
+
+void tst_QPainter::setPenColorOnImage()
+{
+ QImage img(QSize(10, 10), QImage::Format_ARGB32_Premultiplied);
+ QPainter p(&img);
+ setPenColor(p);
+}
+
+void tst_QPainter::setPenColorOnPixmap()
+{
+ QPixmap pix(10, 10);
+ QPainter p(&pix);
+ setPenColor(p);
+}
+
QTEST_MAIN(tst_QPainter)
+
#include "tst_qpainter.moc"
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/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp
index 8e02c74e25..d7f042edea 100644
--- a/tests/auto/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp
@@ -293,7 +293,7 @@ void tst_QPixmap::setAlphaChannel()
QRgb expected = alpha == 0 ? 0 : qRgba(red, green, blue, alpha);
for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) {
- if (result.numColors() > 0) {
+ if (result.colorCount() > 0) {
ok &= result.pixelIndex(x, y) == expected;
} else {
ok &= result.pixel(x, y) == expected;
@@ -330,7 +330,7 @@ void tst_QPixmap::fromImage()
QImage image(37, 16, format);
- if (image.numColors() == 2) {
+ if (image.colorCount() == 2) {
image.setColor(0, QColor(Qt::color0).rgba());
image.setColor(1, QColor(Qt::color1).rgba());
}
@@ -731,7 +731,7 @@ void tst_QPixmap::testMetrics()
void tst_QPixmap::createMaskFromColor()
{
QImage image(3, 3, QImage::Format_Indexed8);
- image.setNumColors(10);
+ image.setColorCount(10);
image.setColor(0, 0xffffffff);
image.setColor(1, 0xff000000);
image.setColor(2, 0xffff0000);
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/qregexp/tst_qregexp.cpp b/tests/auto/qregexp/tst_qregexp.cpp
index 86d831e8ad..e3053865cf 100644
--- a/tests/auto/qregexp/tst_qregexp.cpp
+++ b/tests/auto/qregexp/tst_qregexp.cpp
@@ -628,7 +628,7 @@ void tst_QRegExp::capturedTexts()
QRegExp rx7("([A-Za-z_])([A-Za-z_0-9]*)");
rx7.setCaseSensitivity(Qt::CaseSensitive);
rx7.setPatternSyntax(QRegExp::RegExp);
- QCOMPARE(rx7.numCaptures(), 2);
+ QCOMPARE(rx7.captureCount(), 2);
int pos = rx7.indexIn("(10 + delta4) * 32");
QCOMPARE(pos, 6);
@@ -1177,36 +1177,36 @@ void tst_QRegExp::prepareEngineOptimization()
QCOMPARE(rx1.capturedTexts(), QStringList() << "" << "" << "" << "");
QCOMPARE(rx1.matchedLength(), -1);
QCOMPARE(rx1.matchedLength(), -1);
- QCOMPARE(rx1.numCaptures(), 3);
+ QCOMPARE(rx1.captureCount(), 3);
QCOMPARE(rx1.exactMatch("foo"), true);
QCOMPARE(rx1.matchedLength(), 3);
QCOMPARE(rx1.capturedTexts(), QStringList() << "foo" << "f" << "o" << "o");
- QCOMPARE(rx1.numCaptures(), 3);
+ QCOMPARE(rx1.captureCount(), 3);
QCOMPARE(rx1.matchedLength(), 3);
QCOMPARE(rx1.capturedTexts(), QStringList() << "foo" << "f" << "o" << "o");
QCOMPARE(rx1.pos(3), 2);
QCOMPARE(rx1.exactMatch("foo"), true);
- QCOMPARE(rx1.numCaptures(), 3);
+ QCOMPARE(rx1.captureCount(), 3);
QCOMPARE(rx1.matchedLength(), 3);
QCOMPARE(rx1.capturedTexts(), QStringList() << "foo" << "f" << "o" << "o");
QCOMPARE(rx1.pos(3), 2);
QRegExp rx2 = rx1;
- QCOMPARE(rx1.numCaptures(), 3);
+ QCOMPARE(rx1.captureCount(), 3);
QCOMPARE(rx1.matchedLength(), 3);
QCOMPARE(rx1.capturedTexts(), QStringList() << "foo" << "f" << "o" << "o");
QCOMPARE(rx1.pos(3), 2);
- QCOMPARE(rx2.numCaptures(), 3);
+ QCOMPARE(rx2.captureCount(), 3);
QCOMPARE(rx2.matchedLength(), 3);
QCOMPARE(rx2.capturedTexts(), QStringList() << "foo" << "f" << "o" << "o");
QCOMPARE(rx2.pos(3), 2);
QCOMPARE(rx1.exactMatch("fo"), true);
- QCOMPARE(rx1.numCaptures(), 3);
+ QCOMPARE(rx1.captureCount(), 3);
QCOMPARE(rx1.matchedLength(), 2);
QCOMPARE(rx1.capturedTexts(), QStringList() << "fo" << "f" << "o" << "");
QCOMPARE(rx1.pos(2), 1);
@@ -1245,25 +1245,25 @@ void tst_QRegExp::prepareEngineOptimization()
rx11.setPatternSyntax(QRegExp::Wildcard);
QVERIFY(!rx11.isValid());
- QCOMPARE(rx11.numCaptures(), 0);
+ QCOMPARE(rx11.captureCount(), 0);
QCOMPARE(rx11.matchedLength(), -1);
rx11.setPatternSyntax(QRegExp::RegExp);
QVERIFY(!rx11.isValid());
- QCOMPARE(rx11.numCaptures(), 0);
+ QCOMPARE(rx11.captureCount(), 0);
QCOMPARE(rx11.matchedLength(), -1);
rx11.setPattern("(foo)");
QVERIFY(rx11.isValid());
- QCOMPARE(rx11.numCaptures(), 1);
+ QCOMPARE(rx11.captureCount(), 1);
QCOMPARE(rx11.matchedLength(), -1);
QCOMPARE(rx11.indexIn("ofoo"), 1);
- QCOMPARE(rx11.numCaptures(), 1);
+ QCOMPARE(rx11.captureCount(), 1);
QCOMPARE(rx11.matchedLength(), 3);
rx11.setPatternSyntax(QRegExp::RegExp);
- QCOMPARE(rx11.numCaptures(), 1);
+ QCOMPARE(rx11.captureCount(), 1);
QCOMPARE(rx11.matchedLength(), 3);
/*
@@ -1278,11 +1278,11 @@ void tst_QRegExp::prepareEngineOptimization()
QCOMPARE(rx11.matchedLength(), 3);
rx11.setPatternSyntax(QRegExp::Wildcard);
- QCOMPARE(rx11.numCaptures(), 0);
+ QCOMPARE(rx11.captureCount(), 0);
QCOMPARE(rx11.matchedLength(), -1);
rx11.setPatternSyntax(QRegExp::RegExp);
- QCOMPARE(rx11.numCaptures(), 1);
+ QCOMPARE(rx11.captureCount(), 1);
QCOMPARE(rx11.matchedLength(), -1);
}
diff --git a/tests/auto/qregion/tst_qregion.cpp b/tests/auto/qregion/tst_qregion.cpp
index e5a3151120..582b5e8df3 100644
--- a/tests/auto/qregion/tst_qregion.cpp
+++ b/tests/auto/qregion/tst_qregion.cpp
@@ -88,8 +88,8 @@ private slots:
void operator_xor_data();
void operator_xor();
- void numRects_data();
- void numRects();
+ void rectCount_data();
+ void rectCount();
void isEmpty_data();
void isEmpty();
@@ -554,7 +554,7 @@ void tst_QRegion::operator_plus()
qDebug() << "expected" << expected;
}
QCOMPARE(r1 + r2, expected);
- if (r2.numRects() == 1) {
+ if (r2.rectCount() == 1) {
if (r1 + r2.boundingRect() != expected) {
qDebug() << "r1 + QRect(r2)" << (r1 + r2.boundingRect());
qDebug() << "expected" << expected;
@@ -567,7 +567,7 @@ void tst_QRegion::operator_plus()
qDebug() << "expected" << expected;
}
QCOMPARE(r2 + r1, expected);
- if (r1.numRects() == 1) {
+ if (r1.rectCount() == 1) {
if (r1 + r2.boundingRect() != expected) {
qDebug() << "r2 + QRect(r1)" << (r2 + r1.boundingRect());
qDebug() << "expected" << expected;
@@ -582,7 +582,7 @@ void tst_QRegion::operator_plus()
qDebug() << "expected" << expected;
}
QCOMPARE(result1, expected);
- if (r2.numRects() == 1) {
+ if (r2.rectCount() == 1) {
result1 = r1;
result1 += r2.boundingRect();
if (result1 != expected) {
@@ -599,7 +599,7 @@ void tst_QRegion::operator_plus()
qDebug() << "expected" << expected;
}
QCOMPARE(result2, expected);
- if (r1.numRects() == 1) {
+ if (r1.rectCount() == 1) {
result2 = r2;
result2 += r1.boundingRect();
if (result2 != expected) {
@@ -802,7 +802,7 @@ void tst_QRegion::operator_xor()
QCOMPARE(dest, expected);
}
-void tst_QRegion::numRects_data()
+void tst_QRegion::rectCount_data()
{
QTest::addColumn<QRegion>("region");
QTest::addColumn<int>("expected");
@@ -818,12 +818,12 @@ void tst_QRegion::numRects_data()
QTest::newRow("2 rects") << dest << rects.size();
}
-void tst_QRegion::numRects()
+void tst_QRegion::rectCount()
{
QFETCH(QRegion, region);
QFETCH(int, expected);
- QCOMPARE(region.numRects(), expected);
+ QCOMPARE(region.rectCount(), expected);
}
void tst_QRegion::isEmpty_data()
@@ -850,7 +850,7 @@ void tst_QRegion::isEmpty()
QVERIFY(region.isEmpty());
QCOMPARE(region, QRegion());
- QCOMPARE(region.numRects(), 0);
+ QCOMPARE(region.rectCount(), 0);
QCOMPARE(region.boundingRect(), QRect());
QVERIFY(region.rects().isEmpty());
}
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp
index 804534fe47..8eaad78470 100644
--- a/tests/auto/qscriptengine/tst_qscriptengine.cpp
+++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp
@@ -4485,7 +4485,7 @@ void tst_QScriptEngine::qRegExpInport()
QScriptValue result = func.call(QScriptValue(), QScriptValueList() << string << rexp);
rx.indexIn(string);
- for (int i = 0; i <= rx.numCaptures(); i++) {
+ for (int i = 0; i <= rx.captureCount(); i++) {
QCOMPARE(result.property(i).toString(), rx.cap(i));
}
}
diff --git a/tests/auto/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/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp
index 4d9e50fab4..4264a70283 100644
--- a/tests/auto/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp
@@ -193,9 +193,13 @@ private slots:
void sqlServerReturn0_data() { generic_data(); }
void sqlServerReturn0();
+
void QTBUG_551_data() { generic_data("QOCI"); }
void QTBUG_551();
+ void QTBUG_5251_data() { generic_data("QPSQL"); }
+ void QTBUG_5251();
+
private:
// returns all database connections
void generic_data(const QString &engine=QString());
@@ -2901,5 +2905,35 @@ void tst_QSqlQuery::QTBUG_551()
QCOMPARE(res_outLst[2].toString(), QLatin1String("3. Value is 2"));
}
+void tst_QSqlQuery::QTBUG_5251()
+{
+ QFETCH( QString, dbName );
+ QSqlDatabase db = QSqlDatabase::database( dbName );
+ CHECK_DATABASE( db );
+
+ if (!db.driverName().startsWith( "QPSQL" )) return;
+
+ QSqlQuery q(db);
+ q.exec("DROP TABLE " + qTableName("timetest"));
+ QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("timetest") + " (t TIME)"));
+ QVERIFY_SQL(q, exec("INSERT INTO " + qTableName("timetest") + " VALUES ('1:2:3.666')"));
+
+ QSqlTableModel timetestModel(0,db);
+ timetestModel.setEditStrategy(QSqlTableModel::OnManualSubmit);
+ timetestModel.setTable(qTableName("timetest"));
+ QVERIFY_SQL(timetestModel, select());
+
+ QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("01:02:03.666"));
+ QVERIFY_SQL(timetestModel,setData(timetestModel.index(0, 0), QTime(0,12,34,500)));
+ QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("00:12:34.500"));
+ QVERIFY_SQL(timetestModel, submitAll());
+ QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("00:12:34.500"));
+
+ QVERIFY_SQL(q, exec("UPDATE " + qTableName("timetest") + " SET t = '0:11:22.33'"));
+ QVERIFY_SQL(timetestModel, select());
+ QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("00:11:22.330"));
+
+}
+
QTEST_MAIN( tst_QSqlQuery )
#include "tst_qsqlquery.moc"
diff --git a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
index e045c1021f..8c840cd1d5 100644
--- a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
+++ b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
@@ -184,8 +184,8 @@ void tst_QSqlRelationalTableModel::dropTestTables( QSqlDatabase db )
<< qTableName("casetest1" );
tst_Databases::safeDropTables( db, tableNames );
- db.exec("DROP SCHEMA "+qTableName("QTBUG_5373"));
- db.exec("DROP SCHEMA "+qTableName("QTBUG_5373_s2"));
+ db.exec("DROP SCHEMA "+qTableName("QTBUG_5373")+" CASCADE");
+ db.exec("DROP SCHEMA "+qTableName("QTBUG_5373_s2")+" CASCADE");
}
void tst_QSqlRelationalTableModel::init()
diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp
index 9a2b2edf1a..fd39515a98 100644
--- a/tests/auto/qstatemachine/tst_qstatemachine.cpp
+++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp
@@ -208,6 +208,7 @@ private slots:
void task260403_clonedSignals();
void postEventFromOtherThread();
+ void eventFilterForApplication();
};
tst_QStateMachine::tst_QStateMachine()
@@ -4276,5 +4277,35 @@ void tst_QStateMachine::postEventFromOtherThread()
QTRY_COMPARE(finishedSpy.count(), 1);
}
+void tst_QStateMachine::eventFilterForApplication()
+{
+ QStateMachine machine;
+
+ QState *s1 = new QState(&machine);
+ {
+ machine.setInitialState(s1);
+ }
+
+ QState *s2 = new QState(&machine);
+
+ QEventTransition *transition = new QEventTransition(QCoreApplication::instance(),
+ QEvent::ApplicationActivate);
+ transition->setTargetState(s2);
+ s1->addTransition(transition);
+
+ machine.start();
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s1));
+
+ QCoreApplication::postEvent(QCoreApplication::instance(),
+ new QEvent(QEvent::ApplicationActivate));
+ QCoreApplication::processEvents();
+
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s2));
+}
+
QTEST_MAIN(tst_QStateMachine)
#include "tst_qstatemachine.moc"
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/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp
index 5237438686..1d54409513 100644
--- a/tests/auto/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp
@@ -1721,21 +1721,21 @@ void tst_QTextDocument::capitalizationHtmlInExport()
const QString smallcaps = doc->toHtml();
QVERIFY(re.exactMatch(doc->toHtml()));
- QCOMPARE(re.numCaptures(), 1);
+ QCOMPARE(re.captureCount(), 1);
QCOMPARE(re.cap(1).trimmed(), QString("font-variant:small-caps;"));
cf.setFontCapitalization(QFont::AllUppercase);
cursor.mergeCharFormat(cf);
const QString uppercase = doc->toHtml();
QVERIFY(re.exactMatch(doc->toHtml()));
- QCOMPARE(re.numCaptures(), 1);
+ QCOMPARE(re.captureCount(), 1);
QCOMPARE(re.cap(1).trimmed(), QString("text-transform:uppercase;"));
cf.setFontCapitalization(QFont::AllLowercase);
cursor.mergeCharFormat(cf);
const QString lowercase = doc->toHtml();
QVERIFY(re.exactMatch(doc->toHtml()));
- QCOMPARE(re.numCaptures(), 1);
+ QCOMPARE(re.captureCount(), 1);
QCOMPARE(re.cap(1).trimmed(), QString("text-transform:lowercase;"));
doc->setHtml(smallcaps);
@@ -1761,14 +1761,14 @@ void tst_QTextDocument::wordspacingHtmlExport()
cursor.mergeCharFormat(cf);
QVERIFY(re.exactMatch(doc->toHtml()));
- QCOMPARE(re.numCaptures(), 1);
+ QCOMPARE(re.captureCount(), 1);
QCOMPARE(re.cap(1).trimmed(), QString("word-spacing:4px;"));
cf.setFontWordSpacing(-8.5);
cursor.mergeCharFormat(cf);
QVERIFY(re.exactMatch(doc->toHtml()));
- QCOMPARE(re.numCaptures(), 1);
+ QCOMPARE(re.captureCount(), 1);
QCOMPARE(re.cap(1).trimmed(), QString("word-spacing:-8.5px;"));
}
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 \