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