- qDebug() << "validity:" << m->isValid();
- if (m->isValid()) {
- m->requestServiceCenterAddress();
- QTest::qWait(2000);
- if (m_sca.length() == 0)
- return;
- qDebug() << "setServiceCenterAddress(+123456)";
- m->setServiceCenterAddress("+123456");
- QTest::qWait(1000);
- qDebug() << "setServiceCenterAddress(original)";
- m->setServiceCenterAddress(m_sca);
- }
- QTest::qWait(1000);
+ QSignalSpy scaComplete(m, SIGNAL(serviceCenterAddressComplete(bool, QString)));
+ m->requestServiceCenterAddress();
+ for (int i=0; i<30; i++) {
+ if (scaComplete.count() > 0)
+ break;
+ QTest::qWait(1000);
+ }
+ QCOMPARE(scaComplete.count(), 1);
+ QVariantList params = scaComplete.takeFirst();
+ QCOMPARE(params.at(0).toBool(), true);
+ QString sca = params.at(1).toString();
+ QVERIFY(sca.length() > 0);
+ qDebug() << sca;
+
+ QSignalSpy setScaFailed(m, SIGNAL(setServiceCenterAddressFailed()));
+ QSignalSpy scaChanged(m, SIGNAL(serviceCenterAddressChanged(QString)));
+
+ m->setServiceCenterAddress("+12345678");
+ for (int i=0; i<30; i++) {
+ if (setScaFailed.count() > 0 || scaChanged.count() > 0)
+ break;
+ QTest::qWait(1000);
+ }
+ QCOMPARE(setScaFailed.count(), 0);
+ QCOMPARE(scaChanged.count(), 1);
+ QCOMPARE(scaChanged.takeFirst().at(0).toString(), QString("+12345678"));
+
+ m->setServiceCenterAddress("");
+ for (int i=0; i<30; i++) {
+ if (setScaFailed.count() > 0 || scaChanged.count() > 0)
+ break;
+ QTest::qWait(1000);
+ }
+ QCOMPARE(setScaFailed.count(), 1);
+ setScaFailed.takeFirst();
+ QCOMPARE(scaChanged.count(), 0);
+ QCOMPARE(m->errorName(), QString("org.ofono.Error.InvalidFormat"));
+ QCOMPARE(m->errorMessage(), QString("Argument format is not recognized"));
+
+ m->setServiceCenterAddress(sca);
+ for (int i=0; i<30; i++) {
+ if (setScaFailed.count() > 0 || scaChanged.count() > 0)
+ break;
+ QTest::qWait(1000);
+ }
+ QCOMPARE(setScaFailed.count(), 0);
+ QCOMPARE(scaChanged.count(), 1);
+ QCOMPARE(scaChanged.takeFirst().at(0).toString(), sca);