|
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 @file |
|
21 @test |
|
22 */ |
|
23 |
|
24 #include "scrnonrestricted.h" |
|
25 #include <usif/scr/appregentries.h> |
|
26 #include <usif/scr/scr.h> |
|
27 #include <scs/cleanuputils.h> |
|
28 #include <e32def.h> |
|
29 |
|
30 _LIT(KScrNonRestrictedSecName, "SCR non-restricted APIs test"); |
|
31 |
|
32 using namespace Usif; |
|
33 |
|
34 CScrNonRestrictedSecTest* CScrNonRestrictedSecTest::NewL() |
|
35 { |
|
36 CScrNonRestrictedSecTest* self=new(ELeave) CScrNonRestrictedSecTest(); |
|
37 CleanupStack::PushL(self); |
|
38 self->ConstructL(); |
|
39 CleanupStack::Pop(self); |
|
40 return self; |
|
41 } |
|
42 |
|
43 CScrNonRestrictedSecTest::CScrNonRestrictedSecTest() |
|
44 { |
|
45 } |
|
46 |
|
47 void CScrNonRestrictedSecTest::ConstructL() |
|
48 { |
|
49 SetNameL(KScrNonRestrictedSecName); |
|
50 } |
|
51 |
|
52 _LIT(KFileName, "c:\test.fil"); |
|
53 _LIT(KPropertyName, "DummyProperty"); |
|
54 |
|
55 void CScrNonRestrictedSecTest::RunTestL() |
|
56 { |
|
57 |
|
58 // Throughout the tests we assume that at least one component is present, i.e. that component id 1 is valid |
|
59 const TComponentId KExistingComponentId = 1; |
|
60 |
|
61 RSoftwareComponentRegistry scrSession; |
|
62 User::LeaveIfError(scrSession.Connect()); |
|
63 CleanupClosePushL(scrSession); |
|
64 |
|
65 TInt err(0); |
|
66 |
|
67 // Check component query APIs |
|
68 |
|
69 CComponentEntry* entry = CComponentEntry::NewLC(); |
|
70 TRAP(err, scrSession.GetComponentL(KExistingComponentId, *entry)); |
|
71 CheckFailL(err, _L("GetComponent")); |
|
72 CleanupStack::PopAndDestroy(entry); |
|
73 |
|
74 RArray<TComponentId> componentIds; |
|
75 TRAP(err, scrSession.GetComponentsL(KFileName, componentIds)); |
|
76 CleanupClosePushL(componentIds); |
|
77 CheckFailL(err, _L("GetComponentsL")); |
|
78 CleanupStack::PopAndDestroy(&componentIds); |
|
79 |
|
80 RPointerArray<CPropertyEntry> properties; |
|
81 CleanupResetAndDestroyPushL(properties); |
|
82 TRAP(err, scrSession.GetFilePropertiesL(KExistingComponentId, KFileName, properties)); |
|
83 CheckFailL(err, _L("GetFilePropertiesL")); |
|
84 CleanupStack::PopAndDestroy(&properties); |
|
85 |
|
86 CPropertyEntry* propertyEntry(NULL); |
|
87 TRAP(err, propertyEntry = scrSession.GetFilePropertyL(KExistingComponentId, KFileName, KPropertyName)); |
|
88 CleanupStack::PushL(propertyEntry); |
|
89 CheckFailL(err, _L("GetFilePropertyL")); |
|
90 CleanupStack::PopAndDestroy(propertyEntry); |
|
91 |
|
92 propertyEntry = NULL; |
|
93 TRAP(err, propertyEntry = scrSession.GetComponentPropertyL(KExistingComponentId, KPropertyName)); |
|
94 CleanupStack::PushL(propertyEntry); |
|
95 CheckFailL(err, _L("GetComponentPropertyL")); |
|
96 CleanupStack::PopAndDestroy(propertyEntry); |
|
97 |
|
98 propertyEntry = NULL; |
|
99 TRAP(err, propertyEntry = scrSession.GetComponentPropertyL(KExistingComponentId, KPropertyName, ELangEnglish)); |
|
100 CleanupStack::PushL(propertyEntry); |
|
101 CheckFailL(err, _L("GetComponentPropertyL - localised")); |
|
102 CleanupStack::PopAndDestroy(propertyEntry); |
|
103 |
|
104 TRAP(err, scrSession.GetComponentPropertiesL(KExistingComponentId, properties)); |
|
105 CleanupResetAndDestroyPushL(properties); |
|
106 CheckFailL(err, _L("GetFilePropertiesL")); |
|
107 CleanupStack::PopAndDestroy(&properties); |
|
108 |
|
109 TRAP(err, scrSession.GetComponentPropertiesL(KExistingComponentId, properties, ELangEnglish)); |
|
110 CleanupResetAndDestroyPushL(properties); |
|
111 CheckFailL(err, _L("GetFilePropertiesL - localised")); |
|
112 CleanupStack::PopAndDestroy(&properties); |
|
113 |
|
114 TRAP(err, scrSession.GetComponentFilesCountL(KExistingComponentId)); |
|
115 CheckFailL(err, _L("GetComponentFilesCountL")); |
|
116 |
|
117 entry = NULL; |
|
118 TRAP(err, entry = scrSession.GetComponentL(_L("GlobalId"), _L("dummy"))); |
|
119 CheckFailL(err, _L("GetComponentL - global id")); |
|
120 if(entry) |
|
121 delete entry; |
|
122 |
|
123 TRAP(err, scrSession.GetComponentIdL(_L("GlobalId"), _L("dummy"))); |
|
124 CheckFailL(err, _L("GetComponentIdL")); |
|
125 |
|
126 RPointerArray<CVersionedComponentId> globalIdList; |
|
127 CGlobalComponentId *dependantGlobalId = CGlobalComponentId::NewLC(_L("DependantGlobalId"), _L("dummy")); |
|
128 TRAP(err, scrSession.GetSupplierComponentsL(*dependantGlobalId, globalIdList)); |
|
129 CheckFailL(err, _L("GetSupplierComponentsL")); |
|
130 CleanupStack::PopAndDestroy(dependantGlobalId); |
|
131 globalIdList.Reset(); |
|
132 |
|
133 CGlobalComponentId *supplierGlobalId = CGlobalComponentId::NewLC(_L("SupplierGlobalId"), _L("dummy")); |
|
134 TRAP(err, scrSession.GetDependantComponentsL(*supplierGlobalId, globalIdList)); |
|
135 CheckFailL(err, _L("GetDependantComponentsL")); |
|
136 CleanupStack::PopAndDestroy(supplierGlobalId); |
|
137 globalIdList.ResetAndDestroy(); |
|
138 |
|
139 // Check application manager APIs |
|
140 |
|
141 TRAP(err, scrSession.IsMediaPresentL(1)); |
|
142 CheckFailL(err, _L("IsMediaPresentL")); |
|
143 |
|
144 TRAP(err, scrSession.IsComponentOrphanedL(KExistingComponentId)); |
|
145 CheckFailL(err, _L("IsComponentOrphanedL")); |
|
146 |
|
147 TRAP(err, scrSession.CompareVersionsL(_L("1.2"), _L("3.2"))); |
|
148 CheckFailL(err, _L("CompareVersionsL")); |
|
149 |
|
150 TRAP(err, scrSession.IsComponentOnReadOnlyDriveL(KExistingComponentId)); |
|
151 CheckFailL(err, _L("IsComponentOnReadOnlyDriveL")); |
|
152 |
|
153 TRAP(err, scrSession.IsComponentPresentL(KExistingComponentId)); |
|
154 CheckFailL(err, _L("IsComponentPresentL")); |
|
155 |
|
156 // Check sub-session APIs |
|
157 RSoftwareComponentRegistryFilesList compFilesListView; |
|
158 TRAP(err, compFilesListView.OpenListL(scrSession, KExistingComponentId)); |
|
159 CheckFailL(err, _L("RSoftwareComponentRegistryFilesList::OpenListL")); |
|
160 CleanupClosePushL(compFilesListView); |
|
161 |
|
162 TRAP(err, compFilesListView.NextFileL()); |
|
163 CheckFailL(err, _L("RSoftwareComponentRegistryFilesList::NextFileL")); |
|
164 |
|
165 CleanupStack::PopAndDestroy(&compFilesListView); |
|
166 |
|
167 |
|
168 // Check sub-session APIs for InfoQueryApp |
|
169 |
|
170 TUid appUid = TUid::Uid(305419896); |
|
171 |
|
172 HBufC* filename = NULL; |
|
173 RRegistrationInfoForApplication AppRegInfoQueryAppSubSession; |
|
174 AppRegInfoQueryAppSubSession.OpenL(scrSession,appUid); |
|
175 |
|
176 TRAP(err,AppRegInfoQueryAppSubSession.GetAppViewIconL(appUid,filename)); |
|
177 CheckFailL(err, _L("RApplicationRegistrationInfoQueryApp::GetAppViewIcon")); |
|
178 if(NULL != filename) |
|
179 delete filename; |
|
180 |
|
181 TRAP(err,AppRegInfoQueryAppSubSession.GetAppIconL(filename)); |
|
182 CheckFailL(err, _L("RApplicationRegistrationInfoQueryApp::GetAppIcon")); |
|
183 if(NULL != filename) |
|
184 delete filename; |
|
185 |
|
186 Usif::TApplicationCharacteristics appCharacteristics ; |
|
187 TRAP(err,AppRegInfoQueryAppSubSession.GetAppCharacteristicsL(appCharacteristics)); |
|
188 CheckFailL(err, _L("RApplicationRegistrationInfoQueryApp::GetAppCharacteristics")); |
|
189 |
|
190 RPointerArray<HBufC> appOwnedFilesArray; |
|
191 TRAP(err,AppRegInfoQueryAppSubSession.GetAppOwnedFilesL(appOwnedFilesArray)); |
|
192 CheckFailL(err, _L("RApplicationRegistrationInfoQueryApp::GetAppOwnedFiles")); |
|
193 |
|
194 |
|
195 RRegistrationInfoForApplication infoQuerySubSession; |
|
196 CleanupClosePushL(infoQuerySubSession); |
|
197 |
|
198 infoQuerySubSession.OpenL(scrSession, appUid); |
|
199 |
|
200 RPointerArray<Usif::CAppViewData> appViewInfoArray; |
|
201 CleanupResetAndDestroyPushL(appViewInfoArray); |
|
202 |
|
203 TRAP(err,infoQuerySubSession.GetAppViewsL(appViewInfoArray)); |
|
204 CheckFailL(err, _L("RRegistrationInfoForApplication::GetAppViewsL")); |
|
205 |
|
206 appViewInfoArray.ResetAndDestroy(); |
|
207 CleanupStack::PopAndDestroy(2,&infoQuerySubSession); |
|
208 |
|
209 //for RSoftwareComponentRegistryAppInfoView |
|
210 |
|
211 CAppInfoFilter* appinfoFilter = CAppInfoFilter::NewL(); |
|
212 CleanupStack::PushL(appinfoFilter); |
|
213 |
|
214 RApplicationInfoView appInfoViewsubSession; |
|
215 CleanupClosePushL(appInfoViewsubSession); |
|
216 TRAP(err, appInfoViewsubSession.OpenViewL(scrSession,appinfoFilter)); |
|
217 CheckFailL(err, _L("RSoftwareComponentRegistryAppInfoView::OpenAppInfoViewL")); |
|
218 |
|
219 RPointerArray<Usif::TAppRegInfo> appRegInfoSet; |
|
220 |
|
221 TRAP(err, appInfoViewsubSession.GetNextAppInfoL(5, appRegInfoSet)); |
|
222 CheckFailL(err, _L("RSoftwareComponentRegistryAppInfoView::GetNextAppInfoL")); |
|
223 |
|
224 TInt count = appRegInfoSet.Count(); |
|
225 Usif::TAppRegInfo* tp=NULL; |
|
226 for (TInt i = 0; i<count; i++ ) |
|
227 { |
|
228 tp=appRegInfoSet[i]; |
|
229 delete tp; |
|
230 } |
|
231 appRegInfoSet.Close(); |
|
232 CleanupStack::PopAndDestroy(2,appinfoFilter); |
|
233 |
|
234 //For GetAppServiceInfo |
|
235 RApplicationRegistrationInfo appRegInfoQuerySubSession; |
|
236 CleanupClosePushL(appRegInfoQuerySubSession); |
|
237 appRegInfoQuerySubSession.OpenL(scrSession); |
|
238 |
|
239 RPointerArray<Usif::CServiceInfo> appServiceInfoArray; |
|
240 CleanupResetAndDestroyPushL(appServiceInfoArray); |
|
241 |
|
242 CAppServiceInfoFilter* appServiceInfoFilter = CAppServiceInfoFilter::NewLC(); |
|
243 |
|
244 TRAP(err,appRegInfoQuerySubSession.GetServiceInfoL(appServiceInfoFilter, appServiceInfoArray)); |
|
245 CheckFailL(err, _L("RApplicationRegistrationInfo::GetServiceInfoL")); |
|
246 |
|
247 CleanupStack::PopAndDestroy(3, &appRegInfoQuerySubSession); |
|
248 |
|
249 //GetComponentIdForAppL |
|
250 TUid testAppUid; |
|
251 testAppUid.iUid = 1; |
|
252 TRAP(err, scrSession.GetComponentIdForAppL(testAppUid)); |
|
253 CheckFailL(err, _L("RSoftwareComponentRegistry::GetComponentIdForAppL")); |
|
254 |
|
255 //GetAppUidsForComponentL |
|
256 TComponentId compId = 1; |
|
257 RArray<TUid> appUids; |
|
258 TRAP(err, scrSession.GetAppUidsForComponentL(compId, appUids)); |
|
259 CheckFailL(err, _L("RSoftwareComponentRegistry::GetAppUidsForComponentL")); |
|
260 appUids.Close(); |
|
261 |
|
262 CleanupStack::PopAndDestroy(&scrSession); |
|
263 |
|
264 } |
|
265 |