2
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
/**
|
|
21 |
@file CTEFLogger.cpp
|
|
22 |
*/
|
|
23 |
|
|
24 |
#include "cteflogger.h"
|
|
25 |
#include "tefunit.h"
|
|
26 |
|
|
27 |
void CTEFLogger::LogResult( const TDesC& aTestName, TInt aResult, CTestExecuteLogger& aLogger )
|
|
28 |
/**
|
|
29 |
* LogResult
|
|
30 |
*
|
|
31 |
* @param aTestName - Name of the test case
|
|
32 |
* @param aResult - Result of the test
|
|
33 |
* @param aLogger - The logger
|
|
34 |
*/
|
|
35 |
{
|
|
36 |
// Log the test case result in the correct colour
|
|
37 |
HBufC* resultBuffer = HBufC::NewLC(KMaxTestExecuteCommandLength*3);
|
|
38 |
TPtr ptr(resultBuffer->Des());
|
|
39 |
|
|
40 |
TFullName serverName;
|
|
41 |
TFindServer htmServerFinder( KTestExecuteLogServerName );
|
|
42 |
TInt errCode = htmServerFinder.Next( serverName );
|
|
43 |
|
|
44 |
if ( errCode != KErrNotFound )
|
|
45 |
{
|
|
46 |
// Set the result text colour
|
|
47 |
switch(aResult)
|
|
48 |
{
|
|
49 |
case KErrTEFUnitPass:
|
|
50 |
{
|
|
51 |
ptr.Append(KTEFFontGreen);
|
|
52 |
}
|
|
53 |
break;
|
|
54 |
case KErrTEFUnitFail:
|
|
55 |
{
|
|
56 |
ptr.Append(KTEFFontRed);
|
|
57 |
}
|
|
58 |
break;
|
|
59 |
default:
|
|
60 |
{
|
|
61 |
ptr.Append(KTEFFontBlue);
|
|
62 |
}
|
|
63 |
break;
|
|
64 |
}
|
|
65 |
|
|
66 |
// Append the test case name
|
|
67 |
ptr.AppendFormat( _L("Test Case") );
|
|
68 |
ptr.Append(KTEFSpace);
|
|
69 |
ptr.Append( aTestName );
|
|
70 |
ptr.Append(KTEFSpace);
|
|
71 |
ptr.AppendFormat( KTEFResultTag );
|
|
72 |
ptr.Append(KTEFSpace);
|
|
73 |
ptr.Append( KTEFEquals );
|
|
74 |
ptr.Append(KTEFSpace);
|
|
75 |
|
|
76 |
// Append the test result
|
|
77 |
switch(aResult)
|
|
78 |
{
|
|
79 |
case KErrTEFUnitPass:
|
|
80 |
{
|
|
81 |
ptr.Append(KTEFResultPass);
|
|
82 |
}
|
|
83 |
break;
|
|
84 |
case KErrTEFUnitFail:
|
|
85 |
{
|
|
86 |
ptr.Append(KTEFResultFail);
|
|
87 |
}
|
|
88 |
break;
|
|
89 |
case KErrTEFUnitInconclusive:
|
|
90 |
{
|
|
91 |
ptr.Append(KTEFResultInconclusive);
|
|
92 |
}
|
|
93 |
break;
|
|
94 |
case KErrTEFUnitAbort:
|
|
95 |
{
|
|
96 |
ptr.Append(KTEFResultAbort);
|
|
97 |
}
|
|
98 |
break;
|
|
99 |
default:
|
|
100 |
{
|
|
101 |
ptr.Append(KTEFResultUnknown);
|
|
102 |
}
|
|
103 |
break;
|
|
104 |
}
|
|
105 |
|
|
106 |
ptr.Append(KTEFSpace);
|
|
107 |
ptr.Append(KTEFFontEnd);
|
|
108 |
|
|
109 |
HBufC8* resultBuffer8 = HBufC8::NewLC(ptr.Length()+2);
|
|
110 |
TPtr8 ptr8(resultBuffer8->Des());
|
|
111 |
ptr8.Copy(ptr);
|
|
112 |
|
|
113 |
// Write to the log file
|
|
114 |
aLogger.HtmlLogger().Write(ptr8);
|
|
115 |
|
|
116 |
CleanupStack::PopAndDestroy(resultBuffer8);
|
|
117 |
}
|
|
118 |
|
|
119 |
TFindServer xmlServerFinder( KFileLogrerServerName );
|
|
120 |
errCode = xmlServerFinder.Next( serverName );
|
|
121 |
|
|
122 |
if ( errCode != KErrNotFound )
|
|
123 |
{
|
|
124 |
// Append the test case name
|
|
125 |
ptr.AppendFormat( _L("Test Case") );
|
|
126 |
ptr.Append(KTEFSpace);
|
|
127 |
ptr.Append( aTestName );
|
|
128 |
ptr.Append(KTEFSpace);
|
|
129 |
ptr.AppendFormat( KTEFResultTag );
|
|
130 |
ptr.Append(KTEFSpace);
|
|
131 |
ptr.Append( KTEFEquals );
|
|
132 |
ptr.Append(KTEFSpace);
|
|
133 |
|
|
134 |
// Append the test result
|
|
135 |
switch(aResult)
|
|
136 |
{
|
|
137 |
case KErrTEFUnitPass:
|
|
138 |
{
|
|
139 |
ptr.Append(KTEFResultPass);
|
|
140 |
}
|
|
141 |
break;
|
|
142 |
case KErrTEFUnitFail:
|
|
143 |
{
|
|
144 |
ptr.Append(KTEFResultFail);
|
|
145 |
}
|
|
146 |
break;
|
|
147 |
case KErrTEFUnitInconclusive:
|
|
148 |
{
|
|
149 |
ptr.Append(KTEFResultInconclusive);
|
|
150 |
}
|
|
151 |
break;
|
|
152 |
case KErrTEFUnitAbort:
|
|
153 |
{
|
|
154 |
ptr.Append(KTEFResultAbort);
|
|
155 |
}
|
|
156 |
break;
|
|
157 |
default:
|
|
158 |
{
|
|
159 |
ptr.Append(KTEFResultUnknown);
|
|
160 |
}
|
|
161 |
break;
|
|
162 |
}
|
|
163 |
aLogger.XmlLogger().Log(((TText8*)__FILE__), __LINE__, RFileFlogger::ESevrTEFUnit, ptr);
|
|
164 |
}
|
|
165 |
|
|
166 |
CleanupStack::PopAndDestroy(resultBuffer);
|
|
167 |
}
|
|
168 |
|
|
169 |
|
|
170 |
void CTEFLogger::LogTraverse( const TDesC& aSuiteName, CTestExecuteLogger& aLogger )
|
|
171 |
/**
|
|
172 |
* LogTraverse
|
|
173 |
*
|
|
174 |
* @param aSuiteName - Name of the test suite
|
|
175 |
* @param aLogger - The logger
|
|
176 |
*/
|
|
177 |
{
|
|
178 |
// Log the test case result in the correct colour
|
|
179 |
HBufC* resultBuffer = HBufC::NewLC(KMaxTestExecuteCommandLength*3);
|
|
180 |
TPtr ptr(resultBuffer->Des());
|
|
181 |
|
|
182 |
TFullName serverName;
|
|
183 |
TFindServer htmServerFinder( KTestExecuteLogServerName );
|
|
184 |
TInt errCode = htmServerFinder.Next( serverName );
|
|
185 |
|
|
186 |
if ( errCode != KErrNotFound )
|
|
187 |
{
|
|
188 |
// Always blue for suite traversal
|
|
189 |
ptr.Append(KTEFFontLightBlue);
|
|
190 |
|
|
191 |
// Append the test case name
|
|
192 |
ptr.AppendFormat( _L("Entering Test Suite:") );
|
|
193 |
ptr.Append(KTEFSpace);
|
|
194 |
ptr.Append( aSuiteName );
|
|
195 |
ptr.Append(KTEFSpace);
|
|
196 |
ptr.Append(KTEFFontEnd);
|
|
197 |
|
|
198 |
HBufC8* resultBuffer8 = HBufC8::NewLC(ptr.Length()+2);
|
|
199 |
TPtr8 ptr8(resultBuffer8->Des());
|
|
200 |
ptr8.Copy(ptr);
|
|
201 |
|
|
202 |
// Write to the log file
|
|
203 |
aLogger.HtmlLogger().Write(ptr8);
|
|
204 |
|
|
205 |
CleanupStack::PopAndDestroy(resultBuffer8);
|
|
206 |
}
|
|
207 |
|
|
208 |
TFindServer xmlServerFinder( KFileLogrerServerName );
|
|
209 |
errCode = xmlServerFinder.Next( serverName );
|
|
210 |
|
|
211 |
if ( errCode != KErrNotFound )
|
|
212 |
{
|
|
213 |
// Append the test case name
|
|
214 |
ptr.AppendFormat( _L("Entering Test Suite:") );
|
|
215 |
ptr.Append(KTEFSpace);
|
|
216 |
ptr.Append( aSuiteName );
|
|
217 |
ptr.Append(KTEFSpace);
|
|
218 |
|
|
219 |
aLogger.XmlLogger().Log(((TText8*)__FILE__), __LINE__, RFileFlogger::ESevrTEFUnit, ptr);
|
|
220 |
}
|
|
221 |
CleanupStack::PopAndDestroy(resultBuffer);
|
|
222 |
}
|