sl@0: // Copyright (c) 2002-2009 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: // This file contains the test steps for Unit Test Suite 20 : TestFrameworkServer.cpp sl@0: // sl@0: // sl@0: sl@0: // EPOC includes sl@0: #include sl@0: sl@0: // Test system includes sl@0: #include sl@0: sl@0: // Specific includes for this test suite sl@0: #include "TSU_MmTsthSuite20.h" sl@0: sl@0: // Specific includes for these test steps sl@0: #include "TSU_MmTsth20.h" sl@0: #include "TestFrameworkServer/TestFrameworkServer.h" sl@0: sl@0: // -------------------------------------------- sl@0: sl@0: // Unit Test Suite 20 : TestFrameworkServer.cpp sl@0: // Depends on : TestFrameworkClient (running) sl@0: // Needs : LogFile.cpp, ServerConsole.cpp sl@0: sl@0: // Tests :- sl@0: sl@0: // 1. verify that a CTestFrameworkServer is running sl@0: // 2. verify that a CTestFrameworkServerSession is running sl@0: sl@0: // (CTestFrameworkServerShutdown is a private utility class) sl@0: // (TWindow is private and obsolete; will be removed) sl@0: sl@0: // NB : to test within the TestFramework, we can't open a new server (it's already sl@0: // running) - nor can we access the private API's of Server and ServerSession sl@0: // The tests will validate that the server and session are already running. sl@0: sl@0: sl@0: // -------------------------------------------- sl@0: // RTestMmTsthU2001 sl@0: sl@0: RTestMmTsthU2001* RTestMmTsthU2001::NewL() sl@0: { sl@0: RTestMmTsthU2001* self = new(ELeave) RTestMmTsthU2001; sl@0: return self; sl@0: } sl@0: sl@0: // Each test step initialises its own name. sl@0: RTestMmTsthU2001::RTestMmTsthU2001() sl@0: { sl@0: iTestStepName = _L("MM-TSTH-U-2001"); sl@0: } sl@0: sl@0: // Do the test step. sl@0: TVerdict RTestMmTsthU2001::DoTestStepL() sl@0: { sl@0: INFO_PRINTF1(_L("Unit test for TestFrameworkServer - Server")); sl@0: sl@0: // we can't construct a server - it's already running. Attempts to construct sl@0: // again will leave. sl@0: // Test :- Check it's running, by trying to construct it again. Trap the leave. sl@0: sl@0: TVerdict currentVerdict = EPass; sl@0: sl@0: // create and install the active scheduler we need sl@0: CActiveScheduler* theScheduler = new(ELeave) CActiveScheduler; sl@0: CleanupStack::PushL(theScheduler); sl@0: CActiveScheduler::Install(theScheduler); sl@0: // sl@0: sl@0: CMmfIpcServer* theServer = NULL; sl@0: TRAPD(err, theServer = CTestFrameworkServer::NewL()); sl@0: if(err != KErrAlreadyExists) sl@0: { sl@0: TPtrC errortxt = CLog::EpocErrorToText(err); sl@0: ERR_PRINTF2(_L("Server not already running, create returned %S"), &errortxt); sl@0: delete theServer; sl@0: currentVerdict = EFail; sl@0: } sl@0: else sl@0: { sl@0: TPtrC errortxt = CLog::EpocErrorToText(err); sl@0: INFO_PRINTF2(_L("Server already running, create returned %S"), &errortxt); sl@0: } sl@0: sl@0: // Cleanup the scheduler sl@0: CleanupStack::PopAndDestroy(theScheduler); sl@0: sl@0: return iTestStepResult = currentVerdict; // should be EPass if we've got here sl@0: } sl@0: sl@0: // ------------------------ sl@0: // RTestMmTsthU2002 sl@0: sl@0: RTestMmTsthU2002* RTestMmTsthU2002::NewL() sl@0: { sl@0: RTestMmTsthU2002* self = new(ELeave) RTestMmTsthU2002; sl@0: return self; sl@0: } sl@0: sl@0: // Each test step initialises its own name. sl@0: RTestMmTsthU2002::RTestMmTsthU2002() sl@0: { sl@0: // store the name of this test case sl@0: // this is the name that is used by the script file sl@0: iTestStepName = _L("MM-TSTH-U-2002"); sl@0: } sl@0: sl@0: // Do the test step. sl@0: TVerdict RTestMmTsthU2002::DoTestStepL() sl@0: { sl@0: INFO_PRINTF1(_L("Unit test for TestFrameworkServer - Server Session")); sl@0: sl@0: TVerdict currentVerdict = EPass; sl@0: sl@0: // create and install the active scheduler we need sl@0: CActiveScheduler* theScheduler = new(ELeave) CActiveScheduler; sl@0: CleanupStack::PushL(theScheduler); sl@0: CActiveScheduler::Install(theScheduler); sl@0: // sl@0: sl@0: CMmfIpcServer* theServer = NULL; sl@0: TRAPD(err, theServer = CTestFrameworkServer::NewL()); sl@0: if(err != KErrAlreadyExists) sl@0: { sl@0: TPtrC errortxt = CLog::EpocErrorToText(err); sl@0: ERR_PRINTF2(_L("Server not already running, create returned %S"), &errortxt); sl@0: delete theServer; sl@0: CleanupStack::PopAndDestroy(theScheduler); sl@0: return iTestStepResult = EInconclusive; sl@0: } sl@0: sl@0: // setup local logger - this will cause a server session to be created sl@0: // (we can't get a handle to it!) sl@0: CLog* logClient = CLog::NewLC(); sl@0: logClient->OpenLogFileL(); sl@0: sl@0: TInt status = logClient->LogStatus(); sl@0: // this will have retrieved log status from the server - the value is dependent on sl@0: // params passed into TestFramework, but in all cases will be nonzero. this demonstrates sl@0: // that a server session is running sl@0: if(status == 0) sl@0: { sl@0: ERR_PRINTF1(_L("Log status is zero - server session may not be running")); sl@0: currentVerdict = EFail; sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("Log status %d retrieved from server session"), status); sl@0: currentVerdict = EPass; sl@0: } sl@0: sl@0: // cleanup the logger and the scheduler sl@0: CleanupStack::PopAndDestroy(2); // logClient, theScheduler sl@0: sl@0: return iTestStepResult = currentVerdict; sl@0: }