|
1 // Copyright (c) 2001-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 the License "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 // TCUSTOMWRAP.CPP |
|
15 // |
|
16 // |
|
17 |
|
18 #include <e32base.h> |
|
19 #include <msvapi.h> |
|
20 #include <msvids.h> |
|
21 #include <mtclreg.h> |
|
22 #include <eikstart.h> |
|
23 |
|
24 #include <basched.h> |
|
25 #include <banamedplugins.h> |
|
26 #include <bautils.h> |
|
27 #include <coecntrl.h> |
|
28 #include <coeccntx.h> |
|
29 #include <coemain.h> |
|
30 #include <charconv.h> |
|
31 #include <convnames.h> |
|
32 #include <e32keys.h> |
|
33 #include <techview\eikon.hrh> |
|
34 #include <eikappui.h> |
|
35 #include <eikapp.h> |
|
36 #include <eikdoc.h> |
|
37 #include <eikenv.h> |
|
38 #include <techview\eikrted.h> |
|
39 #include <techview\eikedwin.h> |
|
40 #include <eikdef.h> |
|
41 #include <techview\eikdialg.h> |
|
42 #include <techview\eikdlgtb.h> |
|
43 #include <techview\eikrted.h> |
|
44 #include <techview\eiksbfrm.h> |
|
45 #include <techview\eikconso.h> |
|
46 #include <txtrich.h> |
|
47 #include <hal.h> |
|
48 #include <fbs.h> |
|
49 #include "TestNrl.hrh" |
|
50 #include <testnrl.rsg> |
|
51 #include <techview\eikon.rsg> |
|
52 #include <prnsetup.h> |
|
53 |
|
54 #include <biodb.h> |
|
55 #include <biouids.h> |
|
56 #include <gdi.h> |
|
57 |
|
58 // forward declarations |
|
59 class CNRLTestAppUi; |
|
60 //class CEikScrollBarFrame; |
|
61 |
|
62 const TInt EGranularity=4; |
|
63 |
|
64 _LIT(KNewLine,"\n"); |
|
65 _LIT(KLitResourceFileNameAppendage, "_NAME.RSC"); |
|
66 #ifdef _DEBUG |
|
67 _LIT(KPanicText, "NonRom_Test"); |
|
68 #endif |
|
69 |
|
70 class TDummyObserver: public MMsvSessionObserver |
|
71 { |
|
72 public: |
|
73 virtual void HandleSessionEventL(TMsvSessionEvent, TAny*, TAny*, TAny*) {}; |
|
74 }; |
|
75 |
|
76 |
|
77 // |
|
78 // class CNRLTestControl |
|
79 // |
|
80 |
|
81 class CNRLTestControl : public CCoeControl |
|
82 { |
|
83 public: |
|
84 |
|
85 void ConstructL(const TRect& aRect); |
|
86 void ActivateL(); |
|
87 ~CNRLTestControl(); |
|
88 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); |
|
89 void PrintToScreen (TRefByValue<const TDesC> aFmt,...); |
|
90 void PrintLineToScreen (TRefByValue<const TDesC> aFmt,...); |
|
91 |
|
92 private: // from CCoeControl |
|
93 void Draw(const TRect&) const; |
|
94 |
|
95 private: |
|
96 CEikConsoleScreen* iConsole; |
|
97 }; |
|
98 |
|
99 |
|
100 CNRLTestControl::~CNRLTestControl () |
|
101 { |
|
102 delete iConsole; |
|
103 } |
|
104 |
|
105 |
|
106 void CNRLTestControl::ConstructL (const TRect& aRect) |
|
107 { |
|
108 CreateWindowL(); |
|
109 Window().SetShadowDisabled(ETrue); |
|
110 Window().SetBackgroundColor(KRgbGray); |
|
111 EnableDragEvents(); |
|
112 SetRect(aRect); |
|
113 SetBlank(); |
|
114 TRect consoleSize = aRect; |
|
115 consoleSize.Shrink(1,1); |
|
116 iConsole=new(ELeave) CEikConsoleScreen; |
|
117 iConsole->ConstructL(_L("TEST"),TPoint(1,1),consoleSize.Size(),CEikConsoleScreen::ENoInitialCursor,EEikConsWinInPixels); |
|
118 } |
|
119 |
|
120 void CNRLTestControl::ActivateL () |
|
121 { |
|
122 CCoeControl::ActivateL(); |
|
123 iConsole->SetKeepCursorInSight(ETrue); |
|
124 iConsole->SetHistorySizeL(500,5); |
|
125 iConsole->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EOn); |
|
126 iConsole->Write(_L("\nStarting tests for Non-Rom Localisation\nThis test requires some user interaction\n")); |
|
127 iConsole->FlushChars(); |
|
128 iConsole->DrawCursor(); |
|
129 iConsole->SetAtt(ATT_NORMAL); |
|
130 } |
|
131 |
|
132 void CNRLTestControl::Draw(const TRect& /* aRect*/) const |
|
133 { |
|
134 CWindowGc& gc = SystemGc(); |
|
135 TRect rect=Rect(); |
|
136 //rect.Shrink(10,10); |
|
137 gc.DrawRect(rect); |
|
138 rect.Shrink(1,1); |
|
139 } |
|
140 |
|
141 |
|
142 TKeyResponse CNRLTestControl::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
143 { |
|
144 if (aType!=EEventKey) |
|
145 return(EKeyWasConsumed); |
|
146 TInt modifiers=aKeyEvent.iModifiers; |
|
147 TInt code=aKeyEvent.iCode; |
|
148 |
|
149 |
|
150 |
|
151 TRect range = iConsole->Selection(); // get current selected range |
|
152 switch (code) |
|
153 { |
|
154 case EKeyUpArrow: |
|
155 iConsole->Up(); |
|
156 if (modifiers & EModifierShift) |
|
157 { |
|
158 range.iTl = iConsole->CursorPos(); |
|
159 iConsole->SetSelection(range); |
|
160 } |
|
161 else |
|
162 iConsole->SelectCursor(); |
|
163 break; |
|
164 case EKeyDownArrow: |
|
165 iConsole->Down(); |
|
166 if (modifiers & EModifierShift) |
|
167 { |
|
168 range.iTl = iConsole->CursorPos(); |
|
169 iConsole->SetSelection(range); |
|
170 } |
|
171 else |
|
172 iConsole->SelectCursor(); |
|
173 break; |
|
174 case EKeyLeftArrow: |
|
175 iConsole->Left(); |
|
176 if (modifiers & EModifierShift) |
|
177 { |
|
178 range.iTl = iConsole->CursorPos(); |
|
179 iConsole->SetSelection(range); |
|
180 } |
|
181 else |
|
182 iConsole->SelectCursor(); |
|
183 break; |
|
184 case EKeyRightArrow: |
|
185 iConsole->Right(); |
|
186 if (modifiers & EModifierShift) |
|
187 { |
|
188 range.iTl = iConsole->CursorPos(); |
|
189 iConsole->SetSelection(range); |
|
190 } |
|
191 else |
|
192 iConsole->SelectCursor(); |
|
193 break; |
|
194 case EKeyEnter: |
|
195 iConsole->Cr(); |
|
196 iConsole->Lf(); |
|
197 break; |
|
198 default: |
|
199 { |
|
200 iConsole->SelectCursor(); // forget previous selection |
|
201 TBuf<1> chr; |
|
202 chr.Format(_L("%c"),code); |
|
203 iConsole->Write(chr); |
|
204 iConsole->FlushChars(); |
|
205 } |
|
206 break; |
|
207 } |
|
208 return(EKeyWasConsumed); |
|
209 } |
|
210 |
|
211 |
|
212 void CNRLTestControl::PrintToScreen(TRefByValue<const TDesC> aFmt,...) |
|
213 { |
|
214 VA_LIST list; |
|
215 VA_START(list,aFmt); |
|
216 TBuf<128> buf; |
|
217 buf.FormatList(aFmt,list); |
|
218 iConsole->Write(buf); |
|
219 } |
|
220 |
|
221 void CNRLTestControl::PrintLineToScreen(TRefByValue<const TDesC> aFmt,...) |
|
222 { |
|
223 VA_LIST list; |
|
224 VA_START(list,aFmt); |
|
225 TBuf<128> buf; |
|
226 buf.FormatList(aFmt,list); |
|
227 iConsole->Write(buf); |
|
228 iConsole->Write(KNewLine); |
|
229 |
|
230 } |
|
231 |
|
232 |
|
233 |
|
234 // |
|
235 // ---------------------- CNRLTestAppView definition ---------------- |
|
236 // |
|
237 |
|
238 |
|
239 class CNRLTestAppUi : public CEikAppUi ,private CBaNamedPlugins::MFallBackName |
|
240 { |
|
241 public: |
|
242 void ConstructL(); |
|
243 void CreateControlL(); |
|
244 ~CNRLTestAppUi(); |
|
245 |
|
246 void StartTestsL(); |
|
247 void TestLocaleL(const TDesC& aTestHeader); |
|
248 void TestCollation(const TDesC& aTestHeader); |
|
249 void TestResourcesL(const TDesC& aTestHeader); |
|
250 void TestCharSetNamesL(const TDesC& aTestHeader); |
|
251 void TestFEPNamesL(const TDesC& aTestHeader); |
|
252 void TestDisplayMessagingL(const TDesC& aTestHeader); |
|
253 void TestBIFL(const TDesC& aTestHeader); |
|
254 void TestPrinterNameL(const TDesC& aTestHeader); |
|
255 void TestLocalisableBitmapL(const TDesC& aTestHeader); |
|
256 |
|
257 |
|
258 private: // from CEikAppUi -- framework |
|
259 void HandleCommandL(TInt aCommand); |
|
260 |
|
261 virtual HBufC* FallBackNameL(const TDesC& aFullResourceFileName) const; |
|
262 |
|
263 void WriteTestHeader(const TDesC& aTestHeader) const; |
|
264 void Pass(const TDesC& aTestHeader); |
|
265 void FailL(const TDesC& aTestHeader); |
|
266 void ReportEndResult() const; |
|
267 private: |
|
268 CNRLTestControl* iNRLTestControl; |
|
269 CDesCArray* iFailedTests; |
|
270 }; |
|
271 |
|
272 void CNRLTestAppUi::ConstructL() |
|
273 { |
|
274 BaseConstructL(); |
|
275 CreateControlL(); |
|
276 |
|
277 } |
|
278 |
|
279 // The cleanup operation of the TCleanupItem |
|
280 |
|
281 LOCAL_C void DestroyResourceFileArray(TAny* aArrayOfResourceFiles) |
|
282 { |
|
283 RArray<CBaNamedPlugins::TResourceFile>& arrayOfResourceFiles=*STATIC_CAST(RArray<CBaNamedPlugins::TResourceFile>*, aArrayOfResourceFiles); |
|
284 for (TInt i=arrayOfResourceFiles.Count()-1; i>=0; --i) |
|
285 { |
|
286 const CBaNamedPlugins::TResourceFile& resourceFile=arrayOfResourceFiles[i]; |
|
287 delete resourceFile.iFullFileName; |
|
288 delete resourceFile.iIdentifier; |
|
289 } |
|
290 arrayOfResourceFiles.Close(); |
|
291 } |
|
292 |
|
293 |
|
294 |
|
295 void CNRLTestAppUi::CreateControlL() |
|
296 { |
|
297 iNRLTestControl=new(ELeave) CNRLTestControl; |
|
298 iNRLTestControl->ConstructL(ClientRect()); |
|
299 AddToStackL(iNRLTestControl); |
|
300 iNRLTestControl->ActivateL(); |
|
301 iFailedTests=new(ELeave) CDesCArrayFlat(3); |
|
302 } |
|
303 |
|
304 CNRLTestAppUi::~CNRLTestAppUi() |
|
305 { |
|
306 RemoveFromStack(iNRLTestControl); |
|
307 delete iNRLTestControl; |
|
308 for (TInt i=0; i<iFailedTests->Count();i++) |
|
309 iFailedTests->Delete(i); |
|
310 delete iFailedTests; |
|
311 } |
|
312 |
|
313 void CNRLTestAppUi::HandleCommandL(TInt aCommand) |
|
314 { |
|
315 switch(aCommand) |
|
316 { |
|
317 case EAppCmdExit: |
|
318 Exit(); |
|
319 break; |
|
320 case EAppCmdTest: |
|
321 StartTestsL (); |
|
322 break; |
|
323 default: |
|
324 break; |
|
325 } |
|
326 } |
|
327 |
|
328 |
|
329 _LIT(KTestAnnouncer,"----------------"); |
|
330 _LIT(KLocaleTestTitle,"Locale "); |
|
331 _LIT(KResourceTestTitle,"Application Resource "); |
|
332 _LIT(KCharSetNamesTest,"Charset Names "); |
|
333 _LIT(KFEPNameTestTitle,"FEP Names "); |
|
334 _LIT(KCollationTestTitle, "Collation Table "); |
|
335 _LIT(KTDisplayMessaging,"Messaging Resources "); |
|
336 _LIT(KBIFTestTitle,"BIF Files "); |
|
337 _LIT(KPrinterNameTestTitle,"Printer Names "); |
|
338 _LIT(KLocalisableBimap,"Bitmap Files "); |
|
339 _LIT(KOriginalBitmapPath,"z:\\resource\\apps\\testnrl.mbm"); |
|
340 _LIT(KNonROM,"Non-ROM"); |
|
341 |
|
342 void CNRLTestAppUi::WriteTestHeader(const TDesC& aTestHeader) const |
|
343 { |
|
344 iNRLTestControl->PrintToScreen(KNewLine); |
|
345 iNRLTestControl->PrintToScreen(aTestHeader); |
|
346 iNRLTestControl->PrintLineToScreen (_L("Test")); |
|
347 iNRLTestControl->PrintToScreen(KNewLine); |
|
348 |
|
349 } |
|
350 |
|
351 |
|
352 void CNRLTestAppUi::StartTestsL () |
|
353 { |
|
354 TestLocaleL(KLocaleTestTitle); |
|
355 TestResourcesL (KResourceTestTitle); |
|
356 TestCharSetNamesL(KCharSetNamesTest); |
|
357 TestCollation(KCollationTestTitle); |
|
358 TestFEPNamesL(KFEPNameTestTitle); |
|
359 TestDisplayMessagingL(KTDisplayMessaging); |
|
360 TestBIFL(KBIFTestTitle); |
|
361 TestPrinterNameL (KPrinterNameTestTitle); |
|
362 TestLocalisableBitmapL (KLocalisableBimap); |
|
363 ReportEndResult(); |
|
364 |
|
365 } |
|
366 |
|
367 |
|
368 void CNRLTestAppUi::TestLocaleL (const TDesC& aTestHeader) |
|
369 { |
|
370 |
|
371 // print on console that we are starting the Locale Testing |
|
372 // just checking it is not enough, need to display as well that |
|
373 // the result is as expected. |
|
374 //Test a few other things besides the |
|
375 // locale number, some thing like a currency symbol. == $$$ |
|
376 |
|
377 WriteTestHeader(aTestHeader); |
|
378 iNRLTestControl->PrintLineToScreen(_L("Have to ensure that the correct locale is picked up")); |
|
379 iNRLTestControl->PrintLineToScreen(_L("Expected Locale with language extension")); |
|
380 |
|
381 TInt language; |
|
382 (void)HAL::Get(HAL::ELanguageIndex,language); |
|
383 iNRLTestControl->PrintLineToScreen(_L("%d"),language); |
|
384 iNRLTestControl->PrintToScreen(_L("Current Locales language extension: ")); |
|
385 |
|
386 TInt currentLangId; |
|
387 currentLangId = TInt(User::Language()); |
|
388 iNRLTestControl->PrintLineToScreen(_L("%d"),currentLangId); |
|
389 |
|
390 if (currentLangId == 95 ) |
|
391 { |
|
392 TCurrencySymbol theCurrencySymbol; |
|
393 _LIT(KExpectedCurrencySymbol,"$$$"); |
|
394 if(theCurrencySymbol==KExpectedCurrencySymbol) |
|
395 { |
|
396 iNRLTestControl->PrintLineToScreen(_L("The correct locale was loaded")); |
|
397 Pass(aTestHeader); |
|
398 } |
|
399 } |
|
400 else |
|
401 { |
|
402 iNRLTestControl->PrintToScreen(_L("The correct locale was not loaded")); |
|
403 FailL(aTestHeader); |
|
404 } |
|
405 } |
|
406 |
|
407 void CNRLTestAppUi::TestResourcesL(const TDesC& aTestHeader) |
|
408 { |
|
409 WriteTestHeader(aTestHeader); |
|
410 iNRLTestControl->PrintLineToScreen (_L("Reading information from resource file...")); |
|
411 |
|
412 TResourceReader resourceReader; |
|
413 CCoeEnv::Static()->CreateResourceReaderLC(resourceReader,R_NRL_COLLATE); |
|
414 CDesCArray* collation=new(ELeave) CDesCArrayFlat(3); |
|
415 CleanupStack::PushL(collation); |
|
416 TInt n=resourceReader.ReadUint16(); |
|
417 |
|
418 for (TInt i=0;i<n;i++) |
|
419 collation->AppendL(resourceReader.ReadTPtrC()); |
|
420 |
|
421 for (TInt j=0;j<n;j++) |
|
422 { |
|
423 iNRLTestControl->PrintLineToScreen((*collation)[j]); |
|
424 } |
|
425 |
|
426 _LIT(KResourceData,"David"); |
|
427 TInt resourceTest; |
|
428 collation->Find(KResourceData,resourceTest,ECmpCollated); |
|
429 if(resourceTest!=collation->MdcaCount()) |
|
430 { |
|
431 Pass(aTestHeader); |
|
432 } |
|
433 else |
|
434 { |
|
435 FailL(aTestHeader); |
|
436 } |
|
437 CleanupStack::PopAndDestroy(2);//resourceReader,collation |
|
438 } |
|
439 |
|
440 void CNRLTestAppUi::TestCharSetNamesL(const TDesC& aTestHeader) |
|
441 { |
|
442 WriteTestHeader(aTestHeader); |
|
443 RFs& aSession = iCoeEnv->FsSession(); |
|
444 CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* charsetArray=CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableLC(aSession); |
|
445 MDesCArray* nameArry=CCnvCharacterSetNames::NewL(aSession,charsetArray->Array()); |
|
446 TInt index=((CCnvCharacterSetNames*)nameArry)->IndexOfIdentifier(KCharacterSetIdentifierAscii); |
|
447 TInt testResult; |
|
448 testResult=0; |
|
449 TPtrC bigFive=nameArry->MdcaPoint(index); |
|
450 TInt findNonROM; |
|
451 findNonROM=bigFive.Find(KNonROM); |
|
452 if(findNonROM!=KErrNotFound) |
|
453 { |
|
454 iNRLTestControl->PrintToScreen(KNewLine); |
|
455 iNRLTestControl->PrintLineToScreen(bigFive); |
|
456 testResult=1; |
|
457 } |
|
458 if(testResult) |
|
459 Pass(aTestHeader); |
|
460 else |
|
461 FailL(aTestHeader); |
|
462 delete nameArry; |
|
463 CleanupStack::PopAndDestroy();//charsetArray |
|
464 } |
|
465 |
|
466 |
|
467 |
|
468 void CNRLTestAppUi::TestCollation(const TDesC& aTestHeader) |
|
469 { |
|
470 WriteTestHeader(aTestHeader); |
|
471 iNRLTestControl->PrintToScreen(_L("This test locale has it's own collation table\n")); |
|
472 iNRLTestControl->PrintToScreen(_L("Set Collation values in the order E-D-C-B-A\n")); |
|
473 iNRLTestControl->PrintToScreen(_L("Loading a few names which have been sorted using collation\n")); |
|
474 iNRLTestControl->PrintToScreen(_L("David should appear before BeiBei\n\n")); |
|
475 TResourceReader resourceReader; |
|
476 CCoeEnv::Static()->CreateResourceReaderLC(resourceReader,R_NRL_COLLATE); |
|
477 CDesCArray* collation=new(ELeave) CDesCArrayFlat(3); |
|
478 CleanupStack::PushL(collation); |
|
479 TInt n=resourceReader.ReadUint16(); |
|
480 |
|
481 for (TInt i=0;i<n;i++) |
|
482 collation->AppendL(resourceReader.ReadTPtrC()); |
|
483 //David is the first name stored in the array before the array is sorted. |
|
484 //When the array is sorted, David should still be the first name |
|
485 // because this locales collation table reverses the ordering between A & E |
|
486 TPtrC david = (*collation)[0]; |
|
487 collation->Sort(ECmpCollated); |
|
488 for (TInt j=0;j<n;j++) |
|
489 { |
|
490 iNRLTestControl->PrintLineToScreen((*collation)[j]); |
|
491 } |
|
492 |
|
493 TInt coltest; |
|
494 |
|
495 // searching for Davids name in the array, |
|
496 // according to the new collation rules David's name should be |
|
497 // the first itm in the array. |
|
498 |
|
499 collation->Find(david,coltest,ECmpCollated); |
|
500 // if coltest=0 then Davids is the first item, |
|
501 // the new collation table was used. |
|
502 if (!coltest) |
|
503 { |
|
504 Pass(aTestHeader); |
|
505 } |
|
506 else |
|
507 { |
|
508 FailL(aTestHeader); |
|
509 } |
|
510 |
|
511 CleanupStack::PopAndDestroy(2);//resourceReader,collation |
|
512 } |
|
513 |
|
514 |
|
515 void CNRLTestAppUi::TestFEPNamesL(const TDesC& aTestHeader) |
|
516 { |
|
517 WriteTestHeader(aTestHeader); |
|
518 iNRLTestControl->PrintLineToScreen (_L("Fep Names are stored in resource files in the fep directory in system")); |
|
519 iNRLTestControl->PrintLineToScreen (_L("Compiled new resources with the word Non-ROM added into a few test fep names")); |
|
520 |
|
521 RArray<CBaNamedPlugins::TResourceFile> arrayOfResourceFiles; |
|
522 CleanupStack::PushL(TCleanupItem(DestroyResourceFileArray, &arrayOfResourceFiles));//arrayOfResourceFiles |
|
523 RFs& fileServerSession=iCoeEnv->FsSession(); |
|
524 TInt numberofsession=fileServerSession.ResourceCount(); |
|
525 TInt i; |
|
526 TParse* parser=new(ELeave) TParse; |
|
527 CleanupStack::PushL(parser);//parser |
|
528 TFileName* fileName=new(ELeave) TFileName; |
|
529 CleanupStack::PushL(fileName);//fileName |
|
530 |
|
531 |
|
532 RArray<TUid> uidsOfAvailableFeps; |
|
533 CleanupClosePushL(uidsOfAvailableFeps); |
|
534 CDesCArray* fileNamesOfAvailableFeps = new(ELeave) CDesCArrayFlat(EGranularity); |
|
535 CleanupDeletePushL(fileNamesOfAvailableFeps);//fileNamesOfAvailableFeps |
|
536 iCoeEnv->AvailableFepsL(uidsOfAvailableFeps,fileNamesOfAvailableFeps);//it is allocated some memory here!!! |
|
537 |
|
538 |
|
539 |
|
540 for (i=fileNamesOfAvailableFeps->MdcaCount()-1; i>=0; --i) |
|
541 { |
|
542 const TPtrC fullFileNameOfDll(fileNamesOfAvailableFeps->MdcaPoint(i)); |
|
543 *fileName=TParsePtrC(fullFileNameOfDll).Name(); |
|
544 fileName->Append(KLitResourceFileNameAppendage); |
|
545 User::LeaveIfError(parser->SetNoWild(*fileName, &fullFileNameOfDll, NULL)); |
|
546 CBaNamedPlugins::TResourceFile resourceFile; |
|
547 resourceFile.iFullFileName=parser->FullName().AllocLC(); |
|
548 resourceFile.iIdentifier=fullFileNameOfDll.AllocLC(); |
|
549 resourceFile.iUid=uidsOfAvailableFeps[i]; |
|
550 resourceFile.iFormat=CBaNamedPlugins::TResourceFile::EFormatTbuf; |
|
551 User::LeaveIfError(arrayOfResourceFiles.Append(resourceFile)); |
|
552 CleanupStack::Pop(2, resourceFile.iFullFileName);//iFullFileName,iIdentifier |
|
553 } |
|
554 CleanupStack::PopAndDestroy(4, parser);//parser,fileName,uidsOfAvailableFeps,fileNamesOfAvailableFeps |
|
555 |
|
556 CBaNamedPlugins::CParameters* parameters=CBaNamedPlugins::CParameters::NewLC(fileServerSession, arrayOfResourceFiles.Array()); |
|
557 parameters->SetFallBackName(*this); |
|
558 CBaNamedPlugins* namedPlugins=CBaNamedPlugins::NewL(*parameters);//numberofsession increased after this |
|
559 numberofsession=fileServerSession.ResourceCount(); |
|
560 const TInt numberOfAvailableFeps=namedPlugins->MdcaCount(); |
|
561 TInt testResult; |
|
562 testResult=0; |
|
563 for (i=0; i<numberOfAvailableFeps; ++i) |
|
564 { |
|
565 TPtrC fepNames = namedPlugins->MdcaPoint(i); |
|
566 RDebug::Print(fepNames); |
|
567 TInt findNonROM; |
|
568 findNonROM=fepNames.Find(KNonROM); |
|
569 if (findNonROM!=KErrNotFound) |
|
570 { |
|
571 iNRLTestControl->PrintLineToScreen(fepNames); |
|
572 testResult =1; |
|
573 } |
|
574 } |
|
575 if (testResult) |
|
576 { |
|
577 Pass(aTestHeader); |
|
578 } |
|
579 else |
|
580 { |
|
581 FailL(aTestHeader); |
|
582 } |
|
583 delete namedPlugins; |
|
584 CleanupStack::PopAndDestroy(2, &arrayOfResourceFiles);//arrayOfResourceFiles,parameters |
|
585 } |
|
586 |
|
587 HBufC* CNRLTestAppUi::FallBackNameL(const TDesC& aFullResourceFileName) const |
|
588 { |
|
589 const TPtrC nameAndExtension(TParsePtrC(aFullResourceFileName).NameAndExt()); |
|
590 __ASSERT_DEBUG(nameAndExtension.Right(KLitResourceFileNameAppendage().Length())==KLitResourceFileNameAppendage, User::Panic(KPanicText,-1)); |
|
591 return nameAndExtension.Left(nameAndExtension.Length()-KLitResourceFileNameAppendage().Length()).AllocL(); |
|
592 } |
|
593 |
|
594 void CNRLTestAppUi::TestDisplayMessagingL(const TDesC& aTestHeader) |
|
595 { |
|
596 WriteTestHeader(aTestHeader); |
|
597 iNRLTestControl->PrintLineToScreen (_L("MTM are stored in resource files in the MTM directory in System")); |
|
598 iNRLTestControl->PrintLineToScreen (_L("Compiled new resources with the word Non-ROM added into the MTM resources")); |
|
599 |
|
600 TDummyObserver obs; |
|
601 CMsvSession *session=CMsvSession::OpenSyncL(obs); |
|
602 CleanupStack::PushL(session); |
|
603 CClientMtmRegistry *reg=CClientMtmRegistry::NewL(*session); |
|
604 CleanupStack::PushL(reg); |
|
605 TInt count=reg->NumRegisteredMtmDlls(); |
|
606 |
|
607 TInt testResult; |
|
608 testResult=0; |
|
609 while(count--) |
|
610 { |
|
611 const CMtmDllInfo& info=reg->RegisteredMtmDllInfo(reg->MtmTypeUid(count)); |
|
612 TPtrC mtmNames = info.HumanReadableName(); |
|
613 TInt findNonROM; |
|
614 findNonROM=mtmNames.Find(KNonROM); |
|
615 if (findNonROM!=KErrNotFound) |
|
616 { |
|
617 iNRLTestControl->PrintLineToScreen (mtmNames); |
|
618 testResult =1; |
|
619 } |
|
620 |
|
621 } |
|
622 |
|
623 CleanupStack::PopAndDestroy(reg); |
|
624 |
|
625 CMsvEntry *entry=session->GetEntryL(KMsvRootIndexEntryId); |
|
626 CleanupStack::PushL(entry); |
|
627 |
|
628 entry->SetEntryL(KMsvDraftEntryId); |
|
629 iNRLTestControl->PrintLineToScreen (entry->Entry().iDetails); |
|
630 |
|
631 |
|
632 entry->SetEntryL(KMsvGlobalInBoxIndexEntryId); |
|
633 iNRLTestControl->PrintLineToScreen (entry->Entry().iDetails); |
|
634 |
|
635 entry->SetEntryL(KMsvGlobalOutBoxIndexEntryId); |
|
636 iNRLTestControl->PrintLineToScreen (entry->Entry().iDetails); |
|
637 |
|
638 entry->SetEntryL(KMsvSentEntryId); |
|
639 iNRLTestControl->PrintLineToScreen (entry->Entry().iDetails); |
|
640 |
|
641 CleanupStack::PopAndDestroy(entry); |
|
642 CleanupStack::PopAndDestroy(session); |
|
643 |
|
644 if (testResult) |
|
645 { |
|
646 Pass(aTestHeader); |
|
647 } |
|
648 else |
|
649 { |
|
650 FailL(aTestHeader); |
|
651 } |
|
652 } |
|
653 |
|
654 |
|
655 |
|
656 void CNRLTestAppUi::TestBIFL (const TDesC& aTestHeader) |
|
657 { |
|
658 WriteTestHeader(aTestHeader); |
|
659 iNRLTestControl->PrintLineToScreen(_L("BIF files are now stored as resources in System\\BIf directory")); |
|
660 iNRLTestControl->PrintLineToScreen(_L("Compiled new BIF resources with the phrase Non-ROM added ... ")); |
|
661 |
|
662 RFs& gFs=iCoeEnv->FsSession(); |
|
663 |
|
664 iNRLTestControl->PrintLineToScreen(_L("Opening & Searching DB")); |
|
665 |
|
666 CBIODatabase* bioDB = CBIODatabase::NewL(gFs); |
|
667 CleanupStack::PushL( bioDB ); |
|
668 iNRLTestControl->PrintLineToScreen(_L("Opened DB Successfully!")); |
|
669 |
|
670 TInt testResult; |
|
671 testResult=0; |
|
672 for (TInt i=0; i < bioDB->BIOCount(); i++) |
|
673 { |
|
674 const CBioInfoFileReader& bifReader = bioDB->BifReader(i); |
|
675 |
|
676 TPtrC desc; |
|
677 desc.Set(bifReader.Description()); |
|
678 TInt findNonROM; |
|
679 findNonROM=desc.Find((KNonROM)); |
|
680 if (findNonROM!=KErrNotFound) |
|
681 { |
|
682 iNRLTestControl->PrintLineToScreen(desc); |
|
683 testResult =1; |
|
684 } |
|
685 } |
|
686 |
|
687 if (testResult) |
|
688 { |
|
689 Pass(aTestHeader); |
|
690 } |
|
691 else |
|
692 { |
|
693 FailL(aTestHeader); |
|
694 } |
|
695 CleanupStack::PopAndDestroy(); // bioDB |
|
696 |
|
697 } |
|
698 |
|
699 void CNRLTestAppUi::TestPrinterNameL (const TDesC& aTestHeader) |
|
700 { |
|
701 |
|
702 WriteTestHeader(aTestHeader); |
|
703 |
|
704 CDesCArray* list=new(ELeave) CDesCArrayFlat(EGranularity); |
|
705 CleanupStack::PushL(list); |
|
706 |
|
707 CPrintSetup* aPrintSetup = CPrintSetup::NewL(); |
|
708 CleanupStack::PushL(aPrintSetup); |
|
709 aPrintSetup->AddPrinterDriverDirL( KDefaultPrinterDriverPath ); |
|
710 RFs& filesession = iCoeEnv->FsSession(); |
|
711 CPrinterModelList* aModelList; |
|
712 aModelList = aPrintSetup->ModelNameListL(filesession); |
|
713 CEikonEnv::GetPrinterNamesL(aModelList,*list); |
|
714 |
|
715 aPrintSetup->FreeModelList(); |
|
716 |
|
717 TInt foundNonRomResource=0; |
|
718 |
|
719 for (TInt i=0; i < list->Count(); ++i) |
|
720 { |
|
721 TPtrC desc; |
|
722 desc.Set((*list)[i]); |
|
723 TInt findNonROM; |
|
724 findNonROM = desc.Find((KNonROM)); |
|
725 if (findNonROM!=KErrNotFound) |
|
726 { |
|
727 iNRLTestControl->PrintLineToScreen (desc); |
|
728 foundNonRomResource=1; |
|
729 } |
|
730 } |
|
731 if (foundNonRomResource) |
|
732 Pass(aTestHeader); |
|
733 else |
|
734 FailL(aTestHeader); |
|
735 |
|
736 |
|
737 CleanupStack::PopAndDestroy(2); // list, aPrintSetup, aModelList |
|
738 |
|
739 } |
|
740 |
|
741 void CNRLTestAppUi::TestLocalisableBitmapL(const TDesC& aTestHeader) |
|
742 { |
|
743 WriteTestHeader(aTestHeader); |
|
744 |
|
745 TFileName filename(KOriginalBitmapPath); |
|
746 CWsBitmap* aBitmap; |
|
747 aBitmap=iEikonEnv->CreateBitmapL(filename,1); |
|
748 TBool nonROM; |
|
749 nonROM=aBitmap->IsRomBitmap(); |
|
750 if(nonROM) |
|
751 { |
|
752 FailL(aTestHeader); |
|
753 } |
|
754 else |
|
755 { |
|
756 iNRLTestControl->PrintLineToScreen(_L("Right, the bitmap loaded should not be in ROM")); |
|
757 Pass(aTestHeader); |
|
758 } |
|
759 |
|
760 delete aBitmap; |
|
761 } |
|
762 |
|
763 |
|
764 void CNRLTestAppUi::Pass(const TDesC& aTestHeader) |
|
765 { |
|
766 iNRLTestControl->PrintToScreen(KNewLine); |
|
767 iNRLTestControl->PrintLineToScreen(KTestAnnouncer); |
|
768 iNRLTestControl->PrintLineToScreen(_L("Expected new %S loaded"),&aTestHeader); |
|
769 iNRLTestControl->PrintLineToScreen(KTestAnnouncer); |
|
770 } |
|
771 |
|
772 void CNRLTestAppUi::FailL(const TDesC& aTestHeader) |
|
773 { |
|
774 iNRLTestControl->PrintToScreen(KNewLine); |
|
775 iNRLTestControl->PrintLineToScreen(KTestAnnouncer); |
|
776 iNRLTestControl->PrintLineToScreen(_L("Unexpected old %S loaded"),&aTestHeader); |
|
777 iNRLTestControl->PrintLineToScreen(KTestAnnouncer); |
|
778 iFailedTests->AppendL(aTestHeader); |
|
779 |
|
780 } |
|
781 |
|
782 void CNRLTestAppUi::ReportEndResult() const |
|
783 { |
|
784 TInt failedTestsCount = iFailedTests->Count(); |
|
785 if (failedTestsCount) |
|
786 { |
|
787 // Print a list of the Tests Failed |
|
788 iNRLTestControl->PrintLineToScreen(_L("The following tests failed\n")); |
|
789 for (TInt i=0; i<failedTestsCount; ++i) |
|
790 { |
|
791 iNRLTestControl->PrintLineToScreen ((*iFailedTests)[i]); |
|
792 } |
|
793 } |
|
794 else |
|
795 { |
|
796 // No Tests Failed, say that new resources were loaded where expected to |
|
797 } |
|
798 } |
|
799 |
|
800 |
|
801 // |
|
802 // --------------------- CNRLTestAppDoc class Definition ------------ |
|
803 // |
|
804 |
|
805 class CNRLTestAppDoc : public CEikDocument |
|
806 { |
|
807 public: |
|
808 CNRLTestAppDoc(CEikApplication& aApp); |
|
809 private: |
|
810 CEikAppUi* CreateAppUiL(); |
|
811 }; |
|
812 |
|
813 |
|
814 CNRLTestAppDoc::CNRLTestAppDoc(CEikApplication& aApp):CEikDocument(aApp) |
|
815 { |
|
816 // Nothing else to do, just call the base class constructor |
|
817 // |
|
818 } |
|
819 |
|
820 CEikAppUi* CNRLTestAppDoc::CreateAppUiL() |
|
821 { |
|
822 return new (ELeave) CNRLTestAppUi; |
|
823 } |
|
824 // |
|
825 // ------------------------------ CNRLTestApp ----------------------- |
|
826 // |
|
827 |
|
828 |
|
829 const TUid KTestNRLid = {0x1000AC5D}; |
|
830 |
|
831 class CNRLTestApp : public CEikApplication |
|
832 { |
|
833 private: |
|
834 CApaDocument* CreateDocumentL(); |
|
835 TUid AppDllUid() const; |
|
836 |
|
837 }; |
|
838 |
|
839 TUid CNRLTestApp::AppDllUid() const |
|
840 { |
|
841 return KTestNRLid; |
|
842 } |
|
843 |
|
844 CApaDocument* CNRLTestApp::CreateDocumentL() |
|
845 { |
|
846 return new (ELeave) CNRLTestAppDoc(*this); |
|
847 } |
|
848 |
|
849 //////////////////////////////////////////////////////////////////////////////////////////// |
|
850 // |
|
851 |
|
852 static CApaApplication* NewApplication() |
|
853 { |
|
854 return new CNRLTestApp; |
|
855 } |
|
856 |
|
857 TInt E32Main() |
|
858 { |
|
859 return EikStart::RunApplication(&NewApplication); |
|
860 } |
|
861 |
|
862 |