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 <ofonomodeminterface.h>
31 class TestOfonoModemInterface : public QObject
39 mi = new OfonoModemInterface(OfonoModem::ManualSelect, "/phonesim", "org.ofono.NetworkRegistration", OfonoGetAllOnStartup, this);
40 QCOMPARE(mi->modem()->isValid(), true);
42 if (!mi->modem()->powered()) {
43 mi->modem()->setPowered(true);
46 if (!mi->modem()->online()) {
47 mi->modem()->setOnline(true);
53 void testOfonoModemInterfaceOnlineOfflineModem()
55 QSignalSpy validity(mi, SIGNAL(validityChanged(bool)));
56 QCOMPARE(mi->isValid(), true);
58 mi->modem()->setOnline(false);
60 QCOMPARE(validity.count(), 1);
61 QCOMPARE(validity.takeFirst().at(0).toBool(), false);
63 mi->modem()->setOnline(true);
65 QCOMPARE(validity.count(), 1);
66 QCOMPARE(validity.takeFirst().at(0).toBool(), true);
69 void testOfonoModemInterfaceAddRemoveModem()
71 QSignalSpy validity(mi, SIGNAL(validityChanged(bool)));
72 qDebug() << "Please stop oFono and then start it again";
74 for (int i=0; i<30; i++) {
75 if (validity.count() > 0)
79 QCOMPARE(validity.count(), 1);
80 QCOMPARE(validity.takeFirst().at(0).toBool(), false);
83 mi = new OfonoModemInterface(OfonoModem::ManualSelect, "/phonesim", "org.ofono.NetworkRegistration", OfonoGetAllOnStartup, this);
84 if (!mi->modem()->powered()) {
85 mi->modem()->setPowered(true);
88 if (!mi->modem()->online()) {
89 mi->modem()->setOnline(true);
92 QCOMPARE(validity.count(), 0);
95 void cleanupTestCase()
102 OfonoModemInterface *mi;
105 QTEST_MAIN(TestOfonoModemInterface)
106 #include "test_ofonomodeminterface.moc"