summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-06-26 08:31:19 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2009-06-26 08:31:19 (GMT)
commitb914c388a809c17e4f76a4dcc1d3a1006e13c115 (patch)
treeef6723688578c7ff13fed8b4ea0c961aaf98fe09 /tests
parent7278c142089d46946d1ad2558eae949220dfe0c4 (diff)
parentd553f376a34ea1d27492a1a5fd14f79616f6a27c (diff)
downloadQt-b914c388a809c17e4f76a4dcc1d3a1006e13c115.zip
Qt-b914c388a809c17e4f76a4dcc1d3a1006e13c115.tar.gz
Qt-b914c388a809c17e4f76a4dcc1d3a1006e13c115.tar.bz2
Merge branch '4.5'
Conflicts: src/3rdparty/webkit/VERSION src/3rdparty/webkit/WebCore/ChangeLog src/network/access/qnetworkreplyimpl.cpp
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/auto.pro1
-rw-r--r--tests/auto/qmetaobject/tst_qmetaobject.cpp22
-rw-r--r--tests/auto/qnetworkaccessmanager_and_qprogressdialog/qnetworkaccessmanager_and_qprogressdialog.pro5
-rw-r--r--tests/auto/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.cpp130
4 files changed, 158 insertions, 0 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index a8b1059..9b62116 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -216,6 +216,7 @@ SUBDIRS += _networkselftest \
qnetworkproxy \
qnetworkrequest \
qnetworkreply \
+ qnetworkaccessmanager_and_qprogressdialog \
qnumeric \
qobject \
qobjectrace \
diff --git a/tests/auto/qmetaobject/tst_qmetaobject.cpp b/tests/auto/qmetaobject/tst_qmetaobject.cpp
index 95d19e2..dea0ffb 100644
--- a/tests/auto/qmetaobject/tst_qmetaobject.cpp
+++ b/tests/auto/qmetaobject/tst_qmetaobject.cpp
@@ -605,6 +605,19 @@ void tst_QMetaObject::invokeCustomTypes()
QCOMPARE(obj.sum, 3);
}
+namespace NamespaceWithConstructibleClass
+{
+
+class ConstructibleClass : public QObject
+{
+ Q_OBJECT
+public:
+ Q_INVOKABLE ConstructibleClass(QObject *parent = 0)
+ : QObject(parent) {}
+};
+
+}
+
void tst_QMetaObject::invokeMetaConstructor()
{
const QMetaObject *mo = &QtTestObject::staticMetaObject;
@@ -619,6 +632,15 @@ void tst_QMetaObject::invokeMetaConstructor()
QCOMPARE(obj2->parent(), (QObject*)&obj);
QVERIFY(qobject_cast<QtTestObject*>(obj2) != 0);
}
+ // class in namespace
+ const QMetaObject *nsmo = &NamespaceWithConstructibleClass::ConstructibleClass::staticMetaObject;
+ {
+ QtTestObject obj;
+ QObject *obj2 = nsmo->newInstance(Q_ARG(QObject*, &obj));
+ QVERIFY(obj2 != 0);
+ QCOMPARE(obj2->parent(), (QObject*)&obj);
+ QVERIFY(qobject_cast<NamespaceWithConstructibleClass::ConstructibleClass*>(obj2) != 0);
+ }
}
void tst_QMetaObject::normalizedSignature_data()
diff --git a/tests/auto/qnetworkaccessmanager_and_qprogressdialog/qnetworkaccessmanager_and_qprogressdialog.pro b/tests/auto/qnetworkaccessmanager_and_qprogressdialog/qnetworkaccessmanager_and_qprogressdialog.pro
new file mode 100644
index 0000000..7ed5b07
--- /dev/null
+++ b/tests/auto/qnetworkaccessmanager_and_qprogressdialog/qnetworkaccessmanager_and_qprogressdialog.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+SOURCES += tst_qnetworkaccessmanager_and_qprogressdialog.cpp
+QT += network
+
+
diff --git a/tests/auto/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.cpp b/tests/auto/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.cpp
new file mode 100644
index 0000000..62e4ce5
--- /dev/null
+++ b/tests/auto/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.cpp
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <QtGui>
+#include <QtCore>
+#include <QtNetwork/QNetworkAccessManager>
+#include <QtNetwork/QNetworkRequest>
+#include <QtNetwork/QNetworkReply>
+#include <qdebug.h>
+
+#include "../network-settings.h"
+
+
+class tst_QNetworkAccessManager_And_QProgressDialog : public QObject
+{
+Q_OBJECT
+private slots:
+ void downloadCheck();
+};
+
+class DownloadCheckWidget : public QWidget
+{
+ Q_OBJECT;
+public:
+ DownloadCheckWidget(QWidget *parent = 0) : QWidget(parent)
+ , progressDlg(this), netmanager(this)
+ , lateReadyRead(true)
+ {
+ progressDlg.setRange(1, 100);
+ QMetaObject::invokeMethod(this, "go", Qt::QueuedConnection);
+ }
+ bool lateReadyRead;
+public slots:
+ void go()
+ {
+ QNetworkReply *reply = netmanager.get(
+ QNetworkRequest(
+ QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/bigfile")
+ ));
+ connect(reply, SIGNAL(downloadProgress(qint64, qint64)),
+ this, SLOT(dataReadProgress(qint64, qint64)));
+ connect(reply, SIGNAL(readyRead()),
+ this, SLOT(dataReadyRead()));
+ connect(reply, SIGNAL(finished()), this, SLOT(finishedFromReply()));
+
+ progressDlg.exec();
+ }
+ void dataReadProgress(qint64 done, qint64 total)
+ {
+ QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
+ progressDlg.setMaximum(total);
+ progressDlg.setValue(done);
+ }
+ void dataReadyRead()
+ {
+ QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
+ lateReadyRead = true;
+ }
+ void finishedFromReply()
+ {
+ QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
+ lateReadyRead = false;
+ reply->deleteLater();
+ QTestEventLoop::instance().exitLoop();
+ }
+
+
+private:
+ QProgressDialog progressDlg;
+ QNetworkAccessManager netmanager;
+};
+
+void tst_QNetworkAccessManager_And_QProgressDialog::downloadCheck()
+{
+ DownloadCheckWidget widget;
+ widget.show();
+ // run and exit on finished()
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ // run some more to catch the late readyRead() (or: to not catch it)
+ QTestEventLoop::instance().enterLoop(1);
+ QVERIFY(QTestEventLoop::instance().timeout());
+ // the following fails when a readyRead() was received after finished()
+ QVERIFY(!widget.lateReadyRead);
+}
+
+
+
+QTEST_MAIN(tst_QNetworkAccessManager_And_QProgressDialog)
+#include "tst_qnetworkaccessmanager_and_qprogressdialog.moc"