2 * This file is part of ofono-qt
4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
6 * Contact: Alexander Kanavin <alexander.kanavin@nokia.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * version 2.1 as published by the Free Software Foundation.
12 * This library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24 #include <QtTest/QtTest>
25 #include <QtCore/QObject>
27 #include <ofonomessagemanager.h>
32 class TestOfonoMessageManager : public QObject
40 m = new OfonoMessageManager(OfonoModem::ManualSelect, "/phonesim", this);
41 QCOMPARE(m->modem()->isValid(), true);
43 if (!m->modem()->powered()) {
44 m->modem()->setPowered(true);
47 if (!m->modem()->online()) {
48 m->modem()->setOnline(true);
51 QCOMPARE(m->isValid(), true);
54 void testOfonoMessageManagerSca()
56 QSignalSpy scaComplete(m, SIGNAL(serviceCenterAddressComplete(bool, QString)));
57 m->requestServiceCenterAddress();
58 for (int i=0; i<30; i++) {
59 if (scaComplete.count() > 0)
63 QCOMPARE(scaComplete.count(), 1);
64 QVariantList params = scaComplete.takeFirst();
65 QCOMPARE(params.at(0).toBool(), true);
66 QString sca = params.at(1).toString();
67 QVERIFY(sca.length() > 0);
70 QSignalSpy setScaFailed(m, SIGNAL(setServiceCenterAddressFailed()));
71 QSignalSpy scaChanged(m, SIGNAL(serviceCenterAddressChanged(QString)));
73 m->setServiceCenterAddress("+12345678");
74 for (int i=0; i<30; i++) {
75 if (setScaFailed.count() > 0 || scaChanged.count() > 0)
79 QCOMPARE(setScaFailed.count(), 0);
80 QCOMPARE(scaChanged.count(), 1);
81 QCOMPARE(scaChanged.takeFirst().at(0).toString(), QString("+12345678"));
83 m->setServiceCenterAddress("");
84 for (int i=0; i<30; i++) {
85 if (setScaFailed.count() > 0 || scaChanged.count() > 0)
89 QCOMPARE(setScaFailed.count(), 1);
90 setScaFailed.takeFirst();
91 QCOMPARE(scaChanged.count(), 0);
92 QCOMPARE(m->errorName(), QString("org.ofono.Error.InvalidFormat"));
93 QCOMPARE(m->errorMessage(), QString("Argument format is not recognized"));
95 m->setServiceCenterAddress(sca);
96 for (int i=0; i<30; i++) {
97 if (setScaFailed.count() > 0 || scaChanged.count() > 0)
101 QCOMPARE(setScaFailed.count(), 0);
102 QCOMPARE(scaChanged.count(), 1);
103 QCOMPARE(scaChanged.takeFirst().at(0).toString(), sca);
107 void cleanupTestCase()
114 OfonoMessageManager *m;
117 QTEST_MAIN(TestOfonoMessageManager)
118 #include "test_ofonomessagemanager.moc"