60dbfbb25698d6a4348819d55470569ea6b109fa
[profile/ivi/ofono-qt.git] / tests / test_ofonomessagemanager.cpp
1 /*
2  * This file is part of ofono-qt
3  *
4  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5  *
6  * Contact: Alexander Kanavin <alexander.kanavin@nokia.com>
7  *
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.
11  *
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.
16  *
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
20  * 02110-1301 USA
21  *
22  */
23
24 #include <QtTest/QtTest>
25 #include <QtCore/QObject>
26
27 #include <ofonomessagemanager.h>
28
29 #include <QtDebug>
30
31
32 class TestOfonoMessageManager : public QObject
33 {
34     Q_OBJECT
35
36 private slots:
37
38     void serviceCenterAddressChanged(const QString numbers)
39     {
40         qDebug() << "serviceCenterAddressChanged" << numbers;
41     }
42
43     void setServiceCenterAddressFailed()
44     {
45         qDebug() << "serviceCenterAddressFailed";
46     }
47
48     void serviceCenterAddressComplete(bool success, const QString numbers)
49     {
50         qDebug() << "serviceCenterAddressComplete" << success << numbers;
51         m_sca = numbers;
52     }
53
54     void validityChanged(bool validity)
55     {
56         qDebug() << "ValidityChanged" << validity;
57     }
58
59     void initTestCase()
60     {
61         m = new OfonoMessageManager(QString(), this);
62         connect(m, SIGNAL(validityChanged(bool)), this, 
63                 SLOT(validityChanged(bool)));
64         connect(m, SIGNAL(serviceCenterAddressChanged(QString)), 
65                 this, 
66                 SLOT(serviceCenterAddressChanged(QString)));
67         connect(m, SIGNAL(setServiceCenterAddressFailed()), 
68                 this, 
69                 SLOT(setServiceCenterAddressFailed()));
70         connect(m, SIGNAL(serviceCenterAddressComplete(bool, QString)), 
71                 this, 
72                 SLOT(serviceCenterAddressComplete(bool, QString)));
73     }
74
75     void testOfonoMessageManager()
76     {
77         qDebug() << "validity:" << m->isValid();
78         if (m->isValid()) {
79             m->requestServiceCenterAddress();
80             QTest::qWait(2000);
81             if (m_sca.length() == 0)
82                 return;
83             qDebug() << "setServiceCenterAddress(+123456)";
84             m->setServiceCenterAddress("+123456");
85             QTest::qWait(1000);
86             qDebug() << "setServiceCenterAddress(original)";
87             m->setServiceCenterAddress(m_sca);
88         }
89         QTest::qWait(1000);
90     }
91
92
93     void cleanupTestCase()
94     {
95
96     }
97
98
99 private:
100     OfonoMessageManager *m;
101     QString m_sca;
102 };
103
104 QTEST_MAIN(TestOfonoMessageManager)
105 #include "test_ofonomessagemanager.moc"