|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <Stiftestinterface.h> |
|
23 #include "UsbBasicPersonalityTest.h" |
|
24 #include <SettingServerClient.h> |
|
25 #include <ecom/ecom.h> |
|
26 |
|
27 // EXTERNAL DATA STRUCTURES |
|
28 //extern ?external_data; |
|
29 |
|
30 // EXTERNAL FUNCTION PROTOTYPES |
|
31 //extern ?external_function( ?arg_type,?arg_type ); |
|
32 |
|
33 // CONSTANTS |
|
34 //const ?type ?constant_var = ?constant; |
|
35 |
|
36 // MACROS |
|
37 //#define ?macro ?macro_def |
|
38 |
|
39 // LOCAL CONSTANTS AND MACROS |
|
40 //const ?type ?constant_var = ?constant; |
|
41 //#define ?macro_name ?macro_def |
|
42 |
|
43 // MODULE DATA STRUCTURES |
|
44 //enum ?declaration |
|
45 //typedef ?declaration |
|
46 |
|
47 // LOCAL FUNCTION PROTOTYPES |
|
48 //?type ?function_name( ?arg_type, ?arg_type ); |
|
49 |
|
50 // FORWARD DECLARATIONS |
|
51 //class ?FORWARD_CLASSNAME; |
|
52 |
|
53 // ============================= LOCAL FUNCTIONS =============================== |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // ?function_name ?description. |
|
57 // ?description |
|
58 // Returns: ?value_1: ?description |
|
59 // ?value_n: ?description_line1 |
|
60 // ?description_line2 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 /* |
|
64 ?type ?function_name( |
|
65 ?arg_type arg, // ?description |
|
66 ?arg_type arg) // ?description |
|
67 { |
|
68 |
|
69 ?code // ?comment |
|
70 |
|
71 // ?comment |
|
72 ?code |
|
73 } |
|
74 */ |
|
75 |
|
76 // ============================ MEMBER FUNCTIONS =============================== |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CUsbBasicPersonalityTest::CUsbBasicPersonalityTest |
|
80 // C++ default constructor can NOT contain any code, that |
|
81 // might leave. |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 CUsbBasicPersonalityTest::CUsbBasicPersonalityTest( |
|
85 CTestModuleIf& aTestModuleIf ): |
|
86 CScriptBase( aTestModuleIf ) |
|
87 { |
|
88 } |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // CUsbBasicPersonalityTest::ConstructL |
|
92 // Symbian 2nd phase constructor can leave. |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 void CUsbBasicPersonalityTest::ConstructL() |
|
96 { |
|
97 //Read logger settings to check whether test case name is to be |
|
98 //appended to log file name. |
|
99 RSettingServer settingServer; |
|
100 TInt ret = settingServer.Connect(); |
|
101 if(ret != KErrNone) |
|
102 { |
|
103 User::Leave(ret); |
|
104 } |
|
105 // Struct to StifLogger settigs. |
|
106 TLoggerSettings loggerSettings; |
|
107 // Parse StifLogger defaults from STIF initialization file. |
|
108 ret = settingServer.GetLoggerSettings(loggerSettings); |
|
109 if(ret != KErrNone) |
|
110 { |
|
111 User::Leave(ret); |
|
112 } |
|
113 // Close Setting server session |
|
114 settingServer.Close(); |
|
115 |
|
116 TFileName logFileName; |
|
117 |
|
118 if(loggerSettings.iAddTestCaseTitle) |
|
119 { |
|
120 TName title; |
|
121 TestModuleIf().GetTestCaseTitleL(title); |
|
122 logFileName.Format(KUsbBasicPersonalityTestLogFileWithTitle, &title); |
|
123 } |
|
124 else |
|
125 { |
|
126 logFileName.Copy(KUsbBasicPersonalityTestLogFile); |
|
127 } |
|
128 |
|
129 iLog = CStifLogger::NewL( KUsbBasicPersonalityTestLogPath, |
|
130 logFileName, |
|
131 CStifLogger::ETxt, |
|
132 CStifLogger::EFile, |
|
133 EFalse ); |
|
134 |
|
135 SendTestClassVersion(); |
|
136 |
|
137 if (!CActiveScheduler::Current()) |
|
138 { |
|
139 iScheduler = new ( ELeave ) CActiveScheduler(); |
|
140 CActiveScheduler::Install( iScheduler ); |
|
141 } |
|
142 |
|
143 iNotifier = CUsbPersonalityNotifier::NewL(); |
|
144 iParams = new ( ELeave )TUsbPersonalityParams( iUsb, *iNotifier ); |
|
145 iPlugin = CUsbPersonalityPlugin::NewL( *iParams, TUid::Uid(0x102068DF) ); |
|
146 |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CUsbBasicPersonalityTest::NewL |
|
151 // Two-phased constructor. |
|
152 // ----------------------------------------------------------------------------- |
|
153 // |
|
154 CUsbBasicPersonalityTest* CUsbBasicPersonalityTest::NewL( |
|
155 CTestModuleIf& aTestModuleIf ) |
|
156 { |
|
157 CUsbBasicPersonalityTest* self = new (ELeave) CUsbBasicPersonalityTest( aTestModuleIf ); |
|
158 |
|
159 CleanupStack::PushL( self ); |
|
160 self->ConstructL(); |
|
161 CleanupStack::Pop(); |
|
162 |
|
163 return self; |
|
164 |
|
165 } |
|
166 |
|
167 // Destructor |
|
168 CUsbBasicPersonalityTest::~CUsbBasicPersonalityTest() |
|
169 { |
|
170 // Delete resources allocated from test methods |
|
171 Delete(); |
|
172 |
|
173 // Delete logger |
|
174 delete iLog; |
|
175 iLog = NULL; |
|
176 } |
|
177 |
|
178 //----------------------------------------------------------------------------- |
|
179 // CUsbBasicPersonalityTest::SendTestClassVersion |
|
180 // Method used to send version of test class |
|
181 //----------------------------------------------------------------------------- |
|
182 // |
|
183 void CUsbBasicPersonalityTest::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("UsbBasicPersonalityTest.dll"); |
|
192 |
|
193 TBool newVersionOfMethod = ETrue; |
|
194 TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod); |
|
195 } |
|
196 |
|
197 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
198 |
|
199 // ----------------------------------------------------------------------------- |
|
200 // LibEntryL is a polymorphic Dll entry point. |
|
201 // Returns: CScriptBase: New CScriptBase derived object |
|
202 // ----------------------------------------------------------------------------- |
|
203 // |
|
204 EXPORT_C CScriptBase* LibEntryL( |
|
205 CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework |
|
206 { |
|
207 |
|
208 return ( CScriptBase* ) CUsbBasicPersonalityTest::NewL( aTestModuleIf ); |
|
209 |
|
210 } |
|
211 |
|
212 |
|
213 // End of File |