os/ossrv/genericservices/httputils/Test/IpuTestUtils/ctestbase.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericservices/httputils/Test/IpuTestUtils/ctestbase.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,50 @@
     1.4 +// Copyright (c) 2002-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 +
    1.20 +
    1.21 +#include "ctestbase.h"
    1.22 +
    1.23 +
    1.24 +EXPORT_C void CTestBase::MemoryLeakTestL(CTestBase& aTest, CIpuTestHarness& aTestHarness)
    1.25 +	{
    1.26 +	// set aTestHarness to be in memoryleak mode
    1.27 +	aTestHarness.SetTestMode(CIpuTestHarness::ETestModeMemoryLeak);
    1.28 +
    1.29 +	TInt ii=0;
    1.30 +	_LIT(KMemoryLeakMessage, "Memory Leak Testing on allocation %d\n");
    1.31 +	FOREVER
    1.32 +		{
    1.33 +		aTestHarness.LogIt(KMemoryLeakMessage, ii);
    1.34 +		__UHEAP_MARK;
    1.35 +		__UHEAP_FAILNEXT(ii);
    1.36 +		TRAPD(err,aTest.DoTestsL());
    1.37 +		__UHEAP_MARKEND;
    1.38 +		User::Heap().Check();
    1.39 +		__UHEAP_RESET;
    1.40 +		// Break out if the test passes successfully;
    1.41 +		if (err == KErrNone)
    1.42 +			break;
    1.43 +		if (err != KErrNoMemory)
    1.44 +			{
    1.45 +			// set aTestHarness back to normal mode
    1.46 +			aTestHarness.SetTestMode(CIpuTestHarness::ETestModeNormal);			
    1.47 +			User::LeaveIfError(err);
    1.48 +			}
    1.49 +		++ii;
    1.50 +		}
    1.51 +	// set aTestHarness back to normal mode
    1.52 +	aTestHarness.SetTestMode(CIpuTestHarness::ETestModeNormal);
    1.53 +	}