First public contribution.
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 10 : Log.cpp
21 // Test system includes
22 #include <testframework.h>
24 // Specific includes for this test suite
25 #include "TSU_MmTsthSuite10.h"
27 // Specific includes for these test steps
28 #include "TSU_MmTsth10.h"
30 // --------------------------------------------
32 // Unit Test Suite 10 : Log.cpp
36 // 1 RTestFrameworkClientSession : check connect
38 // 12 Log : open log file (existing)
39 // 13 Log : write format - no test specified as this is called every time the INFO_PRINTF or ERR_PRINTF
40 // macro is called by the framework or suite(s)
41 // 14 Log : status (incorporated in test 12)
43 // ---------------------
46 RTestMmTsthU1001* RTestMmTsthU1001::NewL()
48 RTestMmTsthU1001* self = new(ELeave) RTestMmTsthU1001;
52 // Each test step initialises its own name.
53 RTestMmTsthU1001::RTestMmTsthU1001()
55 iTestStepName = _L("MM-TSTH-U-1001");
59 TVerdict RTestMmTsthU1001::DoTestStepL()
61 INFO_PRINTF1(_L("Unit test for RTestFrameworkServerSession"));
63 // Check we can connect to the existing server.
64 // NB - open, write, close, status will be called by Log tests
66 TVerdict currentVerdict = EPass;
69 RTestFrameworkClientSession testSession;
70 ret = testSession.Connect();
73 ERR_PRINTF2(_L("Could not connect to server, error %d"), ret);
74 return iTestStepResult = EFail;
77 INFO_PRINTF1(_L("Successfully connected to server with a new session"));
79 testSession.Close(); // cleanup session
80 return iTestStepResult = currentVerdict; // should be EPass if we've got here
83 // ---------------------
86 RTestMmTsthU1011* RTestMmTsthU1011::NewL()
88 RTestMmTsthU1011* self = new(ELeave) RTestMmTsthU1011;
92 // Each test step initialises its own name.
93 RTestMmTsthU1011::RTestMmTsthU1011()
95 iTestStepName = _L("MM-TSTH-U-1011");
99 TVerdict RTestMmTsthU1011::DoTestStepL()
101 INFO_PRINTF1(_L("Unit test for Log : create"));
103 TVerdict currentVerdict = EPass;
106 TRAPD(err, theLog = CLog::NewL());
109 ERR_PRINTF2(_L("CLog::NewL() left, error code %d"), err);
110 return iTestStepResult = EFail;
113 INFO_PRINTF1(_L("CLog created successfully"));
115 return iTestStepResult = currentVerdict; // should be EPass if we've got here
118 // ---------------------
121 RTestMmTsthU1012* RTestMmTsthU1012::NewL()
123 RTestMmTsthU1012* self = new(ELeave) RTestMmTsthU1012;
127 // Each test step initialises its own name.
128 RTestMmTsthU1012::RTestMmTsthU1012()
130 iTestStepName = _L("MM-TSTH-U-1012");
134 TVerdict RTestMmTsthU1012::DoTestStepL()
136 INFO_PRINTF1(_L("Unit test for Log : open"));
138 TVerdict currentVerdict = EPass;
141 TRAPD(err, theLog = CLog::NewL());
144 ERR_PRINTF2(_L("CLog::NewL() left, error code %d"), err);
145 return iTestStepResult = EInconclusive;
148 // Open the current logfile (it's already open at the server)
149 TRAP(err, theLog->OpenLogFileL());
152 ERR_PRINTF2(_L("CLog::OpenLogFileL() left, error code %d"), err);
154 return iTestStepResult = EFail;
157 // Attempt to open a new log file. This will complete without opening the log file and
158 // without disturbing the server; we can
159 // ascertain this by checking the log status, which will be unchanged.
160 TInt theStatus = theLog->LogStatus();
164 _LIT(KDummyLogName, "DummyLog");
165 TRAP(err, theLog = CLog::NewL());
168 ERR_PRINTF2(_L("CLog::NewL() left, error code %d"), err);
169 return iTestStepResult = EInconclusive;
172 TRAP(err, theLog->OpenLogFileL(KDummyLogName, theStatus - 1));
175 ERR_PRINTF2(_L("CLog::OpenLogFileL(KDummyLogName) left, error code %d"), err);
177 return iTestStepResult = EFail;
180 TInt theNewStatus = theLog->LogStatus();
181 if(theNewStatus != theStatus)
183 ERR_PRINTF1(_L("CLog::OpenLogFileL(KDummyLogName) changed log status!"));
185 return iTestStepResult = EFail;
188 // NB no test for CloseLogFileL - as this acts at the server and is something we only ever
189 // want to do at the end of the TestFramework run
191 INFO_PRINTF1(_L("CLog opened existing log file successfully"));
193 return iTestStepResult = currentVerdict; // should be EPass if we've got here
196 // ---------------------
199 RTestMmTsthU1013* RTestMmTsthU1013::NewL()
201 RTestMmTsthU1013* self = new(ELeave) RTestMmTsthU1013;
205 // Each test step initialises its own name.
206 RTestMmTsthU1013::RTestMmTsthU1013()
208 iTestStepName = _L("MM-TSTH-U-1013");
212 TVerdict RTestMmTsthU1013::DoTestStepL()
214 INFO_PRINTF1(_L("Unit test for Log : write format"));
216 TVerdict currentVerdict = EPass;
218 // any call to LogExtra will test this. if it doesn't crash, consider it passed
220 INFO_PRINTF1(_L("Testing WriteFormat..."));
222 return iTestStepResult = currentVerdict;