os/graphics/graphicsresourceservices/graphicsresourceimplementation/test/src/tgraphicsresourceinternalteststepbase.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicsresourceservices/graphicsresourceimplementation/test/src/tgraphicsresourceinternalteststepbase.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,111 @@
1.4 +// Copyright (c) 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 +@file
1.21 +@test
1.22 +@internalComponent
1.23 + */
1.24 +
1.25 +#include "tgraphicsresourceinternalteststepbase.h"
1.26 +
1.27 +CTGraphicsResourceInternalBase::CTGraphicsResourceInternalBase()
1.28 + {
1.29 + }
1.30 +
1.31 +CTGraphicsResourceInternalBase::~CTGraphicsResourceInternalBase()
1.32 + {
1.33 + }
1.34 +
1.35 +/**
1.36 +Creates a second process and do some tests in it.
1.37 +@param aExecutableName The name of the new process
1.38 +@param aTestInfo The information for the tests
1.39 +@leave Gets system wide error code
1.40 +*/
1.41 +TInt CTGraphicsResourceInternalBase::CreateSecondProcessAndDoTestL(const TDesC &aExecutableName, TSgResIntTestInfo& aTestInfo)
1.42 + {
1.43 + // Create a second process
1.44 + RProcess process;
1.45 + User::LeaveIfError(process.Create(aExecutableName, KNullDesC));
1.46 + CleanupClosePushL(process);
1.47 +
1.48 + // Specify the id passed to the second process
1.49 + TPckg<TSgResIntTestInfo> ptr(aTestInfo);
1.50 + TInt err = process.SetParameter(KSecondProcessParametersSlot, ptr);
1.51 + TESTEL(KErrNone == err, err);
1.52 +
1.53 + // Kick off the second process and wait for it to complete
1.54 + // The actual testing is done in the second process
1.55 + TRequestStatus status;
1.56 + process.Logon(status);
1.57 + process.Resume();
1.58 + User::WaitForRequest(status);
1.59 +
1.60 + //ExitReason() returns the test result
1.61 + TInt exitreason = process.ExitReason();
1.62 +
1.63 + TEST(process.ExitType() == EExitKill);
1.64 +
1.65 + CleanupStack::PopAndDestroy();
1.66 +
1.67 + return exitreason;
1.68 + }
1.69 +
1.70 +/**
1.71 +Creates a second process, runs the requested test and ensures that
1.72 +the specified panic occurs.
1.73 +
1.74 +@param aExecutableName The name of the new process
1.75 +@param aTestInfo The specification for this test
1.76 +@param aPanicCategory Descriptor containing the start of the expected panic string e.g. for "ALLOC:xxxxxxxx" this would be "ALLOC"
1.77 +@leave One of the system wide error codes
1.78 +*/
1.79 +void CTGraphicsResourceInternalBase::CreateSecondProcessAndCheckAllocPanicL(const TDesC &aExecutableName, TSgResIntTestInfo& aTestInfo, const TDesC &aPanicCategory)
1.80 + {
1.81 + // Create a second process
1.82 + RProcess process;
1.83 + TInt err = process.Create(aExecutableName, KNullDesC);
1.84 + TESTEL(KErrNone == err, err);
1.85 + CleanupClosePushL(process);
1.86 +
1.87 + // Specify the id passed to the second process
1.88 + TPckg<TSgResIntTestInfo> ptr(aTestInfo);
1.89 + err = process.SetParameter(KSecondProcessParametersSlot, ptr);
1.90 + TESTEL(KErrNone == err, err);
1.91 +
1.92 + // Kick off the second process and wait for it to complete
1.93 + // The actual testing is done in the second process
1.94 + TRequestStatus status;
1.95 + process.Logon(status);
1.96 + process.Resume();
1.97 + User::WaitForRequest(status);
1.98 +
1.99 + if(EExitPanic != process.ExitType())
1.100 + {
1.101 + ERR_PRINTF3(_L("Expected exit type: %d, Actual exit type: %d"), EExitPanic, process.ExitType());
1.102 + TEST(EFalse);
1.103 + }
1.104 +
1.105 + TExitCategoryName secondProcessExitCategory = process.ExitCategory();
1.106 + if(0 != secondProcessExitCategory.Match(aPanicCategory))
1.107 + {
1.108 + ERR_PRINTF3(_L("Expected panic category: %S, Actual panic category: %S"), &aPanicCategory, &secondProcessExitCategory);
1.109 + TEST(EFalse);
1.110 + }
1.111 +
1.112 + CleanupStack::PopAndDestroy();
1.113 + }
1.114 +