1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/fbs/fontandbitmapserver/tfbs/TALLOC.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1298 @@
1.4 +// Copyright (c) 1996-2009 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 <s32file.h>
1.20 +#include <graphics/bitmapuid.h>
1.21 +#include "../sfbs/UTILS.H"
1.22 +#include "TFBS.H"
1.23 +#include "TALLOC.H"
1.24 +#include "../sfbs/fbsbitmapasyncstreamer.h"
1.25 +#include "fbsmessage.h"
1.26 +#include "fbsdefs.h"
1.27 +
1.28 +const TSize KLargeSize(4096 + 100, 1);
1.29 +const TSize KLargeSizeAlt(4096 + 200, 2);
1.30 +const TSize KSmallSize(10, 10);
1.31 +const TSize KSmallSizeAlt(20, 20);
1.32 +
1.33 +CTAlloc::CTAlloc(CTestStep* aStep):
1.34 + CTGraphicsBase(aStep),
1.35 + iFbs(NULL),
1.36 + iStore(NULL),
1.37 + iBitmap(NULL),
1.38 + iBitmap2(NULL)
1.39 + {
1.40 + INFO_PRINTF1(_L("Font/Bitmap Server Alloc Failure Recovery Testing"));
1.41 + }
1.42 +
1.43 +CTAlloc::~CTAlloc()
1.44 + {
1.45 + if (iShutdownFbs)
1.46 + {
1.47 + iFbs->SendCommand(EFbsMessShutdown);
1.48 + }
1.49 + iFbs->Disconnect();
1.50 +
1.51 + delete iStore;
1.52 + }
1.53 +
1.54 +void CTAlloc::ConstructL()
1.55 + {
1.56 + iStore = CFbsTypefaceStore::NewL(NULL);
1.57 +
1.58 + if(RFbsSession::Connect()==KErrNone)
1.59 + {
1.60 + RFbsSession::Disconnect();
1.61 + iShutdownFbs = EFalse;
1.62 + }
1.63 + else
1.64 + {
1.65 + FbsStartup();
1.66 + iShutdownFbs = ETrue;
1.67 + }
1.68 + }
1.69 +
1.70 +void CTAlloc::RunTestCaseL(TInt aCurTestCase)
1.71 + {
1.72 + ((CTAllocStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
1.73 + switch(aCurTestCase)
1.74 + {
1.75 + case 1:
1.76 + ((CTAllocStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0511"));
1.77 + Session();
1.78 + break;
1.79 + case 2:
1.80 + {
1.81 +/**
1.82 + @SYMTestCaseID GRAPHICS-FBSERV-0611
1.83 +*/
1.84 + ((CTAllocStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0611"));
1.85 + TInt ret = RFbsSession::Connect();
1.86 + TEST2(ret, KErrNone);
1.87 + iFbs = RFbsSession::GetSession();
1.88 + TEST(iFbs != NULL);
1.89 + }
1.90 + break;
1.91 + case 4:
1.92 + ((CTAllocStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0512"));
1.93 + BitmapsL();
1.94 + break;
1.95 + case 5:
1.96 + ((CTAllocStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0514"));
1.97 + BitmapHandlerL();
1.98 + break;
1.99 + case 6:
1.100 + ((CTAllocStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0513"));
1.101 + TypefaceStoreL();
1.102 + break;
1.103 + case 7:
1.104 + ((CTAllocStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0515"));
1.105 + FontStoreL();
1.106 + break;
1.107 + case 8:
1.108 + ((CTAllocStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1.109 + ((CTAllocStep*)iStep)->CloseTMSGraphicsStep();
1.110 + TestComplete();
1.111 + break;
1.112 + default:
1.113 + ((CTAllocStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1.114 + break;
1.115 + }
1.116 + ((CTAllocStep*)iStep)->RecordTestResultL();
1.117 + }
1.118 +
1.119 +/**
1.120 + @SYMTestCaseID
1.121 + GRAPHICS-FBSERV-0511
1.122 +
1.123 + @SYMTestCaseDesc
1.124 + Allocated sessions with the FbsServer and simulates memory allocation errors
1.125 +
1.126 + @SYMTestActions
1.127 + Checks the heap
1.128 +
1.129 + @SYMTestExpectedResults
1.130 + Test should pass
1.131 +*/
1.132 +void CTAlloc::Session()
1.133 + {
1.134 + INFO_PRINTF1(_L("RFbsSession::Connect()\r\n"));
1.135 +
1.136 + for (TInt count = 1; ; count++)
1.137 + {
1.138 + __UHEAP_FAILNEXT(count);
1.139 + __UHEAP_MARK;
1.140 +
1.141 + TInt ret = RFbsSession::Connect();
1.142 +
1.143 + if (ret == KErrNoMemory)
1.144 + {
1.145 + __UHEAP_MARKEND;
1.146 + }
1.147 + else if (ret == KErrNone)
1.148 + {
1.149 + RFbsSession::Disconnect();
1.150 + __UHEAP_MARKEND;
1.151 + break;
1.152 + }
1.153 + else
1.154 + {
1.155 + __UHEAP_MARKEND;
1.156 + TEST2(ret, KErrNone);
1.157 + }
1.158 + }
1.159 +
1.160 + __UHEAP_RESET;
1.161 + }
1.162 +
1.163 +/**
1.164 + @SYMTestCaseID
1.165 + GRAPHICS-FBSERV-0512
1.166 +
1.167 + @SYMTestCaseDesc
1.168 + Creates bitmaps in different ways and checks if memory allocation succeeded
1.169 +
1.170 + @SYMTestActions
1.171 + Creates normal size bitmaps, large bitmaps, loads bitmaps, loads shared bitmaps,
1.172 + duplicated bitmaps, resizes bitmaps, compresses bitmaps, externalized bitmaps to write store,
1.173 + internalizes bitmaps back again from write store. All ways of creating bitmaps are tested
1.174 + against Out Of Memory error conditions
1.175 +
1.176 + @SYMTestExpectedResults
1.177 + Test should pass
1.178 +*/
1.179 +void CTAlloc::BitmapsL()
1.180 + {
1.181 + TInt heapMarkCheckFlag;
1.182 + if( !iStep->GetIntFromConfig(KDefaultSectionName, KFbsHeapMarkCheckFlag, heapMarkCheckFlag) )
1.183 + {
1.184 + INFO_PRINTF1(_L("Error reading ini file"));
1.185 + User::Leave(KErrNotFound);
1.186 + }
1.187 +
1.188 + CFbsBitmap iBitmap;
1.189 + CFbsBitmap iBitmap2;
1.190 +
1.191 + iTestBitmapName = KTestBitmapOnZ;
1.192 + TInt ret = iBitmap.Load(iTestBitmapName,ETfbs,NULL);
1.193 + TEST2(ret, KErrNone);
1.194 +
1.195 + ret = iBitmap.Create(KLargeSize,EColor256); // Expand server caches
1.196 + TEST2(ret, KErrNone);
1.197 + iBitmap.Reset();
1.198 +
1.199 + TInt count;
1.200 +
1.201 +// Create bitmap
1.202 + INFO_PRINTF1(_L("CFbsBitmap::Create()\r\n"));
1.203 + for (count = 1; ; count++)
1.204 + {
1.205 + iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
1.206 + if(heapMarkCheckFlag)
1.207 + {
1.208 + iFbs->SendCommand(EFbsMessDefaultMark);
1.209 + iFbs->SendCommand(EFbsMessUserMark);
1.210 + }
1.211 + ret = iBitmap.Create(KSmallSize,EColor256);
1.212 +
1.213 + if (ret == KErrNoMemory)
1.214 + {
1.215 + if(heapMarkCheckFlag)
1.216 + {
1.217 + iFbs->SendCommand(EFbsMessDefaultMark);
1.218 + iFbs->SendCommand(EFbsMessUserMark);
1.219 + }
1.220 + }
1.221 + else if (ret == KErrNone)
1.222 + {
1.223 + iBitmap.Reset();
1.224 + if(heapMarkCheckFlag)
1.225 + {
1.226 + iFbs->SendCommand(EFbsMessDefaultMark);
1.227 + iFbs->SendCommand(EFbsMessUserMark);
1.228 + }
1.229 + break;
1.230 + }
1.231 + else
1.232 + TEST2(ret, KErrNone);
1.233 + }
1.234 +
1.235 + iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
1.236 + iFbs->SendCommand(EFbsMessUserAllocFail,0);
1.237 + TEST(iFbs->ResourceCount()==0);
1.238 +
1.239 + for (count = 1; ; count++)
1.240 + {
1.241 + iFbs->SendCommand(EFbsMessUserAllocFail,count);
1.242 + if(heapMarkCheckFlag)
1.243 + {
1.244 + iFbs->SendCommand(EFbsMessDefaultMark);
1.245 + iFbs->SendCommand(EFbsMessUserMark);
1.246 + }
1.247 +
1.248 + ret=iBitmap.Create(KSmallSize,EGray2);
1.249 +
1.250 + if (ret == KErrNoMemory)
1.251 + {
1.252 + if(heapMarkCheckFlag)
1.253 + {
1.254 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.255 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.256 + }
1.257 + }
1.258 + else if (ret == KErrNone)
1.259 + {
1.260 + iBitmap.Reset();
1.261 + if(heapMarkCheckFlag)
1.262 + {
1.263 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.264 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.265 + }
1.266 + break;
1.267 + }
1.268 + else
1.269 + TEST2(ret, KErrNone);
1.270 + }
1.271 +
1.272 + iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
1.273 + iFbs->SendCommand(EFbsMessUserAllocFail,0);
1.274 + TEST(iFbs->ResourceCount()==0);
1.275 +
1.276 +// Create (large)
1.277 + for (count = 1; ; count++)
1.278 + {
1.279 + iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
1.280 + if(heapMarkCheckFlag)
1.281 + {
1.282 + iFbs->SendCommand(EFbsMessDefaultMark);
1.283 + iFbs->SendCommand(EFbsMessUserMark);
1.284 + }
1.285 +
1.286 + ret = iBitmap.Create(KLargeSize,EColor256);
1.287 +
1.288 + if (ret == KErrNoMemory)
1.289 + {
1.290 + if(heapMarkCheckFlag)
1.291 + {
1.292 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.293 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.294 + }
1.295 + }
1.296 + else if (ret == KErrNone)
1.297 + {
1.298 + iBitmap.Reset();
1.299 + if(heapMarkCheckFlag)
1.300 + {
1.301 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.302 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.303 + }
1.304 + break;
1.305 + }
1.306 + else
1.307 + TEST2(ret, KErrNone);
1.308 + }
1.309 +
1.310 + iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
1.311 + iFbs->SendCommand(EFbsMessUserAllocFail,0);
1.312 + TEST(iFbs->ResourceCount()==0);
1.313 +
1.314 + for (count = 1; ; count++)
1.315 + {
1.316 + iFbs->SendCommand(EFbsMessUserAllocFail,count);
1.317 + if(heapMarkCheckFlag)
1.318 + {
1.319 + iFbs->SendCommand(EFbsMessDefaultMark);
1.320 + iFbs->SendCommand(EFbsMessUserMark);
1.321 + }
1.322 +
1.323 + ret = iBitmap.Create(KLargeSize,EColor256);
1.324 +
1.325 + if (ret == KErrNoMemory)
1.326 + {
1.327 + if(heapMarkCheckFlag)
1.328 + {
1.329 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.330 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.331 + }
1.332 + }
1.333 + else if (ret == KErrNone)
1.334 + {
1.335 + iBitmap.Reset();
1.336 + if(heapMarkCheckFlag)
1.337 + {
1.338 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.339 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.340 + }
1.341 + break;
1.342 + }
1.343 + else
1.344 + TEST2(ret, KErrNone);
1.345 + }
1.346 +
1.347 + iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
1.348 + iFbs->SendCommand(EFbsMessUserAllocFail,0);
1.349 + TEST(iFbs->ResourceCount()==0);
1.350 +
1.351 +// Load
1.352 + INFO_PRINTF1(_L("CFbsBitmap::Load()\r\n"));
1.353 + ret = iBitmap.Load(iTestBitmapName,ETfbs,NULL);
1.354 + TEST2(ret, KErrNone);
1.355 + iBitmap.Reset();
1.356 + for (count = 1; ; count++)
1.357 + {
1.358 + iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
1.359 + if(heapMarkCheckFlag)
1.360 + {
1.361 + iFbs->SendCommand(EFbsMessDefaultMark);
1.362 + iFbs->SendCommand(EFbsMessUserMark);
1.363 + }
1.364 +
1.365 + ret = iBitmap.Load(iTestBitmapName,ETfbs,NULL);
1.366 +
1.367 + if (ret == KErrNoMemory)
1.368 + {
1.369 + if(heapMarkCheckFlag)
1.370 + {
1.371 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.372 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.373 + }
1.374 + }
1.375 + else if (ret == KErrNone)
1.376 + {
1.377 + iBitmap.Reset();
1.378 + if(heapMarkCheckFlag)
1.379 + {
1.380 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.381 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.382 + }
1.383 + break;
1.384 + }
1.385 + else
1.386 + TEST2(ret, KErrNone);
1.387 + }
1.388 +
1.389 + iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
1.390 + iFbs->SendCommand(EFbsMessUserAllocFail,0);
1.391 + TEST(iFbs->ResourceCount()==0);
1.392 +
1.393 + for (count = 1; ; count++)
1.394 + {
1.395 + iFbs->SendCommand(EFbsMessUserAllocFail,count);
1.396 + if(heapMarkCheckFlag)
1.397 + {
1.398 + iFbs->SendCommand(EFbsMessDefaultMark);
1.399 + iFbs->SendCommand(EFbsMessUserMark);
1.400 + }
1.401 +
1.402 + ret = iBitmap.Load(iTestBitmapName,ETfbs,NULL);
1.403 +
1.404 + if (ret == KErrNoMemory)
1.405 + {
1.406 + if(heapMarkCheckFlag)
1.407 + {
1.408 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.409 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.410 + }
1.411 + }
1.412 + else if (ret == KErrNone)
1.413 + {
1.414 + iBitmap.Reset();
1.415 + if(heapMarkCheckFlag)
1.416 + {
1.417 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.418 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.419 + }
1.420 + break;
1.421 + }
1.422 + else
1.423 + TEST2(ret, KErrNone);
1.424 + }
1.425 +
1.426 + iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
1.427 + iFbs->SendCommand(EFbsMessUserAllocFail,0);
1.428 + TEST(iFbs->ResourceCount()==0);
1.429 +
1.430 +// Load (shared)
1.431 + INFO_PRINTF1(_L("CFbsBitmap::Load() - shared \r\n"));
1.432 +
1.433 + // Do an initial load to ensure the StreamId cache does not get updated whilst OOM testing
1.434 + ret = iBitmap.Load(iTestBitmapName,ETfbs,ETrue);
1.435 + TEST2(ret, KErrNone);
1.436 + iBitmap.Reset();
1.437 +
1.438 + for (count = 1; ; count++)
1.439 + {
1.440 + iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
1.441 + if(heapMarkCheckFlag)
1.442 + {
1.443 + iFbs->SendCommand(EFbsMessDefaultMark);
1.444 + iFbs->SendCommand(EFbsMessUserMark);
1.445 + }
1.446 +
1.447 + ret = iBitmap.Load(iTestBitmapName,ETfbs,ETrue);
1.448 +
1.449 + if (ret == KErrNoMemory)
1.450 + {
1.451 + if(heapMarkCheckFlag)
1.452 + {
1.453 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.454 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.455 + }
1.456 + continue;
1.457 + }
1.458 + else if (ret != KErrNone)
1.459 + TEST2(ret, KErrNone);
1.460 +
1.461 + ret = iBitmap2.Load(iTestBitmapName,ETfbs,ETrue);
1.462 +
1.463 + if (ret == KErrNoMemory)
1.464 + {
1.465 + iBitmap.Reset();
1.466 + if(heapMarkCheckFlag)
1.467 + {
1.468 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.469 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.470 + }
1.471 + continue;
1.472 + }
1.473 + else if (ret == KErrNone)
1.474 + {
1.475 + iBitmap.Reset();
1.476 + iBitmap2.Reset();
1.477 + if(heapMarkCheckFlag)
1.478 + {
1.479 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.480 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.481 + }
1.482 + break;
1.483 + }
1.484 + else
1.485 + TEST2(ret, KErrNone);
1.486 + }
1.487 +
1.488 + iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
1.489 + iFbs->SendCommand(EFbsMessUserAllocFail,0);
1.490 + TEST(iFbs->ResourceCount()==0);
1.491 +
1.492 + for (count = 1; ; count++)
1.493 + {
1.494 + iFbs->SendCommand(EFbsMessUserAllocFail,count);
1.495 + if(heapMarkCheckFlag)
1.496 + {
1.497 + iFbs->SendCommand(EFbsMessDefaultMark);
1.498 + iFbs->SendCommand(EFbsMessUserMark);
1.499 + }
1.500 +
1.501 + ret = iBitmap.Load(iTestBitmapName,ETfbs,ETrue);
1.502 +
1.503 + if (ret == KErrNoMemory)
1.504 + {
1.505 + if(heapMarkCheckFlag)
1.506 + {
1.507 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.508 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.509 + }
1.510 + continue;
1.511 + }
1.512 + else if (ret != KErrNone)
1.513 + TEST2(ret, KErrNone);
1.514 +
1.515 + ret = iBitmap2.Load(iTestBitmapName,ETfbs,ETrue);
1.516 +
1.517 + if (ret == KErrNoMemory)
1.518 + {
1.519 + iBitmap.Reset();
1.520 + if(heapMarkCheckFlag)
1.521 + {
1.522 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.523 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.524 + }
1.525 + continue;
1.526 + }
1.527 + else if (ret == KErrNone)
1.528 + {
1.529 + iBitmap.Reset();
1.530 + iBitmap2.Reset();
1.531 + if(heapMarkCheckFlag)
1.532 + {
1.533 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.534 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.535 + }
1.536 + break;
1.537 + }
1.538 + else
1.539 + TEST2(ret, KErrNone);
1.540 + }
1.541 +
1.542 + iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
1.543 + iFbs->SendCommand(EFbsMessUserAllocFail,0);
1.544 + TEST(iFbs->ResourceCount()==0);
1.545 +
1.546 +
1.547 +// Duplicate
1.548 + CFbsBitmap bmpalt;
1.549 + ret = bmpalt.Create(KSmallSize,EColor256);
1.550 + TEST2(ret, KErrNone);
1.551 +
1.552 + INFO_PRINTF1(_L("CFbsBitmap::Duplicate()\r\n"));
1.553 + for (count = 1; ; count++)
1.554 + {
1.555 + iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
1.556 + if(heapMarkCheckFlag)
1.557 + {
1.558 + iFbs->SendCommand(EFbsMessDefaultMark);
1.559 + iFbs->SendCommand(EFbsMessUserMark);
1.560 + }
1.561 +
1.562 + ret = iBitmap.Duplicate(bmpalt.Handle());
1.563 +
1.564 + if (ret == KErrNoMemory)
1.565 + {
1.566 + if(heapMarkCheckFlag)
1.567 + {
1.568 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.569 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.570 + }
1.571 + }
1.572 + else if (ret == KErrNone)
1.573 + {
1.574 + iBitmap.Reset();
1.575 + if(heapMarkCheckFlag)
1.576 + {
1.577 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.578 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.579 + }
1.580 + break;
1.581 + }
1.582 + else
1.583 + TEST2(ret, KErrNone);
1.584 + }
1.585 +
1.586 + iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
1.587 + iFbs->SendCommand(EFbsMessUserAllocFail,0);
1.588 + TEST(iFbs->ResourceCount()==1);
1.589 + ret = bmpalt.Create(KSmallSize,EColor256);
1.590 + TEST2(ret, KErrNone);
1.591 +
1.592 + for (count = 1; ; count++)
1.593 + {
1.594 + iFbs->SendCommand(EFbsMessUserAllocFail,count);
1.595 + if(heapMarkCheckFlag)
1.596 + {
1.597 + iFbs->SendCommand(EFbsMessDefaultMark);
1.598 + iFbs->SendCommand(EFbsMessUserMark);
1.599 + }
1.600 +
1.601 + ret = iBitmap.Duplicate(bmpalt.Handle());
1.602 +
1.603 + if (ret == KErrNoMemory)
1.604 + {
1.605 + if(heapMarkCheckFlag)
1.606 + {
1.607 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.608 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.609 + }
1.610 + }
1.611 + else if (ret == KErrNone)
1.612 + {
1.613 + iBitmap.Reset();
1.614 + if(heapMarkCheckFlag)
1.615 + {
1.616 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.617 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.618 + }
1.619 + break;
1.620 + }
1.621 + else
1.622 + TEST2(ret, KErrNone);
1.623 + }
1.624 +
1.625 + iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
1.626 + iFbs->SendCommand(EFbsMessUserAllocFail,0);
1.627 + bmpalt.Reset();
1.628 + TEST(iFbs->ResourceCount()==0);
1.629 +
1.630 +// Resize
1.631 + // force fbserv to do a resize. This makes the pile to insert an index in it's array
1.632 + // If the array is empty when the tests below are run then the insert will look like a mem leak
1.633 + ret=iBitmap.Create(KLargeSize,EColor256);
1.634 + iBitmap.Resize(KLargeSizeAlt);
1.635 + iBitmap.Reset();
1.636 +
1.637 + ret=iBitmap.Create(KSmallSize,EColor256);
1.638 + TEST2(ret, KErrNone);
1.639 +
1.640 + INFO_PRINTF1(_L("CFbsBitmap::Resize()\r\n"));
1.641 + for (count = 1; ; count++)
1.642 + {
1.643 + iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
1.644 + if(heapMarkCheckFlag)
1.645 + {
1.646 + iFbs->SendCommand(EFbsMessDefaultMark);
1.647 + iFbs->SendCommand(EFbsMessUserMark);
1.648 + }
1.649 +
1.650 + ret = iBitmap.Resize(KSmallSizeAlt);
1.651 +
1.652 + if (ret == KErrNoMemory)
1.653 + {
1.654 + if(heapMarkCheckFlag)
1.655 + {
1.656 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.657 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.658 + }
1.659 + }
1.660 + else if (ret == KErrNone)
1.661 + {
1.662 + iBitmap.Reset();
1.663 + if(heapMarkCheckFlag)
1.664 + {
1.665 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.666 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.667 + }
1.668 + break;
1.669 + }
1.670 + else
1.671 + TEST2(ret, KErrNone);
1.672 + }
1.673 +
1.674 + iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
1.675 + iFbs->SendCommand(EFbsMessUserAllocFail,0);
1.676 + TEST(iFbs->ResourceCount()==0);
1.677 +
1.678 +
1.679 + // force fbserv to do a resize. This makes the pile to insert an index in it's array
1.680 + // If the array is empty when the tests below are run then the insert will look like a mem leak
1.681 + ret=iBitmap.Create(KLargeSize,EColor256);
1.682 + iBitmap.Resize(KLargeSizeAlt);
1.683 + iBitmap.Reset();
1.684 +
1.685 + ret=iBitmap.Create(KLargeSize,EColor256);
1.686 + TEST2(ret, KErrNone);
1.687 +
1.688 + for (count = 1; ; count++)
1.689 + {
1.690 + iFbs->SendCommand(EFbsMessUserAllocFail,count);
1.691 + if(heapMarkCheckFlag)
1.692 + {
1.693 + iFbs->SendCommand(EFbsMessDefaultMark);
1.694 + iFbs->SendCommand(EFbsMessUserMark);
1.695 + }
1.696 +
1.697 + ret = iBitmap.Resize(KLargeSizeAlt);
1.698 +
1.699 + if (ret == KErrNoMemory)
1.700 + {
1.701 + if(heapMarkCheckFlag)
1.702 + {
1.703 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.704 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.705 + }
1.706 + }
1.707 + else if (ret == KErrNone)
1.708 + {
1.709 + iBitmap.Reset();
1.710 + if(heapMarkCheckFlag)
1.711 + {
1.712 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.713 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.714 + }
1.715 + break;
1.716 + }
1.717 + else
1.718 + TEST2(ret, KErrNone);
1.719 + }
1.720 +
1.721 + iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
1.722 + iFbs->SendCommand(EFbsMessUserAllocFail,0);
1.723 + TEST(iFbs->ResourceCount()==0);
1.724 +
1.725 +// Compress
1.726 + ret=iBitmap.Create(KSmallSize,EColor256);
1.727 + TEST2(ret, KErrNone);
1.728 +
1.729 + INFO_PRINTF1(_L("CFbsBitmap::Compress()\r\n"));
1.730 + for (count = 1; ; count++)
1.731 + {
1.732 + iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
1.733 + if(heapMarkCheckFlag)
1.734 + {
1.735 + iFbs->SendCommand(EFbsMessDefaultMark);
1.736 + iFbs->SendCommand(EFbsMessUserMark);
1.737 + }
1.738 +
1.739 + ret = iBitmap.Compress();
1.740 +
1.741 + if (ret == KErrNoMemory)
1.742 + {
1.743 + if(heapMarkCheckFlag)
1.744 + {
1.745 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.746 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.747 + }
1.748 + }
1.749 + else if (ret == KErrNone)
1.750 + {
1.751 + iBitmap.Reset();
1.752 + if(heapMarkCheckFlag)
1.753 + {
1.754 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.755 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.756 + }
1.757 + break;
1.758 + }
1.759 + else
1.760 + TEST2(ret, KErrNone);
1.761 + }
1.762 +
1.763 + iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
1.764 + iFbs->SendCommand(EFbsMessUserAllocFail,0);
1.765 + TEST(iFbs->ResourceCount()==0);
1.766 +
1.767 + ret=iBitmap.Create(KLargeSize,EColor256);
1.768 + TEST2(ret, KErrNone);
1.769 +
1.770 + INFO_PRINTF1(_L("CFbsBitmap::Compress()\r\n"));
1.771 + for (count = 1; ; count++)
1.772 + {
1.773 + iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
1.774 + if(heapMarkCheckFlag)
1.775 + {
1.776 + iFbs->SendCommand(EFbsMessDefaultMark);
1.777 + iFbs->SendCommand(EFbsMessUserMark);
1.778 + }
1.779 +
1.780 + ret = iBitmap.Compress();
1.781 +
1.782 + if (ret == KErrNoMemory)
1.783 + {
1.784 + if(heapMarkCheckFlag)
1.785 + {
1.786 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.787 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.788 + }
1.789 + }
1.790 + else if (ret == KErrNone)
1.791 + {
1.792 + iBitmap.Reset();
1.793 + if(heapMarkCheckFlag)
1.794 + {
1.795 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.796 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.797 + }
1.798 + break;
1.799 + }
1.800 + else
1.801 + TEST2(ret, KErrNone);
1.802 + }
1.803 +
1.804 + iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
1.805 + iFbs->SendCommand(EFbsMessUserAllocFail,0);
1.806 + TEST(iFbs->ResourceCount()==0);
1.807 +
1.808 +// WriteStore creation
1.809 + RFs fs;
1.810 + ret=fs.Connect();
1.811 + TEST2(ret, KErrNone);
1.812 + CDirectFileStore* writestore=NULL;
1.813 +
1.814 + //Construct filename using the thread id to enable concurrent test runs.
1.815 + _LIT(KSbmFileName,"c:\\tall_");
1.816 + TBuf<36> buf(KSbmFileName);
1.817 + TThreadId threadId = RThread().Id();
1.818 + TUint64 id = threadId.Id();
1.819 + TBuf<20> threadIdBuf;
1.820 + threadIdBuf.Num(id);
1.821 + buf.Append(threadIdBuf);
1.822 + buf.Append(_L(".sbm"));
1.823 +
1.824 + TRAP(ret,writestore=CDirectFileStore::ReplaceL(fs,buf,EFileStream|EFileWrite));
1.825 + TEST2(ret, KErrNone);
1.826 + TUidType uidtype(KDirectFileStoreLayoutUid,KMultiBitmapFileImageUid);
1.827 + TRAP(ret,writestore->SetTypeL(uidtype));
1.828 + TEST2(ret, KErrNone);
1.829 +
1.830 + RStoreWriteStream writestrm;
1.831 + TStreamId headerid(0);
1.832 + TRAP(ret,headerid=writestrm.CreateL(*writestore));
1.833 + TEST2(ret, KErrNone);
1.834 + TRAP(ret,writestore->SetRootL(headerid));
1.835 + TEST2(ret, KErrNone);
1.836 +
1.837 +// Externalize
1.838 + ret=iBitmap.Create(KSmallSize,EColor256);
1.839 + TEST2(ret, KErrNone);
1.840 +
1.841 + INFO_PRINTF1(_L("CFbsBitmap::ExternalizeL()\r\n"));
1.842 + for (count = 1; ; count++)
1.843 + {
1.844 + __UHEAP_SETFAIL(RHeap::EDeterministic,count);
1.845 + __UHEAP_MARK;
1.846 +
1.847 + TRAP(ret,iBitmap.ExternalizeL(writestrm));
1.848 +
1.849 + if (ret == KErrNoMemory)
1.850 + {
1.851 + __UHEAP_MARKEND;
1.852 + }
1.853 + else if (ret == KErrNone)
1.854 + {
1.855 + iBitmap.Reset();
1.856 + __UHEAP_MARKEND;
1.857 + break;
1.858 + }
1.859 + else
1.860 + {
1.861 + __UHEAP_MARKEND;
1.862 + TEST2(ret, KErrNone);
1.863 + }
1.864 + }
1.865 +
1.866 + __UHEAP_RESET;
1.867 + TEST(iFbs->ResourceCount()==0);
1.868 +
1.869 +// ExternalizeRectangle
1.870 + ret=iBitmap.Create(KSmallSize,EColor256);
1.871 + TEST2(ret, KErrNone);
1.872 +
1.873 + INFO_PRINTF1(_L("CFbsBitmap::ExternalizeRectangleL()\r\n"));
1.874 + for (count = 1; ; count++)
1.875 + {
1.876 + __UHEAP_SETFAIL(RHeap::EDeterministic,count);
1.877 + __UHEAP_MARK;
1.878 +
1.879 + TRAP(ret,iBitmap.ExternalizeRectangleL(writestrm,TRect(3,3,7,7)));
1.880 +
1.881 + if (ret == KErrNoMemory)
1.882 + {
1.883 + __UHEAP_MARKEND;
1.884 + }
1.885 + else if (ret == KErrNone)
1.886 + {
1.887 + __UHEAP_MARKEND;
1.888 + break;
1.889 + }
1.890 + else
1.891 + {
1.892 + __UHEAP_MARKEND;
1.893 + TEST2(ret, KErrNone);
1.894 + }
1.895 + }
1.896 +
1.897 + __UHEAP_RESET;
1.898 + writestrm.Close();
1.899 + delete writestore;
1.900 + iBitmap.Reset();
1.901 + TEST(iFbs->ResourceCount()==0);
1.902 +
1.903 +// Internalize
1.904 + INFO_PRINTF1(_L("CFbsBitmap::InternalizeL()\r\n"));
1.905 + for (count = 1; ; count++)
1.906 + {
1.907 + // ReadStore creation
1.908 + CDirectFileStore* readstore=NULL;
1.909 + TRAP(ret,readstore=CDirectFileStore::OpenL(fs,buf,EFileStream|EFileRead|EFileShareAny));
1.910 + TEST2(ret, KErrNone);
1.911 + RStoreReadStream readstrm;
1.912 + headerid=readstore->Root();
1.913 + TRAP(ret,readstrm.OpenL(*readstore,headerid));
1.914 + TEST2(ret, KErrNone);
1.915 +
1.916 + iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
1.917 + if(heapMarkCheckFlag)
1.918 + {
1.919 + iFbs->SendCommand(EFbsMessDefaultMark);
1.920 + iFbs->SendCommand(EFbsMessUserMark);
1.921 + }
1.922 +
1.923 + TRAP(ret,iBitmap.InternalizeL(readstrm));
1.924 +
1.925 + readstrm.Close();
1.926 + delete readstore;
1.927 +
1.928 + if (ret == KErrNoMemory)
1.929 + {
1.930 + if(heapMarkCheckFlag)
1.931 + {
1.932 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.933 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.934 + }
1.935 + }
1.936 + else if (ret == KErrNone)
1.937 + {
1.938 + iBitmap.Reset();
1.939 + if(heapMarkCheckFlag)
1.940 + {
1.941 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.942 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.943 + }
1.944 + break;
1.945 + }
1.946 + else
1.947 + TEST2(ret, KErrNone);
1.948 + }
1.949 +
1.950 + iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
1.951 + iFbs->SendCommand(EFbsMessUserAllocFail,0);
1.952 + TEST(iFbs->ResourceCount()==0);
1.953 +
1.954 + for (count = 1; ; count++)
1.955 + {
1.956 + // ReadStore re-creation
1.957 + CDirectFileStore* readstore=NULL;
1.958 +// TRAP(ret,readstore=CDirectFileStore::OpenL(fs,_L("c:\\tall.sbm"),EFileStream|EFileRead|EFileShareAny));
1.959 + TRAP(ret,readstore=CDirectFileStore::OpenL(fs,buf,EFileStream|EFileRead|EFileShareAny));
1.960 + TEST2(ret, KErrNone);
1.961 + headerid=readstore->Root();
1.962 + RStoreReadStream readstrm;
1.963 + TRAP(ret,readstrm.OpenL(*readstore,headerid));
1.964 + TEST2(ret, KErrNone);
1.965 +
1.966 + iFbs->SendCommand(EFbsMessUserAllocFail,count);
1.967 + if(heapMarkCheckFlag)
1.968 + {
1.969 + iFbs->SendCommand(EFbsMessDefaultMark);
1.970 + iFbs->SendCommand(EFbsMessUserMark);
1.971 + }
1.972 +
1.973 + TRAP(ret,iBitmap.InternalizeL(readstrm));
1.974 +
1.975 + readstrm.Close();
1.976 + delete readstore;
1.977 +
1.978 + if (ret == KErrNoMemory)
1.979 + {
1.980 + if(heapMarkCheckFlag)
1.981 + {
1.982 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.983 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.984 + }
1.985 + }
1.986 + else if (ret == KErrNone)
1.987 + {
1.988 + iBitmap.Reset();
1.989 + if(heapMarkCheckFlag)
1.990 + {
1.991 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.992 + iFbs->SendCommand(EFbsMessUserMarkEnd);
1.993 + }
1.994 + break;
1.995 + }
1.996 + else
1.997 + TEST2(ret, KErrNone);
1.998 + }
1.999 +
1.1000 + iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
1.1001 + iFbs->SendCommand(EFbsMessUserAllocFail,0);
1.1002 + TEST(iFbs->ResourceCount()==0);
1.1003 +
1.1004 + fs.Delete(buf);
1.1005 + fs.Close();
1.1006 + }
1.1007 +
1.1008 +/**
1.1009 + @SYMTestCaseID
1.1010 + GRAPHICS-FBSERV-0513
1.1011 +
1.1012 + @SYMTestCaseDesc
1.1013 + Checks allocations of CFbsTypeFaceStore Objects OOM conditions
1.1014 +
1.1015 + @SYMTestActions
1.1016 + Uses different fonts and allocates CFbsTypeFaceStore objects
1.1017 + and checks them under Out Of Memory conditions
1.1018 +
1.1019 + @SYMTestExpectedResults
1.1020 + Test should pass
1.1021 +*/
1.1022 +void CTAlloc::TypefaceStoreL()
1.1023 + {
1.1024 + TInt count;
1.1025 + TInt ret;
1.1026 + CFbsTypefaceStore* tfs = NULL;
1.1027 + INFO_PRINTF1(_L("CFbsTypefaceStore::NewL()\r\n"));
1.1028 +
1.1029 + TInt heapMarkCheckFlag;
1.1030 + if( !iStep->GetIntFromConfig(KDefaultSectionName, KFbsHeapMarkCheckFlag, heapMarkCheckFlag) )
1.1031 + {
1.1032 + INFO_PRINTF1(_L("Error reading ini file"));
1.1033 + User::Leave(KErrNotFound);
1.1034 + }
1.1035 +
1.1036 +// CFbsTypefaceStore::NewL()
1.1037 + for (count = 1; ; count++)
1.1038 + {
1.1039 + __UHEAP_SETFAIL(RHeap::EDeterministic,count);
1.1040 + __UHEAP_MARK;
1.1041 +
1.1042 + TRAP(ret,tfs=CFbsTypefaceStore::NewL(NULL));
1.1043 +
1.1044 + if (ret == KErrNoMemory)
1.1045 + {
1.1046 + __UHEAP_MARKEND;
1.1047 + }
1.1048 + else if (ret == KErrNone)
1.1049 + {
1.1050 + delete tfs;
1.1051 + __UHEAP_MARKEND;
1.1052 + break;
1.1053 + }
1.1054 + else
1.1055 + {
1.1056 + __UHEAP_MARKEND;
1.1057 + TEST2(ret, KErrNone);
1.1058 + }
1.1059 + }
1.1060 +
1.1061 + __UHEAP_RESET;
1.1062 +
1.1063 +// CFbsTypefaceStore::SetFontNameAliasL()
1.1064 + _LIT(KFontNameAlias,"Fubar");
1.1065 + TRAP(ret,tfs = CFbsTypefaceStore::NewL(NULL));
1.1066 + TEST2(ret, KErrNone);
1.1067 + TRAP(ret, tfs->SetFontNameAliasL(_L("ExpandArray"),_L("DejaVu Serif Condensed")));
1.1068 + TEST2(ret, KErrNone);
1.1069 + TRAP(ret, tfs->SetFontNameAliasL(_L("ExpandArray"),KNullDesC));
1.1070 + TEST2(ret, KErrNone);
1.1071 +
1.1072 + for (count = 1; ; count++)
1.1073 + {
1.1074 + iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
1.1075 + if(heapMarkCheckFlag)
1.1076 + {
1.1077 + iFbs->SendCommand(EFbsMessDefaultMark);
1.1078 + }
1.1079 +
1.1080 + TRAP(ret, tfs->SetFontNameAliasL(KFontNameAlias,_L("DejaVu Serif Condensed")));
1.1081 +
1.1082 + if (ret == KErrNoMemory)
1.1083 + {
1.1084 + if(heapMarkCheckFlag)
1.1085 + {
1.1086 + iFbs->SendCommand(EFbsMessDefaultMarkEnd);
1.1087 + }
1.1088 + }
1.1089 + else if (ret == KErrNone)
1.1090 + {
1.1091 + if(heapMarkCheckFlag)
1.1092 + {
1.1093 + iFbs->SendCommand(EFbsMessDefaultMarkEnd,2);
1.1094 + }
1.1095 + break;
1.1096 + }
1.1097 + else
1.1098 + TEST2(ret, KErrNone);
1.1099 + }
1.1100 +
1.1101 + iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
1.1102 +
1.1103 +// GetNearestFontToDesignHeightInTwips()
1.1104 + TFontSpec spec(_L("SwissA"),12);
1.1105 + CFont* font = NULL;
1.1106 + ret = tfs->GetNearestFontToDesignHeightInTwips(font,spec);
1.1107 + TEST2(ret, KErrNone);
1.1108 + tfs->ReleaseFont(font);
1.1109 + spec.iTypeface.iName = _L("DejaVu Serif Condensed");
1.1110 +
1.1111 + for (count = 1; ; count++)
1.1112 + {
1.1113 + __UHEAP_SETFAIL(RHeap::EDeterministic,count);
1.1114 + __UHEAP_MARK;
1.1115 +
1.1116 + ret = tfs->GetNearestFontToDesignHeightInTwips(font,spec);
1.1117 +
1.1118 + if (ret == KErrNoMemory)
1.1119 + {
1.1120 + ASSERT(!font);
1.1121 + __UHEAP_MARKEND;
1.1122 + }
1.1123 + else if (ret == KErrNone)
1.1124 + {
1.1125 + ASSERT(font);
1.1126 + tfs->ReleaseFont(font);
1.1127 + __UHEAP_MARKEND;
1.1128 + break;
1.1129 + }
1.1130 + else
1.1131 + {
1.1132 + __UHEAP_MARKEND;
1.1133 + TEST2(ret, KErrNone);
1.1134 + }
1.1135 + }
1.1136 +
1.1137 + __UHEAP_RESET;
1.1138 +
1.1139 +// GetNearestFontToDesignHeightInTwips() with alias
1.1140 + spec.iTypeface.iName = KFontNameAlias;
1.1141 + TRAP(ret, tfs->SetFontNameAliasL(KFontNameAlias,_L("DejaVu Serif Condensed")));
1.1142 + TEST2(ret, KErrNone);
1.1143 +
1.1144 + for (count = 1; ; count++)
1.1145 + {
1.1146 + __UHEAP_SETFAIL(RHeap::EDeterministic,count);
1.1147 + __UHEAP_MARK;
1.1148 +
1.1149 + ret = tfs->GetNearestFontToDesignHeightInTwips(font,spec);
1.1150 +
1.1151 + if (ret == KErrNoMemory)
1.1152 + {
1.1153 + ASSERT(!font);
1.1154 + __UHEAP_MARKEND;
1.1155 + }
1.1156 + else if (ret == KErrNone)
1.1157 + {
1.1158 + ASSERT(font);
1.1159 + tfs->ReleaseFont(font);
1.1160 + __UHEAP_MARKEND;
1.1161 + break;
1.1162 + }
1.1163 + else
1.1164 + {
1.1165 + __UHEAP_MARKEND;
1.1166 + TEST2(ret, KErrNone);
1.1167 + }
1.1168 + }
1.1169 +
1.1170 + __UHEAP_RESET;
1.1171 + TRAP(ret, tfs->SetFontNameAliasL(KFontNameAlias,KNullDesC));
1.1172 + TEST2(ret, KErrNone);
1.1173 + delete tfs;
1.1174 + }
1.1175 +
1.1176 +/**
1.1177 + @SYMTestCaseID
1.1178 + GRAPHICS-FBSERV-0514
1.1179 +
1.1180 + @SYMTestCaseDesc
1.1181 + Asynchronous loading and saving of bitmaps
1.1182 +
1.1183 + @SYMTestActions
1.1184 + Creates a loader for bitmaps and simulates Out Of Memory conditions
1.1185 + and then creates and saver and simulates Out Of Memory conditions
1.1186 +
1.1187 + @SYMTestExpectedResults
1.1188 + Test should pass
1.1189 +*/
1.1190 +void CTAlloc::BitmapHandlerL()
1.1191 + {
1.1192 + TInt ret=KErrNone;
1.1193 + CFbsBitmapAsyncStreamer* bmphandler=NULL;
1.1194 +
1.1195 +// Create loader
1.1196 + TInt count;
1.1197 + INFO_PRINTF1(_L("CFbsBitmapAsyncStreamer::NewL()\r\n"));
1.1198 + for (count = 1; ; count++)
1.1199 + {
1.1200 + __UHEAP_SETFAIL(RHeap::EDeterministic,count);
1.1201 + __UHEAP_MARK;
1.1202 +
1.1203 + TRAP(ret,bmphandler = CFbsBitmapAsyncStreamer::NewL(CFbsBitmapAsyncStreamer::ELoad));
1.1204 +
1.1205 + if (ret == KErrNoMemory)
1.1206 + {
1.1207 + __UHEAP_MARKEND;
1.1208 + }
1.1209 + else if (ret == KErrNone)
1.1210 + {
1.1211 + delete bmphandler;
1.1212 + __UHEAP_MARKEND;
1.1213 + break;
1.1214 + }
1.1215 + else
1.1216 + {
1.1217 + __UHEAP_MARKEND;
1.1218 + TEST2(ret, KErrNone);
1.1219 + }
1.1220 + }
1.1221 +
1.1222 + __UHEAP_RESET;
1.1223 + TEST(iFbs->ResourceCount()==0);
1.1224 +
1.1225 +// Create saver
1.1226 + for (count = 1; ; count++)
1.1227 + {
1.1228 + __UHEAP_SETFAIL(RHeap::EDeterministic,count);
1.1229 + __UHEAP_MARK;
1.1230 +
1.1231 + TRAP(ret,bmphandler=CFbsBitmapAsyncStreamer::NewL(CFbsBitmapAsyncStreamer::ESave));
1.1232 +
1.1233 + if (ret == KErrNoMemory)
1.1234 + {
1.1235 + __UHEAP_MARKEND;
1.1236 + }
1.1237 + else if (ret == KErrNone)
1.1238 + {
1.1239 + delete bmphandler;
1.1240 + __UHEAP_MARKEND;
1.1241 + break;
1.1242 + }
1.1243 + else
1.1244 + {
1.1245 + __UHEAP_MARKEND;
1.1246 + TEST2(ret, KErrNone);
1.1247 + }
1.1248 + }
1.1249 +
1.1250 + __UHEAP_RESET;
1.1251 + TEST(iFbs->ResourceCount()==0);
1.1252 + }
1.1253 +
1.1254 +/**
1.1255 + @SYMTestCaseID
1.1256 + GRAPHICS-FBSERV-0515
1.1257 +
1.1258 + @SYMTestCaseDesc
1.1259 + Tests memory allocation of CFontStore object
1.1260 +
1.1261 + @SYMTestActions
1.1262 + CFontStore objects is created on the heap
1.1263 +
1.1264 + @SYMTestExpectedResults
1.1265 + Test should pass
1.1266 +*/
1.1267 +void CTAlloc::FontStoreL()
1.1268 + {
1.1269 + INFO_PRINTF1(_L("CFontStore::NewL()\r\n"));
1.1270 +
1.1271 + for (TInt count = 1; ; count++)
1.1272 + {
1.1273 + __UHEAP_SETFAIL(RHeap::EDeterministic,count);
1.1274 + __UHEAP_MARK;
1.1275 +
1.1276 + CFontStore* fs = NULL;
1.1277 + TRAPD(ret,fs = CFontStore::NewL(&User::Heap()));
1.1278 +
1.1279 + if (ret == KErrNoMemory)
1.1280 + {
1.1281 + __UHEAP_MARKEND;
1.1282 + }
1.1283 + else if (ret == KErrNone)
1.1284 + {
1.1285 + delete fs;
1.1286 + __UHEAP_MARKEND;
1.1287 + __UHEAP_SETFAIL(RHeap::ENone,count);
1.1288 + break;
1.1289 + }
1.1290 + else
1.1291 + {
1.1292 + __UHEAP_MARKEND;
1.1293 + TEST2(ret, KErrNone);
1.1294 + }
1.1295 + }
1.1296 +
1.1297 + }
1.1298 +
1.1299 +//--------------
1.1300 +__CONSTRUCT_STEP__(Alloc)
1.1301 +