summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp8
-rw-r--r--tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp66
-rw-r--r--tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp22
-rw-r--r--tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp50
-rw-r--r--tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp8
-rw-r--r--tests/auto/corelib/io/qprocess/test/test.pro4
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp16
-rw-r--r--tests/auto/corelib/io/qsettings/tst_qsettings.cpp7
-rw-r--r--tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp46
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp22
-rw-r--r--tests/auto/corelib/itemmodels/itemmodels.pro2
-rw-r--r--tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp14
-rw-r--r--tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp64
-rw-r--r--tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp28
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp2
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp383
-rw-r--r--tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp6
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp290
-rw-r--r--tests/auto/corelib/plugin/qfactoryloader/test/test.pro1
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/tst/tst.pro2
-rw-r--r--tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp8
-rw-r--r--tests/auto/corelib/tools/qchar/tst_qchar.cpp86
-rw-r--r--tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp6
-rw-r--r--tests/auto/corelib/tools/qlocale/test/test.pro1
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp122
-rw-r--r--tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp10
-rw-r--r--tests/auto/corelib/tools/qtimeline/qtimeline.pro1
-rw-r--r--tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp28
-rw-r--r--tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp2
29 files changed, 938 insertions, 367 deletions
diff --git a/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp b/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp
index 3abd851c89..db7f067680 100644
--- a/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp
+++ b/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp
@@ -145,9 +145,9 @@ void tst_QAnimationGroup::emptyGroup()
QCOMPARE(groupStateChangedSpy.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(1).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(groupStateChangedSpy.at(1).first()),
QAnimationGroup::Stopped);
QCOMPARE(group.state(), QAnimationGroup::Stopped);
@@ -160,9 +160,9 @@ void tst_QAnimationGroup::emptyGroup()
group.start();
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(2).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(groupStateChangedSpy.at(2).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(3).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(groupStateChangedSpy.at(3).first()),
QAnimationGroup::Stopped);
QCOMPARE(group.state(), QAnimationGroup::Stopped);
diff --git a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
index 2fdf1de9c8..b7464c8467 100644
--- a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
+++ b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
@@ -270,18 +270,18 @@ void tst_QParallelAnimationGroup::stateChanged()
group.start();
//all the animations should be started
QCOMPARE(spy1.count(), 1);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Running);
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Running);
QCOMPARE(spy2.count(), 1);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Running);
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Running);
QCOMPARE(spy3.count(), 1);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Running);
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Running);
QCOMPARE(spy4.count(), 1);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Running);
+ QCOMPARE(qvariant_cast<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().first()), TestAnimation::Stopped);
+ QCOMPARE(qvariant_cast<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
@@ -290,7 +290,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().first()), TestAnimation::Stopped);
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Stopped);
QCOMPARE(spy3.count(), 1); //no change
QCOMPARE(spy4.count(), 1); //no change
@@ -299,9 +299,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().first()), TestAnimation::Stopped);
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Stopped);
QCOMPARE(spy4.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Stopped);
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Stopped);
//cleanup
spy1.clear();
@@ -318,22 +318,22 @@ void tst_QParallelAnimationGroup::stateChanged()
QCOMPARE(spy1.count(), 0);
QCOMPARE(spy2.count(), 0);
QCOMPARE(spy3.count(), 1);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Running);
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Running);
QCOMPARE(spy4.count(), 1);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Running);
+ QCOMPARE(qvariant_cast<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().first()), TestAnimation::Running);
+ QCOMPARE(qvariant_cast<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().first()), TestAnimation::Running);
+ QCOMPARE(qvariant_cast<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
@@ -341,13 +341,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().first()), TestAnimation::Stopped);
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Stopped);
QCOMPARE(spy2.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Stopped);
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Stopped);
QCOMPARE(spy3.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Stopped);
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Stopped);
QCOMPARE(spy4.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Stopped);
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Stopped);
}
void tst_QParallelAnimationGroup::clearGroup()
@@ -455,9 +455,9 @@ void tst_QParallelAnimationGroup::updateChildrenWithRunningGroup()
QCOMPARE(groupStateChangedSpy.count(), 1);
QCOMPARE(childStateChangedSpy.count(), 1);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(childStateChangedSpy.at(0).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(childStateChangedSpy.at(0).first()),
QAnimationGroup::Running);
// starting directly a running child will not have any effect
@@ -620,11 +620,11 @@ void tst_QParallelAnimationGroup::startGroupWithRunningChild()
anim2.start();
anim2.pause();
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(0).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(1).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(1).first()),
QAnimationGroup::Paused);
QCOMPARE(group.state(), QAnimationGroup::Stopped);
@@ -634,15 +634,15 @@ void tst_QParallelAnimationGroup::startGroupWithRunningChild()
group.start();
QCOMPARE(stateChangedSpy1.count(), 3);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(1).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(1).first()),
QAnimationGroup::Stopped);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(2).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(2).first()),
QAnimationGroup::Running);
QCOMPARE(stateChangedSpy2.count(), 4);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(2).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(2).first()),
QAnimationGroup::Stopped);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(3).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(3).first()),
QAnimationGroup::Running);
QCOMPARE(group.state(), QAnimationGroup::Running);
@@ -694,19 +694,19 @@ void tst_QParallelAnimationGroup::zeroDurationAnimation()
group.start();
QCOMPARE(stateChangedSpy1.count(), 2);
QCOMPARE(finishedSpy1.count(), 1);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(1).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(1).first()),
QAnimationGroup::Stopped);
QCOMPARE(stateChangedSpy2.count(), 1);
QCOMPARE(finishedSpy2.count(), 0);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()),
QAnimationGroup::Running);
QCOMPARE(stateChangedSpy3.count(), 1);
QCOMPARE(finishedSpy3.count(), 0);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy3.at(0).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy3.at(0).first()),
QAnimationGroup::Running);
@@ -770,9 +770,9 @@ void tst_QParallelAnimationGroup::stopUncontrolledAnimations()
group.start();
QCOMPARE(stateChangedSpy.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(0).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(1).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy.at(1).first()),
QAnimationGroup::Stopped);
QCOMPARE(group.state(), QAnimationGroup::Running);
@@ -1000,10 +1000,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().first()), TestAnimation::Running);
+ QCOMPARE(qvariant_cast<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().first()), TestAnimation::Stopped);
+ QCOMPARE(qvariant_cast<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/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
index 05d1569988..11b95d82d8 100644
--- a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
+++ b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
@@ -702,7 +702,7 @@ Q_DECLARE_METATYPE(QAbstractAnimation::State)
QVariant numberInterpolator(const Number &f, const Number &t, qreal progress)
{
- return qVariantFromValue<Number>(Number(f.n + (t.n - f.n)*progress));
+ return QVariant::fromValue<Number>(Number(f.n + (t.n - f.n)*progress));
}
QVariant xaxisQPointInterpolator(const QPointF &f, const QPointF &t, qreal progress)
@@ -714,21 +714,21 @@ void tst_QPropertyAnimation::interpolated()
{
QObject o;
o.setProperty("point", QPointF()); //this will avoid warnings
- o.setProperty("number", qVariantFromValue<Number>(Number(42)));
- QCOMPARE(qVariantValue<Number>(o.property("number")), Number(42));
+ o.setProperty("number", QVariant::fromValue<Number>(Number(42)));
+ QCOMPARE(qvariant_cast<Number>(o.property("number")), Number(42));
{
qRegisterAnimationInterpolator<Number>(numberInterpolator);
QPropertyAnimation anim(&o, "number");
- anim.setStartValue(qVariantFromValue<Number>(Number(0)));
- anim.setEndValue(qVariantFromValue<Number>(Number(100)));
+ anim.setStartValue(QVariant::fromValue<Number>(Number(0)));
+ anim.setEndValue(QVariant::fromValue<Number>(Number(100)));
anim.setDuration(1000);
anim.start();
anim.pause();
anim.setCurrentTime(100);
- Number t(qVariantValue<Number>(o.property("number")));
+ Number t(qvariant_cast<Number>(o.property("number")));
QCOMPARE(t, Number(10));
anim.setCurrentTime(500);
- QCOMPARE(qVariantValue<Number>(o.property("number")), Number(50));
+ QCOMPARE(qvariant_cast<Number>(o.property("number")), Number(50));
}
{
qRegisterAnimationInterpolator<QPointF>(xaxisQPointInterpolator);
@@ -861,16 +861,16 @@ void tst_QPropertyAnimation::zeroDurationStart()
//let's check the first state change
const QVariantList firstChange = spy.first();
//old state
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(firstChange.last()), QAbstractAnimation::Stopped);
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(firstChange.last()), QAbstractAnimation::Stopped);
//new state
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(firstChange.first()), QAbstractAnimation::Running);
+ QCOMPARE(qvariant_cast<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.last()), QAbstractAnimation::Running);
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(secondChange.last()), QAbstractAnimation::Running);
//new state
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(secondChange.first()), QAbstractAnimation::Stopped);
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(secondChange.first()), QAbstractAnimation::Stopped);
}
#define Pause 1
diff --git a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
index 63a4de5ac9..0ceeb6ce86 100644
--- a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
+++ b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
@@ -590,7 +590,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.first());
+ QAbstractAnimation::State actual = qvariant_cast<QAbstractAnimation::State>(args.first());
if (equals && actual != st) {
equals = false;
break;
@@ -608,7 +608,7 @@ static bool compareStates(const QSignalSpy& spy, const StateList &expectedStates
}
if (i < spy.count()) {
QList<QVariant> args = spy.at(i);
- QAbstractAnimation::State actual = qVariantValue<QAbstractAnimation::State>(args.value(1));
+ QAbstractAnimation::State actual = qvariant_cast<QAbstractAnimation::State>(args.value(1));
if (!a.isEmpty())
a += QLatin1String(", ");
if (int(actual) >= 0 && int(actual) <= 2) {
@@ -677,20 +677,20 @@ void tst_QSequentialAnimationGroup::pauseAndResume()
<< QAbstractAnimation::Running
<< QAbstractAnimation::Stopped)));
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(0).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(a1StateChangedSpy.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(1).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(a1StateChangedSpy.at(1).first()),
QAnimationGroup::Paused);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(2).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(a1StateChangedSpy.at(2).first()),
QAnimationGroup::Stopped);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(3).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(a1StateChangedSpy.at(3).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(a1StateChangedSpy.at(4).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(a1StateChangedSpy.at(4).first()),
QAnimationGroup::Stopped);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(0).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(1).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(1).first()),
QAnimationGroup::Paused);
group.resume();
@@ -711,7 +711,7 @@ void tst_QSequentialAnimationGroup::pauseAndResume()
QVERIFY(a3_s_o1->currentLoopTime() >= 1);
QCOMPARE(seqStateChangedSpy.count(), 3); // Running,Paused,Running
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(2).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(2).first()),
QAnimationGroup::Running);
group.pause();
@@ -732,13 +732,13 @@ void tst_QSequentialAnimationGroup::pauseAndResume()
QVERIFY(a3_s_o1->currentLoopTime() >= 1);
QCOMPARE(seqStateChangedSpy.count(), 4); // Running,Paused,Running,Paused
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(3).first()),
+ QCOMPARE(qvariant_cast<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).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(4).first()),
QAnimationGroup::Stopped);
}
@@ -782,25 +782,25 @@ void tst_QSequentialAnimationGroup::restart()
for (int i = 0; i < 3; i++) {
QCOMPARE(animsStateChanged[i]->count(), 4);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(0).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(animsStateChanged[i]->at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(1).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(animsStateChanged[i]->at(1).first()),
QAnimationGroup::Stopped);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(2).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(animsStateChanged[i]->at(2).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(animsStateChanged[i]->at(3).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(animsStateChanged[i]->at(3).first()),
QAnimationGroup::Stopped);
}
QCOMPARE(seqStateChangedSpy.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(0).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(seqStateChangedSpy.at(1).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(1).first()),
QAnimationGroup::Stopped);
QCOMPARE(seqCurrentAnimChangedSpy.count(), 6);
for(int i=0; i<seqCurrentAnimChangedSpy.count(); i++)
- QCOMPARE(static_cast<QAbstractAnimation*>(anims[i%3]), qVariantValue<QAbstractAnimation*>(seqCurrentAnimChangedSpy.at(i).at(0)));
+ QCOMPARE(static_cast<QAbstractAnimation*>(anims[i%3]), qvariant_cast<QAbstractAnimation*>(seqCurrentAnimChangedSpy.at(i).at(0)));
group.start();
@@ -1124,9 +1124,9 @@ void tst_QSequentialAnimationGroup::updateChildrenWithRunningGroup()
QCOMPARE(groupStateChangedSpy.count(), 1);
QCOMPARE(childStateChangedSpy.count(), 1);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(childStateChangedSpy.at(0).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(childStateChangedSpy.at(0).first()),
QAnimationGroup::Running);
// starting directly a running child will not have any effect
@@ -1317,9 +1317,9 @@ void tst_QSequentialAnimationGroup::startGroupWithRunningChild()
QCOMPARE(anim2->state(), QAnimationGroup::Running);
QCOMPARE(stateChangedSpy2.count(), 4);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(2).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(2).first()),
QAnimationGroup::Stopped);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy2.at(3).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(3).first()),
QAnimationGroup::Running);
group.stop();
@@ -1357,9 +1357,9 @@ void tst_QSequentialAnimationGroup::zeroDurationAnimation()
group.start();
QCOMPARE(stateChangedSpy.count(), 2);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(0).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(qVariantValue<QAbstractAnimation::State>(stateChangedSpy.at(1).first()),
+ QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy.at(1).first()),
QAnimationGroup::Stopped);
QCOMPARE(anim1->state(), QAnimationGroup::Stopped);
diff --git a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp
index 4144e82a29..719e29e412 100644
--- a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp
+++ b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp
@@ -528,8 +528,10 @@ void tst_QTextCodec::utf8Codec_data()
QTest::newRow("str0") << QByteArray("abcdefgh") << QString("abcdefgh") << -1;
QTest::newRow("str0-len") << QByteArray("abcdefgh") << QString("abc") << 3;
- QTest::newRow("str1") << QByteArray("\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205") << QString("\366\344\374\326\304\334\370\346\345\330\306\305") << -1;
- QTest::newRow("str1-len") << QByteArray("\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205") << QString("\366\344\374\326\304") << 10;
+ QTest::newRow("str1") << QByteArray("\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205")
+ << QString::fromLatin1("\366\344\374\326\304\334\370\346\345\330\306\305") << -1;
+ QTest::newRow("str1-len") << QByteArray("\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205")
+ << QString::fromLatin1("\366\344\374\326\304") << 10;
str += QChar(0x05e9);
str += QChar(0x05d3);
@@ -1565,7 +1567,7 @@ void tst_QTextCodec::utf8bom_data()
QTest::newRow("nobom")
<< QByteArray("\302\240", 2)
- << QString("\240");
+ << QString::fromLatin1("\240");
{
static const ushort data[] = { 0x201d };
diff --git a/tests/auto/corelib/io/qprocess/test/test.pro b/tests/auto/corelib/io/qprocess/test/test.pro
index fb21800976..0b8b761a83 100644
--- a/tests/auto/corelib/io/qprocess/test/test.pro
+++ b/tests/auto/corelib/io/qprocess/test/test.pro
@@ -8,9 +8,13 @@ TARGET = ../tst_qprocess
win32:TESTDATA += ../testBatFiles/*
include(../qprocess.pri)
+
+win32:CONFIG += insignificant_test # QTBUG-25342 - sometimes hangs
+
load(testcase) # for target.path and installTestHelperApp()
for(file, SUBPROGRAMS): installTestHelperApp("../$${file}/$${file}",$${file},$${file})
installTestHelperApp("../testProcessSpacesArgs/nospace",testProcessSpacesArgs,nospace)
installTestHelperApp("../testProcessSpacesArgs/one space",testProcessSpacesArgs,"one space")
installTestHelperApp("../testProcessSpacesArgs/two space s",testProcessSpacesArgs,"two space s")
installTestHelperApp("../test Space In Name/testSpaceInName","test Space In Name",testSpaceInName)
+
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index c3c4607119..3ca9521d8b 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -264,9 +264,9 @@ void tst_QProcess::simpleStart()
process = 0;
QCOMPARE(spy.count(), 3);
- QCOMPARE(qVariantValue<QProcess::ProcessState>(spy.at(0).at(0)), QProcess::Starting);
- QCOMPARE(qVariantValue<QProcess::ProcessState>(spy.at(1).at(0)), QProcess::Running);
- QCOMPARE(qVariantValue<QProcess::ProcessState>(spy.at(2).at(0)), QProcess::NotRunning);
+ QCOMPARE(qvariant_cast<QProcess::ProcessState>(spy.at(0).at(0)), QProcess::Starting);
+ QCOMPARE(qvariant_cast<QProcess::ProcessState>(spy.at(1).at(0)), QProcess::Running);
+ QCOMPARE(qvariant_cast<QProcess::ProcessState>(spy.at(2).at(0)), QProcess::NotRunning);
}
//-----------------------------------------------------------------------------
void tst_QProcess::execute()
@@ -331,9 +331,9 @@ void tst_QProcess::crashTest()
process = 0;
QCOMPARE(stateSpy.count(), 3);
- QCOMPARE(qVariantValue<QProcess::ProcessState>(stateSpy.at(0).at(0)), QProcess::Starting);
- QCOMPARE(qVariantValue<QProcess::ProcessState>(stateSpy.at(1).at(0)), QProcess::Running);
- QCOMPARE(qVariantValue<QProcess::ProcessState>(stateSpy.at(2).at(0)), QProcess::NotRunning);
+ QCOMPARE(qvariant_cast<QProcess::ProcessState>(stateSpy.at(0).at(0)), QProcess::Starting);
+ QCOMPARE(qvariant_cast<QProcess::ProcessState>(stateSpy.at(1).at(0)), QProcess::Running);
+ QCOMPARE(qvariant_cast<QProcess::ProcessState>(stateSpy.at(2).at(0)), QProcess::NotRunning);
}
//-----------------------------------------------------------------------------
@@ -1571,8 +1571,8 @@ void tst_QProcess::failToStart()
int it = j * attempts + i + 1;
QCOMPARE(stateSpy.count(), it * 2);
- QCOMPARE(qVariantValue<QProcess::ProcessState>(stateSpy.at(it * 2 - 2).at(0)), QProcess::Starting);
- QCOMPARE(qVariantValue<QProcess::ProcessState>(stateSpy.at(it * 2 - 1).at(0)), QProcess::NotRunning);
+ QCOMPARE(qvariant_cast<QProcess::ProcessState>(stateSpy.at(it * 2 - 2).at(0)), QProcess::Starting);
+ QCOMPARE(qvariant_cast<QProcess::ProcessState>(stateSpy.at(it * 2 - 1).at(0)), QProcess::NotRunning);
}
}
}
diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
index dbb844d204..65ab63510c 100644
--- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
+++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
@@ -1023,7 +1023,7 @@ void tst_QSettings::testVariantTypes()
#define testVal(key, val, tp, rtype) \
{ \
QSettings settings1(format, QSettings::UserScope, "software.org", "KillerAPP"); \
- settings1.setValue(key, qVariantFromValue(val)); \
+ settings1.setValue(key, QVariant::fromValue(val)); \
} \
QConfFile::clearCache(); \
{ \
@@ -1055,7 +1055,7 @@ void tst_QSettings::testVariantTypes()
QList<QVariant> l3;
QDate date = QDate::currentDate();
QTime time = QTime::currentTime();
- l3 << QString("ene") << 10 << qVariantFromValue(QColor(1, 2, 3)) << QVariant(QRect(1, 2, 3, 4))
+ l3 << QString("ene") << 10 << QVariant::fromValue(QColor(1, 2, 3)) << QVariant(QRect(1, 2, 3, 4))
<< QVariant(QSize(4, 56)) << QVariant(QPoint(4, 2)) << true << false << date << time;
testVal("key3", l3, QVariantList, List);
@@ -1989,6 +1989,9 @@ void tst_QSettings::setIniCodec()
QConfFile::clearCache();
+#ifdef Q_OS_WIN
+ QEXPECT_FAIL("", "QTBUG-25446", Abort);
+#endif
QCOMPARE(actualContents4, expeContents4);
QCOMPARE(actualContents5, expeContents5);
diff --git a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
index 37a1556cf9..6e330faa85 100644
--- a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
+++ b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
@@ -419,28 +419,28 @@ void tst_QTextStream::generateLineData(bool for_QString)
// one line
QTest::newRow("utf16-BE/nothing")
<< QByteArray("\xfe\xff"
- "\x00\xe5\x00\x67\x00\x65", 8) << (QStringList() << "\345ge");
+ "\x00\xe5\x00\x67\x00\x65", 8) << (QStringList() << QLatin1String("\345ge"));
QTest::newRow("utf16-LE/nothing")
<< QByteArray("\xff\xfe"
- "\xe5\x00\x67\x00\x65\x00", 8) << (QStringList() << "\345ge");
+ "\xe5\x00\x67\x00\x65\x00", 8) << (QStringList() << QLatin1String("\345ge"));
QTest::newRow("utf16-BE/lf")
<< QByteArray("\xfe\xff"
- "\x00\xe5\x00\x67\x00\x65\x00\x0a", 10) << (QStringList() << "\345ge");
+ "\x00\xe5\x00\x67\x00\x65\x00\x0a", 10) << (QStringList() << QLatin1String("\345ge"));
QTest::newRow("utf16-LE/lf")
<< QByteArray("\xff\xfe"
- "\xe5\x00\x67\x00\x65\x00\x0a\x00", 10) << (QStringList() << "\345ge");
+ "\xe5\x00\x67\x00\x65\x00\x0a\x00", 10) << (QStringList() << QLatin1String("\345ge"));
// two lines
QTest::newRow("utf16-BE/twolines")
<< QByteArray("\xfe\xff"
"\x00\xe5\x00\x67\x00\x65\x00\x0a"
"\x00\xe5\x00\x67\x00\x65\x00\x0a", 18)
- << (QStringList() << "\345ge" << "\345ge");
+ << (QStringList() << QLatin1String("\345ge") << QLatin1String("\345ge"));
QTest::newRow("utf16-LE/twolines")
<< QByteArray("\xff\xfe"
"\xe5\x00\x67\x00\x65\x00\x0a\x00"
"\xe5\x00\x67\x00\x65\x00\x0a\x00", 18)
- << (QStringList() << "\345ge" << "\345ge");
+ << (QStringList() << QLatin1String("\345ge") << QLatin1String("\345ge"));
// three lines
QTest::newRow("utf16-BE/threelines")
@@ -448,32 +448,32 @@ void tst_QTextStream::generateLineData(bool for_QString)
"\x00\xe5\x00\x67\x00\x65\x00\x0a"
"\x00\xe5\x00\x67\x00\x65\x00\x0a"
"\x00\xe5\x00\x67\x00\x65\x00\x0a", 26)
- << (QStringList() << "\345ge" << "\345ge" << "\345ge");
+ << (QStringList() << QLatin1String("\345ge") << QLatin1String("\345ge") << QLatin1String("\345ge"));
QTest::newRow("utf16-LE/threelines")
<< QByteArray("\xff\xfe"
"\xe5\x00\x67\x00\x65\x00\x0a\x00"
"\xe5\x00\x67\x00\x65\x00\x0a\x00"
"\xe5\x00\x67\x00\x65\x00\x0a\x00", 26)
- << (QStringList() << "\345ge" << "\345ge" << "\345ge");
+ << (QStringList() << QLatin1String("\345ge") << QLatin1String("\345ge") << QLatin1String("\345ge"));
// utf-32
QTest::newRow("utf32-BE/twolines")
<< QByteArray("\x00\x00\xfe\xff"
"\x00\x00\x00\xe5\x00\x00\x00\x67\x00\x00\x00\x65\x00\x00\x00\x0a"
"\x00\x00\x00\xe5\x00\x00\x00\x67\x00\x00\x00\x65\x00\x00\x00\x0a", 36)
- << (QStringList() << "\345ge" << "\345ge");
+ << (QStringList() << QLatin1String("\345ge") << QLatin1String("\345ge"));
QTest::newRow("utf32-LE/twolines")
<< QByteArray("\xff\xfe\x00\x00"
"\xe5\x00\x00\x00\x67\x00\x00\x00\x65\x00\x00\x00\x0a\x00\x00\x00"
"\xe5\x00\x00\x00\x67\x00\x00\x00\x65\x00\x00\x00\x0a\x00\x00\x00", 36)
- << (QStringList() << "\345ge" << "\345ge");
+ << (QStringList() << QLatin1String("\345ge") << QLatin1String("\345ge"));
}
// partials
QTest::newRow("cr") << QByteArray("\r") << (QStringList() << "");
QTest::newRow("oneline/cr") << QByteArray("ole\r") << (QStringList() << "ole");
if (!for_QString)
- QTest::newRow("utf16-BE/cr") << QByteArray("\xfe\xff\x00\xe5\x00\x67\x00\x65\x00\x0d", 10) << (QStringList() << "\345ge");
+ QTest::newRow("utf16-BE/cr") << QByteArray("\xfe\xff\x00\xe5\x00\x67\x00\x65\x00\x0d", 10) << (QStringList() << QLatin1String("\345ge"));
}
// ------------------------------------------------------------------------------
@@ -702,34 +702,34 @@ void tst_QTextStream::generateAllData(bool for_QString)
// one line
QTest::newRow("utf16-BE/nothing")
<< QByteArray("\xfe\xff"
- "\x00\xe5\x00\x67\x00\x65", 8) << QString("\345ge");
+ "\x00\xe5\x00\x67\x00\x65", 8) << QString::fromLatin1("\345ge");
QTest::newRow("utf16-LE/nothing")
<< QByteArray("\xff\xfe"
- "\xe5\x00\x67\x00\x65\x00", 8) << QString("\345ge");
+ "\xe5\x00\x67\x00\x65\x00", 8) << QString::fromLatin1("\345ge");
QTest::newRow("utf16-BE/lf")
<< QByteArray("\xfe\xff"
- "\x00\xe5\x00\x67\x00\x65\x00\x0a", 10) << QString("\345ge\n");
+ "\x00\xe5\x00\x67\x00\x65\x00\x0a", 10) << QString::fromLatin1("\345ge\n");
QTest::newRow("utf16-LE/lf")
<< QByteArray("\xff\xfe"
- "\xe5\x00\x67\x00\x65\x00\x0a\x00", 10) << QString("\345ge\n");
+ "\xe5\x00\x67\x00\x65\x00\x0a\x00", 10) << QString::fromLatin1("\345ge\n");
QTest::newRow("utf16-BE/crlf")
<< QByteArray("\xfe\xff"
- "\x00\xe5\x00\x67\x00\x65\x00\x0d\x00\x0a", 12) << QString("\345ge\r\n");
+ "\x00\xe5\x00\x67\x00\x65\x00\x0d\x00\x0a", 12) << QString::fromLatin1("\345ge\r\n");
QTest::newRow("utf16-LE/crlf")
<< QByteArray("\xff\xfe"
- "\xe5\x00\x67\x00\x65\x00\x0d\x00\x0a\x00", 12) << QString("\345ge\r\n");
+ "\xe5\x00\x67\x00\x65\x00\x0d\x00\x0a\x00", 12) << QString::fromLatin1("\345ge\r\n");
// two lines
QTest::newRow("utf16-BE/twolines")
<< QByteArray("\xfe\xff"
"\x00\xe5\x00\x67\x00\x65\x00\x0a"
"\x00\xe5\x00\x67\x00\x65\x00\x0a", 18)
- << QString("\345ge\n\345ge\n");
+ << QString::fromLatin1("\345ge\n\345ge\n");
QTest::newRow("utf16-LE/twolines")
<< QByteArray("\xff\xfe"
"\xe5\x00\x67\x00\x65\x00\x0a\x00"
"\xe5\x00\x67\x00\x65\x00\x0a\x00", 18)
- << QString("\345ge\n\345ge\n");
+ << QString::fromLatin1("\345ge\n\345ge\n");
// three lines
QTest::newRow("utf16-BE/threelines")
@@ -737,13 +737,13 @@ void tst_QTextStream::generateAllData(bool for_QString)
"\x00\xe5\x00\x67\x00\x65\x00\x0a"
"\x00\xe5\x00\x67\x00\x65\x00\x0a"
"\x00\xe5\x00\x67\x00\x65\x00\x0a", 26)
- << QString("\345ge\n\345ge\n\345ge\n");
+ << QString::fromLatin1("\345ge\n\345ge\n\345ge\n");
QTest::newRow("utf16-LE/threelines")
<< QByteArray("\xff\xfe"
"\xe5\x00\x67\x00\x65\x00\x0a\x00"
"\xe5\x00\x67\x00\x65\x00\x0a\x00"
"\xe5\x00\x67\x00\x65\x00\x0a\x00", 26)
- << QString("\345ge\n\345ge\n\345ge\n");
+ << QString::fromLatin1("\345ge\n\345ge\n\345ge\n");
}
}
@@ -2042,9 +2042,9 @@ void tst_QTextStream::generateStringData(bool for_QString)
if (!for_QString) {
QTest::newRow("utf16-BE (empty)") << QByteArray("\xff\xfe", 2) << QByteArray() << QString();
- QTest::newRow("utf16-BE (corrupt)") << QByteArray("\xff", 1) << QByteArray("\xff") << QString("\xff");
+ QTest::newRow("utf16-BE (corrupt)") << QByteArray("\xff", 1) << QByteArray("\xff") << QString::fromLatin1("\xff");
QTest::newRow("utf16-LE (empty)") << QByteArray("\xfe\xff", 2) << QByteArray() << QString();
- QTest::newRow("utf16-LE (corrupt)") << QByteArray("\xfe", 1) << QByteArray("\xfe") << QString("\xfe");
+ QTest::newRow("utf16-LE (corrupt)") << QByteArray("\xfe", 1) << QByteArray("\xfe") << QString::fromLatin1("\xfe");
}
}
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index f9fbb8cba8..608bdfb78b 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -1017,12 +1017,22 @@ void tst_QUrl::toLocalFile_data()
QTest::newRow("data0") << QString::fromLatin1("file:/a.txt") << QString::fromLatin1("/a.txt");
QTest::newRow("data4") << QString::fromLatin1("file:///a.txt") << QString::fromLatin1("/a.txt");
+#ifdef Q_OS_WIN
QTest::newRow("data5") << QString::fromLatin1("file:///c:/a.txt") << QString::fromLatin1("c:/a.txt");
+#else
+ QTest::newRow("data5") << QString::fromLatin1("file:///c:/a.txt") << QString::fromLatin1("/c:/a.txt");
+#endif
QTest::newRow("data6") << QString::fromLatin1("file://somehost/somedir/somefile") << QString::fromLatin1("//somehost/somedir/somefile");
QTest::newRow("data7") << QString::fromLatin1("file://somehost/") << QString::fromLatin1("//somehost/");
QTest::newRow("data8") << QString::fromLatin1("file://somehost") << QString::fromLatin1("//somehost");
QTest::newRow("data9") << QString::fromLatin1("file:////somehost/somedir/somefile") << QString::fromLatin1("//somehost/somedir/somefile");
QTest::newRow("data10") << QString::fromLatin1("FILE:/a.txt") << QString::fromLatin1("/a.txt");
+ QTest::newRow("data11") << QString::fromLatin1("file:///Mambo <%235>.mp3") << QString::fromLatin1("/Mambo <#5>.mp3");
+ QTest::newRow("data12") << QString::fromLatin1("file:///a%25.txt") << QString::fromLatin1("/a%.txt");
+ QTest::newRow("data13") << QString::fromLatin1("file:///a%25%25.txt") << QString::fromLatin1("/a%%.txt");
+ QTest::newRow("data14") << QString::fromLatin1("file:///a%25a%25.txt") << QString::fromLatin1("/a%a%.txt");
+ QTest::newRow("data15") << QString::fromLatin1("file:///a%1f.txt") << QString::fromLatin1("/a\x1f.txt");
+ QTest::newRow("data16") << QString::fromLatin1("file:///%2580.txt") << QString::fromLatin1("/%80.txt");
// and some that result in empty (i.e., not local)
QTest::newRow("xdata0") << QString::fromLatin1("/a.txt") << QString();
@@ -1059,6 +1069,14 @@ void tst_QUrl::fromLocalFile_data()
<< QString::fromLatin1("");
QTest::newRow("data6") << QString::fromLatin1("//somehost/") << QString::fromLatin1("file://somehost/")
<< QString::fromLatin1("/");
+ QTest::newRow("data7") << QString::fromLatin1("/Mambo <#5>.mp3") << QString::fromLatin1("file:///Mambo <%235>.mp3")
+ << QString::fromLatin1("/Mambo <#5>.mp3");
+ QTest::newRow("data8") << QString::fromLatin1("/a%.txt") << QString::fromLatin1("file:///a%25.txt")
+ << QString::fromLatin1("/a%25.txt");
+ QTest::newRow("data9") << QString::fromLatin1("/a%25.txt") << QString::fromLatin1("file:///a%2525.txt")
+ << QString::fromLatin1("/a%2525.txt");
+ QTest::newRow("data10") << QString::fromLatin1("/%80.txt") << QString::fromLatin1("file:///%2580.txt")
+ << QString::fromLatin1("/%2580.txt");
}
void tst_QUrl::fromLocalFile()
@@ -1069,7 +1087,7 @@ void tst_QUrl::fromLocalFile()
QUrl url = QUrl::fromLocalFile(theFile);
- QCOMPARE(url.toString(), theUrl);
+ QCOMPARE(url.toString(QUrl::MostDecoded), theUrl);
QCOMPARE(url.path(), thePath);
}
@@ -1616,7 +1634,7 @@ void tst_QUrl::isRelative_data()
QTest::newRow("man: URL, is relative") << "man:mmap" << false;
QTest::newRow("javascript: URL, is relative") << "javascript:doSomething()" << false;
QTest::newRow("file: URL, is relative") << "file:/blah" << false;
- QTest::newRow("/path, is relative") << "/path" << false;
+ QTest::newRow("/path, is relative") << "/path" << true;
QTest::newRow("something, is relative") << "something" << true;
// end kde
}
diff --git a/tests/auto/corelib/itemmodels/itemmodels.pro b/tests/auto/corelib/itemmodels/itemmodels.pro
index 851035e949..418c5e1678 100644
--- a/tests/auto/corelib/itemmodels/itemmodels.pro
+++ b/tests/auto/corelib/itemmodels/itemmodels.pro
@@ -7,5 +7,3 @@ SUBDIRS = qabstractitemmodel \
qitemselectionmodel \
qsortfilterproxymodel \
qstringlistmodel
-
-mac: qabstractitemmodel.CONFIG = no_check_target # QTBUG-22748
diff --git a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp
index d27d685f37..6a15133b27 100644
--- a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp
@@ -535,27 +535,27 @@ void tst_QItemModel::data()
// General Purpose roles
QVariant variant = currentModel->data(currentModel->index(0,0), Qt::ToolTipRole);
if (variant.isValid()) {
- QVERIFY(qVariantCanConvert<QString>(variant));
+ QVERIFY(variant.canConvert<QString>());
}
variant = currentModel->data(currentModel->index(0,0), Qt::StatusTipRole);
if (variant.isValid()) {
- QVERIFY(qVariantCanConvert<QString>(variant));
+ QVERIFY(variant.canConvert<QString>());
}
variant = currentModel->data(currentModel->index(0,0), Qt::WhatsThisRole);
if (variant.isValid()) {
- QVERIFY(qVariantCanConvert<QString>(variant));
+ QVERIFY(variant.canConvert<QString>());
}
variant = currentModel->data(currentModel->index(0,0), Qt::SizeHintRole);
if (variant.isValid()) {
- QVERIFY(qVariantCanConvert<QSize>(variant));
+ QVERIFY(variant.canConvert<QSize>());
}
// Appearance roles
QVariant fontVariant = currentModel->data(currentModel->index(0,0), Qt::FontRole);
if (fontVariant.isValid()) {
- QVERIFY(qVariantCanConvert<QFont>(fontVariant));
+ QVERIFY(fontVariant.canConvert<QFont>());
}
QVariant textAlignmentVariant = currentModel->data(currentModel->index(0,0), Qt::TextAlignmentRole);
@@ -569,12 +569,12 @@ void tst_QItemModel::data()
QVariant colorVariant = currentModel->data(currentModel->index(0,0), Qt::BackgroundColorRole);
if (colorVariant.isValid()) {
- QVERIFY(qVariantCanConvert<QColor>(colorVariant));
+ QVERIFY(colorVariant.canConvert<QColor>());
}
colorVariant = currentModel->data(currentModel->index(0,0), Qt::TextColorRole);
if (colorVariant.isValid()) {
- QVERIFY(qVariantCanConvert<QColor>(colorVariant));
+ QVERIFY(colorVariant.canConvert<QColor>());
}
QVariant checkStateVariant = currentModel->data(currentModel->index(0,0), Qt::CheckStateRole);
diff --git a/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp b/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp
index 55997a3ca0..2858bf64eb 100644
--- a/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp
+++ b/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp
@@ -54,6 +54,10 @@ private slots:
void method();
void invalidMethod();
+
+ void comparisonOperators();
+
+ void fromSignal();
};
struct CustomType { };
@@ -672,5 +676,65 @@ void tst_QMetaMethod::invalidMethod()
QVERIFY(!method3.isValid());
}
+void tst_QMetaMethod::comparisonOperators()
+{
+ static const QMetaObject *mo = &MethodTestObject::staticMetaObject;
+ for (int x = 0; x < 2; ++x) {
+ int count = x ? mo->constructorCount() : mo->methodCount();
+ for (int i = 0; i < count; ++i) {
+ QMetaMethod method = x ? mo->constructor(i) : mo->method(i);
+ const QMetaObject *methodMo = method.enclosingMetaObject();
+ for (int j = 0; j < count; ++j) {
+ QMetaMethod other = x ? mo->constructor(j) : mo->method(j);
+ bool expectedEqual = ((methodMo == other.enclosingMetaObject())
+ && (i == j));
+ QCOMPARE(method == other, expectedEqual);
+ QCOMPARE(method != other, !expectedEqual);
+ QCOMPARE(other == method, expectedEqual);
+ QCOMPARE(other != method, !expectedEqual);
+ }
+
+ QVERIFY(method != QMetaMethod());
+ QVERIFY(QMetaMethod() != method);
+ QVERIFY(!(method == QMetaMethod()));
+ QVERIFY(!(QMetaMethod() == method));
+ }
+ }
+
+ // Constructors and normal methods with identical index should not
+ // compare equal
+ for (int i = 0; i < qMin(mo->methodCount(), mo->constructorCount()); ++i) {
+ QMetaMethod method = mo->method(i);
+ QMetaMethod constructor = mo->constructor(i);
+ QVERIFY(method != constructor);
+ QVERIFY(!(method == constructor));
+ }
+}
+
+void tst_QMetaMethod::fromSignal()
+{
+#define FROMSIGNAL_HELPER(ObjectType, Name, Arguments) { \
+ void (ObjectType::*signal)Arguments = &ObjectType::Name; \
+ const QMetaObject *signalMeta = &ObjectType::staticMetaObject; \
+ QCOMPARE(QMetaMethod::fromSignal(signal), \
+ signalMeta->method(signalMeta->indexOfSignal(QMetaObject::normalizedSignature(#Name #Arguments)))); \
+ }
+
+ FROMSIGNAL_HELPER(MethodTestObject, voidSignal, ())
+ FROMSIGNAL_HELPER(MethodTestObject, voidSignalQString, (const QString&))
+ FROMSIGNAL_HELPER(QObject, destroyed, (QObject*))
+ FROMSIGNAL_HELPER(QObject, objectNameChanged, (const QString &))
+
+ // Inherited from QObject
+ FROMSIGNAL_HELPER(MethodTestObject, destroyed, (QObject*))
+ FROMSIGNAL_HELPER(MethodTestObject, objectNameChanged, (const QString &))
+
+ // Methods that are not signals; fromSignal should return invalid method
+ FROMSIGNAL_HELPER(MethodTestObject, voidSlot, ())
+ FROMSIGNAL_HELPER(QObject, deleteLater, ())
+
+#undef FROMSIGNAL_HELPER
+}
+
QTEST_MAIN(tst_QMetaMethod)
#include "tst_qmetamethod.moc"
diff --git a/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp b/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp
index 4b0a64ab54..cfb23989dc 100644
--- a/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp
+++ b/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp
@@ -1097,6 +1097,11 @@ void tst_QMetaObjectBuilder::relocatableData()
QMetaObject *meta = builder.toMetaObject();
QVERIFY(sameMetaObject(meta, &meta2));
+
+ QVERIFY(!meta2.d.extradata);
+ QVERIFY(!meta2.d.relatedMetaObjects);
+ QVERIFY(!meta2.d.static_metacall);
+
free(meta);
}
@@ -1316,25 +1321,8 @@ bool tst_QMetaObjectBuilder::sameMetaObject
return false;
}
- const QMetaObject **objects1 = 0;
- const QMetaObject **objects2 = 0;
- if (meta1->d.data[0] == meta2->d.data[0] && meta1->d.data[0] >= 2) {
- QMetaObjectExtraData *extra1 = (QMetaObjectExtraData *)(meta1->d.extradata);
- QMetaObjectExtraData *extra2 = (QMetaObjectExtraData *)(meta2->d.extradata);
- if (extra1 && !extra2)
- return false;
- if (extra2 && !extra1)
- return false;
- if (extra1 && extra2) {
- if (extra1->static_metacall != extra2->static_metacall)
- return false;
- objects1 = extra1->objects;
- objects2 = extra1->objects;
- }
- } else if (meta1->d.data[0] == meta2->d.data[0] && meta1->d.data[0] == 1) {
- objects1 = (const QMetaObject **)(meta1->d.extradata);
- objects2 = (const QMetaObject **)(meta2->d.extradata);
- }
+ const QMetaObject **objects1 = meta1->d.relatedMetaObjects;
+ const QMetaObject **objects2 = meta2->d.relatedMetaObjects;
if (objects1 && !objects2)
return false;
if (objects2 && !objects1)
@@ -1402,7 +1390,7 @@ private:
};
QMetaObject TestObject::staticMetaObject = {
- { 0, 0, 0, 0 }
+ { 0, 0, 0, 0, 0, 0 }
};
TestObject::TestObject(QObject *parent)
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
index 4eb26928ac..e9de52b821 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
@@ -260,7 +260,7 @@ Q_DECLARE_METATYPE(TestSpace::Foo)
void tst_QMetaType::namespaces()
{
TestSpace::Foo nf = { 11.12 };
- QVariant v = qVariantFromValue(nf);
+ QVariant v = QVariant::fromValue(nf);
QCOMPARE(qvariant_cast<TestSpace::Foo>(v).d, 11.12);
}
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index f429af7ce2..e5da03c890 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -77,6 +77,12 @@ private slots:
void connectDisconnectNotify_data();
void connectDisconnectNotify();
void connectNotifyPtr();
+ void connectDisconnectNotifyMethod_data();
+ void connectDisconnectNotifyMethod();
+ void connectDisconnectNotifyMethodPMF();
+ void disconnectNotifyMethod_receiverDestroyed();
+ void connectNotifyMethod_connectSlotsByName();
+ void connectDisconnectNotifyMethod_shadowing();
void emitInDefinedOrder();
void customTypes();
void streamCustomTypes();
@@ -166,6 +172,7 @@ signals:
void signal4();
QT_MOC_COMPAT void signal5();
void signal6(void);
+ void signal7(int, const QString &);
public slots:
void aPublicSlot() { aPublicSlotCalled++; }
@@ -827,6 +834,7 @@ void tst_QObject::connectDisconnectNotify_data()
QTest::newRow("combo4") << SIGNAL( signal4( void ) )<< SLOT( slot4( void ) );
QTest::newRow("combo5") << SIGNAL( signal6( void ) ) << SLOT( slot4() );
QTest::newRow("combo6") << SIGNAL( signal6() ) << SLOT( slot4() );
+ QTest::newRow("combo7") << SIGNAL( signal7( int , const QString & ) ) << SLOT( slot4() );
}
void tst_QObject::connectDisconnectNotify()
@@ -887,6 +895,316 @@ void tst_QObject::connectNotifyPtr()
delete r;
}
+class NotifyMethodObject : public SenderObject, public ReceiverObject
+{
+public:
+ NotifyMethodObject() : SenderObject(), ReceiverObject()
+ {}
+
+ QList<QMetaMethod> connectedSignals;
+ QList<QMetaMethod> disconnectedSignals;
+ void clearNotifications()
+ {
+ connectedSignals.clear();
+ disconnectedSignals.clear();
+ }
+protected:
+ void connectNotify(const QMetaMethod &signal)
+ { connectedSignals.append(signal); }
+ void disconnectNotify(const QMetaMethod &signal)
+ { disconnectedSignals.append(signal); }
+};
+
+void tst_QObject::connectDisconnectNotifyMethod_data()
+{
+ tst_QObject::connectDisconnectNotify_data();
+}
+
+void tst_QObject::connectDisconnectNotifyMethod()
+{
+ NotifyMethodObject *s = new NotifyMethodObject;
+ NotifyMethodObject *r = new NotifyMethodObject;
+
+ QFETCH(QString, a_signal);
+ QFETCH(QString, a_slot);
+
+ // Obtaining meta methods
+ int signalIndx = ((SenderObject*)s)->metaObject()->indexOfSignal(
+ QMetaObject::normalizedSignature(a_signal.toLatin1().constData()+1).constData());
+ int methodIndx = ((ReceiverObject*)r)->metaObject()->indexOfMethod(
+ QMetaObject::normalizedSignature(a_slot.toLatin1().constData()+1).constData());
+ QMetaMethod signal = ((SenderObject*)s)->metaObject()->method(signalIndx);
+ QMetaMethod method = ((ReceiverObject*)r)->metaObject()->method(methodIndx);
+ QVERIFY(signal.isValid());
+ QVERIFY(method.isValid());
+
+ // Test connectNotify
+ QVERIFY(QObject::connect((SenderObject*)s, a_signal.toLatin1(), (ReceiverObject*)r, a_slot.toLatin1()));
+ QCOMPARE(s->connectedSignals.size(), 1);
+ QCOMPARE(s->connectedSignals.at(0), signal);
+ QVERIFY(s->disconnectedSignals.isEmpty());
+
+ // Test disconnectNotify
+ QVERIFY(QObject::disconnect((SenderObject*)s, a_signal.toLatin1(), (ReceiverObject*)r, a_slot.toLatin1()));
+ QCOMPARE(s->disconnectedSignals.size(), 1);
+ QCOMPARE(s->disconnectedSignals.at(0), signal);
+ QCOMPARE(s->connectedSignals.size(), 1);
+
+ // Reconnect
+ s->clearNotifications();
+ QVERIFY(QObject::connect((SenderObject*)s, a_signal.toLatin1(), (ReceiverObject*)r, a_slot.toLatin1()));
+ QCOMPARE(s->connectedSignals.size(), 1);
+ QCOMPARE(s->connectedSignals.at(0), signal);
+ QVERIFY(s->disconnectedSignals.isEmpty());
+
+ // Test disconnectNotify for a complete disconnect
+ QVERIFY(((SenderObject*)s)->disconnect((ReceiverObject*)r));
+ QCOMPARE(s->disconnectedSignals.size(), 1);
+ QCOMPARE(s->disconnectedSignals.at(0), QMetaMethod());
+ QCOMPARE(s->connectedSignals.size(), 1);
+
+ // Test connectNotify when connecting by QMetaMethod
+ s->clearNotifications();
+ QVERIFY(QObject::connect((SenderObject*)s, signal, (ReceiverObject*)r, method));
+ QCOMPARE(s->connectedSignals.size(), 1);
+ QCOMPARE(s->connectedSignals.at(0), signal);
+ QVERIFY(s->disconnectedSignals.isEmpty());
+
+ // Test disconnectNotify when disconnecting by QMetaMethod
+ QVERIFY(QObject::disconnect((SenderObject*)s, signal, (ReceiverObject*)r, method));
+ QCOMPARE(s->disconnectedSignals.size(), 1);
+ QCOMPARE(s->disconnectedSignals.at(0), signal);
+ QCOMPARE(s->connectedSignals.size(), 1);
+
+ // Reconnect
+ s->clearNotifications();
+ QVERIFY(QObject::connect((SenderObject*)s, a_signal.toLatin1(), (ReceiverObject*)r, a_slot.toLatin1()));
+
+ // Test disconnectNotify for a complete disconnect by QMetaMethod
+ QVERIFY(QObject::disconnect((SenderObject*)s, QMetaMethod(), 0, QMetaMethod()));
+ QCOMPARE(s->disconnectedSignals.size(), 1);
+ QCOMPARE(s->disconnectedSignals.at(0), QMetaMethod());
+ QCOMPARE(s->connectedSignals.size(), 1);
+
+ // Test connectNotify when connecting by index
+ s->clearNotifications();
+ QVERIFY(QMetaObject::connect((SenderObject*)s, signalIndx, (ReceiverObject*)r, methodIndx));
+ QCOMPARE(s->connectedSignals.size(), 1);
+ QCOMPARE(s->connectedSignals.at(0), signal);
+ QVERIFY(s->disconnectedSignals.isEmpty());
+
+ // Test disconnectNotify when disconnecting by index
+ QVERIFY(QMetaObject::disconnect((SenderObject*)s, signalIndx, (ReceiverObject*)r, methodIndx));
+ QCOMPARE(s->disconnectedSignals.size(), 1);
+ QCOMPARE(s->disconnectedSignals.at(0), signal);
+ QCOMPARE(s->connectedSignals.size(), 1);
+
+ delete s;
+ delete r;
+}
+
+static void connectDisconnectNotifyTestSlot() {}
+
+void tst_QObject::connectDisconnectNotifyMethodPMF()
+{
+ NotifyMethodObject *s = new NotifyMethodObject;
+ NotifyMethodObject *r = new NotifyMethodObject;
+
+ QMetaMethod signal = QMetaMethod::fromSignal(&SenderObject::signal1);
+
+ // Test connectNotify
+ QVERIFY(QObject::connect((SenderObject*)s, &SenderObject::signal1, (ReceiverObject*)r, &ReceiverObject::slot1));
+ QCOMPARE(s->connectedSignals.size(), 1);
+ QCOMPARE(s->connectedSignals.at(0), signal);
+ QVERIFY(s->disconnectedSignals.isEmpty());
+
+ // Test disconnectNotify
+ QVERIFY(QObject::disconnect((SenderObject*)s, &SenderObject::signal1, (ReceiverObject*)r, &ReceiverObject::slot1));
+ QCOMPARE(s->disconnectedSignals.size(), 1);
+ QCOMPARE(s->disconnectedSignals.at(0), signal);
+ QCOMPARE(s->connectedSignals.size(), 1);
+
+ // Reconnect
+ s->clearNotifications();
+ QVERIFY(QObject::connect((SenderObject*)s, &SenderObject::signal1, (ReceiverObject*)r, &ReceiverObject::slot1));
+ QCOMPARE(s->connectedSignals.size(), 1);
+ QCOMPARE(s->connectedSignals.at(0), signal);
+ QVERIFY(s->disconnectedSignals.isEmpty());
+
+ // Test disconnectNotify with wildcard slot
+ QVERIFY(QObject::disconnect((SenderObject*)s, &SenderObject::signal1, (ReceiverObject*)r, 0));
+ QCOMPARE(s->disconnectedSignals.size(), 1);
+ QCOMPARE(s->disconnectedSignals.at(0), signal);
+ QCOMPARE(s->connectedSignals.size(), 1);
+
+ // Reconnect
+ s->clearNotifications();
+ QMetaObject::Connection conn = connect((SenderObject*)s, &SenderObject::signal1,
+ (ReceiverObject*)r, &ReceiverObject::slot1);
+
+ // Test disconnectNotify when disconnecting by QMetaObject::Connection
+ QVERIFY(QObject::disconnect(conn));
+ // disconnectNotify() is not called, but it probably should be.
+ QVERIFY(s->disconnectedSignals.isEmpty());
+
+ // Test connectNotify when connecting by function pointer
+ s->clearNotifications();
+ QVERIFY(QObject::connect((SenderObject*)s, &SenderObject::signal1, connectDisconnectNotifyTestSlot));
+ QCOMPARE(s->connectedSignals.size(), 1);
+ QCOMPARE(s->connectedSignals.at(0), signal);
+ QVERIFY(s->disconnectedSignals.isEmpty());
+
+ delete s;
+ delete r;
+}
+
+void tst_QObject::disconnectNotifyMethod_receiverDestroyed()
+{
+ NotifyMethodObject *s = new NotifyMethodObject;
+ NotifyMethodObject *r = new NotifyMethodObject;
+
+ QVERIFY(QObject::connect((SenderObject*)s, SIGNAL(signal1()), (ReceiverObject*)r, SLOT(slot1())));
+
+ delete r;
+ // disconnectNotify() is not called, but it probably should be.
+ QVERIFY(s->disconnectedSignals.isEmpty());
+
+ delete s;
+}
+
+class ConnectByNameNotifySenderObject : public QObject
+{
+ Q_OBJECT
+public:
+ QList<QMetaMethod> connectedSignals;
+ QList<QMetaMethod> disconnectedSignals;
+ void clearNotifications()
+ {
+ connectedSignals.clear();
+ disconnectedSignals.clear();
+ }
+protected:
+ void connectNotify(const QMetaMethod &signal)
+ { connectedSignals.append(signal); }
+ void disconnectNotify(const QMetaMethod &signal)
+ { disconnectedSignals.append(signal); }
+Q_SIGNALS:
+ void signal1();
+};
+
+class ConnectByNameNotifyReceiverObject : public QObject
+{
+ Q_OBJECT
+ void createNotifyChild(const char *name)
+ {
+ QObject *o = new ConnectByNameNotifySenderObject;
+ o->setParent(this);
+ o->setObjectName(QString::fromLatin1(name));
+ }
+public:
+ ConnectByNameNotifyReceiverObject()
+ {
+ createNotifyChild("foo");
+ createNotifyChild("bar");
+ createNotifyChild("baz");
+ };
+
+public Q_SLOTS:
+ void on_foo_signal1() {}
+ void on_bar_signal1() {}
+ void on_baz_signal1() {}
+};
+
+void tst_QObject::connectNotifyMethod_connectSlotsByName()
+{
+ ConnectByNameNotifyReceiverObject testObject;
+ QList<ConnectByNameNotifySenderObject *> senders =
+ qFindChildren<ConnectByNameNotifySenderObject *>(&testObject);
+ for (int i = 0; i < senders.size(); ++i) {
+ ConnectByNameNotifySenderObject *o = senders.at(i);
+ QVERIFY(o->connectedSignals.isEmpty());
+ QVERIFY(o->disconnectedSignals.isEmpty());
+ }
+
+ QMetaObject::connectSlotsByName(&testObject);
+
+ for (int i = 0; i < senders.size(); ++i) {
+ ConnectByNameNotifySenderObject *o = senders.at(i);
+ QCOMPARE(o->connectedSignals.size(), 1);
+ QCOMPARE(o->connectedSignals.at(0), QMetaMethod::fromSignal(&ConnectByNameNotifySenderObject::signal1));
+ QVERIFY(o->disconnectedSignals.isEmpty());
+ }
+}
+
+class ConnectDisconnectNotifyShadowObject
+ : public ConnectByNameNotifySenderObject
+{
+ Q_OBJECT
+public Q_SLOTS:
+ void slot1() {}
+Q_SIGNALS:
+ void signal1();
+};
+
+void tst_QObject::connectDisconnectNotifyMethod_shadowing()
+{
+ ConnectDisconnectNotifyShadowObject s;
+ // Obtain QMetaMethods
+ QMetaMethod shadowedSignal1 = QMetaMethod::fromSignal(&ConnectByNameNotifySenderObject::signal1);
+ QMetaMethod redefinedSignal1 = QMetaMethod::fromSignal(&ConnectDisconnectNotifyShadowObject::signal1);
+ QVERIFY(shadowedSignal1 != redefinedSignal1);
+ int slot1Index = s.metaObject()->indexOfSlot("slot1()");
+ QVERIFY(slot1Index != -1);
+ QMetaMethod slot1 = s.metaObject()->method(slot1Index);
+
+ // Test connectNotify
+#ifndef QT_NO_DEBUG
+ const char *warning = "QMetaObject::indexOfSignal: signal signal1() from "
+ "ConnectByNameNotifySenderObject redefined in "
+ "ConnectDisconnectNotifyShadowObject";
+ QTest::ignoreMessage(QtWarningMsg, warning);
+#endif
+ QVERIFY(QObject::connect(&s, SIGNAL(signal1()), &s, SLOT(slot1())));
+ QCOMPARE(s.connectedSignals.size(), 1);
+ QCOMPARE(s.connectedSignals.at(0), redefinedSignal1);
+ QVERIFY(s.disconnectedSignals.isEmpty());
+
+ // Test disconnectNotify
+#ifndef QT_NO_DEBUG
+ QTest::ignoreMessage(QtWarningMsg, warning);
+#endif
+ QVERIFY(QObject::disconnect(&s, SIGNAL(signal1()), &s, SLOT(slot1())));
+ QCOMPARE(s.disconnectedSignals.size(), 1);
+ QCOMPARE(s.disconnectedSignals.at(0), redefinedSignal1);
+ QCOMPARE(s.connectedSignals.size(), 1);
+
+ // Test connectNotify when connecting by shadowed QMetaMethod
+ s.clearNotifications();
+ QVERIFY(QObject::connect(&s, shadowedSignal1, &s, slot1));
+ QCOMPARE(s.connectedSignals.size(), 1);
+ QCOMPARE(s.connectedSignals.at(0), shadowedSignal1);
+ QVERIFY(s.disconnectedSignals.isEmpty());
+
+ // Test disconnectNotify when disconnecting by shadowed QMetaMethod
+ QVERIFY(QObject::disconnect(&s, shadowedSignal1, &s, slot1));
+ QCOMPARE(s.disconnectedSignals.size(), 1);
+ QCOMPARE(s.disconnectedSignals.at(0), shadowedSignal1);
+ QCOMPARE(s.connectedSignals.size(), 1);
+
+ // Test connectNotify when connecting by redefined QMetaMethod
+ s.clearNotifications();
+ QVERIFY(QObject::connect(&s, redefinedSignal1, &s, slot1));
+ QCOMPARE(s.connectedSignals.size(), 1);
+ QCOMPARE(s.connectedSignals.at(0), redefinedSignal1);
+ QVERIFY(s.disconnectedSignals.isEmpty());
+
+ // Test disconnectNotify when disconnecting by redefined QMetaMethod
+ QVERIFY(QObject::disconnect(&s, redefinedSignal1, &s, slot1));
+ QCOMPARE(s.disconnectedSignals.size(), 1);
+ QCOMPARE(s.disconnectedSignals.at(0), redefinedSignal1);
+ QCOMPARE(s.connectedSignals.size(), 1);
+}
+
class SequenceObject : public ReceiverObject
{
Q_OBJECT
@@ -1733,12 +2051,12 @@ void tst_QObject::property()
CustomType *customPointer = 0;
QVariant customVariant = object.property("custom");
- customPointer = qVariantValue<CustomType *>(customVariant);
+ customPointer = qvariant_cast<CustomType *>(customVariant);
QCOMPARE(customPointer, object.custom());
CustomType custom;
customPointer = &custom;
- qVariantSetValue(customVariant, customPointer);
+ customVariant.setValue(customPointer);
property = mo->property(mo->indexOfProperty("custom"));
QVERIFY(property.isWritable());
@@ -1750,7 +2068,7 @@ void tst_QObject::property()
QCOMPARE(object.custom(), customPointer);
customVariant = object.property("custom");
- customPointer = qVariantValue<CustomType *>(customVariant);
+ customPointer = qvariant_cast<CustomType *>(customVariant);
QCOMPARE(object.custom(), customPointer);
// this enum property has a meta type, but it's not yet registered, so we know this fails
@@ -1783,22 +2101,22 @@ void tst_QObject::property()
var = object.property("priority");
QVERIFY(!var.isNull());
- QVERIFY(qVariantCanConvert<PropertyObject::Priority>(var));
- QCOMPARE(qVariantValue<PropertyObject::Priority>(var), PropertyObject::High);
+ QVERIFY(var.canConvert<PropertyObject::Priority>());
+ QCOMPARE(qvariant_cast<PropertyObject::Priority>(var), PropertyObject::High);
object.setPriority(PropertyObject::Low);
- QCOMPARE(qVariantValue<PropertyObject::Priority>(object.property("priority")), PropertyObject::Low);
+ QCOMPARE(qvariant_cast<PropertyObject::Priority>(object.property("priority")), PropertyObject::Low);
QVERIFY(object.setProperty("priority", PropertyObject::VeryHigh));
- QCOMPARE(qVariantValue<PropertyObject::Priority>(object.property("priority")), PropertyObject::VeryHigh);
+ QCOMPARE(qvariant_cast<PropertyObject::Priority>(object.property("priority")), PropertyObject::VeryHigh);
QVERIFY(object.setProperty("priority", "High"));
- QCOMPARE(qVariantValue<PropertyObject::Priority>(object.property("priority")), PropertyObject::High);
+ QCOMPARE(qvariant_cast<PropertyObject::Priority>(object.property("priority")), PropertyObject::High);
QVERIFY(!object.setProperty("priority", QVariant()));
var = object.property("priority");
- QCOMPARE(qVariantValue<PropertyObject::Priority>(var), PropertyObject::High);
+ QCOMPARE(qvariant_cast<PropertyObject::Priority>(var), PropertyObject::High);
object.setPriority(PropertyObject::Low);
- QCOMPARE(qVariantValue<PropertyObject::Priority>(object.property("priority")), PropertyObject::Low);
+ QCOMPARE(qvariant_cast<PropertyObject::Priority>(object.property("priority")), PropertyObject::Low);
object.setProperty("priority", var);
- QCOMPARE(qVariantValue<PropertyObject::Priority>(object.property("priority")), PropertyObject::High);
+ QCOMPARE(qvariant_cast<PropertyObject::Priority>(object.property("priority")), PropertyObject::High);
qRegisterMetaType<CustomString>("CustomString");
QVERIFY(mo->indexOfProperty("customString") != -1);
@@ -2684,10 +3002,10 @@ void tst_QObject::floatProperty()
QVERIFY(prop.isValid());
QVERIFY(prop.type() == uint(QMetaType::type("float")));
QVERIFY(!prop.write(&obj, QVariant("Hello")));
- QVERIFY(prop.write(&obj, qVariantFromValue(128.0f)));
+ QVERIFY(prop.write(&obj, QVariant::fromValue(128.0f)));
QVariant v = prop.read(&obj);
QVERIFY(int(v.userType()) == QMetaType::Float);
- QVERIFY(qVariantValue<float>(v) == 128.0f);
+ QVERIFY(qvariant_cast<float>(v) == 128.0f);
}
void tst_QObject::qrealProperty()
@@ -2700,15 +3018,15 @@ void tst_QObject::qrealProperty()
QVERIFY(prop.type() == uint(QMetaType::type("qreal")));
QVERIFY(!prop.write(&obj, QVariant("Hello")));
- QVERIFY(prop.write(&obj, qVariantFromValue(128.0f)));
+ QVERIFY(prop.write(&obj, QVariant::fromValue(128.0f)));
QVariant v = prop.read(&obj);
QCOMPARE(v.userType(), qMetaTypeId<qreal>());
- QVERIFY(qVariantValue<qreal>(v) == 128.0);
+ QVERIFY(qvariant_cast<qreal>(v) == 128.0);
- QVERIFY(prop.write(&obj, qVariantFromValue(double(127))));
+ QVERIFY(prop.write(&obj, QVariant::fromValue(double(127))));
v = prop.read(&obj);
QCOMPARE(v.userType(), qMetaTypeId<qreal>());
- QVERIFY(qVariantValue<qreal>(v) == 127.0);
+ QVERIFY(qvariant_cast<qreal>(v) == 127.0);
}
class DynamicPropertyObject : public PropertyObject
@@ -3456,6 +3774,7 @@ public:
void tst_QObject::isSignalConnected()
{
ManySignals o;
+ const QMetaObject *meta = o.metaObject();
o.rec = 0;
#ifdef QT_BUILD_INTERNAL
QObjectPrivate *priv = QObjectPrivate::get(&o);
@@ -3466,6 +3785,13 @@ void tst_QObject::isSignalConnected()
QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig29()")));
QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig60()")));
#endif
+ QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("destroyed()"))));
+ QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("sig00()"))));
+ QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("sig05()"))));
+ QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("sig15()"))));
+ QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("sig29()"))));
+ QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("sig60()"))));
+ QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("sig69()"))));
QObject::connect(&o, SIGNAL(sig00()), &o, SIGNAL(sig69()));
QObject::connect(&o, SIGNAL(sig34()), &o, SIGNAL(sig03()));
@@ -3484,6 +3810,18 @@ void tst_QObject::isSignalConnected()
QVERIFY(priv->isSignalConnected(priv->signalIndex("sig69()")));
QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig18()")));
#endif
+ QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("destroyed()"))));
+ QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("destroyed(QObject*)"))));
+ QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("sig05()"))));
+ QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("sig15()"))));
+ QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("sig29()"))));
+
+ QVERIFY(o.isSignalConnected(meta->method(meta->indexOfSignal("sig00()"))));
+ QVERIFY(o.isSignalConnected(meta->method(meta->indexOfSignal("sig03()"))));
+ QVERIFY(o.isSignalConnected(meta->method(meta->indexOfSignal("sig34()"))));
+ QVERIFY(o.isSignalConnected(meta->method(meta->indexOfSignal("sig69()"))));
+ QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("sig18()"))));
+
QObject::connect(&o, SIGNAL(sig18()), &o, SIGNAL(sig29()));
QObject::connect(&o, SIGNAL(sig29()), &o, SIGNAL(sig62()));
@@ -3497,6 +3835,11 @@ void tst_QObject::isSignalConnected()
QVERIFY(priv->isSignalConnected(priv->signalIndex("sig69()")));
QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig27()")));
#endif
+ QVERIFY(o.isSignalConnected(meta->method(meta->indexOfSignal("sig18()"))));
+ QVERIFY(o.isSignalConnected(meta->method(meta->indexOfSignal("sig62()"))));
+ QVERIFY(o.isSignalConnected(meta->method(meta->indexOfSignal("sig28()"))));
+ QVERIFY(o.isSignalConnected(meta->method(meta->indexOfSignal("sig69()"))));
+ QVERIFY(!o.isSignalConnected(meta->method(meta->indexOfSignal("sig27()"))));
QCOMPARE(o.rec, 0);
emit o.sig01();
@@ -3527,6 +3870,12 @@ void tst_QObject::isSignalConnected()
QCOMPARE(o.rec, 2);
emit o.sig36();
QCOMPARE(o.rec, 2);
+
+ QObject::connect(&o, &QObject::destroyed, qt_noop);
+ QVERIFY(o.isSignalConnected(meta->method(meta->indexOfSignal("destroyed()"))));
+ QVERIFY(o.isSignalConnected(meta->method(meta->indexOfSignal("destroyed(QObject*)"))));
+
+ QVERIFY(!o.isSignalConnected(QMetaMethod()));
}
void tst_QObject::qMetaObjectConnect()
diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
index e4ecfb6f2d..0e42572b03 100644
--- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
+++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
@@ -39,6 +39,12 @@
**
****************************************************************************/
+#ifdef QT_GUI_LIB
+# include <QtGui/QGuiApplication>
+#else
+# include <QtCore/QCoreApplication>
+#endif
+
#include <QtTest/QtTest>
#include <qtimer.h>
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index 7d821f038b..569e448d88 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -102,6 +102,8 @@ private slots:
void constructor();
void copy_constructor();
+ void constructor_invalid_data();
+ void constructor_invalid();
void isNull();
void swap();
@@ -346,6 +348,67 @@ void tst_QVariant::constructor()
QVERIFY(!var8.isNull());
}
+void tst_QVariant::constructor_invalid_data()
+{
+ QTest::addColumn<uint>("typeId");
+
+ QTest::newRow("-1") << uint(-1);
+ QTest::newRow("-122234567") << uint(-122234567);
+ QTest::newRow("0xfffffffff") << uint(0xfffffffff);
+ QTest::newRow("LastCoreType + 1") << uint(QMetaType::LastCoreType + 1);
+ QVERIFY(!QMetaType::isRegistered(QMetaType::LastCoreType + 1));
+ QTest::newRow("LastGuiType + 1") << uint(QMetaType::LastGuiType + 1);
+ QVERIFY(!QMetaType::isRegistered(QMetaType::LastGuiType + 1));
+ QTest::newRow("LastWidgetsType + 1") << uint(QMetaType::LastWidgetsType + 1);
+ QVERIFY(!QMetaType::isRegistered(QMetaType::LastWidgetsType + 1));
+}
+
+struct MessageHandlerInvalidType
+{
+ MessageHandlerInvalidType()
+ : oldMsgHandler(qInstallMsgHandler(handler))
+ {
+ ok = false;
+ }
+
+ ~MessageHandlerInvalidType()
+ {
+ qInstallMsgHandler(oldMsgHandler);
+ }
+
+ QtMsgHandler oldMsgHandler;
+
+ static void handler(QtMsgType type, const char *txt)
+ {
+ QString msg = QString::fromLatin1(txt);
+ // uint(-1) can be platform dependent so we check only beginning of the message.
+ ok = msg.startsWith("Trying to construct an instance of an invalid type, type id:");
+ QVERIFY2(ok, (QString::fromLatin1("Message is not started correctly: '") + msg + '\'').toLatin1().constData());
+ }
+ static bool ok;
+};
+bool MessageHandlerInvalidType::ok;
+
+void tst_QVariant::constructor_invalid()
+{
+
+ QFETCH(uint, typeId);
+ {
+ MessageHandlerInvalidType msg;
+ QVariant variant(static_cast<QVariant::Type>(typeId));
+ QVERIFY(!variant.isValid());
+ QVERIFY(variant.userType() == QMetaType::UnknownType);
+ QVERIFY(msg.ok);
+ }
+ {
+ MessageHandlerInvalidType msg;
+ QVariant variant(typeId, /* copy */ 0);
+ QVERIFY(!variant.isValid());
+ QVERIFY(variant.userType() == QMetaType::UnknownType);
+ QVERIFY(msg.ok);
+ }
+}
+
void tst_QVariant::copy_constructor()
{
QVariant var7(QVariant::Int);
@@ -447,20 +510,20 @@ void tst_QVariant::canConvert_data()
QVariant var(QBitArray(0));
QTest::newRow("BitArray")
<< var << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N;
- var = qVariantFromValue(QBitmap());
+ var = QVariant::fromValue(QBitmap());
QTest::newRow("Bitmap")
<< var << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N;
- var = qVariantFromValue(QBrush());
+ var = QVariant::fromValue(QBrush());
QTest::newRow("Brush")
<< var << N << N << N << Y << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N;
var = QVariant(QByteArray());
QTest::newRow("ByteArray")
<< var << N << N << Y << N << Y << Y << N << N << N << Y << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y;
- var = qVariantFromValue(QColor());
+ var = QVariant::fromValue(QColor());
QTest::newRow("Color")
<< var << N << N << N << Y << Y << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N;
#ifndef QT_NO_CURSOR
- var = qVariantFromValue(QCursor());
+ var = QVariant::fromValue(QCursor());
QTest::newRow("Cursor")
<< var << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N;
#endif
@@ -476,13 +539,13 @@ void tst_QVariant::canConvert_data()
var = QVariant(0.1f);
QTest::newRow("Float")
<< var << N << N << Y << N << Y << N << N << N << N << Y << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y;
- var = qVariantFromValue(QFont());
+ var = QVariant::fromValue(QFont());
QTest::newRow("Font")
<< var << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N;
- var = qVariantFromValue(QIcon());
+ var = QVariant::fromValue(QIcon());
QTest::newRow("Icon")
<< var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N;
- var = qVariantFromValue(QImage());
+ var = QVariant::fromValue(QImage());
QTest::newRow("Image")
<< var << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N;
var = QVariant((int)1);
@@ -491,7 +554,7 @@ void tst_QVariant::canConvert_data()
var = QVariant();
QTest::newRow("Invalid")
<< var << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N;
- var = qVariantFromValue(QKeySequence());
+ var = QVariant::fromValue(QKeySequence());
QTest::newRow("KeySequence")
<< var << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << Y << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N;
var = QVariant(QList<QVariant>());
@@ -503,16 +566,16 @@ void tst_QVariant::canConvert_data()
var = QVariant(QMap<QString,QVariant>());
QTest::newRow("Map")
<< var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N << N << N;
- var = qVariantFromValue(QPalette());
+ var = QVariant::fromValue(QPalette());
QTest::newRow("Palette")
<< var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N << N;
- var = qVariantFromValue(QPen());
+ var = QVariant::fromValue(QPen());
QTest::newRow("Pen")
<< var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N << N;
- var = qVariantFromValue(QPixmap());
+ var = QVariant::fromValue(QPixmap());
QTest::newRow("Pixmap")
<< var << N << Y << N << Y << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N << N << N;
- var = qVariantFromValue(QPolygon());
+ var = QVariant::fromValue(QPolygon());
QTest::newRow("PointArray")
<< var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N;
var = QVariant(QPoint());
@@ -521,13 +584,13 @@ void tst_QVariant::canConvert_data()
var = QVariant(QRect());
QTest::newRow("Rect")
<< var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N << N;
- var = qVariantFromValue(QRegion());
+ var = QVariant::fromValue(QRegion());
QTest::newRow("Region")
<< var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N << N;
var = QVariant(QSize());
QTest::newRow("Size")
<< var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N << N;
- var = qVariantFromValue(QSizePolicy());
+ var = QVariant::fromValue(QSizePolicy());
QTest::newRow("SizePolicy")
<< var << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << N << Y << N << N << N << N << N;
var = QVariant(QString());
@@ -648,7 +711,7 @@ void tst_QVariant::toInt_data()
QTest::newRow( "signedint-string" ) << QVariant( QString("-123") ) << -123 << true;
QTest::newRow( "signedlonglong0" ) << QVariant( (qlonglong)-34 ) << -34 << true;
QTest::newRow( "QChar" ) << QVariant(QChar('a')) << int('a') << true;
- QTest::newRow( "keysequence" ) << qVariantFromValue( QKeySequence( Qt::Key_A ) ) << 65 << true;
+ QTest::newRow( "keysequence" ) << QVariant::fromValue( QKeySequence( Qt::Key_A ) ) << 65 << true;
QByteArray bytearray(4, ' ');
bytearray[0] = 'T';
bytearray[1] = 'e';
@@ -955,7 +1018,7 @@ void tst_QVariant::toColor()
QFETCH( QColor, result );
QVERIFY( value.isValid() );
QVERIFY( value.canConvert( QVariant::Color ) );
- QColor d = qVariantValue<QColor>(value);
+ QColor d = qvariant_cast<QColor>(value);
QCOMPARE( d, result );
}
@@ -979,7 +1042,7 @@ void tst_QVariant::toPixmap()
QFETCH( QPixmap, result );
QVERIFY( value.isValid() );
QVERIFY( value.canConvert( QVariant::Pixmap ) );
- QPixmap d = qVariantValue<QPixmap>(value);
+ QPixmap d = qvariant_cast<QPixmap>(value);
QCOMPARE( d, result );
}
@@ -999,7 +1062,7 @@ void tst_QVariant::toImage()
QFETCH( QImage, result );
QVERIFY( value.isValid() );
QVERIFY( value.canConvert( QVariant::Image ) );
- QImage d = qVariantValue<QImage>(value);
+ QImage d = qvariant_cast<QImage>(value);
QCOMPARE( d, result );
}
@@ -1021,7 +1084,7 @@ void tst_QVariant::toBrush()
QFETCH( QBrush, result );
QVERIFY( value.isValid() );
QVERIFY( value.canConvert( QVariant::Brush ) );
- QBrush d = qVariantValue<QBrush>(value);
+ QBrush d = qvariant_cast<QBrush>(value);
QCOMPARE( d, result );
}
@@ -1040,7 +1103,7 @@ void tst_QVariant::toFont()
QFETCH( QFont, result );
QVERIFY( value.isValid() );
QVERIFY( value.canConvert( QVariant::Font ) );
- QFont d = qVariantValue<QFont>(value);
+ QFont d = qvariant_cast<QFont>(value);
QCOMPARE( d, result );
}
@@ -1064,7 +1127,7 @@ void tst_QVariant::toKeySequence()
QFETCH( QKeySequence, result );
QVERIFY( value.isValid() );
QVERIFY( value.canConvert( QVariant::KeySequence ) );
- QKeySequence d = qVariantValue<QKeySequence>(value);
+ QKeySequence d = qvariant_cast<QKeySequence>(value);
QCOMPARE( d, result );
}
@@ -1226,7 +1289,7 @@ void tst_QVariant::toString_data()
QTest::newRow( "qdate" ) << QVariant( QDate( 2002, 1, 1 ) ) << QString( "2002-01-01" );
QTest::newRow( "qtime" ) << QVariant( QTime( 12, 34, 56 ) ) << QString( "12:34:56" );
QTest::newRow( "qdatetime" ) << QVariant( QDateTime( QDate( 2002, 1, 1 ), QTime( 12, 34, 56 ) ) ) << QString( "2002-01-01T12:34:56" );
- QTest::newRow( "qkeysequence" ) << qVariantFromValue( QKeySequence( Qt::CTRL + Qt::Key_A ) )
+ QTest::newRow( "qkeysequence" ) << QVariant::fromValue( QKeySequence( Qt::CTRL + Qt::Key_A ) )
#ifndef Q_OS_MAC
<< QString( "Ctrl+A" );
#else
@@ -1234,8 +1297,8 @@ void tst_QVariant::toString_data()
#endif
QFont font( "times", 12 );
- QTest::newRow( "qfont" ) << qVariantFromValue( font ) << QString("times,12,-1,5,50,0,0,0,0,0");
- QTest::newRow( "qcolor" ) << qVariantFromValue( QColor( 10, 10, 10 ) ) << QString( "#0a0a0a" );
+ QTest::newRow( "qfont" ) << QVariant::fromValue( font ) << QString("times,12,-1,5,50,0,0,0,0,0");
+ QTest::newRow( "qcolor" ) << QVariant::fromValue( QColor( 10, 10, 10 ) ) << QString( "#0a0a0a" );
QTest::newRow( "llong" ) << QVariant( (qlonglong)Q_INT64_C(123456789012) ) <<
QString( "123456789012" );
}
@@ -1342,10 +1405,10 @@ void tst_QVariant::toRegularExpression()
void tst_QVariant::matrix()
{
QVariant variant;
- QMatrix matrix = qVariantValue<QMatrix>(variant);
+ QMatrix matrix = qvariant_cast<QMatrix>(variant);
QVERIFY(matrix.isIdentity());
- qVariantSetValue(variant, QMatrix().rotate(90));
- QCOMPARE(QMatrix().rotate(90), qVariantValue<QMatrix>(variant));
+ variant.setValue(QMatrix().rotate(90));
+ QCOMPARE(QMatrix().rotate(90), qvariant_cast<QMatrix>(variant));
void *mmatrix = QMetaType::create(QVariant::Matrix, 0);
QVERIFY(mmatrix);
@@ -1355,12 +1418,12 @@ void tst_QVariant::matrix()
void tst_QVariant::matrix4x4()
{
QVariant variant;
- QMatrix4x4 matrix = qVariantValue<QMatrix4x4>(variant);
+ QMatrix4x4 matrix = qvariant_cast<QMatrix4x4>(variant);
QVERIFY(matrix.isIdentity());
QMatrix4x4 m;
m.scale(2.0f);
- qVariantSetValue(variant, m);
- QCOMPARE(m, qVariantValue<QMatrix4x4>(variant));
+ variant.setValue(m);
+ QCOMPARE(m, qvariant_cast<QMatrix4x4>(variant));
void *mmatrix = QMetaType::create(QVariant::Matrix4x4, 0);
QVERIFY(mmatrix);
@@ -1370,10 +1433,10 @@ void tst_QVariant::matrix4x4()
void tst_QVariant::transform()
{
QVariant variant;
- QTransform matrix = qVariantValue<QTransform>(variant);
+ QTransform matrix = qvariant_cast<QTransform>(variant);
QVERIFY(matrix.isIdentity());
- qVariantSetValue(variant, QTransform().rotate(90));
- QCOMPARE(QTransform().rotate(90), qVariantValue<QTransform>(variant));
+ variant.setValue(QTransform().rotate(90));
+ QCOMPARE(QTransform().rotate(90), qvariant_cast<QTransform>(variant));
void *mmatrix = QMetaType::create(QVariant::Transform, 0);
QVERIFY(mmatrix);
@@ -1384,10 +1447,10 @@ void tst_QVariant::transform()
void tst_QVariant::vector2D()
{
QVariant variant;
- QVector2D vector = qVariantValue<QVector2D>(variant);
+ QVector2D vector = qvariant_cast<QVector2D>(variant);
QVERIFY(vector.isNull());
- qVariantSetValue(variant, QVector2D(0.1, 0.2));
- QCOMPARE(QVector2D(0.1, 0.2), qVariantValue<QVector2D>(variant));
+ variant.setValue(QVector2D(0.1, 0.2));
+ QCOMPARE(QVector2D(0.1, 0.2), qvariant_cast<QVector2D>(variant));
void *pvector = QMetaType::create(QVariant::Vector2D, 0);
QVERIFY(pvector);
@@ -1397,10 +1460,10 @@ void tst_QVariant::vector2D()
void tst_QVariant::vector3D()
{
QVariant variant;
- QVector3D vector = qVariantValue<QVector3D>(variant);
+ QVector3D vector = qvariant_cast<QVector3D>(variant);
QVERIFY(vector.isNull());
- qVariantSetValue(variant, QVector3D(0.1, 0.2, 0.3));
- QCOMPARE(QVector3D(0.1, 0.2, 0.3), qVariantValue<QVector3D>(variant));
+ variant.setValue(QVector3D(0.1, 0.2, 0.3));
+ QCOMPARE(QVector3D(0.1, 0.2, 0.3), qvariant_cast<QVector3D>(variant));
void *pvector = QMetaType::create(QVariant::Vector3D, 0);
QVERIFY(pvector);
@@ -1410,10 +1473,10 @@ void tst_QVariant::vector3D()
void tst_QVariant::vector4D()
{
QVariant variant;
- QVector4D vector = qVariantValue<QVector4D>(variant);
+ QVector4D vector = qvariant_cast<QVector4D>(variant);
QVERIFY(vector.isNull());
- qVariantSetValue(variant, QVector4D(0.1, 0.2, 0.3, 0.4));
- QCOMPARE(QVector4D(0.1, 0.2, 0.3, 0.4), qVariantValue<QVector4D>(variant));
+ variant.setValue(QVector4D(0.1, 0.2, 0.3, 0.4));
+ QCOMPARE(QVector4D(0.1, 0.2, 0.3, 0.4), qvariant_cast<QVector4D>(variant));
void *pvector = QMetaType::create(QVariant::Vector4D, 0);
QVERIFY(pvector);
@@ -1423,10 +1486,10 @@ void tst_QVariant::vector4D()
void tst_QVariant::quaternion()
{
QVariant variant;
- QQuaternion quaternion = qVariantValue<QQuaternion>(variant);
+ QQuaternion quaternion = qvariant_cast<QQuaternion>(variant);
QVERIFY(quaternion.isIdentity());
- qVariantSetValue(variant, QQuaternion(0.1, 0.2, 0.3, 0.4));
- QCOMPARE(QQuaternion(0.1, 0.2, 0.3, 0.4), qVariantValue<QQuaternion>(variant));
+ variant.setValue(QQuaternion(0.1, 0.2, 0.3, 0.4));
+ QCOMPARE(QQuaternion(0.1, 0.2, 0.3, 0.4), qvariant_cast<QQuaternion>(variant));
void *pquaternion = QMetaType::create(QVariant::Quaternion, 0);
QVERIFY(pquaternion);
@@ -1483,14 +1546,14 @@ void tst_QVariant::writeToReadFromDataStream_data()
bytearray[3] = 't';
bytearray[4] = '\0';
QTest::newRow( "bytearray_valid" ) << QVariant( bytearray ) << false;
- QTest::newRow( "bitmap_invalid" ) << qVariantFromValue( QBitmap() ) << true;
+ QTest::newRow( "bitmap_invalid" ) << QVariant::fromValue( QBitmap() ) << true;
QBitmap bitmap( 10, 10 );
bitmap.fill( Qt::red );
- QTest::newRow( "bitmap_valid" ) << qVariantFromValue( bitmap ) << false;
- QTest::newRow( "brush_valid" ) << qVariantFromValue( QBrush( Qt::red ) ) << false;
- QTest::newRow( "color_valid" ) << qVariantFromValue( QColor( Qt::red ) ) << false;
+ QTest::newRow( "bitmap_valid" ) << QVariant::fromValue( bitmap ) << false;
+ QTest::newRow( "brush_valid" ) << QVariant::fromValue( QBrush( Qt::red ) ) << false;
+ QTest::newRow( "color_valid" ) << QVariant::fromValue( QColor( Qt::red ) ) << false;
#ifndef QT_NO_CURSOR
- QTest::newRow( "cursor_valid" ) << qVariantFromValue( QCursor( Qt::PointingHandCursor ) ) << false;
+ QTest::newRow( "cursor_valid" ) << QVariant::fromValue( QCursor( Qt::PointingHandCursor ) ) << false;
#endif
QTest::newRow( "date_invalid" ) << QVariant( QDate() ) << true;
QTest::newRow( "date_valid" ) << QVariant( QDate( 2002, 07, 06 ) ) << false;
@@ -1498,14 +1561,14 @@ void tst_QVariant::writeToReadFromDataStream_data()
QTest::newRow( "datetime_valid" ) << QVariant( QDateTime( QDate( 2002, 07, 06 ), QTime( 14, 0, 0 ) ) ) << false;
QTest::newRow( "double_valid" ) << QVariant( 123.456 ) << false;
QTest::newRow( "float_valid" ) << QVariant( 123.456f ) << false;
- QTest::newRow( "font_valid" ) << qVariantFromValue( QFont( "times", 12 ) ) << false;
- QTest::newRow( "pixmap_invalid" ) << qVariantFromValue( QPixmap() ) << true;
+ QTest::newRow( "font_valid" ) << QVariant::fromValue( QFont( "times", 12 ) ) << false;
+ QTest::newRow( "pixmap_invalid" ) << QVariant::fromValue( QPixmap() ) << true;
QPixmap pixmap( 10, 10 );
pixmap.fill( Qt::red );
- QTest::newRow( "pixmap_valid" ) << qVariantFromValue( pixmap ) << false;
+ QTest::newRow( "pixmap_valid" ) << QVariant::fromValue( pixmap ) << false;
// QTest::newRow( "iconset_valid" ) << QVariant( QIcon( pixmap ) ) << false;
- QTest::newRow( "image_invalid" ) << qVariantFromValue( QImage() ) << true;
- QTest::newRow( "keysequence_valid" ) << qVariantFromValue( QKeySequence( Qt::CTRL + Qt::Key_A ) ) << false;
+ QTest::newRow( "image_invalid" ) << QVariant::fromValue( QImage() ) << true;
+ QTest::newRow( "keysequence_valid" ) << QVariant::fromValue( QKeySequence( Qt::CTRL + Qt::Key_A ) ) << false;
QTest::newRow( "int_valid" ) << QVariant( -123 ) << false;
typedef QMap<QString, QVariant> variantsMap;
variantsMap vMap;
@@ -1514,15 +1577,15 @@ void tst_QVariant::writeToReadFromDataStream_data()
vMap.insert( "double", QVariant( 3.45 ) );
vMap.insert( "float", QVariant( 3.45f ) );
QTest::newRow( "map_valid" ) << QVariant( vMap ) << false;
- QTest::newRow( "palette_valid" ) << qVariantFromValue(QPalette(QColor("turquoise"))) << false;
- QTest::newRow( "pen_valid" ) << qVariantFromValue( QPen( Qt::red ) ) << false;
- QTest::newRow( "pointarray_invalid" ) << qVariantFromValue( QPolygon() ) << true;
- QTest::newRow( "pointarray_valid" ) << qVariantFromValue( QPolygon( QRect( 10, 10, 20, 20 ) ) ) << false;
- QTest::newRow( "region_invalid" ) << qVariantFromValue( QRegion() ) << true;
- QTest::newRow( "region_valid" ) << qVariantFromValue( QRegion( 10, 10, 20, 20 ) ) << false;
- QTest::newRow( "sizepolicy_valid" ) << qVariantFromValue( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ) << false;
- QTest::newRow( "point_invalid" ) << qVariantFromValue( QPoint() ) << true;
- QTest::newRow( "point_valid" ) << qVariantFromValue( QPoint( 10, 10 ) ) << false;
+ QTest::newRow( "palette_valid" ) << QVariant::fromValue(QPalette(QColor("turquoise"))) << false;
+ QTest::newRow( "pen_valid" ) << QVariant::fromValue( QPen( Qt::red ) ) << false;
+ QTest::newRow( "pointarray_invalid" ) << QVariant::fromValue( QPolygon() ) << true;
+ QTest::newRow( "pointarray_valid" ) << QVariant::fromValue( QPolygon( QRect( 10, 10, 20, 20 ) ) ) << false;
+ QTest::newRow( "region_invalid" ) << QVariant::fromValue( QRegion() ) << true;
+ QTest::newRow( "region_valid" ) << QVariant::fromValue( QRegion( 10, 10, 20, 20 ) ) << false;
+ QTest::newRow( "sizepolicy_valid" ) << QVariant::fromValue( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ) << false;
+ QTest::newRow( "point_invalid" ) << QVariant::fromValue( QPoint() ) << true;
+ QTest::newRow( "point_valid" ) << QVariant::fromValue( QPoint( 10, 10 ) ) << false;
QTest::newRow( "rect_invalid" ) << QVariant( QRect() ) << true;
QTest::newRow( "rect_valid" ) << QVariant( QRect( 10, 10, 20, 20 ) ) << false;
QTest::newRow( "size_invalid" ) << QVariant( QSize( 0, 0 ) ) << true;
@@ -2067,7 +2130,7 @@ void tst_QVariant::userType()
{
QVariant userVar;
- qVariantSetValue(userVar, data);
+ userVar.setValue(data);
QCOMPARE(userVar.type(), QVariant::UserType);
QCOMPARE(userVar.userType(), qMetaTypeId<MyType>());
@@ -2078,7 +2141,7 @@ void tst_QVariant::userType()
QVariant userVar2(userVar);
QVERIFY(userVar == userVar2);
- qVariantSetValue(userVar2, data2);
+ userVar2.setValue(data2);
QVERIFY(userVar != userVar2);
const MyType *varData = static_cast<const MyType *>(userVar.constData());
@@ -2087,7 +2150,7 @@ void tst_QVariant::userType()
QCOMPARE(varData->text, data.text);
QVariant userVar3;
- qVariantSetValue(userVar3, data2);
+ userVar3.setValue(data2);
userVar3 = userVar2;
QVERIFY(userVar2 == userVar3);
@@ -2096,7 +2159,7 @@ void tst_QVariant::userType()
QCOMPARE(instanceCount, 2);
{
QVariant userVar;
- qVariantSetValue(userVar, &data);
+ userVar.setValue(&data);
QCOMPARE(userVar.type(), QVariant::UserType);
QCOMPARE(userVar.userType(), qMetaTypeId<MyType*>());
@@ -2107,7 +2170,7 @@ void tst_QVariant::userType()
QVariant userVar2(userVar);
QVERIFY(userVar == userVar2);
- qVariantSetValue(userVar2, &data2);
+ userVar2.setValue(&data2);
QVERIFY(userVar != userVar2);
MyType * const*varData = reinterpret_cast<MyType *const *>(userVar.constData());
@@ -2115,7 +2178,7 @@ void tst_QVariant::userType()
QCOMPARE(*varData, &data);
QVariant userVar3;
- qVariantSetValue(userVar3, &data2);
+ userVar3.setValue(&data2);
/* This check is correct now. userVar2 contains a pointer to data2 and so
* does userVar3. */
@@ -2127,7 +2190,7 @@ void tst_QVariant::userType()
QCOMPARE(instanceCount, 2);
QVariant myCarrier;
- qVariantSetValue(myCarrier, data);
+ myCarrier.setValue(data);
QCOMPARE(instanceCount, 3);
{
QVariant second = myCarrier;
@@ -2138,7 +2201,7 @@ void tst_QVariant::userType()
QCOMPARE(instanceCount, 3);
MyType data3(0, "null");
- data3 = qVariantValue<MyType>(myCarrier);
+ data3 = qvariant_cast<MyType>(myCarrier);
QCOMPARE(data3.number, 1);
QCOMPARE(data3.text, (const char *)"eins");
#ifndef Q_CC_SUN
@@ -2151,7 +2214,7 @@ void tst_QVariant::userType()
const MyType data(3, "drei");
QVariant myCarrier;
- qVariantSetValue(myCarrier, data);
+ myCarrier.setValue(data);
QCOMPARE(myCarrier.typeName(), "MyType");
const MyType data2 = qvariant_cast<MyType>(myCarrier);
@@ -2163,7 +2226,7 @@ void tst_QVariant::userType()
short s = 42;
QVariant myCarrier;
- qVariantSetValue(myCarrier, s);
+ myCarrier.setValue(s);
QCOMPARE((int)qvariant_cast<short>(myCarrier), 42);
}
@@ -2171,7 +2234,7 @@ void tst_QVariant::userType()
qlonglong ll = Q_INT64_C(42);
QVariant myCarrier;
- qVariantSetValue(myCarrier, ll);
+ myCarrier.setValue(ll);
QCOMPARE(qvariant_cast<int>(myCarrier), 42);
}
@@ -2192,14 +2255,14 @@ void tst_QVariant::podUserType()
pod.a = 10;
pod.b = 20;
- QVariant pod_as_variant = qVariantFromValue(pod);
+ QVariant pod_as_variant = QVariant::fromValue(pod);
MyTypePOD pod2 = qvariant_cast<MyTypePOD>(pod_as_variant);
QCOMPARE(pod.a, pod2.a);
QCOMPARE(pod.b, pod2.b);
- qVariantSetValue(pod_as_variant, pod);
- pod2 = qVariantValue<MyTypePOD>(pod_as_variant);
+ pod_as_variant.setValue(pod);
+ pod2 = qvariant_cast<MyTypePOD>(pod_as_variant);
QCOMPARE(pod.a, pod2.a);
QCOMPARE(pod.b, pod2.b);
@@ -2266,7 +2329,7 @@ void tst_QVariant::data()
v = f;
QVERIFY(v.data());
- QCOMPARE(*static_cast<float *>(v.data()), qVariantValue<float>(v));
+ QCOMPARE(*static_cast<float *>(v.data()), qvariant_cast<float>(v));
v = ll;
QVERIFY(v.data());
@@ -2345,12 +2408,12 @@ void tst_QVariant::variant_to()
QStringList sl;
sl << QLatin1String("blah");
- qVariantSetValue(v3, sl);
+ v3.setValue(sl);
Foo foo;
foo.i = 42;
- qVariantSetValue(v4, foo);
+ v4.setValue(foo);
QCOMPARE(qvariant_cast<double>(v1), 4.2);
QCOMPARE(qvariant_cast<float>(v1), 4.2f);
@@ -2365,7 +2428,7 @@ void tst_QVariant::variant_to()
QCOMPARE(qvariant_cast<int>(v1), 4);
- QVariant n = qVariantFromValue<short>(42);
+ QVariant n = QVariant::fromValue<short>(42);
QCOMPARE(qvariant_cast<int>(n), 42);
QCOMPARE(qvariant_cast<uint>(n), 42u);
QCOMPARE(qvariant_cast<double>(n), 42.0);
@@ -2373,7 +2436,7 @@ void tst_QVariant::variant_to()
QCOMPARE(qvariant_cast<short>(n), short(42));
QCOMPARE(qvariant_cast<ushort>(n), ushort(42));
- n = qVariantFromValue(43l);
+ n = QVariant::fromValue(43l);
QCOMPARE(qvariant_cast<int>(n), 43);
QCOMPARE(qvariant_cast<uint>(n), 43u);
QCOMPARE(qvariant_cast<double>(n), 43.0);
@@ -2385,7 +2448,7 @@ void tst_QVariant::variant_to()
QCOMPARE(qvariant_cast<ulong>(n), 44ul);
QCOMPARE(qvariant_cast<float>(n), 44.0f);
- QCOMPARE(qVariantFromValue(0.25f).toDouble(), 0.25);
+ QCOMPARE(QVariant::fromValue(0.25f).toDouble(), 0.25);
}
struct Blah { int i; };
@@ -2437,10 +2500,10 @@ void tst_QVariant::url()
QVariant v3(str); //built with a QString
QCOMPARE(v2.toUrl(), url);
- QVERIFY(qVariantCanConvert<QUrl>(v3));
+ QVERIFY(v3.canConvert<QUrl>());
QCOMPARE(v2.toUrl(), v3.toUrl());
- QVERIFY(qVariantCanConvert<QString>(v2));
+ QVERIFY(v2.canConvert<QString>());
QCOMPARE(v2.toString(), str);
QCOMPARE(v3.toString(), str);
}
@@ -2615,7 +2678,7 @@ void tst_QVariant::convertToQUint8() const
* It's of type QVariant::Int. */
const QVariant v0 = anInt;
- QVERIFY(qVariantCanConvert<qint8>(v0));
+ QVERIFY(v0.canConvert<qint8>());
QCOMPARE(int(qvariant_cast<qint8>(v0)), 32);
QCOMPARE(int(v0.toInt()), 32);
QCOMPARE(v0.toString(), QString("32"));
@@ -2633,7 +2696,7 @@ void tst_QVariant::convertToQUint8() const
const quint8 anInt = 32;
const QVariant v0 = anInt;
- QVERIFY(qVariantCanConvert<quint8>(v0));
+ QVERIFY(v0.canConvert<quint8>());
QCOMPARE(int(qvariant_cast<quint8>(v0)), 32);
QCOMPARE(int(v0.toUInt()), 32);
QCOMPARE(v0.toString(), QString("32"));
@@ -2644,7 +2707,7 @@ void tst_QVariant::convertToQUint8() const
const qint16 anInt = 32;
const QVariant v0 = anInt;
- QVERIFY(qVariantCanConvert<qint16>(v0));
+ QVERIFY(v0.canConvert<qint16>());
QCOMPARE(int(qvariant_cast<qint16>(v0)), 32);
QCOMPARE(int(v0.toInt()), 32);
QCOMPARE(v0.toString(), QString("32"));
@@ -2655,7 +2718,7 @@ void tst_QVariant::convertToQUint8() const
const quint16 anInt = 32;
const QVariant v0 = anInt;
- QVERIFY(qVariantCanConvert<quint16>(v0));
+ QVERIFY(v0.canConvert<quint16>());
QCOMPARE(int(qvariant_cast<quint16>(v0)), 32);
QCOMPARE(int(v0.toUInt()), 32);
QCOMPARE(v0.toString(), QString("32"));
@@ -2670,8 +2733,8 @@ void tst_QVariant::comparePointers() const
MyClass myClass;
- QVariant v = qVariantFromValue<void *>(&myClass);
- QVariant v2 = qVariantFromValue<void *>(&myClass);
+ QVariant v = QVariant::fromValue<void *>(&myClass);
+ QVariant v2 = QVariant::fromValue<void *>(&myClass);
QCOMPARE(v, v2);
}
@@ -2686,15 +2749,15 @@ void tst_QVariant::voidStar() const
void *p2 = p1;
QVariant v1, v2;
- v1 = qVariantFromValue(p1);
+ v1 = QVariant::fromValue(p1);
v2 = v1;
QVERIFY(v1 == v2);
- v2 = qVariantFromValue(p2);
+ v2 = QVariant::fromValue(p2);
QVERIFY(v1 == v2);
p2 = 0;
- v2 = qVariantFromValue(p2);
+ v2 = QVariant::fromValue(p2);
QVERIFY(v1 != v2);
}
@@ -2703,14 +2766,14 @@ void tst_QVariant::dataStar() const
qRegisterMetaType<Data*>();
Data *p1 = new Data;
- QVariant v1 = qVariantFromValue(p1);
+ QVariant v1 = QVariant::fromValue(p1);
QCOMPARE(v1.userType(), qMetaTypeId<Data*>());
QCOMPARE(qvariant_cast<Data*>(v1), p1);
QVariant v2 = v1;
QVERIFY(v1 == v2);
- v2 = qVariantFromValue(p1);
+ v2 = QVariant::fromValue(p1);
QVERIFY(v1 == v2);
delete p1;
}
@@ -2748,10 +2811,10 @@ void tst_QVariant::canConvertQStringList_data() const
template<typename T> void convertMetaType()
{
- QVERIFY(qVariantFromValue<T>(10).isValid());
- QVERIFY(qVariantFromValue<T>(10).canConvert(QVariant::Int));
- QCOMPARE(qVariantFromValue<T>(10).toInt(), 10);
- QCOMPARE(qVariantFromValue<T>(10), qVariantFromValue<T>(10));
+ QVERIFY(QVariant::fromValue<T>(10).isValid());
+ QVERIFY(QVariant::fromValue<T>(10).canConvert(QVariant::Int));
+ QCOMPARE(QVariant::fromValue<T>(10).toInt(), 10);
+ QCOMPARE(QVariant::fromValue<T>(10), QVariant::fromValue<T>(10));
}
#define CONVERT_META_TYPE(Type) \
@@ -2818,6 +2881,8 @@ Q_DECLARE_METATYPE( MyClass )
void tst_QVariant::loadUnknownUserType()
{
qRegisterMetaType<MyClass>("MyClass");
+ QTest::ignoreMessage(QtWarningMsg, "QVariant::load: unable to load type "
+ + QByteArray::number(qMetaTypeId<MyClass>()) +".");
char data[] = {0, 0, QMetaType::User >> 8 , char(QMetaType::User), 0, 0, 0, 0, 8, 'M', 'y', 'C', 'l', 'a', 's', 's', 0};
QByteArray ba(data, sizeof(data));
@@ -2829,13 +2894,14 @@ void tst_QVariant::loadUnknownUserType()
void tst_QVariant::loadBrokenUserType()
{
- char data[] = {0, 0, 0, 127, 0, 112 };
+ QTest::ignoreMessage(QtWarningMsg, "Trying to construct an instance of an invalid type, type id: 127");
+ char data[] = {0, 0, 0, 127, 0 };
QByteArray ba(data, sizeof(data));
QDataStream ds(&ba, QIODevice::ReadOnly);
QVariant var;
var.load(ds);
- QCOMPARE(ds.status(), QDataStream::ReadPastEnd);
+ QCOMPARE(ds.status(), QDataStream::Ok);
}
void tst_QVariant::invalidDate() const
@@ -2872,11 +2938,11 @@ void tst_QVariant::compareCustomTypes() const
WontCompare f1;
f1.x = 0;
- const QVariant variant1(qVariantFromValue(f1));
+ const QVariant variant1(QVariant::fromValue(f1));
WontCompare f2;
f2.x = 0;
- const QVariant variant2(qVariantFromValue(f2));
+ const QVariant variant2(QVariant::fromValue(f2));
/* We compare pointers. */
QVERIFY(variant1 != variant2);
@@ -2898,10 +2964,10 @@ void tst_QVariant::copyingUserTypes() const
QVariant var;
QVariant var3;
const QHostAddress ha("127.0.0.1");
- qVariantSetValue(var, ha);
+ var.setValue(ha);
var3 = var;
- QCOMPARE(qVariantValue<QHostAddress>(var3), ha);
+ QCOMPARE(qvariant_cast<QHostAddress>(var3), ha);
}
void tst_QVariant::convertBoolToByteArray() const
@@ -2912,7 +2978,7 @@ void tst_QVariant::convertBoolToByteArray() const
const QVariant variant(input);
- QCOMPARE(qVariantCanConvert<bool>(variant), canConvert);
+ QCOMPARE(variant.canConvert<bool>(), canConvert);
if(canConvert) {
/* Just call this function so we run the code path. */
@@ -2980,7 +3046,7 @@ void tst_QVariant::convertByteArrayToBool() const
const QVariant variant(input);
QCOMPARE(variant.type(), QVariant::Bool);
QCOMPARE(variant.toBool(), input);
- QVERIFY(qVariantCanConvert<bool>(variant));
+ QVERIFY(variant.canConvert<bool>());
QCOMPARE(variant.toByteArray(), output);
}
@@ -3055,7 +3121,7 @@ void tst_QVariant::setValue()
QVERIFY( !v1.isDetached() );
QVERIFY( !v2.isDetached() );
- qVariantSetValue(v2, 3); //set an integer value
+ v2.setValue(3); //set an integer value
QVERIFY( v1.isDetached() );
QVERIFY( v2.isDetached() );
@@ -3134,7 +3200,7 @@ template<class T> void playWithVariant(const T &orig, bool isNull, const QString
}
QCOMPARE(qvariant_cast<T>(v2), qvariant_cast<T>(v));
QCOMPARE(v2.toString(), toString);
- v3 = qVariantFromValue(orig);
+ v3 = QVariant::fromValue(orig);
QVERIFY(v3.isValid());
QCOMPARE(v3.isNull(), isNull);
@@ -3344,7 +3410,7 @@ void tst_QVariant::moreCustomTypes()
PLAY_WITH_VARIANT( qint32(17), false, "17", 17, true);
PLAY_WITH_VARIANT(quint64(18), false, "18", 18, true);
PLAY_WITH_VARIANT( qint64(19), false, "19", 19, true);
- PLAY_WITH_VARIANT( qint8(-12), false, "\xf4", -12, true);
+ PLAY_WITH_VARIANT( qint8(-12), false, QLatin1String("\xf4"), -12, true); // qint8 is char, so it gets converted via QChar
PLAY_WITH_VARIANT( qint16(-13), false, "-13", -13, true);
PLAY_WITH_VARIANT( qint32(-14), false, "-14", -14, true);
PLAY_WITH_VARIANT( qint64(-15), false, "-15", -15, true);
diff --git a/tests/auto/corelib/plugin/qfactoryloader/test/test.pro b/tests/auto/corelib/plugin/qfactoryloader/test/test.pro
index d03af231aa..1ec4db8756 100644
--- a/tests/auto/corelib/plugin/qfactoryloader/test/test.pro
+++ b/tests/auto/corelib/plugin/qfactoryloader/test/test.pro
@@ -18,4 +18,3 @@ win32 {
}
mac: CONFIG -= app_bundle
-mac: CONFIG += insignificant_test # QTBUG-22765
diff --git a/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro b/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro
index 810efe856c..a8dad32720 100644
--- a/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro
+++ b/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro
@@ -13,5 +13,3 @@ win32 {
}
TESTDATA += ../elftest
-
-mac: CONFIG += insignificant_test # QTBUG-22765
diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
index 267aa71085..e84eb95447 100644
--- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
@@ -170,10 +170,10 @@ static const struct StaticByteArrays {
const char string[8];
} shiftedNotNullTerminated;
-} statics = {{{ Q_REFCOUNT_INITIALIZE_STATIC, /* length = */ 4, 0, 0, sizeof(QByteArrayData) }, "data"}
- ,{{ Q_REFCOUNT_INITIALIZE_STATIC, /* length = */ 4, 0, 0, sizeof(QByteArrayData) }, "dataBAD"}
- ,{{ Q_REFCOUNT_INITIALIZE_STATIC, /* length = */ 4, 0, 0, sizeof(QByteArrayData) + sizeof(char) }, 0, "data"}
- ,{{ Q_REFCOUNT_INITIALIZE_STATIC, /* length = */ 4, 0, 0, sizeof(QByteArrayData) + sizeof(char) }, 0, "dataBAD"}
+} statics = {{Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER(4), "data"}
+ ,{Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER(4), "dataBAD"}
+ ,{Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(4, sizeof(QByteArrayData) + sizeof(char)), 0, "data"}
+ ,{Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(4, sizeof(QByteArrayData) + sizeof(char)), 0, "dataBAD"}
};
static const QByteArrayDataPtr staticStandard = { const_cast<QByteArrayData *>(&statics.standard.data) };
diff --git a/tests/auto/corelib/tools/qchar/tst_qchar.cpp b/tests/auto/corelib/tools/qchar/tst_qchar.cpp
index 14c43d0088..1a568073cf 100644
--- a/tests/auto/corelib/tools/qchar/tst_qchar.cpp
+++ b/tests/auto/corelib/tools/qchar/tst_qchar.cpp
@@ -276,8 +276,65 @@ void tst_QChar::isLetterOrNumber()
void tst_QChar::isPrint()
{
+ // noncharacters, reserved (General_Gategory =Cn)
+ QVERIFY(!QChar(0x2064).isPrint());
+ QVERIFY(!QChar(0x2069).isPrint());
+ QVERIFY(!QChar(0xfdd0).isPrint());
+ QVERIFY(!QChar(0xfdef).isPrint());
+ QVERIFY(!QChar(0xfff0).isPrint());
+ QVERIFY(!QChar(0xfff8).isPrint());
+ QVERIFY(!QChar(0xfffe).isPrint());
+ QVERIFY(!QChar(0xffff).isPrint());
+/*
+ QVERIFY(!QChar::isPrint(0xe0000u));
+ QVERIFY(!QChar::isPrint(0xe0002u));
+ QVERIFY(!QChar::isPrint(0xe001fu));
+ QVERIFY(!QChar::isPrint(0xe0080u));
+ QVERIFY(!QChar::isPrint(0xe00ffu));
+*/
+
+ // Other_Default_Ignorable_Code_Point, Variation_Selector
+ QVERIFY(QChar(0x034f).isPrint());
+ QVERIFY(QChar(0x115f).isPrint());
+ QVERIFY(QChar(0x180b).isPrint());
+ QVERIFY(QChar(0x180d).isPrint());
+ QVERIFY(QChar(0x3164).isPrint());
+ QVERIFY(QChar(0xfe00).isPrint());
+ QVERIFY(QChar(0xfe0f).isPrint());
+ QVERIFY(QChar(0xffa0).isPrint());
+/*
+ QVERIFY(QChar::isPrint(0xe0100u));
+ QVERIFY(QChar::isPrint(0xe01efu));
+*/
+
+ // Cf, Cs, Cc, White_Space, Annotation Characters
+ QVERIFY(!QChar(0x0008).isPrint());
+ QVERIFY(!QChar(0x000a).isPrint());
+ QVERIFY(QChar(0x0020).isPrint());
+ QVERIFY(QChar(0x00a0).isPrint());
+ QVERIFY(!QChar(0x00ad).isPrint());
+ QVERIFY(!QChar(0x0085).isPrint());
+ QVERIFY(!QChar(0xd800).isPrint());
+ QVERIFY(!QChar(0xdc00).isPrint());
+ QVERIFY(!QChar(0xfeff).isPrint());
+/*
+ QVERIFY(!QChar::isPrint(0x1d173u));
+*/
+
+ QVERIFY(QChar('0').isPrint());
QVERIFY(QChar('A').isPrint());
- QVERIFY(!QChar(0x1aff).isPrint()); // General_Gategory =Cn
+ QVERIFY(QChar('a').isPrint());
+
+ QVERIFY(!QChar(0x0370).isPrint()); // assigned in 5.1
+ QVERIFY(!QChar(0x0524).isPrint()); // assigned in 5.2
+ QVERIFY(!QChar(0x0526).isPrint()); // assigned in 6.0
+ QVERIFY(!QChar(0x08a0).isPrint()); // assigned in 6.1
+ QVERIFY(!QChar(0x1aff).isPrint()); // not assigned
+ QVERIFY(!QChar(0x1e9e).isPrint()); // assigned in 5.1
+/*
+ QVERIFY(!QChar::isPrint(0x1b000u)); // assigned in 6.0
+ QVERIFY(!QChar::isPrint(0x110d0u)); // assigned in 5.1
+*/
}
void tst_QChar::isUpper()
@@ -551,6 +608,14 @@ void tst_QChar::mirroredChar()
void tst_QChar::decomposition()
{
+ // Hangul syllables
+ for (uint ucs = 0xac00; ucs <= 0xd7af; ++ucs) {
+ QChar::Decomposition expected = QChar::unicodeVersion(ucs) > QChar::Unicode_Unassigned ? QChar::Canonical : QChar::NoDecomposition;
+ QString desc = QString::fromLatin1("ucs = 0x%1, tag = %2, expected = %3")
+ .arg(QString::number(ucs, 16)).arg(QChar::decompositionTag(ucs)).arg(expected);
+ QVERIFY2(QChar::decompositionTag(ucs) == expected, desc.toLatin1());
+ }
+
QVERIFY(QChar((ushort)0xa0).decompositionTag() == QChar::NoBreak);
QVERIFY(QChar((ushort)0xa8).decompositionTag() == QChar::Compat);
QVERIFY(QChar((ushort)0x41).decompositionTag() == QChar::NoDecomposition);
@@ -748,6 +813,25 @@ void tst_QChar::normalization_manual()
QVERIFY(composed.normalized(QString::NormalizationForm_KD) == decomposed);
QVERIFY(composed.normalized(QString::NormalizationForm_KC) == decomposed);
}
+ { // hangul
+ QString composed;
+ composed += QChar(0xc154);
+ composed += QChar(0x11f0);
+ QString decomposed;
+ decomposed += QChar(0x1109);
+ decomposed += QChar(0x1167);
+ decomposed += QChar(0x11f0);
+
+ QVERIFY(composed.normalized(QString::NormalizationForm_D) == decomposed);
+ QVERIFY(composed.normalized(QString::NormalizationForm_C) == composed);
+ QVERIFY(composed.normalized(QString::NormalizationForm_KD) == decomposed);
+ QVERIFY(composed.normalized(QString::NormalizationForm_KC) == composed);
+
+ QVERIFY(decomposed.normalized(QString::NormalizationForm_D) == decomposed);
+ QVERIFY(decomposed.normalized(QString::NormalizationForm_C) == composed);
+ QVERIFY(decomposed.normalized(QString::NormalizationForm_KD) == decomposed);
+ QVERIFY(decomposed.normalized(QString::NormalizationForm_KC) == composed);
+ }
}
void tst_QChar::normalizationCorrections()
diff --git a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp
index 40e3cd08b6..487007e4cf 100644
--- a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp
+++ b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp
@@ -526,7 +526,7 @@ void tst_QEasingCurve::properties()
obj.setEasing(inOutBack);
- QEasingCurve easing = qVariantValue<QEasingCurve>(obj.property("easing"));
+ QEasingCurve easing = qvariant_cast<QEasingCurve>(obj.property("easing"));
QCOMPARE(easing.type(), QEasingCurve::InOutBack);
QCOMPARE(easing.overshoot(), overshoot);
QCOMPARE(easing.amplitude(), amplitude);
@@ -538,9 +538,9 @@ void tst_QEasingCurve::properties()
period = linear.period();
obj.setProperty("easing",
- qVariantFromValue(QEasingCurve(QEasingCurve::Linear)));
+ QVariant::fromValue(QEasingCurve(QEasingCurve::Linear)));
- easing = qVariantValue<QEasingCurve>(obj.property("easing"));
+ easing = qvariant_cast<QEasingCurve>(obj.property("easing"));
QCOMPARE(easing.type(), QEasingCurve::Linear);
QCOMPARE(easing.overshoot(), overshoot);
QCOMPARE(easing.amplitude(), amplitude);
diff --git a/tests/auto/corelib/tools/qlocale/test/test.pro b/tests/auto/corelib/tools/qlocale/test/test.pro
index 28e127e307..25023fad4d 100644
--- a/tests/auto/corelib/tools/qlocale/test/test.pro
+++ b/tests/auto/corelib/tools/qlocale/test/test.pro
@@ -16,5 +16,4 @@ win32 {
load(testcase) # for target.path and installTestHelperApp()
installTestHelperApp("../syslocaleapp/syslocaleapp",syslocaleapp,syslocaleapp)
-mac: CONFIG += insignificant_test # QTBUG-22769
win32:CONFIG+= insignificant_test # QTBUG-25284
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index 1905c9c049..4ac1221643 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -39,6 +39,16 @@
**
****************************************************************************/
+#ifdef QT_NO_CAST_FROM_ASCII
+# undef QT_NO_CAST_FROM_ASCII
+#endif
+#ifdef QT_NO_CAST_TO_ASCII
+# undef QT_NO_CAST_TO_ASCII
+#endif
+#ifdef QT_ASCII_CAST_WARNINGS
+# undef QT_ASCII_CAST_WARNINGS
+#endif
+
#include <QtTest/QtTest>
#include <qregexp.h>
#include <qregularexpression.h>
@@ -623,7 +633,7 @@ void tst_QString::utf8_data()
QTest::newRow( "str0" ) << QByteArray("abcdefgh")
<< QString("abcdefgh");
QTest::newRow( "str1" ) << QByteArray("\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205")
- << QString("\366\344\374\326\304\334\370\346\345\330\306\305") ;
+ << QString::fromLatin1("\366\344\374\326\304\334\370\346\345\330\306\305") ;
str += QChar( 0x05e9 );
str += QChar( 0x05d3 );
str += QChar( 0x05d2 );
@@ -885,41 +895,11 @@ void tst_QString::constructorQByteArray()
void tst_QString::STL()
{
-#ifndef QT_NO_CAST_TO_ASCII
- QString qt( "QString" );
-
std::string stdstr( "QString" );
- QString stlqt;
-
- // constructor
- stlqt = QString( stdstr );
- QCOMPARE( stlqt, qt );
-
- // assignment
- stlqt = stdstr;
- QCOMPARE( stlqt, qt );
-
- std::string stdstr2 = stlqt;
- QCOMPARE( stdstr2, stdstr );
-
- // prepend
- stlqt = QString();
- stlqt.prepend( stdstr );
- QCOMPARE( stlqt, qt );
-
- // append
- stlqt = QString();
- stlqt.append( stdstr );
- QCOMPARE( stlqt, qt );
-
- // pathologics (null-strings not supported by many STLs, so test only empty strings)
- stdstr = std::string();
- stlqt = stdstr;
- QVERIFY( stlqt.isEmpty() );
- std::string stdstr3 = stlqt;
- QVERIFY( !stdstr3.length() );
-#endif
+ QString stlqt = QString::fromStdString(stdstr);
+ QCOMPARE(stlqt, QString::fromLatin1(stdstr.c_str()));
+ QCOMPARE(stlqt.toStdString(), stdstr);
const wchar_t arr[] = {'h', 'e', 'l', 'l', 'o', 0};
std::wstring stlStr = arr;
@@ -3297,7 +3277,7 @@ void tst_QString::check_QTextIOStream()
a="";
QTextStream ts(&a);
ts << "pi \261= " << 3.125;
- QCOMPARE(a,(QString)"pi \261= 3.125");
+ QCOMPARE(a, QString::fromLatin1("pi \261= 3.125"));
}
{
a="123 456";
@@ -3426,8 +3406,10 @@ void tst_QString::fromUtf8_data()
QTest::newRow("str0") << QByteArray("abcdefgh") << QString("abcdefgh") << -1;
QTest::newRow("str0-len") << QByteArray("abcdefgh") << QString("abc") << 3;
- QTest::newRow("str1") << QByteArray("\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205") << QString("\366\344\374\326\304\334\370\346\345\330\306\305") << -1;
- QTest::newRow("str1-len") << QByteArray("\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205") << QString("\366\344\374\326\304") << 10;
+ QTest::newRow("str1") << QByteArray("\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205")
+ << QString::fromLatin1("\366\344\374\326\304\334\370\346\345\330\306\305") << -1;
+ QTest::newRow("str1-len") << QByteArray("\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205")
+ << QString::fromLatin1("\366\344\374\326\304") << 10;
str += QChar(0x05e9);
str += QChar(0x05d3);
@@ -3474,9 +3456,9 @@ void tst_QString::fromUtf8_data()
QTest::newRow("null5") << QByteArray() << QString() << 5;
QTest::newRow("empty-1") << QByteArray("\0abcd", 5) << QString() << -1;
QTest::newRow("empty0") << QByteArray() << QString() << 0;
- QTest::newRow("empty5") << QByteArray("\0abcd", 5) << QString::fromAscii("\0abcd", 5) << 5;
- QTest::newRow("other-1") << QByteArray("ab\0cd", 5) << QString::fromAscii("ab") << -1;
- QTest::newRow("other5") << QByteArray("ab\0cd", 5) << QString::fromAscii("ab\0cd", 5) << 5;
+ QTest::newRow("empty5") << QByteArray("\0abcd", 5) << QString::fromLatin1("\0abcd", 5) << 5;
+ QTest::newRow("other-1") << QByteArray("ab\0cd", 5) << QString::fromLatin1("ab") << -1;
+ QTest::newRow("other5") << QByteArray("ab\0cd", 5) << QString::fromLatin1("ab\0cd", 5) << 5;
str = "Old Italic: ";
str += QChar(0xd800);
@@ -4390,13 +4372,13 @@ void tst_QString::localeAwareCompare_data()
below.
*/
#ifdef Q_OS_WIN // assume c locale to be english
- QTest::newRow("c1") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("\xe5") << QString("\xe4") << 1;
- QTest::newRow("c2") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("\xe4") << QString("\xf6") << -1;
- QTest::newRow("c3") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("\xe5") << QString("\xf6") << -1;
+ QTest::newRow("c1") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString::fromLatin1("\xe5") << QString::fromLatin1("\xe4") << 1;
+ QTest::newRow("c2") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1;
+ QTest::newRow("c3") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString::fromLatin1("\xe5") << QString::fromLatin1("\xf6") << -1;
#else
- QTest::newRow("c1") << QString("C") << QString("\xe5") << QString("\xe4") << 1;
- QTest::newRow("c2") << QString("C") << QString("\xe4") << QString("\xf6") << -1;
- QTest::newRow("c3") << QString("C") << QString("\xe5") << QString("\xf6") << -1;
+ QTest::newRow("c1") << QString("C") << QString::fromLatin1("\xe5") << QString::fromLatin1("\xe4") << 1;
+ QTest::newRow("c2") << QString("C") << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1;
+ QTest::newRow("c3") << QString("C") << QString::fromLatin1("\xe5") << QString::fromLatin1("\xf6") << -1;
#endif
/*
@@ -4422,20 +4404,20 @@ void tst_QString::localeAwareCompare_data()
all come after z.
*/
#ifdef Q_OS_MAC
- QTest::newRow("swedish1") << QString("sv_SE.ISO8859-1") << QString("\xe5") << QString("\xe4") << -1;
- QTest::newRow("swedish2") << QString("sv_SE.ISO8859-1") << QString("\xe4") << QString("\xf6") << -1;
- QTest::newRow("swedish3") << QString("sv_SE.ISO8859-1") << QString("\xe5") << QString("\xf6") << -1;
- QTest::newRow("swedish4") << QString("sv_SE.ISO8859-1") << QString("z") << QString("\xe5") << -1;
+ QTest::newRow("swedish1") << QString("sv_SE.ISO8859-1") << QString::fromLatin1("\xe5") << QString::fromLatin1("\xe4") << -1;
+ QTest::newRow("swedish2") << QString("sv_SE.ISO8859-1") << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1;
+ QTest::newRow("swedish3") << QString("sv_SE.ISO8859-1") << QString::fromLatin1("\xe5") << QString::fromLatin1("\xf6") << -1;
+ QTest::newRow("swedish4") << QString("sv_SE.ISO8859-1") << QString::fromLatin1("z") << QString::fromLatin1("\xe5") << -1;
#elif defined(Q_OS_WIN)
- QTest::newRow("swedish1") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString("\xe5") << QString("\xe4") << -1;
- QTest::newRow("swedish2") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString("\xe4") << QString("\xf6") << -1;
- QTest::newRow("swedish3") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString("\xe5") << QString("\xf6") << -1;
- QTest::newRow("swedish4") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString("z") << QString("\xe5") << -1;
+ QTest::newRow("swedish1") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString::fromLatin1("\xe5") << QString::fromLatin1("\xe4") << -1;
+ QTest::newRow("swedish2") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1;
+ QTest::newRow("swedish3") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString::fromLatin1("\xe5") << QString::fromLatin1("\xf6") << -1;
+ QTest::newRow("swedish4") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString::fromLatin1("z") << QString::fromLatin1("\xe5") << -1;
#else
- QTest::newRow("swedish1") << QString("sv_SE") << QString("\xe5") << QString("\xe4") << -1;
- QTest::newRow("swedish2") << QString("sv_SE") << QString("\xe4") << QString("\xf6") << -1;
- QTest::newRow("swedish3") << QString("sv_SE") << QString("\xe5") << QString("\xf6") << -1;
- QTest::newRow("swedish4") << QString("sv_SE") << QString("z") << QString("\xe5") << -1;
+ QTest::newRow("swedish1") << QString("sv_SE") << QString::fromLatin1("\xe5") << QString::fromLatin1("\xe4") << -1;
+ QTest::newRow("swedish2") << QString("sv_SE") << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1;
+ QTest::newRow("swedish3") << QString("sv_SE") << QString::fromLatin1("\xe5") << QString::fromLatin1("\xf6") << -1;
+ QTest::newRow("swedish4") << QString("sv_SE") << QString::fromLatin1("z") << QString::fromLatin1("\xe5") << -1;
#endif
#if 0
@@ -4443,9 +4425,9 @@ void tst_QString::localeAwareCompare_data()
In Norwegian, ae (E6) comes before o with stroke (D8), which
comes before a with ring above (E5).
*/
- QTest::newRow("norwegian1") << QString("no_NO") << QString("\xe6") << QString("\xd8") << -1;
- QTest::newRow("norwegian2") << QString("no_NO") << QString("\xd8") << QString("\xe5") << -1;
- QTest::newRow("norwegian3") << QString("no_NO") << QString("\xe6") << QString("\xe5") << -1;
+ QTest::newRow("norwegian1") << QString("no_NO") << QString::fromLatin1("\xe6") << QString::fromLatin1("\xd8") << -1;
+ QTest::newRow("norwegian2") << QString("no_NO") << QString::fromLatin1("\xd8") << QString::fromLatin1("\xe5") << -1;
+ QTest::newRow("norwegian3") << QString("no_NO") << QString::fromLatin1("\xe6") << QString::fromLatin1("\xe5") << -1;
#endif
/*
@@ -4453,17 +4435,17 @@ void tst_QString::localeAwareCompare_data()
which comes before o diaresis (F6).
*/
#ifdef Q_OS_MAC
- QTest::newRow("german1") << QString("de_DE.ISO8859-1") << QString("z") << QString("\xe4") << 1;
- QTest::newRow("german2") << QString("de_DE.ISO8859-1") << QString("\xe4") << QString("\xf6") << -1;
- QTest::newRow("german3") << QString("de_DE.ISO8859-1") << QString("z") << QString("\xf6") << 1;
+ QTest::newRow("german1") << QString("de_DE.ISO8859-1") << QString::fromLatin1("z") << QString::fromLatin1("\xe4") << 1;
+ QTest::newRow("german2") << QString("de_DE.ISO8859-1") << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1;
+ QTest::newRow("german3") << QString("de_DE.ISO8859-1") << QString::fromLatin1("z") << QString::fromLatin1("\xf6") << 1;
#elif defined(Q_OS_WIN)
- QTest::newRow("german1") << MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) << QString("z") << QString("\xe4") << 1;
- QTest::newRow("german2") << MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) << QString("\xe4") << QString("\xf6") << -1;
- QTest::newRow("german3") << MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) << QString("z") << QString("\xf6") << 1;
+ QTest::newRow("german1") << MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) << QString::fromLatin1("z") << QString::fromLatin1("\xe4") << 1;
+ QTest::newRow("german2") << MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1;
+ QTest::newRow("german3") << MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) << QString::fromLatin1("z") << QString::fromLatin1("\xf6") << 1;
#else
- QTest::newRow("german1") << QString("de_DE") << QString("z") << QString("\xe4") << 1;
- QTest::newRow("german2") << QString("de_DE") << QString("\xe4") << QString("\xf6") << -1;
- QTest::newRow("german3") << QString("de_DE") << QString("z") << QString("\xf6") << 1;
+ QTest::newRow("german1") << QString("de_DE") << QString::fromLatin1("z") << QString::fromLatin1("\xe4") << 1;
+ QTest::newRow("german2") << QString("de_DE") << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1;
+ QTest::newRow("german3") << QString("de_DE") << QString::fromLatin1("z") << QString::fromLatin1("\xf6") << 1;
#endif
}
diff --git a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp
index 556b9ac16a..d0f82a38b7 100644
--- a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp
+++ b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp
@@ -57,6 +57,11 @@
#define UNICODE_LITERAL_EXTRA u"s\u00f6m\u00eb l\u00eft\u00ebr\u00e4l" "EXTRA"
#endif
+#ifndef P
+# error You need to define P
+# define P +
+#endif
+
//fix for gcc4.0: if the operator+ does not exist without QT_USE_FAST_OPERATOR_PLUS
#ifndef QT_USE_FAST_CONCATENATION
#define Q %
@@ -68,7 +73,6 @@ void runScenario()
{
// this code is latin1. TODO: replace it with the utf8 block below, once
// strings default to utf8.
- QLatin1Literal l1literal(LITERAL);
QLatin1String l1string(LITERAL);
QString string(l1string);
QStringRef stringref(&string, 2, 10);
@@ -78,14 +82,10 @@ void runScenario()
QString r3 = QString::fromUtf8(UTF8_LITERAL UTF8_LITERAL);
QString r;
- r = l1literal Q l1literal;
- QCOMPARE(r, r2);
r = string P string;
QCOMPARE(r, r2);
r = stringref Q stringref;
QCOMPARE(r, QString(stringref.toString() + stringref.toString()));
- r = string Q l1literal;
- QCOMPARE(r, r2);
r = string P l1string;
QCOMPARE(r, r2);
r = string Q QStringLiteral(LITERAL);
diff --git a/tests/auto/corelib/tools/qtimeline/qtimeline.pro b/tests/auto/corelib/tools/qtimeline/qtimeline.pro
index cac8074038..3a6c120b5a 100644
--- a/tests/auto/corelib/tools/qtimeline/qtimeline.pro
+++ b/tests/auto/corelib/tools/qtimeline/qtimeline.pro
@@ -2,4 +2,3 @@ CONFIG += testcase parallel_test
TARGET = tst_qtimeline
QT = core testlib
SOURCES = tst_qtimeline.cpp
-win32:CONFIG+=insignificant_test # unstable, QTBUG-24796
diff --git a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
index f05497d7a2..b15de5c1df 100644
--- a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
+++ b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
@@ -184,9 +184,10 @@ void tst_QTimeLine::duration()
timeLine.start();
QTest::qWait(999);
QCOMPARE(timeLine.state(), QTimeLine::Running);
- QVERIFY(timeLine.currentTime() > 0.9);
- QTest::qWait(50);
+ QVERIFY(timeLine.currentTime() > 900);
+ QTest::qWait(100);
QCOMPARE(timeLine.state(), QTimeLine::NotRunning);
+ QCOMPARE(timeLine.currentTime(), 1000);
// The duration shouldn't change
QCOMPARE(timeLine.duration(), 1000);
}
@@ -368,6 +369,8 @@ void tst_QTimeLine::interpolation()
QCOMPARE(timeLine.state(), QTimeLine::Running);
// Smooth accellerates slowly so in the beginning so it is farther behind
+ if (firstValue >= timeLine.currentFrame())
+ QEXPECT_FAIL("", "QTBUG-24796: QTimeLine exhibits inconsistent timing behaviour", Abort);
QVERIFY(firstValue < timeLine.currentFrame());
QTest::qWait(200);
QVERIFY(endValue > timeLine.currentFrame());
@@ -456,24 +459,33 @@ void tst_QTimeLine::toggleDirection()
void tst_QTimeLine::frameChanged()
{
QTimeLine timeLine;
+ timeLine.setCurveShape(QTimeLine::LinearCurve);
timeLine.setFrameRange(0,9);
- timeLine.setUpdateInterval(1000);
+ timeLine.setUpdateInterval(800);
QSignalSpy spy(&timeLine, SIGNAL(frameChanged(int)));
QVERIFY(spy.isValid());
+
+ // Test what happens when duration expires before all frames are emitted.
timeLine.start();
- QTest::qWait(timeLine.duration()*2);
+ QTest::qWait(timeLine.duration()/2);
+ QCOMPARE(timeLine.state(), QTimeLine::Running);
+ QCOMPARE(spy.count(), 0);
+ QTest::qWait(timeLine.duration());
+ if (timeLine.state() != QTimeLine::NotRunning)
+ QEXPECT_FAIL("", "QTBUG-24796: QTimeLine runs slower than it should", Abort);
QCOMPARE(timeLine.state(), QTimeLine::NotRunning);
- // Probably 10
- QVERIFY(spy.count() <= 10 && spy.count() > 0);
+ if (spy.count() != 1)
+ QEXPECT_FAIL("", "QTBUG-24796: QTimeLine runs slower than it should", Abort);
+ QCOMPARE(spy.count(), 1);
+ // Test what happens when the frames are all emitted well before duration expires.
timeLine.setUpdateInterval(5);
spy.clear();
timeLine.setCurrentTime(0);
timeLine.start();
QTest::qWait(timeLine.duration()*2);
QCOMPARE(timeLine.state(), QTimeLine::NotRunning);
- // Probably 1
- QVERIFY(spy.count() <= 10 && spy.count() > 0);
+ QCOMPARE(spy.count(), 10);
}
void tst_QTimeLine::stopped()
diff --git a/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp b/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp
index 8a60bb1876..4442094541 100644
--- a/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp
+++ b/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp
@@ -1252,7 +1252,7 @@ void tst_QXmlStream::writeWithCodec() const
QVERIFY(codec);
writer.setCodec(codec);
- const char *latin2 = "hé hé";
+ const char *latin2 = "h\xe9 h\xe9";
const QString string = codec->toUnicode(latin2);