os/graphics/fbs/fontandbitmapserver/tfbs/tipctest.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/fbs/fontandbitmapserver/tfbs/tipctest.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,400 @@
     1.4 +// Copyright (c) 1996-2010 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include "../sfbs/UTILS.H"
    1.20 +#include "tipctest.h"
    1.21 +#include "fbsdefs.h"
    1.22 +#include "fbsmessage.h"
    1.23 +
    1.24 +// Invalid parameters to be passed in SendCommand() calls.
    1.25 +const TInt KInvalidParam1 = 963955448;
    1.26 +const TInt KInvalidParam2 = 963955368;
    1.27 +const TInt KInvalidParam3 = 963955300;
    1.28 +const TInt KInvalidParam4 = 963955232;
    1.29 +
    1.30 +CTIPCTest::CTIPCTest(CTestStep* aStep):
    1.31 +	CTGraphicsBase(aStep),
    1.32 +	iFbs(NULL),
    1.33 +	iFs(NULL)
    1.34 +	{}
    1.35 +
    1.36 +CTIPCTest::~CTIPCTest()
    1.37 +	{
    1.38 +	if(iShutdownFbs)
    1.39 +		RFbsSession::GetSession()->SendCommand(EFbsMessShutdown);
    1.40 +	RFbsSession::Disconnect();
    1.41 +	delete iFs;
    1.42 +	iHeap->Close();
    1.43 +	}
    1.44 +
    1.45 +void CTIPCTest::ConstructL()
    1.46 +	{
    1.47 +	INFO_PRINTF1(_L("Font/Bitmap Server IPC Messages Testing"));
    1.48 +
    1.49 +	if(RFbsSession::Connect()==KErrNone)
    1.50 +		{
    1.51 +		RFbsSession::Disconnect();
    1.52 +		iShutdownFbs = EFalse;
    1.53 +		}
    1.54 +	else
    1.55 +		{
    1.56 +		FbsStartup();
    1.57 +		iShutdownFbs = ETrue;
    1.58 +		}
    1.59 +	RFbsSession::Connect();
    1.60 +	iFbs=RFbsSession::GetSession();
    1.61 +	
    1.62 +	if(!iShutdownFbs)
    1.63 +		{
    1.64 +		if(iClient.Connect() == KErrNone)
    1.65 +			{
    1.66 +			iShutdownFbs = EFalse;
    1.67 +			}
    1.68 +		else
    1.69 +			{
    1.70 +			iShutdownFbs = ETrue;
    1.71 +			}
    1.72 +		}
    1.73 +		
    1.74 +	iHeap=UserHeap::ChunkHeap(NULL,0x10000,0x10000);
    1.75 +	TRAPD(ret,iFs=CFontStore::NewL(iHeap));
    1.76 +	TEST(ret==KErrNone);
    1.77 +	TEST(iFs != NULL);
    1.78 +	
    1.79 +	}
    1.80 +
    1.81 +void CTIPCTest::RunTestCaseL(TInt aCurTestCase)
    1.82 +	{
    1.83 +	_LIT(KCaseNumber, "CaseNumber");
    1.84 +	
    1.85 +	TBool res = iStep->GetIntFromConfig(iStep->ConfigSection(), KCaseNumber, aCurTestCase);
    1.86 +	
    1.87 +	if(!res)
    1.88 +		{
    1.89 +		return;
    1.90 +		}
    1.91 +		
    1.92 +	switch(aCurTestCase)
    1.93 +		{
    1.94 +	/**
    1.95 +		@SYMTestCaseID
    1.96 +		GRAPHICS-FBSERV-0603
    1.97 +
    1.98 +		@SYMTestCaseDesc
    1.99 +		Tests the sending of commands to a FbsSession 
   1.100 +		server thru Inter Process Communication. Sends
   1.101 +		both valid and invalid commands.
   1.102 +
   1.103 +		@SYMTestActions
   1.104 +		Commands sent to the server:
   1.105 +		1. EFbsMessShutdown
   1.106 +		2. EFbsMessFontHeightInTwips
   1.107 +		3. EFbsMessFontHeightInTwips
   1.108 +		4. EFbsMessFontHeightInPixels
   1.109 +		5. EFbsMessFontHeightInPixels
   1.110 +		6. EFbsMessAddFontStoreFile
   1.111 +		7. EFbsMessAddFontStoreFile
   1.112 +		8. EFbsMessInstallFontStoreFile
   1.113 +		9. EFbsMessInstallFontStoreFile
   1.114 +		10. EFbsMessInstallFontStoreFile
   1.115 +		11. EFbsMessBitmapCreate
   1.116 +		12. EFbsMessRasterize
   1.117 +		13. EFbsMessFaceAttrib
   1.118 +		14. EFbsMessHasCharacter
   1.119 +		15. EFbsMessFontNameAlias
   1.120 +		16. EFbsMessGetNearestFontToDesignHeightInTwips
   1.121 +		17. EFbsMessGetNearestFontToMaxHeightInTwips
   1.122 +		18. EFbsMessGetNearestFontToDesignHeightInPixels
   1.123 +		19. EFbsMessGetNearestFontToMaxHeightInPixels
   1.124 +		20. EFbsMessShapeText
   1.125 +		21. EFbsMessShapeDelete
   1.126 +		22. EFbsMessSetTwipsHeight
   1.127 +		23. EFbsMessGetTwipsHeight
   1.128 +		
   1.129 +		@SYMTestExpectedResults
   1.130 +		Test should pass
   1.131 +	*/
   1.132 +	case 1:
   1.133 +		INFO_PRINTF1(_L("Shutdown"));
   1.134 +		iFbs->SendCommand(EFbsMessShutdown);
   1.135 +		TestComplete();
   1.136 +		break;
   1.137 +	case 2:
   1.138 +		INFO_PRINTF1(_L("Height in twips with negative typeface index"));
   1.139 +		iFbs->SendCommand(EFbsMessFontHeightInTwips, -1);	
   1.140 +		TEST(EFalse); // Previous line should have paniced 
   1.141 +		TestComplete();
   1.142 +		break;	
   1.143 +	case 3:
   1.144 +		INFO_PRINTF1(_L("Height in twips with invalid size"));
   1.145 +		iClient.SendInvalidSize(EFbsMessFontHeightInTwips);
   1.146 +		TEST(EFalse);
   1.147 +		TestComplete();
   1.148 +		break;
   1.149 +	case 4:
   1.150 +		INFO_PRINTF1(_L("Height in pixels with negative typeface index"));
   1.151 +		iFbs->SendCommand(EFbsMessFontHeightInPixels, -1);
   1.152 +		TEST(EFalse);
   1.153 +		TestComplete();
   1.154 +		break;
   1.155 +	case 5:
   1.156 +		INFO_PRINTF1(_L("Height in pixels with invalid size"));
   1.157 +		iClient.SendInvalidSize(EFbsMessFontHeightInPixels);
   1.158 +		TEST(EFalse);
   1.159 +		TestComplete();
   1.160 +		break;
   1.161 +	case 6:
   1.162 +		INFO_PRINTF1(_L("Add font store file with negative length"));
   1.163 +		iFbs->SendCommand(EFbsMessAddFontStoreFile, 0, -1);
   1.164 +		TEST(EFalse);
   1.165 +		TestComplete();
   1.166 +		break;
   1.167 +	case 7:
   1.168 +		INFO_PRINTF1(_L("Add font store file with huge length"));
   1.169 +		iFbs->SendCommand(EFbsMessAddFontStoreFile, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   1.170 +		TEST(EFalse);
   1.171 +		TestComplete();
   1.172 +		break;
   1.173 +	case 8:
   1.174 +		INFO_PRINTF1(_L("Install font store file with negative length"));
   1.175 +		iFbs->SendCommand(EFbsMessInstallFontStoreFile, 0, -1);
   1.176 +		TEST(EFalse);
   1.177 +		TestComplete();
   1.178 +		break;
   1.179 +	case 9:
   1.180 +		INFO_PRINTF1(_L("Install font store file with huge length"));
   1.181 +		iFbs->SendCommand(EFbsMessInstallFontStoreFile, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   1.182 +		TEST(EFalse);
   1.183 +		TestComplete();
   1.184 +		break;
   1.185 +	case 10:
   1.186 +		INFO_PRINTF1(_L("Remove font store file with active references"));
   1.187 +		iFbs->SendCommand(EFbsMessRemoveFontStoreFile, 11);
   1.188 +		// With PDEF121246 (INC120690) fix in place, this test will always pass. Without the fix there will be a KERN 4 panic.
   1.189 +		TEST(ETrue); 
   1.190 +		TestComplete();
   1.191 +		break;
   1.192 +	case 11:
   1.193 +		INFO_PRINTF1(_L("Bitmap create with invalid display mode"));
   1.194 +		iClient.SendInvalidDisplayMode(EFbsMessBitmapCreate);
   1.195 +		TEST(EFalse);
   1.196 +		TestComplete();
   1.197 +		break;
   1.198 +	case 12:
   1.199 +		INFO_PRINTF1(_L("Rasterize with invalid bitmap handle"));
   1.200 +		iFbs->SendCommand(EFbsMessRasterize, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   1.201 +		TEST(EFalse);
   1.202 +		TestComplete();
   1.203 +		break;
   1.204 +	case 13:
   1.205 +		INFO_PRINTF1(_L("Face Attribute with invalid bitmap handle"));
   1.206 +		iFbs->SendCommand(EFbsMessFaceAttrib, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   1.207 +		TEST(EFalse);
   1.208 +		TestComplete();
   1.209 +		break;
   1.210 +	case 14:
   1.211 +		INFO_PRINTF1(_L("Has Character with invalid bitmap handle"));
   1.212 +		iFbs->SendCommand(EFbsMessHasCharacter, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   1.213 +		TEST(EFalse);
   1.214 +		TestComplete();
   1.215 +		break;
   1.216 +	case 15:
   1.217 +		INFO_PRINTF1(_L("Name Alias with huge alias name length"));
   1.218 +		iFbs->SendCommand(EFbsMessFontNameAlias, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   1.219 +		TEST(EFalse);
   1.220 +		TestComplete();
   1.221 +		break;
   1.222 +	case 16:
   1.223 +		INFO_PRINTF1(_L("Get nearest font to design height in twips with invalid typeface name length"));
   1.224 +		iClient.SendInvalidNameLength(EFbsMessGetNearestFontToDesignHeightInTwips);
   1.225 +		TEST(EFalse);
   1.226 +		TestComplete();
   1.227 +		break;
   1.228 +	case 17:
   1.229 +		INFO_PRINTF1(_L("Get nearest font to max height in twips with invalid typeface name length"));
   1.230 +		iClient.SendInvalidNameLength(EFbsMessGetNearestFontToMaxHeightInTwips);
   1.231 +		TEST(EFalse);
   1.232 +		TestComplete();
   1.233 +		break;
   1.234 +	case 18:
   1.235 +		INFO_PRINTF1(_L("Get nearest font to design height in pixels with invalid typeface name length"));
   1.236 +		iClient.SendInvalidNameLength(EFbsMessGetNearestFontToDesignHeightInPixels);
   1.237 +		TEST(EFalse);
   1.238 +		TestComplete();
   1.239 +		break;
   1.240 +	case 19:
   1.241 +		INFO_PRINTF1(_L("Get nearest font to max height in pixels with invalid typeface name length"));
   1.242 +		iClient.SendInvalidNameLength(EFbsMessGetNearestFontToMaxHeightInPixels);
   1.243 +		TEST(EFalse);
   1.244 +		TestComplete();
   1.245 +		break;
   1.246 +	case 20:
   1.247 +		INFO_PRINTF1(_L("Shape text with invalid bitmap font handle"));
   1.248 +		iFbs->SendCommand(EFbsMessShapeText, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   1.249 +		TEST(EFalse);
   1.250 +		TestComplete();
   1.251 +		break;
   1.252 +	case 21:
   1.253 +		INFO_PRINTF1(_L("Shape delete with invalid bitmap font handle"));
   1.254 +		iFbs->SendCommand(EFbsMessShapeDelete, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   1.255 +		TEST(EFalse);
   1.256 +		TestComplete();
   1.257 +		break;
   1.258 +	case 22:
   1.259 +		INFO_PRINTF1(_L("Set twips height with invalid font handle"));
   1.260 +		iFbs->SendCommand(EFbsMessSetTwipsHeight, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   1.261 +		TEST(EFalse);
   1.262 +		TestComplete();
   1.263 +		break;
   1.264 +	case 23:
   1.265 +		INFO_PRINTF1(_L("Get twips height with invalid font handle"));
   1.266 +		iFbs->SendCommand(EFbsMessGetTwipsHeight, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   1.267 +		TEST(EFalse);
   1.268 +		TestComplete();
   1.269 +		break;	
   1.270 +	case 24:
   1.271 +		/**
   1.272 +			@SYMTestCaseID	GRAPHICS-FBSERV-0630
   1.273 +
   1.274 +			@SYMTestCaseDesc
   1.275 +			Tests that invalid font handle to EFbsMessGetGlyphs causes panic
   1.276 +
   1.277 +			@SYMTestExpectedResults
   1.278 +			Client should panic with FBSERV -8
   1.279 +		*/
   1.280 +		INFO_PRINTF1(_L("Get glyphs from glyph atlas with invalid font handle"));
   1.281 +		iFbs->SendCommand(EFbsMessGetGlyphs, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   1.282 +		TEST(EFalse);
   1.283 +		TestComplete();
   1.284 +		break;
   1.285 +	case 25:
   1.286 +		/**
   1.287 +			@SYMTestCaseID	GRAPHICS-FBSERV-0670
   1.288 +
   1.289 +			@SYMTestCaseDesc
   1.290 +			Tests that invalid font handle to EFbsMessGetGlyphMetrics causes panic
   1.291 +
   1.292 +			@SYMTestExpectedResults
   1.293 +			Client should panic with FBSERV -8
   1.294 +		*/
   1.295 +		INFO_PRINTF1(_L("Get glyph metrics with invalid font handle"));
   1.296 +		iFbs->SendCommand(EFbsMessGetGlyphMetrics, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   1.297 +		TEST(EFalse);
   1.298 +		TestComplete();
   1.299 +		break;
   1.300 +	/**
   1.301 +		@SYMTestCaseID
   1.302 +		TI18N-GDI-CIT-4086
   1.303 +
   1.304 +		@SYMTestCaseDesc
   1.305 +		Test if FBS can handle invalid messages correctly
   1.306 +		and panic the client as needed.
   1.307 +
   1.308 +		@SYMTestActions
   1.309 +		26. EFbsMessGetFontTable
   1.310 +		27. EFbsMessReleaseFontTable
   1.311 +		28. EFbsMessGetGlyphOutline
   1.312 +		29. EFbsMessReleaseGlyphOutline
   1.313 +	
   1.314 +		@SYMTestExpectedResults
   1.315 +		Test should pass
   1.316 +	*/
   1.317 +	case 26:
   1.318 +		INFO_PRINTF1(_L("Get Font Table with wrong msg"));
   1.319 +		iFbs->SendCommand(EFbsMessGetFontTable, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   1.320 +		TEST(EFalse); 
   1.321 +		TestComplete();
   1.322 +		break;
   1.323 +	case 27:
   1.324 +		INFO_PRINTF1(_L("Release Font Table with wrong msg"));
   1.325 +		iFbs->SendCommand(EFbsMessReleaseFontTable, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   1.326 +		TEST(EFalse); 
   1.327 +		TestComplete();
   1.328 +		break;
   1.329 +	case 28:
   1.330 +		INFO_PRINTF1(_L("Get Glyph outline with wrong msg"));
   1.331 +		iFbs->SendCommand(EFbsMessGetGlyphOutline,KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   1.332 +		TEST(EFalse); 
   1.333 +		TestComplete();
   1.334 +		break;
   1.335 +	case 29:
   1.336 +		INFO_PRINTF1(_L("Release Glyph outline with wrong msg"));
   1.337 +		iFbs->SendCommand(EFbsMessReleaseGlyphOutline, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
   1.338 +		TEST(EFalse); 
   1.339 +		TestComplete();
   1.340 +		break;
   1.341 +	case 30:
   1.342 +		TestComplete();
   1.343 +		break;
   1.344 +		}
   1.345 +	}
   1.346 +	
   1.347 +RIPCTestFbservClient::RIPCTestFbservClient()
   1.348 +	{
   1.349 +	
   1.350 +	}
   1.351 +	
   1.352 +RIPCTestFbservClient::~RIPCTestFbservClient()
   1.353 +	{
   1.354 +	
   1.355 +	}
   1.356 +	
   1.357 +TInt RIPCTestFbservClient::Connect(void)
   1.358 +	{
   1.359 +	_LIT(KFbServerName, "!Fontbitmapserver");
   1.360 +	TVersion version(0, 0, 0);
   1.361 +	TInt ret = CreateSession(KFbServerName, version);
   1.362 +	return ret;
   1.363 +	}
   1.364 +	
   1.365 +void RIPCTestFbservClient::SendInvalidSize(TInt aFunctionNumber)
   1.366 +	{
   1.367 +	TPckgBuf<TSize> size;
   1.368 +	size().iHeight = 0;
   1.369 +	size().iWidth = 0;
   1.370 +	TIpcArgs args;
   1.371 +	args.Set(0, 1);
   1.372 +	args.Set(2, &size);
   1.373 +	
   1.374 +	SendReceive(aFunctionNumber, args);
   1.375 +	}
   1.376 +	
   1.377 +void RIPCTestFbservClient::SendInvalidDisplayMode(TInt aFunctionNumber)
   1.378 +	{
   1.379 +	TPckgBuf<TBmpSpec> bmpSpec;
   1.380 +	bmpSpec().iDispMode = EColorLast;
   1.381 +	TIpcArgs args = TIpcArgs();
   1.382 +	args.Set(0, &bmpSpec);
   1.383 +	
   1.384 +	SendReceive(aFunctionNumber, args);
   1.385 +	}
   1.386 +
   1.387 +void RIPCTestFbservClient::SendInvalidNameLength(TInt aFunctionNumber)	
   1.388 +	{
   1.389 +	TIpcArgs args = TIpcArgs();
   1.390 +	_LIT(KDefault, "Default");
   1.391 +	TInt size = 7;
   1.392 +	HBufC8 *buf1 = HBufC8::NewLC(size);
   1.393 +	TPtr8 ptr1 = buf1->Des();
   1.394 +	ptr1.Copy(KDefault);
   1.395 +	CleanupStack::PopAndDestroy(buf1);
   1.396 +	args.Set(0, &ptr1);	
   1.397 +	SendReceive(aFunctionNumber, args);
   1.398 +	}
   1.399 +
   1.400 +
   1.401 +//--------------
   1.402 +__CONSTRUCT_STEP__(IPCTest)
   1.403 +