fbs/fontandbitmapserver/tfbs/tipctest.CPP
changeset 36 01a6848ebfd7
parent 0 5d03bc08d59c
child 116 171fae344dd4
equal deleted inserted replaced
0:5d03bc08d59c 36:01a6848ebfd7
     1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 1996-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    16 #include "fbsmessage.h"
    16 #include "fbsmessage.h"
    17 #include "../sfbs/UTILS.H"
    17 #include "../sfbs/UTILS.H"
    18 #include "tipctest.h"
    18 #include "tipctest.h"
    19 #include "fbsdefs.h"
    19 #include "fbsdefs.h"
    20 
    20 
       
    21 // Invalid parameters to be passed in SendCommand() calls.
       
    22 const TInt KInvalidParam1 = 963955448;
       
    23 const TInt KInvalidParam2 = 963955368;
       
    24 const TInt KInvalidParam3 = 963955300;
       
    25 const TInt KInvalidParam4 = 963955232;
    21 
    26 
    22 CTIPCTest::CTIPCTest(CTestStep* aStep):
    27 CTIPCTest::CTIPCTest(CTestStep* aStep):
    23 	CTGraphicsBase(aStep),
    28 	CTGraphicsBase(aStep),
    24 	iFbs(NULL),
    29 	iFbs(NULL),
    25 	iFs(NULL)
    30 	iFs(NULL)
   102 	19. EFbsMessGetNearestFontToMaxHeightInPixels
   107 	19. EFbsMessGetNearestFontToMaxHeightInPixels
   103 	20. EFbsMessShapeText
   108 	20. EFbsMessShapeText
   104 	21. EFbsMessShapeDelete
   109 	21. EFbsMessShapeDelete
   105 	22. EFbsMessSetTwipsHeight
   110 	22. EFbsMessSetTwipsHeight
   106 	23. EFbsMessGetTwipsHeight	
   111 	23. EFbsMessGetTwipsHeight	
       
   112 	@SYMTestExpectedResults
       
   113     Test should pass
       
   114 
       
   115     @SYMTestCaseID
       
   116     TI18N-GDI-CIT-4086
       
   117 
       
   118     @SYMTestCaseDesc
       
   119     Test if FBS can handle invalid messages correctly
       
   120     and panic the client as needed.
       
   121 
       
   122     @SYMTestActions
       
   123 	24. EFbsMessGetFontTable
       
   124 	25. EFbsMessReleaseFontTable
       
   125 	26. EFbsMessGetGlyphOutline
       
   126 	27.EFbsMessReleaseGlyphOutline
   107 	
   127 	
   108 	@SYMTestExpectedResults
   128 	@SYMTestExpectedResults
   109 	Test should pass
   129 	Test should pass
   110 */
   130 */
   111 void CTIPCTest::RunTestCaseL(TInt aCurTestCase)
   131 void CTIPCTest::RunTestCaseL(TInt aCurTestCase)
   156 		TEST(EFalse);
   176 		TEST(EFalse);
   157 		TestComplete();
   177 		TestComplete();
   158 		break;
   178 		break;
   159 	case 7:
   179 	case 7:
   160 		INFO_PRINTF1(_L("Add font store file with huge length\r\n"));
   180 		INFO_PRINTF1(_L("Add font store file with huge length\r\n"));
   161 		iFbs->SendCommand(EFbsMessAddFontStoreFile, 963955448, 963955368, 963955300, 963955232);
   181 		iFbs->SendCommand(EFbsMessAddFontStoreFile, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   162 		TEST(EFalse);
   182 		TEST(EFalse);
   163 		TestComplete();
   183 		TestComplete();
   164 		break;
   184 		break;
   165 	case 8:
   185 	case 8:
   166 		INFO_PRINTF1(_L("Install font store file with negative length\r\n"));
   186 		INFO_PRINTF1(_L("Install font store file with negative length\r\n"));
   168 		TEST(EFalse);
   188 		TEST(EFalse);
   169 		TestComplete();
   189 		TestComplete();
   170 		break;
   190 		break;
   171 	case 9:
   191 	case 9:
   172 		INFO_PRINTF1(_L("Install font store file with huge length\r\n"));
   192 		INFO_PRINTF1(_L("Install font store file with huge length\r\n"));
   173 		iFbs->SendCommand(EFbsMessInstallFontStoreFile, 963955448, 963955368, 963955300, 963955232);
   193 		iFbs->SendCommand(EFbsMessInstallFontStoreFile, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   174 		TEST(EFalse);
   194 		TEST(EFalse);
   175 		TestComplete();
   195 		TestComplete();
   176 		break;
   196 		break;
   177 	case 10:
   197 	case 10:
   178 		INFO_PRINTF1(_L("Remove font store file with active references\r\n"));
   198 		INFO_PRINTF1(_L("Remove font store file with active references\r\n"));
   187 		TEST(EFalse);
   207 		TEST(EFalse);
   188 		TestComplete();
   208 		TestComplete();
   189 		break;
   209 		break;
   190 	case 12:
   210 	case 12:
   191 		INFO_PRINTF1(_L("Rasterize with invalid bitmap handle\r\n"));
   211 		INFO_PRINTF1(_L("Rasterize with invalid bitmap handle\r\n"));
   192 		iFbs->SendCommand(EFbsMessRasterize, 963955448, 963955368, 963955300, 963955232);
   212 		iFbs->SendCommand(EFbsMessRasterize, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   193 		TEST(EFalse);
   213 		TEST(EFalse);
   194 		TestComplete();
   214 		TestComplete();
   195 		break;
   215 		break;
   196 	case 13:
   216 	case 13:
   197 		INFO_PRINTF1(_L("Face Attribute with invalid bitmap handle\r\n"));
   217 		INFO_PRINTF1(_L("Face Attribute with invalid bitmap handle\r\n"));
   198 		iFbs->SendCommand(EFbsMessFaceAttrib, 963955448, 963955368, 963955300, 963955232);
   218 		iFbs->SendCommand(EFbsMessFaceAttrib, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   199 		TEST(EFalse);
   219 		TEST(EFalse);
   200 		TestComplete();
   220 		TestComplete();
   201 		break;
   221 		break;
   202 	case 14:
   222 	case 14:
   203 		INFO_PRINTF1(_L("Has Character with invalid bitmap handle\r\n"));
   223 		INFO_PRINTF1(_L("Has Character with invalid bitmap handle\r\n"));
   204 		iFbs->SendCommand(EFbsMessHasCharacter, 963955448, 963955368, 963955300, 963955232);
   224 		iFbs->SendCommand(EFbsMessHasCharacter, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   205 		TEST(EFalse);
   225 		TEST(EFalse);
   206 		TestComplete();
   226 		TestComplete();
   207 		break;
   227 		break;
   208 	case 15:
   228 	case 15:
   209 		INFO_PRINTF1(_L("Name Alias with huge alias name length\r\n"));
   229 		INFO_PRINTF1(_L("Name Alias with huge alias name length\r\n"));
   210 		iFbs->SendCommand(EFbsMessFontNameAlias, 963955448, 963955368, 963955300, 963955232);
   230 		iFbs->SendCommand(EFbsMessFontNameAlias, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   211 		TEST(EFalse);
   231 		TEST(EFalse);
   212 		TestComplete();
   232 		TestComplete();
   213 		break;
   233 		break;
   214 	case 16:
   234 	case 16:
   215 		INFO_PRINTF1(_L("Get nearest font to design height in twips with invalid typeface name length\r\n"));
   235 		INFO_PRINTF1(_L("Get nearest font to design height in twips with invalid typeface name length\r\n"));
   235 		TEST(EFalse);
   255 		TEST(EFalse);
   236 		TestComplete();
   256 		TestComplete();
   237 		break;
   257 		break;
   238 	case 20:
   258 	case 20:
   239 		INFO_PRINTF1(_L("Shape text with invalid bitmap font handle\r\n"));
   259 		INFO_PRINTF1(_L("Shape text with invalid bitmap font handle\r\n"));
   240 		iFbs->SendCommand(EFbsMessShapeText, 963955448, 963955368, 963955300, 963955232);
   260 		iFbs->SendCommand(EFbsMessShapeText, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   241 		TEST(EFalse);
   261 		TEST(EFalse);
   242 		TestComplete();
   262 		TestComplete();
   243 		break;
   263 		break;
   244 	case 21:
   264 	case 21:
   245 		INFO_PRINTF1(_L("Shape delete with invalid bitmap font handle\r\n"));
   265 		INFO_PRINTF1(_L("Shape delete with invalid bitmap font handle\r\n"));
   246 		iFbs->SendCommand(EFbsMessShapeDelete, 963955448, 963955368, 963955300, 963955232);
   266 		iFbs->SendCommand(EFbsMessShapeDelete, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   247 		TEST(EFalse);
   267 		TEST(EFalse);
   248 		TestComplete();
   268 		TestComplete();
   249 		break;
   269 		break;
   250 	case 22:
   270 	case 22:
   251 		INFO_PRINTF1(_L("Set twips height with invalid font handle\r\n"));
   271 		INFO_PRINTF1(_L("Set twips height with invalid font handle\r\n"));
   252 		iFbs->SendCommand(EFbsMessSetTwipsHeight, 963955448, 963955368, 963955300, 963955232);
   272 		iFbs->SendCommand(EFbsMessSetTwipsHeight, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   253 		TEST(EFalse);
   273 		TEST(EFalse);
   254 		TestComplete();
   274 		TestComplete();
   255 		break;
   275 		break;
   256 	case 23:
   276 	case 23:
   257 		INFO_PRINTF1(_L("Get twips height with invalid font handle\r\n"));
   277 		INFO_PRINTF1(_L("Get twips height with invalid font handle\r\n"));
   258 		((CTIPCTestStep*)iStep)->SetOverallTestStepID(_L("GRAPHICS-FBSERV-0603"));
   278 		((CTIPCTestStep*)iStep)->SetOverallTestStepID(_L("GRAPHICS-FBSERV-0603"));
   259 		((CTIPCTestStep*)iStep)->RecordTestResultL();
   279 		((CTIPCTestStep*)iStep)->RecordTestResultL();
   260 		((CTIPCTestStep*)iStep)->CloseTMSGraphicsStep();
   280 		((CTIPCTestStep*)iStep)->CloseTMSGraphicsStep();
   261 		iFbs->SendCommand(EFbsMessGetTwipsHeight, 963955448, 963955368, 963955300, 963955232);
   281 		iFbs->SendCommand(EFbsMessGetTwipsHeight, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   262 		TEST(EFalse);
   282 		TEST(EFalse);
   263 		TestComplete();
   283 		TestComplete();
   264 		break;	
   284 		break;	
   265 	case 24:
   285 	case 24:
       
   286 		INFO_PRINTF1(_L("Get Font Table with wrong msg\r\n"));
       
   287 		iFbs->SendCommand(EFbsMessGetFontTable, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);   
       
   288 		TEST(EFalse); 
       
   289 		TestComplete();
       
   290 		break;
       
   291 	case 25:
       
   292 		INFO_PRINTF1(_L("Release Font Table with wrong msg\r\n"));
       
   293 		iFbs->SendCommand(EFbsMessReleaseFontTable, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);   
       
   294 		TEST(EFalse); 
       
   295 		TestComplete();
       
   296 		break;    
       
   297 	case 26:
       
   298 		INFO_PRINTF1(_L("Get Glyph outline with wrong msg\r\n"));
       
   299 		iFbs->SendCommand(EFbsMessGetGlyphOutline,KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);   
       
   300 		TEST(EFalse); 
       
   301 		TestComplete();
       
   302 		break;
       
   303 	case 27:
       
   304 		INFO_PRINTF1(_L("Release Glyph outline with wrong msg\r\n"));
       
   305 		iFbs->SendCommand(EFbsMessReleaseGlyphOutline, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);   
       
   306 		TEST(EFalse); 
       
   307 		TestComplete();
       
   308 		break;
       
   309 	case 28:
   266 		TestComplete();
   310 		TestComplete();
   267 		break;
   311 		break;
   268 		}
   312 		}
   269 	}
   313 	}
   270 	
   314 	
   318 	ptr1.Copy(KDefault);
   362 	ptr1.Copy(KDefault);
   319 	CleanupStack::PopAndDestroy(buf1);
   363 	CleanupStack::PopAndDestroy(buf1);
   320 	args.Set(0, &ptr1);	
   364 	args.Set(0, &ptr1);	
   321 	SendReceive(aFunctionNumber, args);
   365 	SendReceive(aFunctionNumber, args);
   322 	}
   366 	}
   323 	
   367 
   324 	
       
   325 void CTIPCTest::LoadFontsL(const TDesC& aFontsDir)
       
   326 	{
       
   327 	RFs fileSys;
       
   328 	User::LeaveIfError(fileSys.Connect());
       
   329 
       
   330 	TFindFile fileFinder(fileSys);
       
   331 	CDir* foundFileList = NULL;
       
   332 	
       
   333 	_LIT(KFBSERVFontFilePattern, "*");
       
   334 	TInt findFileComplete = fileFinder.FindWildByDir(KFBSERVFontFilePattern,aFontsDir,foundFileList);
       
   335 
       
   336 	TRAPD(addFileError, LoadFontFromFilelistL(findFileComplete, foundFileList, fileFinder));
       
   337 	TEST(addFileError == KErrNone);
       
   338 		
       
   339 	fileSys.Close();
       
   340 	}
       
   341 
       
   342 void CTIPCTest::LoadFontFromFilelistL(TInt aFindFileComplete, CDir* aFoundFileList, TFindFile& aFileFinder)
       
   343 	{
       
   344 	TUid id1 = TUid::Uid(0);
       
   345 	while (!aFindFileComplete)
       
   346 		{
       
   347 		CleanupStack::PushL(aFoundFileList);
       
   348 
       
   349 		const TInt foundFileCount = aFoundFileList->Count();
       
   350 		for (TInt i = 0; i < foundFileCount; i++)
       
   351 			{			
       
   352 			TParse parse;
       
   353 			if (parse.Set((*aFoundFileList)[i].iName,&aFileFinder.File(),NULL) == KErrNone)
       
   354 				{
       
   355 				// Get filename and extension of font proposing to be loaded
       
   356 				TPtrC fontFilename = parse.NameAndExt();
       
   357 				id1=iFs->AddFileL(parse.FullName());
       
   358 				
       
   359 				iFs->RemoveFile(KNullUid);
       
   360 				
       
   361 				}
       
   362 			}
       
   363 		CleanupStack::PopAndDestroy(aFoundFileList); 
       
   364 		aFindFileComplete = aFileFinder.FindWild(aFoundFileList);
       
   365 		}
       
   366 	}
       
   367 
   368 
   368 //--------------
   369 //--------------
   369 __CONSTRUCT_STEP__(IPCTest)
   370 __CONSTRUCT_STEP__(IPCTest)
   370 
   371