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