|
1 /* |
|
2 * Copyright (c) 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 "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] - do not remove |
|
19 #include <e32base.h> |
|
20 #include <e32svr.h> |
|
21 #include <StifParser.h> |
|
22 #include <Stiftestinterface.h> |
|
23 #include <glxcollectionmanager.h> |
|
24 |
|
25 #include "ut_collectionmanager.h" |
|
26 |
|
27 |
|
28 // EXTERNAL DATA STRUCTURES |
|
29 //extern ?external_data; |
|
30 |
|
31 // EXTERNAL FUNCTION PROTOTYPES |
|
32 //extern ?external_function( ?arg_type,?arg_type ); |
|
33 |
|
34 // CONSTANTS |
|
35 //const ?type ?constant_var = ?constant; |
|
36 |
|
37 // MACROS |
|
38 //#define ?macro ?macro_def |
|
39 |
|
40 // LOCAL CONSTANTS AND MACROS |
|
41 //const ?type ?constant_var = ?constant; |
|
42 //#define ?macro_name ?macro_def |
|
43 |
|
44 // MODULE DATA STRUCTURES |
|
45 //enum ?declaration |
|
46 //typedef ?declaration |
|
47 |
|
48 // LOCAL FUNCTION PROTOTYPES |
|
49 //?type ?function_name( ?arg_type, ?arg_type ); |
|
50 |
|
51 // FORWARD DECLARATIONS |
|
52 //class ?FORWARD_CLASSNAME; |
|
53 |
|
54 // ============================= LOCAL FUNCTIONS =============================== |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // ?function_name ?description. |
|
58 // ?description |
|
59 // Returns: ?value_1: ?description |
|
60 // ?value_n: ?description_line1 |
|
61 // ?description_line2 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 /* |
|
65 ?type ?function_name( |
|
66 ?arg_type arg, // ?description |
|
67 ?arg_type arg) // ?description |
|
68 { |
|
69 |
|
70 ?code // ?comment |
|
71 |
|
72 // ?comment |
|
73 ?code |
|
74 } |
|
75 */ |
|
76 |
|
77 // ============================ MEMBER FUNCTIONS =============================== |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // Cut_collectionmanager::Delete |
|
81 // Delete here all resources allocated and opened from test methods. |
|
82 // Called from destructor. |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 void Cut_collectionmanager::Delete() |
|
86 { |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // Cut_collectionmanager::RunMethodL |
|
91 // Run specified method. Contains also table of test mothods and their names. |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 TInt Cut_collectionmanager::RunMethodL( |
|
95 CStifItemParser& aItem ) |
|
96 { |
|
97 |
|
98 static TStifFunctionInfo const KFunctions[] = |
|
99 { |
|
100 // Copy this line for every implemented function. |
|
101 // First string is the function name used in TestScripter script file. |
|
102 // Second is the actual implementation member function. |
|
103 //ADD NEW ENTRY HERE |
|
104 // [test cases entries] - Do not remove |
|
105 ENTRY( "NewL", Cut_collectionmanager::NewLTestL ), |
|
106 ENTRY( "Destructor", Cut_collectionmanager::DestructionTestL ), |
|
107 ENTRY( "AddToCollection", Cut_collectionmanager::AddToCollectionTestL), |
|
108 ENTRY( "CollectionInfoL", Cut_collectionmanager::TestCollectionInfoL ), |
|
109 ENTRY( "Cancel", Cut_collectionmanager::TestCancelL ), |
|
110 }; |
|
111 |
|
112 const TInt count = sizeof( KFunctions ) / |
|
113 sizeof( TStifFunctionInfo ); |
|
114 |
|
115 |
|
116 return RunInternalL( KFunctions, count, aItem ); |
|
117 |
|
118 } |
|
119 |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // Cut_collectionmanager::NewLTestL |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 TInt Cut_collectionmanager::NewLTestL( CStifItemParser& /*aItem*/ ) |
|
126 { |
|
127 // Create CollectionManager Instance |
|
128 CGlxCollectionManager* collectionManager = CGlxCollectionManager::NewL(); |
|
129 |
|
130 if( collectionManager ) |
|
131 { |
|
132 // Print test case passed if CGlxCollectionManager instance is created |
|
133 iLog->Log(_L("CGlxCollectionManager::NewL() Passed")); |
|
134 delete collectionManager; |
|
135 collectionManager = NULL; |
|
136 User::InfoPrint(_L("test newL passed")); |
|
137 return KErrNone; |
|
138 } |
|
139 else |
|
140 { |
|
141 // Print test case passed if CGlxCollectionManager instance is created |
|
142 iLog->Log(_L("CGlxCollectionManager::NewL() Failed")); |
|
143 User::InfoPrint(_L("test newL failed")); |
|
144 return KErrArgument; |
|
145 } |
|
146 } |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // Cut_collectionmanager::DestructionTestL |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 TInt Cut_collectionmanager::DestructionTestL(CStifItemParser& /*aItem*/) |
|
153 { |
|
154 _LIT( KDestructionTest, "DestructionTest" ); |
|
155 |
|
156 // Print to log file |
|
157 iLog->Log( KDestructionTest ); |
|
158 |
|
159 __UHEAP_MARK; |
|
160 // Create CollectionManager Instance |
|
161 CGlxCollectionManager* collectionManager = CGlxCollectionManager::NewL(); |
|
162 delete collectionManager; |
|
163 collectionManager = NULL; |
|
164 __UHEAP_MARKEND; |
|
165 |
|
166 iLog->Log(_L("~CollectionManager() :: Passed")); |
|
167 User::InfoPrint(_L("test ~CollectionManager() Passed")); |
|
168 |
|
169 return KErrNone; |
|
170 } |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // Cut_collectionmanager::AddToCollectionTestL |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 TInt Cut_collectionmanager::AddToCollectionTestL(CStifItemParser& aItem) |
|
177 { |
|
178 TInt error = KErrNone ; |
|
179 TRAP(error, |
|
180 if(iAo) |
|
181 { |
|
182 //iAo->TestingFunc(aItem) ;//uncomment it later when pass the args from .cfg file and parse it in parse func |
|
183 iAo->AddToCollectionTestL(); |
|
184 iWait->Start(); |
|
185 } |
|
186 ); |
|
187 return error; |
|
188 } |
|
189 |
|
190 // ----------------------------------------------------------------------------- |
|
191 // Cut_collectionmanager::TestCollectionInfoL |
|
192 // ----------------------------------------------------------------------------- |
|
193 // |
|
194 TInt Cut_collectionmanager::TestCollectionInfoL() |
|
195 { |
|
196 TInt error = KErrNone ; |
|
197 TRAP(error, |
|
198 if(iAo) |
|
199 { |
|
200 iAo->TestCollectionInfoL() ; |
|
201 iWait->Start(); |
|
202 } |
|
203 ); |
|
204 return error; |
|
205 } |
|
206 |
|
207 // ----------------------------------------------------------------------------- |
|
208 // Cut_collectionmanager::TestCancelL |
|
209 // ----------------------------------------------------------------------------- |
|
210 // |
|
211 TInt Cut_collectionmanager::TestCancelL() |
|
212 { |
|
213 TInt error = KErrNone ; |
|
214 TRAP(error, |
|
215 if(iAo) |
|
216 { |
|
217 iAo->TestCancel() ; |
|
218 iWait->Start(); |
|
219 } |
|
220 ); |
|
221 return error; |
|
222 } |
|
223 |
|
224 |
|
225 /**** |
|
226 * callback from ut_collectionmanager.cpp to report the pass/fail |
|
227 */ |
|
228 void Cut_collectionmanager::RequestComplete(TInt aError) |
|
229 { |
|
230 iWait->AsyncStop(); |
|
231 if( aError == KErrNone ) |
|
232 { |
|
233 iLog->Log(_L("Test case passed")); |
|
234 User::InfoPrint(_L("Test case passed")); |
|
235 } |
|
236 else if(aError == KErrCancel) |
|
237 { |
|
238 iLog->Log(_L("cancel Test case passed")); |
|
239 User::InfoPrint(_L("cancel Test case passed")); |
|
240 } |
|
241 else |
|
242 { |
|
243 iLog->Log(_L("Test case Failed")); |
|
244 User::InfoPrint(_L("test case failed")); |
|
245 } |
|
246 } |
|
247 // ----------------------------------------------------------------------------- |
|
248 // Cut_collectionmanager::?member_function |
|
249 // ?implementation_description |
|
250 // (other items were commented in a header). |
|
251 // ----------------------------------------------------------------------------- |
|
252 // |
|
253 /* |
|
254 TInt Cut_collectionmanager::?member_function( |
|
255 CItemParser& aItem ) |
|
256 { |
|
257 |
|
258 ?code |
|
259 |
|
260 } |
|
261 */ |
|
262 |
|
263 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
264 // None |
|
265 |
|
266 // [End of File] - Do not remove |