diff -r 57c618273d5c -r bbf46f59e123 graphicsresourceservices/graphicsresourceimplementation/test/src/tsggenericmanual.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graphicsresourceservices/graphicsresourceimplementation/test/src/tsggenericmanual.cpp Tue Aug 31 16:31:06 2010 +0300 @@ -0,0 +1,210 @@ +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Tests for manual execution. + +/** + @file + @test + @internalComponent - Graphics Resource API Conformance Test Suite +*/ + +#include "tsggenericmanual.h" + +CTSgGenericManual::CTSgGenericManual(TBool aConformanceTests) : + CTSgTestStepBase(aConformanceTests) + { + INFO_PRINTF1(_L("Graphics resource component test - Generic Manual Tests.\r\n")); + } + +CTSgGenericManual::~CTSgGenericManual() + { + iSecondProcess.Close(); + iMsgQ.Close(); + } + +/** +This is intented to be used for TestStressResourceLeakL (GRAPHICS-RESOURCE-0050) test. +It creates images until the memory full situation. The images are kept in the passed RArray of RSgImage. +The returned error code is expected to be either KErrNoMemory or KErrNoGraphicsMemory. +Optionally, it opens and closes a duplicate handle to each image in the same process and in another process. +*/ +TInt CTSgGenericManual::CreateImages(const TSgImageInfo& aInfo, RArray& aTestImages, TBool aDuplicate) + { + TInt err = KErrNone; + while(err == KErrNone) + { + RSgImage image; + err = image.Create(aInfo); + if(err == KErrNone) + { + err = aTestImages.Append(image); + if (err != KErrNone) + { + image.Close(); + return err; + } + if (aDuplicate) + { + RSgImage image2; + err = image2.Open(image.Id()); + if (err != KErrNone) + { + return err; + } + // send the image ID to the second process and wait until the + // second process has opened and closed a handle to the image + TRequestStatus status; + iSecondProcess.Rendezvous(status); + iMsgQ.SendBlocking(image.Id()); + User::WaitForRequest(status); + image2.Close(); + err = status.Int(); + } + } + } + return err; + } + +void CTSgGenericManual::DestroyImages(RArray& aTestImages) + { + TInt count = aTestImages.Count(); + for(TInt i=0; i testImages; + + TInt count(0); + TInt err = KErrNone; + for (TInt i = 0; i < numIterations && err == KErrNone; ++i) + { + err = CreateImages(info, testImages, duplicate); + TInt thisCount = testImages.Count(); + DestroyImages(testImages); + + if (err == KErrNoMemory || err == KErrNoGraphicsMemory) + { + err = KErrNone; + } + else if (err != KErrNone) + { + WARN_PRINTF2(_L("Create images error [%d]"), err); + SetTestStepResult(ETestSuiteError); + } + + if (i == 0) + { + count = thisCount; + } + else + { + if (count != thisCount) + { + INFO_PRINTF4(_L("Mismatch @ iteration %d: initial %d, now %d"), i, count, thisCount); + } + if (tolerance >= 0) + { + TEST(Abs(count - thisCount) <= tolerance); + } + } + } + + INFO_PRINTF2(_L("Last iteration: %d images created\r\n"), count); + if (duplicate) + { + // send a null ID to tell the second process to kill itself + // and wait until the second process terminates + TRequestStatus status; + iSecondProcess.Logon(status); + iMsgQ.SendBlocking(KSgNullDrawableId); + User::WaitForRequest(status); + iMsgQ.Close(); + iSecondProcess.Close(); + } + TestCloseDriver(); + } +