Beispiel #1
0
void Tst_qofonoTest::testContextConnection()
{
    QOfonoManager manager;
    QOfonoModem modem;
    QStringList modems = manager.modems();

    modem.setModemPath(manager.modems()[0]);
    qDebug() << Q_FUNC_INFO << manager.modems()[0] << modem.online();

    if (!modem.online()) {
        QSignalSpy spy_bogusContext(&modem, SIGNAL(onlineChanged(bool)));
        modem.setOnline(true);
        ::waitForSignal(&modem,SIGNAL(onlineChanged(bool)),3000);
        QCOMPARE(spy_bogusContext.count(),1);
    }
Beispiel #2
0
void Tst_qofonoTest::testConnectionManager()
{
    QOfonoManager manager;
    QOfonoConnectionManager connman;
    QOfonoModem modem;
    modem.setModemPath(manager.modems()[0]);

    if (!modem.online()) {
        modem.setOnline(true);
    }
    QVERIFY(modem.online());

    connman.setModemPath(manager.modems()[0]);
    QVERIFY(!connman.modemPath().isEmpty());

    QSignalSpy spy(&connman, SIGNAL(contextAdded(QString)));
    connman.addContext("internet");
    ::waitForSignal(&connman,SIGNAL(contextAdded(QString)),1000);
    QCOMPARE(spy.count(),1);

//    QList<QVariant> arguments ;
//    arguments = spy.takeFirst();

    // attached

    // bearer
    // suspended
    // roamingAllowed
//    QSignalSpy spy_roaming(&connman, SIGNAL(roamingAllowedChanged(bool)));
//    bool expected = !connman.roamingAllowed();
//    connman.setRoamingAllowed(expected);
//    QTest::qWait(3000);
//    QCOMPARE(spy_roaming.count(),1);
//    QList<QVariant> argumentsspy_roaming;
//    argumentsspy_roaming = spy_roaming.takeFirst();
//    QCOMPARE(argumentsspy_roaming[0].toBool(), expected);

//    connman.setRoamingAllowed(false);
//    QTest::qWait(3000);
//    QCOMPARE(spy_roaming.count(),1);
//    QList<QVariant> argumentsspy_roaming2;
//    argumentsspy_roaming2 = spy_roaming.takeFirst();
//    if (manager.modems()[0].contains("phonesim"))
//        QEXPECT_FAIL("","seems to nt work on phonesim",Continue);
//    QCOMPARE(argumentsspy_roaming[0].toBool(), false);

//    // powered

//    QSignalSpy spy_powered(&connman, SIGNAL(poweredChanged(bool)));
//    QList<QVariant> argumentsspy_powered;
    //  bool isPowered = connman.powered();

//    qDebug() << Q_FUNC_INFO << "modem powered" << connman.powered();

//    connman.setPowered(!isPowered);
//    QTest::qWait(3000);
//    QCOMPARE(spy_powered.count(),2); //powers itself back on
//    argumentsspy_powered = spy_powered.takeFirst();
//    QCOMPARE(argumentsspy_powered[0].toBool(), !isPowered);

//    if(!connman.powered()) {
//        connman.setPowered(true);
//        QTest::qWait(3000);
//        QVERIFY(connman.powered());
//    }

    //TODO other signals
}