void tst_QBluetoothLocalDevice::tst_pairDevice()
{
    QFETCH(QBluetoothAddress, deviceAddress);
    QFETCH(QBluetoothLocalDevice::Pairing, pairingExpected);

    QBluetoothLocalDevice localDevice;
    //powerOn if not already
    localDevice.powerOn();

    QSignalSpy pairingSpy(&localDevice, SIGNAL(pairingFinished(const QBluetoothAddress &,QBluetoothLocalDevice::Pairing)) );
    // there should be no signals yet
    QVERIFY(pairingSpy.isEmpty());

    localDevice.requestPairing(deviceAddress, pairingExpected);
    // async, wait for it
    WAIT_FOR_CONDITION(pairingSpy.count(),1);
    QVERIFY(pairingSpy.count() > 0);

    // test the actual signal values.
    QList<QVariant> arguments = pairingSpy.takeFirst();
    QBluetoothAddress address = qvariant_cast<QBluetoothAddress>(arguments.at(0));
    QBluetoothLocalDevice::Pairing pairingResult = qvariant_cast<QBluetoothLocalDevice::Pairing>(arguments.at(1));
    QCOMPARE(deviceAddress, address);
    QCOMPARE(pairingExpected, pairingResult);

    QCOMPARE(pairingExpected, localDevice.pairingStatus(deviceAddress));

}
void tst_QBluetoothLocalDevice::tst_hostModes()
{
    QFETCH(QBluetoothLocalDevice::HostMode, hostModeExpected);

    QBluetoothLocalDevice localDevice;
    QSignalSpy hostModeSpy(&localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)));
    // there should be no changes yet
    QVERIFY(hostModeSpy.isEmpty());

    QTest::qWait(1000);

    localDevice.setHostMode(hostModeExpected);
    // wait for the device to switch bluetooth mode.
    QTest::qWait(1000);
    if (hostModeExpected != localDevice.hostMode()) {
        WAIT_FOR_CONDITION(hostModeSpy.count(),1);
        QVERIFY(hostModeSpy.count() > 0);
    }
    // test the actual signal values.
    QList<QVariant> arguments = hostModeSpy.takeFirst();
    QBluetoothLocalDevice::HostMode hostMode = qvariant_cast<QBluetoothLocalDevice::HostMode>(arguments.at(0));
    QCOMPARE(hostModeExpected, hostMode);
    // test actual
    QCOMPARE(hostModeExpected, localDevice.hostMode());
}
Пример #3
0
void tst_QMetadata_xa::testMetadata()
{
    QFETCH_GLOBAL(QMediaContent, mediaContent);
    QFETCH_GLOBAL(int, count);
    QFETCH_GLOBAL(QtMultimediaKit::MetaData, key);
    QFETCH_GLOBAL(QString, strValue);
    QFETCH_GLOBAL(qint64, intValue);

    QSignalSpy spy(m_player, SIGNAL(metaDataAvailableChanged(bool)));
    m_player->setMedia(mediaContent);

    WAIT_FOR_CONDITION(spy.count(), 1);
    //get metadata count
    QList<QtMultimediaKit::MetaData> mdList = m_player->availableMetaData ();
    QStringList amdList = m_player->availableExtendedMetaData();

    int numMetadataItems = mdList.size() + amdList.size();
    if (count>=0) //-1 indicate ignore count
        QVERIFY(count==numMetadataItems);

    if (numMetadataItems>0 && !strValue.isEmpty()) {
        QVariant val = m_player->metaData(key);

        if(key == QtMultimediaKit::CoverArtImage)
            val.value<QImage>().save(strValue);
        else
            QVERIFY(strValue == val.toString());
    }
}
void tst_QBluetoothLocalDevice::tst_powerOn()
{
    {
    QBluetoothLocalDevice localDevice;

    QSignalSpy hostModeSpy(&localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)));
    // there should be no changes yet
    QVERIFY(hostModeSpy.isEmpty());

    localDevice.powerOn();
    // async, wait for it
    WAIT_FOR_CONDITION(hostModeSpy.count(),1);
    QVERIFY(hostModeSpy.count() > 0);
    QBluetoothLocalDevice::HostMode hostMode= localDevice.hostMode();
    // we should not be powered off
    QVERIFY(hostMode == QBluetoothLocalDevice::HostConnectable
         || hostMode == QBluetoothLocalDevice::HostDiscoverable);
    }

}
void tst_QBluetoothLocalDevice::tst_powerOff()
{
    {
        QBluetoothLocalDevice *device = new QBluetoothLocalDevice();
        device->powerOn();
        delete device;
        // wait for the device to switch bluetooth mode.
        QTest::qWait(1000);
    }
    QBluetoothLocalDevice localDevice;
    QSignalSpy hostModeSpy(&localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)));
    // there should be no changes yet
    QVERIFY(hostModeSpy.isEmpty());

    localDevice.setHostMode(QBluetoothLocalDevice::HostPoweredOff);
    // async, wait for it
    WAIT_FOR_CONDITION(hostModeSpy.count(),1);
    QVERIFY(hostModeSpy.count() > 0);
    // we should not be powered off
    QVERIFY(localDevice.hostMode() == QBluetoothLocalDevice::HostPoweredOff);

}