37
|
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 PhoneNoteController.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <QtTest/QtTest>
|
|
19 |
#include <QtGui>
|
|
20 |
#include <hbapplication.h>
|
|
21 |
#include <QSignalSpy>
|
|
22 |
//#include <hbglobal_p.h>
|
|
23 |
#include "phonenotecontroller.h"
|
|
24 |
#include "phoneresourceids.h"
|
|
25 |
#include "phoneui.hrh"
|
|
26 |
#include "tphonecmdparamglobalnote.h"
|
|
27 |
#include "tphonecmdparamquery.h"
|
|
28 |
#include "phoneresourceadapter.h"
|
|
29 |
#include "phoneconstants.h"
|
|
30 |
|
|
31 |
#define PHONE_QT_NOTE_CONTROLLER_TEST_MAIN(TestObject) \
|
|
32 |
int main(int argc, char *argv[]) \
|
|
33 |
{ \
|
|
34 |
HbApplication app(argc, argv); \
|
|
35 |
TestObject tc; \
|
|
36 |
QResource::registerResource("../hbcore.rcc"); \
|
|
37 |
int ret = QTest::qExec(&tc, argc, argv); \
|
|
38 |
/* Core dump if HbIconLoader instance is not destroyed before the application instance. */ \
|
|
39 |
/* HbIconLoader uses QCoreApplication::aboutToQuit() signal to destroy itself. */ \
|
|
40 |
/* app.exec() where the signal is normally emitted is not called here. */ \
|
|
41 |
/* So, invoking the signal explicitly. */ \
|
|
42 |
QMetaObject::invokeMethod(&app, "aboutToQuit", Qt::DirectConnection); \
|
|
43 |
return ret; \
|
|
44 |
}
|
|
45 |
|
|
46 |
class TestPhoneNoteController : public QObject
|
|
47 |
{
|
|
48 |
Q_OBJECT
|
|
49 |
public:
|
|
50 |
TestPhoneNoteController();
|
|
51 |
virtual ~TestPhoneNoteController();
|
|
52 |
|
|
53 |
public slots:
|
|
54 |
void initTestCase ();
|
|
55 |
void cleanupTestCase ();
|
|
56 |
void init ();
|
|
57 |
void cleanup ();
|
|
58 |
|
|
59 |
private slots:
|
|
60 |
void testShowGlobalNoteDefault ();
|
|
61 |
void testShowGlobalInfoNoteWithResourceId ();
|
|
62 |
void testShowGlobalWarningNoteWithText ();
|
|
63 |
void testShowGlobalNoteWithTextAndResourceId ();
|
|
64 |
void testShowGlobalNoteTwoTimes ();
|
|
65 |
void testShowGlobalNoteThreeTimes ();
|
|
66 |
void testShowNote();
|
|
67 |
void testShowQuery();
|
|
68 |
void testShowClobalWaitNote();
|
|
69 |
|
|
70 |
|
|
71 |
private:
|
|
72 |
PhoneNoteController *m_noteController; // class under test
|
|
73 |
};
|
|
74 |
|
|
75 |
TestPhoneNoteController::TestPhoneNoteController ()
|
|
76 |
{
|
|
77 |
}
|
|
78 |
|
|
79 |
TestPhoneNoteController::~TestPhoneNoteController ()
|
|
80 |
{
|
|
81 |
}
|
|
82 |
|
|
83 |
void TestPhoneNoteController::initTestCase ()
|
|
84 |
{
|
|
85 |
m_noteController = new PhoneNoteController();
|
|
86 |
}
|
|
87 |
|
|
88 |
void TestPhoneNoteController::cleanupTestCase ()
|
|
89 |
{
|
|
90 |
delete m_noteController;
|
|
91 |
}
|
|
92 |
|
|
93 |
void TestPhoneNoteController::init ()
|
|
94 |
{
|
|
95 |
}
|
|
96 |
|
|
97 |
void TestPhoneNoteController::cleanup ()
|
|
98 |
{
|
|
99 |
}
|
|
100 |
|
|
101 |
void TestPhoneNoteController::testShowGlobalNoteDefault ()
|
|
102 |
{
|
|
103 |
TPhoneCmdParamGlobalNote globalNoteParam;
|
|
104 |
globalNoteParam.SetTimeout(0);
|
|
105 |
globalNoteParam.SetWaitForReady(ETrue);
|
|
106 |
m_noteController->showGlobalNote(&globalNoteParam);
|
|
107 |
QTest::qWait(2500);
|
|
108 |
|
|
109 |
globalNoteParam.SetTimeout(KPhoneNoteNoTimeout);
|
|
110 |
m_noteController->showGlobalNote(&globalNoteParam);
|
|
111 |
QTest::qWait(2500);
|
|
112 |
}
|
|
113 |
|
|
114 |
void TestPhoneNoteController::testShowGlobalInfoNoteWithResourceId ()
|
|
115 |
{
|
|
116 |
TPhoneCmdParamGlobalNote globalNoteParam;
|
|
117 |
globalNoteParam.SetTextResourceId(R_NOTETEXT_NO_ANSWER);
|
|
118 |
globalNoteParam.SetWaitForReady(EFalse);
|
|
119 |
globalNoteParam.SetType( EAknGlobalInformationNote );
|
|
120 |
|
|
121 |
m_noteController->showGlobalNote(&globalNoteParam);
|
|
122 |
|
|
123 |
QTest::qWait(5000);
|
|
124 |
}
|
|
125 |
|
|
126 |
void TestPhoneNoteController::testShowGlobalWarningNoteWithText ()
|
|
127 |
{
|
|
128 |
TPhoneCmdParamGlobalNote globalNoteParam;
|
|
129 |
globalNoteParam.SetWaitForReady(ETrue);
|
|
130 |
globalNoteParam.SetType( EAknGlobalWarningNote );
|
|
131 |
globalNoteParam.SetText(_L("Test note 1"));
|
|
132 |
|
|
133 |
m_noteController->showGlobalNote(&globalNoteParam);
|
|
134 |
}
|
|
135 |
|
|
136 |
void TestPhoneNoteController::testShowGlobalNoteWithTextAndResourceId ()
|
|
137 |
{
|
|
138 |
TPhoneCmdParamGlobalNote globalNoteParam;
|
|
139 |
globalNoteParam.SetTextResourceId(R_PHONE_TEXT_COLP_CONNECTED);
|
|
140 |
globalNoteParam.SetWaitForReady(EFalse);
|
|
141 |
globalNoteParam.SetType( EAknGlobalInformationNote );
|
|
142 |
globalNoteParam.SetText(_L("Test number"));
|
|
143 |
|
|
144 |
m_noteController->showGlobalNote(&globalNoteParam);
|
|
145 |
|
|
146 |
QTest::qWait(5000);
|
|
147 |
}
|
|
148 |
|
|
149 |
void TestPhoneNoteController::testShowGlobalNoteTwoTimes ()
|
|
150 |
{
|
|
151 |
TPhoneCmdParamGlobalNote globalNoteParam;
|
|
152 |
//globalNoteParam.SetTextResourceId(R_NOTETEXT_NO_ANSWER);
|
|
153 |
globalNoteParam.SetWaitForReady(EFalse);
|
|
154 |
globalNoteParam.SetType( EAknGlobalInformationNote );
|
|
155 |
globalNoteParam.SetText(_L("Test note 2"));
|
|
156 |
|
|
157 |
m_noteController->showGlobalNote(&globalNoteParam);
|
|
158 |
|
|
159 |
globalNoteParam.SetText(_L("Test note 3"));
|
|
160 |
|
|
161 |
m_noteController->showGlobalNote(&globalNoteParam);
|
|
162 |
|
|
163 |
QTest::qWait(10000);
|
|
164 |
|
|
165 |
}
|
|
166 |
|
|
167 |
void TestPhoneNoteController::testShowGlobalNoteThreeTimes ()
|
|
168 |
{
|
|
169 |
TPhoneCmdParamGlobalNote globalNoteParam;
|
|
170 |
//globalNoteParam.SetTextResourceId(R_NOTETEXT_NO_ANSWER);
|
|
171 |
globalNoteParam.SetWaitForReady(EFalse);
|
|
172 |
globalNoteParam.SetType( EAknGlobalInformationNote );
|
|
173 |
globalNoteParam.SetText(_L("Test note 4"));
|
|
174 |
|
|
175 |
m_noteController->showGlobalNote(&globalNoteParam);
|
|
176 |
|
|
177 |
globalNoteParam.SetText(_L("Test note 5"));
|
|
178 |
|
|
179 |
m_noteController->showGlobalNote(&globalNoteParam);
|
|
180 |
|
|
181 |
globalNoteParam.SetText(_L("Test note 6"));
|
|
182 |
|
|
183 |
m_noteController->showGlobalNote(&globalNoteParam);
|
|
184 |
|
|
185 |
QTest::qWait(20000);
|
|
186 |
}
|
|
187 |
|
|
188 |
void TestPhoneNoteController::testShowNote()
|
|
189 |
{
|
|
190 |
TPhoneCmdParamNote noteParam;
|
|
191 |
|
|
192 |
m_noteController->showNote(¬eParam);
|
|
193 |
m_noteController->removeDtmfNote();
|
|
194 |
m_noteController->removeNote();
|
|
195 |
|
|
196 |
noteParam.SetType(EPhoneNoteDtmfSending);
|
|
197 |
m_noteController->showNote(¬eParam);
|
|
198 |
|
|
199 |
noteParam.SetResourceId(R_PHONEUI_SENDING_DTMF_WAIT_NOTE);
|
|
200 |
noteParam.SetText(_L("Sending:\n123p456"));
|
|
201 |
|
|
202 |
m_noteController->showNote(¬eParam);
|
|
203 |
QTest::qWait(20000);
|
|
204 |
|
|
205 |
noteParam.SetText(_L("Sending:\n123p456"));
|
|
206 |
m_noteController->showNote(¬eParam);
|
|
207 |
|
|
208 |
QTest::qWait(20000);
|
|
209 |
|
|
210 |
m_noteController->removeNote();
|
|
211 |
|
|
212 |
QTest::qWait(20000);
|
|
213 |
}
|
|
214 |
|
|
215 |
void TestPhoneNoteController::testShowQuery()
|
|
216 |
{
|
|
217 |
TPhoneCmdParamQuery queryParam;
|
|
218 |
m_noteController->showQuery(&queryParam);
|
|
219 |
|
|
220 |
queryParam.SetQueryType(EPhoneQueryDialog);
|
|
221 |
m_noteController->showQuery(&queryParam);
|
|
222 |
|
|
223 |
queryParam.SetQueryPrompt(_L("TestQuery"));
|
|
224 |
m_noteController->showQuery(&queryParam);
|
|
225 |
m_noteController->removeQuery();
|
|
226 |
|
|
227 |
queryParam.SetQueryResourceId(R_PHONEUI_DTMF_WAIT_CHARACTER_CONFIRMATION_QUERY);
|
|
228 |
m_noteController->showQuery(&queryParam);
|
|
229 |
|
|
230 |
QTest::qWait(20000);
|
|
231 |
m_noteController->showQuery(&queryParam);
|
|
232 |
|
|
233 |
m_noteController->removeQuery();
|
|
234 |
|
|
235 |
QTest::qWait(20000);
|
|
236 |
}
|
|
237 |
|
|
238 |
void TestPhoneNoteController::testShowClobalWaitNote()
|
|
239 |
{
|
|
240 |
TPhoneCmdParamQuery queryParam;
|
|
241 |
|
|
242 |
queryParam.SetQueryType(EPhoneGlobalWaitNote);
|
|
243 |
m_noteController->showQuery(&queryParam);
|
|
244 |
QTest::qWait(5000);
|
|
245 |
m_noteController->removeGlobalWaitNote();
|
|
246 |
QTest::qWait(5000);
|
|
247 |
|
|
248 |
queryParam.SetQueryPrompt(_L("TestQuery"));
|
|
249 |
m_noteController->showQuery(&queryParam);
|
|
250 |
QTest::qWait(5000);
|
|
251 |
m_noteController->removeGlobalWaitNote();
|
|
252 |
QTest::qWait(5000);
|
|
253 |
|
|
254 |
queryParam.SetQueryPrompt(KNullDesC);
|
|
255 |
TBuf<4> buf(_L("test"));
|
|
256 |
queryParam.SetDataText(&buf);
|
|
257 |
queryParam.SetTimeOut(2000);
|
|
258 |
m_noteController->showQuery(&queryParam);
|
|
259 |
QTest::qWait(10000);
|
|
260 |
|
|
261 |
queryParam.SetCustomCommandForTimeOut(10);
|
|
262 |
m_noteController->showQuery(&queryParam);
|
|
263 |
QTest::qWait(10000);
|
|
264 |
}
|
|
265 |
|
|
266 |
PHONE_QT_NOTE_CONTROLLER_TEST_MAIN(TestPhoneNoteController)
|
|
267 |
#include "unit_tests.moc"
|