os/graphics/windowing/windowserver/test/tauto/TGRAPHICSDRAWER.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserver/test/tauto/TGRAPHICSDRAWER.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,112 @@
     1.4 +// Copyright (c) 2007-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 +// Tests for the TWsGraphicMsgBufParser 
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +/**
    1.22 + @file
    1.23 + @test
    1.24 + @internalComponent - Internal Symbian test code
    1.25 +*/
    1.26 +
    1.27 +#include "TGRAPHICSDRAWER.H"
    1.28 +#include "graphics/WSGRAPHICMSGBUF.H"
    1.29 +
    1.30 +CTGraphicsDrawer::CTGraphicsDrawer(CTestStep* aStep):
    1.31 +	CTGraphicsBase(aStep)
    1.32 +	{
    1.33 +	INFO_PRINTF1(_L("Testing TWsGraphicMsgBufParser"));
    1.34 +	}
    1.35 +		
    1.36 +void CTGraphicsDrawer::RunTestCaseL(TInt aCurTestCase)
    1.37 +	{	
    1.38 +	((CTGraphicsDrawerStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
    1.39 +	switch(aCurTestCase)
    1.40 +		{
    1.41 +	case 1:		
    1.42 +		((CTGraphicsDrawerStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0449"));
    1.43 +		INFO_PRINTF1(_L("TWsGraphicMsgBufParser Indefinite Loop Test"));		
    1.44 +		IndefiniteLoopL();
    1.45 +		break;
    1.46 +		
    1.47 +	case 2:
    1.48 +		((CTGraphicsDrawerStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
    1.49 +		((CTGraphicsDrawerStep*)iStep)->CloseTMSGraphicsStep();
    1.50 +		INFO_PRINTF1(_L("Test complete\n"));
    1.51 +		TestComplete();
    1.52 +		break;
    1.53 +		}
    1.54 +	((CTGraphicsDrawerStep*)iStep)->RecordTestResultL();
    1.55 +	}
    1.56 +
    1.57 +
    1.58 +void CTGraphicsDrawer::ConstructL()
    1.59 +	{
    1.60 +	}
    1.61 +	
    1.62 +CTGraphicsDrawer::~CTGraphicsDrawer()
    1.63 +	{
    1.64 +	}
    1.65 +
    1.66 +/**
    1.67 +@SYMTestCaseID		GRAPHICS-WSERV-0449
    1.68 +
    1.69 +@SYMDEF  			DEF110513, PDEF112710
    1.70 +
    1.71 +@SYMTestCaseDesc    Tests that a zero length buffer does not cause an indefinate loop during verify 
    1.72 +
    1.73 +@SYMTestPriority    Normal
    1.74 +
    1.75 +@SYMTestStatus      Implemented
    1.76 +
    1.77 +@SYMTestActions    	Creates a buffer, puts it into a TWsGraphicMsgBufParser and calls verify on it
    1.78 +					then removes the message from the buffer and re-tests verify.
    1.79 +
    1.80 +@SYMTestExpectedResults Test should pass and not timeout
    1.81 +*/
    1.82 +
    1.83 +void CTGraphicsDrawer::IndefiniteLoopL()
    1.84 +	{
    1.85 +	RWsGraphicMsgBuf msgBuffer;
    1.86 +	msgBuffer.CleanupClosePushL();
    1.87 +	msgBuffer.Append(TUid::Uid(0x12345670),KNullDesC8);
    1.88 +	TWsGraphicMsgBufParser msgParser(msgBuffer.Pckg());
    1.89 +	
    1.90 +	// test the verify method with a single message in the buffer
    1.91 +	if(msgParser.Verify() != KErrNone)
    1.92 +		{
    1.93 +		INFO_PRINTF1(_L("TWsGraphicMsgBufParser::Verify() failed for buffer length 1"));
    1.94 +		TEST(EFalse);
    1.95 +		}
    1.96 +		
    1.97 +	// remove the (only) message so the message buffer now has a length of zero
    1.98 +	msgBuffer.Remove(0);
    1.99 +	TEST(msgBuffer.Count()==0);
   1.100 +	
   1.101 +	// test the verify method with an zero length buffer
   1.102 +	if(msgParser.Verify() != KErrNone)
   1.103 +		{
   1.104 +		INFO_PRINTF1(_L("TWsGraphicMsgBufParser::Verify() failed for zero length buffer"));
   1.105 +		TEST(EFalse);
   1.106 +		}
   1.107 +	
   1.108 +	CleanupStack::PopAndDestroy(&msgBuffer);
   1.109 +	}
   1.110 +
   1.111 +//--------------
   1.112 +__CONSTRUCT_STEP__(GraphicsDrawer)
   1.113 +
   1.114 +
   1.115 +