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