|
1 /*! |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Unit tests for telephonyservice. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <QtTest/QtTest> |
|
19 #include <QtGui> |
|
20 #include <hbapplication.h> |
|
21 #include <QSignalSpy> |
|
22 #include <xqservicerequest.h> |
|
23 #include <hbmenu.h> |
|
24 |
|
25 #include "telephonyservice.h" |
|
26 #include "phoneuiqtviewif.h" |
|
27 #include "phoneuiqtviewadapter.h" |
|
28 |
|
29 extern bool phoneAppStart; |
|
30 extern bool inCallDialerStart; |
|
31 |
|
32 #define PHONE_QT_NOTE_CONTROLLER_TEST_MAIN(TestObject) \ |
|
33 int main(int argc, char *argv[]) \ |
|
34 { \ |
|
35 HbApplication app(argc, argv); \ |
|
36 TestObject tc; \ |
|
37 QResource::registerResource("../hbcore.rcc"); \ |
|
38 int ret = QTest::qExec(&tc, argc, argv); \ |
|
39 /* Core dump if HbIconLoader instance is not destroyed before the application instance. */ \ |
|
40 /* HbIconLoader uses QCoreApplication::aboutToQuit() signal to destroy itself. */ \ |
|
41 /* app.exec() where the signal is normally emitted is not called here. */ \ |
|
42 /* So, invoking the signal explicitly. */ \ |
|
43 QMetaObject::invokeMethod(&app, "aboutToQuit", Qt::DirectConnection); \ |
|
44 return ret; \ |
|
45 } |
|
46 |
|
47 class TestTelephonyService : public QObject, public PhoneUIQtViewIF |
|
48 { |
|
49 Q_OBJECT |
|
50 public: |
|
51 TestTelephonyService(); |
|
52 virtual ~TestTelephonyService(); |
|
53 |
|
54 public: // PhoneUIQtViewIF |
|
55 |
|
56 BubbleManagerIF& bubbleManager (){}; |
|
57 void addBubbleCommand ( |
|
58 int , |
|
59 const PhoneAction& ){}; |
|
60 void clearBubbleCommands (int ){}; |
|
61 void addParticipantListAction( |
|
62 int , |
|
63 const QString &, |
|
64 const HbIcon &){}; |
|
65 void clearParticipantListActions(){}; |
|
66 void hideToolbar () {}; |
|
67 void showToolbar () {}; |
|
68 void setToolbarActions (const QList<PhoneAction*>& ){}; |
|
69 int volumeSliderValue () { return 0; }; |
|
70 void removeVolumeSlider () {}; |
|
71 void setVolumeSliderValue ( |
|
72 int , |
|
73 int , |
|
74 int , |
|
75 int ) { }; |
|
76 |
|
77 void setExpandAction(int , int ) {}; |
|
78 void removeExpandAction(int ) {}; |
|
79 void showDialpad() {}; |
|
80 void hideDialpad() {}; |
|
81 bool isDialpadVisible() { return false; }; |
|
82 QString dialpadText() {return QString("1234567");}; |
|
83 void clearAndHideDialpad(){}; |
|
84 void clearDialpad() {}; |
|
85 void bringToForeground() {}; |
|
86 void setMenuActions(const QList<PhoneAction*>& ){}; |
|
87 void shutdownPhoneApp() {}; |
|
88 void setBackButtonVisible(bool ) {}; |
|
89 HbMenu &menuReference() { return mMenu; }; |
|
90 void captureKey(Qt::Key , bool ) {}; |
|
91 void setRestrictedMode(bool ) {}; |
|
92 |
|
93 public slots: |
|
94 void initTestCase (); |
|
95 void cleanupTestCase (); |
|
96 void init (); |
|
97 void cleanup (); |
|
98 |
|
99 private slots: |
|
100 void testConstructionDestruction (); |
|
101 void startPhoneApp (); |
|
102 void startInCallDialer (); |
|
103 |
|
104 private: |
|
105 TelephonyService *m_service; // class under test |
|
106 PhoneUIQtViewAdapter *m_viewstub; // stub test |
|
107 HbMenu mMenu; |
|
108 }; |
|
109 |
|
110 TestTelephonyService::TestTelephonyService () |
|
111 { |
|
112 } |
|
113 |
|
114 TestTelephonyService::~TestTelephonyService () |
|
115 { |
|
116 } |
|
117 |
|
118 void TestTelephonyService::initTestCase () |
|
119 { |
|
120 m_viewstub = new PhoneUIQtViewAdapter (*this); |
|
121 m_service = new TelephonyService(m_viewstub, this); |
|
122 } |
|
123 |
|
124 void TestTelephonyService::cleanupTestCase () |
|
125 { |
|
126 if (m_viewstub) { |
|
127 delete m_viewstub; |
|
128 } |
|
129 |
|
130 if (m_service) { |
|
131 delete m_service; |
|
132 } |
|
133 } |
|
134 |
|
135 void TestTelephonyService::init () |
|
136 { |
|
137 } |
|
138 |
|
139 void TestTelephonyService::cleanup () |
|
140 { |
|
141 } |
|
142 |
|
143 void TestTelephonyService::testConstructionDestruction () |
|
144 { |
|
145 // empty |
|
146 } |
|
147 |
|
148 void TestTelephonyService::startPhoneApp () |
|
149 { |
|
150 phoneAppStart = false; |
|
151 inCallDialerStart = false; |
|
152 int phoneApp(0); |
|
153 m_service->start(phoneApp); |
|
154 QVERIFY (phoneAppStart == true); |
|
155 QVERIFY (inCallDialerStart == false); |
|
156 } |
|
157 |
|
158 void TestTelephonyService::startInCallDialer () |
|
159 { |
|
160 phoneAppStart = false; |
|
161 inCallDialerStart = false; |
|
162 int dialer(1); |
|
163 m_service->start(dialer); |
|
164 QVERIFY (phoneAppStart == true); |
|
165 QVERIFY (inCallDialerStart == true); |
|
166 } |
|
167 |
|
168 PHONE_QT_NOTE_CONTROLLER_TEST_MAIN(TestTelephonyService) |
|
169 #include "unit_tests.moc" |