2 * This file is part of ofono-qt
4 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 * Contact: Alexander Kanavin <alex.kanavin@gmail.com>
7 * Author: Arun Ravindran <ext-arun.1.ravindran@nokia.com>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * version 2.1 as published by the Free Software Foundation.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 #include <QtTest/QtTest>
26 #include <QtCore/QObject>
28 #include <ofonocallvolume.h>
32 class TestOfonoCallVolume : public QObject
40 m = new OfonoCallVolume(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 testOfonoCallVolume()
57 QSignalSpy mutedChanged(m, SIGNAL(mutedChanged(const bool)));
58 QSignalSpy speakerVolumeChanged(m, SIGNAL(speakerVolumeChanged(const quint8)));
59 QSignalSpy microphoneVolumeChanged(m, SIGNAL(microphoneVolumeChanged(const quint8)));
60 QSignalSpy spfail(m, SIGNAL(setSpeakerVolumeFailed()));
61 QSignalSpy mvfail(m, SIGNAL(setMicrophoneVolumeFailed()));
63 m->modem()->setPowered(false);
65 m->modem()->setPowered(true);
67 m->modem()->setOnline(true);
72 QCOMPARE(mutedChanged.count(), 1);
73 QVERIFY(mutedChanged.takeFirst().at(0).toBool()==bool(true));
74 QVERIFY(m->muted()==bool(true));
78 QCOMPARE(mutedChanged.count(), 1);
79 QVERIFY(mutedChanged.takeFirst().at(0).toBool()==bool(false));
80 QVERIFY(m->muted()==bool(false));
83 m->setSpeakerVolume(quint8(15));
85 QCOMPARE(speakerVolumeChanged.count(), 1);
86 QCOMPARE(quint8(speakerVolumeChanged.takeFirst().at(0).toUInt()), quint8(15));
87 QCOMPARE(m->speakerVolume(),quint8(15));
89 m->setSpeakerVolume(quint8(250));
91 QCOMPARE(spfail.count(), 1);
93 m->setMicrophoneVolume(quint8(10));
95 QCOMPARE(mvfail.count(), 1);
98 void cleanupTestCase()
108 QTEST_MAIN(TestOfonoCallVolume)
109 #include "test_ofonocallvolume.moc"