Update contrib.
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // This file contains the test steps for Unit Test Suite 20 : TestFrameworkServer.cpp
21 // Test system includes
22 #include <testframework.h>
24 // Specific includes for this test suite
25 #include "TSU_MmTsthSuite20.h"
27 // Specific includes for these test steps
28 #include "TSU_MmTsth20.h"
29 #include "TestFrameworkServer/TestFrameworkServer.h"
31 // --------------------------------------------
33 // Unit Test Suite 20 : TestFrameworkServer.cpp
34 // Depends on : TestFrameworkClient (running)
35 // Needs : LogFile.cpp, ServerConsole.cpp
39 // 1. verify that a CTestFrameworkServer is running
40 // 2. verify that a CTestFrameworkServerSession is running
42 // (CTestFrameworkServerShutdown is a private utility class)
43 // (TWindow is private and obsolete; will be removed)
45 // NB : to test within the TestFramework, we can't open a new server (it's already
46 // running) - nor can we access the private API's of Server and ServerSession
47 // The tests will validate that the server and session are already running.
50 // --------------------------------------------
53 RTestMmTsthU2001* RTestMmTsthU2001::NewL()
55 RTestMmTsthU2001* self = new(ELeave) RTestMmTsthU2001;
59 // Each test step initialises its own name.
60 RTestMmTsthU2001::RTestMmTsthU2001()
62 iTestStepName = _L("MM-TSTH-U-2001");
66 TVerdict RTestMmTsthU2001::DoTestStepL()
68 INFO_PRINTF1(_L("Unit test for TestFrameworkServer - Server"));
70 // we can't construct a server - it's already running. Attempts to construct
72 // Test :- Check it's running, by trying to construct it again. Trap the leave.
74 TVerdict currentVerdict = EPass;
76 // create and install the active scheduler we need
77 CActiveScheduler* theScheduler = new(ELeave) CActiveScheduler;
78 CleanupStack::PushL(theScheduler);
79 CActiveScheduler::Install(theScheduler);
82 CMmfIpcServer* theServer = NULL;
83 TRAPD(err, theServer = CTestFrameworkServer::NewL());
84 if(err != KErrAlreadyExists)
86 TPtrC errortxt = CLog::EpocErrorToText(err);
87 ERR_PRINTF2(_L("Server not already running, create returned %S"), &errortxt);
89 currentVerdict = EFail;
93 TPtrC errortxt = CLog::EpocErrorToText(err);
94 INFO_PRINTF2(_L("Server already running, create returned %S"), &errortxt);
97 // Cleanup the scheduler
98 CleanupStack::PopAndDestroy(theScheduler);
100 return iTestStepResult = currentVerdict; // should be EPass if we've got here
103 // ------------------------
106 RTestMmTsthU2002* RTestMmTsthU2002::NewL()
108 RTestMmTsthU2002* self = new(ELeave) RTestMmTsthU2002;
112 // Each test step initialises its own name.
113 RTestMmTsthU2002::RTestMmTsthU2002()
115 // store the name of this test case
116 // this is the name that is used by the script file
117 iTestStepName = _L("MM-TSTH-U-2002");
121 TVerdict RTestMmTsthU2002::DoTestStepL()
123 INFO_PRINTF1(_L("Unit test for TestFrameworkServer - Server Session"));
125 TVerdict currentVerdict = EPass;
127 // create and install the active scheduler we need
128 CActiveScheduler* theScheduler = new(ELeave) CActiveScheduler;
129 CleanupStack::PushL(theScheduler);
130 CActiveScheduler::Install(theScheduler);
133 CMmfIpcServer* theServer = NULL;
134 TRAPD(err, theServer = CTestFrameworkServer::NewL());
135 if(err != KErrAlreadyExists)
137 TPtrC errortxt = CLog::EpocErrorToText(err);
138 ERR_PRINTF2(_L("Server not already running, create returned %S"), &errortxt);
140 CleanupStack::PopAndDestroy(theScheduler);
141 return iTestStepResult = EInconclusive;
144 // setup local logger - this will cause a server session to be created
145 // (we can't get a handle to it!)
146 CLog* logClient = CLog::NewLC();
147 logClient->OpenLogFileL();
149 TInt status = logClient->LogStatus();
150 // this will have retrieved log status from the server - the value is dependent on
151 // params passed into TestFramework, but in all cases will be nonzero. this demonstrates
152 // that a server session is running
155 ERR_PRINTF1(_L("Log status is zero - server session may not be running"));
156 currentVerdict = EFail;
160 INFO_PRINTF2(_L("Log status %d retrieved from server session"), status);
161 currentVerdict = EPass;
164 // cleanup the logger and the scheduler
165 CleanupStack::PopAndDestroy(2); // logClient, theScheduler
167 return iTestStepResult = currentVerdict;