localisation/apparchitecture/tef/T_StartAppStep.cpp
branchSymbian3
changeset 57 b8d18c84f71c
parent 6 c108117318cb
equal deleted inserted replaced
56:aa99f2208aad 57:b8d18c84f71c
     1 // Copyright (c) 2005-2009 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 the License "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".
     7 //
     7 //
     8 // Initial Contributors:
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
     9 // Nokia Corporation - initial contribution.
    10 //
    10 //
    11 // Contributors:
    11 // Contributors:
    12 //
    12 //
    13 // Description:
    13 // Description:
    14 //
    14 //
    15 
       
    16 
       
    17 
    15 
    18 /**
    16 /**
    19  @file
    17  @file
    20  @test
    18  @test
    21  @internalComponent - Internal Symbian test code 
    19  @internalComponent - Internal Symbian test code 
   139 	return TestStepResult();
   137 	return TestStepResult();
   140 	}
   138 	}
   141 
   139 
   142 void CT_StartAppTestStep::RunTestCasesL()
   140 void CT_StartAppTestStep::RunTestCasesL()
   143 	{
   141 	{
       
   142 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp8L(), NO_CLEANUP);
   144 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp1L(), NO_CLEANUP);
   143 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp1L(), NO_CLEANUP);
   145 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp2L(), iApaLsSession.FlushRecognitionCache() );
   144 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp2L(), iApaLsSession.FlushRecognitionCache() );
   146 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp3L(), iApaLsSession.FlushRecognitionCache() );
   145 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp3L(), iApaLsSession.FlushRecognitionCache() );
   147 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp4L(), NO_CLEANUP);
   146 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp4L(), NO_CLEANUP);
   148 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp5L(), NO_CLEANUP);
   147 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp5L(), NO_CLEANUP);
   149 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp6L(), NO_CLEANUP);
   148 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp6L(), NO_CLEANUP);
   150 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp7L(), NO_CLEANUP);
   149 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp7L(), NO_CLEANUP);
   151 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp8L(), NO_CLEANUP);
       
   152 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp9L(), NO_CLEANUP);
   150 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp9L(), NO_CLEANUP);
   153 	// The following two APIs InsertDataMappingL() & DeleteDataMappingL(), update the type store on the server side.
   151 	// The following two APIs InsertDataMappingL() & DeleteDataMappingL(), update the type store on the server side.
   154 	// This update takes place on the server side while the test case is still running, which causes the heap check to fail.
   152 	// This update takes place on the server side while the test case is still running, which causes the heap check to fail.
   155 	// To avoid the heap check on the server side, DONT_CHECK macro is used.
   153 	// To avoid the heap check on the server side, DONT_CHECK macro is used.
   156 
   154 
   195 	
   193 	
   196 	_LIT8(KLitDogfish,"dogfish");
   194 	_LIT8(KLitDogfish,"dogfish");
   197 	_LIT(KLitWibble,"wibble");
   195 	_LIT(KLitWibble,"wibble");
   198 	cmdLn->SetExecutableNameL(filename);
   196 	cmdLn->SetExecutableNameL(filename);
   199 	cmdLn->SetTailEndL(KLitDogfish);
   197 	cmdLn->SetTailEndL(KLitDogfish);
   200 	TInt ret = iApaLsSession.StartApp(*cmdLn); // explicit
   198 	TThreadId startAppThreadID;
   201 	TEST(ret==KErrNone);
   199 	TInt ret = iApaLsSession.StartApp(*cmdLn,startAppThreadID); // explicit
   202 
   200 	TEST(ret==KErrNone);
       
   201 
       
   202 	//we need to close the started thread, if appropiate
       
   203 	if (ret==KErrNone)	
       
   204 		{
       
   205 		RThread thread;
       
   206 		User::LeaveIfError(thread.Open(startAppThreadID));
       
   207 		CleanupClosePushL(thread);
       
   208 
       
   209 		RProcess process;
       
   210 		User::LeaveIfError(thread.Process(process));
       
   211 		CleanupClosePushL(process);
       
   212 
       
   213 		process.Kill(0);
       
   214 		
       
   215 		CleanupStack::PopAndDestroy(&process);
       
   216 		CleanupStack::PopAndDestroy(&thread);
       
   217 		}
       
   218 	
   203 	// start a non-existant app
   219 	// start a non-existant app
   204 	cmdLn->SetExecutableNameL(KLitWibble);
   220 	cmdLn->SetExecutableNameL(KLitWibble);
   205 
   221 
   206 	ret = iApaLsSession.StartApp(*cmdLn);
   222 	ret = iApaLsSession.StartApp(*cmdLn);
   207 	TEST(ret==KErrNotFound);
   223 	TEST(ret==KErrNotFound);
   589 	INFO_PRINTF2(_L("returned, %d"), err);
   605 	INFO_PRINTF2(_L("returned, %d"), err);
   590 	TSecurityInfo info;
   606 	TSecurityInfo info;
   591 	info.Set(RProcess());
   607 	info.Set(RProcess());
   592 	
   608 	
   593 	info.iCaps.HasCapability(ECapabilityWriteDeviceData) ? TEST(err==KErrNone) :  TEST(err==KErrPermissionDenied);
   609 	info.iCaps.HasCapability(ECapabilityWriteDeviceData) ? TEST(err==KErrNone) :  TEST(err==KErrPermissionDenied);
   594 	
   610 
       
   611  	TRequestStatus status;
       
   612 	
       
   613  	//Register for notification when data type mappings are restored from the data store ini file
       
   614  	iApaLsSession.NotifyOnDataMappingChange(status);
       
   615   	
   595 	err=iApaLsSession.InsertDataMappingIfHigher(TDataType(KLitPlainText), KPriHigh, KUidTestApp, added);
   616 	err=iApaLsSession.InsertDataMappingIfHigher(TDataType(KLitPlainText), KPriHigh, KUidTestApp, added);
   596 	INFO_PRINTF2(_L("returned, %d"), err);
   617 	INFO_PRINTF2(_L("returned, %d"), err);
   597 	info.iCaps.HasCapability(ECapabilityWriteDeviceData) ? TEST(err==KErrNone && added)  :  TEST(err==KErrPermissionDenied);
   618 	info.iCaps.HasCapability(ECapabilityWriteDeviceData) ? TEST(err==KErrNone && added)  :  TEST(err==KErrPermissionDenied);
       
   619 	
   598 	if (err==KErrNone)
   620 	if (err==KErrNone)
   599 		{
   621 		{
   600 		// Waits till the data type mappings are restored from the data store ini file
   622 		// Waits till the data type mappings are restored from the data store ini file
   601 		iApaLsSession.WaitForTypeStoreUpdate();
   623 		User::WaitForRequest(status);	
       
   624 		TEST(status.Int()==KErrNone);		
       
   625 		}
       
   626 	else
       
   627 		{		
       
   628 		iApaLsSession.CancelNotifyOnDataMappingChange();
       
   629 		TEST(status.Int()==KErrCancel);
   602 		}
   630 		}
   603 	INFO_PRINTF1(_L("Test RApaLsSession::InsertDataMapping....Check data type mapping addition....Done"));
   631 	INFO_PRINTF1(_L("Test RApaLsSession::InsertDataMapping....Check data type mapping addition....Done"));
   604 	}
   632 	}
   605 
   633 
   606 /**
   634 /**
   652 
   680 
   653 void CT_StartAppTestStep::TestDeleteDataTypeL()
   681 void CT_StartAppTestStep::TestDeleteDataTypeL()
   654 	{
   682 	{
   655 	INFO_PRINTF1(_L("Test RApaLsSession::DeleteDataMapping....Check data type mapping deletion"));
   683 	INFO_PRINTF1(_L("Test RApaLsSession::DeleteDataMapping....Check data type mapping deletion"));
   656 
   684 
       
   685 	TRequestStatus status;
       
   686 	
       
   687  	//Register for notification when data type mappings are restored from the data store ini file
       
   688  	iApaLsSession.NotifyOnDataMappingChange(status);
       
   689  	
   657 	TInt err=iApaLsSession.DeleteDataMapping(TDataType(KLitPlainText));
   690 	TInt err=iApaLsSession.DeleteDataMapping(TDataType(KLitPlainText));
   658 	INFO_PRINTF2(_L("returned, %d"), err);
   691 	INFO_PRINTF2(_L("returned, %d"), err);
   659 	TSecurityInfo info;
   692 	TSecurityInfo info;
   660 	info.Set(RProcess());
   693 	info.Set(RProcess());
   661 	
   694 	
   662 	info.iCaps.HasCapability(ECapabilityWriteDeviceData) ? TEST(err==KErrNone) :  TEST(err==KErrPermissionDenied);
   695 	info.iCaps.HasCapability(ECapabilityWriteDeviceData) ? TEST(err==KErrNone) :  TEST(err==KErrPermissionDenied);
   663 	if(err==KErrNone)
   696 
   664 	{
   697 	if (err==KErrNone)
   665 	// Waits till the data type mappings are restored from the data store ini file
   698 		{
   666 	iApaLsSession.WaitForTypeStoreUpdate();	
   699 		// Waits till the data type mappings are restored from the data store ini file
   667 	}
   700 		User::WaitForRequest(status);	
       
   701 		TEST(status.Int()==KErrNone);		
       
   702 		}
       
   703 	else
       
   704 		{		
       
   705 		iApaLsSession.CancelNotifyOnDataMappingChange();
       
   706 		TEST(status.Int()==KErrCancel);
       
   707 		}
   668 	INFO_PRINTF1(_L("Test RApaLsSession::DeleteDataMapping....Check data type mapping deletion....Done"));
   708 	INFO_PRINTF1(_L("Test RApaLsSession::DeleteDataMapping....Check data type mapping deletion....Done"));
   669 	}
   709 	}
   670 	
   710 	
   671 TFileName CT_StartAppTestStep::SearchAndReturnCompleteFileName(const TDesC& aFileName)
   711 TFileName CT_StartAppTestStep::SearchAndReturnCompleteFileName(const TDesC& aFileName)
   672 	{
   712 	{
   694 	TRAPD(err,testIpc.RunFuzzTestL());
   734 	TRAPD(err,testIpc.RunFuzzTestL());
   695 	TEST(err==KErrNone);
   735 	TEST(err==KErrNone);
   696 	CleanupStack::PopAndDestroy(&testIpc);
   736 	CleanupStack::PopAndDestroy(&testIpc);
   697 	INFO_PRINTF1(_L("Test IpcFuzz DEF116002 Completed"));
   737 	INFO_PRINTF1(_L("Test IpcFuzz DEF116002 Completed"));
   698 	}
   738 	}
       
   739