diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2011-01-17 09:35:23 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2011-01-17 09:35:23 (GMT) |
commit | 1e179f6c0279adefc20924731b6e8378a89131de (patch) | |
tree | 1ce899307c51f03a73c7093477e829ae4091da78 /tests/auto/mediaobject | |
parent | 6c52715202ad8fd3c3f4bb94207cb7627c12f995 (diff) | |
parent | 4631d297781b8ad4eba0735b7023265d4872c1cb (diff) | |
download | Qt-1e179f6c0279adefc20924731b6e8378a89131de.zip Qt-1e179f6c0279adefc20924731b6e8378a89131de.tar.gz Qt-1e179f6c0279adefc20924731b6e8378a89131de.tar.bz2 |
Merge remote branch 'origin/4.7' into qt-master-from-4.7
Conflicts:
examples/webkit/imageanalyzer/imageanalyzer.h
examples/webkit/imageanalyzer/mainwindow.h
mkspecs/unsupported/qws/linux-x86-openkode-g++/qplatformdefs.h
src/corelib/io/qfsfileengine_iterator_unix.cpp
src/corelib/io/qfsfileengine_iterator_win.cpp
src/corelib/kernel/qcoreapplication.cpp
src/network/access/qnetworkaccessdatabackend.cpp
src/plugins/bearer/connman/qconnmanservice_linux.cpp
src/plugins/platforms/openvglite/qwindowsurface_vglite.h
src/s60installs/bwins/QtCoreu.def
src/s60installs/eabi/QtCoreu.def
src/s60installs/s60installs.pro
tools/assistant/tools/assistant/helpviewer_qwv.h
tools/qdoc3/test/qt-html-templates.qdocconf
Diffstat (limited to 'tests/auto/mediaobject')
-rw-r--r-- | tests/auto/mediaobject/dummy/audiooutput.cpp | 2 | ||||
-rw-r--r-- | tests/auto/mediaobject/dummy/audiooutput.h | 2 | ||||
-rw-r--r-- | tests/auto/mediaobject/dummy/backend.cpp | 2 | ||||
-rw-r--r-- | tests/auto/mediaobject/dummy/backend.h | 2 | ||||
-rw-r--r-- | tests/auto/mediaobject/dummy/mediaobject.cpp | 2 | ||||
-rw-r--r-- | tests/auto/mediaobject/dummy/mediaobject.h | 2 | ||||
-rw-r--r-- | tests/auto/mediaobject/dummy/videowidget.cpp | 2 | ||||
-rw-r--r-- | tests/auto/mediaobject/dummy/videowidget.h | 2 | ||||
-rwxr-xr-x | tests/auto/mediaobject/mediaobject.pro | 2 | ||||
-rw-r--r-- | tests/auto/mediaobject/qtesthelper.h | 2 | ||||
-rw-r--r-- | tests/auto/mediaobject/tst_mediaobject.cpp | 195 |
11 files changed, 205 insertions, 10 deletions
diff --git a/tests/auto/mediaobject/dummy/audiooutput.cpp b/tests/auto/mediaobject/dummy/audiooutput.cpp index 879d583..2645e20 100644 --- a/tests/auto/mediaobject/dummy/audiooutput.cpp +++ b/tests/auto/mediaobject/dummy/audiooutput.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/tests/auto/mediaobject/dummy/audiooutput.h b/tests/auto/mediaobject/dummy/audiooutput.h index 0994946..4acdd8a 100644 --- a/tests/auto/mediaobject/dummy/audiooutput.h +++ b/tests/auto/mediaobject/dummy/audiooutput.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/tests/auto/mediaobject/dummy/backend.cpp b/tests/auto/mediaobject/dummy/backend.cpp index dc66b36..1db89cc 100644 --- a/tests/auto/mediaobject/dummy/backend.cpp +++ b/tests/auto/mediaobject/dummy/backend.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/tests/auto/mediaobject/dummy/backend.h b/tests/auto/mediaobject/dummy/backend.h index f3b11ba..40833ea 100644 --- a/tests/auto/mediaobject/dummy/backend.h +++ b/tests/auto/mediaobject/dummy/backend.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/tests/auto/mediaobject/dummy/mediaobject.cpp b/tests/auto/mediaobject/dummy/mediaobject.cpp index 1d7fc43..98ab94f 100644 --- a/tests/auto/mediaobject/dummy/mediaobject.cpp +++ b/tests/auto/mediaobject/dummy/mediaobject.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/tests/auto/mediaobject/dummy/mediaobject.h b/tests/auto/mediaobject/dummy/mediaobject.h index 8aee645..a20873b 100644 --- a/tests/auto/mediaobject/dummy/mediaobject.h +++ b/tests/auto/mediaobject/dummy/mediaobject.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/tests/auto/mediaobject/dummy/videowidget.cpp b/tests/auto/mediaobject/dummy/videowidget.cpp index cfff473..f46704a 100644 --- a/tests/auto/mediaobject/dummy/videowidget.cpp +++ b/tests/auto/mediaobject/dummy/videowidget.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/tests/auto/mediaobject/dummy/videowidget.h b/tests/auto/mediaobject/dummy/videowidget.h index 1f86854..615aa02 100644 --- a/tests/auto/mediaobject/dummy/videowidget.h +++ b/tests/auto/mediaobject/dummy/videowidget.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/tests/auto/mediaobject/mediaobject.pro b/tests/auto/mediaobject/mediaobject.pro index ea78e63..23ec56b 100755 --- a/tests/auto/mediaobject/mediaobject.pro +++ b/tests/auto/mediaobject/mediaobject.pro @@ -18,5 +18,7 @@ symbian:{ addFiles.files = media/test.sdp addFiles.path = media DEPLOYMENT += addFiles + LIBS += -lCommDb -lconnmon + TARGET.CAPABILITY += "NetworkServices" } diff --git a/tests/auto/mediaobject/qtesthelper.h b/tests/auto/mediaobject/qtesthelper.h index 39d5b91..9b1ea18 100644 --- a/tests/auto/mediaobject/qtesthelper.h +++ b/tests/auto/mediaobject/qtesthelper.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/tests/auto/mediaobject/tst_mediaobject.cpp b/tests/auto/mediaobject/tst_mediaobject.cpp index d2c6f0f..b29a6db 100644 --- a/tests/auto/mediaobject/tst_mediaobject.cpp +++ b/tests/auto/mediaobject/tst_mediaobject.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -101,6 +101,70 @@ const qint64 ALLOWED_TIME_FOR_SEEKING = 1000; // 1s const qint64 SEEKING_TOLERANCE = 0; #endif //Q_OS_WINCE +#ifdef Q_OS_SYMBIAN +#include <cdbcols.h> +#include <cdblen.h> +#include <commdb.h> +#include <rconnmon.h> + +const QString KDefaultIAP = QLatin1String("default"); +const QString KInvalidIAP = QLatin1String("invalid IAP"); + +class CConnectionObserver : public CBase, public MConnectionMonitorObserver +{ +public: + static CConnectionObserver* NewL() + { + CConnectionObserver* self = new (ELeave) CConnectionObserver(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + QString currentIAP() + { + return m_currentIAPName; + } + ~CConnectionObserver() + { + m_connMon.Close(); + } +private: + CConnectionObserver() + { + } + void ConstructL() + { + m_connMon.ConnectL(); + m_connMon.NotifyEventL(*this); + } + void EventL (const CConnMonEventBase &aConnEvent) + { + TInt event = aConnEvent.EventType(); + TUint connId = aConnEvent.ConnectionId(); + TRequestStatus status; + switch (event) { + case EConnMonCreateConnection: { + TBuf<KCommsDbSvrMaxColumnNameLength> iapName; + m_connMon.GetStringAttribute(connId, 0, KIAPName, iapName, status); + User::WaitForRequest(status); + m_currentIAPName = QString(reinterpret_cast<const QChar *>(iapName.Ptr()), iapName.Length()); + qDebug() << "A new connection created using: " << m_currentIAPName; + break; + } + default: + break; + } + } + +private: + RConnectionMonitor m_connMon; + QString m_currentIAPName; +}; + +#endif + + class tst_MediaObject : public QObject { Q_OBJECT @@ -140,6 +204,8 @@ class tst_MediaObject : public QObject void pauseToPlay(); void pauseToStop(); void playSDP(); + void playUrl_data(); + void playUrl(); void testPrefinishMark(); void testSeek(); @@ -161,6 +227,10 @@ class tst_MediaObject : public QObject Phonon::MediaObject *m_media; QSignalSpy *m_stateChangedSignalSpy; QString m_tmpFileName; +#ifdef Q_OS_SYMBIAN + CConnectionObserver *m_iapConnectionObserver; + QString getValidIAPL(); +#endif //Q_OS_SYMBIAN static void copyMediaFile(const QString &original, const QString &name, @@ -451,6 +521,10 @@ void tst_MediaObject::initTestCase() QCOMPARE(m_media->outputPaths().size(), 1); QCOMPARE(audioOutput->inputPaths().size(), 1); +#ifdef Q_OS_SYMBIAN + TRAP_IGNORE(m_iapConnectionObserver = CConnectionObserver::NewL()); +#endif //Q_OS_SYMBIAN + } void tst_MediaObject::checkForDefaults() @@ -586,6 +660,121 @@ void tst_MediaObject::playSDP() #endif } +/*! + Attempt to play from an RTSP link, and, on Symbian, to specify the IAP that + should be used to connect to the network. This test requires the unit under test + to have a default internet connection that will support streaming media, and ideally + one other internet connection that will also support streaming. + */ +void tst_MediaObject::playUrl_data() +{ + QTest::addColumn<QUrl>("url"); +#ifdef Q_OS_SYMBIAN + QTest::addColumn<QString>("iap"); +#endif //Q_OS_SYMBIAN + + QUrl rtspLink("rtsp://v1.cache8.c.youtube.com/CjgLENy73wIaLwnoDBCE7tF7fxMYESARFEIJbXYtZ29vZ2xlSARSB3Jlc3VsdHNgpbWqq7L7je5KDA==/0/0/0/video.3gp"); + QUrl httpLink("http://www.theflute.co.uk/media/BachCPE_SonataAmin_1.wma"); + +#ifdef Q_OS_SYMBIAN + QTest::newRow("default_IAP_rtsp") << rtspLink << KDefaultIAP; + QTest::newRow("invalid_IAP_rtsp") << rtspLink << KInvalidIAP; + //don't test HTTP link with invalid or default IAP as it will prompt the user + //Add tests with a valid IAP if we can get one from CommsDB + QString validIAP; + TRAPD(err, validIAP = getValidIAPL()); + if (KErrNone == err) { + QTest::newRow("valid_IAP_rtsp") << rtspLink << validIAP; + QTest::newRow("valid_IAP_http") << httpLink << validIAP; + } +#else + QTest::newRow("default_IAP_rtsp") << rtspLink; + QTest::newRow("invalid_IAP_rtsp") << rtspLink; +#endif //Q_OS_SYMBIAN +} + +#ifdef Q_OS_SYMBIAN +QString tst_MediaObject::getValidIAPL() +{ + CCommsDatabase* commsDb = CCommsDatabase::NewL(EDatabaseTypeIAP); + CleanupStack::PushL(commsDb); + commsDb->ShowHiddenRecords(); + CCommsDbTableView* view = commsDb->OpenTableLC(TPtrC(IAP)); + QString validIAP; + TBool found = EFalse; + TInt record = view->GotoFirstRecord(); + while (KErrNotFound != record) { + TBuf<KCommsDbSvrMaxColumnNameLength> iapName; + view->ReadTextL(TPtrC(COMMDB_NAME), iapName); + validIAP = QString::fromUtf16(iapName.Ptr(),iapName.Length()); + //We don't want the "Easy WLAN" IAP as it will try and prompt the user + if ("Easy WLAN" != validIAP) { + qDebug() << "playUrl_data() adding a valid IAP test: " << validIAP; + found = ETrue; + break; + } + record = view->GotoNextRecord(); + } + CleanupStack::PopAndDestroy(2); + if (!found) + User::Leave(KErrNotFound); + return validIAP; +} +#endif //Q_OS_SYMBIAN + +void tst_MediaObject::playUrl() +{ + QFETCH(QUrl, url); +#ifdef Q_OS_SYMBIAN + QFETCH(QString, iap); +#endif + MediaObject media(this); + + //Create a proper media path for video and audio + VideoWidget videoOutput; + Path path = createPath(&media, &videoOutput); + QVERIFY(path.isValid()); + AudioOutput audioOutput(Phonon::MusicCategory, this); + path = createPath(&media, &audioOutput); + QVERIFY(path.isValid()); + +#ifdef Q_OS_SYMBIAN + //The Symbian backend allows the IAP used for streaming connections to be specified + //by the application, using the "InternetAccessPointName" property. + if (KDefaultIAP != iap) + media.setProperty("InternetAccessPointName", iap); +#endif //Q_OS_SYMBIAN + media.setCurrentSource(Phonon::MediaSource(url)); + QVERIFY(media.state() != Phonon::ErrorState); + + //we use a long 30s timeout here as it can take a long time for the streaming source to + //be sucessfully prepared depending on the network. + if (media.state() != Phonon::StoppedState) + QTest::waitForSignal(&media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), 30000); + QCOMPARE(media.state(), Phonon::StoppedState); + + media.play(); + if (media.state() != Phonon::PlayingState) + QTest::waitForSignal(&media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), 15000); + QCOMPARE(media.state(), Phonon::PlayingState); + + //sleep and allow some of the stream to be played + QTest::qSleep(10000); + +#ifdef Q_OS_SYMBIAN + // Verify that the specified IAP is actually being used when we're not doing negative tests + if ((KDefaultIAP == iap || KInvalidIAP == iap) == false) { + if (m_iapConnectionObserver) + QCOMPARE(iap,m_iapConnectionObserver->currentIAP()); + } +#endif //Q_OS_SYMBIAN + + media.stop(); + if (media.state() != Phonon::StoppedState) + QTest::waitForSignal(&media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), 15000); + QCOMPARE(media.state(), Phonon::StoppedState); +} + void tst_MediaObject::testPrefinishMark() { const qint32 requestedPrefinishMarkTime = 2000; @@ -937,6 +1126,10 @@ void tst_MediaObject::cleanupTestCase() if (!m_tmpFileName.isNull()) { QVERIFY(QFile::remove(m_tmpFileName)); } +#ifdef Q_OS_SYMBIAN + if (m_iapConnectionObserver) + delete m_iapConnectionObserver; +#endif //Q_OS_SYMBIAN } void tst_MediaObject::_testOneSeek(qint64 seekTo) |