author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 24 Nov 2009 08:56:33 +0200 | |
changeset 33 | 50974a8b132e |
parent 19 | 989d2f495d90 |
permissions | -rw-r--r-- |
19 | 1 |
/* |
2 |
* Copyright (c) 2002 - 2007 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 the License "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: ?Description |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
// INCLUDE FILES |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
21 |
#include <StifTestInterface.h> |
19 | 22 |
#include "tserviceregistrytest.h" |
23 |
#include <SettingServerClient.h> |
|
24 |
||
25 |
||
26 |
// ============================ MEMBER FUNCTIONS =============================== |
|
27 |
||
28 |
// ----------------------------------------------------------------------------- |
|
29 |
// CIServiceTestModule::CIServiceTestModule |
|
30 |
// C++ default constructor can NOT contain any code, that |
|
31 |
// might leave. |
|
32 |
// ----------------------------------------------------------------------------- |
|
33 |
// |
|
34 |
CIServiceTestModule::CIServiceTestModule( |
|
35 |
CTestModuleIf& aTestModuleIf ): |
|
36 |
CScriptBase( aTestModuleIf ) |
|
37 |
{ |
|
38 |
} |
|
39 |
||
40 |
||
41 |
// ----------------------------------------------------------------------------- |
|
42 |
// CIServiceTestModule::RunMethodL |
|
43 |
// Run specified method. Contains also table of test mothods and their names. |
|
44 |
// ----------------------------------------------------------------------------- |
|
45 |
// |
|
46 |
TInt CIServiceTestModule::RunMethodL(CStifItemParser& aItem) |
|
47 |
{ |
|
48 |
static TStifFunctionInfo const KFunctions[] = |
|
49 |
{ |
|
50 |
// Copy this line for every implemented function. |
|
51 |
// First string is the function name used in TestScripter script file. |
|
52 |
// Second is the actual implementation member function. |
|
53 |
ENTRY("GetMetaDataListL", CIServiceTestModule::GetMetaDataListL), |
|
54 |
ENTRY("LoadProviderTest", CIServiceTestModule::LoadProviderTest), |
|
55 |
ENTRY("GetListTwice", CIServiceTestModule::GetListTwice), |
|
56 |
ENTRY("InvalidCommand", CIServiceTestModule::InvalidCommand), |
|
57 |
ENTRY("CancelInvalidTransID", CIServiceTestModule::CancelInvalidTransID), |
|
58 |
ENTRY("InvalidServiceValue", CIServiceTestModule::InvalidServiceValue), |
|
59 |
ENTRY("InvalidInterfaceValue", CIServiceTestModule::InvalidInterfaceValue), |
|
60 |
ENTRY("InvalidMinVerValue", CIServiceTestModule::InvalidMinVerValue), |
|
61 |
ENTRY("InvalidMaxVerValue", CIServiceTestModule::InvalidMaxVerValue), |
|
62 |
ENTRY("InvalidFilterValue", CIServiceTestModule::InvalidFilterValue), |
|
63 |
}; |
|
64 |
const TInt count = sizeof(KFunctions)/ |
|
65 |
sizeof(TStifFunctionInfo); |
|
66 |
return RunInternalL(KFunctions, count, aItem); |
|
67 |
} |
|
68 |
// ----------------------------------------------------------------------------- |
|
69 |
// CIServiceTestModule::ConstructL |
|
70 |
// Symbian 2nd phase constructor can leave. |
|
71 |
// ----------------------------------------------------------------------------- |
|
72 |
// |
|
73 |
void CIServiceTestModule::ConstructL() |
|
74 |
{ |
|
75 |
//Read logger settings to check whether test case name is to be |
|
76 |
//appended to log file name. |
|
77 |
RSettingServer settingServer; |
|
78 |
TInt ret = settingServer.Connect(); |
|
79 |
if(ret != KErrNone) |
|
80 |
{ |
|
81 |
User::Leave(ret); |
|
82 |
} |
|
83 |
// Struct to StifLogger settigs. |
|
84 |
TLoggerSettings loggerSettings; |
|
85 |
// Parse StifLogger defaults from STIF initialization file. |
|
86 |
ret = settingServer.GetLoggerSettings(loggerSettings); |
|
87 |
if(ret != KErrNone) |
|
88 |
{ |
|
89 |
User::Leave(ret); |
|
90 |
} |
|
91 |
// Close Setting server session |
|
92 |
settingServer.Close(); |
|
93 |
||
94 |
TFileName logFileName; |
|
95 |
||
96 |
if(loggerSettings.iAddTestCaseTitle) |
|
97 |
{ |
|
98 |
TName title; |
|
99 |
TestModuleIf().GetTestCaseTitleL(title); |
|
100 |
logFileName.Format(KIServiceTestModuleLogFileWithTitle, &title); |
|
101 |
} |
|
102 |
else |
|
103 |
{ |
|
104 |
logFileName.Copy(KIServiceTestModuleLogFile); |
|
105 |
} |
|
106 |
||
107 |
iLog = CStifLogger::NewL( KIServiceTestModuleLogPath, |
|
108 |
logFileName, |
|
109 |
CStifLogger::ETxt, |
|
110 |
CStifLogger::EFile, |
|
111 |
EFalse ); |
|
112 |
SendTestClassVersion(); |
|
113 |
||
114 |
LoadServiceRegistry(); |
|
115 |
} |
|
116 |
||
117 |
// ----------------------------------------------------------------------------- |
|
118 |
// CIServiceTestModule::NewL |
|
119 |
// Two-phased constructor. |
|
120 |
// ----------------------------------------------------------------------------- |
|
121 |
// |
|
122 |
CIServiceTestModule* CIServiceTestModule::NewL( |
|
123 |
CTestModuleIf& aTestModuleIf ) |
|
124 |
{ |
|
125 |
CIServiceTestModule* self = new (ELeave) CIServiceTestModule( aTestModuleIf ); |
|
126 |
||
127 |
CleanupStack::PushL( self ); |
|
128 |
self->ConstructL(); |
|
129 |
CleanupStack::Pop(); |
|
130 |
||
131 |
return self; |
|
132 |
||
133 |
} |
|
134 |
||
135 |
// Destructor |
|
136 |
CIServiceTestModule::~CIServiceTestModule() |
|
137 |
{ |
|
138 |
// Delete logger |
|
139 |
delete iLog; |
|
140 |
||
141 |
} |
|
142 |
||
143 |
||
144 |
void CIServiceTestModule::LoadServiceRegistry() |
|
145 |
{ |
|
146 |
TInt pos = 0; |
|
147 |
||
148 |
iServiceHandler = CLiwServiceHandler::NewL(); |
|
149 |
||
150 |
iInparams = &(iServiceHandler->InParamListL()); |
|
151 |
iOutparams = &(iServiceHandler->OutParamListL()); |
|
152 |
||
153 |
iCriteria = CLiwCriteriaItem::NewL( 1, _L8("IService"), _L8("Service.ServiceRegistry") ); |
|
154 |
iCriteria->SetServiceClass(TUid::Uid( KLiwClassBase )); |
|
155 |
||
156 |
iCriteriaArray.AppendL( iCriteria ); |
|
157 |
iServiceHandler->AttachL( iCriteriaArray ); |
|
158 |
||
159 |
iServiceHandler->ExecuteServiceCmdL( *iCriteria, *iInparams, *iOutparams ); |
|
160 |
||
161 |
iOutparams->FindFirst( pos, _L8("IService") ); |
|
162 |
if(pos != KErrNotFound) |
|
163 |
{ |
|
164 |
//LogMessage(_L8("Service Loaded\n")); |
|
165 |
iIface = ( *iOutparams )[pos].Value().AsInterface(); |
|
166 |
} |
|
167 |
else |
|
168 |
{ |
|
169 |
//LogMessage(_L8("Service Not found\n")); |
|
170 |
} |
|
171 |
if( iInparams ) |
|
172 |
{ |
|
173 |
iInparams->Reset(); |
|
174 |
} |
|
175 |
if( iOutparams ) |
|
176 |
{ |
|
177 |
iOutparams->Reset(); |
|
178 |
} |
|
179 |
if( iCriteria ) |
|
180 |
{ |
|
181 |
delete iCriteria; |
|
182 |
iCriteria = NULL; |
|
183 |
} |
|
184 |
} |
|
185 |
//----------------------------------------------------------------------------- |
|
186 |
// CIServiceTestModule::SendTestClassVersion |
|
187 |
// Method used to send version of test class |
|
188 |
//----------------------------------------------------------------------------- |
|
189 |
// |
|
190 |
void CIServiceTestModule::SendTestClassVersion() |
|
191 |
{ |
|
192 |
TVersion moduleVersion; |
|
193 |
moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR; |
|
194 |
moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR; |
|
195 |
moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD; |
|
196 |
||
197 |
TFileName moduleName; |
|
198 |
moduleName = _L("IServiceTestModule.dll"); |
|
199 |
||
200 |
TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName); |
|
201 |
} |
|
202 |
||
203 |
// ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
204 |
||
205 |
// ----------------------------------------------------------------------------- |
|
206 |
// LibEntryL is a polymorphic Dll entry point. |
|
207 |
// Returns: CScriptBase: New CScriptBase derived object |
|
208 |
// ----------------------------------------------------------------------------- |
|
209 |
// |
|
210 |
EXPORT_C CScriptBase* LibEntryL( |
|
211 |
CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework |
|
212 |
{ |
|
213 |
||
214 |
return ( CScriptBase* ) CIServiceTestModule::NewL( aTestModuleIf ); |
|
215 |
||
216 |
} |
|
217 |
||
218 |
||
219 |
// End of File |