2 * This file is part of ofono-qt
4 * Copyright (C) 2010-2011 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 connectedLinePresentationComplete(m, SIGNAL(connectedLinePresentationComplete(bool, QString)));
58 QSignalSpy connectedLineRestrictionComplete(m, SIGNAL(connectedLineRestrictionComplete(bool, QString)));
59 QSignalSpy callingLineRestrictionComplete(m, SIGNAL(callingLineRestrictionComplete(bool, QString)));
60 QSignalSpy hideCallerIdComplete(m, SIGNAL(hideCallerIdComplete(bool, QString)));
61 QSignalSpy voiceCallWaitingComplete(m, SIGNAL(voiceCallWaitingComplete(bool, QString)));
63 QSignalSpy callingLinePresentationChanged(m, SIGNAL(callingLinePresentationChanged(QString)));
64 QSignalSpy calledLinePresentationChanged(m, SIGNAL(calledLinePresentationChanged(QString)));
65 QSignalSpy connectedLinePresentationChanged(m, SIGNAL(connectedLinePresentationChanged(QString)));
66 QSignalSpy connectedLineRestrictionChanged(m, SIGNAL(connectedLineRestrictionChanged(QString)));
67 QSignalSpy callingLineRestrictionChanged(m, SIGNAL(callingLineRestrictionChanged(QString)));
68 QSignalSpy hideCallerIdChanged(m, SIGNAL(hideCallerIdChanged(QString)));
69 QSignalSpy voiceCallWaitingChanged(m, SIGNAL(voiceCallWaitingChanged(QString)));
71 QSignalSpy setHideCallerIdFailed(m, SIGNAL(setHideCallerIdFailed()));
72 QSignalSpy setVoiceCallWaitingFailed(m, SIGNAL(setVoiceCallWaitingFailed()));
74 m->requestCallingLinePresentation();
76 QCOMPARE(callingLinePresentationComplete.count(), 1);
77 QVariantList list = callingLinePresentationComplete.takeFirst();
78 QCOMPARE(list.at(0).toBool(), true);
79 QCOMPARE(list.at(1).toString(), QString("enabled"));
80 QVERIFY(callingLinePresentationChanged.count() > 0);
81 QCOMPARE(callingLinePresentationChanged.takeFirst().at(0).toString(), QString("enabled"));
82 m->requestCalledLinePresentation();
84 QCOMPARE(calledLinePresentationComplete.count(), 1);
85 list = calledLinePresentationComplete.takeFirst();
86 QCOMPARE(list.at(0).toBool(), true);
87 QCOMPARE(list.at(1).toString(), QString("enabled"));
88 QVERIFY(calledLinePresentationChanged.count() > 0);
89 QCOMPARE(calledLinePresentationChanged.takeFirst().at(0).toString(), QString("enabled"));
90 m->requestConnectedLinePresentation();
92 QCOMPARE(connectedLinePresentationComplete.count(), 1);
93 list = connectedLinePresentationComplete.takeFirst();
94 QCOMPARE(list.at(0).toBool(), true);
95 QCOMPARE(list.at(1).toString(), QString("enabled"));
96 QVERIFY(connectedLinePresentationChanged.count() > 0);
97 QCOMPARE(connectedLinePresentationChanged.takeFirst().at(0).toString(), QString("enabled"));
98 m->requestConnectedLineRestriction();
100 QCOMPARE(connectedLineRestrictionComplete.count(), 1);
101 list = connectedLineRestrictionComplete.takeFirst();
102 QCOMPARE(list.at(0).toBool(), true);
103 QCOMPARE(list.at(1).toString(), QString("enabled"));
104 QVERIFY(connectedLineRestrictionChanged.count() > 0);
105 QCOMPARE(connectedLineRestrictionChanged.takeFirst().at(0).toString(), QString("enabled"));
106 m->requestCallingLineRestriction();
108 QCOMPARE(callingLineRestrictionComplete.count(), 1);
109 list = callingLineRestrictionComplete.takeFirst();
110 QCOMPARE(list.at(0).toBool(), true);
111 QCOMPARE(list.at(1).toString(), QString("on"));
112 QVERIFY(callingLineRestrictionChanged.count() > 0);
113 QCOMPARE(callingLineRestrictionChanged.takeFirst().at(0).toString(), QString("on"));
114 m->requestHideCallerId();
116 QCOMPARE(hideCallerIdComplete.count(), 1);
117 list = hideCallerIdComplete.takeFirst();
118 QCOMPARE(list.at(0).toBool(), true);
119 QCOMPARE(list.at(1).toString(), QString("default"));
120 QVERIFY(hideCallerIdChanged.count() > 0);
121 QCOMPARE(hideCallerIdChanged.takeFirst().at(0).toString(), QString("default"));
122 m->requestVoiceCallWaiting();
124 QCOMPARE(voiceCallWaitingComplete.count(), 1);
125 list = voiceCallWaitingComplete.takeFirst();
126 QCOMPARE(list.at(0).toBool(), true);
127 QCOMPARE(list.at(1).toString(), QString("enabled"));
128 QVERIFY(voiceCallWaitingChanged.count() > 0);
129 QCOMPARE(voiceCallWaitingChanged.takeFirst().at(0).toString(), QString("enabled"));
131 m->setHideCallerId("abc");
133 QCOMPARE(setHideCallerIdFailed.count(), 1);
134 setHideCallerIdFailed.takeFirst();
135 m->setVoiceCallWaiting("abc");
137 QCOMPARE(setVoiceCallWaitingFailed.count(), 1);
138 setVoiceCallWaitingFailed.takeFirst();
140 hideCallerIdChanged.clear();
141 m->setHideCallerId("enabled");
143 m->setHideCallerId("default");
145 QCOMPARE(hideCallerIdChanged.count(), 2);
146 QCOMPARE(hideCallerIdChanged.takeFirst().at(0).toString(), QString("enabled"));
147 QCOMPARE(hideCallerIdChanged.takeFirst().at(0).toString(), QString("default"));
149 voiceCallWaitingChanged.clear();
150 m->setVoiceCallWaiting("disabled");
152 m->setVoiceCallWaiting("enabled");
154 QCOMPARE(voiceCallWaitingChanged.count(), 2);
155 QCOMPARE(voiceCallWaitingChanged.takeFirst().at(0).toString(), QString("disabled"));
156 QCOMPARE(voiceCallWaitingChanged.takeFirst().at(0).toString(), QString("enabled"));
160 void cleanupTestCase()
167 OfonoCallSettings *m;
170 QTEST_MAIN(TestOfonoCallSettings)
171 #include "test_ofonocallsettings.moc"