First public contribution.
1 // Copyright (c) 1996-2010 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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include "../sfbs/UTILS.H"
19 #include "fbsmessage.h"
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;
27 CTIPCTest::CTIPCTest(CTestStep* aStep):
28 CTGraphicsBase(aStep),
33 CTIPCTest::~CTIPCTest()
36 RFbsSession::GetSession()->SendCommand(EFbsMessShutdown);
37 RFbsSession::Disconnect();
42 void CTIPCTest::ConstructL()
44 INFO_PRINTF1(_L("Font/Bitmap Server IPC Messages Testing"));
46 if(RFbsSession::Connect()==KErrNone)
48 RFbsSession::Disconnect();
49 iShutdownFbs = EFalse;
56 RFbsSession::Connect();
57 iFbs=RFbsSession::GetSession();
61 if(iClient.Connect() == KErrNone)
63 iShutdownFbs = EFalse;
71 iHeap=UserHeap::ChunkHeap(NULL,0x10000,0x10000);
72 TRAPD(ret,iFs=CFontStore::NewL(iHeap));
78 void CTIPCTest::RunTestCaseL(TInt aCurTestCase)
80 _LIT(KCaseNumber, "CaseNumber");
82 TBool res = iStep->GetIntFromConfig(iStep->ConfigSection(), KCaseNumber, aCurTestCase);
96 Tests the sending of commands to a FbsSession
97 server thru Inter Process Communication. Sends
98 both valid and invalid commands.
101 Commands sent to the server:
103 2. EFbsMessFontHeightInTwips
104 3. EFbsMessFontHeightInTwips
105 4. EFbsMessFontHeightInPixels
106 5. EFbsMessFontHeightInPixels
107 6. EFbsMessAddFontStoreFile
108 7. EFbsMessAddFontStoreFile
109 8. EFbsMessInstallFontStoreFile
110 9. EFbsMessInstallFontStoreFile
111 10. EFbsMessInstallFontStoreFile
112 11. EFbsMessBitmapCreate
113 12. EFbsMessRasterize
114 13. EFbsMessFaceAttrib
115 14. EFbsMessHasCharacter
116 15. EFbsMessFontNameAlias
117 16. EFbsMessGetNearestFontToDesignHeightInTwips
118 17. EFbsMessGetNearestFontToMaxHeightInTwips
119 18. EFbsMessGetNearestFontToDesignHeightInPixels
120 19. EFbsMessGetNearestFontToMaxHeightInPixels
121 20. EFbsMessShapeText
122 21. EFbsMessShapeDelete
123 22. EFbsMessSetTwipsHeight
124 23. EFbsMessGetTwipsHeight
126 @SYMTestExpectedResults
130 INFO_PRINTF1(_L("Shutdown"));
131 iFbs->SendCommand(EFbsMessShutdown);
135 INFO_PRINTF1(_L("Height in twips with negative typeface index"));
136 iFbs->SendCommand(EFbsMessFontHeightInTwips, -1);
137 TEST(EFalse); // Previous line should have paniced
141 INFO_PRINTF1(_L("Height in twips with invalid size"));
142 iClient.SendInvalidSize(EFbsMessFontHeightInTwips);
147 INFO_PRINTF1(_L("Height in pixels with negative typeface index"));
148 iFbs->SendCommand(EFbsMessFontHeightInPixels, -1);
153 INFO_PRINTF1(_L("Height in pixels with invalid size"));
154 iClient.SendInvalidSize(EFbsMessFontHeightInPixels);
159 INFO_PRINTF1(_L("Add font store file with negative length"));
160 iFbs->SendCommand(EFbsMessAddFontStoreFile, 0, -1);
165 INFO_PRINTF1(_L("Add font store file with huge length"));
166 iFbs->SendCommand(EFbsMessAddFontStoreFile, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
171 INFO_PRINTF1(_L("Install font store file with negative length"));
172 iFbs->SendCommand(EFbsMessInstallFontStoreFile, 0, -1);
177 INFO_PRINTF1(_L("Install font store file with huge length"));
178 iFbs->SendCommand(EFbsMessInstallFontStoreFile, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
183 INFO_PRINTF1(_L("Remove font store file with active references"));
184 iFbs->SendCommand(EFbsMessRemoveFontStoreFile, 11);
185 // With PDEF121246 (INC120690) fix in place, this test will always pass. Without the fix there will be a KERN 4 panic.
190 INFO_PRINTF1(_L("Bitmap create with invalid display mode"));
191 iClient.SendInvalidDisplayMode(EFbsMessBitmapCreate);
196 INFO_PRINTF1(_L("Rasterize with invalid bitmap handle"));
197 iFbs->SendCommand(EFbsMessRasterize, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
202 INFO_PRINTF1(_L("Face Attribute with invalid bitmap handle"));
203 iFbs->SendCommand(EFbsMessFaceAttrib, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
208 INFO_PRINTF1(_L("Has Character with invalid bitmap handle"));
209 iFbs->SendCommand(EFbsMessHasCharacter, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
214 INFO_PRINTF1(_L("Name Alias with huge alias name length"));
215 iFbs->SendCommand(EFbsMessFontNameAlias, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
220 INFO_PRINTF1(_L("Get nearest font to design height in twips with invalid typeface name length"));
221 iClient.SendInvalidNameLength(EFbsMessGetNearestFontToDesignHeightInTwips);
226 INFO_PRINTF1(_L("Get nearest font to max height in twips with invalid typeface name length"));
227 iClient.SendInvalidNameLength(EFbsMessGetNearestFontToMaxHeightInTwips);
232 INFO_PRINTF1(_L("Get nearest font to design height in pixels with invalid typeface name length"));
233 iClient.SendInvalidNameLength(EFbsMessGetNearestFontToDesignHeightInPixels);
238 INFO_PRINTF1(_L("Get nearest font to max height in pixels with invalid typeface name length"));
239 iClient.SendInvalidNameLength(EFbsMessGetNearestFontToMaxHeightInPixels);
244 INFO_PRINTF1(_L("Shape text with invalid bitmap font handle"));
245 iFbs->SendCommand(EFbsMessShapeText, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
250 INFO_PRINTF1(_L("Shape delete with invalid bitmap font handle"));
251 iFbs->SendCommand(EFbsMessShapeDelete, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
256 INFO_PRINTF1(_L("Set twips height with invalid font handle"));
257 iFbs->SendCommand(EFbsMessSetTwipsHeight, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
262 INFO_PRINTF1(_L("Get twips height with invalid font handle"));
263 iFbs->SendCommand(EFbsMessGetTwipsHeight, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
269 @SYMTestCaseID GRAPHICS-FBSERV-0630
272 Tests that invalid font handle to EFbsMessGetGlyphs causes panic
274 @SYMTestExpectedResults
275 Client should panic with FBSERV -8
277 INFO_PRINTF1(_L("Get glyphs from glyph atlas with invalid font handle"));
278 iFbs->SendCommand(EFbsMessGetGlyphs, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
284 @SYMTestCaseID GRAPHICS-FBSERV-0670
287 Tests that invalid font handle to EFbsMessGetGlyphMetrics causes panic
289 @SYMTestExpectedResults
290 Client should panic with FBSERV -8
292 INFO_PRINTF1(_L("Get glyph metrics with invalid font handle"));
293 iFbs->SendCommand(EFbsMessGetGlyphMetrics, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
302 Test if FBS can handle invalid messages correctly
303 and panic the client as needed.
306 26. EFbsMessGetFontTable
307 27. EFbsMessReleaseFontTable
308 28. EFbsMessGetGlyphOutline
309 29. EFbsMessReleaseGlyphOutline
311 @SYMTestExpectedResults
315 INFO_PRINTF1(_L("Get Font Table with wrong msg"));
316 iFbs->SendCommand(EFbsMessGetFontTable, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
321 INFO_PRINTF1(_L("Release Font Table with wrong msg"));
322 iFbs->SendCommand(EFbsMessReleaseFontTable, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
327 INFO_PRINTF1(_L("Get Glyph outline with wrong msg"));
328 iFbs->SendCommand(EFbsMessGetGlyphOutline,KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
333 INFO_PRINTF1(_L("Release Glyph outline with wrong msg"));
334 iFbs->SendCommand(EFbsMessReleaseGlyphOutline, KInvalidParam1, KInvalidParam2, KInvalidParam3, KInvalidParam4);
344 RIPCTestFbservClient::RIPCTestFbservClient()
349 RIPCTestFbservClient::~RIPCTestFbservClient()
354 TInt RIPCTestFbservClient::Connect(void)
356 _LIT(KFbServerName, "!Fontbitmapserver");
357 TVersion version(0, 0, 0);
358 TInt ret = CreateSession(KFbServerName, version);
362 void RIPCTestFbservClient::SendInvalidSize(TInt aFunctionNumber)
364 TPckgBuf<TSize> size;
371 SendReceive(aFunctionNumber, args);
374 void RIPCTestFbservClient::SendInvalidDisplayMode(TInt aFunctionNumber)
376 TPckgBuf<TBmpSpec> bmpSpec;
377 bmpSpec().iDispMode = EColorLast;
378 TIpcArgs args = TIpcArgs();
379 args.Set(0, &bmpSpec);
381 SendReceive(aFunctionNumber, args);
384 void RIPCTestFbservClient::SendInvalidNameLength(TInt aFunctionNumber)
386 TIpcArgs args = TIpcArgs();
387 _LIT(KDefault, "Default");
389 HBufC8 *buf1 = HBufC8::NewLC(size);
390 TPtr8 ptr1 = buf1->Des();
392 CleanupStack::PopAndDestroy(buf1);
394 SendReceive(aFunctionNumber, args);
399 __CONSTRUCT_STEP__(IPCTest)