|
1 /* |
|
2 * Copyright (c) 2008-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 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <Stiftestinterface.h> |
|
23 #include "UsbUiNotifApiTest.h" |
|
24 #include <SettingServerClient.h> |
|
25 |
|
26 // EXTERNAL DATA STRUCTURES |
|
27 //extern ?external_data; |
|
28 |
|
29 // EXTERNAL FUNCTION PROTOTYPES |
|
30 //extern ?external_function( ?arg_type,?arg_type ); |
|
31 |
|
32 // CONSTANTS |
|
33 //const ?type ?constant_var = ?constant; |
|
34 |
|
35 // MACROS |
|
36 //#define ?macro ?macro_def |
|
37 |
|
38 // LOCAL CONSTANTS AND MACROS |
|
39 //const ?type ?constant_var = ?constant; |
|
40 //#define ?macro_name ?macro_def |
|
41 |
|
42 // MODULE DATA STRUCTURES |
|
43 //enum ?declaration |
|
44 //typedef ?declaration |
|
45 |
|
46 // LOCAL FUNCTION PROTOTYPES |
|
47 //?type ?function_name( ?arg_type, ?arg_type ); |
|
48 |
|
49 // FORWARD DECLARATIONS |
|
50 //class ?FORWARD_CLASSNAME; |
|
51 |
|
52 // ============================= LOCAL FUNCTIONS =============================== |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // ?function_name ?description. |
|
56 // ?description |
|
57 // Returns: ?value_1: ?description |
|
58 // ?value_n: ?description_line1 |
|
59 // ?description_line2 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 /* |
|
63 ?type ?function_name( |
|
64 ?arg_type arg, // ?description |
|
65 ?arg_type arg) // ?description |
|
66 { |
|
67 |
|
68 ?code // ?comment |
|
69 |
|
70 // ?comment |
|
71 ?code |
|
72 } |
|
73 */ |
|
74 |
|
75 // ============================ MEMBER FUNCTIONS =============================== |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CUsbUiNotifApiTest::CUsbUiNotifApiTest |
|
79 // C++ default constructor can NOT contain any code, that |
|
80 // might leave. |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 CUsbUiNotifApiTest::CUsbUiNotifApiTest( |
|
84 CTestModuleIf& aTestModuleIf ): |
|
85 CScriptBase( aTestModuleIf ), |
|
86 iRes(0) |
|
87 { |
|
88 } |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // CUsbUiNotifApiTest::ConstructL |
|
92 // Symbian 2nd phase constructor can leave. |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 void CUsbUiNotifApiTest::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(KUsbUiNotifApiTestLogFileWithTitle, &title); |
|
123 } |
|
124 else |
|
125 { |
|
126 logFileName.Copy(KUsbUiNotifApiTestLogFile); |
|
127 } |
|
128 |
|
129 iLog = CStifLogger::NewL( KUsbUiNotifApiTestLogPath, |
|
130 logFileName, |
|
131 CStifLogger::ETxt, |
|
132 CStifLogger::EFile, |
|
133 EFalse ); |
|
134 |
|
135 SendTestClassVersion(); |
|
136 |
|
137 iNotifier = new ( ELeave ) RNotifier(); |
|
138 iUsbWatcher = new ( ELeave ) RUsbWatcher(); |
|
139 iRepository = CRepository::NewL( KCRUidUsbWatcher ); |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CUsbUiNotifApiTest::NewL |
|
144 // Two-phased constructor. |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 CUsbUiNotifApiTest* CUsbUiNotifApiTest::NewL( |
|
148 CTestModuleIf& aTestModuleIf ) |
|
149 { |
|
150 CUsbUiNotifApiTest* self = new (ELeave) CUsbUiNotifApiTest( aTestModuleIf ); |
|
151 |
|
152 CleanupStack::PushL( self ); |
|
153 self->ConstructL(); |
|
154 CleanupStack::Pop(); |
|
155 |
|
156 return self; |
|
157 |
|
158 } |
|
159 |
|
160 // Destructor |
|
161 CUsbUiNotifApiTest::~CUsbUiNotifApiTest() |
|
162 { |
|
163 |
|
164 // Delete resources allocated from test methods |
|
165 Delete(); |
|
166 |
|
167 // Delete logger |
|
168 delete iLog; |
|
169 |
|
170 } |
|
171 |
|
172 //----------------------------------------------------------------------------- |
|
173 // CUsbUiNotifApiTest::SendTestClassVersion |
|
174 // Method used to send version of test class |
|
175 //----------------------------------------------------------------------------- |
|
176 // |
|
177 void CUsbUiNotifApiTest::SendTestClassVersion() |
|
178 { |
|
179 TVersion moduleVersion; |
|
180 moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR; |
|
181 moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR; |
|
182 moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD; |
|
183 |
|
184 TFileName moduleName; |
|
185 moduleName = _L("UsbUiNotifApiTest.dll"); |
|
186 |
|
187 TBool newVersionOfMethod = ETrue; |
|
188 TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod); |
|
189 } |
|
190 |
|
191 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // LibEntryL is a polymorphic Dll entry point. |
|
195 // Returns: CScriptBase: New CScriptBase derived object |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 EXPORT_C CScriptBase* LibEntryL( |
|
199 CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework |
|
200 { |
|
201 |
|
202 return ( CScriptBase* ) CUsbUiNotifApiTest::NewL( aTestModuleIf ); |
|
203 |
|
204 } |
|
205 |
|
206 |
|
207 // End of File |