os/graphics/fbs/fontandbitmapserver/tfbs/textendedbitmappanic.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2008-2009 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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include "UTILS.h"
    17 #include "textendedbitmapcommon.h"
    18 #include "textendedbitmappanic.h"
    19 #include <e32math.h>
    20 #include <s32file.h>
    21 #include <bautils.h>
    22 #include <hal.h>
    23 #include <test/tefunit.h>
    24 
    25 
    26 const TUint8 KTestData[] = "Extended bitmap test data 123456";
    27 const TInt KTestDataSize = sizeof(KTestData);
    28 const TSize KSizeInPixels = TSize(50,50);
    29 const TDisplayMode KDisplayMode	= EColor64K;
    30 
    31 GLREF_C void Panic(TFbsPanic aPanic);
    32 
    33 CTExtendedBitmapPanic::CTExtendedBitmapPanic(CTestStep* aStep):
    34 CTFbsBase(aStep, EFalse)
    35 	{
    36 	__ASSERT_DEBUG(CActiveScheduler::Current(), User::Invariant());	
    37 	}
    38 
    39 CTExtendedBitmapPanic::~CTExtendedBitmapPanic()
    40 	{	
    41 	delete iExtendedBitmap;
    42 	}
    43 
    44 void CTExtendedBitmapPanic::ConstructL()
    45 	{
    46 	iExtendedBitmap = new(ELeave)CFbsBitmap;
    47 	TInt err = iExtendedBitmap->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize);
    48 	User::LeaveIfError(err);
    49 	}
    50 
    51 void CTExtendedBitmapPanic::RunFbsTestL(TInt /*aCurTestCase*/)
    52     {       
    53     _LIT(KCaseNumber, "CaseNumber");
    54 
    55     TInt stepNumber;
    56 	TBool res = iStep->GetIntFromConfig(iStep->ConfigSection(), KCaseNumber, stepNumber);	
    57 	if(!res)
    58 		{
    59 		return;
    60 		}
    61 	((CTExtendedBitmapPanicStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
    62 	switch(stepNumber)
    63 		{
    64 	case 1:
    65 		((CTExtendedBitmapPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0020"));
    66 		TestSetScanLine();
    67 		((CTExtendedBitmapPanicStep*)iStep)->RecordTestResultL();
    68 		TEST(EFalse);
    69 		TestComplete();
    70 		break;
    71 	case 2:
    72 		((CTExtendedBitmapPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0041"));
    73 		TestIsMonochrome();
    74 		((CTExtendedBitmapPanicStep*)iStep)->RecordTestResultL();
    75 		TEST(EFalse);
    76 		TestComplete();
    77 		break;
    78 	default:
    79 		((CTExtendedBitmapPanicStep*)iStep)->CloseTMSGraphicsStep();
    80 		TestComplete();
    81 		break;
    82 		}
    83     }
    84    
    85 /**
    86 @SYMTestCaseID
    87 	GRAPHICS-FBSERV-EXTENDEDBITMAP-0020
    88 
    89 @SYMTestCaseDesc
    90 	Panic test to check that CFbsBitmap::SetScanLine() panics when used with an extended bitmap
    91 
    92 @SYMPREQ 
    93 	PREQ2096
    94 	
    95 @SYMREQ
    96 	REQ10847
    97 	REQ10857	
    98 
    99 @SYMTestPriority  
   100 	High
   101 	
   102 @SYMTestStatus 
   103 	Implemented
   104 	
   105 @SYMTestActions
   106 	Create an extended bitmap using test data and test Uid.
   107 	Call SetScanLine() on the extended bitmap.
   108 		
   109 @SYMTestExpectedResults
   110 	CFbsBitmap::SetScanLine() should panic with FBSERV 28 (EFbsPanicBitmapReadOnly) in debug only
   111 */
   112 void CTExtendedBitmapPanic::TestSetScanLine()
   113 	{
   114 	INFO_PRINTF1(_L("TestSetScanLine - panic test"));
   115 		
   116 	TBuf8<16> temp;		
   117 	iExtendedBitmap->SetScanLine(temp, 0); // This should panic with FBSERV 28 (EFbsPanicBitmapReadOnly) - debug only panic
   118 	
   119 #ifndef _DEBUG
   120 	// Force the panic when not in debug mode so that the test still passes
   121 	INFO_PRINTF1(_L("Forcing a panic in release mode as SetScanLine() only panics in debug"));
   122 	User::Panic(KFBSERVPanicCategory, EFbsPanicBitmapReadOnly);
   123 #endif	
   124 	}
   125 
   126 
   127 /**
   128 @SYMTestCaseID
   129 	GRAPHICS-FBSERV-EXTENDEDBITMAP-0041
   130 
   131 @SYMTestCaseDesc
   132 	Panic test to check that CFbsBitmap::IsMonochrome() panics when used with an extended bitmap
   133 
   134 @SYMPREQ
   135 	CR1804
   136 
   137 @SYMTestPriority 
   138 	High
   139 	
   140 @SYMTestStatus 
   141 	Implemented
   142 	
   143 @SYMTestActions
   144 	Create an extended bitmap using test data and test Uid.
   145 	Call IsMonochrome() on the extended bitmap.
   146 		
   147 @SYMTestExpectedResults
   148 	CFbsBitmap::IsMonochrome() should panic with FBSERV 11 (EFbsBitmapInvalidCompression) in debug only
   149 */
   150 void CTExtendedBitmapPanic::TestIsMonochrome()
   151 	{
   152 	INFO_PRINTF1(_L("TestIsMonochrome - panic test"));
   153 		
   154 	iExtendedBitmap->IsMonochrome(); // This should panic with FBSERV 11 (EFbsBitmapInvalidCompression) - debug only panic
   155 	
   156 #ifndef _DEBUG
   157 	// Force the panic when not in debug mode so that the test still passes
   158 	INFO_PRINTF1(_L("Forcing a panic in release mode as IsMonochrome() only panics in debug"));
   159 	User::Panic(KFBSERVPanicCategory, EFbsBitmapInvalidCompression);
   160 #endif	
   161 	}
   162 
   163 __CONSTRUCT_STEP__(ExtendedBitmapPanic)
   164