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