appfw/apparchitecture/tef/t_drivenotification.cpp
branchRCL_3
changeset 62 924385140d98
parent 0 2e3d3ce01487
child 63 c2c61fdca848
equal deleted inserted replaced
58:0818dd463d41 62:924385140d98
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-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".
    27 */
    27 */
    28 
    28 
    29 #include <e32test.h>
    29 #include <e32test.h>
    30 #include "appfwk_test_utils.h"
    30 #include "appfwk_test_utils.h"
    31 #include "t_drivenotification.h"
    31 #include "t_drivenotification.h"
    32 
    32 #include "T_SisFileInstaller.h"
    33 _LIT(KResourceFileSourceZ, "z:\\system\\data\\tnotifydrivesapp_reg.rsc");
    33 
       
    34 _LIT(KNotifyDriveAppSisFile, "z:\\apparctest\\apparctestsisfiles\\tnotifydrivesapp.sis");
       
    35 _LIT(KNotifyDriveAppComponent, "tnotifydrivesapp");
       
    36 
    34 
    37 
    35 void CDriveTestObserver::HandleAppListEvent(TInt /*aEvent*/)
    38 void CDriveTestObserver::HandleAppListEvent(TInt /*aEvent*/)
    36 	{
    39 	{
    37 	iNotified++;
    40 	iNotified++;
    38 	if (iNotifier)
    41 	if (iNotifier)
    80 	RApaLsSession theLs;
    83 	RApaLsSession theLs;
    81 	User::LeaveIfError(theLs.Connect());
    84 	User::LeaveIfError(theLs.Connect());
    82 	CleanupClosePushL(theLs);
    85 	CleanupClosePushL(theLs);
    83 	
    86 	
    84 	// Wait for applist to be updated.... 
    87 	// Wait for applist to be updated.... 
    85 	RPointerArray<TDesC> dummy;
    88 	TRequestStatus status;
    86 	User::LeaveIfError(theLs.ForceRegistration(dummy));
    89 	theLs.SetNotify(ETrue, status);
       
    90 	User::WaitForRequest(status);
    87 	
    91 	
    88 	//Check whether app is not present in the applist
    92 	//Check whether app is not present in the applist
    89 	TInt ret = theLs.GetAppInfo(appInfo,appUid);
    93 	TInt ret = theLs.GetAppInfo(appInfo,appUid);
    90 	INFO_PRINTF3(_L(" Expected value is %d, Call to GetAppInfo returned : %d  "), KErrNotFound, ret);
    94 	INFO_PRINTF3(_L(" Expected value is %d, Call to GetAppInfo returned : %d  "), KErrNotFound, ret);
    91 	TEST(ret==KErrNotFound);
    95 	TEST(ret==KErrNotFound);
    92 	
    96 	
    93 	//Copy the registration file to C: drive.
    97 	//Install the application.
    94 	CopyRegFileL(EDriveC);
       
    95 	
    98 	
    96 	CDriveTestObserver* obs = new(ELeave) CDriveTestObserver();
    99 	CDriveTestObserver* obs = new(ELeave) CDriveTestObserver();
    97 	CleanupStack::PushL(obs);
   100 	CleanupStack::PushL(obs);
    98 	CApaAppListNotifier* notif = CApaAppListNotifier::NewL(obs, CActive::EPriorityHigh);
   101 	CApaAppListNotifier* notif = CApaAppListNotifier::NewL(obs, CActive::EPriorityHigh);
    99 	CleanupStack::PushL(notif);
   102 	CleanupStack::PushL(notif);
   100 	
   103 	
   101 	obs->iNotifier = notif;
   104 	obs->iNotifier = notif;
   102 		
   105 
       
   106     CSisFileInstaller sisFileInstaller;
       
   107     sisFileInstaller.InstallSisL(KNotifyDriveAppSisFile);
       
   108 	
   103 	CActiveScheduler::Start();
   109 	CActiveScheduler::Start();
   104 	//Since c:\\private\\10003a3f\\Import\\apps\\ path is Monitored, a notification is issued and applist is updated.
   110 	//Since c:\\private\\10003a3f\\Import\\apps\\ path is Monitored, a notification is issued and applist is updated.
   105 	TEST(obs->iNotified > 0);	
   111 	TEST(obs->iNotified > 0);	
   106 	INFO_PRINTF2(_L("Received %d notifications"),obs->iNotified);
   112 	INFO_PRINTF2(_L("Received %d notifications"),obs->iNotified);
   107 	
   113 	
   108 	//Check whether applist is updated and app is present in the applist.
   114 	//Check whether applist is updated and app is present in the applist.
   109 	ret = theLs.GetAppInfo(appInfo,appUid);
   115 	ret = theLs.GetAppInfo(appInfo,appUid);
   110 	INFO_PRINTF3(_L(" Expected value is %d, Call to GetAppInfo returned : %d  "), KErrNone, ret);
   116 	INFO_PRINTF3(_L(" Expected value is %d, Call to GetAppInfo returned : %d  "), KErrNone, ret);
   111 	TEST(ret==KErrNone);
   117 	TEST(ret==KErrNone);
   112 	
   118 	
   113 	//Deleting the rsc file that is present in c:\\private\\10003a3f\\Import\\apps\\ path.
   119 	//Uninstall the application
   114 	DeleteRegFileL(EDriveC);
   120 	sisFileInstaller.UninstallSisAndWaitForAppListUpdateL(KNotifyDriveAppComponent);
   115 	
       
   116 	// Wait for applist to be updated.... 
       
   117 	User::LeaveIfError(theLs.ForceRegistration(dummy));
       
   118 	
   121 	
   119 	//Check whether applist is updated and app is absent in the applist.
   122 	//Check whether applist is updated and app is absent in the applist.
   120 	ret = theLs.GetAppInfo(appInfo,appUid);
   123 	ret = theLs.GetAppInfo(appInfo,appUid);
   121 	INFO_PRINTF3(_L(" Expected value is %d, Call to GetAppInfo returned : %d  "), KErrNotFound, ret);
   124 	INFO_PRINTF3(_L(" Expected value is %d, Call to GetAppInfo returned : %d  "), KErrNotFound, ret);
   122 	TEST(ret==KErrNotFound);
   125 	TEST(ret==KErrNotFound);
   126 	TDriveNumber drive = GetMMCDriveL();
   129 	TDriveNumber drive = GetMMCDriveL();
   127 	
   130 	
   128 	//Copy the registration file to drive specified.
   131 	//Copy the registration file to drive specified.
   129 	CopyRegFileL(drive);
   132 	CopyRegFileL(drive);
   130 	
   133 	
   131 	// Wait for applist to be updated.... 
   134 //	// Wait for applist to be updated.... 
   132 	User::LeaveIfError(theLs.ForceRegistration(dummy));
   135 //	User::LeaveIfError(theLs.ForceRegistration(dummy));
   133 	
   136 	
   134 	//Check whether applist is updated and app is present in the applist.
   137 	//Check whether applist is updated and app is present in the applist.
   135 #ifdef __EABI__
   138 #ifdef __EABI__
   136 	ret = theLs.GetAppInfo(appInfo,appUid);
   139 	ret = theLs.GetAppInfo(appInfo,appUid);
   137 	TEST (ret == KErrNotFound);
   140 	TEST (ret == KErrNotFound);
   141 #else	
   144 #else	
   142 	ret = theLs.GetAppInfo(appInfo,appUid);
   145 	ret = theLs.GetAppInfo(appInfo,appUid);
   143 	TEST(ret==KErrNone);
   146 	TEST(ret==KErrNone);
   144 	INFO_PRINTF3(_L(" Expected value is %d, Call to GetAppInfo returned : %d  "),KErrNone, ret);
   147 	INFO_PRINTF3(_L(" Expected value is %d, Call to GetAppInfo returned : %d  "),KErrNone, ret);
   145 	//Deleting the rsc file.
   148 	//Deleting the rsc file.
   146 	DeleteRegFileL(drive);
   149 //	DeleteRegFileL(drive);
   147 #endif
   150 #endif
   148 	CleanupStack::PopAndDestroy(3, &theLs);
   151 	CleanupStack::PopAndDestroy(3, &theLs);
   149 	
   152 	
   150 	INFO_PRINTF1(_L("End TestDrivesNotificationL()"));
   153 	INFO_PRINTF1(_L("End TestDrivesNotificationL()"));
   151 	}
   154 	}
   182 	ret = smlServer.CreateDirectoryL(tempFolderToBeCreated);
   185 	ret = smlServer.CreateDirectoryL(tempFolderToBeCreated);
   183 	if (ret != KErrNone && ret != KErrAlreadyExists)
   186 	if (ret != KErrNone && ret != KErrAlreadyExists)
   184 		{
   187 		{
   185 		User::LeaveIfError(ret);
   188 		User::LeaveIfError(ret);
   186 		}
   189 		}
   187 	ret = smlServer.CopyFileL(KResourceFileSourceZ, tempPathToBeCopied);
   190 //	ret = smlServer.CopyFileL(KResourceFileSourceZ, tempPathToBeCopied);
   188 	TEST(ret == KErrNone);
   191 	TEST(ret == KErrNone);
   189 	INFO_PRINTF2(_L("Copied Registration file. Finished with the value : %d "), ret);
   192 	INFO_PRINTF2(_L("Copied Registration file. Finished with the value : %d "), ret);
   190 	CleanupStack::PopAndDestroy(4, &fs);
   193 	CleanupStack::PopAndDestroy(4, &fs);
   191 	}
   194 	}
   192 
   195