From 75e9dc39dda515847961a04d402754d93d0b3326 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 31 Mar 2010 12:30:33 +1000 Subject: Test openUrlExternally --- .../qdeclarativeqt/data/openUrlExternally.qml | 5 +++++ .../qdeclarativeqt/tst_qdeclarativeqt.cpp | 26 ++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativeqt/data/openUrlExternally.qml diff --git a/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally.qml b/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally.qml new file mode 100644 index 0000000..70bd74d --- /dev/null +++ b/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +QtObject { + Component.onCompleted: Qt.openUrlExternally("test:url") +} diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp index 4987557..48d5235 100644 --- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp +++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -261,10 +262,31 @@ void tst_qdeclarativeqt::tint() delete object; } +class MyUrlHandler : public QObject +{ + Q_OBJECT +public: + MyUrlHandler() : called(0) { } + int called; + QUrl last; + +public slots: + void noteCall(const QUrl &url) { called++; last = url; } +}; + void tst_qdeclarativeqt::openUrlExternally() { - QEXPECT_FAIL("", "How do we test this?", Abort); - QVERIFY(false); + MyUrlHandler handler; + + QDesktopServices::setUrlHandler("test", &handler, "noteCall"); + + QDeclarativeComponent component(&engine, TEST_FILE("openUrlExternally.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(handler.called,1); + QCOMPARE(handler.last, QUrl("test:url")); + + QDesktopServices::unsetUrlHandler("test"); } void tst_qdeclarativeqt::md5() -- cgit v0.12