1 // Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
40 #include <apgnotif.h> |
40 #include <apgnotif.h> |
41 #include <e32test.h> |
41 #include <e32test.h> |
42 |
42 |
43 #include "appfwk_test_utils.h" |
43 #include "appfwk_test_utils.h" |
44 #include "T_NotifStep.h" |
44 #include "T_NotifStep.h" |
45 #include "T_SisFileInstaller.h" |
|
46 |
|
47 _LIT(KApparcTestAppSisFile, "z:\\apparctest\\apparctestsisfiles\\TApparcTestApp.sis"); |
|
48 _LIT(KApparcTestAppComponent, "TApparcTestApp"); |
|
49 |
|
50 |
45 |
51 _LIT(KImportAppsDir,"c:\\private\\10003a3f\\import\\apps\\"); |
46 _LIT(KImportAppsDir,"c:\\private\\10003a3f\\import\\apps\\"); |
52 _LIT(KResourceAppsDir,"c:\\resource\\apps\\"); |
47 _LIT(KResourceAppsDir,"c:\\resource\\apps\\"); |
53 |
48 |
54 _LIT(KForceRegAppSourcePath_Reg,"Z:\\ApparcTest\\testforceregistrationapp1_reg.rsc"); |
49 _LIT(KForceRegAppSourcePath_Reg,"Z:\\ApparcTest\\testforceregistrationapp1_reg.rsc"); |
143 */ |
138 */ |
144 void CT_NotifStep::TestAppNotificationL() |
139 void CT_NotifStep::TestAppNotificationL() |
145 { |
140 { |
146 // Force the applist to be updated |
141 // Force the applist to be updated |
147 //To ensure that server has time to count all applications in the system |
142 //To ensure that server has time to count all applications in the system |
148 TRequestStatus status; |
143 RPointerArray<TDesC> dummy; |
149 iSession.SetNotify(ETrue, status); |
144 User::LeaveIfError(iSession.ForceRegistration(dummy)); |
150 User::WaitForRequest(status); |
145 |
151 |
|
152 TInt theAppCount = 0; |
146 TInt theAppCount = 0; |
153 TInt theErr1 = iSession.AppCount(theAppCount); |
147 TInt theErr1 = iSession.AppCount(theAppCount); |
154 TEST(theErr1==KErrNone); |
148 TEST(theErr1==KErrNone); |
155 |
149 |
156 INFO_PRINTF2(_L("The number of applications : %d"), theAppCount); |
150 INFO_PRINTF2(_L("The number of applications : %d"), theAppCount); |
159 CleanupStack::PushL(obs); |
153 CleanupStack::PushL(obs); |
160 CApaAppListNotifier* notif=CApaAppListNotifier::NewL(obs,CActive::EPriorityHigh); |
154 CApaAppListNotifier* notif=CApaAppListNotifier::NewL(obs,CActive::EPriorityHigh); |
161 CleanupStack::PushL(notif); |
155 CleanupStack::PushL(notif); |
162 obs->iNotifier=notif; |
156 obs->iNotifier=notif; |
163 INFO_PRINTF1(_L("Creating and deleting apps for notification")); |
157 INFO_PRINTF1(_L("Creating and deleting apps for notification")); |
164 CSisFileInstaller sisFileInstaller; |
158 CreateAppL(_L("AAA")); |
165 INFO_PRINTF2(_L("Installing sis file from -> %S"), &KApparcTestAppSisFile); |
|
166 sisFileInstaller.InstallSisAndWaitForAppListUpdateL(KApparcTestAppSisFile); |
|
167 |
159 |
168 CActiveScheduler::Start(); |
160 CActiveScheduler::Start(); |
169 |
161 |
170 TInt theAppCount1 = 0; |
162 TInt theAppCount1 = 0; |
171 theErr1 = iSession.AppCount(theAppCount1); |
163 theErr1 = iSession.AppCount(theAppCount1); |
172 TEST((theAppCount1 - 1) == theAppCount); |
164 TEST((theAppCount1 - 1) == theAppCount); |
173 INFO_PRINTF2(_L("The number of applications : %d"), theAppCount1); |
165 INFO_PRINTF2(_L("The number of applications : %d"), theAppCount1); |
174 CleanupStack::PopAndDestroy(notif); |
166 CleanupStack::PopAndDestroy(notif); |
175 |
167 |
176 notif = CApaAppListNotifier::NewL(obs,CActive::EPriorityHigh); |
168 notif = CApaAppListNotifier::NewL(obs,CActive::EPriorityHigh); |
177 CleanupStack::PushL(notif); |
169 CleanupStack::PushL(notif); |
178 obs->iNotifier = notif; |
170 obs->iNotifier = notif; |
179 INFO_PRINTF1(_L("Deleting the application")); |
171 INFO_PRINTF1(_L("Deleting the application")); |
180 sisFileInstaller.UninstallSisL(KApparcTestAppComponent); |
172 DeleteAppL(_L("AAA")); |
|
173 |
181 CActiveScheduler::Start(); |
174 CActiveScheduler::Start(); |
182 |
175 |
183 CleanupStack::PopAndDestroy(notif); |
176 CleanupStack::PopAndDestroy(notif); |
|
177 User::LeaveIfError(iSession.ForceRegistration(dummy)); |
184 theErr1 = iSession.AppCount(theAppCount1); |
178 theErr1 = iSession.AppCount(theAppCount1); |
185 |
|
186 TEST(theErr1==KErrNone); |
179 TEST(theErr1==KErrNone); |
187 TEST(theAppCount1 == theAppCount); |
180 TEST(theAppCount1 == theAppCount); |
188 |
181 |
189 INFO_PRINTF2(_L("The number of applications : %d"), theAppCount1); |
182 INFO_PRINTF2(_L("The number of applications : %d"), theAppCount1); |
190 TEST(obs->iNotified>0); |
183 TEST(obs->iNotified>0); |
481 |
474 |
482 TEST(KErrNone == iFs.Connect()); |
475 TEST(KErrNone == iFs.Connect()); |
483 TEST(KErrNone == iSession.Connect()); |
476 TEST(KErrNone == iSession.Connect()); |
484 TEST(KErrNone == iUtils.Connect()); |
477 TEST(KErrNone == iUtils.Connect()); |
485 |
478 |
486 TApaAppInfo info; |
|
487 TUid uid = {0x100048F3}; |
|
488 TInt err = iSession.GetAppInfo(info, uid); |
|
489 if(err == KErrNone) |
|
490 { |
|
491 CSisFileInstaller sisFileInstaller; |
|
492 sisFileInstaller.UninstallSisL(KApparcTestAppComponent); |
|
493 } |
|
494 |
|
495 // run the testcode (inside an alloc heaven harness) |
479 // run the testcode (inside an alloc heaven harness) |
496 __UHEAP_MARK; |
480 __UHEAP_MARK; |
497 iUtils.Connect(); |
481 iUtils.Connect(); |
498 //#if defined (__WINSCW__) |
482 #if defined (__WINSCW__) |
499 // INFO_PRINTF1(_L("T-NotifStep-TTestIconFileNotificationL Test Started...")); |
483 INFO_PRINTF1(_L("T-NotifStep-TTestIconFileNotificationL Test Started...")); |
500 // TRAP(ret,TestIconFileNotificationL()); |
484 TRAP(ret,TestIconFileNotificationL()); |
501 // TEST(ret==KErrNone); |
485 TEST(ret==KErrNone); |
502 // INFO_PRINTF2(_L("TestIconFileNotificationL() finished with return code '%d'\n"), ret); |
486 INFO_PRINTF2(_L("TestIconFileNotificationL() finished with return code '%d'\n"), ret); |
503 //#endif |
487 #endif |
504 INFO_PRINTF1(_L("T-NotifStep-TestAppNotificationL Test Started...")); |
488 INFO_PRINTF1(_L("T-NotifStep-TestAppNotificationL Test Started...")); |
505 TRAP(ret,TestAppNotificationL()); |
489 TRAP(ret,TestAppNotificationL()); |
506 TEST(ret==KErrNone); |
490 TEST(ret==KErrNone); |
507 INFO_PRINTF2(_L("TestAppNotificationL() finished with return code '%d'\n"), ret); |
491 INFO_PRINTF2(_L("TestAppNotificationL() finished with return code '%d'\n"), ret); |
508 |
492 |
509 // INFO_PRINTF1(_L("TestForceRegistrationNotificationL Test Started...")); |
493 INFO_PRINTF1(_L("TestForceRegistrationNotificationL Test Started...")); |
510 // TRAP(ret, TestForceRegistrationNotificationL()); |
494 TRAP(ret, TestForceRegistrationNotificationL()); |
511 // TEST(ret==KErrNone); |
495 TEST(ret==KErrNone); |
512 // INFO_PRINTF2(_L("TestForceRegistrationNotificationL() finished with return code '%d'\n"), ret); |
496 INFO_PRINTF2(_L("TestForceRegistrationNotificationL() finished with return code '%d'\n"), ret); |
513 iUtils.Close(); |
497 iUtils.Close(); |
514 __UHEAP_MARKEND; |
498 __UHEAP_MARKEND; |
515 |
499 |
516 iUtils.Close(); |
500 iUtils.Close(); |
517 iSession.Close(); |
501 iSession.Close(); |