|
1 /* |
|
2 * Copyright (c) 2010 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: This file contains testclass implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <StifTestInterface.h> |
|
20 #include "DefaultFolderRFSPluginTestModule.h" |
|
21 #include <SettingServerClient.h> |
|
22 #include <rfsplugin.h> |
|
23 |
|
24 // EXTERNAL DATA STRUCTURES |
|
25 //extern ?external_data; |
|
26 |
|
27 // EXTERNAL FUNCTION PROTOTYPES |
|
28 //extern ?external_function( ?arg_type,?arg_type ); |
|
29 |
|
30 // CONSTANTS |
|
31 //const ?type ?constant_var = ?constant; |
|
32 |
|
33 // MACROS |
|
34 //#define ?macro ?macro_def |
|
35 |
|
36 // LOCAL CONSTANTS AND MACROS |
|
37 //const ?type ?constant_var = ?constant; |
|
38 //#define ?macro_name ?macro_def |
|
39 |
|
40 // MODULE DATA STRUCTURES |
|
41 //enum ?declaration |
|
42 //typedef ?declaration |
|
43 |
|
44 // LOCAL FUNCTION PROTOTYPES |
|
45 //?type ?function_name( ?arg_type, ?arg_type ); |
|
46 |
|
47 // FORWARD DECLARATIONS |
|
48 //class ?FORWARD_CLASSNAME; |
|
49 |
|
50 // ============================= LOCAL FUNCTIONS =============================== |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // ?function_name ?description. |
|
54 // ?description |
|
55 // Returns: ?value_1: ?description |
|
56 // ?value_n: ?description_line1 |
|
57 // ?description_line2 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 /* |
|
61 ?type ?function_name( |
|
62 ?arg_type arg, // ?description |
|
63 ?arg_type arg) // ?description |
|
64 { |
|
65 |
|
66 ?code // ?comment |
|
67 |
|
68 // ?comment |
|
69 ?code |
|
70 } |
|
71 */ |
|
72 |
|
73 // ============================ MEMBER FUNCTIONS =============================== |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CDefaultFolderRFSPluginTestModule::CDefaultFolderRFSPluginTestModule |
|
77 // C++ default constructor can NOT contain any code, that |
|
78 // might leave. |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 CDefaultFolderRFSPluginTestModule::CDefaultFolderRFSPluginTestModule( |
|
82 CTestModuleIf& aTestModuleIf ): |
|
83 CScriptBase( aTestModuleIf ) |
|
84 { |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CDefaultFolderRFSPluginTestModule::ConstructL |
|
89 // Symbian 2nd phase constructor can leave. |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void CDefaultFolderRFSPluginTestModule::ConstructL() |
|
93 { |
|
94 //Read logger settings to check whether test case name is to be |
|
95 //appended to log file name. |
|
96 RSettingServer settingServer; |
|
97 TInt ret = settingServer.Connect(); |
|
98 if(ret != KErrNone) |
|
99 { |
|
100 User::Leave(ret); |
|
101 } |
|
102 // Struct to StifLogger settigs. |
|
103 TLoggerSettings loggerSettings; |
|
104 // Parse StifLogger defaults from STIF initialization file. |
|
105 ret = settingServer.GetLoggerSettings(loggerSettings); |
|
106 if(ret != KErrNone) |
|
107 { |
|
108 User::Leave(ret); |
|
109 } |
|
110 // Close Setting server session |
|
111 settingServer.Close(); |
|
112 |
|
113 TFileName logFileName; |
|
114 |
|
115 if(loggerSettings.iAddTestCaseTitle) |
|
116 { |
|
117 TName title; |
|
118 TestModuleIf().GetTestCaseTitleL(title); |
|
119 logFileName.Format(KDefaultFolderRFSPluginTestModuleLogFileWithTitle, &title); |
|
120 } |
|
121 else |
|
122 { |
|
123 logFileName.Copy(KDefaultFolderRFSPluginTestModuleLogFile); |
|
124 } |
|
125 |
|
126 iLog = CStifLogger::NewL( KDefaultFolderRFSPluginTestModuleLogPath, |
|
127 logFileName, |
|
128 CStifLogger::ETxt, |
|
129 CStifLogger::EFile, |
|
130 EFalse ); |
|
131 |
|
132 SendTestClassVersion(); |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CDefaultFolderRFSPluginTestModule::NewL |
|
137 // Two-phased constructor. |
|
138 // ----------------------------------------------------------------------------- |
|
139 // |
|
140 CDefaultFolderRFSPluginTestModule* CDefaultFolderRFSPluginTestModule::NewL( |
|
141 CTestModuleIf& aTestModuleIf ) |
|
142 { |
|
143 CDefaultFolderRFSPluginTestModule* self = new (ELeave) CDefaultFolderRFSPluginTestModule( aTestModuleIf ); |
|
144 |
|
145 CleanupStack::PushL( self ); |
|
146 self->ConstructL(); |
|
147 CleanupStack::Pop(); |
|
148 |
|
149 return self; |
|
150 |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CDefaultFolderRFSPluginTestModule::Delete |
|
155 // Delete here all resources allocated and opened from test methods. |
|
156 // Called from destructor. |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 void CDefaultFolderRFSPluginTestModule::Delete() |
|
160 { |
|
161 |
|
162 } |
|
163 |
|
164 // Destructor |
|
165 CDefaultFolderRFSPluginTestModule::~CDefaultFolderRFSPluginTestModule() |
|
166 { |
|
167 // Delete resources allocated from test methods |
|
168 Delete(); |
|
169 |
|
170 delete iPlugin; |
|
171 REComSession::FinalClose(); |
|
172 |
|
173 // Delete logger |
|
174 delete iLog; |
|
175 |
|
176 } |
|
177 |
|
178 //----------------------------------------------------------------------------- |
|
179 // CDefaultFolderRFSPluginTestModule::SendTestClassVersion |
|
180 // Method used to send version of test class |
|
181 //----------------------------------------------------------------------------- |
|
182 // |
|
183 void CDefaultFolderRFSPluginTestModule::SendTestClassVersion() |
|
184 { |
|
185 TVersion moduleVersion; |
|
186 moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR; |
|
187 moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR; |
|
188 moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD; |
|
189 |
|
190 TFileName moduleName; |
|
191 moduleName = _L("DefaultFolderRFSPluginTestModule.dll"); |
|
192 |
|
193 TBool newVersionOfMethod = ETrue; |
|
194 TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod); |
|
195 } |
|
196 |
|
197 // ----------------------------------------------------------------------------- |
|
198 // CDefaultFolderRFSPluginTestModule::RunMethodL |
|
199 // Run specified method. Contains also table of test mothods and their names. |
|
200 // ----------------------------------------------------------------------------- |
|
201 // |
|
202 TInt CDefaultFolderRFSPluginTestModule::RunMethodL( |
|
203 CStifItemParser& aItem ) |
|
204 { |
|
205 |
|
206 static TStifFunctionInfo const KFunctions[] = |
|
207 { |
|
208 // Copy this line for every implemented function. |
|
209 // First string is the function name used in TestScripter script file. |
|
210 // Second is the actual implementation member function. |
|
211 ENTRY( "CreatePlugin", CDefaultFolderRFSPluginTestModule::CreatePlugin ), |
|
212 ENTRY( "DestroyPlugin", CDefaultFolderRFSPluginTestModule::DestroyPlugin ), |
|
213 ENTRY( "RestoreFactorySettings", CDefaultFolderRFSPluginTestModule::RestoreFactorySettings ), |
|
214 ENTRY( "GetScript", CDefaultFolderRFSPluginTestModule::GetScript ), |
|
215 ENTRY( "ExecuteCustomCommand", CDefaultFolderRFSPluginTestModule::ExecuteCustomCommand ), |
|
216 //ADD NEW ENTRY HERE |
|
217 // [test cases entries] - Do not remove |
|
218 |
|
219 }; |
|
220 |
|
221 const TInt count = sizeof( KFunctions ) / |
|
222 sizeof( TStifFunctionInfo ); |
|
223 |
|
224 return RunInternalL( KFunctions, count, aItem ); |
|
225 |
|
226 } |
|
227 |
|
228 TInt CDefaultFolderRFSPluginTestModule::CreatePlugin(CStifItemParser& /*aItem */) |
|
229 { |
|
230 STIF_ASSERT_NOT_LEAVES(iPlugin = CRFSPlugin::NewL( TUid::Uid( 0x2000F8AF ) ) ); |
|
231 STIF_ASSERT_NOT_NULL( iPlugin ); |
|
232 |
|
233 return KErrNone; |
|
234 |
|
235 } |
|
236 TInt CDefaultFolderRFSPluginTestModule::DestroyPlugin(CStifItemParser& /*aItem*/ ) |
|
237 { |
|
238 delete iPlugin; |
|
239 iPlugin = NULL; |
|
240 |
|
241 return KErrNone; |
|
242 } |
|
243 |
|
244 TInt CDefaultFolderRFSPluginTestModule::RestoreFactorySettings(CStifItemParser& /*aItem*/ ) |
|
245 { |
|
246 STIF_ASSERT_NOT_LEAVES( iPlugin->RestoreFactorySettingsL( ENormalRfs ) ); |
|
247 STIF_ASSERT_NOT_LEAVES( iPlugin->RestoreFactorySettingsL( EDeepRfs ) ); |
|
248 STIF_ASSERT_NOT_LEAVES( iPlugin->RestoreFactorySettingsL( EInitRfs ) ); |
|
249 STIF_ASSERT_NOT_LEAVES( iPlugin->RestoreFactorySettingsL( static_cast<TRfsReason>( 100 ) ) ); |
|
250 return KErrNone; |
|
251 } |
|
252 |
|
253 TInt CDefaultFolderRFSPluginTestModule::GetScript(CStifItemParser& /*aItem*/ ) |
|
254 { |
|
255 TBuf<256> path; |
|
256 //TBuf<256> buf; |
|
257 //buf.Copy(KExpectedScript); |
|
258 STIF_ASSERT_NOT_LEAVES( iPlugin->GetScriptL( ENormalRfs, path ) ); |
|
259 RDebug::Print(_L( "Script = '%S'"), &path ); |
|
260 //STIF_ASSERT_EQUALS( buf, path ); |
|
261 |
|
262 STIF_ASSERT_NOT_LEAVES( iPlugin->GetScriptL( EDeepRfs, path ) ); |
|
263 RDebug::Print(_L( "Script = '%S'"), &path ); |
|
264 //STIF_ASSERT_EQUALS( buf, path ); |
|
265 |
|
266 STIF_ASSERT_NOT_LEAVES( iPlugin->GetScriptL( EInitRfs, path ) ); |
|
267 RDebug::Print(_L( "Script = '%S'"), &path ); |
|
268 //STIF_ASSERT_EQUALS( buf, path ); |
|
269 |
|
270 STIF_ASSERT_NOT_LEAVES( iPlugin->GetScriptL( static_cast<TRfsReason>( 100 ), path ) ); |
|
271 RDebug::Print(_L( "Script = '%S'"), &path ); |
|
272 //STIF_ASSERT_EQUALS( buf, path ); |
|
273 |
|
274 return KErrNone; |
|
275 } |
|
276 |
|
277 TInt CDefaultFolderRFSPluginTestModule::ExecuteCustomCommand(CStifItemParser& /*aItem*/ ) |
|
278 { |
|
279 TBuf<256> param1( KNullDesC ); |
|
280 STIF_ASSERT_NOT_LEAVES( iPlugin->ExecuteCustomCommandL( ENormalRfs, param1 ) ); |
|
281 TBuf<1> param2( KNullDesC ); |
|
282 STIF_ASSERT_NOT_LEAVES( iPlugin->ExecuteCustomCommandL( EDeepRfs, param2 ) ); |
|
283 STIF_ASSERT_NOT_LEAVES( iPlugin->ExecuteCustomCommandL( EInitRfs, param2 ) ); |
|
284 STIF_ASSERT_NOT_LEAVES( iPlugin->ExecuteCustomCommandL( static_cast<TRfsReason>( 100 ), param2 ) ); |
|
285 return KErrNone; |
|
286 } |
|
287 |
|
288 |
|
289 |
|
290 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
291 |
|
292 // ----------------------------------------------------------------------------- |
|
293 // LibEntryL is a polymorphic Dll entry point. |
|
294 // Returns: CScriptBase: New CScriptBase derived object |
|
295 // ----------------------------------------------------------------------------- |
|
296 // |
|
297 EXPORT_C CScriptBase* LibEntryL( |
|
298 CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework |
|
299 { |
|
300 |
|
301 return ( CScriptBase* ) CDefaultFolderRFSPluginTestModule::NewL( aTestModuleIf ); |
|
302 |
|
303 } |
|
304 |
|
305 // End of File |