|
1 /* |
|
2 * Copyright (c) 2004 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // CLASS HEADER |
|
20 #include "T_casrvUtils.h" |
|
21 |
|
22 // EXTERNAL INCLUDES |
|
23 #include <e32property.h> |
|
24 #include <e32debug.h> |
|
25 |
|
26 #include "cadef.h" |
|
27 #include "castorageproxy.h" |
|
28 #include "castorage.h" |
|
29 #include "casrvengutils.h" |
|
30 #include "cainnerentry.h" |
|
31 |
|
32 // INTERNAL INCLUDES |
|
33 #include "casrvtestutils.h" |
|
34 #include "testconsts.h" |
|
35 |
|
36 // CONSTANTS |
|
37 const TUid KAppScannerPluginUid = {0x20026FAF}; |
|
38 |
|
39 void T_casrvUtils::initTestCase() |
|
40 { |
|
41 } |
|
42 |
|
43 void T_casrvUtils::cleanupTestCase() |
|
44 { |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 void |
|
52 T_casrvUtils::init() |
|
53 { |
|
54 TRAPD(err, |
|
55 iTestUtils = CTestUtils::NewL(); |
|
56 iTestUtils->CopyDb(); |
|
57 |
|
58 iStorage = CCaStorageProxy::NewL(); |
|
59 |
|
60 iSrvEngUtils = CCaSrvEngUtils::NewL(); |
|
61 ); |
|
62 QCOMPARE(err, KErrNone); |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 void |
|
70 T_casrvUtils::cleanup() |
|
71 { |
|
72 |
|
73 delete iSrvEngUtils; |
|
74 iSrvEngUtils = NULL; |
|
75 delete iStorage; |
|
76 iStorage = NULL; |
|
77 delete iTestUtils; |
|
78 iTestUtils = NULL; |
|
79 |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 void |
|
87 T_casrvUtils::testNewL() |
|
88 { |
|
89 CCaSrvEngUtils *obj(0); |
|
90 |
|
91 TRAPD(err, obj = CCaSrvEngUtils::NewL()); |
|
92 QCOMPARE(err, KErrNone); |
|
93 |
|
94 QVERIFY(obj != NULL); |
|
95 |
|
96 delete obj; |
|
97 } |
|
98 |
|
99 void |
|
100 T_casrvUtils::testGetAppUidL() |
|
101 { |
|
102 TInt getAppUidResult(KErrGeneral); |
|
103 TInt getInvalidAppUidResult(KErrNone); |
|
104 TUid actualAppUid = TUid::Uid(0); |
|
105 const TInt32 expectedAppUid = 1; |
|
106 |
|
107 TRAPD(err, |
|
108 CCaInnerEntry *const entry = CCaInnerEntry::NewLC(); |
|
109 |
|
110 entry->SetUid(expectedAppUid); |
|
111 |
|
112 |
|
113 getAppUidResult = |
|
114 iSrvEngUtils->GetAppUid(*entry, actualAppUid); |
|
115 |
|
116 const TInt32 invalidUid = 0; |
|
117 entry->SetUid(invalidUid); |
|
118 |
|
119 getInvalidAppUidResult = |
|
120 iSrvEngUtils->GetAppUid(*entry, actualAppUid); |
|
121 |
|
122 CleanupStack::PopAndDestroy(entry); |
|
123 ); |
|
124 |
|
125 QCOMPARE(err, KErrNone); |
|
126 QCOMPARE(getAppUidResult, KErrNone); |
|
127 QCOMPARE(expectedAppUid, actualAppUid.iUid); |
|
128 QCOMPARE(getInvalidAppUidResult, KErrNotFound); |
|
129 } |
|
130 |
|
131 void |
|
132 T_casrvUtils::testGetApaAppInfoL() |
|
133 { |
|
134 TApaAppInfo referenceInfo; |
|
135 |
|
136 RApaLsSession apaLsSession; |
|
137 TInt err(KErrNone); |
|
138 TRAP(err, User::LeaveIfError(apaLsSession.Connect())); |
|
139 QCOMPARE(err, KErrNone); |
|
140 |
|
141 QCOMPARE(apaLsSession.GetAppInfo(referenceInfo, TUid::Uid(KSystemApp)), KErrNone); |
|
142 |
|
143 TApaAppInfo srvEngUtilsInfo; |
|
144 const TInt result = iSrvEngUtils->GetApaAppInfo( |
|
145 TUid::Uid(KSystemApp), srvEngUtilsInfo); |
|
146 QCOMPARE(result, KErrNone); |
|
147 |
|
148 QCOMPARE(srvEngUtilsInfo.iUid.iUid, referenceInfo.iUid.iUid); |
|
149 QVERIFY(srvEngUtilsInfo.iFullName.Compare(referenceInfo.iFullName) == 0); |
|
150 QVERIFY(srvEngUtilsInfo.iCaption.Compare(referenceInfo.iCaption) == 0); |
|
151 QVERIFY(srvEngUtilsInfo.iShortCaption.Compare(referenceInfo.iShortCaption) == 0); |
|
152 } |
|
153 |
|
154 void |
|
155 T_casrvUtils::testGetAppInfoL() |
|
156 { |
|
157 CCaInnerEntry *entry(0); |
|
158 TRAPD(err, |
|
159 entry = CCaInnerEntry::NewLC(); |
|
160 CleanupStack::Pop(entry); |
|
161 ); |
|
162 QCOMPARE(err, KErrNone); |
|
163 |
|
164 TApaAppInfo info; |
|
165 |
|
166 entry->SetUid(KSystemApp); |
|
167 |
|
168 TInt result = iSrvEngUtils->GetAppInfo(*entry, info); |
|
169 QCOMPARE(result, KErrNone); |
|
170 QCOMPARE(info.iUid.iUid, static_cast<TInt32>(KSystemApp)); |
|
171 QVERIFY(info.iFullName.Compare(_L("Z:\\sys\\bin\\phonebook.exe")) == 0); |
|
172 QVERIFY(info.iCaption.Compare(_L("Contacts")) == 0); |
|
173 QVERIFY(info.iShortCaption.Length()>0); |
|
174 |
|
175 const TInt32 invalidUid = 0; |
|
176 entry->SetUid(invalidUid); |
|
177 QCOMPARE(iSrvEngUtils->GetAppInfo(*entry, info), KErrNotFound); |
|
178 |
|
179 entry->SetUid(notInstalledUid); |
|
180 QCOMPARE(iSrvEngUtils->GetAppInfo(*entry, info), KErrNotFound); |
|
181 |
|
182 delete entry; |
|
183 } |
|
184 |
|
185 void |
|
186 T_casrvUtils::testIsNativeL() |
|
187 { |
|
188 CCaInnerEntry *entry(0); |
|
189 TRAPD(err, |
|
190 entry = CCaInnerEntry::NewLC(); |
|
191 entry->SetEntryTypeNameL(KCaTypeApp); |
|
192 CleanupStack::Pop(entry); |
|
193 ); |
|
194 QCOMPARE(err, KErrNone); |
|
195 |
|
196 |
|
197 entry->SetUid(KSystemApp); |
|
198 |
|
199 const TInt32 isNative = iSrvEngUtils->IsNativeL(*entry); |
|
200 |
|
201 QVERIFY(isNative != 0); |
|
202 |
|
203 delete entry; |
|
204 } |
|
205 |
|
206 QTEST_MAIN(T_casrvUtils) |
|
207 |
|
208 // END OF FILE |