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 <ofonocallsettings.h>
32 class TestOfonoCallSettings : public QObject
39 m = new OfonoCallSettings(OfonoModem::ManualSelect, "/phonesim", this);
40 QCOMPARE(m->modem()->isValid(), true);
42 if (!m->modem()->powered()) {
43 m->modem()->setPowered(true);
46 if (!m->modem()->online()) {
47 m->modem()->setOnline(true);
50 QCOMPARE(m->isValid(), true);
53 void testOfonoCallSettings()
55 QSignalSpy callingLinePresentationComplete(m, SIGNAL(callingLinePresentationComplete(bool, QString)));
56 QSignalSpy calledLinePresentationComplete(m, SIGNAL(calledLinePresentationComplete(bool, QString)));
57 QSignalSpy calledLineRestrictionComplete(m, SIGNAL(calledLineRestrictionComplete(bool, QString)));
58 QSignalSpy callingLineRestrictionComplete(m, SIGNAL(callingLineRestrictionComplete(bool, QString)));
59 QSignalSpy hideCallerIdComplete(m, SIGNAL(hideCallerIdComplete(bool, QString)));
60 QSignalSpy voiceCallWaitingComplete(m, SIGNAL(voiceCallWaitingComplete(bool, QString)));
62 QSignalSpy callingLinePresentationChanged(m, SIGNAL(callingLinePresentationChanged(QString)));
63 QSignalSpy calledLinePresentationChanged(m, SIGNAL(calledLinePresentationChanged(QString)));
64 QSignalSpy calledLineRestrictionChanged(m, SIGNAL(calledLineRestrictionChanged(QString)));
65 QSignalSpy callingLineRestrictionChanged(m, SIGNAL(callingLineRestrictionChanged(QString)));
66 QSignalSpy hideCallerIdChanged(m, SIGNAL(hideCallerIdChanged(QString)));
67 QSignalSpy voiceCallWaitingChanged(m, SIGNAL(voiceCallWaitingChanged(QString)));
69 QSignalSpy setHideCallerIdFailed(m, SIGNAL(setHideCallerIdFailed()));
70 QSignalSpy setVoiceCallWaitingFailed(m, SIGNAL(setVoiceCallWaitingFailed()));
72 m->requestCallingLinePresentation();
74 QCOMPARE(callingLinePresentationComplete.count(), 1);
75 QVariantList list = callingLinePresentationComplete.takeFirst();
76 QCOMPARE(list.at(0).toBool(), true);
77 QCOMPARE(list.at(1).toString(), QString("enabled"));
78 QVERIFY(callingLinePresentationChanged.count() > 0);
79 QCOMPARE(callingLinePresentationChanged.takeFirst().at(0).toString(), QString("enabled"));
80 m->requestCalledLinePresentation();
82 QCOMPARE(calledLinePresentationComplete.count(), 1);
83 list = calledLinePresentationComplete.takeFirst();
84 QCOMPARE(list.at(0).toBool(), true);
85 QCOMPARE(list.at(1).toString(), QString("enabled"));
86 QVERIFY(calledLinePresentationChanged.count() > 0);
87 QCOMPARE(calledLinePresentationChanged.takeFirst().at(0).toString(), QString("enabled"));
88 m->requestCalledLineRestriction();
90 QCOMPARE(calledLineRestrictionComplete.count(), 1);
91 list = calledLineRestrictionComplete.takeFirst();
92 QCOMPARE(list.at(0).toBool(), true);
93 QCOMPARE(list.at(1).toString(), QString("enabled"));
94 QVERIFY(calledLineRestrictionChanged.count() > 0);
95 QCOMPARE(calledLineRestrictionChanged.takeFirst().at(0).toString(), QString("enabled"));
96 m->requestCallingLineRestriction();
98 QCOMPARE(callingLineRestrictionComplete.count(), 1);
99 list = callingLineRestrictionComplete.takeFirst();
100 QCOMPARE(list.at(0).toBool(), true);
101 QCOMPARE(list.at(1).toString(), QString("on"));
102 QVERIFY(callingLineRestrictionChanged.count() > 0);
103 QCOMPARE(callingLineRestrictionChanged.takeFirst().at(0).toString(), QString("on"));
104 m->requestHideCallerId();
106 QCOMPARE(hideCallerIdComplete.count(), 1);
107 list = hideCallerIdComplete.takeFirst();
108 QCOMPARE(list.at(0).toBool(), true);
109 QCOMPARE(list.at(1).toString(), QString("default"));
110 QVERIFY(hideCallerIdChanged.count() > 0);
111 QCOMPARE(hideCallerIdChanged.takeFirst().at(0).toString(), QString("default"));
112 m->requestVoiceCallWaiting();
114 QCOMPARE(voiceCallWaitingComplete.count(), 1);
115 list = voiceCallWaitingComplete.takeFirst();
116 QCOMPARE(list.at(0).toBool(), true);
117 QCOMPARE(list.at(1).toString(), QString("enabled"));
118 QVERIFY(voiceCallWaitingChanged.count() > 0);
119 QCOMPARE(voiceCallWaitingChanged.takeFirst().at(0).toString(), QString("enabled"));
121 m->setHideCallerId("abc");
123 QCOMPARE(setHideCallerIdFailed.count(), 1);
124 setHideCallerIdFailed.takeFirst();
125 m->setVoiceCallWaiting("abc");
127 QCOMPARE(setVoiceCallWaitingFailed.count(), 1);
128 setVoiceCallWaitingFailed.takeFirst();
130 hideCallerIdChanged.clear();
131 m->setHideCallerId("enabled");
133 m->setHideCallerId("default");
135 QCOMPARE(hideCallerIdChanged.count(), 2);
136 QCOMPARE(hideCallerIdChanged.takeFirst().at(0).toString(), QString("enabled"));
137 QCOMPARE(hideCallerIdChanged.takeFirst().at(0).toString(), QString("default"));
139 voiceCallWaitingChanged.clear();
140 m->setVoiceCallWaiting("disabled");
142 m->setVoiceCallWaiting("enabled");
144 QCOMPARE(voiceCallWaitingChanged.count(), 2);
145 QCOMPARE(voiceCallWaitingChanged.takeFirst().at(0).toString(), QString("disabled"));
146 QCOMPARE(voiceCallWaitingChanged.takeFirst().at(0).toString(), QString("enabled"));
150 void cleanupTestCase()
157 OfonoCallSettings *m;
160 QTEST_MAIN(TestOfonoCallSettings)
161 #include "test_ofonocallsettings.moc"