2271 |
2279 |
2272 // Send a IPC command to set the font's height with the font's handle |
2280 // Send a IPC command to set the font's height with the font's handle |
2273 TEST(KErrNone == iFbs->SendCommand(EFbsMessSetTwipsHeight, fontHandle, 49)); |
2281 TEST(KErrNone == iFbs->SendCommand(EFbsMessSetTwipsHeight, fontHandle, 49)); |
2274 // In a second thread, send a IPC command to set the font's height with the |
2282 // In a second thread, send a IPC command to set the font's height with the |
2275 // bitmap's handle. Should panic with FBServ -6. |
2283 // bitmap's handle. Should panic with FBServ -6. |
2276 TFbsTestThreadInfo threadInfo = {EFbsSecondThreadInvalidHandleInIpcCall}; |
|
2277 TExitCategoryName exitCategoryName(KFbsPanicCategory); |
|
2278 _LIT(KTestName, "TestInvalidHandlesInIpcCall"); |
2284 _LIT(KTestName, "TestInvalidHandlesInIpcCall"); |
2279 CreateSecondThreadAndCheckPanicL(threadInfo, -6, exitCategoryName, KTestName); |
2285 CreateSecondThreadAndCheckPanicL(SecondThreadPanicInvalidHandleInIpcCallL, KErrArgument, KFbsPanicCategory, KTestName); |
2280 |
2286 |
2281 iTs->ReleaseFont(font); |
2287 iTs->ReleaseFont(font); |
2282 delete bmp; |
2288 delete bmp; |
2283 } |
2289 } |
2284 |
2290 |
2285 /** |
2291 /** |
2286 Creates a second thread and do some panic tests in it. |
2292 Second thread function for test GRAPHICS-FBSERV-0650. It should panic with FBSERV -6 if the test is successful. |
2287 @param aTestInfo The information for the tests |
2293 */ |
2288 @param aPanicCode The expected panic code |
2294 void CTFbs::SecondThreadPanicInvalidHandleInIpcCallL() |
2289 @param aExitCategory The expected panic category |
2295 { |
2290 @param aThreadName The name of the new thread |
2296 User::LeaveIfError(RFbsSession::Connect()); |
2291 @leave Gets system wide error code |
2297 RFbsSession* fbs = RFbsSession::GetSession(); |
2292 */ |
2298 CFbsBitmapEx* bmp = new(ELeave) CFbsBitmapEx(); |
2293 void CTFbs::CreateSecondThreadAndCheckPanicL(TFbsTestThreadInfo& aTestInfo, TInt aPanicCode, TExitCategoryName aExitCategory, const TDesC &aThreadName) |
2299 CleanupStack::PushL(bmp); |
|
2300 User::LeaveIfError(bmp->Create(TSize(1,1), EGray2)); |
|
2301 CFbsTypefaceStore* ts = CFbsTypefaceStore::NewL(NULL); |
|
2302 CleanupStack::PushL(ts); |
|
2303 CFbsFont* font=NULL; |
|
2304 User::LeaveIfError(ts->GetNearestFontToDesignHeightInPixels((CFont*&)font, TFontSpec(KTypefaceName, 15))); |
|
2305 TInt bitmapHandle = bmp->BitmapHandle(); |
|
2306 |
|
2307 // Send a IPC command to set twips height of font with a bitmap handle |
|
2308 (void)fbs->SendCommand(EFbsMessSetTwipsHeight, bitmapHandle, 49); |
|
2309 |
|
2310 ts->ReleaseFont(font); |
|
2311 CleanupStack::PopAndDestroy(2); |
|
2312 RFbsSession::Disconnect(); |
|
2313 } |
|
2314 |
|
2315 |
|
2316 struct TFbsTestDelegator |
|
2317 { |
|
2318 CTFbs* iTestBase; |
|
2319 void (CTFbs::*iMethodPtr)(); |
|
2320 }; |
|
2321 |
|
2322 /** |
|
2323 Creates a second thread and checks that it panics. |
|
2324 @param aMethodL The leaving method of CTFbs that the second thread is going to execute. |
|
2325 @param aPanicCode The expected panic code. |
|
2326 @param aPanicCategory The expected panic category. |
|
2327 @param aThreadName The name of the new thread. |
|
2328 */ |
|
2329 void CTFbs::CreateSecondThreadAndCheckPanicL(void (CTFbs::*aMethodL)(), TInt aPanicCode, const TDesC& aPanicCategory, const TDesC& aThreadName) |
2294 { |
2330 { |
2295 RThread secondThread; |
2331 RThread secondThread; |
2296 User::LeaveIfError(secondThread.Create(aThreadName, SecondThreadStart, KDefaultStackSize, 0x1000, 0x1000, &aTestInfo)); |
2332 TFbsTestDelegator delegator; |
|
2333 delegator.iTestBase = this; |
|
2334 delegator.iMethodPtr = aMethodL; |
|
2335 User::LeaveIfError(secondThread.Create(aThreadName, MethodDelegatorThreadFunction, KDefaultStackSize, 0x1000, 0x1000, &delegator)); |
2297 // Launch second thread |
2336 // Launch second thread |
2298 TRequestStatus statusSecondThread; |
2337 TRequestStatus statusSecondThread; |
2299 secondThread.Logon(statusSecondThread); |
2338 secondThread.Logon(statusSecondThread); |
2300 secondThread.SetPriority(EPriorityLess); |
2339 secondThread.Resume(); |
2301 secondThread.Resume(); |
2340 // Wait until second thread is finished |
2302 |
|
2303 User::WaitForRequest(statusSecondThread); |
2341 User::WaitForRequest(statusSecondThread); |
2304 |
2342 // Check results |
2305 if(EExitPanic != secondThread.ExitType()) |
2343 if (EExitPanic != secondThread.ExitType()) |
2306 { |
2344 { |
2307 ERR_PRINTF3(_L("Expected exit type: %d, Actual exit type: %d"), EExitPanic, secondThread.ExitType()); |
2345 ERR_PRINTF2(_L("Expected exit type: EExitPanic, actual exit type: %d"), secondThread.ExitType()); |
2308 TEST(EFalse); |
2346 TEST(EFalse); |
2309 } |
2347 } |
2310 |
2348 if (aPanicCode != secondThread.ExitReason()) |
2311 if(aPanicCode != secondThread.ExitReason()) |
|
2312 { |
2349 { |
2313 ERR_PRINTF3(_L("Expected panic code: %d, Actual panic code: %d"), aPanicCode, secondThread.ExitReason()); |
2350 ERR_PRINTF3(_L("Expected exit reason: %d, actual exit reason: %d"), aPanicCode, secondThread.ExitReason()); |
2314 TEST(EFalse); |
2351 TEST(EFalse); |
2315 } |
2352 } |
2316 |
|
2317 TExitCategoryName secondThreadExitCategory = secondThread.ExitCategory(); |
2353 TExitCategoryName secondThreadExitCategory = secondThread.ExitCategory(); |
2318 if(aExitCategory != secondThreadExitCategory) |
2354 if (aPanicCategory != secondThreadExitCategory) |
2319 { |
2355 { |
2320 ERR_PRINTF3(_L("Expected panic category: %S, Actual panic category: %S"), &aExitCategory, &secondThreadExitCategory); |
2356 ERR_PRINTF3(_L("Expected exit category: %S, actual exit category: %S"), &aPanicCategory, &secondThreadExitCategory); |
2321 TEST(EFalse); |
2357 TEST(EFalse); |
2322 } |
2358 } |
2323 |
2359 // Dispose of the remains of the second thread |
2324 //Close the handle |
|
2325 secondThread.Close(); |
2360 secondThread.Close(); |
2326 } |
2361 } |
2327 |
2362 |
2328 /** |
2363 TInt CTFbs::MethodDelegatorThreadFunction(TAny* aDelegator) |
2329 Second thread entry function. |
2364 { |
2330 */ |
|
2331 TInt CTFbs::SecondThreadStart(TAny* aTestInfo) |
|
2332 { |
|
2333 |
|
2334 __UHEAP_MARK; |
|
2335 TInt procHandles1 =0; |
|
2336 TInt threadHandles1=0; |
|
2337 RThread().HandleCount(procHandles1, threadHandles1); |
|
2338 CTrapCleanup* cleanupStack = CTrapCleanup::New(); |
2365 CTrapCleanup* cleanupStack = CTrapCleanup::New(); |
2339 |
|
2340 if (!cleanupStack) |
2366 if (!cleanupStack) |
2341 { |
2367 { |
2342 __UHEAP_MARKEND; |
|
2343 return KErrNoMemory; |
2368 return KErrNoMemory; |
2344 } |
2369 } |
2345 |
2370 TFbsTestDelegator* delegator = static_cast<TFbsTestDelegator*>(aDelegator); |
2346 TInt result = KErrNone; |
2371 TRAPD(err, (delegator->iTestBase->*delegator->iMethodPtr)()); |
2347 TRAP(result, SecondThreadMainL(static_cast<TFbsTestThreadInfo*>(aTestInfo))); |
|
2348 |
|
2349 delete cleanupStack; |
2372 delete cleanupStack; |
2350 |
2373 return err; |
2351 TInt procHandles2 =0; |
|
2352 TInt threadHandles2=0; |
|
2353 RThread().HandleCount(procHandles2,threadHandles2); |
|
2354 if (threadHandles1 != threadHandles2) |
|
2355 { |
|
2356 result = KErrGeneral; // Thread-owned handles not closed |
|
2357 } |
|
2358 __UHEAP_MARKEND; |
|
2359 |
|
2360 return result; |
|
2361 } |
|
2362 |
|
2363 /** |
|
2364 Run the test contained within the TFbsTestThreadInfo object. A new thread is |
|
2365 created for each test and only one of the cases in the switch statements |
|
2366 below will be used. |
|
2367 |
|
2368 @param aTestInfo The parameters for the test |
|
2369 @return One of the system wide error codes or an enumeration of passed tests. |
|
2370 */ |
|
2371 TInt CTFbs::SecondThreadMainL(TFbsTestThreadInfo* aTestInfo) |
|
2372 { |
|
2373 TInt result = 0; |
|
2374 TFbsMultiThreadTestCase testcase = aTestInfo->iTestCase; |
|
2375 |
|
2376 //test cases without the need of an initialised driver |
|
2377 switch (testcase) |
|
2378 { |
|
2379 case EFbsSecondThreadInvalidHandleInIpcCall: |
|
2380 result = SecondThreadPanicInvalidHandleInIpcCall(); |
|
2381 break; |
|
2382 } |
|
2383 return result; |
|
2384 } |
|
2385 |
|
2386 /** |
|
2387 Implementation of SecondThread test EFbsSecondThreadInvalidHandleInIpcCall |
|
2388 |
|
2389 @panic FBSERV -6 If the test is successful |
|
2390 |
|
2391 @return One of the system wide error codes. |
|
2392 */ |
|
2393 TInt CTFbs::SecondThreadPanicInvalidHandleInIpcCall() |
|
2394 { |
|
2395 TInt result = RFbsSession::Connect(); |
|
2396 if (KErrNone != result) |
|
2397 { |
|
2398 return result; |
|
2399 } |
|
2400 RFbsSession* fbs = RFbsSession::GetSession(); |
|
2401 CFbsBitmapEx* bmp = new CFbsBitmapEx(); |
|
2402 if (!bmp) |
|
2403 { |
|
2404 return KErrGeneral; |
|
2405 } |
|
2406 result = bmp->Create(TSize(1,1),EGray2); |
|
2407 if(KErrNone != result) |
|
2408 { |
|
2409 delete bmp; |
|
2410 return KErrGeneral; |
|
2411 } |
|
2412 |
|
2413 CFbsTypefaceStore* ts = NULL; |
|
2414 ts = (CFbsTypefaceStore*)CFbsTypefaceStore::NewL(NULL); |
|
2415 if (!ts) |
|
2416 { |
|
2417 delete bmp; |
|
2418 return KErrGeneral; |
|
2419 } |
|
2420 |
|
2421 CFbsFontEx* font=NULL; |
|
2422 result = ts->GetNearestFontToDesignHeightInPixels((CFont*&)font, TFontSpec(KTypefaceName, 15)); |
|
2423 if (!font) |
|
2424 { |
|
2425 delete bmp; |
|
2426 delete ts; |
|
2427 return KErrGeneral; |
|
2428 } |
|
2429 |
|
2430 TInt fontHandle = font->FontHandle(); |
|
2431 TInt bitmapHandle = bmp->BitmapHandle(); |
|
2432 |
|
2433 // Send a IPC command to set twips height of font with a bitmap handle |
|
2434 result = fbs->SendCommand(EFbsMessSetTwipsHeight, bitmapHandle, 49); |
|
2435 |
|
2436 ts->ReleaseFont(font); |
|
2437 delete bmp; |
|
2438 delete ts; |
|
2439 return result; |
|
2440 } |
2374 } |
2441 |
2375 |
2442 /** |
2376 /** |
2443 @SYMTestCaseID GRAPHICS-FBSERV-0619 |
2377 @SYMTestCaseID GRAPHICS-FBSERV-0619 |
2444 @SYMTestPriority High |
2378 @SYMTestPriority High |