os/textandloc/localisation/localesupport/TestNrl/TestNrl.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/localisation/localesupport/TestNrl/TestNrl.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,864 @@
     1.4 +/*
     1.5 +* Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +* TCUSTOMWRAP.CPP 
    1.19 +*
    1.20 +*/
    1.21 +
    1.22 +
    1.23 +#include <e32base.h>
    1.24 +#include <msvapi.h>
    1.25 +#include <msvids.h>
    1.26 +#include <mtclreg.h>
    1.27 +#include <eikstart.h>
    1.28 +
    1.29 +#include <basched.h>
    1.30 +#include <banamedplugins.h>
    1.31 +#include <bautils.h>
    1.32 +#include <coecntrl.h>
    1.33 +#include <coeccntx.h>
    1.34 +#include <coemain.h>
    1.35 +#include <charconv.h>
    1.36 +#include <convnames.h>
    1.37 +#include <e32keys.h>
    1.38 +#include <techview/eikon.hrh>
    1.39 +#include <eikappui.h>
    1.40 +#include <eikapp.h>
    1.41 +#include <eikdoc.h>
    1.42 +#include <eikenv.h>
    1.43 +#include <techview/eikrted.h>
    1.44 +#include <techview/eikedwin.h>
    1.45 +#include <eikdef.h>
    1.46 +#include <techview/eikdialg.h>
    1.47 +#include <techview/eikdlgtb.h>
    1.48 +#include <techview/eikrted.h>
    1.49 +#include <techview/eiksbfrm.h>
    1.50 +#include <techview/eikconso.h>
    1.51 +#include <txtrich.h>
    1.52 +#include <hal.h>
    1.53 +#include <fbs.h>
    1.54 +#include "TestNrl.hrh"
    1.55 +#include <testnrl.rsg>
    1.56 +#include <techview/eikon.rsg>
    1.57 +#include <prnsetup.h>
    1.58 +
    1.59 +#include <biodb.h>	
    1.60 +#include <biouids.h>
    1.61 +#include <gdi.h>
    1.62 +
    1.63 +// forward declarations
    1.64 +class CNRLTestAppUi;
    1.65 +//class CEikScrollBarFrame;
    1.66 +
    1.67 +const TInt EGranularity=4;
    1.68 +
    1.69 +_LIT(KNewLine,"\n");
    1.70 +_LIT(KLitResourceFileNameAppendage, "_NAME.RSC");
    1.71 +#ifdef _DEBUG
    1.72 +_LIT(KPanicText, "NonRom_Test");
    1.73 +#endif
    1.74 +
    1.75 +class TDummyObserver: public MMsvSessionObserver
    1.76 +	{
    1.77 +public:
    1.78 +		virtual void HandleSessionEventL(TMsvSessionEvent, TAny*, TAny*, TAny*) {};
    1.79 +	};
    1.80 +
    1.81 +
    1.82 +//
    1.83 +// class CNRLTestControl
    1.84 +//
    1.85 +
    1.86 +class CNRLTestControl : public CCoeControl
    1.87 +    {
    1.88 +public:
    1.89 +
    1.90 +    void ConstructL(const TRect& aRect);
    1.91 +	void ActivateL();
    1.92 +	~CNRLTestControl();
    1.93 +	TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
    1.94 +	void PrintToScreen (TRefByValue<const TDesC> aFmt,...);
    1.95 +	void PrintLineToScreen (TRefByValue<const TDesC> aFmt,...);
    1.96 +
    1.97 +private: // from CCoeControl
    1.98 +	void Draw(const TRect&) const;
    1.99 +	
   1.100 +private:
   1.101 +	CEikConsoleScreen* iConsole;
   1.102 +    };
   1.103 +
   1.104 +
   1.105 +CNRLTestControl::~CNRLTestControl ()
   1.106 +	{
   1.107 +	delete iConsole;
   1.108 +	}
   1.109 +
   1.110 +
   1.111 +void CNRLTestControl::ConstructL (const TRect& aRect)
   1.112 +	{
   1.113 +	CreateWindowL();
   1.114 +	Window().SetShadowDisabled(ETrue);
   1.115 +    Window().SetBackgroundColor(KRgbGray);
   1.116 +    EnableDragEvents();
   1.117 +	SetRect(aRect);
   1.118 +	SetBlank();
   1.119 +	TRect consoleSize = aRect;
   1.120 +	consoleSize.Shrink(1,1);
   1.121 +	iConsole=new(ELeave) CEikConsoleScreen;
   1.122 +	iConsole->ConstructL(_L("TEST"),TPoint(1,1),consoleSize.Size(),CEikConsoleScreen::ENoInitialCursor,EEikConsWinInPixels);
   1.123 +	}
   1.124 +
   1.125 +void CNRLTestControl::ActivateL ()
   1.126 +	{
   1.127 +	CCoeControl::ActivateL();
   1.128 +	iConsole->SetKeepCursorInSight(ETrue);
   1.129 +	iConsole->SetHistorySizeL(500,5);
   1.130 +	iConsole->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EOn);
   1.131 +	iConsole->Write(_L("\nStarting tests for Non-Rom Localisation\nThis test requires some user interaction\n"));
   1.132 +	iConsole->FlushChars();
   1.133 +	iConsole->DrawCursor();
   1.134 +	iConsole->SetAtt(ATT_NORMAL);
   1.135 +	}
   1.136 +
   1.137 +void CNRLTestControl::Draw(const TRect& /* aRect*/) const
   1.138 +	{
   1.139 +	CWindowGc& gc = SystemGc();
   1.140 +	TRect rect=Rect();
   1.141 +	//rect.Shrink(10,10);
   1.142 +	gc.DrawRect(rect);
   1.143 +	rect.Shrink(1,1);
   1.144 +	}
   1.145 +
   1.146 +
   1.147 +TKeyResponse CNRLTestControl::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
   1.148 +    {
   1.149 +	if (aType!=EEventKey)
   1.150 +		return(EKeyWasConsumed);
   1.151 +    TInt modifiers=aKeyEvent.iModifiers;
   1.152 +    TInt code=aKeyEvent.iCode;
   1.153 +
   1.154 +
   1.155 +
   1.156 +	TRect range = iConsole->Selection(); // get current selected range
   1.157 +	switch (code)
   1.158 +		{
   1.159 +		case EKeyUpArrow:
   1.160 +			iConsole->Up();
   1.161 +			if (modifiers & EModifierShift)
   1.162 +				{
   1.163 +				range.iTl = iConsole->CursorPos();
   1.164 +				iConsole->SetSelection(range); 
   1.165 +				}
   1.166 +			else
   1.167 +				iConsole->SelectCursor(); 
   1.168 +			break;
   1.169 +		case EKeyDownArrow:
   1.170 +			iConsole->Down();
   1.171 +			if (modifiers & EModifierShift)
   1.172 +				{
   1.173 +				range.iTl = iConsole->CursorPos();
   1.174 +				iConsole->SetSelection(range); 
   1.175 +				}
   1.176 +			else
   1.177 +				iConsole->SelectCursor(); 
   1.178 +			break;
   1.179 +		case EKeyLeftArrow:
   1.180 +			iConsole->Left();
   1.181 +			if (modifiers & EModifierShift)
   1.182 +				{
   1.183 +				range.iTl = iConsole->CursorPos();
   1.184 +				iConsole->SetSelection(range); 
   1.185 +				}
   1.186 +			else
   1.187 +				iConsole->SelectCursor(); 
   1.188 +			break;
   1.189 +		case EKeyRightArrow:
   1.190 +			iConsole->Right();
   1.191 +			if (modifiers & EModifierShift)
   1.192 +				{
   1.193 +				range.iTl = iConsole->CursorPos();
   1.194 +				iConsole->SetSelection(range); 
   1.195 +				}
   1.196 +			else
   1.197 +				iConsole->SelectCursor(); 
   1.198 +			break;
   1.199 +		case EKeyEnter: 
   1.200 +				iConsole->Cr();
   1.201 +				iConsole->Lf();
   1.202 +			break;
   1.203 +		default:
   1.204 +			{
   1.205 +			iConsole->SelectCursor();	// forget previous selection
   1.206 +			TBuf<1> chr;
   1.207 +			chr.Format(_L("%c"),code);
   1.208 +			iConsole->Write(chr);
   1.209 +			iConsole->FlushChars();
   1.210 +			}
   1.211 +			break;
   1.212 +		}
   1.213 +    return(EKeyWasConsumed);
   1.214 +    }
   1.215 +
   1.216 +
   1.217 +void CNRLTestControl::PrintToScreen(TRefByValue<const TDesC> aFmt,...)
   1.218 +	{
   1.219 +	VA_LIST list;
   1.220 +	VA_START(list,aFmt);
   1.221 +	TBuf<128> buf;
   1.222 +	buf.FormatList(aFmt,list);
   1.223 +	iConsole->Write(buf);
   1.224 +	}
   1.225 +
   1.226 +void CNRLTestControl::PrintLineToScreen(TRefByValue<const TDesC> aFmt,...)
   1.227 +	{
   1.228 +	VA_LIST list;
   1.229 +	VA_START(list,aFmt);
   1.230 +	TBuf<128> buf;
   1.231 +	buf.FormatList(aFmt,list);
   1.232 +	iConsole->Write(buf);
   1.233 +	iConsole->Write(KNewLine);
   1.234 +
   1.235 +	}
   1.236 +
   1.237 +
   1.238 +
   1.239 +// 
   1.240 +//  ---------------------- CNRLTestAppView definition ---------------- 
   1.241 +//
   1.242 +
   1.243 +
   1.244 +class CNRLTestAppUi : public CEikAppUi ,private CBaNamedPlugins::MFallBackName
   1.245 +	{
   1.246 +public:
   1.247 +	void ConstructL();
   1.248 +	void CreateControlL();
   1.249 +	~CNRLTestAppUi();
   1.250 +	
   1.251 +	void StartTestsL();
   1.252 +	void TestLocaleL(const TDesC& aTestHeader);
   1.253 +	void TestCollation(const TDesC& aTestHeader);
   1.254 +	void TestResourcesL(const TDesC& aTestHeader);
   1.255 +	void TestCharSetNamesL(const TDesC& aTestHeader);
   1.256 +	void TestFEPNamesL(const TDesC& aTestHeader);
   1.257 +	void TestDisplayMessagingL(const TDesC& aTestHeader);
   1.258 +	void TestBIFL(const TDesC& aTestHeader);
   1.259 +	void TestPrinterNameL(const TDesC& aTestHeader);
   1.260 +	void TestLocalisableBitmapL(const TDesC& aTestHeader);
   1.261 +
   1.262 +
   1.263 +private: // from CEikAppUi -- framework
   1.264 +	void HandleCommandL(TInt aCommand);
   1.265 +
   1.266 +	virtual HBufC* FallBackNameL(const TDesC& aFullResourceFileName) const;
   1.267 +	
   1.268 +	void WriteTestHeader(const TDesC& aTestHeader) const;
   1.269 +	void Pass(const TDesC& aTestHeader);
   1.270 +	void FailL(const TDesC& aTestHeader);
   1.271 +	void ReportEndResult() const;
   1.272 +private: 
   1.273 +	CNRLTestControl* iNRLTestControl;
   1.274 +	CDesCArray* iFailedTests;
   1.275 +	};
   1.276 +
   1.277 +void CNRLTestAppUi::ConstructL()
   1.278 +	{
   1.279 +	BaseConstructL();
   1.280 +	CreateControlL();
   1.281 +
   1.282 +	}
   1.283 +
   1.284 +// The cleanup operation of the TCleanupItem
   1.285 +
   1.286 +LOCAL_C void DestroyResourceFileArray(TAny* aArrayOfResourceFiles)
   1.287 +	{
   1.288 +	RArray<CBaNamedPlugins::TResourceFile>& arrayOfResourceFiles=*STATIC_CAST(RArray<CBaNamedPlugins::TResourceFile>*, aArrayOfResourceFiles);
   1.289 +	for (TInt i=arrayOfResourceFiles.Count()-1; i>=0; --i)
   1.290 +		{
   1.291 +		const CBaNamedPlugins::TResourceFile& resourceFile=arrayOfResourceFiles[i];
   1.292 +		delete resourceFile.iFullFileName;
   1.293 +		delete resourceFile.iIdentifier;
   1.294 +		}
   1.295 +	arrayOfResourceFiles.Close();
   1.296 +	}
   1.297 +
   1.298 +
   1.299 +
   1.300 +void CNRLTestAppUi::CreateControlL()
   1.301 +	{
   1.302 +	iNRLTestControl=new(ELeave) CNRLTestControl;
   1.303 +    iNRLTestControl->ConstructL(ClientRect());
   1.304 +	AddToStackL(iNRLTestControl);
   1.305 +	iNRLTestControl->ActivateL();
   1.306 +	iFailedTests=new(ELeave) CDesCArrayFlat(3);
   1.307 +	}
   1.308 +
   1.309 +CNRLTestAppUi::~CNRLTestAppUi()
   1.310 +	{
   1.311 +	RemoveFromStack(iNRLTestControl);
   1.312 +	delete iNRLTestControl;
   1.313 +	for (TInt i=0; i<iFailedTests->Count();i++)
   1.314 +		iFailedTests->Delete(i);
   1.315 +	delete iFailedTests;
   1.316 +	}
   1.317 +
   1.318 +void CNRLTestAppUi::HandleCommandL(TInt aCommand)
   1.319 +	{
   1.320 +	switch(aCommand)
   1.321 +		{
   1.322 +		case EAppCmdExit:
   1.323 +			Exit();
   1.324 +			break;
   1.325 +		case EAppCmdTest:
   1.326 +			StartTestsL ();
   1.327 +			break;
   1.328 +		default:
   1.329 +			break;
   1.330 +		}
   1.331 +	} 
   1.332 +
   1.333 +
   1.334 +_LIT(KTestAnnouncer,"----------------");
   1.335 +_LIT(KLocaleTestTitle,"Locale ");
   1.336 +_LIT(KResourceTestTitle,"Application Resource ");
   1.337 +_LIT(KCharSetNamesTest,"Charset Names ");
   1.338 +_LIT(KFEPNameTestTitle,"FEP Names ");
   1.339 +_LIT(KCollationTestTitle, "Collation Table ");
   1.340 +_LIT(KTDisplayMessaging,"Messaging Resources ");
   1.341 +_LIT(KBIFTestTitle,"BIF Files ");
   1.342 +_LIT(KPrinterNameTestTitle,"Printer Names ");
   1.343 +_LIT(KLocalisableBimap,"Bitmap Files ");
   1.344 +_LIT(KOriginalBitmapPath,"z:\\resource\\apps\\testnrl.mbm");
   1.345 +_LIT(KNonROM,"Non-ROM");
   1.346 +
   1.347 +void CNRLTestAppUi::WriteTestHeader(const TDesC& aTestHeader) const 
   1.348 +	{
   1.349 +	iNRLTestControl->PrintToScreen(KNewLine);
   1.350 +	iNRLTestControl->PrintToScreen(aTestHeader);
   1.351 +	iNRLTestControl->PrintLineToScreen (_L("Test"));
   1.352 +	iNRLTestControl->PrintToScreen(KNewLine);
   1.353 +
   1.354 +	}
   1.355 +
   1.356 +
   1.357 +void CNRLTestAppUi::StartTestsL ()
   1.358 +	{
   1.359 +	TestLocaleL(KLocaleTestTitle);
   1.360 +	TestResourcesL (KResourceTestTitle);
   1.361 +	TestCharSetNamesL(KCharSetNamesTest);
   1.362 +	TestCollation(KCollationTestTitle);
   1.363 +	TestFEPNamesL(KFEPNameTestTitle);
   1.364 +	TestDisplayMessagingL(KTDisplayMessaging);
   1.365 +	TestBIFL(KBIFTestTitle);
   1.366 +	TestPrinterNameL (KPrinterNameTestTitle);
   1.367 +	TestLocalisableBitmapL (KLocalisableBimap);
   1.368 +	ReportEndResult();
   1.369 +	
   1.370 +	}
   1.371 +
   1.372 +
   1.373 +void CNRLTestAppUi::TestLocaleL (const TDesC& aTestHeader)
   1.374 +	{
   1.375 +
   1.376 +	// print on console that we are starting the Locale Testing
   1.377 +	// just checking it is not enough, need to display as well that 
   1.378 +	// the result is as expected. 
   1.379 +	//Test a few other things besides the 
   1.380 +	// locale number, some thing like a currency symbol. == $$$ 
   1.381 +	
   1.382 +	WriteTestHeader(aTestHeader);
   1.383 +	iNRLTestControl->PrintLineToScreen(_L("Have to ensure that the correct locale is picked up"));
   1.384 +	iNRLTestControl->PrintLineToScreen(_L("Expected Locale with language extension"));
   1.385 +
   1.386 +	TInt language; 
   1.387 +	(void)HAL::Get(HAL::ELanguageIndex,language);
   1.388 +	iNRLTestControl->PrintLineToScreen(_L("%d"),language);
   1.389 +	iNRLTestControl->PrintToScreen(_L("Current Locales language extension:	"));
   1.390 +
   1.391 +	TInt currentLangId;
   1.392 +	currentLangId = TInt(User::Language());
   1.393 +	iNRLTestControl->PrintLineToScreen(_L("%d"),currentLangId);
   1.394 +
   1.395 +	if (currentLangId == 95 )
   1.396 +		{
   1.397 +		TCurrencySymbol theCurrencySymbol;
   1.398 +		_LIT(KExpectedCurrencySymbol,"$$$");
   1.399 +		if(theCurrencySymbol==KExpectedCurrencySymbol)
   1.400 +			{
   1.401 +			iNRLTestControl->PrintLineToScreen(_L("The correct locale was loaded"));
   1.402 +			Pass(aTestHeader);
   1.403 +			}
   1.404 +		}
   1.405 +	else
   1.406 +		{
   1.407 +		iNRLTestControl->PrintToScreen(_L("The correct locale was not loaded"));
   1.408 +		FailL(aTestHeader);
   1.409 +		}
   1.410 +	}
   1.411 +
   1.412 +void CNRLTestAppUi::TestResourcesL(const TDesC& aTestHeader)
   1.413 +	{
   1.414 +	WriteTestHeader(aTestHeader);
   1.415 +	iNRLTestControl->PrintLineToScreen (_L("Reading information from resource file..."));
   1.416 +
   1.417 +	TResourceReader resourceReader;
   1.418 +	CCoeEnv::Static()->CreateResourceReaderLC(resourceReader,R_NRL_COLLATE);
   1.419 +	CDesCArray* collation=new(ELeave) CDesCArrayFlat(3);
   1.420 +	CleanupStack::PushL(collation);
   1.421 +	TInt n=resourceReader.ReadUint16();
   1.422 +	
   1.423 +	for (TInt i=0;i<n;i++)
   1.424 +		collation->AppendL(resourceReader.ReadTPtrC());
   1.425 +
   1.426 +	for (TInt j=0;j<n;j++)
   1.427 +		{
   1.428 +		iNRLTestControl->PrintLineToScreen((*collation)[j]);
   1.429 +		}
   1.430 +	
   1.431 +	_LIT(KResourceData,"David");
   1.432 +	TInt resourceTest; 
   1.433 +	collation->Find(KResourceData,resourceTest,ECmpCollated);
   1.434 +	if(resourceTest!=collation->MdcaCount())
   1.435 +		{
   1.436 +		Pass(aTestHeader);
   1.437 +		}
   1.438 +	else
   1.439 +		{
   1.440 +		FailL(aTestHeader);
   1.441 +		}
   1.442 +	CleanupStack::PopAndDestroy(2);//resourceReader,collation
   1.443 +	}
   1.444 +
   1.445 +void CNRLTestAppUi::TestCharSetNamesL(const TDesC& aTestHeader)
   1.446 +	{
   1.447 +	WriteTestHeader(aTestHeader);
   1.448 +	RFs& aSession = iCoeEnv->FsSession();
   1.449 +	CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* charsetArray=CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableLC(aSession);
   1.450 +	MDesCArray* nameArry=CCnvCharacterSetNames::NewL(aSession,charsetArray->Array());
   1.451 +	TInt index=((CCnvCharacterSetNames*)nameArry)->IndexOfIdentifier(KCharacterSetIdentifierAscii);
   1.452 +	TInt testResult;
   1.453 +	testResult=0;
   1.454 +	TPtrC bigFive=nameArry->MdcaPoint(index);
   1.455 +	TInt findNonROM;
   1.456 +	findNonROM=bigFive.Find(KNonROM);
   1.457 +	if(findNonROM!=KErrNotFound)
   1.458 +		{
   1.459 +		iNRLTestControl->PrintToScreen(KNewLine);
   1.460 +		iNRLTestControl->PrintLineToScreen(bigFive);
   1.461 +		testResult=1;
   1.462 +		}
   1.463 +	if(testResult)
   1.464 +		Pass(aTestHeader);
   1.465 +	else
   1.466 +		FailL(aTestHeader);
   1.467 +	delete nameArry;
   1.468 +	CleanupStack::PopAndDestroy();//charsetArray
   1.469 +	}
   1.470 +
   1.471 +
   1.472 +
   1.473 +void CNRLTestAppUi::TestCollation(const TDesC& aTestHeader)
   1.474 +	{
   1.475 +	WriteTestHeader(aTestHeader);
   1.476 +	iNRLTestControl->PrintToScreen(_L("This test locale has it's own collation table\n"));
   1.477 +	iNRLTestControl->PrintToScreen(_L("Set Collation values in the order E-D-C-B-A\n"));
   1.478 +	iNRLTestControl->PrintToScreen(_L("Loading a few names which have been sorted using collation\n"));
   1.479 +	iNRLTestControl->PrintToScreen(_L("David should appear before BeiBei\n\n"));
   1.480 +	TResourceReader resourceReader;
   1.481 +	CCoeEnv::Static()->CreateResourceReaderLC(resourceReader,R_NRL_COLLATE);
   1.482 +	CDesCArray* collation=new(ELeave) CDesCArrayFlat(3);
   1.483 +	CleanupStack::PushL(collation);
   1.484 +	TInt n=resourceReader.ReadUint16();
   1.485 +	
   1.486 +	for (TInt i=0;i<n;i++)
   1.487 +		collation->AppendL(resourceReader.ReadTPtrC());
   1.488 +	//David is the first name stored in the array before the array is sorted.
   1.489 +	//When the array is sorted, David should still be the first name
   1.490 +	// because this locales collation table reverses the ordering between A & E 
   1.491 +	TPtrC david = (*collation)[0];
   1.492 +	collation->Sort(ECmpCollated);
   1.493 +	for (TInt j=0;j<n;j++)
   1.494 +		{
   1.495 +		iNRLTestControl->PrintLineToScreen((*collation)[j]);
   1.496 +		}
   1.497 +	
   1.498 +	TInt coltest;
   1.499 +	
   1.500 +	// searching for Davids name in the array,
   1.501 +	// according to the new collation rules David's name should be 
   1.502 +	// the first itm in the array. 
   1.503 +
   1.504 +	collation->Find(david,coltest,ECmpCollated);
   1.505 +	// if coltest=0 then Davids is the first item, 
   1.506 +	// the new collation table was used. 
   1.507 +	if (!coltest)
   1.508 +		{
   1.509 +		Pass(aTestHeader);
   1.510 +		}
   1.511 +	else
   1.512 +		{
   1.513 +		FailL(aTestHeader);
   1.514 +		}
   1.515 +		
   1.516 +	CleanupStack::PopAndDestroy(2);//resourceReader,collation
   1.517 +	}
   1.518 +
   1.519 +
   1.520 +void CNRLTestAppUi::TestFEPNamesL(const TDesC& aTestHeader)
   1.521 +	{
   1.522 +	WriteTestHeader(aTestHeader);
   1.523 +	iNRLTestControl->PrintLineToScreen (_L("Fep Names are stored in resource files in the fep directory in system"));
   1.524 +	iNRLTestControl->PrintLineToScreen (_L("Compiled new resources with the word Non-ROM added into a few test fep names"));
   1.525 +	
   1.526 +	RArray<CBaNamedPlugins::TResourceFile> arrayOfResourceFiles;
   1.527 +	CleanupStack::PushL(TCleanupItem(DestroyResourceFileArray, &arrayOfResourceFiles));//arrayOfResourceFiles
   1.528 +	RFs& fileServerSession=iCoeEnv->FsSession();
   1.529 +	TInt numberofsession=fileServerSession.ResourceCount();
   1.530 +	TInt i;
   1.531 +	TParse* parser=new(ELeave) TParse;
   1.532 +	CleanupStack::PushL(parser);//parser
   1.533 +	TFileName* fileName=new(ELeave) TFileName;
   1.534 +	CleanupStack::PushL(fileName);//fileName
   1.535 +	 
   1.536 +
   1.537 +	RArray<TUid> uidsOfAvailableFeps;
   1.538 +	CleanupClosePushL(uidsOfAvailableFeps);
   1.539 +	CDesCArray*  fileNamesOfAvailableFeps = new(ELeave) CDesCArrayFlat(EGranularity);
   1.540 +	CleanupDeletePushL(fileNamesOfAvailableFeps);//fileNamesOfAvailableFeps
   1.541 +	iCoeEnv->AvailableFepsL(uidsOfAvailableFeps,fileNamesOfAvailableFeps);//it is allocated some memory here!!!
   1.542 +	
   1.543 +	
   1.544 +	
   1.545 +	for (i=fileNamesOfAvailableFeps->MdcaCount()-1; i>=0; --i)
   1.546 +		{
   1.547 +		const TPtrC fullFileNameOfDll(fileNamesOfAvailableFeps->MdcaPoint(i));
   1.548 +		*fileName=TParsePtrC(fullFileNameOfDll).Name();
   1.549 +		fileName->Append(KLitResourceFileNameAppendage);
   1.550 +		User::LeaveIfError(parser->SetNoWild(*fileName, &fullFileNameOfDll, NULL));
   1.551 +		CBaNamedPlugins::TResourceFile resourceFile;
   1.552 +		resourceFile.iFullFileName=parser->FullName().AllocLC();
   1.553 +		resourceFile.iIdentifier=fullFileNameOfDll.AllocLC();
   1.554 +		resourceFile.iUid=uidsOfAvailableFeps[i];
   1.555 +		resourceFile.iFormat=CBaNamedPlugins::TResourceFile::EFormatTbuf;
   1.556 +		User::LeaveIfError(arrayOfResourceFiles.Append(resourceFile));
   1.557 +		CleanupStack::Pop(2, resourceFile.iFullFileName);//iFullFileName,iIdentifier
   1.558 +		}
   1.559 +	CleanupStack::PopAndDestroy(4, parser);//parser,fileName,uidsOfAvailableFeps,fileNamesOfAvailableFeps
   1.560 +
   1.561 +	CBaNamedPlugins::CParameters* parameters=CBaNamedPlugins::CParameters::NewLC(fileServerSession, arrayOfResourceFiles.Array());
   1.562 +	parameters->SetFallBackName(*this);
   1.563 +	CBaNamedPlugins* namedPlugins=CBaNamedPlugins::NewL(*parameters);//numberofsession increased after this
   1.564 +	numberofsession=fileServerSession.ResourceCount(); 
   1.565 +	const TInt numberOfAvailableFeps=namedPlugins->MdcaCount();
   1.566 +	TInt testResult; 
   1.567 +	testResult=0;
   1.568 +	for (i=0; i<numberOfAvailableFeps; ++i)
   1.569 +		{
   1.570 +		TPtrC fepNames = namedPlugins->MdcaPoint(i);
   1.571 +		RDebug::Print(fepNames);
   1.572 +		TInt findNonROM;
   1.573 +		findNonROM=fepNames.Find(KNonROM);
   1.574 +		if (findNonROM!=KErrNotFound)
   1.575 +			{
   1.576 +			iNRLTestControl->PrintLineToScreen(fepNames);
   1.577 +			testResult =1;
   1.578 +			}
   1.579 +		}
   1.580 +	if (testResult)
   1.581 +		{
   1.582 +		Pass(aTestHeader);
   1.583 +		}
   1.584 +	else
   1.585 +		{
   1.586 +		FailL(aTestHeader);
   1.587 +		}
   1.588 +	delete namedPlugins;
   1.589 +	CleanupStack::PopAndDestroy(2, &arrayOfResourceFiles);//arrayOfResourceFiles,parameters
   1.590 +	}
   1.591 +
   1.592 +HBufC* CNRLTestAppUi::FallBackNameL(const TDesC& aFullResourceFileName) const
   1.593 +	{
   1.594 +	const TPtrC nameAndExtension(TParsePtrC(aFullResourceFileName).NameAndExt());
   1.595 +	__ASSERT_DEBUG(nameAndExtension.Right(KLitResourceFileNameAppendage().Length())==KLitResourceFileNameAppendage, User::Panic(KPanicText,-1));
   1.596 +	return nameAndExtension.Left(nameAndExtension.Length()-KLitResourceFileNameAppendage().Length()).AllocL();
   1.597 +	}
   1.598 +
   1.599 +void CNRLTestAppUi::TestDisplayMessagingL(const TDesC& aTestHeader)
   1.600 +	{
   1.601 +	WriteTestHeader(aTestHeader);
   1.602 +	iNRLTestControl->PrintLineToScreen (_L("MTM are stored in resource files in the MTM directory in System"));
   1.603 +	iNRLTestControl->PrintLineToScreen (_L("Compiled new resources with the word Non-ROM added into the MTM resources"));
   1.604 +
   1.605 +	TDummyObserver obs;
   1.606 +	CMsvSession *session=CMsvSession::OpenSyncL(obs);
   1.607 +	CleanupStack::PushL(session);
   1.608 +	CClientMtmRegistry *reg=CClientMtmRegistry::NewL(*session);
   1.609 +	CleanupStack::PushL(reg);
   1.610 +	TInt count=reg->NumRegisteredMtmDlls();
   1.611 +	
   1.612 +	TInt testResult; 
   1.613 +	testResult=0;
   1.614 +	while(count--)
   1.615 +		{
   1.616 +		const CMtmDllInfo& info=reg->RegisteredMtmDllInfo(reg->MtmTypeUid(count));
   1.617 +		TPtrC mtmNames = info.HumanReadableName();
   1.618 +		TInt findNonROM;
   1.619 +		findNonROM=mtmNames.Find(KNonROM);
   1.620 +		if (findNonROM!=KErrNotFound)
   1.621 +			{
   1.622 +			iNRLTestControl->PrintLineToScreen (mtmNames);
   1.623 +			testResult =1;
   1.624 +			}
   1.625 +		
   1.626 +		}
   1.627 +
   1.628 +	CleanupStack::PopAndDestroy(reg);
   1.629 +
   1.630 +	CMsvEntry *entry=session->GetEntryL(KMsvRootIndexEntryId);
   1.631 +	CleanupStack::PushL(entry);
   1.632 +
   1.633 +	entry->SetEntryL(KMsvDraftEntryId);
   1.634 +	iNRLTestControl->PrintLineToScreen (entry->Entry().iDetails);
   1.635 +	
   1.636 +
   1.637 +	entry->SetEntryL(KMsvGlobalInBoxIndexEntryId);
   1.638 +	iNRLTestControl->PrintLineToScreen (entry->Entry().iDetails);
   1.639 +
   1.640 +	entry->SetEntryL(KMsvGlobalOutBoxIndexEntryId);
   1.641 +	iNRLTestControl->PrintLineToScreen (entry->Entry().iDetails);
   1.642 +
   1.643 +	entry->SetEntryL(KMsvSentEntryId);
   1.644 +	iNRLTestControl->PrintLineToScreen (entry->Entry().iDetails);
   1.645 +
   1.646 +	CleanupStack::PopAndDestroy(entry);
   1.647 +	CleanupStack::PopAndDestroy(session);
   1.648 +	
   1.649 +	if (testResult)
   1.650 +		{
   1.651 +		Pass(aTestHeader);
   1.652 +		}
   1.653 +	else
   1.654 +		{
   1.655 +		FailL(aTestHeader);
   1.656 +		}
   1.657 +	}
   1.658 +
   1.659 +
   1.660 +
   1.661 +void CNRLTestAppUi::TestBIFL (const TDesC& aTestHeader)
   1.662 +	{
   1.663 +	WriteTestHeader(aTestHeader);
   1.664 +	iNRLTestControl->PrintLineToScreen(_L("BIF files are now stored as resources in System\\BIf directory"));
   1.665 +	iNRLTestControl->PrintLineToScreen(_L("Compiled new BIF resources with the phrase Non-ROM added ... "));
   1.666 +
   1.667 +	RFs& gFs=iCoeEnv->FsSession();
   1.668 +	
   1.669 +	iNRLTestControl->PrintLineToScreen(_L("Opening & Searching DB"));
   1.670 +
   1.671 +	CBIODatabase* bioDB = CBIODatabase::NewL(gFs);
   1.672 +	CleanupStack::PushL( bioDB );
   1.673 +	iNRLTestControl->PrintLineToScreen(_L("Opened DB Successfully!"));
   1.674 +
   1.675 +	TInt testResult; 
   1.676 +	testResult=0;
   1.677 +	for (TInt i=0; i < bioDB->BIOCount(); i++)
   1.678 +		{
   1.679 +			const CBioInfoFileReader& bifReader = bioDB->BifReader(i);
   1.680 +
   1.681 +			TPtrC desc;
   1.682 +			desc.Set(bifReader.Description()); 
   1.683 +			TInt findNonROM;
   1.684 +			findNonROM=desc.Find((KNonROM));
   1.685 +			if (findNonROM!=KErrNotFound)
   1.686 +				{
   1.687 +				iNRLTestControl->PrintLineToScreen(desc);
   1.688 +				testResult =1;
   1.689 +				}
   1.690 +		}
   1.691 +
   1.692 +	if (testResult)
   1.693 +		{
   1.694 +		Pass(aTestHeader);
   1.695 +		}
   1.696 +	else
   1.697 +		{
   1.698 +		FailL(aTestHeader);
   1.699 +		}
   1.700 +	CleanupStack::PopAndDestroy();	// bioDB
   1.701 +	
   1.702 +	}
   1.703 +
   1.704 +void CNRLTestAppUi::TestPrinterNameL (const TDesC& aTestHeader)
   1.705 +	{
   1.706 +	
   1.707 +	WriteTestHeader(aTestHeader);
   1.708 +
   1.709 +	CDesCArray* list=new(ELeave) CDesCArrayFlat(EGranularity);
   1.710 +	CleanupStack::PushL(list);
   1.711 +
   1.712 +	CPrintSetup* aPrintSetup = CPrintSetup::NewL();
   1.713 +	CleanupStack::PushL(aPrintSetup);
   1.714 +	aPrintSetup->AddPrinterDriverDirL( KDefaultPrinterDriverPath );
   1.715 +	RFs& filesession = iCoeEnv->FsSession();
   1.716 +	CPrinterModelList* aModelList;
   1.717 +	aModelList = aPrintSetup->ModelNameListL(filesession);
   1.718 +	CEikonEnv::GetPrinterNamesL(aModelList,*list);
   1.719 +
   1.720 +	aPrintSetup->FreeModelList();
   1.721 +
   1.722 +	TInt foundNonRomResource=0; 
   1.723 +
   1.724 +	for (TInt i=0; i < list->Count(); ++i)
   1.725 +		{
   1.726 +		TPtrC desc;
   1.727 +		desc.Set((*list)[i]);
   1.728 +		TInt findNonROM; 
   1.729 +		findNonROM = desc.Find((KNonROM));
   1.730 +		if (findNonROM!=KErrNotFound)
   1.731 +			{
   1.732 +			iNRLTestControl->PrintLineToScreen (desc);
   1.733 +			foundNonRomResource=1;
   1.734 +			}
   1.735 +		}
   1.736 +	if (foundNonRomResource)
   1.737 +		Pass(aTestHeader);
   1.738 +	else
   1.739 +		FailL(aTestHeader);
   1.740 +
   1.741 +
   1.742 +	CleanupStack::PopAndDestroy(2); // list, aPrintSetup, aModelList
   1.743 +	
   1.744 +	}
   1.745 +
   1.746 +void CNRLTestAppUi::TestLocalisableBitmapL(const TDesC& aTestHeader)
   1.747 +	{
   1.748 +	WriteTestHeader(aTestHeader);
   1.749 +
   1.750 +	TFileName filename(KOriginalBitmapPath);
   1.751 +	CWsBitmap* aBitmap;
   1.752 +	aBitmap=iEikonEnv->CreateBitmapL(filename,1);
   1.753 +	TBool nonROM;
   1.754 +	nonROM=aBitmap->IsRomBitmap();
   1.755 +	if(nonROM)
   1.756 +		{
   1.757 +		FailL(aTestHeader);
   1.758 +		}
   1.759 +	else
   1.760 +		{
   1.761 +		iNRLTestControl->PrintLineToScreen(_L("Right, the bitmap loaded should not be in ROM"));
   1.762 +		Pass(aTestHeader);
   1.763 +		}
   1.764 +
   1.765 +	delete aBitmap;
   1.766 +	}
   1.767 +
   1.768 +
   1.769 +void CNRLTestAppUi::Pass(const TDesC& aTestHeader)
   1.770 +	{
   1.771 +	iNRLTestControl->PrintToScreen(KNewLine);
   1.772 +	iNRLTestControl->PrintLineToScreen(KTestAnnouncer);
   1.773 +	iNRLTestControl->PrintLineToScreen(_L("Expected new %S loaded"),&aTestHeader);
   1.774 +	iNRLTestControl->PrintLineToScreen(KTestAnnouncer);
   1.775 +	}
   1.776 +
   1.777 +void CNRLTestAppUi::FailL(const TDesC& aTestHeader)
   1.778 +	{
   1.779 +	iNRLTestControl->PrintToScreen(KNewLine);
   1.780 +	iNRLTestControl->PrintLineToScreen(KTestAnnouncer);
   1.781 +	iNRLTestControl->PrintLineToScreen(_L("Unexpected old %S loaded"),&aTestHeader);
   1.782 +	iNRLTestControl->PrintLineToScreen(KTestAnnouncer);
   1.783 +	iFailedTests->AppendL(aTestHeader);
   1.784 +
   1.785 +	}
   1.786 +
   1.787 +void CNRLTestAppUi::ReportEndResult() const
   1.788 +	{
   1.789 +	TInt failedTestsCount = iFailedTests->Count();
   1.790 +	if (failedTestsCount)
   1.791 +		{
   1.792 +		// Print a list of the Tests Failed 
   1.793 +		iNRLTestControl->PrintLineToScreen(_L("The following tests failed\n"));
   1.794 +		for (TInt i=0; i<failedTestsCount; ++i)
   1.795 +			{
   1.796 +			iNRLTestControl->PrintLineToScreen ((*iFailedTests)[i]);
   1.797 +			}
   1.798 +		}
   1.799 +	else
   1.800 +		{
   1.801 +		// No Tests Failed, say that new resources were loaded where expected to
   1.802 +		}
   1.803 +	}
   1.804 +
   1.805 +
   1.806 +//
   1.807 +//  --------------------- CNRLTestAppDoc class Definition ------------ 
   1.808 +//
   1.809 +
   1.810 +class CNRLTestAppDoc : public CEikDocument
   1.811 +	{
   1.812 +public:
   1.813 +	CNRLTestAppDoc(CEikApplication& aApp);
   1.814 +private:
   1.815 +	CEikAppUi* CreateAppUiL();
   1.816 +	};
   1.817 +
   1.818 +
   1.819 +CNRLTestAppDoc::CNRLTestAppDoc(CEikApplication& aApp):CEikDocument(aApp)
   1.820 +	{
   1.821 +	// Nothing else to do, just call the base class constructor
   1.822 +	//
   1.823 +	}
   1.824 +
   1.825 +CEikAppUi* CNRLTestAppDoc::CreateAppUiL()
   1.826 +	{
   1.827 +	return new (ELeave) CNRLTestAppUi;
   1.828 +	}
   1.829 +//
   1.830 +//  ------------------------------ CNRLTestApp ----------------------- 
   1.831 +//
   1.832 +
   1.833 +
   1.834 +const TUid KTestNRLid = {0x1000AC5D};
   1.835 +
   1.836 +class CNRLTestApp : public CEikApplication
   1.837 +	{
   1.838 +private:
   1.839 +	CApaDocument* CreateDocumentL();
   1.840 +	TUid AppDllUid() const;
   1.841 +
   1.842 +	};
   1.843 +
   1.844 +TUid CNRLTestApp::AppDllUid() const 
   1.845 +	{
   1.846 +	return KTestNRLid;
   1.847 +	}
   1.848 +
   1.849 +CApaDocument* CNRLTestApp::CreateDocumentL()
   1.850 +	{
   1.851 +	return new (ELeave) CNRLTestAppDoc(*this);
   1.852 +	}
   1.853 +
   1.854 +////////////////////////////////////////////////////////////////////////////////////////////
   1.855 +//
   1.856 +
   1.857 +	static CApaApplication* NewApplication()
   1.858 +		{
   1.859 +		return new CNRLTestApp;
   1.860 +		}
   1.861 +
   1.862 +	TInt E32Main()
   1.863 +		{
   1.864 +		return EikStart::RunApplication(&NewApplication);
   1.865 +		}
   1.866 +
   1.867 +