|
1 /* |
|
2 * Copyright (c) 2002 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: TestPnPUtil.cpp |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <Stiftestinterface.h> |
|
22 #include "TestPnpUtil.h" |
|
23 #include <SettingServerClient.h> |
|
24 |
|
25 |
|
26 // EXTERNAL DATA STRUCTURES |
|
27 //extern ?external_data; |
|
28 |
|
29 // EXTERNAL FUNCTION PROTOTYPES |
|
30 |
|
31 // CONSTANTS |
|
32 |
|
33 // MACROS |
|
34 //#define ?macro ?macro_def |
|
35 |
|
36 // LOCAL CONSTANTS AND MACROS |
|
37 |
|
38 //#define ?macro_name ?macro_def |
|
39 |
|
40 // MODULE DATA STRUCTURES |
|
41 //enum ?declaration |
|
42 //typedef ?declaration |
|
43 |
|
44 // LOCAL FUNCTION PROTOTYPES |
|
45 |
|
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 // CTestPnpUtil::CTestPnpUtil |
|
77 // C++ default constructor can NOT contain any code, that |
|
78 // might leave. |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 CTestPnpUtil::CTestPnpUtil( |
|
82 CTestModuleIf& aTestModuleIf ): |
|
83 CScriptBase( aTestModuleIf ) |
|
84 { |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CTestPnpUtil::ConstructL |
|
89 // Symbian 2nd phase constructor can leave. |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void CTestPnpUtil::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(KTestPnpUtilLogFileWithTitle, &title); |
|
120 } |
|
121 else |
|
122 { |
|
123 logFileName.Copy(KTestPnpUtilLogFile); |
|
124 } |
|
125 |
|
126 iLog = CStifLogger::NewL( KTestPnpUtilLogPath, |
|
127 logFileName, |
|
128 CStifLogger::ETxt, |
|
129 CStifLogger::EFile, |
|
130 EFalse ); |
|
131 |
|
132 SendTestClassVersion(); |
|
133 |
|
134 |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CTestPnpUtil::NewL |
|
139 // Two-phased constructor. |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 CTestPnpUtil* CTestPnpUtil::NewL( |
|
143 CTestModuleIf& aTestModuleIf ) |
|
144 { |
|
145 CTestPnpUtil* self = new (ELeave) CTestPnpUtil( aTestModuleIf ); |
|
146 |
|
147 CleanupStack::PushL( self ); |
|
148 self->ConstructL(); |
|
149 CleanupStack::Pop(self); |
|
150 |
|
151 return self; |
|
152 |
|
153 } |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CTestPnpUtil::~CTestPnpUtil |
|
156 // Destructor |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 CTestPnpUtil::~CTestPnpUtil() |
|
160 { |
|
161 |
|
162 // Delete resources allocated from test methods |
|
163 Delete(); |
|
164 |
|
165 // Delete logger |
|
166 delete iLog; |
|
167 |
|
168 //delete PnPUtil; |
|
169 |
|
170 |
|
171 |
|
172 } |
|
173 |
|
174 //----------------------------------------------------------------------------- |
|
175 // CTestPnpUtil::SendTestClassVersion |
|
176 // Method used to send version of test class |
|
177 //----------------------------------------------------------------------------- |
|
178 // |
|
179 void CTestPnpUtil::SendTestClassVersion() |
|
180 { |
|
181 TVersion moduleVersion; |
|
182 moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR; |
|
183 moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR; |
|
184 moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD; |
|
185 |
|
186 TFileName moduleName; |
|
187 moduleName = _L("TestPnpUtil.dll"); |
|
188 |
|
189 TBool newVersionOfMethod = ETrue; |
|
190 TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod); |
|
191 } |
|
192 |
|
193 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
194 |
|
195 // ----------------------------------------------------------------------------- |
|
196 // LibEntryL is a polymorphic Dll entry point. |
|
197 // Returns: CScriptBase: New CScriptBase derived object |
|
198 // ----------------------------------------------------------------------------- |
|
199 // |
|
200 EXPORT_C CScriptBase* LibEntryL( |
|
201 CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework |
|
202 { |
|
203 |
|
204 return ( CScriptBase* ) CTestPnpUtil::NewL( aTestModuleIf ); |
|
205 |
|
206 } |
|
207 |
|
208 |
|
209 // End of File |