lafagnosticuifoundation/cone/tef/TConeErrorMsgStep.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @test
       
    19  @internalComponent - Internal Symbian test code 
       
    20 */
       
    21 
       
    22 #include <coemain.h>
       
    23 #include <bautils.h>
       
    24 #include <apacmdln.h> 
       
    25 #include <fbs.h>
       
    26 #include <imageconversion.h>
       
    27 #include <bitmaptransforms.h>
       
    28 #include "TConeErrorMsgStep.h"
       
    29 
       
    30 /**
       
    31   Single Argument Constructor for CConeErrorMsgTestAppUi class.\n
       
    32 */
       
    33 CConeErrorMsgTestAppUi::CConeErrorMsgTestAppUi(CTmsTestStep* aStep) :
       
    34 CTestCoeAppUi(aStep)
       
    35 {}
       
    36 /**
       
    37   Destructor for CConeErrorMsgTestAppUi class.\n
       
    38 */
       
    39 CConeErrorMsgTestAppUi::~CConeErrorMsgTestAppUi()
       
    40 {}
       
    41 
       
    42 /**
       
    43   Second phase Constructor for CConeErrorMsgTestAppUi class.\n
       
    44   Invokes the base class CTestCoeAppUi second phase constructor.\n
       
    45   Executes the test cases asynchronously using Autotest Manager.\n
       
    46 */
       
    47 void CConeErrorMsgTestAppUi::ConstructL()
       
    48 	{
       
    49 	CTestCoeAppUi::ConstructL();
       
    50 	
       
    51 	AutoTestManager().StartAutoTest();
       
    52 	}
       
    53 
       
    54 void CConeErrorMsgTestAppUi::TestLeaveWithErrorTextL(const TDesC& aErrorText, const TDesC* aContextErrorText, const TBool& aExceedMaxDesc)
       
    55 	{
       
    56 	RBuf testMsg;
       
    57 	testMsg.CreateL(aErrorText);
       
    58 	testMsg.CleanupClosePushL();
       
    59 	
       
    60 	TInt err=KErrNone;
       
    61 	
       
    62 	if (aContextErrorText)
       
    63 		{
       
    64 		RBuf testConMsg;
       
    65 		testConMsg.CreateL(*aContextErrorText);
       
    66 		testConMsg.CleanupClosePushL();
       
    67 		TRAP(err,iCoeEnv->LeaveWithErrorText(testMsg, &testConMsg));
       
    68 	
       
    69 		TDes& errConRxText = static_cast<CTestCoeEnv*>(iCoeEnv)->TestErrorContextText();
       
    70 		RBuf errConMsg;
       
    71 		errConMsg.CreateL(errConRxText);
       
    72 		errConMsg.CleanupClosePushL();
       
    73 		INFO_PRINTF3(_L("Err Cntxt Msg Tx: %S, Err Cntxt Msg Rx: %S"), &testConMsg, &errConMsg);
       
    74 		if (aExceedMaxDesc)
       
    75 			{
       
    76 			TEST(testConMsg!=errConMsg);
       
    77 			TEST(errConMsg.Length()==80); // KErrorContextTextLength
       
    78 			TEST(errConMsg[79]==KBaflCharTruncation);
       
    79 			testConMsg.Delete(80, 1); // remove the last char
       
    80 			testConMsg[79]=KBaflCharTruncation; // set the last char to the truncation char
       
    81 			TEST(testConMsg==errConMsg);
       
    82 			}
       
    83 		else
       
    84 			{
       
    85 			TEST(testConMsg==errConMsg);
       
    86 			}
       
    87 		
       
    88 		CleanupStack::PopAndDestroy(2);
       
    89 		}
       
    90 	else
       
    91 		{
       
    92 		TRAP(err,iCoeEnv->LeaveWithErrorText(testMsg));
       
    93 		
       
    94 		TDes& errConText = static_cast<CTestCoeEnv*>(iCoeEnv)->TestErrorContextText();
       
    95 		INFO_PRINTF3(_L("Actual Context Length: %d, Expected Context Length: %d"), errConText.Length(), 0);			
       
    96 		TEST(errConText.Length()==0);
       
    97 		}
       
    98 
       
    99 	INFO_PRINTF3(_L("Actual Leave Code: %d, Expected Leave Code: %d"), err, KErrExtendedWithText);
       
   100 	TEST(err==KErrExtendedWithText);
       
   101 	
       
   102 	TDes& errRxText = ((CTestCoeEnv *)iCoeEnv)->TestErrorText();
       
   103 	RBuf errMsg;
       
   104 	errMsg.CreateL(errRxText);
       
   105 	errMsg.CleanupClosePushL();
       
   106 	INFO_PRINTF3(_L("Err Msg Tx: %S, Err Msg Rx: %S"), &testMsg, &errMsg);
       
   107 	if (aExceedMaxDesc)
       
   108 		{
       
   109 		TEST(testMsg!=errMsg);
       
   110 		TEST(errMsg.Length()==80); // KErrorTextLength
       
   111 		TEST(errMsg[79]==KBaflCharTruncation);
       
   112 		testMsg.Delete(80, 1); // remove the last char
       
   113 		testMsg[79]=KBaflCharTruncation; // set the last char to the truncation char
       
   114 		TEST(testMsg==errMsg);
       
   115 		}
       
   116 	else
       
   117 		{
       
   118 		TEST(testMsg==errMsg);
       
   119 		}
       
   120 
       
   121 	CleanupStack::PopAndDestroy(2);
       
   122 	}
       
   123 
       
   124 /**
       
   125  Utility to close the dialogs once the screen has been compared
       
   126  with a previous capture of an expected display.
       
   127  */	
       
   128 void CConeErrorMsgTestAppUi::CloseDialogsL()
       
   129 	{	
       
   130 	User::LeaveIfError(iWs.Connect());
       
   131 	TInt wgFocus = iWs.GetFocusWindowGroup();
       
   132 
       
   133 	const TUint32 ENullWsHandle = 0xFFFFFFFF;	// Events delivered to this handle are thrown away
       
   134 	RWindowGroup wg = RWindowGroup(iWs);
       
   135 
       
   136 	wg.Construct(ENullWsHandle);
       
   137 	TInt wgId = wg.Identifier();
       
   138 
       
   139 	TWsEvent event;
       
   140 	event.SetType(EEventKey);
       
   141 	TKeyEvent *keyEvent = event.Key();
       
   142 	keyEvent->iCode = EKeyEscape;
       
   143 	keyEvent->iScanCode = EStdKeyEscape;
       
   144 	keyEvent->iModifiers = 0;
       
   145 
       
   146 	TInt limit = 0;
       
   147 	for(limit = 0; wgFocus != wgId && (limit < 50); limit++)
       
   148 		{
       
   149 		iWs.SendEventToAllWindowGroups(event);
       
   150 		wgFocus = iWs.GetFocusWindowGroup();
       
   151 		RDebug::Print(_L("CloseAllPanicWindowsL() - EKeyEscape sent to Windows Group"));
       
   152 		}
       
   153 
       
   154 	wg.Close();
       
   155 	iWs.Close();
       
   156 	}
       
   157 
       
   158 /**
       
   159  Utility for creating a easily readable bmp from a CFbsBitmap
       
   160  */
       
   161 
       
   162 void CConeErrorMsgTestAppUi::ConvertToBmpL(const CFbsBitmap* aBitmap, const TDesC* aFileName)
       
   163 	{
       
   164 	CImageEncoder * imageEncoder = CImageEncoder::FileNewL(iFs,*aFileName,CImageEncoder::EOptionAlwaysThread ,KImageTypeBMPUid);
       
   165 	CleanupStack::PushL(imageEncoder);
       
   166 	TRequestStatus status;
       
   167 	imageEncoder->Convert(&status,*aBitmap);
       
   168 	User::WaitForRequest(status);
       
   169 	CleanupStack::PopAndDestroy(imageEncoder);
       
   170 	}
       
   171 
       
   172 /**
       
   173    @SYMTestCaseID		    UIF-CONE-0008
       
   174 
       
   175    @SYMTestCaseDesc 	    Check use of CCoeEnv::LeaveWithErrorText() to set error text to 'Test Error Message'
       
   176   
       
   177    @SYMTestPriority   	    Critical
       
   178    
       
   179    @SYMTestType				Component Integration Test
       
   180   
       
   181    @SYMTestStatus 	  	    Implemented
       
   182     
       
   183    @SYMTestActions  	    Call CCoeEnv::LeaveWithErrorText() to set error text to 'Test Error Message'
       
   184    
       
   185    @SYMTestExpectedResults  CCoeEnv::iErrorText is set to 'Test Error Message'
       
   186    							CCoeEnv::iErrorContextText is zero'd
       
   187    							Function leaves with KErrExtendedWithText
       
   188  */
       
   189 void CConeErrorMsgTestAppUi::TestCase01L()
       
   190 	{
       
   191 	INFO_PRINTF1(_L("UIF-CONE-0008 - test case start"));
       
   192 	_LIT(KTestErrMsg, "Test Error Message");
       
   193 	TBuf<20> errText(KTestErrMsg);
       
   194 	TestLeaveWithErrorTextL(errText);
       
   195 	INFO_PRINTF1(_L("UIF-CONE-0008 - test case end"));
       
   196 	}
       
   197 
       
   198 /**
       
   199    @SYMTestCaseID		    UIF-CONE-0009
       
   200 
       
   201    @SYMTestCaseDesc 	    Check use of CCoeEnv::LeaveWithErrorText() to set error text to 'Test Error Message'
       
   202    							and error context text to 'Test Context Error Message'
       
   203   
       
   204    @SYMTestPriority   	    Critical
       
   205    
       
   206    @SYMTestType				Component Integration Test
       
   207   
       
   208    @SYMTestStatus 	  	    Implemented
       
   209     
       
   210    @SYMTestActions  	    Call CCoeEnv::LeaveWithErrorText() to set error text to 'Test Error Message'
       
   211    							and error context text to 'Test Context Error Message'
       
   212    
       
   213    @SYMTestExpectedResults  CCoeEnv::iErrorText is set to 'Test Error Message'
       
   214    							CCoeEnv::iErrorContextText is set to 'Test Context Error Message'
       
   215    							Function leaves with KErrExtendedWithText
       
   216  */
       
   217 void CConeErrorMsgTestAppUi::TestCase02L()
       
   218 	{
       
   219 	INFO_PRINTF1(_L("UIF-CONE-0009 - test case start"));
       
   220 	_LIT(KTestErrMsg, "Test Error Message");
       
   221 	TBuf<20> errText(KTestErrMsg);
       
   222 	_LIT(KTestErrConMsg, "Test Context Error Message");
       
   223 	TBuf<40> errConText(KTestErrConMsg);
       
   224 	TestLeaveWithErrorTextL(errText, &errConText);
       
   225 	INFO_PRINTF1(_L("UIF-CONE-0009 - test case end"));
       
   226 	}
       
   227 
       
   228 /**
       
   229    @SYMTestCaseID		    UIF-CONE-0010
       
   230 
       
   231    @SYMTestCaseDesc 	    Check use of CCoeEnv::LeaveWithErrorText() to set error text to ''
       
   232   
       
   233    @SYMTestPriority   	    Critical
       
   234    
       
   235    @SYMTestType				Component Integration Test
       
   236   
       
   237    @SYMTestStatus 	  	    Implemented
       
   238     
       
   239    @SYMTestActions  	    Call CCoeEnv::LeaveWithErrorText() to set error text to ''
       
   240    
       
   241    @SYMTestExpectedResults  CCoeEnv::iErrorText is set to ''
       
   242    							CCoeEnv::iErrorContextText is zero'd
       
   243    							Function leaves with KErrExtendedWithText
       
   244  */
       
   245 void CConeErrorMsgTestAppUi::TestCase03L()
       
   246 	{
       
   247 	INFO_PRINTF1(_L("UIF-CONE-0010 - test case start"));
       
   248 	_LIT(KTestErrMsg, "");
       
   249 	TBuf<20> errText(KTestErrMsg);
       
   250 	TestLeaveWithErrorTextL(errText);
       
   251 	INFO_PRINTF1(_L("UIF-CONE-0010 - test case end"));
       
   252 	}
       
   253 
       
   254 /**
       
   255    @SYMTestCaseID		    UIF-CONE-0011
       
   256 
       
   257    @SYMTestCaseDesc 	    Check use of CCoeEnv::LeaveWithErrorText() to set error text to ''
       
   258    							and error context text to ''
       
   259   
       
   260    @SYMTestPriority   	    Critical
       
   261    
       
   262    @SYMTestType				Component Integration Test
       
   263   
       
   264    @SYMTestStatus 	  	    Implemented
       
   265     
       
   266    @SYMTestActions  	    Call CCoeEnv::LeaveWithErrorText() to set error text to ''
       
   267    							and error context text to ''
       
   268    
       
   269    @SYMTestExpectedResults  CCoeEnv::iErrorText is set to ''
       
   270    							CCoeEnv::iErrorContextText is set to ''
       
   271    							Function leaves with KErrExtendedWithText
       
   272  */
       
   273 void CConeErrorMsgTestAppUi::TestCase04L()
       
   274 	{
       
   275 	INFO_PRINTF1(_L("UIF-CONE-0011 - test case start"));
       
   276 	_LIT(KTestErrMsg, "");
       
   277 	TBuf<20> errText(KTestErrMsg);
       
   278 	_LIT(KTestErrConMsg, "");
       
   279 	TBuf<40> errConText(KTestErrConMsg);
       
   280 	TestLeaveWithErrorTextL(errText, &errConText);
       
   281 	INFO_PRINTF1(_L("UIF-CONE-0011 - test case end"));
       
   282 	}
       
   283 
       
   284 /**
       
   285    @SYMTestCaseID		    UIF-CONE-0012
       
   286 
       
   287    @SYMTestCaseDesc 	    Check use of CCoeEnv::LeaveWithErrorText() to set error text to 'Test Max Error Message'
       
   288    							plus, filled to max length of 80 chars.
       
   289    							and error context text to 'Test Max Error Message' 
       
   290    							plus, filled to max length of 80 chars.
       
   291   
       
   292    @SYMTestPriority   	    Critical
       
   293    
       
   294    @SYMTestType				Component Integration Test
       
   295   
       
   296    @SYMTestStatus 	  	    Implemented
       
   297     
       
   298    @SYMTestActions  	    Call CCoeEnv::LeaveWithErrorText() to set error text to 'Test Max Error Message'
       
   299    							plus, filled to max length of 80 chars.
       
   300    							and error context text to 'Test Max Error Message'
       
   301    							plus, filled to max length of 80 chars.
       
   302    
       
   303    @SYMTestExpectedResults  CCoeEnv::iErrorText is set to 'Test Max Error Message34567890...'
       
   304    							CCoeEnv::iErrorContextText is set to 'Test Max Error Message34567...'
       
   305    							Function leaves with KErrExtendedWithText
       
   306  */
       
   307 void CConeErrorMsgTestAppUi::TestCase05L()
       
   308 	{
       
   309 	INFO_PRINTF1(_L("UIF-CONE-0012 - test case start"));
       
   310 	_LIT(KTestErrMsg, "Test Max Error Message3456789012345678901234567890123456789012345678901234567890"); // 80 chars
       
   311 	TBuf<80> errText(KTestErrMsg);
       
   312 	_LIT(KTestErrConMsg, "Test Max Error Message3456789012345678901234567890123456789012345678901234567890"); // 80 chars
       
   313 	TBuf<80> errConText(KTestErrConMsg);
       
   314 	TestLeaveWithErrorTextL(errText, &errConText);
       
   315 	INFO_PRINTF1(_L("UIF-CONE-0012 - test case end"));
       
   316 	}
       
   317 
       
   318 /**
       
   319    @SYMTestCaseID		    UIF-CONE-0013
       
   320 
       
   321    @SYMTestCaseDesc 	    Check use of CCoeEnv::LeaveWithErrorText() to set error text to 'Test Max Error Message'
       
   322    							plus, filled to exceed max length of 80 chars, i.e. 81 chars
       
   323    							and error context text to 'Test Max Error Message' 
       
   324    							plus, filled to exceed max length of 80 chars, i.e. 81 chars
       
   325   
       
   326    @SYMTestPriority   	    Critical
       
   327    
       
   328    @SYMTestType				Component Integration Test
       
   329   
       
   330    @SYMTestStatus 	  	    Implemented
       
   331     
       
   332    @SYMTestActions  	    Call CCoeEnv::LeaveWithErrorText() to set error text to 'Test Max Error Message'
       
   333    							plus, filled to exceed max length of 80 chars, i.e. 81 chars
       
   334    							and error context text to 'Test Max Error Message'
       
   335    							plus, filled to exceed max length of 80 chars, i.e. 81 chars
       
   336    
       
   337    @SYMTestExpectedResults  CCoeEnv::iErrorText is set to 'Test Max Error Message34567890...' 
       
   338    							and terminated by KBaflCharTruncation at the 80th char
       
   339    							CCoeEnv::iErrorContextText is set to 'Test Max Error Message34567...' 
       
   340    							and terminated by KBaflCharTruncation at the 80th char
       
   341    							Function leaves with KErrExtendedWithText
       
   342  */
       
   343 void CConeErrorMsgTestAppUi::TestCase06L()
       
   344 	{
       
   345 	INFO_PRINTF1(_L("UIF-CONE-0013 - test case start"));
       
   346 	_LIT(KTestErrMsg, "Test Max Error Message34567890123456789012345678901234567890123456789012345678901"); // 81 chars
       
   347 	TBuf<81> errText(KTestErrMsg);
       
   348 	_LIT(KTestErrConMsg, "Test Max Error Message34567890123456789012345678901234567890123456789012345678901"); // 81 chars
       
   349 	TBuf<81> errConText(KTestErrConMsg);
       
   350 	TestLeaveWithErrorTextL(errText, &errConText, ETrue);
       
   351 	INFO_PRINTF1(_L("UIF-CONE-0013 - test case end"));
       
   352 	}
       
   353 
       
   354 
       
   355 TSize CConeErrorMsgTestAppUi::CalculateScreenSize()
       
   356 	{
       
   357 	User::LeaveIfError(iWs.Connect());
       
   358 	CWsScreenDevice *screen;
       
   359 	screen=new(ELeave) CWsScreenDevice(iWs);
       
   360 	CleanupStack::PushL(screen);
       
   361 	User::LeaveIfError(screen->Construct(0));
       
   362 	TSize screenSize=screen->SizeInPixels();
       
   363 	CleanupStack::PopAndDestroy(screen);
       
   364 	iWs.Close();
       
   365     return screenSize;
       
   366 	}
       
   367 
       
   368 
       
   369 /**
       
   370    @SYMTestCaseID		    UIF-CONE-0014
       
   371 
       
   372    @SYMTestCaseDesc 	    Check use of CCoeEnv::LeaveWithErrorText() to display a dialog with error text of 
       
   373    							'Test Error Message' and error context text of 'Test Context Error Message' 
       
   374   
       
   375    @SYMTestPriority   	    Critical
       
   376    
       
   377    @SYMTestType				Component Integration Test
       
   378   
       
   379    @SYMTestStatus 	  	    Implemented
       
   380     
       
   381    @SYMTestActions  	    Start the TErrMsgApp, which takes the TailEnd set to "TestCase07", that
       
   382    							then sets up the Error Text and Context Error Text before calling
       
   383    							CCoeEnv::LeaveWithErrorText() to result in the display of the dialog.
       
   384    
       
   385    @SYMTestExpectedResults  Dialog with 'Test Context Error Message' and 'Test Error Message' displayed.
       
   386    							NOTE: Context error message is on line 1, with Test Error Message below.
       
   387    							
       
   388    @SYMTestCaseDependencies TErrMsgApp.exe (see TErrMsgApp.cpp)
       
   389  */
       
   390 void CConeErrorMsgTestAppUi::TestCase07()
       
   391 	{
       
   392 	INFO_PRINTF1(_L("UIF-CONE-0014 - test case start"));
       
   393 	INFO_PRINTF1(_L("ErrAndConMsg Dialog"));
       
   394 	_LIT8(KTestCaseName,"UIF-CONE-0014 ErrAndConMsg");
       
   395 	_LIT(KDbgBmp,          "c:\\test\\appfwk\\cone\\errandconmsg.bmp");
       
   396 	_LIT(KDbgConvBmp,      "c:\\test\\appfwk\\cone\\errandconmsg_conv_act.bmp");
       
   397 	_LIT(KDbgConvCompBmp,  "c:\\test\\appfwk\\cone\\errandconmsg_conv_exp.bmp");
       
   398 	_LIT(KDbgMbm,          "c:\\test\\appfwk\\cone\\errandconmsg.mbm");
       
   399 	_LIT(KTestCompareMbm,  "z:\\conetest\\errandconmsg.mbm");
       
   400 	_LIT(KTestCompareMbmh6,  "z:\\conetest\\errandconmsgh6.mbm");
       
   401 	_LIT(KTestCompareMbmh6vga,  "z:\\conetest\\errandconmsgh6vga.mbm");
       
   402 	_LIT(KTestCompareMbmNavi,  "z:\\conetest\\errandconmsgnavi.mbm");
       
   403 	
       
   404 	TSize screenSize = CalculateScreenSize();
       
   405 	TInt err;
       
   406 	
       
   407 	//test on h4 or emulator
       
   408 	if((screenSize.iHeight == 240 && screenSize.iWidth == 320) || (screenSize.iHeight == 240 && screenSize.iWidth == 640))
       
   409 		{
       
   410 		TRAP(err,TestErrorDialogL(	KTestCaseName, 
       
   411 									KTestCompareMbm,
       
   412 									&KDbgBmp, 
       
   413 									&KDbgConvBmp, 
       
   414 									&KDbgConvCompBmp,
       
   415 									&KDbgMbm));
       
   416 		}
       
   417 	//test on h6 QVGA
       
   418 	else if(screenSize.iHeight == 320 && screenSize.iWidth == 240)
       
   419 		{
       
   420 		TRAP(err,TestErrorDialogL(	KTestCaseName, 
       
   421 									KTestCompareMbmh6,
       
   422 									&KDbgBmp, 
       
   423 									&KDbgConvBmp, 
       
   424 									&KDbgConvCompBmp,
       
   425 									&KDbgMbm));
       
   426 		}
       
   427 	//test on h6 VGA
       
   428 	else if(screenSize.iHeight == 640 && screenSize.iWidth == 480)
       
   429 	    {
       
   430         TRAP(err,TestErrorDialogL(  KTestCaseName, 
       
   431                                     KTestCompareMbmh6vga,
       
   432                                     &KDbgBmp, 
       
   433                                     &KDbgConvBmp, 
       
   434                                     &KDbgConvCompBmp,
       
   435                                     &KDbgMbm));
       
   436         }   
       
   437 	//test on NaviEngine
       
   438 	else if(screenSize.iHeight == 480 && screenSize.iWidth == 640)
       
   439 		{
       
   440 		
       
   441 		TRAP(err,TestErrorDialogL(	KTestCaseName, 
       
   442 									KTestCompareMbmNavi,
       
   443 									&KDbgBmp, 
       
   444 									&KDbgConvBmp, 
       
   445 									&KDbgConvCompBmp,
       
   446 									&KDbgMbm));
       
   447 		
       
   448 		}
       
   449 	//It might be a new platform or unknown hardware
       
   450 	else
       
   451 		{
       
   452 		err = KErrNotFound;
       
   453 		ERR_PRINTF1(_L("UIF-CONE-0014 - Test case ERROR - Unknown Screen size"));
       
   454 		}
       
   455 	TEST(err==KErrNone);	
       
   456 	INFO_PRINTF1(_L("UIF-CONE-0014 - test case end"));
       
   457 	}
       
   458 
       
   459 /**
       
   460    @SYMTestCaseID		    UIF-CONE-0015
       
   461 
       
   462    @SYMTestCaseDesc 	    Check use of CCoeEnv::LeaveWithErrorText() to display a dialog with error text of 
       
   463    							'Test Error Message' 
       
   464   
       
   465    @SYMTestPriority   	    Critical
       
   466    
       
   467    @SYMTestType				Component Integration Test
       
   468   
       
   469    @SYMTestStatus 	  	    Implemented
       
   470     
       
   471    @SYMTestActions  	    Start the TErrMsgApp, which takes the TailEnd set to "TestCase08", that
       
   472    							then sets up the Error Text before calling
       
   473    							CCoeEnv::LeaveWithErrorText() to result in the display of the dialog.
       
   474    
       
   475    @SYMTestExpectedResults  Dialog with 'Test Error Message' displayed.
       
   476    							NOTE: No Context error message
       
   477    							
       
   478    @SYMTestCaseDependencies TErrMsgApp.exe (see TErrMsgApp.cpp)
       
   479  */
       
   480 void CConeErrorMsgTestAppUi::TestCase08()
       
   481 	{
       
   482 	INFO_PRINTF1(_L("UIF-CONE-0015 - test case start"));
       
   483 	INFO_PRINTF1(_L("ErrMsg Dialog"));
       
   484 	_LIT8(KTestCaseName,   "UIF-CONE-0015 ErrMsg");
       
   485 	_LIT(KDbgBmp,          "c:\\test\\appfwk\\cone\\errmsg.bmp");
       
   486 	_LIT(KDbgConvBmp,      "c:\\test\\appfwk\\cone\\errmsg_conv_act.bmp");
       
   487 	_LIT(KDbgConvCompBmp,  "c:\\test\\appfwk\\cone\\errmsg_conv_exp.bmp");
       
   488 	_LIT(KDbgMbm,          "c:\\test\\appfwk\\cone\\errmsg.mbm");
       
   489 	_LIT(KTestCompareMbm,  "z:\\conetest\\errmsg.mbm");
       
   490 	_LIT(KTestCompareMbmh6,  "z:\\conetest\\errmsgh6.mbm");
       
   491 	_LIT(KTestCompareMbmh6vga,  "z:\\conetest\\errmsgh6vga.mbm");
       
   492 	_LIT(KTestCompareMbmNavi, "z:\\conetest\\errmsgnavi.mbm");
       
   493 	
       
   494 	TSize screenSize = CalculateScreenSize();
       
   495 	TInt err;
       
   496 	//test on h4 or emulator
       
   497 	if((screenSize.iHeight == 240 && screenSize.iWidth == 320) || (screenSize.iHeight == 240 && screenSize.iWidth ==640))
       
   498 		{
       
   499 		TRAP(err,TestErrorDialogL(	KTestCaseName, 
       
   500 									KTestCompareMbm,
       
   501 									&KDbgBmp, 
       
   502 									&KDbgConvBmp, 
       
   503 									&KDbgConvCompBmp,
       
   504 									&KDbgMbm));
       
   505 		}
       
   506 	//test on h6 QVGA
       
   507 	else if(screenSize.iHeight == 320 && screenSize.iWidth == 240)
       
   508 		{
       
   509 		TRAP(err,TestErrorDialogL(	KTestCaseName, 
       
   510 									KTestCompareMbmh6,
       
   511 									&KDbgBmp, 
       
   512 									&KDbgConvBmp, 
       
   513 									&KDbgConvCompBmp,
       
   514 									&KDbgMbm));	
       
   515 		}
       
   516 	//test on h6 VGA
       
   517     else if(screenSize.iHeight == 640 && screenSize.iWidth == 480)
       
   518         {
       
   519         TRAP(err,TestErrorDialogL(  KTestCaseName, 
       
   520                                     KTestCompareMbmh6vga,
       
   521                                     &KDbgBmp,
       
   522                                     &KDbgConvBmp, 
       
   523                                     &KDbgConvCompBmp,
       
   524                                     &KDbgMbm));
       
   525         }
       
   526 	//test on NaviEngine
       
   527 	else if(screenSize.iHeight == 480 && screenSize.iWidth == 640)
       
   528 		{
       
   529 				
       
   530 		TRAP(err,TestErrorDialogL(	KTestCaseName, 
       
   531 									KTestCompareMbmNavi,
       
   532 									&KDbgBmp, 
       
   533 									&KDbgConvBmp, 
       
   534 									&KDbgConvCompBmp,
       
   535 									&KDbgMbm));	
       
   536 		}
       
   537 
       
   538 	//It might be a new platform or unknown hardware
       
   539 	else
       
   540 		{
       
   541 		err = KErrNotFound;
       
   542 		ERR_PRINTF1(_L("UIF-CONE-0015 - Test case ERROR - Unknown Screen size"));
       
   543 		}
       
   544 	TEST(err==KErrNone);	
       
   545 	INFO_PRINTF1(_L("UIF-CONE-0015 - test case end"));
       
   546 	}	
       
   547 
       
   548 /**
       
   549 	Utility function to setup and start TErrMsgApp for the display of the 
       
   550 	error dialogs when the App leaves due to a call to CCoeEnv::LeaveWithErrorText()
       
   551  */
       
   552 void CConeErrorMsgTestAppUi::TestErrorDialogL(const TDesC8& aTestCaseName,
       
   553 			const TDesC& aTestCompareMbm,
       
   554 			const TDesC* aDbgBmp,
       
   555 			const TDesC* aDbgConvBmp,
       
   556 			const TDesC* aDbgConvCompBmp,
       
   557 			const TDesC* aDbgMbm)
       
   558 	{
       
   559 	_LIT(KExeName,"z:\\sys\\bin\\TErrMsgApp.EXE");
       
   560 	RProcess process; 
       
   561 	TRequestStatus status;
       
   562 	TPtrC8 tailEnd;
       
   563 	tailEnd.Set(aTestCaseName); 
       
   564 	
       
   565 	// create and configure command line, with test case name in
       
   566 	// the tail end to be used by TErrMsgApp to determine what
       
   567 	// information is displayed in the error dialog
       
   568  	CApaCommandLine* cmdLine=CApaCommandLine::NewLC();
       
   569 	User::LeaveIfError(process.Create(KExeName, KNullDesC));
       
   570 	CleanupClosePushL(process);
       
   571 	cmdLine->SetExecutableNameL(KExeName);
       
   572 	cmdLine->SetTailEndL(tailEnd);
       
   573 	cmdLine->SetProcessEnvironmentL(process);
       
   574 	status =  KRequestPending;
       
   575 	process.Logon(status);
       
   576 	process.Resume();
       
   577 	
       
   578 	// allow the host process to start and display a dialog
       
   579 	User::After(1000000);
       
   580 	
       
   581 	// screen capture
       
   582 	CFbsBitmap* screenBitmap=new(ELeave) CFbsBitmap();
       
   583 	CleanupStack::PushL(screenBitmap);
       
   584 	User::LeaveIfError(iWs.Connect());
       
   585 	CWsScreenDevice *actualScreen;
       
   586 	actualScreen=new(ELeave) CWsScreenDevice(iWs);
       
   587 	CleanupStack::PushL(actualScreen);
       
   588 	User::LeaveIfError(actualScreen->Construct(0));
       
   589 	TSize screenSize=actualScreen->SizeInPixels();
       
   590 	TDisplayMode screenDisplayMode = actualScreen->DisplayMode();
       
   591 	User::LeaveIfError(screenBitmap->Create(screenSize, screenDisplayMode));
       
   592 	User::LeaveIfError(actualScreen->CopyScreenToBitmap(screenBitmap));
       
   593 	screenBitmap->Save(_L("c:\\screen.mbm"));
       
   594 
       
   595 	// load in expected bmp for comparison
       
   596 	CFbsBitmap* compareBitmap=new(ELeave) CFbsBitmap();
       
   597 	CleanupStack::PushL(compareBitmap);
       
   598 	TInt loadErr = compareBitmap->Load(aTestCompareMbm);
       
   599 	INFO_PRINTF3(_L("Load Error: %d Expected Error: %d"), loadErr, KErrNone);
       
   600 	TEST(loadErr==KErrNone);
       
   601 		
       
   602 	// compare expected and actual bitmaps
       
   603 	TInt lengthInBytes=screenBitmap->ScanLineLength(screenSize.iWidth, screenDisplayMode);
       
   604 	HBufC8* lineBufBitmap=HBufC8::NewLC(lengthInBytes);
       
   605 	TPtr8 lineBufBitmapPtr(lineBufBitmap->Des());
       
   606 	HBufC8* lineBufScreenBitmap=HBufC8::NewLC(lengthInBytes);
       
   607 	TPtr8 lineBufScreenBitmapPtr(lineBufScreenBitmap->Des());
       
   608 
       
   609 	// in the case of the emulator the colour palette used by
       
   610 	// windows can differ and therefore causes false failures to
       
   611 	// be reported. e.g. although the dialog is displayed it is
       
   612 	// subtly different shade of blue (techview), hence for 
       
   613 	// emulator test runs we purposely do not run a comparison
       
   614 	// of the screen.
       
   615 #ifndef __WINS__
       
   616 	INFO_PRINTF1(_L("Comparing expected vs actual screen bitmap"));
       
   617 	for (TInt index=0; index<screenSize.iHeight; index++)
       
   618 		{
       
   619 		compareBitmap->GetScanLine(lineBufBitmapPtr, TPoint(0,index), screenSize.iWidth, screenDisplayMode);
       
   620 		screenBitmap->GetScanLine(lineBufScreenBitmapPtr, TPoint(0,index), screenSize.iWidth, screenDisplayMode);
       
   621 		INFO_PRINTF2(_L("Scanline: %d"),index);
       
   622 		TEST(lineBufBitmapPtr.Compare(lineBufScreenBitmapPtr)==0);
       
   623 		}
       
   624 #endif
       
   625 
       
   626 	if (aDbgMbm)
       
   627 		{
       
   628 		// for debug purposes store the screen capture
       
   629 		// in c:\appfwk\test\cone\...
       
   630 		User::LeaveIfError(iFs.Connect());
       
   631 		iFs.MkDirAll(*aDbgBmp);
       
   632 		screenBitmap->Save(*aDbgBmp);
       
   633 		const TDesC* bmpArray[1];
       
   634 		bmpArray[0] = aDbgBmp;
       
   635 		TInt32 bmpIds[1];
       
   636 		bmpIds[0]=0;
       
   637 		CFbsBitmap::StoreL(*aDbgMbm,1,bmpArray,bmpIds);
       
   638 		// convert CFbsBitmap of screen capture to standard bmp to ease debug
       
   639 		ConvertToBmpL(screenBitmap, aDbgConvBmp);
       
   640 		// convert CFbsBitmap of expected bmp to standard bmp to ease debug
       
   641 		ConvertToBmpL(compareBitmap, aDbgConvCompBmp);
       
   642 		iFs.Close();
       
   643 		}
       
   644 	
       
   645 	// terminate the host process
       
   646 	process.Terminate(KErrNone);
       
   647 	
       
   648 	CleanupStack::PopAndDestroy(7);
       
   649 	iWs.Close();
       
   650 	
       
   651 	// send signal to close a dialog
       
   652 	CloseDialogsL();
       
   653 	// wait the host process for a termination
       
   654 	User::WaitForRequest(status);
       
   655 	
       
   656 	}
       
   657 
       
   658 /**
       
   659    Auxiliary Function for all Test Cases.\n
       
   660   
       
   661    The method is an override from CTestCoeAppUi.\n
       
   662    This function is called asynchronously by RunL function of the
       
   663    AutotestManager after previous test case is executed.\n
       
   664    Generates the KeyDown event and KeyUp Events alternatively.\n
       
   665  */
       
   666  
       
   667 void CConeErrorMsgTestAppUi::RunTestStepL(TInt aStepNum)
       
   668 	{
       
   669 	switch(aStepNum)
       
   670 		{
       
   671 		case 1:
       
   672 			{
       
   673 			SetTestStepID(_L("UIF-CONE-0008"));
       
   674 			TRAPD(err,TestCase01L());
       
   675 			TEST(err==KErrNone);	
       
   676 			RecordTestResultL();
       
   677 			break;
       
   678 			}
       
   679 		case 2:
       
   680 			{
       
   681 			SetTestStepID(_L("UIF-CONE-0009"));
       
   682 			TRAPD(err,TestCase02L());
       
   683 			TEST(err==KErrNone);	
       
   684 			RecordTestResultL();
       
   685 			break;
       
   686 			}
       
   687 		case 3:
       
   688 			{
       
   689 			SetTestStepID(_L("UIF-CONE-0010"));
       
   690 			TRAPD(err,TestCase03L());
       
   691 			TEST(err==KErrNone);	
       
   692 			RecordTestResultL();
       
   693 			break;
       
   694 			}
       
   695 		case 4:
       
   696 			{
       
   697 			SetTestStepID(_L("UIF-CONE-0011"));
       
   698 			TRAPD(err,TestCase04L());
       
   699 			TEST(err==KErrNone);	
       
   700 			RecordTestResultL();
       
   701 			break;
       
   702 			}
       
   703 		case 5:
       
   704 			{
       
   705 			SetTestStepID(_L("UIF-CONE-0012"));
       
   706 			TRAPD(err,TestCase05L());
       
   707 			TEST(err==KErrNone);	
       
   708 			RecordTestResultL();
       
   709 			break;
       
   710 			}
       
   711 		case 6:
       
   712 			{
       
   713 			SetTestStepID(_L("UIF-CONE-0013"));
       
   714 			TRAPD(err,TestCase06L());
       
   715 			TEST(err==KErrNone);	
       
   716 			RecordTestResultL();
       
   717 			break;
       
   718 			}
       
   719 		case 7:
       
   720 			SetTestStepID(_L("UIF-CONE-0014"));
       
   721 			TestCase07();
       
   722 			RecordTestResultL();
       
   723 			break;
       
   724 		case 8:
       
   725 			SetTestStepID(_L("UIF-CONE-0015"));
       
   726 			TestCase08();
       
   727 			RecordTestResultL();
       
   728 			CloseTMSGraphicsStep();
       
   729 			break;
       
   730 		default:
       
   731 			AutoTestManager().FinishAllTestCases(CAutoTestManager::EPass);
       
   732 			break;
       
   733 		}
       
   734 	}
       
   735 
       
   736 /**
       
   737   Completes the construction of the Control Environment(CCoeEnv object).\n
       
   738   Instantiates the CConeErrorMsgTestAppUi class which serves as a AppUi class.\n
       
   739   Sets the CConeErrorMsgTestAppUi object as the application's user interface object.\n
       
   740   Invokes the second phase constructor of the application's UI.\n
       
   741 */
       
   742 void CTConeErrorMsgStep::ConstructAppL(CCoeEnv* aCoe)
       
   743 	{ // runs inside a TRAP harness
       
   744 	aCoe->ConstructL();
       
   745 	CConeErrorMsgTestAppUi* appUi= new (ELeave) CConeErrorMsgTestAppUi(this);
       
   746 	aCoe->SetAppUi(appUi);
       
   747 	appUi->ConstructL();
       
   748 	}
       
   749 /**
       
   750   Constructor for CTConeErrorMsgStep class.\n
       
   751   Sets the test step name.\n
       
   752 */
       
   753 CTConeErrorMsgStep::CTConeErrorMsgStep()
       
   754 	{
       
   755 	SetTestStepName(KTConeErrorMsgStep);
       
   756 	}
       
   757 /**
       
   758   Destructor for CTConeErrorMsgStep class.\n
       
   759 */
       
   760 CTConeErrorMsgStep::~CTConeErrorMsgStep()
       
   761 {}
       
   762 
       
   763 /**
       
   764   Entry function for CTConeErrorMsgStep Test Step.\n
       
   765   Sets up the control environment.\n
       
   766   Constructs and Launches the CTConeErrorMsgStep Test application.\n
       
   767  
       
   768 */
       
   769 TVerdict CTConeErrorMsgStep::doTestStepL() // main function called by E32
       
   770 	{
       
   771 	INFO_PRINTF1(_L("Test Started"));
       
   772 	
       
   773 	PreallocateHALBuffer();
       
   774 
       
   775 	__UHEAP_MARK;
       
   776 
       
   777 	CCoeEnv* coe=new(ELeave) CCoeEnv;
       
   778 	TRAPD(err,ConstructAppL(coe));
       
   779 
       
   780 	if (!err)
       
   781 		coe->ExecuteD();
       
   782 	else
       
   783 		{
       
   784 		SetTestStepResult(EFail);
       
   785 		delete coe;
       
   786 		}
       
   787 
       
   788 	REComSession::FinalClose();	
       
   789 
       
   790 	__UHEAP_MARKEND;
       
   791 
       
   792 	INFO_PRINTF1(_L("Test Finished"));
       
   793 	return TestStepResult();
       
   794 	}
       
   795 
       
   796