|
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 "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: SendUIAPITest implementation* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <Stiftestinterface.h> |
|
22 #include "SendUIAPITest.h" |
|
23 #include <SettingServerClient.h> |
|
24 #include <sendui.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 // CSendUIAPITest::CSendUIAPITest |
|
79 // C++ default constructor can NOT contain any code, that |
|
80 // might leave. |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 CSendUIAPITest::CSendUIAPITest( |
|
84 CTestModuleIf& aTestModuleIf ): |
|
85 CScriptBase( aTestModuleIf ), |
|
86 iMessageData( NULL ), |
|
87 iMessageAddress( NULL ) |
|
88 { |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CSendUIAPITest::ConstructL |
|
93 // Symbian 2nd phase constructor can leave. |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 void CSendUIAPITest::ConstructL() |
|
97 { |
|
98 //Read logger settings to check whether test case name is to be |
|
99 //appended to log file name. |
|
100 RSettingServer settingServer; |
|
101 TInt ret = settingServer.Connect(); |
|
102 if(ret != KErrNone) |
|
103 { |
|
104 User::Leave(ret); |
|
105 } |
|
106 // Struct to StifLogger settigs. |
|
107 TLoggerSettings loggerSettings; |
|
108 // Parse StifLogger defaults from STIF initialization file. |
|
109 ret = settingServer.GetLoggerSettings(loggerSettings); |
|
110 if(ret != KErrNone) |
|
111 { |
|
112 User::Leave(ret); |
|
113 } |
|
114 // Close Setting server session |
|
115 settingServer.Close(); |
|
116 |
|
117 TFileName logFileName; |
|
118 |
|
119 if(loggerSettings.iAddTestCaseTitle) |
|
120 { |
|
121 TName title; |
|
122 TestModuleIf().GetTestCaseTitleL(title); |
|
123 logFileName.Format(KSendUIAPITestLogFileWithTitle, &title); |
|
124 } |
|
125 else |
|
126 { |
|
127 logFileName.Copy(KSendUIAPITestLogFile); |
|
128 } |
|
129 |
|
130 iLog = CStifLogger::NewL( KSendUIAPITestLogPath, |
|
131 logFileName, |
|
132 CStifLogger::ETxt, |
|
133 CStifLogger::EFile, |
|
134 EFalse ); |
|
135 |
|
136 |
|
137 SendTestClassVersion(); |
|
138 //Create the SendUI var |
|
139 iSendUi = CSendUi::NewL(); |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CSendUIAPITest::NewL |
|
144 // Two-phased constructor. |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 CSendUIAPITest* CSendUIAPITest::NewL( |
|
148 CTestModuleIf& aTestModuleIf ) |
|
149 { |
|
150 CSendUIAPITest* self = new (ELeave) CSendUIAPITest( aTestModuleIf ); |
|
151 |
|
152 CleanupStack::PushL( self ); |
|
153 self->ConstructL(); |
|
154 CleanupStack::Pop( self ); |
|
155 |
|
156 return self; |
|
157 |
|
158 } |
|
159 |
|
160 // Destructor |
|
161 CSendUIAPITest::~CSendUIAPITest() |
|
162 { |
|
163 |
|
164 // Delete resources allocated from test methods |
|
165 Delete(); |
|
166 |
|
167 //Delete the SendUI var |
|
168 delete iSendUi; |
|
169 |
|
170 // Delete logger |
|
171 delete iLog; |
|
172 |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // CSendUIAPITest::?MsgDataSetSubjectL |
|
177 // ?Test Case for Calling CMessageData's SetSubjectL fun |
|
178 // (other items were commented in a header). |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 |
|
182 TInt CSendUIAPITest::MsgDataSetSubjectL( TPtrC& aSubject ) |
|
183 { |
|
184 // Print to UI |
|
185 _LIT( KSendUIAPITest, "SendUIAPITest" ); |
|
186 _LIT( KMsgDataSetSubjectL, "In MsgDataSetSubjectL" ); |
|
187 TestModuleIf().Printf( 0, KSendUIAPITest, KMsgDataSetSubjectL ); |
|
188 // Print to log file |
|
189 iLog->Log( KMsgDataSetSubjectL); |
|
190 |
|
191 //Create the instance of CMessageData |
|
192 CMessageData* messagedata = InitL(); |
|
193 |
|
194 //Set the subject |
|
195 TRAPD(err,messagedata->SetSubjectL(&aSubject)); |
|
196 if(err == KErrNone) |
|
197 { |
|
198 return KErrNone; |
|
199 } |
|
200 |
|
201 else |
|
202 { |
|
203 return err; |
|
204 } |
|
205 |
|
206 } |
|
207 |
|
208 // ----------------------------------------------------------------------------- |
|
209 // CSendUIAPITest::?MsgDataCompSubjectL |
|
210 // ?Test Case for Calling CMessageData's Subject fun and comparing it with passed param |
|
211 // (other items were commented in a header). |
|
212 // ----------------------------------------------------------------------------- |
|
213 // |
|
214 |
|
215 TInt CSendUIAPITest::MsgDataCompSubjectL( TPtrC& aSubject ) |
|
216 { |
|
217 // Print to UI |
|
218 _LIT( KSendUIAPITest, "SendUIAPITest" ); |
|
219 _LIT( KMsgDataCompSubjectL, "In MsgDataCompSubjectL" ); |
|
220 TestModuleIf().Printf( 0, KSendUIAPITest, KMsgDataCompSubjectL ); |
|
221 // Print to log file |
|
222 iLog->Log( KMsgDataCompSubjectL); |
|
223 |
|
224 //Create the instance of CMessageData |
|
225 CMessageData* messagedata = InitL(); |
|
226 //Get the subject from message data |
|
227 TPtrC msgdatasubject = messagedata->Subject(); |
|
228 |
|
229 //Compare the two subjects |
|
230 if(msgdatasubject == aSubject) |
|
231 { |
|
232 return KErrNone; |
|
233 } |
|
234 else |
|
235 { |
|
236 return KErrGeneral; |
|
237 } |
|
238 } |
|
239 |
|
240 //----------------------------------------------------------------------------- |
|
241 // CSendUIAPITest::SendTestClassVersion |
|
242 // Method used to send version of test class |
|
243 //----------------------------------------------------------------------------- |
|
244 // |
|
245 void CSendUIAPITest::SendTestClassVersion() |
|
246 { |
|
247 TVersion moduleVersion; |
|
248 moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR; |
|
249 moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR; |
|
250 moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD; |
|
251 |
|
252 TFileName moduleName; |
|
253 moduleName = _L("SendUIAPITest.dll"); |
|
254 |
|
255 TBool newVersionOfMethod = ETrue; |
|
256 TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod); |
|
257 } |
|
258 |
|
259 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
260 |
|
261 // ----------------------------------------------------------------------------- |
|
262 // LibEntryL is a polymorphic Dll entry point. |
|
263 // Returns: CScriptBase: New CScriptBase derived object |
|
264 // ----------------------------------------------------------------------------- |
|
265 // |
|
266 EXPORT_C CScriptBase* LibEntryL( |
|
267 CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework |
|
268 { |
|
269 |
|
270 return ( CScriptBase* ) CSendUIAPITest::NewL( aTestModuleIf ); |
|
271 |
|
272 } |
|
273 |
|
274 |
|
275 // End of File |