0
|
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".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// This file contains the test steps for Unit Test Suite 10 : Log.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
// EPOC includes
|
|
19 |
#include <e32base.h>
|
|
20 |
|
|
21 |
// Test system includes
|
|
22 |
#include <testframework.h>
|
|
23 |
|
|
24 |
// Specific includes for this test suite
|
|
25 |
#include "TSU_MmTsthSuite10.h"
|
|
26 |
|
|
27 |
// Specific includes for these test steps
|
|
28 |
#include "TSU_MmTsth10.h"
|
|
29 |
|
|
30 |
// --------------------------------------------
|
|
31 |
|
|
32 |
// Unit Test Suite 10 : Log.cpp
|
|
33 |
// Depends on : none
|
|
34 |
|
|
35 |
// Tests :-
|
|
36 |
// 1 RTestFrameworkClientSession : check connect
|
|
37 |
// 11 Log : create
|
|
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)
|
|
42 |
|
|
43 |
// ---------------------
|
|
44 |
// RTestMmTsthU1001
|
|
45 |
|
|
46 |
RTestMmTsthU1001* RTestMmTsthU1001::NewL()
|
|
47 |
{
|
|
48 |
RTestMmTsthU1001* self = new(ELeave) RTestMmTsthU1001;
|
|
49 |
return self;
|
|
50 |
}
|
|
51 |
|
|
52 |
// Each test step initialises its own name.
|
|
53 |
RTestMmTsthU1001::RTestMmTsthU1001()
|
|
54 |
{
|
|
55 |
iTestStepName = _L("MM-TSTH-U-1001");
|
|
56 |
}
|
|
57 |
|
|
58 |
// Do the test step.
|
|
59 |
TVerdict RTestMmTsthU1001::DoTestStepL()
|
|
60 |
{
|
|
61 |
INFO_PRINTF1(_L("Unit test for RTestFrameworkServerSession"));
|
|
62 |
|
|
63 |
// Check we can connect to the existing server.
|
|
64 |
// NB - open, write, close, status will be called by Log tests
|
|
65 |
|
|
66 |
TVerdict currentVerdict = EPass;
|
|
67 |
|
|
68 |
TInt ret;
|
|
69 |
RTestFrameworkClientSession testSession;
|
|
70 |
ret = testSession.Connect();
|
|
71 |
if(ret != KErrNone)
|
|
72 |
{
|
|
73 |
ERR_PRINTF2(_L("Could not connect to server, error %d"), ret);
|
|
74 |
return iTestStepResult = EFail;
|
|
75 |
}
|
|
76 |
|
|
77 |
INFO_PRINTF1(_L("Successfully connected to server with a new session"));
|
|
78 |
|
|
79 |
testSession.Close(); // cleanup session
|
|
80 |
return iTestStepResult = currentVerdict; // should be EPass if we've got here
|
|
81 |
}
|
|
82 |
|
|
83 |
// ---------------------
|
|
84 |
// RTestMmTsthU1011
|
|
85 |
|
|
86 |
RTestMmTsthU1011* RTestMmTsthU1011::NewL()
|
|
87 |
{
|
|
88 |
RTestMmTsthU1011* self = new(ELeave) RTestMmTsthU1011;
|
|
89 |
return self;
|
|
90 |
}
|
|
91 |
|
|
92 |
// Each test step initialises its own name.
|
|
93 |
RTestMmTsthU1011::RTestMmTsthU1011()
|
|
94 |
{
|
|
95 |
iTestStepName = _L("MM-TSTH-U-1011");
|
|
96 |
}
|
|
97 |
|
|
98 |
// Do the test step.
|
|
99 |
TVerdict RTestMmTsthU1011::DoTestStepL()
|
|
100 |
{
|
|
101 |
INFO_PRINTF1(_L("Unit test for Log : create"));
|
|
102 |
|
|
103 |
TVerdict currentVerdict = EPass;
|
|
104 |
|
|
105 |
CLog* theLog = NULL;
|
|
106 |
TRAPD(err, theLog = CLog::NewL());
|
|
107 |
if(err != KErrNone)
|
|
108 |
{
|
|
109 |
ERR_PRINTF2(_L("CLog::NewL() left, error code %d"), err);
|
|
110 |
return iTestStepResult = EFail;
|
|
111 |
}
|
|
112 |
|
|
113 |
INFO_PRINTF1(_L("CLog created successfully"));
|
|
114 |
delete theLog;
|
|
115 |
return iTestStepResult = currentVerdict; // should be EPass if we've got here
|
|
116 |
}
|
|
117 |
|
|
118 |
// ---------------------
|
|
119 |
// RTestMmTsthU1012
|
|
120 |
|
|
121 |
RTestMmTsthU1012* RTestMmTsthU1012::NewL()
|
|
122 |
{
|
|
123 |
RTestMmTsthU1012* self = new(ELeave) RTestMmTsthU1012;
|
|
124 |
return self;
|
|
125 |
}
|
|
126 |
|
|
127 |
// Each test step initialises its own name.
|
|
128 |
RTestMmTsthU1012::RTestMmTsthU1012()
|
|
129 |
{
|
|
130 |
iTestStepName = _L("MM-TSTH-U-1012");
|
|
131 |
}
|
|
132 |
|
|
133 |
// Do the test step.
|
|
134 |
TVerdict RTestMmTsthU1012::DoTestStepL()
|
|
135 |
{
|
|
136 |
INFO_PRINTF1(_L("Unit test for Log : open"));
|
|
137 |
|
|
138 |
TVerdict currentVerdict = EPass;
|
|
139 |
|
|
140 |
CLog* theLog = NULL;
|
|
141 |
TRAPD(err, theLog = CLog::NewL());
|
|
142 |
if(err != KErrNone)
|
|
143 |
{
|
|
144 |
ERR_PRINTF2(_L("CLog::NewL() left, error code %d"), err);
|
|
145 |
return iTestStepResult = EInconclusive;
|
|
146 |
}
|
|
147 |
|
|
148 |
// Open the current logfile (it's already open at the server)
|
|
149 |
TRAP(err, theLog->OpenLogFileL());
|
|
150 |
if(err != KErrNone)
|
|
151 |
{
|
|
152 |
ERR_PRINTF2(_L("CLog::OpenLogFileL() left, error code %d"), err);
|
|
153 |
delete theLog;
|
|
154 |
return iTestStepResult = EFail;
|
|
155 |
}
|
|
156 |
|
|
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();
|
|
161 |
delete theLog;
|
|
162 |
theLog = NULL;
|
|
163 |
|
|
164 |
_LIT(KDummyLogName, "DummyLog");
|
|
165 |
TRAP(err, theLog = CLog::NewL());
|
|
166 |
if(err != KErrNone)
|
|
167 |
{
|
|
168 |
ERR_PRINTF2(_L("CLog::NewL() left, error code %d"), err);
|
|
169 |
return iTestStepResult = EInconclusive;
|
|
170 |
}
|
|
171 |
|
|
172 |
TRAP(err, theLog->OpenLogFileL(KDummyLogName, theStatus - 1));
|
|
173 |
if(err != KErrNone)
|
|
174 |
{
|
|
175 |
ERR_PRINTF2(_L("CLog::OpenLogFileL(KDummyLogName) left, error code %d"), err);
|
|
176 |
delete theLog;
|
|
177 |
return iTestStepResult = EFail;
|
|
178 |
}
|
|
179 |
|
|
180 |
TInt theNewStatus = theLog->LogStatus();
|
|
181 |
if(theNewStatus != theStatus)
|
|
182 |
{
|
|
183 |
ERR_PRINTF1(_L("CLog::OpenLogFileL(KDummyLogName) changed log status!"));
|
|
184 |
delete theLog;
|
|
185 |
return iTestStepResult = EFail;
|
|
186 |
}
|
|
187 |
|
|
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
|
|
190 |
|
|
191 |
INFO_PRINTF1(_L("CLog opened existing log file successfully"));
|
|
192 |
delete theLog;
|
|
193 |
return iTestStepResult = currentVerdict; // should be EPass if we've got here
|
|
194 |
}
|
|
195 |
|
|
196 |
// ---------------------
|
|
197 |
// RTestMmTsthU1013
|
|
198 |
|
|
199 |
RTestMmTsthU1013* RTestMmTsthU1013::NewL()
|
|
200 |
{
|
|
201 |
RTestMmTsthU1013* self = new(ELeave) RTestMmTsthU1013;
|
|
202 |
return self;
|
|
203 |
}
|
|
204 |
|
|
205 |
// Each test step initialises its own name.
|
|
206 |
RTestMmTsthU1013::RTestMmTsthU1013()
|
|
207 |
{
|
|
208 |
iTestStepName = _L("MM-TSTH-U-1013");
|
|
209 |
}
|
|
210 |
|
|
211 |
// Do the test step.
|
|
212 |
TVerdict RTestMmTsthU1013::DoTestStepL()
|
|
213 |
{
|
|
214 |
INFO_PRINTF1(_L("Unit test for Log : write format"));
|
|
215 |
|
|
216 |
TVerdict currentVerdict = EPass;
|
|
217 |
|
|
218 |
// any call to LogExtra will test this. if it doesn't crash, consider it passed
|
|
219 |
|
|
220 |
INFO_PRINTF1(_L("Testing WriteFormat..."));
|
|
221 |
|
|
222 |
return iTestStepResult = currentVerdict;
|
|
223 |
}
|
|
224 |
|