author | William Roberts <williamr@symbian.org> |
Thu, 22 Jul 2010 16:33:21 +0100 | |
branch | GCC_SURGE |
changeset 51 | f39ed5e045e0 |
parent 30 | ebdbd102c78a |
parent 46 | bc5a64e5bc3c |
permissions | -rw-r--r-- |
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: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include "ut_cpphonenotes.h" |
|
19 |
#include "qtestmains60ui.h" |
|
20 |
#include <hbmainwindow.h> |
|
21 |
#include <HbDeviceMessageBox.h> |
|
22 |
#include <HbMessageBox.h> |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
23 |
#include <hbnotificationdialog.h> |
37 | 24 |
#define private public |
25 |
#include "cpphonenotes.h" |
|
26 |
||
27 |
/*! |
|
28 |
UT_CpPhoneNotes::UT_CpPhoneNotes |
|
29 |
*/ |
|
30 |
UT_CpPhoneNotes::UT_CpPhoneNotes() |
|
31 |
{ |
|
32 |
CpPhoneNotes::instance(); |
|
33 |
} |
|
34 |
||
35 |
/*! |
|
36 |
UT_CpPhoneNotes::~UT_CpPhoneNotes |
|
37 |
*/ |
|
38 |
UT_CpPhoneNotes::~UT_CpPhoneNotes() |
|
39 |
{ |
|
40 |
//delete m_psui; |
|
41 |
} |
|
42 |
||
43 |
/*! |
|
44 |
UT_CpPhoneNotes::timerEvent |
|
45 |
*/ |
|
46 |
void UT_CpPhoneNotes::timerEvent( QTimerEvent* event ) |
|
47 |
{ |
|
48 |
QString currentTest(QTest::currentTestFunction()); |
|
49 |
qDebug() << "timerEvent:" << currentTest; |
|
50 |
||
51 |
if (currentTest == "t_showGlobalErrorNote") { |
|
52 |
verifyGlobalNote(wantedNoteText); |
|
53 |
} |
|
54 |
||
55 |
if (m_noteid1) { |
|
56 |
CpPhoneNotes::instance()->cancelNote(m_noteid1); |
|
57 |
m_noteid1 = 0; |
|
58 |
} |
|
59 |
if (m_noteid2) { |
|
60 |
CpPhoneNotes::instance()->cancelNote(m_noteid2); |
|
61 |
m_noteid2 = 0; |
|
62 |
} |
|
63 |
if (m_noteid3) { |
|
64 |
CpPhoneNotes::instance()->cancelNote(m_noteid3); |
|
65 |
m_noteid3 = 0; |
|
66 |
} |
|
67 |
||
68 |
if (visibleDialog()) { |
|
69 |
visibleDialog()->close(); |
|
70 |
QTest::qWait(1); |
|
71 |
} |
|
72 |
||
73 |
} |
|
74 |
||
75 |
/*! |
|
76 |
UT_CpPhoneNotes::visibleDialog |
|
77 |
*/ |
|
78 |
HbDialog *UT_CpPhoneNotes::visibleDialog() |
|
79 |
{ |
|
80 |
QList<QGraphicsItem*> items = mainWindow->scene()->items(); |
|
81 |
foreach (QGraphicsItem* item, items) { |
|
82 |
HbDialog *w = qobject_cast<HbDialog*>(item->parentWidget()); |
|
83 |
if (w && w->isVisible()) { |
|
84 |
qDebug() << "visibleDialog: " << w->getStaticMetaObject().className() << |
|
85 |
"contentWidget: " << w->contentWidget()->getStaticMetaObject().className(); |
|
86 |
return w; |
|
87 |
} |
|
88 |
} |
|
89 |
||
90 |
return 0; |
|
91 |
} |
|
92 |
||
93 |
/*! |
|
94 |
UT_CpPhoneNotes::verifyGlobalNote |
|
95 |
*/ |
|
96 |
void UT_CpPhoneNotes::verifyGlobalNote( const QString& noteText ) |
|
97 |
{ |
|
98 |
qDebug() << "verifyGlobalNote:" << noteText; |
|
99 |
HbDeviceMessageBox *note=0; |
|
100 |
QObject* o=0; |
|
101 |
QVERIFY(CpPhoneNotes::instance()->m_notesQueue->count()); |
|
102 |
QVERIFY(o = CpPhoneNotes::instance()->m_notesQueue->at(0)); |
|
103 |
QVERIFY(note = qobject_cast<HbDeviceMessageBox *>(o)); |
|
104 |
QCOMPARE(note->text(), noteText); |
|
105 |
note->close(); |
|
106 |
QTest::qWait(1); |
|
107 |
} |
|
108 |
||
109 |
/*! |
|
110 |
UT_CpPhoneNotes::init |
|
111 |
*/ |
|
112 |
void UT_CpPhoneNotes::init() |
|
113 |
{ |
|
114 |
initialize(); |
|
115 |
timerid = startTimer(3000); |
|
116 |
m_noteid1 = 0; |
|
117 |
m_noteid2 = 0; |
|
118 |
m_noteid3 = 0; |
|
119 |
} |
|
120 |
||
121 |
/*! |
|
122 |
UT_CpPhoneNotes::cleanup |
|
123 |
*/ |
|
124 |
void UT_CpPhoneNotes::cleanup() |
|
125 |
{ |
|
126 |
reset(); |
|
127 |
if (timerid) { |
|
128 |
killTimer(timerid); |
|
129 |
timerid = 0; |
|
130 |
} |
|
131 |
} |
|
132 |
||
133 |
/*! |
|
134 |
UT_CpPhoneNotes::t_memleak |
|
135 |
*/ |
|
136 |
void UT_CpPhoneNotes::t_memleak() |
|
137 |
{ |
|
138 |
||
139 |
} |
|
140 |
||
141 |
/*! |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
142 |
UT_CpPhoneNotes::t_showNotificationDialog |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
143 |
*/ |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
144 |
void UT_CpPhoneNotes::t_showNotificationDialog() |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
145 |
{ |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
146 |
CpPhoneNotes::instance()->showNotificationDialog("NotificationDialog"); |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
147 |
} |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
148 |
|
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
149 |
/*! |
37 | 150 |
UT_CpPhoneNotes::t_showProgressNote |
151 |
*/ |
|
152 |
void UT_CpPhoneNotes::t_showProgressNote() |
|
153 |
{ |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
154 |
CpPhoneNotes::instance()->showGlobalProgressNote(m_noteid1, "testshowProgressNote1"); |
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
155 |
QTest::qWait(5000); |
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
156 |
CpPhoneNotes::instance()->showGlobalProgressNote(m_noteid2, "testshowProgressNote2"); |
37 | 157 |
QTest::qWait(5000); |
158 |
} |
|
159 |
||
160 |
/*! |
|
161 |
UT_CpPhoneNotes::t_showGlobalProgressNote |
|
162 |
*/ |
|
163 |
void UT_CpPhoneNotes::t_showGlobalProgressNote() |
|
164 |
{ |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
165 |
CpPhoneNotes::instance()->showGlobalProgressNote(m_noteid1, "testshowGPN"); |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
166 |
QTest::qWait(5000); |
46
bc5a64e5bc3c
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
167 |
CpPhoneNotes::instance()->showGlobalProgressNote(m_noteid2, |
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
168 |
hbTrId("txt_common_info_requesting")); |
37 | 169 |
QTest::qWait(5000); |
170 |
} |
|
171 |
||
172 |
/*! |
|
173 |
UT_CpPhoneNotes::t_showGlobalNote |
|
174 |
*/ |
|
175 |
void UT_CpPhoneNotes::t_showGlobalNote() |
|
176 |
{ |
|
177 |
CpPhoneNotes::instance()->showGlobalNote(m_noteid1, "MessageTypeQuestion",HbMessageBox::MessageTypeQuestion ); |
|
178 |
CpPhoneNotes::instance()->showGlobalNote(m_noteid2, "MessageTypeInformation",HbMessageBox::MessageTypeInformation); |
|
179 |
CpPhoneNotes::instance()->showGlobalNote(m_noteid3, "MessageTypeWarning",HbMessageBox::MessageTypeWarning ); |
|
180 |
||
181 |
} |
|
182 |
||
183 |
/*! |
|
184 |
UT_CpPhoneNotes::t_showGlobalErrorNote |
|
185 |
*/ |
|
186 |
void UT_CpPhoneNotes::t_showGlobalErrorNote() |
|
187 |
{ |
|
188 |
int errorcode = -1; |
|
189 |
wantedNoteText = ""; |
|
190 |
expect("Tools::errorCodeTextMapping").with(errorcode,wantedNoteText).returns(true); |
|
191 |
CpPhoneNotes::instance()->showGlobalErrorNote(m_noteid1, errorcode ); |
|
192 |
QVERIFY( verify() ); |
|
193 |
||
194 |
} |
|
195 |
||
196 |
||
197 |
/*! |
|
198 |
UT_CpPhoneNotes::t_showCallDivertDetails |
|
199 |
*/ |
|
200 |
void UT_CpPhoneNotes::t_showCallDivertDetails() |
|
201 |
{ |
|
202 |
expect("CpSettingsWrapper::numberGroupingSupported").returns(QVariant(true)); |
|
203 |
PSCallDivertingStatus status; |
|
204 |
CpPhoneNotes::instance()->showCallDivertDetails(status); |
|
205 |
QVERIFY( verify() ); |
|
206 |
||
207 |
expect("CpSettingsWrapper::numberGroupingSupported").returns(QVariant(false)); |
|
208 |
status.iTimeout = 30; |
|
209 |
CpPhoneNotes::instance()->showCallDivertDetails(status); |
|
210 |
QVERIFY( verify() ); |
|
211 |
} |
|
212 |
||
213 |
/*! |
|
214 |
UT_CpPhoneNotes::t_showPasswordQueryDialog |
|
215 |
*/ |
|
216 |
void UT_CpPhoneNotes::t_showPasswordQueryDialog() |
|
217 |
{ |
|
218 |
QString queryTitle("Password query title"); |
|
219 |
QString password = ""; |
|
220 |
bool okPressed = false; |
|
221 |
QRegExp regExpression("\\d{4}"); |
|
222 |
QRegExpValidator validator(regExpression, this); |
|
223 |
CpPhoneNotes::instance()->showPasswordQueryDialog( |
|
224 |
queryTitle, validator, 5); |
|
225 |
||
226 |
} |
|
227 |
||
228 |
||
229 |
/*! |
|
230 |
UT_CpPhoneNotes::t_cancelNote |
|
231 |
*/ |
|
232 |
void UT_CpPhoneNotes::t_cancelNote() |
|
233 |
{ |
|
234 |
CpPhoneNotes::instance()->cancelNote(m_noteid1); |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
235 |
CpPhoneNotes::instance()->showGlobalProgressNote(m_noteid1, "testcancelNote"); |
37 | 236 |
CpPhoneNotes::instance()->noteShowing(); |
237 |
CpPhoneNotes::instance()->cancelNote(m_noteid1); |
|
238 |
||
239 |
QTest::qWait(5000); |
|
240 |
} |
|
241 |
||
242 |
QTEST_MAIN_S60UI(UT_CpPhoneNotes) |