File: test_ofonovoicecallmanager.cpp

package info (click to toggle)
libofono-qt 1.30-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 960 kB
  • sloc: cpp: 6,663; xml: 77; makefile: 14
file content (136 lines) | stat: -rw-r--r-- 4,103 bytes parent folder | download
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
/*
 * This file is part of ofono-qt
 *
 * Copyright (C) 2010-2011 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 <ofonovoicecallmanager.h>

#include <QtDebug>


class TestOfonoVoiceCallManager : public QObject
{
    Q_OBJECT

private slots:
    void initTestCase()
    {
	m = new OfonoVoiceCallManager(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 testOfonoVoiceCallManager()
    {
        bool success = false;
    	QVERIFY(m->emergencyNumbers().count() > 0);

	QSignalSpy emergencyNumbers(m, SIGNAL(emergencyNumbersChanged(QStringList)));
        QSignalSpy dspy(m, SIGNAL(callAdded(QString, QVariantMap)));
        QSignalSpy hupreg(m,SIGNAL(hangupAllComplete(bool)));
        QSignalSpy tonereg(m,SIGNAL(sendTonesComplete(bool)));
        QSignalSpy hspy(m, SIGNAL(callRemoved(QString)));

        m->modem()->setPowered(false);
        QTest::qWait(5000);
        m->modem()->setPowered(true);
        QTest::qWait(5000);
  	m->modem()->setOnline(true);
        QTest::qWait(5000);

        QCOMPARE(emergencyNumbers.count(), 1);
        QVERIFY(emergencyNumbers.takeFirst().at(0).toStringList().count() > 0);
        //Dial testing
        QDBusObjectPath objectPath = m->dial("123","", success);
        qDebug() << "Please find a call in 'Dialing' state in phonesim window and press 'Active' button";
        QTest::qWait(15000);
        QCOMPARE(objectPath.path().isEmpty(), false);
        QCOMPARE(success, true);
        QCOMPARE(dspy.count(), 1);
        //Tones testing
        QTest::qWait(5000);
        m->sendTones("1234");
        QTest::qWait(5000);
        QCOMPARE(tonereg.count(), 1);
        QCOMPARE(tonereg.takeFirst().at(0).toBool(),true);
        QTest::qWait(5000);
        QStringList calls = m->getCalls();
        QVERIFY(calls.size()>0);
        //hangup testing
        m->hangupAll();
        QTest::qWait(5000);
        QCOMPARE(hupreg.count(), 1);
        QCOMPARE(hupreg.takeFirst().at(0).toBool(),true);
        QCOMPARE(hspy.count(), 1);

    }

    void testoFonoVoiceCallManagerStep2()
    {
        bool success = false;
        // test dial failure and hangup of incoming alerting call
        QSignalSpy hupreg(m,SIGNAL(hangupAllComplete(bool)));
        QSignalSpy dspy(m, SIGNAL(callAdded(QString, QVariantMap)));
        QSignalSpy hspy(m, SIGNAL(callRemoved(QString)));


        QDBusObjectPath objectPath = m->dial("199","", success);
        QTest::qWait(5000);
        QCOMPARE(objectPath.path().isEmpty(), false);
        QCOMPARE(success, false);
        QTest::qWait(10000);
        QCOMPARE(dspy.count(), 1);

        //hangup the alerting call
        m->hangupAll();
        QTest::qWait(5000);
        QCOMPARE(hupreg.count(), 1);
        QCOMPARE(hupreg.takeFirst().at(0).toBool(),true);

        QTest::qWait(10000);
        QCOMPARE(hspy.count(), 1);

    }

    void cleanupTestCase()
    {

    }


private:
    OfonoVoiceCallManager *m;
};

QTEST_MAIN(TestOfonoVoiceCallManager)
#include "test_ofonovoicecallmanager.moc"