Rewrite ModemManager test
[profile/ivi/ofono-qt.git] / tests / test_ofonomodem.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 <ofonomodem.h>
28
29 #include <QtDebug>
30
31 class TestOfonoModem : public QObject
32 {
33     Q_OBJECT
34
35 private slots:
36     void validityChanged(bool validity)
37     {
38     qDebug() << "ValidityChanged" << validity;
39         qDebug() << "validity" << m->isValid() << "modemPath" << m->modemPath();
40     }
41
42     void modemPathChanged(QString modemPath)
43     {
44     qDebug() << "ModemPathChanged" << modemPath;
45         qDebug() << "validity" << m->isValid() << "modemPath" << m->modemPath();
46     }
47
48     void poweredChanged(bool powered)
49     {
50     qDebug() << "PoweredChanged" << powered;
51     }
52
53     void onlineChanged(bool online)
54     {
55     qDebug() << "OnlineChanged" << online;
56     }
57
58     void nameChanged(QString name)
59     {
60     qDebug() << "nameChanged" << name;
61     }
62     
63     void manufacturerChanged(QString manufacturer)
64     {
65     qDebug() << "manufacturerChanged" << manufacturer;
66     }
67
68     void modelChanged(QString model)
69     {
70     qDebug() << "modelChanged" << model;
71     }
72
73     void revisionChanged(QString revision)
74     {
75     qDebug() << "revisionChanged" << revision;
76     }
77
78     void serialChanged(QString serial)
79     {
80     qDebug() << "serialChanged" << serial;
81     }
82
83     void featuresChanged(QStringList features)
84     {
85     qDebug() << "FeaturesChanged" << features;
86     }
87
88     void interfacesChanged(QStringList interfaces)
89     {
90     qDebug() << "InterfacesChanged" << interfaces;
91     }
92
93     void initTestCase()
94     {
95         m = new OfonoModem(OfonoModem::ManualSelect, "/isimodem0", this);
96 //      m = new OfonoModem(this);
97         connect(m, SIGNAL(validityChanged(bool)), this, SLOT(validityChanged(bool)));
98     connect(m, SIGNAL(modemPathChanged(QString)),
99             this, SLOT(modemPathChanged(QString)));
100         connect(m, SIGNAL(poweredChanged(bool)), this, SLOT(poweredChanged(bool)));
101         connect(m, SIGNAL(onlineChanged(bool)), this, SLOT(onlineChanged(bool)));
102    connect(m, SIGNAL(nameChanged(QString)),
103             this, SLOT(nameChanged(QString)));
104     connect(m, SIGNAL(manufacturerChanged(QString)),
105             this, SLOT(manufacturerChanged(QString)));
106     connect(m, SIGNAL(modelChanged(QString)),
107             this, SLOT(modelChanged(QString)));
108     connect(m, SIGNAL(revisionChanged(QString)),
109             this, SLOT(revisionChanged(QString)));
110     connect(m, SIGNAL(serialChanged(QString)),
111             this, SLOT(serialChanged(QString)));
112         connect(m, SIGNAL(featuresChanged(QStringList)), this, SLOT(featuresChanged(QStringList)));
113         connect(m, SIGNAL(interfacesChanged(QStringList)), this, SLOT(interfacesChanged(QStringList)));
114     }
115
116     void testOfonoModem()
117     {
118         qDebug() << "validity" << m->isValid() << "modemPath" << m->modemPath();
119     qDebug() << m->powered() << m->online() << m->manufacturer() << m->model() << m->revision() << m->serial() << m->features() << m->interfaces();
120     m->setOnline(true);
121     QTest::qWait(120000);
122     }
123
124
125     void cleanupTestCase()
126     {
127
128     }
129
130
131 private:
132     OfonoModem *m;
133 };
134
135 QTEST_MAIN(TestOfonoModem)
136 #include "test_ofonomodem.moc"