|
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 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // [INCLUDE FILES] - do not remove |
|
20 #include <e32svr.h> |
|
21 #include <StifParser.h> |
|
22 #include <Stiftestinterface.h> |
|
23 #include <LiwServiceHandler.h> |
|
24 |
|
25 #include "tmediaprovidertesting.h" |
|
26 #include "tmediaprovidertesting.hrh" |
|
27 |
|
28 |
|
29 |
|
30 using namespace LIW; |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // Ctmediaprovidertesting::Delete |
|
36 // Delete here all resources allocated and opened from test methods. |
|
37 // Called from destructor. |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 void Ctmediaprovidertesting::Delete() |
|
41 { |
|
42 TInt count = iExpectedOutPutArray.Count(); |
|
43 for(TInt index =0 ;index<count;index++) |
|
44 { |
|
45 iExpectedOutPutArray[index]->DecRef(); |
|
46 } |
|
47 iExpectedOutPutArray.Close(); |
|
48 iIface->Close(); |
|
49 delete iServicehandler; |
|
50 delete iInList; |
|
51 delete iOutList; |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // Ctmediaprovidertesting::RunMethodL |
|
56 // Run specified method. Contains also table of test mothods and their names. |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 TInt Ctmediaprovidertesting::RunMethodL(CStifItemParser& aItem) |
|
60 { |
|
61 static TStifFunctionInfo const KFunctions[] = |
|
62 { |
|
63 ENTRY("GetFilesListL", Ctmediaprovidertesting::GetFilesListL) |
|
64 }; |
|
65 const TInt count = sizeof( KFunctions ) / |
|
66 sizeof( TStifFunctionInfo ); |
|
67 return RunInternalL( KFunctions, count, aItem ); |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // Callback:: HandleNotifyL |
|
72 // Call Back Function Called by the Media Management SAPI. |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 TInt Ctmediaprovidertesting:: HandleNotifyL(TInt /*aCmdId*/, |
|
76 TInt aEventId, |
|
77 CLiwGenericParamList& aEventParamList, |
|
78 const CLiwGenericParamList& /*aInParamList*/) |
|
79 { |
|
80 TInt pos = 0; |
|
81 TInt error = KErrGeneral; |
|
82 iResult = KErrGeneral; |
|
83 |
|
84 TBuf<25> errorcodedes(KNullDesC); |
|
85 const TLiwGenericParam* errorCode = NULL; |
|
86 const TLiwGenericParam* resultList = NULL; |
|
87 CLiwIterable* iterator = NULL; |
|
88 |
|
89 CActiveScheduler::Stop(); |
|
90 |
|
91 errorCode = aEventParamList.FindFirst(pos, KErrorCode); // Finding Error Code |
|
92 resultList = aEventParamList.FindFirst(pos, KResponse); // Finding Iterator for the result list |
|
93 |
|
94 if(errorCode) |
|
95 { |
|
96 error = errorCode->Value().AsTInt32(); |
|
97 errorcodedes.Num(error); |
|
98 iLog->Log(_L("Error code:")); |
|
99 iLog->Log(errorcodedes); |
|
100 } |
|
101 if(iExpErrorCode != error) |
|
102 { |
|
103 iLog->Log(_L("Expected Error code does not match")); |
|
104 User::Leave(KErrGeneral); |
|
105 } |
|
106 if(resultList) |
|
107 { |
|
108 iterator = resultList->Value().AsIterable(); |
|
109 if(IsExpectedResult(iterator)) |
|
110 { |
|
111 iResult = KErrNone; |
|
112 } |
|
113 } |
|
114 else |
|
115 { |
|
116 if(iExpectedOutPutArray.Count() != 0) |
|
117 { |
|
118 iLog->Log(_L("Result Iterator Not Found")); |
|
119 User::Leave(KErrNotFound); |
|
120 } |
|
121 } |
|
122 } |
|
123 |
|
124 /* -------------------------------------------------------------------------- |
|
125 Ctmediaprovidertesting :: GetImageFilesL |
|
126 Calls the Getlist of Media management SAPI. |
|
127 ----------------------------------------------------------------------------- |
|
128 */ |
|
129 TInt Ctmediaprovidertesting::GetFilesListL( CStifItemParser& aItem ) |
|
130 { |
|
131 TInt error = KErrGeneral; |
|
132 |
|
133 LoadServiceL(); |
|
134 |
|
135 ParseStiffInput(aItem); |
|
136 |
|
137 iIface->ExecuteCmdL(command8, |
|
138 *iInList, |
|
139 *iOutList, |
|
140 KLiwOptASyncronous, |
|
141 this); |
|
142 TInt pos = 0; |
|
143 const TLiwGenericParam* p = iOutList->FindFirst(pos, |
|
144 KErrorCode); // Finding Error Code |
|
145 if(p) |
|
146 { |
|
147 TInt retcode = p->Value().AsTInt32(); |
|
148 if(KErrNone == retcode) |
|
149 { |
|
150 CActiveScheduler::Start(); |
|
151 } |
|
152 else |
|
153 { |
|
154 if(iExpErrorCode == retcode) |
|
155 { |
|
156 iResult = KErrNone; |
|
157 } |
|
158 else |
|
159 { |
|
160 User::Leave(KErrGeneral); |
|
161 } |
|
162 } |
|
163 } |
|
164 iInList->Reset(); |
|
165 iOutList->Reset(); |
|
166 iLog->Log(_L("")); |
|
167 return iResult; |
|
168 } |
|
169 |
|
170 |
|
171 |
|
172 /* -------------------------------------------------------------------------- |
|
173 Ctmediaprovidertesting :: LoadServiceL |
|
174 Loads the mediamanagement service. |
|
175 ----------------------------------------------------------------------------- |
|
176 */ |
|
177 void Ctmediaprovidertesting :: LoadServiceL() |
|
178 { |
|
179 TInt pos = 0; |
|
180 iInList = CLiwGenericParamList::NewL(); |
|
181 |
|
182 iOutList = CLiwGenericParamList::NewL(); |
|
183 |
|
184 iServicehandler = CLiwServiceHandler::NewL(); |
|
185 |
|
186 CLiwCriteriaItem* criteria = CLiwCriteriaItem::NewL(1, |
|
187 KIDataSource, |
|
188 KService); |
|
189 CleanupStack :: PushL(criteria); |
|
190 |
|
191 criteria->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
192 RCriteriaArray critArray; |
|
193 critArray.AppendL(criteria); |
|
194 |
|
195 iServicehandler->AttachL(critArray); |
|
196 iServicehandler->ExecuteServiceCmdL(*criteria, |
|
197 *iInList, |
|
198 *iOutList); |
|
199 |
|
200 iOutList->FindFirst( pos, KIDataSource ); |
|
201 if(pos != KErrNotFound) |
|
202 { |
|
203 iIface = (*iOutList)[pos].Value().AsInterface(); |
|
204 } |
|
205 else |
|
206 { |
|
207 User::Leave(KErrNotFound); |
|
208 } |
|
209 iInList->Reset(); |
|
210 iOutList->Reset(); |
|
211 CleanupStack :: PopAndDestroy(criteria); |
|
212 critArray.Close(); |
|
213 } |