1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
/*
* This file is part of ofono-qt
*
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* Contact: Alexander Kanavin <alex.kanavin@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#include <QtTest/QtTest>
#include <QtCore/QObject>
#include <ofonocallbarring.h>
#include <QtDebug>
class TestOfonoCallBarring : public QObject
{
Q_OBJECT
private slots:
void initTestCase()
{
m = new OfonoCallBarring(OfonoModem::ManualSelect, "/phonesim", this);
QCOMPARE(m->modem()->isValid(), true);
if (!m->modem()->powered()) {
m->modem()->setPowered(true);
QTest::qWait(5000);
}
if (!m->modem()->online()) {
m->modem()->setOnline(true);
QTest::qWait(5000);
}
QCOMPARE(m->isValid(), true);
}
void testOfonoCallbarring()
{
QSignalSpy voiceIncomingComplete(m, SIGNAL(voiceIncomingComplete(bool, QString)));
QSignalSpy voiceOutgoingComplete(m, SIGNAL(voiceOutgoingComplete(bool, QString)));
QSignalSpy voiceIncomingChanged(m, SIGNAL(voiceIncomingChanged(QString)));
QSignalSpy voiceOutgoingChanged(m, SIGNAL(voiceOutgoingChanged(QString)));
QSignalSpy setVoiceIncomingFailed(m, SIGNAL(setVoiceIncomingFailed()));
QSignalSpy setVoiceOutgoingFailed(m, SIGNAL(setVoiceOutgoingFailed()));
QSignalSpy changePasswordComplete(m, SIGNAL(changePasswordComplete(bool)));
QSignalSpy disableAllComplete(m, SIGNAL(disableAllComplete(bool)));
QSignalSpy disableAllIncomingComplete(m, SIGNAL(disableAllIncomingComplete(bool)));
QSignalSpy disableAllOutgoingComplete(m, SIGNAL(disableAllOutgoingComplete(bool)));
m->requestVoiceIncoming();
QTest::qWait(1000);
QCOMPARE(voiceIncomingComplete.count(), 1);
QVariantList list = voiceIncomingComplete.takeFirst();
QCOMPARE(list.at(0).toBool(), true);
QCOMPARE(list.at(1).toString(), QString("disabled"));
QCOMPARE(voiceIncomingChanged.count(), 1);
QCOMPARE(voiceIncomingChanged.takeFirst().at(0).toString(), QString("disabled"));
m->requestVoiceOutgoing();
QTest::qWait(1000);
QCOMPARE(voiceOutgoingComplete.count(), 1);
list = voiceOutgoingComplete.takeFirst();
QCOMPARE(list.at(0).toBool(), true);
QCOMPARE(list.at(1).toString(), QString("disabled"));
QCOMPARE(voiceOutgoingChanged.count(), 1);
QCOMPARE(voiceOutgoingChanged.takeFirst().at(0).toString(), QString("disabled"));
m->setVoiceIncoming("always", "0000");
QTest::qWait(1000);
QCOMPARE(setVoiceIncomingFailed.count(), 1);
setVoiceIncomingFailed.takeFirst();
m->setVoiceOutgoing("always", "0000");
QTest::qWait(1000);
QCOMPARE(setVoiceOutgoingFailed.count(), 1);
setVoiceOutgoingFailed.takeFirst();
m->setVoiceIncoming("always", "3579");
QTest::qWait(1000);
QCOMPARE(voiceIncomingChanged.count(), 1);
QCOMPARE(voiceIncomingChanged.takeFirst().at(0).toString(), QString("always"));
m->setVoiceOutgoing("international", "3579");
QTest::qWait(1000);
QCOMPARE(voiceOutgoingChanged.count(), 1);
QCOMPARE(voiceOutgoingChanged.takeFirst().at(0).toString(), QString("international"));
m->disableAllIncoming("3579");
QTest::qWait(1000);
QCOMPARE(disableAllIncomingComplete.count(), 1);
QCOMPARE(disableAllIncomingComplete.takeFirst().at(0).toBool(), false);
QCOMPARE(m->errorName(), QString("org.ofono.Error.Failed"));
QCOMPARE(m->errorMessage(), QString("Operation failed"));
m->disableAllOutgoing("3579");
QTest::qWait(1000);
QCOMPARE(disableAllOutgoingComplete.count(), 1);
QCOMPARE(disableAllOutgoingComplete.takeFirst().at(0).toBool(), false);
QCOMPARE(m->errorName(), QString("org.ofono.Error.Failed"));
QCOMPARE(m->errorMessage(), QString("Operation failed"));
m->disableAll("3579");
QTest::qWait(1000);
QCOMPARE(disableAllComplete.count(), 1);
QCOMPARE(disableAllComplete.takeFirst().at(0).toBool(), true);
QCOMPARE(voiceIncomingChanged.count(), 1);
QCOMPARE(voiceIncomingChanged.takeFirst().at(0).toString(), QString("disabled"));
QCOMPARE(voiceOutgoingChanged.count(), 1);
QCOMPARE(voiceOutgoingChanged.takeFirst().at(0).toString(), QString("disabled"));
m->changePassword("3579", "1234");
QTest::qWait(1000);
m->changePassword("1234", "3579");
QTest::qWait(1000);
QCOMPARE(changePasswordComplete.count(), 2);
QCOMPARE(changePasswordComplete.takeFirst().at(0).toBool(), true);
QCOMPARE(changePasswordComplete.takeFirst().at(0).toBool(), true);
}
void cleanupTestCase()
{
}
private:
OfonoCallBarring *m;
};
QTEST_MAIN(TestOfonoCallBarring)
#include "test_ofonocallbarring.moc"
|