1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. |
|
3 * |
|
4 * This library is free software; you can redistribute it and/or |
|
5 * modify it under the terms of the GNU Lesser General Public |
|
6 * License as published by the Free Software Foundation; either |
|
7 * version 2 of the License, or (at your option) any later version. |
|
8 * |
|
9 * This library is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
12 * Lesser General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU Lesser General Public |
|
15 * License along with this library; if not, write to the |
|
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
17 * Boston, MA 02111-1307, USA. |
|
18 * |
|
19 * Description: This file contains testclass implementation. |
|
20 * |
|
21 */ |
|
22 |
|
23 // [INCLUDE FILES] - do not remove |
|
24 #include <e32svr.h> |
|
25 #include <StifParser.h> |
|
26 #include <StifTestInterface.h> |
|
27 #include "GstreamerTestCases.h" |
|
28 |
|
29 // EXTERNAL DATA STRUCTURES |
|
30 //extern ?external_data; |
|
31 |
|
32 // EXTERNAL FUNCTION PROTOTYPES |
|
33 //extern ?external_function( ?arg_type,?arg_type ); |
|
34 |
|
35 // CONSTANTS |
|
36 //const ?type ?constant_var = ?constant; |
|
37 |
|
38 // MACROS |
|
39 //#define ?macro ?macro_def |
|
40 |
|
41 // LOCAL CONSTANTS AND MACROS |
|
42 //const ?type ?constant_var = ?constant; |
|
43 //#define ?macro_name ?macro_def |
|
44 |
|
45 // MODULE DATA STRUCTURES |
|
46 //enum ?declaration |
|
47 //typedef ?declaration |
|
48 |
|
49 // LOCAL FUNCTION PROTOTYPES |
|
50 //?type ?function_name( ?arg_type, ?arg_type ); |
|
51 |
|
52 // FORWARD DECLARATIONS |
|
53 //class ?FORWARD_CLASSNAME; |
|
54 |
|
55 // ============================= LOCAL FUNCTIONS =============================== |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // ?function_name ?description. |
|
59 // ?description |
|
60 // Returns: ?value_1: ?description |
|
61 // ?value_n: ?description_line1 |
|
62 // ?description_line2 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 /* |
|
66 ?type ?function_name( |
|
67 ?arg_type arg, // ?description |
|
68 ?arg_type arg) // ?description |
|
69 { |
|
70 |
|
71 ?code // ?comment |
|
72 |
|
73 // ?comment |
|
74 ?code |
|
75 } |
|
76 */ |
|
77 |
|
78 // ============================ MEMBER FUNCTIONS =============================== |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CGstreamerTestCases::Delete |
|
82 // Delete here all resources allocated and opened from test methods. |
|
83 // Called from destructor. |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 void CGstreamerTestCases::Delete() |
|
87 { |
|
88 |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CGstreamerTestCases::RunMethodL |
|
93 // Run specified method. Contains also table of test mothods and their names. |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 TInt CGstreamerTestCases::RunMethodL( |
|
97 CStifItemParser& aItem ) |
|
98 { |
|
99 |
|
100 static TStifFunctionInfo const KFunctions[] = |
|
101 { |
|
102 // Copy this line for every implemented function. |
|
103 // First string is the function name used in TestScripter script file. |
|
104 // Second is the actual implementation member function. |
|
105 ENTRY( "Example", CGstreamerTestCases::ExampleL ), |
|
106 //ADD NEW ENTRY HERE |
|
107 // [test cases entries] - Do not remove |
|
108 |
|
109 }; |
|
110 |
|
111 const TInt count = sizeof( KFunctions ) / |
|
112 sizeof( TStifFunctionInfo ); |
|
113 |
|
114 return RunInternalL( KFunctions, count, aItem ); |
|
115 |
|
116 } |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CGstreamerTestCases::ExampleL |
|
120 // Example test method function. |
|
121 // (other items were commented in a header). |
|
122 // ----------------------------------------------------------------------------- |
|
123 // |
|
124 TInt CGstreamerTestCases::ExampleL( CStifItemParser& aItem ) |
|
125 { |
|
126 TInt err = KErrNone; |
|
127 RTimer timeoutTimer; |
|
128 // Print to UI |
|
129 // _LIT( KGstreamerTestCases, "GstreamerTestCases" ); |
|
130 // _LIT( KExample, "Test case: " ); |
|
131 // TestModuleIf().Printf( 0, KGstreamerTestCases, KExample ); |
|
132 // Print to log file |
|
133 |
|
134 TPtrC string[2]; |
|
135 TFileName arg; |
|
136 //_LIT( KParam, "Param[%i]: %S" ); |
|
137 |
|
138 if( aItem.GetNextString ( string[0] ) != KErrNone) |
|
139 { |
|
140 iLog->Log( _L(">> Test cases Not Found") ); |
|
141 return -1; |
|
142 } |
|
143 iLog->Log( _L( "Test case Name is : " ) ); |
|
144 iLog->Log( string[0] ); |
|
145 |
|
146 while ( aItem.GetNextString ( string[1] ) == KErrNone ) |
|
147 { |
|
148 iLog->Log( string[1] ); |
|
149 arg.Append( string[1] ); |
|
150 arg.Append( TChar(' ') ); |
|
151 } |
|
152 |
|
153 |
|
154 _LIT( KArg, "Arg: " ); |
|
155 iLog->Log( KArg ); |
|
156 iLog->Log( arg ); |
|
157 RProcess process; |
|
158 err = process.Create( string[0],arg ); |
|
159 |
|
160 if( !err ) |
|
161 { |
|
162 |
|
163 if( timeoutTimer.CreateLocal() != KErrNone ) |
|
164 { |
|
165 iLog->Log( _L(">> timeoutTimer.CreateLocal failed") ); |
|
166 } |
|
167 |
|
168 iLog->Log( _L(">> Test cases Started") ); |
|
169 TRequestStatus processStatus = KRequestPending; |
|
170 TRequestStatus timerStatus = KRequestPending; |
|
171 process.Logon( processStatus ); |
|
172 |
|
173 process.Resume(); |
|
174 TTimeIntervalMicroSeconds32 timeout = 1 * 60 * 1000000; |
|
175 timeoutTimer.After( timerStatus, timeout ); |
|
176 |
|
177 while( processStatus == KRequestPending && timerStatus == KRequestPending ) |
|
178 { |
|
179 User::WaitForAnyRequest(); |
|
180 |
|
181 } |
|
182 |
|
183 err = process.ExitReason(); |
|
184 if( timerStatus != KRequestPending ) |
|
185 { |
|
186 err = KErrTimedOut; |
|
187 } |
|
188 |
|
189 process.LogonCancel( processStatus ); |
|
190 timeoutTimer.Cancel(); |
|
191 /// required to complete one of the pending request.. |
|
192 User::WaitForAnyRequest(); |
|
193 |
|
194 process.Kill( KErrNone ); |
|
195 process.Close(); |
|
196 timeoutTimer.Close(); |
|
197 iLog->Log( _L(">> test cases completed") ); |
|
198 } |
|
199 else |
|
200 { |
|
201 iLog->Log( _L(">> test cases exe not found") ); |
|
202 } |
|
203 |
|
204 |
|
205 if( err != KErrNone ) |
|
206 { |
|
207 iLog->Log( CStifLogger::ERed, _L( "Test cases FAILED!" ) ); |
|
208 } |
|
209 else |
|
210 { |
|
211 iLog->Log( CStifLogger::EGreen, _L( "Test cases PASSED!" ) ); |
|
212 } |
|
213 |
|
214 |
|
215 return err; |
|
216 } |
|
217 |
|
218 // ----------------------------------------------------------------------------- |
|
219 // CGstreamerTestCases::?member_function |
|
220 // ?implementation_description |
|
221 // (other items were commented in a header). |
|
222 // ----------------------------------------------------------------------------- |
|
223 // |
|
224 /* |
|
225 TInt CGstreamerTestCases::?member_function( |
|
226 CItemParser& aItem ) |
|
227 { |
|
228 |
|
229 ?code |
|
230 |
|
231 } |
|
232 */ |
|
233 |
|
234 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
235 // None |
|
236 |
|
237 // [End of File] - Do not remove |
|