appfw/apparchitecture/tef/T_ControlPanelTest.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".
    46 #include <w32std.h>
    46 #include <w32std.h>
    47 
    47 
    48 #if !defined(__E32TEST_H__)
    48 #if !defined(__E32TEST_H__)
    49 #include <e32test.h>
    49 #include <e32test.h>
    50 #endif
    50 #endif
       
    51 #include "T_SisFileInstaller.h"
    51 
    52 
    52 _LIT(KCompleted, "Completed.");
    53 _LIT(KCompleted, "Completed.");
    53 
    54 
    54 
    55 
    55 _LIT(KRSCDIR,"C:\\Resource\\apps\\");
    56 _LIT(KCtrlApp2SisFile, "z:\\apparctest\\apparctestsisfiles\\app_CTRL2.sis");
    56 _LIT(KRSCREGDIR,"C:\\private\\10003a3f\\import\\apps\\");
    57 _LIT(KCtrlApp2Component, "app_CTRL2");
       
    58 
    57 _LIT(KNEWCTLPATH,"C:\\sys\\bin\\app_CTRL2.exe");
    59 _LIT(KNEWCTLPATH,"C:\\sys\\bin\\app_CTRL2.exe");
    58 _LIT(KSRCRESOURCEPATH,"Z:\\private\\10003a3f\\import\\apps\\App_CTRL2_reg.Rsc");
    60 
    59 _LIT(KDESTRESOURCEPATH,"C:\\private\\10003a3f\\import\\apps\\App_CTRL2_reg.Rsc");
       
    60 
    61 
    61 LOCAL_D TInt SimulateKeyL(TAny*)
    62 LOCAL_D TInt SimulateKeyL(TAny*)
    62 	{
    63 	{
    63 	User::After(3000000);
    64 	User::After(3000000);
    64 	RWsSession session;
    65 	RWsSession session;
    84 	session.Flush();
    85 	session.Flush();
    85 	
    86 	
    86 	session.Close();
    87 	session.Close();
    87 	return KErrNone;
    88 	return KErrNone;
    88 	}
    89 	}
    89 
       
    90 void CT_ControlPanelTestStep::RemoveFilesFromCDrive()
       
    91 	{
       
    92 	TInt ret = iTestServ.SetReadOnly(KDESTRESOURCEPATH,0); //remove READ ONLY option
       
    93 	TEST(ret==KErrNone);
       
    94 
       
    95 	TRAP(ret,iTestServ.DeleteFileL(KDESTRESOURCEPATH));
       
    96 	TEST(ret==KErrNone);
       
    97 	}
       
    98 
       
    99 
       
   100 
    90 
   101 /**
    91 /**
   102   Auxiliary Fn for Test Case ID T-ControlPanelStep-testControls1L,
    92   Auxiliary Fn for Test Case ID T-ControlPanelStep-testControls1L,
   103   T-ControlPanelStep-testControls2L, T-ControlPanelStep-testControls3L
    93   T-ControlPanelStep-testControls2L, T-ControlPanelStep-testControls3L
   104  
    94  
   207 
   197 
   208 void CT_ControlPanelTestStep::testControls2L()
   198 void CT_ControlPanelTestStep::testControls2L()
   209 	{
   199 	{
   210 	INFO_PRINTF1(_L("In testControls2L......"));	
   200 	INFO_PRINTF1(_L("In testControls2L......"));	
   211 	
   201 	
   212 	iTestServ.CreateDirectoryL(KRSCDIR);
   202 	INFO_PRINTF1(_L("Application installing to C Drive......"));
   213 	iTestServ.CreateDirectoryL(KRSCREGDIR);
   203 
   214 
   204     CSisFileInstaller sisFileInstaller;
   215 	TInt ret=iTestServ.CopyFileL(KSRCRESOURCEPATH,KDESTRESOURCEPATH);
   205     INFO_PRINTF2(_L("Installing sis file from -> %S"), &KCtrlApp2SisFile);
   216 	TEST(ret==KErrNone);
   206     sisFileInstaller.InstallSisL(KCtrlApp2SisFile);
   217 	
   207     
   218 	INFO_PRINTF1(_L("Files Copied to C Drive......"));
   208     INFO_PRINTF1(_L("Updating the list ......"));
   219 	INFO_PRINTF1(_L("Updating the list ......"));
   209     TInt ret;
   220 	iControlCount=iControlList->UpdateCount();
   210     iControlCount=iControlList->UpdateCount();
   221 	while(iControlList->UpdateCount()<=iControlCount)
   211 	while(iControlList->UpdateCount()<=iControlCount)
   222 		{
   212 		{
   223 		TRAP(ret, iControlList->UpdateL());
   213 		TRAP(ret, iControlList->UpdateL());
   224 		if(ret!=KErrNone)
   214 		if(ret!=KErrNone)
   225 			{
   215 			{
   236 	iIndex = ControlIndexInList(iControlList,ETrue);
   226 	iIndex = ControlIndexInList(iControlList,ETrue);
   237 	TEST((iIndex >= 0) && (iIndex < iControlCount3));
   227 	TEST((iIndex >= 0) && (iIndex < iControlCount3));
   238 
   228 
   239 	TFileName name=iControlList->Control(iIndex)->FileName();
   229 	TFileName name=iControlList->Control(iIndex)->FileName();
   240 	TEST(name.CompareF(KNEWCTLPATH)==0);
   230 	TEST(name.CompareF(KNEWCTLPATH)==0);
   241 	RemoveFilesFromCDrive();
   231 	
   242 	INFO_PRINTF1(_L("Removed the file from C Drive......"));
   232 	sisFileInstaller.UninstallSisL(KCtrlApp2Component);
       
   233 	INFO_PRINTF1(_L("Removed application from C Drive......"));
   243 	INFO_PRINTF1(_L("Updating the list ......"));
   234 	INFO_PRINTF1(_L("Updating the list ......"));
   244 	iControlCount=iControlList->UpdateCount();
   235 	iControlCount=iControlList->UpdateCount();
   245 	while(iControlList->UpdateCount()<=iControlCount)
   236 	while(iControlList->UpdateCount()<=iControlCount)
   246 		{
   237 		{
   247 		TRAPD(ret, iControlList->UpdateL());
   238 		TRAPD(ret, iControlList->UpdateL());
   447 	User::LeaveIfError(iFs.Connect());
   438 	User::LeaveIfError(iFs.Connect());
   448 	
   439 	
   449 	// connect to the test utils server
   440 	// connect to the test utils server
   450 	User::LeaveIfError(iTestServ.Connect());
   441 	User::LeaveIfError(iTestServ.Connect());
   451 	
   442 	
       
   443 	RApaLsSession ls;
       
   444 	User::LeaveIfError(ls.Connect());
       
   445 	
       
   446 	TRequestStatus status;
       
   447 	ls.SetNotify(ETrue, status);
       
   448 	User::WaitForRequest(status);
       
   449 	ls.Close();
       
   450 	
   452 	// Run the tests...w	
   451 	// Run the tests...w	
   453 	TRAPD(ret,DoStepTestsInCallbackL())
   452 	TRAPD(ret,DoStepTestsInCallbackL())
   454 	TEST(ret==KErrNone);
   453 	TEST(ret==KErrNone);
   455 
   454 
   456 	// Close everything
   455 	// Close everything