API unit tests from Maemo API test team.

A large number of tweaks and changes to original tests, and refactor
a lot of the mock backends to reduce duplication.

Changed viewfinder test case to use mock service and provider so
that it matches the image capture test case.

Reviewed-by: Jonas Rabbe
(cherry picked from commit e40bef5508a4165cec4a46b97115aed461027fa5)

Also licence header fix:
(cherry picked from commit e9ee9e8c48b45b97d62ee4a82e400fa9d8ea8107)

Change-Id: Ic59891d75563bb2e008a336eea859e8c44d8d831
Reviewed-on: http://codereview.qt.nokia.com/2078
Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com>
This commit is contained in:
Michael Goddard
2011-07-25 15:02:51 +10:00
committed by Qt by Nokia
parent 1e4dda9710
commit a6128410da
94 changed files with 8814 additions and 2396 deletions

View File

@@ -42,6 +42,10 @@
//TESTED_COMPONENT=src/multimedia
#include "tst_qmediaobject.h"
#include "qvideowidget.h"
#include "mockmediarecorderservice.h"
#include "mockmediaserviceprovider.h"
QT_USE_NAMESPACE
@@ -357,3 +361,44 @@ void tst_QMediaObject::availability()
QCOMPARE(object.isAvailable(), true);
QCOMPARE(object.availabilityError(), QtMultimediaKit::NoError);
}
void tst_QMediaObject::service()
{
// Create the mediaobject with service.
QtTestMetaDataService service;
QtTestMediaObject mediaObject1(&service);
// Get service and Compare if it equal to the service passed as an argument in mediaObject1.
QMediaService *service1 = mediaObject1.service();
QVERIFY(service1 != NULL);
QCOMPARE(service1,&service);
// Create the mediaobject with empty service and verify that service() returns NULL.
QtTestMediaObject mediaObject2;
QMediaService *service2 = mediaObject2.service();
QVERIFY(service2 == NULL);
}
void tst_QMediaObject::availabilityChangedSignal()
{
// The availabilityChangedSignal is implemented in QAudioCaptureSource. So using it to test the signal.
MockMediaRecorderService *mockAudioSourceService = new MockMediaRecorderService;
MockMediaServiceProvider *mockProvider = new MockMediaServiceProvider(mockAudioSourceService);
QAudioCaptureSource *audiosource = new QAudioCaptureSource(0, mockProvider);
QSignalSpy spy(audiosource, SIGNAL(availabilityChanged(bool)));
// Add the end points and verify if the availablity changed signal emitted with argument true.
QMetaObject::invokeMethod(mockAudioSourceService->mockAudioEndpointSelector, "addEndpoints");
QVERIFY(spy.count() == 1);
bool available = qvariant_cast<bool>(spy.at(0).at(0));
QVERIFY(available == true);
spy.clear();
// Remove all endpoints and verify if the signal is emitted with argument false.
QMetaObject::invokeMethod(mockAudioSourceService->mockAudioEndpointSelector, "removeEndpoints");
QVERIFY(spy.count() == 1);
available = qvariant_cast<bool>(spy.at(0).at(0));
QVERIFY(available == false);
}