|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 #include "t_textresourceutils.h" |
|
23 #include <tultextresourceutils.h> |
|
24 #include <tulstringresourcereader.h> |
|
25 #include <t_textresourceutils.rsg> |
|
26 #include <coeutils.h> |
|
27 #include <eikenv.h> |
|
28 |
|
29 #include <apacmdln.h> |
|
30 |
|
31 const TText KLRMarker = 0x200E; |
|
32 const TText KRLMarker = 0x200F; |
|
33 |
|
34 _LIT(KTextResourceUtilsFilePath, "z:\\resource\\apps\\t_textresourceutils.rsc"); |
|
35 |
|
36 CT_TextResourceUtilsAppUi::CT_TextResourceUtilsAppUi(CT_TextResourceUtilsStep& aStep): |
|
37 CTestAppUi(&aStep, KTextResourceUtilsFilePath) |
|
38 { |
|
39 } |
|
40 |
|
41 void CT_TextResourceUtilsAppUi::ConstructL() |
|
42 { |
|
43 CTestAppUi::ConstructL(); |
|
44 AutoTestManager().StartAutoTest(); |
|
45 } |
|
46 |
|
47 CT_TextResourceUtilsAppUi::~CT_TextResourceUtilsAppUi() |
|
48 { |
|
49 Reset(); |
|
50 } |
|
51 |
|
52 void CT_TextResourceUtilsAppUi::Reset() |
|
53 { |
|
54 delete iStringHolder; |
|
55 iStringHolder = NULL; |
|
56 } |
|
57 |
|
58 void CT_TextResourceUtilsAppUi::RunTestStepL(TInt aStep) |
|
59 { |
|
60 switch(aStep) |
|
61 { |
|
62 case 1: |
|
63 SetTestStepID(_L("UIF-ETUL-0015")); |
|
64 TextResourceUtilsCase1(); |
|
65 RecordTestResultL(); |
|
66 break; |
|
67 case 2: |
|
68 SetTestStepID(_L("UIF-ETUL-0016")); |
|
69 TextResourceUtilsCase2(); |
|
70 RecordTestResultL(); |
|
71 break; |
|
72 case 3: |
|
73 SetTestStepID(_L("UIF-ETUL-0017")); |
|
74 TextResourceUtilsCase3(); |
|
75 RecordTestResultL(); |
|
76 break; |
|
77 case 4: |
|
78 SetTestStepID(_L("UIF-ETUL-0018")); |
|
79 TextResourceUtilsCase4(); |
|
80 RecordTestResultL(); |
|
81 break; |
|
82 case 5: |
|
83 SetTestStepID(_L("UIF-ETUL-0019")); |
|
84 TRAPD(err, TextResourceUtilsCase5L()); |
|
85 TEST(err == KErrNone); |
|
86 RecordTestResultL(); |
|
87 break; |
|
88 case 6: |
|
89 SetTestStepID(_L("UIF-ETUL-0020")); |
|
90 TextResourceUtilsCase6(); |
|
91 RecordTestResultL(); |
|
92 break; |
|
93 case 7: |
|
94 SetTestStepID(_L("UIF-ETUL-0021")); |
|
95 TRAP(err, TextResourceUtilsCase7L()); |
|
96 TEST(err == KErrNone); |
|
97 RecordTestResultL(); |
|
98 break; |
|
99 case 8: |
|
100 SetTestStepID(_L("UIF-ETUL-0022")); |
|
101 TRAP(err, TextResourceUtilsCase8L()); |
|
102 TEST(err == KErrNone); |
|
103 RecordTestResultL(); |
|
104 break; |
|
105 case 9: |
|
106 SetTestStepID(_L("UIF-ETUL-0023")); |
|
107 TRAP(err, TestStringResourceReaderCaseL()); |
|
108 TEST(err == KErrNone); |
|
109 RecordTestResultL(); |
|
110 CloseTMSGraphicsStep(); // call after last RecordTestResultL() |
|
111 break; |
|
112 case 10: |
|
113 AutoTestManager().FinishAllTestCases(CAutoTestManager::EPass); |
|
114 break; |
|
115 |
|
116 default: |
|
117 break; |
|
118 } |
|
119 } |
|
120 |
|
121 /** |
|
122 @SYMTestCaseID UIF-ETUL-0015 |
|
123 |
|
124 @SYMREQ 7736 |
|
125 |
|
126 @SYMTestCaseDesc Tests variants of TulTextResourceUtils::LoadLC() and TulTextResourceUtils::LoadL() methods |
|
127 for normal and OOM conditions. |
|
128 |
|
129 @SYMTestPriority High |
|
130 |
|
131 @SYMTestStatus Implemented |
|
132 |
|
133 @SYMTestActions Calls TulTextResourceUtils::LoadL() and LoadLC() to read resource string without any |
|
134 format specifiers from the rss file. |
|
135 |
|
136 @SYMTestExpectedResults The test checks whether |
|
137 1. TulTextResourceUtils::LoadL() loads the correct string from the resource file. |
|
138 2. TulTextResourceUtils::LoadL() loads the string with substring separator correctly. |
|
139 3. OOM test completes without any memory leaks. |
|
140 */ |
|
141 void CT_TextResourceUtilsAppUi::TextResourceUtilsCase1() |
|
142 { |
|
143 CEikonEnv* eikonEnv = CEikonEnv::Static(); |
|
144 |
|
145 INFO_PRINTF1(_L("Test to read resource string from the rss file")); |
|
146 |
|
147 HBufC* buf = NULL; |
|
148 TRAPD(ret, buf = TulTextResourceUtils::LoadLC(R_TEXT_EXAMPLE_1); CleanupStack::Pop(buf)); |
|
149 TEST(ret == KErrNone && buf->Compare(_L("Humblemumble")) == 0); |
|
150 delete buf; |
|
151 |
|
152 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_B)); |
|
153 TEST(ret == KErrNone && iStringHolder->Compare(_L("Humble mumble")) == 0); |
|
154 Reset(); |
|
155 |
|
156 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_B, eikonEnv)); |
|
157 TEST(ret == KErrNone && iStringHolder->Compare(_L("Humble mumble")) == 0); |
|
158 Reset(); |
|
159 |
|
160 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_B)); |
|
161 TEST(ret == KErrNone && iStringHolder->Compare(_L("Humble mumble")) == 0); |
|
162 Reset(); |
|
163 |
|
164 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_NEW_1)); |
|
165 TEST(ret == KErrNone && iStringHolder->Compare(_L("Substrings\001no param\neters\001at all")) == 0); |
|
166 Reset(); |
|
167 |
|
168 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_NEW_2)); |
|
169 TEST(ret == KErrNone && iStringHolder->Compare( _L("\001")) == 0); |
|
170 Reset(); |
|
171 |
|
172 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_NEW_3)); |
|
173 TEST(ret == KErrNone && iStringHolder->Compare( _L("\001\001")) == 0); |
|
174 Reset(); |
|
175 |
|
176 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_NEW_4)); |
|
177 TEST(ret == KErrNone && iStringHolder->Compare( _L("\001Substring inside\001")) ==0); |
|
178 Reset(); |
|
179 |
|
180 // Test LoadL(TInt aResourceId, CCoeEnv* aLoaderEnv); for out of memory conditions. |
|
181 for (TInt fail = 1;; fail++) |
|
182 { |
|
183 __UHEAP_SETFAIL(RHeap::EDeterministic, fail); |
|
184 __UHEAP_MARK; |
|
185 |
|
186 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_B, eikonEnv)); |
|
187 TEST((ret==KErrNone || ret==KErrNoMemory)); |
|
188 if (ret == KErrNone) |
|
189 { |
|
190 TEST(iStringHolder->Compare(_L("Humble mumble")) == 0); |
|
191 Reset(); |
|
192 __UHEAP_MARKEND; |
|
193 break; |
|
194 } |
|
195 __UHEAP_MARKEND; |
|
196 } |
|
197 __UHEAP_RESET; |
|
198 } |
|
199 |
|
200 /** |
|
201 @SYMTestCaseID UIF-ETUL-0016 |
|
202 |
|
203 @SYMREQ 7736 |
|
204 |
|
205 @SYMTestCaseDesc Tests variants of TulTextResourceUtils::LoadL() and LoadLC() methods for normal and OOM conditions. |
|
206 |
|
207 @SYMTestPriority High |
|
208 |
|
209 @SYMTestStatus Implemented |
|
210 |
|
211 @SYMTestActions Calls TulTextResourceUtils::LoadL() and LoadLC() to read a resource string from rss file, |
|
212 and replace the first %U-string in it with replacement string. |
|
213 |
|
214 @SYMTestExpectedResults The test checks whether |
|
215 1. TulTextResourceUtils::LoadL() and LoadLC() loads the correct string from the resource file and replaces |
|
216 the first %U with specified string. |
|
217 2. OOM completes without any memory leaks. |
|
218 */ |
|
219 void CT_TextResourceUtilsAppUi::TextResourceUtilsCase2() |
|
220 { |
|
221 INFO_PRINTF1(_L("Test to read a resource string from rss file, and replace the first %%U-string in it with replacement string")); |
|
222 |
|
223 CEikonEnv* eikonEnv = CEikonEnv::Static(); |
|
224 TRAPD(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_2, _L("and"))); |
|
225 TEST(ret == KErrNone && iStringHolder->Compare(_L("Humble %and mumble")) == 0); |
|
226 Reset(); |
|
227 |
|
228 HBufC* buf = NULL; |
|
229 TRAP(ret, buf = TulTextResourceUtils::LoadLC(R_TEXT_EXAMPLE_A2, _L("and"), eikonEnv); CleanupStack::Pop(buf)); |
|
230 TEST(ret == KErrNone && buf->Compare(_L("and Humble mumble")) == 0); |
|
231 delete buf; |
|
232 |
|
233 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_A2, _L("I will"), eikonEnv)); |
|
234 TEST(ret == KErrNone && iStringHolder->Compare(_L("I will Humble mumble")) == 0); |
|
235 Reset(); |
|
236 |
|
237 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_A1, _L(" is nice."), eikonEnv)); |
|
238 TEST(ret == KErrNone && iStringHolder->Compare(_L("Humble mumble is nice.")) == 0); |
|
239 Reset(); |
|
240 |
|
241 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_2, _L("hilipatipilipatipippampaajarallatirallatirallallaatervemoroheipäheimulonmunatsullaei"))); |
|
242 TEST(ret == KErrNone && iStringHolder->Compare(_L("Humble %hilipatipilipatipippampaajarallatirallatirallallaatervemoroheipäheimulonmunatsullaei mumble")) == 0); |
|
243 Reset(); |
|
244 |
|
245 TRAP(ret, iStringHolder = iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_2, _L(""))); |
|
246 TEST(ret == KErrNone && iStringHolder->Compare(_L("Humble % mumble")) == 0); |
|
247 Reset(); |
|
248 |
|
249 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_10, _L("string"), eikonEnv)); |
|
250 TEST(ret == KErrNone && iStringHolder->Compare(_L("Testing substring separator at end of the string ")) == 0); |
|
251 Reset(); |
|
252 |
|
253 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_11, _L("string"), eikonEnv)); |
|
254 TEST(ret == KErrNone && iStringHolder->Compare(_L("Testing substring separator at end of the string \001 ")) == 0); |
|
255 Reset(); |
|
256 |
|
257 for (TInt fail = 1;; fail++) |
|
258 { |
|
259 __UHEAP_SETFAIL(RHeap::EDeterministic, fail); |
|
260 __UHEAP_MARK; |
|
261 |
|
262 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_2, _L("a"))); |
|
263 TEST((ret==KErrNone || ret==KErrNoMemory)); |
|
264 if (ret == KErrNone) |
|
265 { |
|
266 TEST(iStringHolder->Compare(_L("Humble %a mumble")) == 0); |
|
267 Reset(); |
|
268 __UHEAP_MARKEND; |
|
269 break; |
|
270 } |
|
271 __UHEAP_MARKEND; |
|
272 } |
|
273 __UHEAP_RESET; |
|
274 } |
|
275 |
|
276 /** |
|
277 @SYMTestCaseID UIF-ETUL-0017 |
|
278 |
|
279 @SYMREQ 7736 |
|
280 |
|
281 @SYMTestCaseDesc Tests variants of TulTextResourceUtils::Load() and TulTextResourceUtils::Format() methods under |
|
282 normal and OOM conditions. |
|
283 |
|
284 @SYMTestPriority High |
|
285 |
|
286 @SYMTestStatus Implemented |
|
287 |
|
288 @SYMTestActions Calls TulTextResourceUtils::LoadL() to read a resource string from rss file, and |
|
289 calls TulTextResourceUtils::Format() method to format the same string. |
|
290 |
|
291 @SYMTestExpectedResults The test checks whether |
|
292 1. TulTextResourceUtils::LoadL() loads the correct string from the resource file. |
|
293 2. TulTextResourceUtils::Format() replaces all %U specifiers with specified string if position given is -1 |
|
294 3. TulTextResourceUtils::Format() replaces all %N specifiers with specified number if position given is -1. |
|
295 4. TulTextResourceUtils::Format() replaces corresponding %U specifiers with specified string if position given is other than -1 |
|
296 5. TulTextResourceUtils::Format() replaces corresponding %N specifiers with specified number if position given is other than -1 |
|
297 6. OOM test completes without any memory leak. |
|
298 */ |
|
299 void CT_TextResourceUtilsAppUi::TextResourceUtilsCase3() |
|
300 { |
|
301 INFO_PRINTF1(_L("Test to read a resource string from rss file, and to format the string")); |
|
302 |
|
303 TBuf<50> buffer1; |
|
304 TBuf<50> buffer2; |
|
305 |
|
306 CEikonEnv* eikonEnv = CEikonEnv::Static(); |
|
307 TulTextResourceUtils::Load(buffer1, R_TEXT_EXAMPLE_8, eikonEnv); |
|
308 TulTextResourceUtils::Format(buffer2, buffer1, -1, _L("either")); |
|
309 TEST(buffer2.Compare(_L("Here either")) == 0); |
|
310 |
|
311 TulTextResourceUtils::Load(buffer1, R_TEXT_EXAMPLE_9); |
|
312 TulTextResourceUtils::Format(buffer2, buffer1, -1, 10); |
|
313 TEST(buffer2.Compare(_L("Humble 10 times...%")) == 0); |
|
314 |
|
315 TulTextResourceUtils::Load(buffer1, R_TEXT_EXAMPLE_D); |
|
316 TEST(buffer1.Compare(_L("No memory allocated")) == 0); |
|
317 |
|
318 TulTextResourceUtils::Load(buffer2, R_TEXT_EXAMPLE_E); |
|
319 TulTextResourceUtils::Format(buffer1, buffer2, 2, _L("Really? ")); |
|
320 buffer2.Zero(); |
|
321 TulTextResourceUtils::Format(buffer2, buffer1, 1, _L("allocated ")); |
|
322 buffer1.Zero(); |
|
323 TulTextResourceUtils::Format(buffer1, buffer2, 0, _L("nothing")); |
|
324 TEST(buffer1.Compare(_L("Really? Here allocated nothing ")) == 0); |
|
325 |
|
326 TulTextResourceUtils::Load(buffer1, R_TEXT_EXAMPLE_G); |
|
327 TulTextResourceUtils::Format(buffer2, buffer1, 3, 6); |
|
328 buffer1.Zero(); |
|
329 TulTextResourceUtils::Format(buffer1, buffer2, 2, 567); |
|
330 buffer2.Zero(); |
|
331 TulTextResourceUtils::Format(buffer2, buffer1, 1, 9); |
|
332 buffer1.Zero(); |
|
333 TulTextResourceUtils::Format(buffer1, buffer2, 0, 7); |
|
334 TEST(buffer1.Compare(_L("6I 9allocated 7 bytes567")) == 0); |
|
335 |
|
336 buffer1.Zero(); |
|
337 buffer2.Zero(); |
|
338 TulTextResourceUtils::Load(buffer1, R_TEXT_EXAMPLE_8, eikonEnv); |
|
339 TInt fail = 0; |
|
340 for (fail = 1; ; fail++) |
|
341 { |
|
342 __UHEAP_SETFAIL(RHeap::EDeterministic, fail); |
|
343 __UHEAP_MARK; |
|
344 TulTextResourceUtils::Format(buffer2, buffer1, -1, _L("either")); |
|
345 if (buffer2.Length()) |
|
346 { |
|
347 __UHEAP_RESET; // TEST result will not be displayed correctly if the memory allocation is not reset. |
|
348 TEST(buffer2.Compare(_L("Here either")) == 0); |
|
349 __UHEAP_MARKEND; |
|
350 break; |
|
351 } |
|
352 __UHEAP_MARKEND; |
|
353 } |
|
354 |
|
355 __UHEAP_RESET; |
|
356 buffer1.Zero(); |
|
357 buffer2.Zero(); |
|
358 TulTextResourceUtils::Load(buffer1, R_TEXT_EXAMPLE_F); |
|
359 for (fail = 1; ; fail++) |
|
360 { |
|
361 __UHEAP_SETFAIL(RHeap::EDeterministic, fail); |
|
362 __UHEAP_MARK; |
|
363 TulTextResourceUtils::Format(buffer2, buffer1, -1, 7); |
|
364 if (buffer2.Length()) |
|
365 { |
|
366 __UHEAP_RESET; // TEST result will not be displayed correctly if the memory allocation is not reset. |
|
367 TEST(buffer2.Compare(_L("I allocated 7 bytes")) == 0); |
|
368 __UHEAP_MARKEND; |
|
369 break; |
|
370 } |
|
371 __UHEAP_MARKEND; |
|
372 } |
|
373 __UHEAP_RESET; |
|
374 } |
|
375 |
|
376 /** |
|
377 @SYMTestCaseID UIF-ETUL-0018 |
|
378 |
|
379 @SYMREQ 7736 |
|
380 |
|
381 @SYMTestCaseDesc Tests variants of TulTextResourceUtils::LoadL() and LoadLC() methods for normal and OOM conditions. |
|
382 |
|
383 @SYMTestPriority High |
|
384 |
|
385 @SYMTestStatus Implemented |
|
386 |
|
387 @SYMTestActions Calls TulTextResourceUtils::LoadL() and LoadLC() to read resource string from the rss file |
|
388 and to replace the first %%(index)N-string with replacement TInt. |
|
389 |
|
390 @SYMTestExpectedResults The test checks whether |
|
391 1. TulTextResourceUtils::LoadL() and LoadLC() loads the correct string from the resource file and replaces |
|
392 the first %%(index)N-string in it with replacement TInt. |
|
393 2. OOM test completes without any memory leaks. |
|
394 */ |
|
395 void CT_TextResourceUtilsAppUi::TextResourceUtilsCase4() |
|
396 { |
|
397 TInt number(324); |
|
398 CEikonEnv* eikonEnv = CEikonEnv::Static(); |
|
399 |
|
400 INFO_PRINTF1(_L("Test to read resource string from the rss file and to replace the first %%(index)N-string in it with replacement TInt")); |
|
401 HBufC* buf = NULL; |
|
402 TRAPD(ret, buf = TulTextResourceUtils::LoadLC(R_TEXT_EXAMPLE_3, number, eikonEnv); CleanupStack::Pop(buf)); |
|
403 TEST(ret == KErrNone && buf->Compare(_L("You have %R324 undone tasks.")) == 0); |
|
404 delete buf; |
|
405 |
|
406 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_9, 123456789, eikonEnv)); |
|
407 TEST(ret == KErrNone && iStringHolder->Compare(_L("Humble 123456789 times...%")) == 0); |
|
408 Reset(); |
|
409 |
|
410 // Test LoadL(TInt aResourceId, TInt aNumber, CCoeEnv* aLoaderEnv = NULL); for out of memory conditions. |
|
411 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_9, -12345, eikonEnv)); |
|
412 TEST(ret == KErrNone && iStringHolder->Compare(_L("Humble -12345 times...%")) == 0); |
|
413 Reset(); |
|
414 |
|
415 for (TInt fail = 1;; fail++) |
|
416 { |
|
417 __UHEAP_SETFAIL(RHeap::EDeterministic, fail); |
|
418 __UHEAP_MARK; |
|
419 |
|
420 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_3, number)); |
|
421 TEST((ret==KErrNone || ret==KErrNoMemory)); |
|
422 if (ret == KErrNone) |
|
423 { |
|
424 TEST(iStringHolder->Compare(_L("You have %R324 undone tasks.")) == 0); |
|
425 Reset(); |
|
426 __UHEAP_MARKEND; |
|
427 break; |
|
428 } |
|
429 __UHEAP_MARKEND; |
|
430 } |
|
431 __UHEAP_RESET; |
|
432 } |
|
433 |
|
434 /** |
|
435 @SYMTestCaseID UIF-ETUL-0019 |
|
436 |
|
437 @SYMREQ 7736 |
|
438 |
|
439 @SYMTestCaseDesc Tests variants of TulTextResourceUtils::LoadL() and LoadLC() methods for normal and OOM conditions. |
|
440 |
|
441 @SYMTestPriority High |
|
442 |
|
443 @SYMTestStatus Implemented |
|
444 |
|
445 @SYMTestActions Calls TulTextResourceUtils::LoadL() and LoadLC() methods to read resource string from the rss file and |
|
446 to replace the %%(index)U-strings with replacement strings from an array |
|
447 |
|
448 @SYMTestExpectedResults The test checks whether |
|
449 1. TulTextResourceUtils::LoadL() and LoadLC() loads the correct string from the resource file |
|
450 and replaces the %%(index)U-strings in it with replacement strings from the array. |
|
451 2. TulTextResourceUtils::LoadL() loads the string which has strictly right-to-left directional characters in substring |
|
452 3. TulTextResourceUtils::LoadL() loads the string with KDirNotFound and substring separator |
|
453 4. OOM test completes without any memory leaks. |
|
454 */ |
|
455 void CT_TextResourceUtilsAppUi::TextResourceUtilsCase5L() |
|
456 { |
|
457 CDesCArrayFlat* strings = new (ELeave)CDesCArrayFlat(4); |
|
458 CleanupStack::PushL(strings); |
|
459 |
|
460 INFO_PRINTF1(_L("Test to read a resource string from the rss file and to replace the %%(index)U-strings in it with replacement strings from an array")); |
|
461 |
|
462 strings->AppendL(_L("orking")); //First string |
|
463 strings->AppendL(_L("ll")); //Second string |
|
464 strings->AppendL(_L("sti")); //Third string |
|
465 strings->AppendL(_L("w")); //Fourth string |
|
466 |
|
467 CEikonEnv* eikonEnv = CEikonEnv::Static(); |
|
468 HBufC* buf = NULL; |
|
469 TRAPD(ret, buf = TulTextResourceUtils::LoadLC(R_TEXT_EXAMPLE_4, *strings, eikonEnv); CleanupStack::Pop(buf)); |
|
470 TEST(ret == KErrNone && buf->Compare(_L("I'm %11 still working fine.")) == 0); |
|
471 delete buf; |
|
472 |
|
473 // Test LoadL(TInt aResourceId, const MDesCArray& aStrings, CCoeEnv* aLoaderEnv = NULL); for out of memory conditions. |
|
474 for (TInt fail = 1;; fail++) |
|
475 { |
|
476 __UHEAP_SETFAIL(RHeap::EDeterministic, fail); |
|
477 __UHEAP_MARK; |
|
478 |
|
479 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_4, *strings)); |
|
480 TEST((ret==KErrNone || ret==KErrNoMemory)); |
|
481 if (ret == KErrNone) |
|
482 { |
|
483 __UHEAP_RESET; // TEST result will not be displayed correctly if the memory allocation is not reset. |
|
484 TEST(iStringHolder->Compare(_L("I'm %11 still working fine.")) == 0); |
|
485 Reset(); |
|
486 __UHEAP_MARKEND; |
|
487 break; |
|
488 } |
|
489 __UHEAP_MARKEND; |
|
490 } |
|
491 |
|
492 __UHEAP_RESET; |
|
493 // strongly right-to-left directional characters in substring |
|
494 TBuf<10> substring; |
|
495 substring.Append(TChar(0x062C)); |
|
496 substring.Append(TChar(0x0639)); |
|
497 substring.Append(TChar(0x0644)); |
|
498 |
|
499 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_NEW_5, substring)); |
|
500 TEST(ret == KErrNone); |
|
501 |
|
502 TBuf<100> compareBuffer; |
|
503 compareBuffer.Append(KLRMarker); |
|
504 compareBuffer.Append(_L("Strongly right-to-left(")); |
|
505 compareBuffer.Append(KRLMarker); |
|
506 compareBuffer.Append(substring); |
|
507 compareBuffer.Append(KRLMarker); |
|
508 compareBuffer.Append(_L(") directional\001")); |
|
509 compareBuffer.Append(KLRMarker); |
|
510 compareBuffer.Append(_L(" characters (")); |
|
511 compareBuffer.Append(KRLMarker); |
|
512 compareBuffer.Append(substring); |
|
513 compareBuffer.Append(KRLMarker); |
|
514 compareBuffer.Append(_L(") in \001")); |
|
515 compareBuffer.Append(KLRMarker); |
|
516 compareBuffer.Append(_L("substring")); |
|
517 TEST(iStringHolder->Compare(compareBuffer) == 0); |
|
518 Reset(); |
|
519 |
|
520 compareBuffer.Insert(1, _L(" ")); |
|
521 compareBuffer.Append(_L("\x0001")); |
|
522 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_NEW_8, substring, eikonEnv)); |
|
523 TEST(ret == KErrNone && iStringHolder->Compare(compareBuffer) == 0); |
|
524 Reset(); |
|
525 |
|
526 compareBuffer.Delete(0, 2); |
|
527 compareBuffer.Insert(0, _L("\x0002 ")); |
|
528 compareBuffer.Delete(compareBuffer.Length()-1, 6); |
|
529 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_NEW_9, substring, eikonEnv)); |
|
530 TEST(ret == KErrNone && iStringHolder->Compare(compareBuffer) == 0); |
|
531 Reset(); |
|
532 |
|
533 strings->Reset(); |
|
534 strings->AppendL(_L("1234567890")); |
|
535 strings->AppendL(_L("ABCDEFGHIJ")); |
|
536 strings->AppendL(_L("?/*")); |
|
537 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_NEW_7, *strings)); |
|
538 TEST(ret == KErrNone); |
|
539 // "Testing string length limiting Five:%0U[05] Three:%1U[03]\001Seven:%0U[07] Nine:%1U[09] Three:%2U[03]" |
|
540 compareBuffer.Zero(); |
|
541 compareBuffer.Append(_L("Testing string length limiting Five:1234")); |
|
542 compareBuffer.Append(KEllipsis); |
|
543 compareBuffer.Append(_L(" Three:AB")); |
|
544 compareBuffer.Append(KEllipsis); |
|
545 compareBuffer.Append(_L("\001Seven:123456")); |
|
546 compareBuffer.Append(KEllipsis); |
|
547 compareBuffer.Append(_L(" Nine:ABCDEFGH")); |
|
548 compareBuffer.Append(KEllipsis); |
|
549 compareBuffer.Append(_L(" Three:?/*")); |
|
550 TEST(iStringHolder->Compare(compareBuffer) == 0); |
|
551 Reset(); |
|
552 |
|
553 CleanupStack::PopAndDestroy(); |
|
554 } |
|
555 |
|
556 /** |
|
557 @SYMTestCaseID UIF-ETUL-0020 |
|
558 |
|
559 @SYMREQ 7736 |
|
560 |
|
561 @SYMTestCaseDesc Tests variants of TulTextResourceUtils::LoadL() and LoadLC() methods for normal and OOM conditions. |
|
562 |
|
563 @SYMTestPriority High |
|
564 |
|
565 @SYMTestStatus Implemented |
|
566 |
|
567 @SYMTestActions Calls TulTextResourceUtils::LoadL() and LoadLC() to read resource string from the rss file and to |
|
568 replace the first %%(index)N-string with replacement TInt and the first %%(index)U-string with replacement string |
|
569 |
|
570 @SYMTestExpectedResults The test checks whether |
|
571 1. TulTextResourceUtils::LoadL() and LoadLC() loads the correct string from the resource file and replaces |
|
572 a. The first %%(index)N-string with replacement TInt |
|
573 b. The first %%(index)U-string with replacement string. |
|
574 2. OOM tests completes without any memory leaks. |
|
575 */ |
|
576 void CT_TextResourceUtilsAppUi::TextResourceUtilsCase6() |
|
577 { |
|
578 TInt number2(12); |
|
579 _LIT(name, "John Doe"); |
|
580 |
|
581 INFO_PRINTF1(_L("Test to read resource string from the rss file and replace the first %%(index)N-string in it with replacement TInt and the first %%(index)U-string in it with replacement string")); |
|
582 |
|
583 CEikonEnv* eikonEnv = CEikonEnv::Static(); |
|
584 HBufC* buf = NULL; |
|
585 TRAPD(ret, buf = TulTextResourceUtils::LoadLC(R_TEXT_EXAMPLE_5, name, number2, eikonEnv); CleanupStack::Pop(buf)); |
|
586 TEST(ret == KErrNone && buf->Compare(_L("You have missed 12 messages from John Doe.\001Missed 12 msgs from John Doe.\001Missed 12 msgs.")) == 0); |
|
587 delete buf; |
|
588 |
|
589 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_C, _L("and"), 68365)); |
|
590 TEST(ret == KErrNone && iStringHolder->Compare(_L("and mumble 68365 times.")) == 0); |
|
591 Reset(); |
|
592 |
|
593 // Test LoadL(TInt aResourceId, const TDesC& aString, TInt aInt, CCoeEnv* aLoaderEnv = NULL); for out of memory conditions. |
|
594 for (TInt fail = 1;; fail++) |
|
595 { |
|
596 __UHEAP_SETFAIL(RHeap::EDeterministic, fail); |
|
597 __UHEAP_MARK; |
|
598 |
|
599 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_5, name, number2)); |
|
600 TEST((ret==KErrNone || ret==KErrNoMemory)); |
|
601 if (ret == KErrNone) |
|
602 { |
|
603 TEST(iStringHolder->Compare(_L("You have missed 12 messages from John Doe.\001Missed 12 msgs from John Doe.\001Missed 12 msgs.")) == 0); |
|
604 Reset(); |
|
605 __UHEAP_MARKEND; |
|
606 break; |
|
607 } |
|
608 __UHEAP_MARKEND; |
|
609 } |
|
610 __UHEAP_RESET; |
|
611 } |
|
612 |
|
613 /** |
|
614 @SYMTestCaseID UIF-ETUL-0021 |
|
615 |
|
616 @SYMREQ 7736 |
|
617 |
|
618 @SYMTestCaseDesc Tests variants of TulTextResourceUtils::LoadL() and LoadLC() methods for normal and OOM conditions. |
|
619 |
|
620 @SYMTestPriority High |
|
621 |
|
622 @SYMTestStatus Implemented |
|
623 |
|
624 @SYMTestActions Calls TulTextResourceUtils::LoadL() and LoadLC() to read resource string from the rss file and to |
|
625 replace the %%(index)N-strings with replacement TInts from the given array. |
|
626 |
|
627 @SYMTestExpectedResults The test checks whether |
|
628 1. TulTextResourceUtils::LoadL() and LoadLC() loads the correct string from the resource file and |
|
629 replaces the %%(index)N-strings with replacement TInts from the given array. |
|
630 2. OOM tests completes without any memory leaks. |
|
631 */ |
|
632 void CT_TextResourceUtilsAppUi::TextResourceUtilsCase7L() |
|
633 { |
|
634 CArrayFix<TInt>* numberArray = new(ELeave)CArrayFixFlat<TInt>(3); |
|
635 CleanupStack::PushL(numberArray); |
|
636 |
|
637 numberArray->AppendL(1); // First Integer |
|
638 numberArray->AppendL(2); // Second Integer |
|
639 |
|
640 INFO_PRINTF1(_L("Test to read resource string from the rss file and replaces the %%(index)N-strings in it with replacement TInts from an array")); |
|
641 |
|
642 CEikonEnv* eikonEnv = CEikonEnv::Static(); |
|
643 HBufC* buf = NULL; |
|
644 TRAPD(ret, buf = TulTextResourceUtils::LoadLC(R_TEXT_EXAMPLE_6, *numberArray, eikonEnv); CleanupStack::Pop(buf)); |
|
645 TEST(ret == KErrNone && buf->Compare(_L("Multiple numeric 1:%2N indexes 1:1\x0001\x0032:2 in separate\x0001substrings")) == 0); |
|
646 delete buf; |
|
647 |
|
648 numberArray->AppendL(3); // Third Integer |
|
649 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_6, *numberArray, eikonEnv)); |
|
650 TEST(ret == KErrNone && iStringHolder->Compare(_L("Multiple numeric 1:3 indexes 1:1\x0001\x0032:2 in separate\x0001substrings")) == 0); |
|
651 Reset(); |
|
652 |
|
653 // Test LoadL(TInt aResourceId, const CArrayFix<TInt>& aInts, CCoeEnv* aLoaderEnv = NULL); for out of memory conditions. |
|
654 for (TInt fail = 1;; fail++) |
|
655 { |
|
656 __UHEAP_SETFAIL(RHeap::EDeterministic, fail); |
|
657 __UHEAP_MARK; |
|
658 |
|
659 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_6, *numberArray)); |
|
660 TEST((ret==KErrNone || ret==KErrNoMemory)); |
|
661 if (ret == KErrNone) |
|
662 { |
|
663 TEST(iStringHolder->Compare(_L("Multiple numeric 1:3 indexes 1:1\x0001\x0032:2 in separate\x0001substrings")) == 0); |
|
664 Reset(); |
|
665 __UHEAP_MARKEND; |
|
666 break; |
|
667 } |
|
668 __UHEAP_MARKEND; |
|
669 } |
|
670 __UHEAP_RESET; |
|
671 CleanupStack::PopAndDestroy(); |
|
672 } |
|
673 |
|
674 /** |
|
675 @SYMTestCaseID UIF-ETUL-0022 |
|
676 |
|
677 @SYMREQ 7736 |
|
678 |
|
679 @SYMTestCaseDesc Tests variants of TulTextResourceUtils::LoadL() and TulTextResourceUtils::LoadLC() |
|
680 methods for normal and OOM conditions. |
|
681 |
|
682 @SYMTestPriority High |
|
683 |
|
684 @SYMTestStatus Implemented |
|
685 |
|
686 @SYMTestActions Calls TulTextResourceUtils::LoadL() to read resource string without any format specifiers from the rss file |
|
687 and to replace the %%(index)U-strings with replacement strings from the give array and |
|
688 the %%(index)N-strings with replacement TInts from an array |
|
689 |
|
690 @SYMTestExpectedResults The test checks whether |
|
691 1. TulTextResourceUtils::LoadL() loads the correct string from the resource file and replaces the |
|
692 a. %%(index)U-strings with replacement strings from the given array of strings |
|
693 b. %%(index)N-strings with replacement strings from the given TInt array |
|
694 2. TulTextResourceUtils::LoadL() loads the string which has multiple strictly right-to-left directional characters |
|
695 in substring |
|
696 3. OOM tests completes without any memory leaks. |
|
697 */ |
|
698 void CT_TextResourceUtilsAppUi::TextResourceUtilsCase8L() |
|
699 { |
|
700 INFO_PRINTF1(_L("Test to read a resource string from the rss file and to replace the %%(index)U-strings in it with replacement strings from an array & the %%(index)N-strings in it with replacement TInts from an array")); |
|
701 |
|
702 CEikonEnv* eikonEnv = CEikonEnv::Static(); |
|
703 CArrayFix<TInt>* numberArray = new(ELeave)CArrayFixFlat<TInt>(2); |
|
704 CleanupStack::PushL(numberArray); |
|
705 |
|
706 numberArray->AppendL(5); // First Integer |
|
707 numberArray->AppendL(2); // Second Integer |
|
708 |
|
709 CDesCArrayFlat* strings = new (ELeave)CDesCArrayFlat(5); |
|
710 CleanupStack::PushL(strings); |
|
711 |
|
712 strings->AppendL(_L("for")); //First string |
|
713 strings->AppendL(_L("Test")); //Second string |
|
714 strings->AppendL(_L("strings")); //Third string |
|
715 strings->AppendL(_L("numerics")); //Fourth string |
|
716 strings->AppendL(_L("and")); //Fifth string |
|
717 |
|
718 HBufC* buf = NULL; |
|
719 TRAPD(ret, buf = TulTextResourceUtils::LoadLC(R_TEXT_EXAMPLE_7, *strings, *numberArray, eikonEnv); CleanupStack::Pop(buf)); |
|
720 TEST(ret == KErrNone); |
|
721 TEST(buf->Compare(_L("Multiple numeric and strings mixed One: Test for reading 5 strings and 2 numerics %4")) == 0); |
|
722 delete buf; |
|
723 |
|
724 // Test LoadL(TInt aResourceId, const MDesCArray& aStrings, const CArrayFix<TInt>& aInts, CCoeEnv* aLoaderEnv = NULL); for out of memory conditions. |
|
725 for (TInt fail = 1;; fail++) |
|
726 { |
|
727 __UHEAP_SETFAIL(RHeap::EDeterministic, fail); |
|
728 __UHEAP_MARK; |
|
729 |
|
730 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_7, *strings, *numberArray)); |
|
731 TEST((ret==KErrNone || ret==KErrNoMemory)); |
|
732 if (ret == KErrNone) |
|
733 { |
|
734 __UHEAP_RESET; // TEST result will not be displayed correctly if the memory allocation is not reset. |
|
735 TEST(iStringHolder->Compare(_L("Multiple numeric and strings mixed One: Test for reading 5 strings and 2 numerics %4")) == 0); |
|
736 Reset(); |
|
737 __UHEAP_MARKEND; |
|
738 break; |
|
739 } |
|
740 __UHEAP_MARKEND; |
|
741 } |
|
742 |
|
743 __UHEAP_RESET; |
|
744 strings->Reset(); |
|
745 numberArray->Reset(); |
|
746 // strongly right-to-left directional characters in substring |
|
747 TBuf<10> substring; |
|
748 TBuf<10> substring2; |
|
749 |
|
750 substring.Append(TChar(0x062C)); |
|
751 substring.Append(TChar(0x0639)); |
|
752 substring.Append(TChar(0x0644)); |
|
753 |
|
754 substring2.Append(TChar(0x0644)); |
|
755 substring2.Append(TChar(0x0639)); |
|
756 substring2.Append(TChar(0x062C)); |
|
757 |
|
758 strings->AppendL(substring); |
|
759 strings->AppendL(substring2); |
|
760 numberArray->AppendL(2); |
|
761 |
|
762 TRAP(ret, iStringHolder = TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_NEW_6, *strings, *numberArray)); |
|
763 TEST(ret == KErrNone); |
|
764 |
|
765 TBuf<150> compareBuffer; |
|
766 //"Multiple (%2N) Strongly right-to-left(%0U,%1U) directional\001 characters (%1U)(%0U) in \001substring" |
|
767 compareBuffer.Append(KLRMarker); |
|
768 compareBuffer.Append(_L("Multiple (2) Strongly right-to-left(")); |
|
769 compareBuffer.Append(KRLMarker); |
|
770 compareBuffer.Append(substring); |
|
771 compareBuffer.Append(KRLMarker); |
|
772 compareBuffer.Append(_L(",")); |
|
773 compareBuffer.Append(KRLMarker); |
|
774 compareBuffer.Append(substring2); |
|
775 compareBuffer.Append(KRLMarker); |
|
776 compareBuffer.Append(_L(") directional\001")); |
|
777 compareBuffer.Append(KLRMarker); |
|
778 compareBuffer.Append(_L(" characters (")); |
|
779 compareBuffer.Append(KRLMarker); |
|
780 compareBuffer.Append(substring2); |
|
781 compareBuffer.Append(KRLMarker); |
|
782 compareBuffer.Append(_L(")(")); |
|
783 compareBuffer.Append(KRLMarker); |
|
784 compareBuffer.Append(substring); |
|
785 compareBuffer.Append(KRLMarker); |
|
786 compareBuffer.Append(_L(") in \001")); |
|
787 compareBuffer.Append(KLRMarker); |
|
788 compareBuffer.Append(_L("substring")); |
|
789 TEST(iStringHolder->Compare(compareBuffer) == 0); |
|
790 Reset(); |
|
791 |
|
792 CleanupStack::PopAndDestroy(2); |
|
793 } |
|
794 |
|
795 /** |
|
796 @SYMTestCaseID UIF-ETUL-0023 |
|
797 |
|
798 @SYMREQ 7736 |
|
799 |
|
800 @SYMTestCaseDesc Tests variants of CTulStringResourceReader::NewLC() and NewL() methods and |
|
801 CTulStringResourceReader::ReadResourceString() method for normal and OOM conditions. |
|
802 |
|
803 @SYMTestPriority High |
|
804 |
|
805 @SYMTestStatus Implemented |
|
806 |
|
807 @SYMTestActions Calls CTulStringResourceReader::ReadResourceString() to read resource string from the given resource file. |
|
808 |
|
809 @SYMTestExpectedResults The test checks whether |
|
810 1. CTulStringResourceReader::ReadResourceString() loads the correct string from the resource file. |
|
811 2. CTulStringResourceReader::ReadResourceString() loads the string with very long text(~1000 characters) from the resource file. |
|
812 3. OOM tests completes without any memory leaks. |
|
813 */ |
|
814 void CT_TextResourceUtilsAppUi::TestStringResourceReaderCaseL() |
|
815 { |
|
816 INFO_PRINTF1(_L("Test to read a resource string from the resource file using CTulStringResourceReader")); |
|
817 TFileName fileName(KTextResourceUtilsFilePath); |
|
818 |
|
819 RFs rFs; |
|
820 User::LeaveIfError(rFs.Connect()); |
|
821 CleanupClosePushL(rFs); |
|
822 TPtrC buf; |
|
823 |
|
824 CTulStringResourceReader* stringResourceLoader = CTulStringResourceReader::NewLC(fileName); |
|
825 buf.Set(stringResourceLoader->ReadResourceString(R_TEXT_STRINGRESOURCEREADER_1)); |
|
826 TEST(buf.Compare(_L("Some string to be read")) == 0); |
|
827 CleanupStack::PopAndDestroy(stringResourceLoader); |
|
828 |
|
829 stringResourceLoader = CTulStringResourceReader::NewL(fileName); |
|
830 CleanupStack::PushL(stringResourceLoader); |
|
831 buf.Set(stringResourceLoader->ReadResourceString(R_TEXT_STRINGRESOURCEREADER_2)); |
|
832 TEST(buf.Compare(_L("Some other string to be read")) == 0); |
|
833 CleanupStack::PopAndDestroy(stringResourceLoader); |
|
834 |
|
835 stringResourceLoader = CTulStringResourceReader::NewLC(fileName, rFs); |
|
836 buf.Set(stringResourceLoader->ReadResourceString(R_TEXT_STRINGRESOURCEREADER_3)); |
|
837 TEST(buf.Compare(_L("Very long text. ~1000 characters. 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012"))); |
|
838 CleanupStack::PopAndDestroy(stringResourceLoader); |
|
839 |
|
840 stringResourceLoader = CTulStringResourceReader::NewL(fileName, rFs); |
|
841 CleanupStack::PushL(stringResourceLoader); |
|
842 buf.Set(stringResourceLoader->ReadResourceString(R_TEXT_STRINGRESOURCEREADER_4)); |
|
843 TEST(buf.Compare(_L("Short string to be read")) == 0); |
|
844 CleanupStack::PopAndDestroy(stringResourceLoader); |
|
845 CleanupStack::PopAndDestroy(&rFs); |
|
846 |
|
847 // OOM test for CTulStringReaderReader. |
|
848 INFO_PRINTF1(_L("OOM Test for CTulStringReaderReader")); |
|
849 for (int fail = 1;; fail++) |
|
850 { |
|
851 __UHEAP_SETFAIL(RHeap::EDeterministic, fail); |
|
852 __UHEAP_MARK; |
|
853 |
|
854 CTulStringResourceReader* stringResourceLoader = NULL; |
|
855 TRAPD(err, stringResourceLoader = CTulStringResourceReader::NewL(fileName)); |
|
856 TEST(err == KErrNone || err == KErrNoMemory); |
|
857 if (err == KErrNone) |
|
858 { |
|
859 buf.Set(stringResourceLoader->ReadResourceString(R_TEXT_STRINGRESOURCEREADER_1)); |
|
860 if (buf != KNullDesC) |
|
861 { |
|
862 TEST(buf.Compare(_L("Some string to be read")) == 0); |
|
863 delete stringResourceLoader; |
|
864 __UHEAP_MARKEND; |
|
865 break; |
|
866 } |
|
867 delete stringResourceLoader; |
|
868 } |
|
869 __UHEAP_MARKEND; |
|
870 } |
|
871 __UHEAP_RESET; |
|
872 } |
|
873 |
|
874 /** |
|
875 Destructor |
|
876 */ |
|
877 CT_TextResourceUtilsStep::~CT_TextResourceUtilsStep() |
|
878 { |
|
879 } |
|
880 |
|
881 /** |
|
882 Constructor |
|
883 */ |
|
884 CT_TextResourceUtilsStep::CT_TextResourceUtilsStep() |
|
885 { |
|
886 // Call base class method to set up the human readable name for logging |
|
887 SetTestStepName(KT_TextResourceUtilsStep); |
|
888 } |
|
889 |
|
890 void CT_TextResourceUtilsStep::ConstructAppL(CEikonEnv* aCoeEnv) |
|
891 { |
|
892 aCoeEnv->ConstructL(); |
|
893 CT_TextResourceUtilsAppUi* appUi=new(ELeave) CT_TextResourceUtilsAppUi(*this); |
|
894 appUi->ConstructL(); |
|
895 aCoeEnv->SetAppUi(appUi); |
|
896 } |
|
897 |
|
898 void CT_TextResourceUtilsStep::TestTextResourceUtilsWithoutCoeEnv() |
|
899 { |
|
900 INFO_PRINTF1(_L("Test TulTextResourceUtils Load methods before CoeEnv is created")); |
|
901 TRAPD(err, TulTextResourceUtils::LoadL(R_TEXT_EXAMPLE_B)); |
|
902 TEST(err == KErrNotSupported); |
|
903 |
|
904 HBufC* buf = NULL; |
|
905 TRAP(err, buf = TulTextResourceUtils::LoadLC(R_TEXT_EXAMPLE_B); CleanupStack::Pop(buf)); |
|
906 TEST(!buf); |
|
907 delete buf; |
|
908 TEST(err == KErrNotSupported); |
|
909 } |
|
910 |
|
911 TVerdict CT_TextResourceUtilsStep::doTestStepL() |
|
912 { |
|
913 INFO_PRINTF1(_L("Test Started")); |
|
914 __UHEAP_MARK; |
|
915 |
|
916 TestTextResourceUtilsWithoutCoeEnv(); |
|
917 CEikonEnv* coe = new(ELeave) CEikonEnv; |
|
918 TRAPD(err, ConstructAppL(coe)); |
|
919 if (!err) |
|
920 coe->ExecuteD(); |
|
921 else |
|
922 { |
|
923 SetTestStepResult(EFail); |
|
924 delete coe; |
|
925 } |
|
926 __UHEAP_MARKEND; |
|
927 INFO_PRINTF1(_L("Test Finished")); |
|
928 return TestStepResult(); |
|
929 } |