diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-02-05 02:40:13 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-02-05 02:40:13 (GMT) |
commit | d97105a6c470ca3982fbc24dc469287fc2d89a84 (patch) | |
tree | 80091149b6f3d554de1668cfd9e915e7bc7c5fbc /tests/auto/declarative/qmlengine | |
parent | 5a75e1254044b69ae34ff26d190d1b4cd410b73f (diff) | |
download | Qt-d97105a6c470ca3982fbc24dc469287fc2d89a84.zip Qt-d97105a6c470ca3982fbc24dc469287fc2d89a84.tar.gz Qt-d97105a6c470ca3982fbc24dc469287fc2d89a84.tar.bz2 |
Update test to handle QmlNetworkAccessManagerFactory
Diffstat (limited to 'tests/auto/declarative/qmlengine')
-rw-r--r-- | tests/auto/declarative/qmlengine/tst_qmlengine.cpp | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/tests/auto/declarative/qmlengine/tst_qmlengine.cpp b/tests/auto/declarative/qmlengine/tst_qmlengine.cpp index 8794af9..1779c01 100644 --- a/tests/auto/declarative/qmlengine/tst_qmlengine.cpp +++ b/tests/auto/declarative/qmlengine/tst_qmlengine.cpp @@ -48,6 +48,7 @@ #include <QDesktopServices> #include <QDebug> #include <QmlComponent> +#include <QmlNetworkAccessManagerFactory> class tst_qmlengine : public QObject { @@ -74,6 +75,19 @@ void tst_qmlengine::rootContext() QVERIFY(engine.rootContext()->parentContext() == 0); } +class NetworkAccessManagerFactory : public QmlNetworkAccessManagerFactory +{ +public: + NetworkAccessManagerFactory() : manager(0) {} + + QNetworkAccessManager *create(QObject *parent) { + manager = new QNetworkAccessManager(parent); + return manager; + } + + QNetworkAccessManager *manager; +}; + void tst_qmlengine::networkAccessManager() { QmlEngine *engine = new QmlEngine; @@ -81,25 +95,14 @@ void tst_qmlengine::networkAccessManager() // Test QmlEngine created manager QPointer<QNetworkAccessManager> manager = engine->networkAccessManager(); QVERIFY(manager != 0); - - // Test non-QmlEngine owner manager - QNetworkAccessManager localManager; - engine->setNetworkAccessManager(&localManager); - QVERIFY(manager == 0); - QVERIFY(engine->networkAccessManager() == &localManager); - - // Test QmlEngine owned manager - QPointer<QNetworkAccessManager> ownedManager = new QNetworkAccessManager(engine); - QVERIFY(ownedManager != 0); - engine->setNetworkAccessManager(ownedManager); - QVERIFY(engine->networkAccessManager() == ownedManager); - engine->setNetworkAccessManager(&localManager); - QVERIFY(ownedManager == 0); - QVERIFY(engine->networkAccessManager() == &localManager); - - // Test setting a null manager - engine->setNetworkAccessManager(0); - QVERIFY(engine->networkAccessManager() != 0); + delete engine; + + // Test factory created manager + engine = new QmlEngine; + NetworkAccessManagerFactory factory; + engine->setNetworkAccessManagerFactory(&factory); + QVERIFY(engine->networkAccessManager() == factory.manager); + delete engine; } void tst_qmlengine::baseUrl() |