summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp20
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp17
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp15
3 files changed, 43 insertions, 9 deletions
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index a74d817b8a..3bff330db2 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -262,9 +262,16 @@ void tst_QUrl::hashInPath()
QCOMPARE(withHashInPath.path(), QString::fromLatin1("hi#mum.txt"));
QCOMPARE(withHashInPath.toEncoded(), QByteArray("hi%23mum.txt"));
QCOMPARE(withHashInPath.toString(), QString("hi%23mum.txt"));
+ QCOMPARE(withHashInPath.toDisplayString(QUrl::PreferLocalFile), QString("hi%23mum.txt"));
QUrl fromHashInPath = QUrl::fromEncoded(withHashInPath.toEncoded());
QVERIFY(withHashInPath == fromHashInPath);
+
+ const QUrl localWithHash = QUrl::fromLocalFile("/hi#mum.txt");
+ QCOMPARE(localWithHash.path(), QString::fromLatin1("/hi#mum.txt"));
+ QCOMPARE(localWithHash.toEncoded(), QByteArray("file:///hi%23mum.txt"));
+ QCOMPARE(localWithHash.toString(), QString("file:///hi%23mum.txt"));
+ QCOMPARE(localWithHash.toDisplayString(QUrl::PreferLocalFile), QString("/hi#mum.txt"));
}
void tst_QUrl::unc()
@@ -352,6 +359,7 @@ void tst_QUrl::setUrl()
QCOMPARE(url.port(), -1);
QCOMPARE(url.toString(), QString::fromLatin1("file:///"));
QCOMPARE(url.toDisplayString(), QString::fromLatin1("file:///"));
+ QCOMPARE(url.toDisplayString(QUrl::PreferLocalFile), QString::fromLatin1("/"));
}
{
@@ -367,6 +375,7 @@ void tst_QUrl::setUrl()
QCOMPARE(url.port(), 80);
QCOMPARE(url.toString(), QString::fromLatin1("http://www.foo.bar:80"));
QCOMPARE(url.toDisplayString(), QString::fromLatin1("http://www.foo.bar:80"));
+ QCOMPARE(url.toDisplayString(QUrl::PreferLocalFile), QString::fromLatin1("http://www.foo.bar:80"));
QUrl url2("//www1.foo.bar");
QCOMPARE(url.resolved(url2).toString(), QString::fromLatin1("http://www1.foo.bar"));
@@ -451,15 +460,7 @@ void tst_QUrl::setUrl()
QUrl url = u1;
QVERIFY(url.isValid());
QCOMPARE(url.toString(), QString::fromLatin1("file:///home/dfaure/my#myref"));
- QCOMPARE(url.fragment(), QString::fromLatin1("myref"));
- }
-
- {
- QString u1 = "file:/home/dfaure/my#myref";
- QUrl url = u1;
- QVERIFY(url.isValid());
-
- QCOMPARE(url.toString(), QString::fromLatin1("file:///home/dfaure/my#myref"));
+ QCOMPARE(url.toString(QUrl::PreferLocalFile), QString::fromLatin1("file:///home/dfaure/my#myref"));
QCOMPARE(url.fragment(), QString::fromLatin1("myref"));
}
@@ -1001,6 +1002,7 @@ void tst_QUrl::toLocalFile()
QUrl url(theUrl);
QCOMPARE(url.toLocalFile(), theFile);
+ QCOMPARE(url.isLocalFile(), !theFile.isEmpty());
}
void tst_QUrl::fromLocalFile_data()
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
index f8403f11a1..572ecc9ba8 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
@@ -100,12 +100,29 @@ private slots:
struct Foo { int i; };
+
+class CustomQObject : public QObject
+{
+ Q_OBJECT
+public:
+ CustomQObject(QObject *parent = 0)
+ : QObject(parent)
+ {
+ }
+};
+
+class CustomNonQObject {};
+
void tst_QMetaType::defined()
{
QCOMPARE(int(QMetaTypeId2<QString>::Defined), 1);
QCOMPARE(int(QMetaTypeId2<Foo>::Defined), 0);
QCOMPARE(int(QMetaTypeId2<void*>::Defined), 1);
QCOMPARE(int(QMetaTypeId2<int*>::Defined), 0);
+ QVERIFY(QMetaTypeId2<CustomQObject*>::Defined);
+ QVERIFY(!QMetaTypeId2<CustomQObject>::Defined);
+ QVERIFY(!QMetaTypeId2<CustomNonQObject>::Defined);
+ QVERIFY(!QMetaTypeId2<CustomNonQObject*>::Defined);
}
struct Bar
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index ccdab17668..5aa1389b65 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -2541,9 +2541,24 @@ public:
};
Q_DECLARE_METATYPE(CustomQObjectDerived*)
+class CustomQObjectDerivedNoMetaType : public CustomQObject {
+ Q_OBJECT
+public:
+ CustomQObjectDerivedNoMetaType(QObject *parent = 0) : CustomQObject(parent) {}
+};
+
void tst_QVariant::qvariant_cast_QObject_derived()
{
{
+ CustomQObjectDerivedNoMetaType *object = new CustomQObjectDerivedNoMetaType(this);
+ QVariant data = QVariant::fromValue(object);
+ QVERIFY(data.userType() == qMetaTypeId<CustomQObjectDerivedNoMetaType*>());
+ QCOMPARE(data.value<QObject *>(), object);
+ QCOMPARE(data.value<CustomQObjectDerivedNoMetaType *>(), object);
+ QCOMPARE(data.value<CustomQObject *>(), object);
+ QVERIFY(data.value<CustomQWidget*>() == 0);
+ }
+ {
CustomQObjectDerived *object = new CustomQObjectDerived(this);
QVariant data = QVariant::fromValue(object);