|
1 /* |
|
2 * Copyright (c) 2010 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 test for satappmainhandler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <msatuiobserver.h> |
|
20 #include "ut_playtoneprovider.h" |
|
21 //test class |
|
22 #include "satappplaytoneprovider.h" |
|
23 |
|
24 // ----------------------------------------------------------------------------- |
|
25 // Ut_SatAppPlayToneProvider::Ut_SatAppPlayToneProvider |
|
26 // ----------------------------------------------------------------------------- |
|
27 // |
|
28 Ut_SatAppPlayToneProvider::Ut_SatAppPlayToneProvider(QObject *parent):QObject(parent) |
|
29 { |
|
30 qDebug("Ut_SatAppPlayToneProvider::Ut_SatAppPlayToneProvider >"); |
|
31 qDebug("Ut_SatAppPlayToneProvider::Ut_SatAppPlayToneProvider <"); |
|
32 } |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // Ut_SatAppPlayToneProvider::~Ut_SatAppPlayToneProvider |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 Ut_SatAppPlayToneProvider::~Ut_SatAppPlayToneProvider() |
|
39 { |
|
40 qDebug("Ut_SatAppPlayToneProvider::~Ut_SatAppPlayToneProvider >"); |
|
41 qDebug("Ut_SatAppPlayToneProvider::~Ut_SatAppPlayToneProvider <"); |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // Ut_SatAppPlayToneProvider::initTestCase |
|
46 // QTestLib cleanup method, called after the last testfunction . |
|
47 // ----------------------------------------------------------------------------- |
|
48 void Ut_SatAppPlayToneProvider::initTestCase() |
|
49 { |
|
50 qDebug("Ut_SatAppPlayToneProvider::initTestCase >"); |
|
51 qDebug("Ut_SatAppPlayToneProvider::initTestCase <"); |
|
52 } |
|
53 |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // Ut_SatAppPlayToneProvider::cleanupTestCase |
|
57 // |
|
58 // Connects to test object signal and verifies received data. |
|
59 // ----------------------------------------------------------------------------- |
|
60 void Ut_SatAppPlayToneProvider::cleanupTestCase() |
|
61 { |
|
62 qDebug("Ut_SatAppPlayToneProvider::cleanupTestCase >"); |
|
63 if (mPlayTone) { |
|
64 qDebug("Ut_SatAppPlayToneProvider::cleanupTestCase delete mPlayTone..."); |
|
65 delete mPlayTone; |
|
66 mPlayTone = 0; |
|
67 } |
|
68 qDebug("Ut_SatAppPlayToneProvider::cleanupTestCase <"); |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // Ut_SatAppPlayToneProvider::testCreatePlayTone |
|
73 // |
|
74 // Connects to test object signal and verifies received data. |
|
75 // ----------------------------------------------------------------------------- |
|
76 void Ut_SatAppPlayToneProvider::testCreatePlayTone() |
|
77 { |
|
78 qDebug("Ut_SatAppPlayToneProvider::testCreatePlayTone >"); |
|
79 mPlayTone = new SatAppPlayToneProvider(); |
|
80 QVERIFY(mPlayTone); |
|
81 qDebug("Ut_SatAppPlayToneProvider::testCreatePlayTone <"); |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // Ut_SatAppPlayToneProvider::testPlayStandardTone_data |
|
86 // |
|
87 // Connects to test object signal and verifies received data. |
|
88 // ----------------------------------------------------------------------------- |
|
89 void Ut_SatAppPlayToneProvider::testPlayStandardTone_data() |
|
90 { |
|
91 qDebug("Ut_SatAppPlayToneProvider::testPlayStandardTone_data >"); |
|
92 QTest::addColumn<QString>("text");//enum 0~3 |
|
93 QTest::addColumn<int>("duration"); |
|
94 QTest::addColumn<bool>("isRequestedIconDisplayed"); |
|
95 QTest::addColumn<int>("expectReturnValue"); |
|
96 // test duration 0 |
|
97 QTest::newRow("duration_0") << "Play Standard tone" << 0 << false << 0; |
|
98 QTest::newRow("duration") << "Play Standard tone" << 1000000 << false << 0; |
|
99 QTest::newRow("textnull") << "" << 10000000 << false << 0; |
|
100 qDebug("Ut_SatAppPlayToneProvider::testPlayStandardTone_data <"); |
|
101 } |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // Ut_SatAppPlayToneProvider::testPlayStandardTone |
|
105 // |
|
106 // Connects to test object signal and verifies received data. |
|
107 // ----------------------------------------------------------------------------- |
|
108 void Ut_SatAppPlayToneProvider::testPlayStandardTone() |
|
109 { |
|
110 qDebug("Ut_SatAppPlayToneProvider::testPlayStandardTone >"); |
|
111 QVERIFY(mPlayTone); |
|
112 QFETCH(QString, text); |
|
113 QFETCH(int, duration); |
|
114 QFETCH(bool, isRequestedIconDisplayed); |
|
115 QFETCH(int, expectReturnValue); |
|
116 qDebug("Ut_SatAppPlayToneProvider::testPlayTone after fetch"); |
|
117 // text |
|
118 HBufC* hText = HBufC::New(text.length()); |
|
119 TPtr aText( hText->Des() ); |
|
120 aText.Copy( text.utf16() ); |
|
121 // text |
|
122 _LIT( KPlayToneSequence, "Play tone sequence"); |
|
123 TBuf8<32> aSequence; |
|
124 aSequence.Copy(KPlayToneSequence); |
|
125 |
|
126 // aDuration |
|
127 TUint aDuration= static_cast<TUint>(duration); |
|
128 CFbsBitmap* bitmap(NULL); |
|
129 qDebug("Ut_SatAppPlayToneProvider::testPlayStandardTone call"); |
|
130 TSatUiResponse result(ESatSuccess); |
|
131 TRAPD(err, result = mPlayTone->PlayStandardToneL( |
|
132 aText, |
|
133 aSequence, |
|
134 aDuration, |
|
135 bitmap, |
|
136 isRequestedIconDisplayed)); |
|
137 QCOMPARE(KErrNone, err); |
|
138 TSatUiResponse exValue = static_cast<TSatUiResponse>(expectReturnValue); |
|
139 QCOMPARE(exValue, result); |
|
140 delete hText; |
|
141 qDebug("Ut_SatAppPlayToneProvider::testPlayStandardTone <"); |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // Ut_SatAppPlayToneProvider::testPlayUserSelectedTone_data |
|
146 // |
|
147 // Connects to test object signal and verifies received data. |
|
148 // ----------------------------------------------------------------------------- |
|
149 void Ut_SatAppPlayToneProvider::testPlayUserSelectedTone_data() |
|
150 { |
|
151 qDebug("Ut_SatAppPlayToneProvider::testPlayUserSelectedTone_data >"); |
|
152 QTest::addColumn<QString>("text");//enum 0~3 |
|
153 QTest::addColumn<int>("duration"); |
|
154 QTest::addColumn<int>("satTone"); |
|
155 QTest::addColumn<bool>("isaSelfExplanatory"); |
|
156 QTest::addColumn<int>("expectReturnValue"); |
|
157 //QTest::newRow("duration_0") << "Play UserSelectedTone" << 0 << 1 <<false << 0; |
|
158 QTest::newRow("duration") << "Play UserSelectedTone" << 1000000 << 2 << false << 0; |
|
159 QTest::newRow("true") << "Play UserSelectedTone" << 20000000 << 4 << true << 0; |
|
160 QTest::newRow("textnull") << "" << 10000000 << 3 << true << 0; |
|
161 qDebug("Ut_SatAppPlayToneProvider::testPlayUserSelectedTone_data <"); |
|
162 } |
|
163 |
|
164 // ----------------------------------------------------------------------------- |
|
165 // Ut_SatAppPlayToneProvider::testPlayUserSelectedTone |
|
166 // |
|
167 // Connects to test object signal and verifies received data. |
|
168 // ----------------------------------------------------------------------------- |
|
169 void Ut_SatAppPlayToneProvider::testPlayUserSelectedTone() |
|
170 { |
|
171 qDebug("Ut_SatAppPlayToneProvider::testPlayUserSelectedTone >"); |
|
172 QVERIFY(mPlayTone); |
|
173 QFETCH(QString, text); |
|
174 QFETCH(int, duration); |
|
175 QFETCH(int, satTone); |
|
176 QFETCH(bool, isaSelfExplanatory); |
|
177 QFETCH(int, expectReturnValue); |
|
178 qDebug("Ut_SatAppPlayToneProvider::testPlayTone after fetch"); |
|
179 // text |
|
180 HBufC* hText = HBufC::New(text.length()); |
|
181 TPtr aText( hText->Des() ); |
|
182 aText.Copy( text.utf16() ); |
|
183 // aTone |
|
184 TSatTone aTone = static_cast<TSatTone>(satTone); |
|
185 // aDuration |
|
186 TUint aDuration= static_cast<TUint>(duration); |
|
187 CFbsBitmap* bitmap(NULL); |
|
188 TBool aSelfExplanatory(isaSelfExplanatory); |
|
189 TSatUiResponse result(ESatSuccess); |
|
190 TRAPD(err, result = mPlayTone->PlayUserSelectedToneL( |
|
191 aText, |
|
192 aDuration, |
|
193 aTone, |
|
194 bitmap, |
|
195 aSelfExplanatory )); |
|
196 QCOMPARE(KErrNone, err); |
|
197 delete hText; |
|
198 hText = 0; |
|
199 TSatUiResponse exValue = static_cast<TSatUiResponse>(expectReturnValue); |
|
200 QCOMPARE(exValue, result); |
|
201 qDebug("Ut_SatAppPlayToneProvider::testPlayUserSelectedTone <"); |
|
202 } |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // Ut_SatAppPlayToneProvider::testPlayUserSelectedTone |
|
206 // |
|
207 // Connects to test object signal and verifies received data. |
|
208 // ----------------------------------------------------------------------------- |
|
209 void Ut_SatAppPlayToneProvider::testCloseSatUI() |
|
210 { |
|
211 qDebug("Ut_SatAppPlayToneProvider::closeSatUI >"); |
|
212 QVERIFY(mPlayTone); |
|
213 mPlayTone->closeSatUI(); |
|
214 qDebug("Ut_SatAppPlayToneProvider::closeSatUI <"); |
|
215 } |
|
216 |
|
217 // ----------------------------------------------------------------------------- |
|
218 // Ut_SatAppPlayToneProvider::testPlayUserSelectedTone |
|
219 // |
|
220 // Connects to test object signal and verifies received data. |
|
221 // ----------------------------------------------------------------------------- |
|
222 void Ut_SatAppPlayToneProvider::testClearScreen() |
|
223 { |
|
224 qDebug("Ut_SatAppPlayToneProvider::clearScreen >"); |
|
225 QVERIFY(mPlayTone); |
|
226 mPlayTone->clearScreen(); |
|
227 qDebug("Ut_SatAppPlayToneProvider::clearScreen <"); |
|
228 } |
|
229 |
|
230 // ----------------------------------------------------------------------------- |
|
231 // Ut_SatAppPlayToneProvider::testMapcPlayComplete_data |
|
232 // |
|
233 // Connects to test object signal and verifies received data. |
|
234 // ----------------------------------------------------------------------------- |
|
235 void Ut_SatAppPlayToneProvider::testMapcPlayComplete_data() |
|
236 { |
|
237 qDebug("Ut_SatAppPlayToneProvider::testMapcPlayComplete_data >"); |
|
238 QTest::addColumn<int>("error"); |
|
239 QTest::newRow("error_0") << 0; |
|
240 QTest::newRow("error_-6") << -6; |
|
241 qDebug("Ut_SatAppPlayToneProvider::testMapcPlayComplete_data <"); |
|
242 } |
|
243 |
|
244 // ----------------------------------------------------------------------------- |
|
245 // Ut_SatAppPlayToneProvider::testMapcPlayComplete |
|
246 // |
|
247 // Connects to test object signal and verifies received data. |
|
248 // ----------------------------------------------------------------------------- |
|
249 void Ut_SatAppPlayToneProvider::testMapcPlayComplete() |
|
250 { |
|
251 qDebug("Ut_SatAppPlayToneProvider::testMapcPlayComplete >"); |
|
252 QVERIFY(mPlayTone); |
|
253 QFETCH(int, error); |
|
254 mPlayTone->MapcPlayComplete(error); |
|
255 qDebug("Ut_SatAppPlayToneProvider::testMapcPlayComplete <"); |
|
256 } |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // Ut_SatAppPlayToneProvider::testMapcInitComplete_data |
|
260 // |
|
261 // Connects to test object signal and verifies received data. |
|
262 // ----------------------------------------------------------------------------- |
|
263 void Ut_SatAppPlayToneProvider::testMapcInitComplete_data() |
|
264 { |
|
265 qDebug("Ut_SatAppPlayToneProvider::testMapcInitComplete_data >"); |
|
266 QTest::addColumn<int>("error"); |
|
267 QTest::newRow("error_0") << 0; |
|
268 QTest::newRow("error_-6") << -6; |
|
269 qDebug("Ut_SatAppPlayToneProvider::testMapcInitComplete_data <"); |
|
270 } |
|
271 |
|
272 // ----------------------------------------------------------------------------- |
|
273 // Ut_SatAppPlayToneProvider::testMapcInitComplete |
|
274 // |
|
275 // Connects to test object signal and verifies received data. |
|
276 // ----------------------------------------------------------------------------- |
|
277 void Ut_SatAppPlayToneProvider::testMapcInitComplete() |
|
278 { |
|
279 qDebug("Ut_SatAppPlayToneProvider::testMapcInitComplete >"); |
|
280 QVERIFY(mPlayTone); |
|
281 QFETCH(int, error); |
|
282 mPlayTone->MapcInitComplete(error, 0); |
|
283 qDebug("Ut_SatAppPlayToneProvider::testMapcInitComplete <"); |
|
284 } |
|
285 |
|
286 // End of file |
|
287 |