appfw/apparchitecture/tef/T_ServicesStep.cpp
changeset 0 2e3d3ce01487
child 29 6a787171e1de
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalComponent - Internal Symbian test code 
       
    19 */
       
    20 
       
    21 
       
    22 #include <barsread.h>
       
    23 #include "T_ServicesStep.h"
       
    24 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    25 #include <apaidpartner.h>
       
    26 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
       
    27 
       
    28 _LIT(KCompleted, "Completed.");
       
    29 _LIT8(KLitPlainText,"text/plain");
       
    30 _LIT8(KLitPriorityText,"text/priority");
       
    31 _LIT8(KLitCustom1Text, "text/custom1");
       
    32 
       
    33 /**
       
    34    Constructor
       
    35  */	
       
    36 CT_ServicesTestStep::CT_ServicesTestStep()
       
    37 	{
       
    38 	// Call base class method to set up the human readable name for logging
       
    39 	SetTestStepName(KT_ServicesStep);
       
    40 	}
       
    41 
       
    42 /**
       
    43    Destructor
       
    44  */
       
    45 CT_ServicesTestStep::~CT_ServicesTestStep()
       
    46 	{
       
    47 	iApaLsSession.Close();
       
    48 	}
       
    49 
       
    50 /**
       
    51    @return - TVerdict code
       
    52    Override of base class virtual
       
    53  */	
       
    54 TVerdict CT_ServicesTestStep::doTestStepPreambleL()
       
    55 	{
       
    56 	SetTestStepResult(EPass);
       
    57 	TInt error = iApaLsSession.Connect();
       
    58 	TEST(error==KErrNone);
       
    59 	return TestStepResult();
       
    60 	}
       
    61 
       
    62 /**
       
    63    @return - TVerdict code
       
    64    Override of base class virtual
       
    65  */
       
    66 TVerdict CT_ServicesTestStep::doTestStepPostambleL()
       
    67 	{
       
    68 	return TestStepResult();
       
    69 	}
       
    70 
       
    71 
       
    72 TVerdict CT_ServicesTestStep::doTestStepL()
       
    73 	{
       
    74 	INFO_PRINTF1(_L("Testing Apparc...T_Services Test Cases Running..."));
       
    75 
       
    76 	TInt ret;
       
    77 	TRAP(ret,RunTestCasesL())
       
    78 		TEST(ret==KErrNone);
       
    79 	
       
    80 	INFO_PRINTF1(_L("...T_Services Test Cases Completed."));
       
    81 
       
    82 	return TestStepResult();
       
    83 	}
       
    84 
       
    85 TInt CT_ServicesTestStep::RunTestCasesL()
       
    86 	{
       
    87 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestServiceDiscovery1L(), iApaLsSession.ClearAppInfoArray() );
       
    88 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestServiceDiscovery2L(), iApaLsSession.ClearAppInfoArray() );
       
    89 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestServiceDiscovery3L(), NO_CLEANUP);
       
    90 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestServiceDiscovery4L(), NO_CLEANUP);
       
    91 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestServiceDiscovery5L(), NO_CLEANUP);
       
    92 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestServiceDiscovery6(), NO_CLEANUP);
       
    93 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestServiceDiscovery7L(), NO_CLEANUP);
       
    94 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestServiceDiscovery8L(), NO_CLEANUP);
       
    95 	// The following two APIs InsertDataMappingL() & DeleteDataMappingL(), update the type store on the server side.
       
    96 	// This update takes place on the server side while the test case is still running, which causes the heap check to fail.
       
    97 	// To avoid the heap check on the server side, DONT_CHECK macro is used.
       
    98 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, DONT_CHECK, TestServiceDiscovery9(), NO_CLEANUP );
       
    99 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestServiceDiscovery10L(), NO_CLEANUP);
       
   100 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestServiceDiscovery11L(), NO_CLEANUP);
       
   101 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestServiceDiscovery12L(), NO_CLEANUP);
       
   102 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestServiceDiscovery13L(), NO_CLEANUP);
       
   103 
       
   104 /**	
       
   105 	#ifndef __SECURE_BIN__
       
   106 	__UHEAP_MARK;
       
   107 	TRAP(r,TestServiceDiscovery14L());
       
   108 	TEST(r==KErrNone);
       
   109 	__UHEAP_MARKEND;
       
   110 	#endif
       
   111 	
       
   112 
       
   113 	#ifndef __SECURE_BIN__
       
   114 	__UHEAP_MARK;
       
   115 	TRAP(r,TestServiceDiscovery15L());
       
   116 	TEST(r==KErrNone);
       
   117 	__UHEAP_MARKEND;
       
   118 	#endif
       
   119 	
       
   120 	#ifndef __SECURE_BIN__
       
   121 	__UHEAP_MARK;
       
   122 	TRAP(r,TestServiceDiscovery16L());
       
   123 	TEST(r==KErrNone);
       
   124 	__UHEAP_MARKEND;
       
   125 	#endif
       
   126 */
       
   127 	
       
   128 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestServiceDiscovery17L(), NO_CLEANUP);
       
   129 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestServiceDiscovery18L(), NO_CLEANUP);
       
   130 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestServiceDiscovery19(), NO_CLEANUP);
       
   131 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestServiceDiscovery20L(), NO_CLEANUP);
       
   132 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestServiceDiscovery21L(), NO_CLEANUP);
       
   133 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestServiceDiscovery22(), iApaLsSession.FlushRecognitionCache() );
       
   134 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestServiceDiscovery23(), iApaLsSession.FlushRecognitionCache() );
       
   135 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestServiceDiscovery24(), NO_CLEANUP);
       
   136 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestServiceDiscovery25(), iApaLsSession.FlushRecognitionCache() );
       
   137 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestServiceDiscovery27(), iApaLsSession.FlushRecognitionCache() );
       
   138 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestServiceDiscovery28L(), NO_CLEANUP);
       
   139 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestOpenService1L(), NO_CLEANUP);
       
   140 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestCtrlPnlAppL(), NO_CLEANUP);
       
   141 	// The following two APIs InsertDataMappingL() & DeleteDataMappingL(), update the type store on the server side.
       
   142 	// This update takes place on the server side while the test case is still running, which causes the heap check to fail.
       
   143 	// To avoid the heap check on the server side, DONT_CHECK macro is used.
       
   144 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, DONT_CHECK, TestPrioritySystemL(), NO_CLEANUP );
       
   145 	return (KErrNone);
       
   146 	}
       
   147 	
       
   148 /**
       
   149    @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery1L
       
   150   
       
   151    @SYMPREQ 538
       
   152   
       
   153    @SYMTestCaseDesc Test the functionality of GetServerApps with a service uid that is not provided by any application  
       
   154    
       
   155    @SYMTestPriority 
       
   156    
       
   157    @SYMTestStatus Implemented
       
   158   
       
   159    @SYMTestActions Call GetServerApps with the service uid as parameter.
       
   160    on z: drive.\n
       
   161    API Calls:\n	
       
   162    RApaLsSession::GetServerApps(TUid aServiceUid) const
       
   163    
       
   164    @SYMTestExpectedResults Returns  ENoMoreAppsInList  since no application provides a service represented by the uid
       
   165     
       
   166  */
       
   167 void CT_ServicesTestStep::TestServiceDiscovery1L()
       
   168 	{
       
   169 	INFO_PRINTF1(_L("TestServiceDiscovery1 about to start..."));
       
   170 	const TUid KUidService = {0x01020300}; // service Uid
       
   171 	TInt ret = iApaLsSession.GetServerApps(KUidService);//initialize the list of apps offering service
       
   172 	TEST(ret==KErrNone);// test if initalized properly
       
   173 	TApaAppInfo appInfo;
       
   174 	// populate the list with all the apps and return the first apps
       
   175 	ret = iApaLsSession.GetNextApp(appInfo);
       
   176 	TEST(ret == RApaLsSession::ENoMoreAppsInList);// since no apps implements this service, ENoMoreAppsInList is returned
       
   177 	}
       
   178 
       
   179 /**
       
   180    @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery2L
       
   181   
       
   182    @SYMPREQ 538
       
   183   
       
   184    @SYMTestCaseDesc Test the functionality of GetServerApps with uid that represents a service provided by more that one application 
       
   185    
       
   186    @SYMTestPriority 
       
   187   
       
   188    @SYMTestStatus Implemented
       
   189    
       
   190    @SYMTestActions GetServerApps with a particular service uid as parameter, 
       
   191    making sure that this service uid is used in at least one application 
       
   192    on z: drive.\n
       
   193    API Calls:\n	
       
   194    RApaLsSession::GetServerApps(TUid aServiceUid) const
       
   195    
       
   196    @SYMTestExpectedResults Returns a list of all applications that offers this service
       
   197     
       
   198  */
       
   199 void CT_ServicesTestStep::TestServiceDiscovery2L()
       
   200 	{
       
   201 	INFO_PRINTF1(_L("TestServiceDiscovery2 about to start..."));	
       
   202 	const TUid KUidService1234 = {0x01020304};//uid of service
       
   203 	const TUid KUidServerApp1 = {0x10004c56}; //uid of one server app
       
   204 	const TUid KUidServerApp2 = {0x10004c57};//uid of second server app
       
   205 	TInt ret = iApaLsSession.GetServerApps(KUidService1234);
       
   206 	
       
   207 	TEST(ret==KErrNone);
       
   208 	TApaAppInfo appInfo;
       
   209 	ret = iApaLsSession.GetNextApp(appInfo);
       
   210 	TEST(ret==KErrNone);
       
   211 	TEST((appInfo.iUid==KUidServerApp2) || (appInfo.iUid==KUidServerApp1));
       
   212 	ret = iApaLsSession.GetNextApp(appInfo);
       
   213 	TEST((appInfo.iUid==KUidServerApp2) || (appInfo.iUid==KUidServerApp1));
       
   214 	ret = iApaLsSession.GetNextApp(appInfo);
       
   215 	TEST(ret == RApaLsSession::ENoMoreAppsInList);//only one app implements the service, ENoMoreAppsInList is returned
       
   216 	}
       
   217 
       
   218 /**
       
   219    @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery3L
       
   220   
       
   221    @SYMPREQ 538
       
   222   
       
   223    @SYMTestCaseDesc Test the functionality of GetAppServicesLC to get all the services provided by an application 
       
   224    
       
   225    @SYMTestPriority 
       
   226   
       
   227    @SYMTestStatus Implemented
       
   228    
       
   229    @SYMTestActions Call GetAppServicesLC with the app uid as parameter
       
   230    on z: drive.\n
       
   231    API Calls:\n	
       
   232    RApaLsSession::GetAppServicesLC(TUid aAppUid) const
       
   233    
       
   234    @SYMTestExpectedResults Returns an array of TApaAppServiceInfo objects. Each TApaAppServiceInfo contains details about a service uid and corresponding opaque data. 
       
   235    The returned data should be the same as that defined in the registration files.
       
   236    In the case where the app provides the same services but with different opaque data, it can be checked that the opaque data is different for each service.
       
   237    In the case where a service does not have any defined opaque data, it can be checked that the length of the returned descriptor for the opaque data is zero.
       
   238     
       
   239  */
       
   240 void CT_ServicesTestStep::TestServiceDiscovery3L()
       
   241 	{
       
   242 	INFO_PRINTF1(_L("TestServiceDiscovery3 about to start..."));
       
   243 	const TUid KUidService1234 = {0x01020304};
       
   244 	const TUid KUidService2345 = {0x02030405};
       
   245 	const TUid KUidServerApp = {0x10004c56};
       
   246 	const TUid KUidService5678 = {0x05060708};
       
   247 	const TUid KUidService = {0x01020333};	
       
   248 
       
   249 	// get all services for a particular app
       
   250 	CApaAppServiceInfoArray* array = iApaLsSession.GetAppServicesLC(KUidServerApp);
       
   251 	TArray<TApaAppServiceInfo> serviceArray(array->Array());
       
   252 	TInt count = serviceArray.Count();
       
   253 	TEST(count == 6); // app provides 5 services + 1 legacy open; just to make sure that app provides more than one service
       
   254 
       
   255 	TPtrC8 opaqueData;
       
   256 	TResourceReader reader;
       
   257 	TPtrC16 theText;
       
   258 	TInt val(0);
       
   259 	
       
   260 	_LIT(KFirstService,"Non-localised text for service uid 0x01020304");
       
   261 	_LIT(KSecondService,"Non-localised text for service uid 0x02030405");
       
   262 	_LIT(KThirdService,"Non-localised resource A");
       
   263 	_LIT(KFourthService,"Non-localised resource B");
       
   264 	
       
   265 	TEST(serviceArray[0].Uid()==KOpenServiceUid);
       
   266 	const CArrayFixFlat<TDataTypeWithPriority>& datatypes = serviceArray[0].DataTypes();
       
   267 	TEST(datatypes.Count()==2);
       
   268 	TEST(0 == datatypes[0].iDataType.Des8().CompareF(KLitPlainText));
       
   269 	TEST(0 == datatypes[1].iDataType.Des8().CompareF(KLitPriorityText));
       
   270 	
       
   271 	
       
   272 	TEST(serviceArray[1].Uid()==KUidService1234);
       
   273 	opaqueData.Set(serviceArray[1].OpaqueData());
       
   274 	reader.SetBuffer(&opaqueData); // opaqueData is an LTEXT resource
       
   275 	theText.Set(reader.ReadTPtrC16());
       
   276 	User::LeaveIfError(val = theText.Compare(KFirstService));
       
   277 	TEST(val==KErrNone);
       
   278 	TEST(serviceArray[1].DataTypes().Count()==0);
       
   279 	
       
   280 	TEST(serviceArray[2].Uid()==KUidService2345);
       
   281 	opaqueData.Set(serviceArray[2].OpaqueData());
       
   282 	reader.SetBuffer(&opaqueData);
       
   283 	theText.Set(reader.ReadTPtrC16());
       
   284 	User::LeaveIfError(val=theText.Compare(KSecondService));
       
   285 	TEST(val==KErrNone);
       
   286 	const CArrayFixFlat<TDataTypeWithPriority>& datatypes2 = 
       
   287 		serviceArray[2].DataTypes();
       
   288 	TEST(datatypes2.Count()==1);
       
   289 	TEST(0 == datatypes2[0].iDataType.Des8().CompareF(KLitCustom1Text));
       
   290 	
       
   291 	TEST(serviceArray[3].Uid()==KUidService5678);
       
   292 	opaqueData.Set(serviceArray[3].OpaqueData());
       
   293 	reader.SetBuffer(&opaqueData); // opaqueData is an LTEXT resource
       
   294 	theText.Set(reader.ReadTPtrC16());
       
   295 	User::LeaveIfError(val = theText.Compare(KThirdService));
       
   296 	TEST(val==KErrNone);
       
   297 	TEST(serviceArray[3].DataTypes().Count()==0);
       
   298 	
       
   299 	TEST(serviceArray[4].Uid()==KUidService5678);
       
   300 	opaqueData.Set(serviceArray[4].OpaqueData());
       
   301 	reader.SetBuffer(&opaqueData);
       
   302 	theText.Set(reader.ReadTPtrC16());
       
   303 	User::LeaveIfError(val=theText.Compare(KFourthService));
       
   304 	TEST(val==KErrNone);
       
   305 	TEST(serviceArray[4].DataTypes().Count()==0);
       
   306 	
       
   307 	TUid myuid = serviceArray[5].Uid();
       
   308 	TEST(myuid==KUidService);
       
   309 	opaqueData.Set(serviceArray[5].OpaqueData());
       
   310 	TEST(opaqueData.Length()==0);
       
   311 	TEST(serviceArray[5].DataTypes().Count()==0);
       
   312 	
       
   313 	CleanupStack::PopAndDestroy(array); // the servicearray
       
   314 	array = NULL;
       
   315 	}
       
   316 
       
   317 /**
       
   318    @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery4L
       
   319   
       
   320    @SYMPREQ 538
       
   321   
       
   322    @SYMTestCaseDesc Test the functionality of GetServiceImplementationsLC 
       
   323    which gets all the implementation details about a specific service 
       
   324    
       
   325    @SYMTestPriority High 
       
   326   
       
   327    @SYMTestStatus Implemented
       
   328    
       
   329    @SYMTestActions Call GetServiceImplementationsLC with the service uid as parameter
       
   330    on z: drive.\n
       
   331    API Calls:\n	
       
   332    RApaLsSession::GetServiceImplementationsLC(TUid aServiceUid) const
       
   333    
       
   334    @SYMTestExpectedResults Returns an array of TApaAppServiceInfo objects. 
       
   335    The size of the array is equal to the number of apps offering this service. 
       
   336    Each TApaAppServiceInfo contain an app uid and  the respective opaquedata. 
       
   337    The returned data should be the same as that defined in the registration files.
       
   338     
       
   339  */
       
   340 void CT_ServicesTestStep::TestServiceDiscovery4L()
       
   341 	{
       
   342 	INFO_PRINTF1(_L("TestServiceDiscovery4 about to start..."));
       
   343 	const TUid KUidService1234 = {0x01020304};
       
   344 	const TUid KUidServerApp1 = {0x10004c56};
       
   345 	const TUid KUidServerApp2 = {0x10004c57};
       
   346 	CApaAppServiceInfoArray* array = iApaLsSession.GetServiceImplementationsLC(KUidService1234);
       
   347 	TArray<TApaAppServiceInfo> implArray(array->Array());
       
   348 	TInt count = implArray.Count();	
       
   349 	TEST(count==2);
       
   350 	_LIT(KService,"Non-localised text for service uid 0x01020304");
       
   351 	TPtrC8 opaqueData;
       
   352 	TResourceReader reader;
       
   353 	TPtrC16 theText;
       
   354 	TInt val(0);
       
   355 
       
   356 	TUid myuid = implArray[0].Uid(); 
       
   357 	// The services can appear in any order
       
   358 	if (myuid==KUidServerApp1)
       
   359 		{
       
   360 		TEST(myuid==KUidServerApp1);
       
   361 		myuid = implArray[1].Uid();
       
   362 		TEST(myuid==KUidServerApp2);
       
   363 		const CArrayFixFlat<TDataTypeWithPriority>& datatypes = implArray[1].DataTypes();
       
   364 		TEST(datatypes.Count()==1);
       
   365 		TEST(0 == datatypes[0].iDataType.Des8().CompareF(KLitCustom1Text));
       
   366 		}
       
   367 	else if (myuid==KUidServerApp2)
       
   368 		{
       
   369 		TEST(myuid==KUidServerApp2);
       
   370 		myuid = implArray[1].Uid();
       
   371 		TEST(myuid==KUidServerApp1);
       
   372 		const CArrayFixFlat<TDataTypeWithPriority>& datatypes = implArray[0].DataTypes();
       
   373 		TEST(datatypes.Count()==1);
       
   374 		TEST(0 == datatypes[0].iDataType.Des8().CompareF(KLitCustom1Text));
       
   375 		}
       
   376 
       
   377 	opaqueData.Set(implArray[0].OpaqueData());
       
   378 	reader.SetBuffer(&opaqueData); // opaqueData is an LTEXT resource
       
   379 	theText.Set(reader.ReadTPtrC16());
       
   380 	User::LeaveIfError(val = theText.Compare(KService));
       
   381 	TEST(val==KErrNone);
       
   382 
       
   383 	opaqueData.Set(implArray[1].OpaqueData());
       
   384 	reader.SetBuffer(&opaqueData); // opaqueData is an LTEXT resource
       
   385 	theText.Set(reader.ReadTPtrC16());
       
   386 	User::LeaveIfError(val = theText.Compare(KService));
       
   387 	TEST(val==KErrNone);
       
   388 
       
   389 	CleanupStack::PopAndDestroy(array);
       
   390 	array = NULL;
       
   391 	}
       
   392 	
       
   393 /**
       
   394    @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery5L
       
   395   
       
   396    @SYMPREQ 538
       
   397   
       
   398    @SYMTestCaseDesc Test the functionality of GetAppServicesL which gets all the service uids of a particular app 
       
   399    
       
   400    @SYMTestPriority 
       
   401   
       
   402    @SYMTestStatus Implemented
       
   403    
       
   404    @SYMTestActions Call GetAppServicesL with two parameters: the app uid and an array to put in the uid of the services 
       
   405    on z: drive.\n
       
   406    API Calls:\n	
       
   407    RApaLsSession::GetAppServicesL(TUid aAppUid, CArrayFixFlat<TUid>& aServiceUids) const
       
   408    
       
   409    @SYMTestExpectedResults Populates the array with the uids of the services offered by this particular app. 
       
   410    The returned data should be the same as that defined in the registration files. 
       
   411     
       
   412  */
       
   413 void CT_ServicesTestStep::TestServiceDiscovery5L()
       
   414 	{
       
   415 	INFO_PRINTF1(_L("TestServiceDiscovery5 about to start..."));
       
   416 	const TUid KUidServerApp = {0x10004c56};
       
   417 	const TUid KUidService1234 = {0x01020304};
       
   418 	const TUid KUidService2345 = {0x02030405};
       
   419 	const TUid KUidService5678 = {0x05060708};
       
   420 	const TUid KUidService = {0x01020333};
       
   421 	// get UIDs of all services implemented by an app
       
   422 	CArrayFixFlat<TUid>* uidArray = new(ELeave) CArrayFixFlat<TUid>(4);
       
   423 	CleanupStack::PushL(uidArray);
       
   424 	iApaLsSession.GetAppServicesL(KUidServerApp,*uidArray);
       
   425 	TInt count = uidArray->Count();
       
   426 	TUid uid;
       
   427 	if(count>0)
       
   428 		{
       
   429 		TEST(count==6);	// Takes into account the open service
       
   430 		uid = (*uidArray)[0];
       
   431 		TEST(uid==KUidService);
       
   432 		uid = (*uidArray)[1];
       
   433 		TEST(uid==KUidService5678);
       
   434 		uid = (*uidArray)[2];
       
   435 		TEST(uid==KUidService5678);
       
   436 		uid = (*uidArray)[3];
       
   437 		TEST(uid==KUidService2345);
       
   438 		uid = (*uidArray)[4];
       
   439 		TEST(uid==KUidService1234);
       
   440 		}
       
   441 	CleanupStack::PopAndDestroy(uidArray);
       
   442 	uidArray = NULL;
       
   443 	}
       
   444 
       
   445 /**
       
   446    @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery6
       
   447   
       
   448    @SYMPREQ 538
       
   449   
       
   450    @SYMTestCaseDesc Test for the functionality AppForDataTypeAndService in the case where two apps 
       
   451    provides have the same datatype definition in their registration file. One app offers the requested 
       
   452    service but has its priority assigned to normal while the other app does not offer the requested 
       
   453    service and has its priority assigned to high 
       
   454   
       
   455    @SYMTestPriority 
       
   456   
       
   457    @SYMTestStatus Implemented
       
   458    
       
   459    @SYMTestActions Call AppForDataTypeAndService with three parameters: the datatype, the service uid 
       
   460    and an unitialised app uid
       
   461    on z: drive.\n
       
   462    API Calls:\n	
       
   463    RApaLsSession::AppForDataTypeAndService(const TDataType& aDataType, TUid aServiceUid, TUid& aAppUid) const
       
   464    
       
   465    @SYMTestExpectedResults Sets the app uid to that of the app with lower priority since the one with higher 
       
   466    priority does not offer this service
       
   467     
       
   468  */
       
   469 void CT_ServicesTestStep::TestServiceDiscovery6()
       
   470 	{
       
   471 	INFO_PRINTF1(_L("TestServiceDiscovery6 about to start..."));
       
   472 	const TUid KUidServerAppHigh = {0x10004c57};
       
   473 	const TUid KUidService = {0x02030405};
       
   474 	const TUid KUidServerAppNormal = {0x10004c56};	
       
   475 	_LIT8(KLitMimeTypeServerAppData,"text/priority");
       
   476 	TUid appUid;
       
   477 	TInt ret(0);
       
   478 	ret=iApaLsSession.AppForDataTypeAndService(TDataType(KLitMimeTypeServerAppData), KUidService,appUid);
       
   479 	TEST(ret==KErrNone);
       
   480 	TEST(appUid != KUidServerAppHigh);
       
   481 	TEST(appUid == KUidServerAppNormal);
       
   482 	}
       
   483 
       
   484 /**
       
   485    @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery7L
       
   486   
       
   487    @SYMPREQ 538
       
   488   
       
   489    @SYMTestCaseDesc Given the size of data that is returned from the server is greater than the default 
       
   490    1024 bytes of the buffer, test if a larger buffer is assigned in such cases
       
   491    
       
   492    @SYMTestPriority 
       
   493   
       
   494    @SYMTestStatus Implemented
       
   495    
       
   496    @SYMTestActions Call GetAppServicesLC with the app uid as parameter. The size of the resource data in 
       
   497    the registration file should be greater than the default size.
       
   498    on z: drive.\n
       
   499    API Calls:\n	
       
   500    RApaLsSession::GetAppServicesLC(TUid aAppUid) const
       
   501    
       
   502    @SYMTestExpectedResults A larger buffer is allocated. The size of the buffer can be tested by checking 
       
   503    the size of the returned data.
       
   504     
       
   505  */
       
   506 void CT_ServicesTestStep::TestServiceDiscovery7L()
       
   507 	{
       
   508 	INFO_PRINTF1(_L("TestServiceDiscovery7 about to start..."));
       
   509 	const TUid KUidServerApp = {0x10004c57};
       
   510 	// get all services for a particular app
       
   511 	CApaAppServiceInfoArray* array = iApaLsSession.GetAppServicesLC(KUidServerApp);
       
   512 	TArray<TApaAppServiceInfo> serviceArray(array->Array());
       
   513 	TInt count = serviceArray.Count();
       
   514 	TEST(count == 16);
       
   515 	TPtrC8 opaqueData;
       
   516 	TInt size(0);
       
   517 	for(TInt i=0;i<count;i++)
       
   518 		{
       
   519 			opaqueData.Set(serviceArray[i].OpaqueData());
       
   520 			size +=opaqueData.Length(); 
       
   521 		}
       
   522 	TEST(size>=1024);
       
   523 	CleanupStack::PopAndDestroy(array); // the servicearray	
       
   524 	array = NULL;
       
   525 	}
       
   526 
       
   527 /**
       
   528    @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery8L
       
   529   
       
   530    @SYMPREQ 538
       
   531   
       
   532    @SYMTestCaseDesc Test for the functionality of GetAppServiceOpaqueDataLC, particularly in the case 
       
   533    where an app offers two services with the same uid but different opaque data
       
   534    
       
   535    @SYMTestPriority 
       
   536   
       
   537    @SYMTestStatus Implemented
       
   538    
       
   539    @SYMTestActions Call GetAppServiceOpaqueDataLC with two parameters: an app uid and a service uid
       
   540    on z: drive.\n
       
   541    API Calls:\n	
       
   542    RApaLsSession::GetAppServiceOpaqueDataLC(TUid aAppUid, TUid aServiceUid) const
       
   543    
       
   544    @SYMTestExpectedResults Returns an array of TApaAppServiceInfo objects. Each TApaAppServiceInfo object 
       
   545    contains the same service uid but different opaque data. The returned data should be the same as that 
       
   546    defined in the registration files.
       
   547     
       
   548  */
       
   549 void CT_ServicesTestStep::TestServiceDiscovery8L()
       
   550 	{
       
   551 	INFO_PRINTF1(_L("TestServiceDiscovery8 about to start..."));
       
   552 	const TUid KUidServerApp = {0x10004c56};
       
   553 	const TUid KUidService = {0x05060708};	
       
   554 	CApaAppServiceInfoArray* array = iApaLsSession.GetAppServiceOpaqueDataLC(KUidServerApp, KUidService);
       
   555 	TArray<TApaAppServiceInfo> implArray(array->Array());
       
   556 	TInt count = implArray.Count();
       
   557 	_LIT(KFirstService,"Non-localised resource A");
       
   558 	_LIT(KSecondService,"Non-localised resource B");
       
   559 	TPtrC8 opaqueData;
       
   560 	TResourceReader reader;
       
   561 	TPtrC16 theText;
       
   562 		if(count>0)
       
   563 		{
       
   564 		TEST(count==2);
       
   565 		
       
   566 		TEST(implArray[0].Uid()==KUidService);
       
   567 		opaqueData.Set(implArray[0].OpaqueData());
       
   568 		reader.SetBuffer(&opaqueData); // opaqueData is an LTEXT resource
       
   569 		theText.Set(reader.ReadTPtrC16());
       
   570 		TInt val(0);
       
   571 		User::LeaveIfError(val=theText.Compare(KSecondService));
       
   572 		TEST(val==KErrNone);
       
   573 		TEST(implArray[1].Uid()==KUidService);
       
   574 		opaqueData.Set(implArray[1].OpaqueData());
       
   575 		reader.SetBuffer(&opaqueData); // opaqueData is an LTEXT resource
       
   576 		theText.Set(reader.ReadTPtrC16());
       
   577 		User::LeaveIfError(val=theText.Compare(KFirstService));
       
   578 		TEST(val==KErrNone);	
       
   579 		}
       
   580 	
       
   581 	CleanupStack::PopAndDestroy(array);
       
   582 	array = NULL;
       
   583 	}
       
   584 	
       
   585 /**
       
   586    @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery9
       
   587   
       
   588    @SYMPREQ 538
       
   589   
       
   590    @SYMTestCaseDesc Test the functionality of AppForDataTypeAndService in the cases where 
       
   591    (a) the datatype is not defined in the registration file 
       
   592    (b) the data type is defined in the registration file
       
   593    
       
   594    @SYMTestPriority 
       
   595   
       
   596    @SYMTestStatus Implemented
       
   597    
       
   598    @SYMTestActions (a)Call InsertDataMapping to make a mapping between the datatype and app. The parameters 
       
   599    used are: the datatype object, the priority assigned and the app uid Call AppForDataTypeAndService with 
       
   600    the three parameters: the data type, the service uid and an unitialised uid for the returning value. 
       
   601    Call DeleteDataMapping with the datatype object as parameter to delete this mapping
       
   602    (b) Call AppForDataTypeAndService with the three parameters: the data type, the service uid and an 
       
   603    unitialised uid for the returning value.
       
   604    on z: drive.\n
       
   605    API Calls:\n	
       
   606    RApaLsSession::AppForDataTypeAndService(const TDataType& aDataType, TUid aServiceUid, TUid& aAppUid) const
       
   607    
       
   608    @SYMTestExpectedResults (a) Returns the app uid of the app that has this datatype and service requested. 
       
   609    It can be checked that the app uid corresponds to the app to which the mapping has been inserted.
       
   610    (b) Returns the uid of the app that has this datatype and service uid defined in its registration file.
       
   611     
       
   612  */
       
   613 void CT_ServicesTestStep::TestServiceDiscovery9()
       
   614 	{
       
   615 	INFO_PRINTF1(_L("TestServiceDiscovery9 about to start..."));
       
   616 	const TUid KUidService1234 = {0x01020304};
       
   617 	const TUid KUidServerApp = {0x10004c56};
       
   618 
       
   619 	TInt ret(0);
       
   620 	// Start AppForDataTypeAndService test cases
       
   621 	// make sure our data mapping is removed before executing the following test cases
       
   622 	_LIT8(KLitMimeTypeServerApp,"serverapp/data");
       
   623 	_LIT8(KLitMimeTypeServerAppData,"text/plain");
       
   624 	ret = iApaLsSession.InsertDataMapping(TDataType(KLitMimeTypeServerApp),
       
   625 	 	1, KUidServerApp, KUidService1234); // need to remove magic number
       
   626 	TEST(ret==KErrNone);
       
   627 	// Waits till the data type mappings are restored from the data store ini file
       
   628 	iApaLsSession.WaitForTypeStoreUpdate();
       
   629 	TUid appUid;
       
   630 	ret=iApaLsSession.AppForDataTypeAndService(TDataType(KLitMimeTypeServerApp), KUidService1234,appUid);
       
   631 	TEST(ret==KErrNone);
       
   632 	// KUidServerApp2 handles KLitMimeTypeJpeg with a higher priority than KUidServerApp,
       
   633 	// but doesn't implement service KUidService1234, so KUidServerApp should be returned
       
   634 	TEST(appUid == KUidServerApp);
       
   635 	ret = iApaLsSession.DeleteDataMapping(TDataType(KLitMimeTypeServerApp),KUidService1234);
       
   636 	TEST(ret==KErrNone);
       
   637 	// Waits till the data type mappings are restored from the data store ini file
       
   638 	iApaLsSession.WaitForTypeStoreUpdate();
       
   639 	ret=iApaLsSession.AppForDataTypeAndService(TDataType(KLitMimeTypeServerAppData), KUidService1234,appUid);
       
   640 	TEST(ret==KErrNone);
       
   641 	TEST(appUid == KUidServerApp);
       
   642 	}
       
   643 
       
   644 /**
       
   645    @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery10L
       
   646   
       
   647    @SYMPREQ 538
       
   648   
       
   649    @SYMTestCaseDesc Test the functionality of GetAppServicesLC on an app that does not provide any service
       
   650    
       
   651    @SYMTestPriority 
       
   652   
       
   653    @SYMTestStatus Implemented
       
   654    
       
   655    @SYMTestActions Call GetAppServicesLC with the app uid as parameter
       
   656    on z: drive.\n
       
   657    API Calls:\n	
       
   658    RApaLsSession::GetAppServicesLC(TUid aAppUid) const
       
   659    
       
   660    @SYMTestExpectedResults Returns KErrNotFound
       
   661     
       
   662  */
       
   663 void CT_ServicesTestStep::TestServiceDiscovery10L()
       
   664 	{
       
   665 	INFO_PRINTF1(_L("TestServiceDiscovery10 about to start..."));
       
   666 	const TUid KUidServerApp = {0x01023450};
       
   667 	TRAPD(r, iApaLsSession.GetAppServicesLC(KUidServerApp));
       
   668 	TEST(r==KErrNotFound);
       
   669 	}
       
   670 
       
   671 /**
       
   672    @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery11L
       
   673   
       
   674    @SYMPREQ 538
       
   675   
       
   676    @SYMTestCaseDesc Test the functionality of GetServiceImplementationsLC using a service uid that is 
       
   677    not defined in any registration file
       
   678    
       
   679    @SYMTestPriority high
       
   680   
       
   681    @SYMTestStatus Implemented
       
   682    
       
   683    @SYMTestActions Call GetServiceImplementationsLC using a service uid not defined in any registration file
       
   684    on z: drive.\n
       
   685    API Calls:\n	
       
   686    RApaLsSession::GetServiceImplementationsLC(TUid aServiceUid) const
       
   687    
       
   688    @SYMTestExpectedResults Returns KErrNotFound
       
   689     
       
   690  */
       
   691 void CT_ServicesTestStep::TestServiceDiscovery11L()
       
   692 	{
       
   693 	INFO_PRINTF1(_L("TestServiceDiscovery11 about to start..."));
       
   694 	const TUid KUidService1230 = {0x01020300};
       
   695 	TRAPD(r, iApaLsSession.GetServiceImplementationsLC(KUidService1230));
       
   696 	TEST(r==KErrNotFound);
       
   697 	}
       
   698 
       
   699 /**
       
   700    @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery12L
       
   701   
       
   702    @SYMPREQ 538
       
   703   
       
   704    @SYMTestCaseDesc Test the functionality of GetAppServicesL for an app that does not exist
       
   705    
       
   706    @SYMTestPriority 
       
   707   
       
   708    @SYMTestStatus Implemented
       
   709    
       
   710    @SYMTestActions Call GetAppServicesL using an app uid that is not used by any app
       
   711    on z: drive.\n
       
   712    API Calls:\n	
       
   713    RApaLsSession::GetAppServicesL(TUid aAppUid, CArrayFixFlat<TUid>& aServiceUids) const
       
   714    
       
   715    @SYMTestExpectedResults Returns KErrNotFound
       
   716     
       
   717  */
       
   718 void CT_ServicesTestStep::TestServiceDiscovery12L()
       
   719 	{
       
   720 	INFO_PRINTF1(_L("TestServiceDiscovery12 about to start..."));
       
   721 	const TUid KUidServerApp = {0x01020300};
       
   722 	CArrayFixFlat<TUid>* uidArray = new(ELeave) CArrayFixFlat<TUid>(4);
       
   723 	CleanupStack::PushL(uidArray);
       
   724 	TRAPD(r,iApaLsSession.GetAppServicesL(KUidServerApp,*uidArray));
       
   725 	CleanupStack::PopAndDestroy(uidArray);
       
   726 	TEST(r==KErrNotFound);
       
   727 	}
       
   728 
       
   729 /**
       
   730    @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery13L
       
   731   
       
   732    @SYMPREQ 538
       
   733   
       
   734    @SYMTestCaseDesc Test the functionality of GetAppServiceOpaqueDataLC on an app that does 
       
   735    not provide a particular service
       
   736    
       
   737    @SYMTestPriority 
       
   738   
       
   739    @SYMTestStatus Implemented
       
   740    
       
   741    @SYMTestActions Call GetAppServicesL using an existing app uid and service uid that is not 
       
   742    defined in its registration file
       
   743    on z: drive.\n
       
   744    API Calls:\n	
       
   745    RApaLsSession::GetAppServiceOpaqueDataLC(TUid aAppUid, TUid aServiceUid) const
       
   746    
       
   747    @SYMTestExpectedResults Returns KErrNotFound
       
   748     
       
   749  */
       
   750  void CT_ServicesTestStep::TestServiceDiscovery13L()
       
   751 	{
       
   752 	INFO_PRINTF1(_L("TestServiceDiscovery13 about to start..."));	
       
   753 	const TUid KUidServerApp = {0x01023456};
       
   754 	const TUid KUidService = {0x05060708};	
       
   755 	TRAPD(r,iApaLsSession.GetAppServiceOpaqueDataLC(KUidServerApp, KUidService));
       
   756 	TEST(r==KErrNotFound);
       
   757 	}
       
   758 
       
   759 
       
   760 
       
   761 
       
   762 
       
   763 /**
       
   764    @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery17L
       
   765   
       
   766    @SYMPREQ 538
       
   767   
       
   768    @SYMTestCaseDesc Test the functionality of GetAppServicesLC on a app that has a localised 
       
   769    resource defined in the registration file
       
   770   
       
   771    @SYMTestStatus Implemented
       
   772 
       
   773    @SYMTestPriority  High
       
   774    
       
   775    @SYMTestActions  Call GetAppServicesLC with the app uid as parameter
       
   776    on z: drive.\n
       
   777    API Calls:\n	
       
   778    RApaLsSession::GetAppServicesLC(TUid aAppUid) const
       
   779    
       
   780    @SYMTestExpectedResults Returns an array of TApaAppServiceInfo objects. 
       
   781    Each TApaAppServiceInfo contains details about a service uid and corresponding opaque data. 
       
   782    The returned data should be the same as that defined in the registration files.
       
   783     
       
   784  */
       
   785 void CT_ServicesTestStep::TestServiceDiscovery17L() 
       
   786 	{
       
   787 	INFO_PRINTF1(_L("TestServiceDiscovery17 about to start..."));
       
   788 	const TUid KUidService1235 = {0x01020305};
       
   789 	const TUid KUidServerApp = {0x10004c55};
       
   790 	CApaAppServiceInfoArray* array = iApaLsSession.GetAppServicesLC(KUidServerApp);
       
   791 	TArray<TApaAppServiceInfo> serviceArray(array->Array());
       
   792 	TInt count = serviceArray.Count();
       
   793 	TEST(count == 1);
       
   794 	TPtrC8 opaqueData;
       
   795 	TResourceReader reader;
       
   796 	TPtrC16 theText;
       
   797 	TInt val(0);
       
   798 	_LIT(KSecondService,"Localised text for service UID 0x01020305");
       
   799 	TEST(serviceArray[0].Uid()==KUidService1235);
       
   800 	opaqueData.Set(serviceArray[0].OpaqueData());
       
   801 	reader.SetBuffer(&opaqueData);
       
   802 	theText.Set(reader.ReadTPtrC16());
       
   803 	User::LeaveIfError(val=theText.Compare(KSecondService));
       
   804 	TEST(val==KErrNone);
       
   805 	CleanupStack::PopAndDestroy(array); // the servicearray
       
   806 	}
       
   807 
       
   808 /**
       
   809    @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery18L
       
   810   
       
   811    @SYMPREQ 538
       
   812   
       
   813    @SYMTestCaseDesc Test the functionality of GetAppServicesLC on a app that has a localised resource
       
   814    defined but the link to the resource file not specified in the registration file
       
   815   
       
   816    @SYMTestStatus Implemented
       
   817    
       
   818    @SYMTestPriority  High	
       
   819    
       
   820    @SYMTestActions  Call GetAppServicesLC with the app uid as parameter
       
   821    on z: drive.\n
       
   822    API Calls:\n	
       
   823    RApaLsSession::GetAppServicesLC(TUid aAppUid) const
       
   824    
       
   825    @SYMTestExpectedResults Returns KErrNone
       
   826     
       
   827  */
       
   828 void CT_ServicesTestStep::TestServiceDiscovery18L() 
       
   829 	{
       
   830 	INFO_PRINTF1(_L("TestServiceDiscovery18 about to start..."));	
       
   831 	const TUid KUidServerApp = {0x10004c54};
       
   832 	TRAPD(r, CleanupStack::PopAndDestroy(iApaLsSession.GetAppServicesLC(KUidServerApp)));
       
   833 	TEST(r==KErrNone);
       
   834 	}
       
   835 	
       
   836 /**
       
   837    @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery19
       
   838   
       
   839    @SYMPREQ 538
       
   840   
       
   841    @SYMTestPriority  High
       
   842 
       
   843    @SYMTestCaseDesc Test the functionality of AppForDataTypeAndService in the cases where
       
   844    (a) the datatype requested is undefined for a particular service uid
       
   845    (b) the service uid is not defined for any app
       
   846   
       
   847    @SYMTestStatus Implemented
       
   848    
       
   849    @SYMTestActions  Call AppForDataTypeAndService with the three parameters: the data type, 
       
   850    the service uid and an unitialised uid for the returning value.
       
   851    on z: drive.\n
       
   852    API Calls:\n	
       
   853    RApaLsSession::AppForDataTypeAndService(const TDataType& aDataType, TUid aServiceUid, TUid& aAppUid) const
       
   854    
       
   855    @SYMTestExpectedResults In both cases, the app uid value is set to null
       
   856     
       
   857  */
       
   858 void CT_ServicesTestStep::TestServiceDiscovery19()
       
   859 	{
       
   860 	INFO_PRINTF1(_L("TestServiceDiscovery19 about to start..."));	
       
   861 	_LIT8(KLitMimeTypeServerAppData,"text/rubbish");
       
   862 	_LIT8(KLitMimeTypeServerApp,"serverapp/data");
       
   863 	TUid appUid=KNullUid;
       
   864 	TInt ret(0);
       
   865 	const TUid KUidService = {0x01020304};
       
   866 	const TUid KUidServiceUnused = {0x01020300};
       
   867 	ret=iApaLsSession.AppForDataTypeAndService(TDataType(KLitMimeTypeServerAppData), KUidService,appUid);
       
   868 	TEST(ret==KErrNone);
       
   869 	TEST(appUid == KNullUid);
       
   870 	ret=iApaLsSession.AppForDataTypeAndService(TDataType(KLitMimeTypeServerApp), KUidServiceUnused,appUid);
       
   871 	TEST(ret==KErrNone);
       
   872 	TEST(appUid == KNullUid);
       
   873 	}
       
   874 
       
   875 /**
       
   876    @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery20L
       
   877   
       
   878    @SYMPREQ 538
       
   879   
       
   880    @SYMTestPriority  High
       
   881 
       
   882    @SYMTestCaseDesc Test the functionality of GetAppServicesLC to get all the services 
       
   883    provided by an application that does not exist
       
   884   
       
   885    @SYMTestStatus Implemented
       
   886    
       
   887    @SYMTestActions  Call GetAppServicesLC with the app uid as parameter
       
   888  
       
   889    on z: drive.\n
       
   890    API Calls:\n	
       
   891    RApaLsSession::GetAppServicesLC(TUid aAppUid) const
       
   892    
       
   893    @SYMTestExpectedResults Returns KErrNotFound
       
   894     
       
   895  */	
       
   896 void CT_ServicesTestStep::TestServiceDiscovery20L()
       
   897 	{
       
   898 	INFO_PRINTF1(_L("TestServiceDiscovery20 about to start..."));
       
   899 	const TUid KUidServerApp = {0x10001111};
       
   900 	// get all services for a particular app
       
   901 	TRAPD(r,iApaLsSession.GetAppServicesLC(KUidServerApp));
       
   902 	TEST(r==KErrNotFound);			
       
   903 	}
       
   904 
       
   905 /**
       
   906    @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery21L
       
   907   
       
   908    @SYMPREQ 538
       
   909   
       
   910    @SYMTestPriority  High
       
   911   
       
   912    @SYMTestCaseDesc Test the functionality of GetAppServiceOpaqueDataLC on an app that does not exist
       
   913    
       
   914    @SYMTestStatus Implemented
       
   915    
       
   916    @SYMTestActions  Call GetAppServiceOpaqueDataLC with two parameters: an app uid and a service uid
       
   917  
       
   918    on z: drive.\n
       
   919    API Calls:\n	
       
   920    RApaLsSession::GetAppServiceOpaqueDataLC(TUid aAppUid, TUid aServiceUid) const
       
   921    
       
   922    @SYMTestExpectedResults Returns KErrNotFound
       
   923     
       
   924  */	
       
   925 void CT_ServicesTestStep::TestServiceDiscovery21L()
       
   926 	{
       
   927 	INFO_PRINTF1(_L("TestServiceDiscovery21L about to start..."));
       
   928 	const TUid KUidServerApp = {0x10004c58};
       
   929 	const TUid KUidService = {0x01020304};
       
   930 	// get all services for a particular app
       
   931 	TRAPD(r,iApaLsSession.GetAppServiceOpaqueDataLC(KUidServerApp,KUidService));
       
   932 	TEST(r==KErrNotFound);	
       
   933 	}
       
   934 
       
   935 /**
       
   936    @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery22
       
   937   
       
   938    @SYMPREQ 538
       
   939   
       
   940    @SYMTestPriority  High
       
   941   
       
   942    @SYMTestStatus Implemented
       
   943    
       
   944    @SYMTestCaseDesc Test the functionality ofAppForDocumentAndService given an existing file name and service uid
       
   945    
       
   946    @SYMTestActions  Call AppForDocumentAndService with two parameters: a filename, a service uid, an
       
   947    app uid and the datatype requested
       
   948    on z: drive.\n
       
   949    API Calls:\n	
       
   950    RApaLsSession::AppForDocumentAndService(const TDesC& aFileName, TUid aServiceUid, TUid& aAppUid, TDataType& aDataType) const
       
   951    
       
   952    @SYMTestExpectedResults Returns KErrNone.It returns the first app that can offer this service and initialise the 
       
   953    datatype that describes the datatype in the document
       
   954     
       
   955  */	
       
   956 void CT_ServicesTestStep::TestServiceDiscovery22()
       
   957 	{
       
   958 	// AppForDocumentAndService test cases
       
   959 	INFO_PRINTF1(_L("TestServiceDiscovery22 about to start..."));
       
   960 	TInt ret(0);
       
   961 	TUid appUid=KNullUid;
       
   962 	const TUid KUidService = {0x01020303};
       
   963 	TDataType dataType;
       
   964 	const TUid TUidExpected = {0x10004c54};
       
   965 	_LIT8(KLitMimeTypeServerData,"text/plain");
       
   966     ret = iApaLsSession.AppForDocumentAndService(_L("z:\\system\\data\\one_byte.txt"), KUidService, appUid, dataType);	
       
   967 	TEST(ret==KErrNone);
       
   968 	TEST(dataType==TDataType(KLitMimeTypeServerData));
       
   969 	TEST(appUid==TUidExpected);
       
   970 	}
       
   971 
       
   972 /**
       
   973    @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery23
       
   974   
       
   975    @SYMPREQ 538
       
   976   
       
   977    @SYMTestPriority  High
       
   978   
       
   979    @SYMTestStatus Implemented
       
   980 
       
   981    @SYMTestCaseDesc Test the functionality ofAppForDocumentAndService given an existing file name and undefined service uid
       
   982    
       
   983    @SYMTestActions  Call AppForDocumentAndService with two parameters: a filename, a service uid, an
       
   984    app uid and the datatype requested
       
   985    on z: drive.\n
       
   986    API Calls:\n	
       
   987    RApaLsSession::AppForDocumentAndService(const TDesC& aFileName, TUid aServiceUid, TUid& aAppUid, TDataType& aDataType) const
       
   988    
       
   989    @SYMTestExpectedResults Returns KErrNone.The value returned for appuid is null.The datatype is set to the one that can desribe the
       
   990    datatype in the document 
       
   991     
       
   992  */	
       
   993 void CT_ServicesTestStep::TestServiceDiscovery23()
       
   994 	{
       
   995 	// AppForDocumentAndService test cases
       
   996 	INFO_PRINTF1(_L("TestServiceDiscovery23 about to start..."));
       
   997 	TInt ret(0);
       
   998 	TUid appUid=KNullUid;
       
   999 	const TUid KUidService = {0x01120304};
       
  1000     TDataType dataType;
       
  1001     _LIT8(KLitMimeTypeServerData,"text/plain");
       
  1002     ret = iApaLsSession.AppForDocumentAndService(_L("z:\\system\\data\\one_byte.txt"), KUidService, appUid, dataType);	
       
  1003 	TEST(ret==KErrNone);
       
  1004 	TEST(appUid==KNullUid);
       
  1005 	TEST(dataType==TDataType(KLitMimeTypeServerData));
       
  1006 	}
       
  1007 
       
  1008 
       
  1009 /**
       
  1010    @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery24
       
  1011   
       
  1012    @SYMPREQ 538
       
  1013   
       
  1014    @SYMTestPriority  High
       
  1015   
       
  1016    @SYMTestStatus Implemented
       
  1017 
       
  1018    @SYMTestCaseDesc Test the functionality ofAppForDocumentAndService given an undefined file name
       
  1019    
       
  1020    @SYMTestActions  Call AppForDocumentAndService with two parameters: a filename, a service uid, an
       
  1021    app uid and the datatype requested
       
  1022    on z: drive.\n
       
  1023    API Calls:\n	
       
  1024    RApaLsSession::AppForDocumentAndService(const TDesC& aFileName, TUid aServiceUid, TUid& aAppUid, TDataType& aDataType) const
       
  1025    
       
  1026    @SYMTestExpectedResults Returns KErrNone.The value returned for appuid is null.The returned value for the datatpe
       
  1027    is null.
       
  1028     
       
  1029  */	
       
  1030 void CT_ServicesTestStep::TestServiceDiscovery24()
       
  1031 	{
       
  1032 	// AppForDocumentAndService test cases
       
  1033 	INFO_PRINTF1(_L("TestServiceDiscovery24 about to start..."));
       
  1034 	TInt ret(0);
       
  1035 	TUid appUid=KNullUid;
       
  1036 	const TUid KUidService = {0x01020304};
       
  1037     TDataType dataType;
       
  1038     ret = iApaLsSession.AppForDocumentAndService(_L(""), KUidService, appUid, dataType);	
       
  1039 	TEST(ret==KErrNone);
       
  1040 	TEST(appUid==KNullUid);
       
  1041 	TEST(dataType.Uid()==KNullUid);
       
  1042 	}
       
  1043 
       
  1044 /**
       
  1045    @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery25
       
  1046   
       
  1047    @SYMPREQ 538
       
  1048    
       
  1049    @SYMTestPriority  High
       
  1050   
       
  1051    @SYMTestStatus Implemented
       
  1052   
       
  1053    @SYMTestCaseDesc Test the functionality ofAppForDocumentAndService given a file name, a file, service uid and file server 
       
  1054    
       
  1055    @SYMTestActions  Call AppForDocumentAndService with two parameters: a filename, a service uid, an
       
  1056    app uid and the datatype requested
       
  1057    on z: drive.\n
       
  1058    API Calls:\n	
       
  1059    RApaLsSession::AppForDocumentAndService(const TDesC& aFileName, TUid aServiceUid, TUid& aAppUid, TDataType& aDataType) const
       
  1060    
       
  1061    @SYMTestExpectedResults Returns KErrNone.The value returned for appuid is that of the app that provides this services.If more than
       
  1062    one app provides this service, it returns the first app in the list. The returned value for the datatype is that
       
  1063    that describes the datatype in the document
       
  1064     
       
  1065  */	
       
  1066 
       
  1067 void CT_ServicesTestStep::TestServiceDiscovery25()
       
  1068 	{
       
  1069 	INFO_PRINTF1(_L("TestServiceDiscovery25 about to start..."));
       
  1070 	const TUid KUidService = {0x01020303};
       
  1071 	TInt ret(0);
       
  1072 	TUid appUid=KNullUid;
       
  1073 	const TUid TUidExpected = {0x10004c54};
       
  1074 	_LIT8(KLitMimeTypeServerData,"text/plain");
       
  1075 	TDataType dataType;
       
  1076 	RFile file;
       
  1077 	_LIT(KOneByteFileName, "z:\\system\\data\\one_byte.txt");
       
  1078 	RFs fs;
       
  1079 	ret = fs.Connect();
       
  1080 	ret = fs.ShareProtected();
       
  1081 	ret = file.Open(fs, KOneByteFileName, EFileRead|EFileShareAny);
       
  1082 	TEST(ret==KErrNone);
       
  1083 	ret = iApaLsSession.AppForDocumentAndService(file, KUidService, appUid, dataType);
       
  1084 	TEST(appUid==TUidExpected);
       
  1085 	TEST(dataType==TDataType(KLitMimeTypeServerData));
       
  1086 	TEST(ret==KErrNone);
       
  1087 	fs.Close();
       
  1088 	}
       
  1089 
       
  1090 /**
       
  1091    @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery26
       
  1092   
       
  1093    @SYMPREQ 538
       
  1094    
       
  1095    @SYMTestPriority  High
       
  1096   
       
  1097    @SYMTestStatus Implemented
       
  1098   
       
  1099    @SYMTestCaseDesc Test the functionality ofAppForDocumentAndService given a file, service uid,file server and undefined file name 
       
  1100    
       
  1101    @SYMTestActions  Call AppForDocumentAndService with two parameters: a filename, a service uid, an
       
  1102    app uid and the datatype requested
       
  1103    on z: drive.\n
       
  1104    API Calls:\n	
       
  1105    RApaLsSession::AppForDocumentAndService(const TDesC& aFileName, TUid aServiceUid, TUid& aAppUid, TDataType& aDataType) const
       
  1106    
       
  1107    @SYMTestExpectedResults Returns KErrBadHandle. The app uid is set to null, the uid of datatype is set to null
       
  1108     
       
  1109  */	
       
  1110 void CT_ServicesTestStep::TestServiceDiscovery26()
       
  1111 	{
       
  1112 	INFO_PRINTF1(_L("TestServiceDiscovery26 about to start..."));
       
  1113 	const TUid KUidService = {0x01020304};
       
  1114 	TInt ret(0);
       
  1115 	TUid appUid=KNullUid;
       
  1116 	TDataType dataType;
       
  1117 	RFile file;
       
  1118 	_LIT(KOneByteFileName, "z:\\system\\data\\imaginary_byte.txt");
       
  1119 	RFs fs;
       
  1120 	ret = fs.Connect();
       
  1121 	ret = fs.ShareProtected();
       
  1122 	ret = file.Open(fs, KOneByteFileName, EFileRead|EFileShareAny);
       
  1123 	TEST(ret==KErrNotFound);
       
  1124 	ret = iApaLsSession.AppForDocumentAndService(file, KUidService, appUid, dataType);
       
  1125 	TEST(appUid==KNullUid);
       
  1126 	TEST(dataType.Des8().Length()==0);
       
  1127 	TEST(ret==KErrBadHandle);	
       
  1128 	fs.Close();
       
  1129 
       
  1130 	}
       
  1131 
       
  1132 /**
       
  1133    @SYMTestCaseID T-RApaLsSessionTestStep-TestServiceDiscovery27
       
  1134   
       
  1135    @SYMPREQ 538
       
  1136 
       
  1137    @SYMTestPriority  High
       
  1138   
       
  1139    @SYMTestStatus Implemented
       
  1140   
       
  1141    @SYMTestCaseDesc Test the functionality ofAppForDocumentAndService given a file name, a file, file server and a service uid that the app 
       
  1142    does not provide  * 
       
  1143    
       
  1144    @SYMTestActions  Call AppForDocumentAndService with two parameters: a filename, a service uid, an
       
  1145    app uid and the datatype requested
       
  1146    on z: drive.\n
       
  1147    API Calls:\n	
       
  1148    RApaLsSession::AppForDocumentAndService(const TDesC& aFileName, TUid aServiceUid, TUid& aAppUid, TDataType& aDataType) const
       
  1149    
       
  1150    @SYMTestExpectedResults Returns KErrNone.The value returned for app uid is null.The datatype is set to that that 
       
  1151    describes the datatype in the document 
       
  1152     
       
  1153  */	
       
  1154 void CT_ServicesTestStep::TestServiceDiscovery27()
       
  1155 	{
       
  1156 	INFO_PRINTF1(_L("TestServiceDiscovery27 about to start..."));
       
  1157 	const TUid KUidService = {0x01000300};
       
  1158 	TInt ret(0);
       
  1159 	TUid appUid=KNullUid;
       
  1160 	TDataType dataType;
       
  1161 	RFile file;
       
  1162 	_LIT(KOneByteFileName, "z:\\system\\data\\one_byte.txt");
       
  1163 	RFs fs;
       
  1164 	ret = fs.Connect();
       
  1165 	ret = fs.ShareProtected();
       
  1166 	ret = file.Open(fs, KOneByteFileName, EFileRead|EFileShareAny);
       
  1167 	TEST(ret==KErrNone);
       
  1168 	ret = iApaLsSession.AppForDocumentAndService(file, KUidService, appUid, dataType);
       
  1169 	TEST(appUid==KNullUid);
       
  1170 	_LIT8(KLitMimeTypeServerData,"text/plain");
       
  1171 	TEST(dataType==TDataType(KLitMimeTypeServerData));
       
  1172 	TEST(ret==KErrNone);	
       
  1173 	fs.Close();
       
  1174 	}
       
  1175 
       
  1176 /**
       
  1177  * @SYMTestCaseID T_ServicesTestStep_TestServiceDiscovery28L
       
  1178  *
       
  1179  * @SYMPREQ 538
       
  1180  *
       
  1181  * @SYMTestCaseDesc Test the functionality of GetServiceImplementationsLC 
       
  1182  * which gets all the implementation details about a specific service 
       
  1183  * @SYMTestPriority 
       
  1184  *
       
  1185  * @SYMTestStatus Implemented
       
  1186  * 
       
  1187  * @SYMTestActions Call GetServiceImplementationsLC with the service uid as parameter
       
  1188  * on z: drive.\n
       
  1189  * API Calls:\n	
       
  1190  * RApaLsSession::GetServiceImplementationsLC(TUid aServiceUid, const TDataType& aDataType) const
       
  1191  * 
       
  1192  * @SYMTestExpectedResults Returns an array of TApaAppServiceInfo objects. 
       
  1193  * The size of the array is equal to the number of apps offering the specified service that
       
  1194  * also handles the speficied datatype. 
       
  1195  * Each TApaAppServiceInfo contain an app uid and  the respective opaquedata. 
       
  1196  * The returned data should be the same as that defined in the registration files.
       
  1197  *  
       
  1198  */
       
  1199 void CT_ServicesTestStep::TestServiceDiscovery28L()
       
  1200 	{
       
  1201 	INFO_PRINTF1(_L("TestServiceDiscovery28 about to start..."));
       
  1202 	const TUid KUidService1234 = {0x01020304};
       
  1203 	//const TUid KUidServerApp1 = {0x10004c56};
       
  1204 	const TUid KUidServerApp2 = {0x10004c57};
       
  1205 	
       
  1206 	TDataType datatype(KLitCustom1Text);
       
  1207 	CApaAppServiceInfoArray* array = iApaLsSession.GetServiceImplementationsLC(KUidService1234, datatype);
       
  1208 	TArray<TApaAppServiceInfo> implArray(array->Array());
       
  1209 	TInt count = implArray.Count();	
       
  1210 	TEST(count==1);
       
  1211 	_LIT(KService,"Non-localised text for service uid 0x01020304");
       
  1212 	TPtrC8 opaqueData;
       
  1213 	TResourceReader reader;
       
  1214 	TPtrC16 theText;
       
  1215 	TInt val(0);
       
  1216 	TUid myuid = implArray[0].Uid(); 
       
  1217 	TEST(myuid==KUidServerApp2);
       
  1218 	const CArrayFixFlat<TDataTypeWithPriority>& datatypes = implArray[0].DataTypes();
       
  1219 	TEST(datatypes.Count()==1);
       
  1220 	TEST(0 == datatypes[0].iDataType.Des8().CompareF(KLitCustom1Text));
       
  1221 	opaqueData.Set(implArray[0].OpaqueData());
       
  1222 	reader.SetBuffer(&opaqueData); // opaqueData is an LTEXT resource
       
  1223 	theText.Set(reader.ReadTPtrC16());
       
  1224 	User::LeaveIfError(val = theText.Compare(KService));
       
  1225 	TEST(val==KErrNone);
       
  1226 	CleanupStack::PopAndDestroy(array);
       
  1227 	array = NULL;
       
  1228 	}
       
  1229 
       
  1230 /**
       
  1231  * @SYMTestCaseID T_ServicesTestStep_TestOpenService1
       
  1232  *
       
  1233  * @SYMPREQ
       
  1234  *
       
  1235  * @SYMTestCaseDesc This test checks that the Open service and legacy datatypes
       
  1236  * functions return the same results. See defect INC053978 as well.
       
  1237  * 
       
  1238  * @SYMTestPriority High 
       
  1239  *
       
  1240  * @SYMTestStatus Implemented
       
  1241  * 
       
  1242  * @SYMTestActions \n
       
  1243  * API Calls:\n
       
  1244  * 
       
  1245  * @SYMTestExpectedResults 
       
  1246  *  
       
  1247  */
       
  1248 void CT_ServicesTestStep::TestOpenService1L()
       
  1249 	{
       
  1250 	INFO_PRINTF1(_L("TestOpenService1L about to start..."));
       
  1251 		
       
  1252 	// First try using the legacy method
       
  1253 	_LIT8(KLitDummyopen1,"text/dummyopen1");
       
  1254 	TUid expectedAppUid1={0x10208200};
       
  1255 	TUid uid1;
       
  1256 	TInt error1 = iApaLsSession.AppForDataType(TDataType(KLitDummyopen1), uid1);
       
  1257 	TEST(error1==KErrNone);
       
  1258 	TEST(uid1==expectedAppUid1);
       
  1259 	
       
  1260 	// Then try with legacy API but new Open service in reg file
       
  1261 	_LIT8(KLitDummyopen2,"text/dummyopen2");
       
  1262 	TUid expectedAppUid2={0x10208201};
       
  1263 	TUid uid2;
       
  1264 	TInt error2 = iApaLsSession.AppForDataType(TDataType(KLitDummyopen2), uid2);
       
  1265 	TEST(error2==KErrNone);
       
  1266 	TEST(uid2==expectedAppUid2);
       
  1267 	
       
  1268 	// Try with new API and old registration file format
       
  1269 	TUid uid3;
       
  1270 	TInt error3 = iApaLsSession.AppForDataTypeAndService(TDataType(KLitDummyopen1), 
       
  1271 		KOpenServiceUid, uid3);
       
  1272 	TEST(error3==KErrNone);
       
  1273 	TEST(uid3==expectedAppUid1);
       
  1274 	
       
  1275 	// Try with new API and new registration file format
       
  1276 	TUid uid4;
       
  1277 	TInt error4 = iApaLsSession.AppForDataTypeAndService(TDataType(KLitDummyopen2), 
       
  1278 		KOpenServiceUid, uid4);
       
  1279 	TEST(error4==KErrNone);
       
  1280 	TEST(uid4==expectedAppUid2);
       
  1281 	
       
  1282 	INFO_PRINTF1(KCompleted);
       
  1283 	}
       
  1284 
       
  1285 //Test that the datatype list in the registration file is skipped
       
  1286 void CT_ServicesTestStep::TestCtrlPnlAppL()
       
  1287 	{
       
  1288 	INFO_PRINTF1(_L("TestCtrlPnlAppL about to start..."));
       
  1289 	TUid appUid={0x10207f79};
       
  1290 	TUid serviceUid = {0x10101010};
       
  1291 	CDesCArray* filesArray = new(ELeave) CDesCArraySeg(1);
       
  1292 	CleanupStack::PushL(filesArray);
       
  1293 	TInt ret = iApaLsSession.GetAppOwnedFiles(*filesArray,appUid);
       
  1294 	TEST(ret==KErrNone);
       
  1295 	TInt count(0);
       
  1296 	count = filesArray->Count();
       
  1297 	TEST(count == 1); 
       
  1298 	CApaAppServiceInfoArray* array = iApaLsSession.GetAppServicesLC(appUid);
       
  1299 	TArray<TApaAppServiceInfo> serviceArray(array->Array());
       
  1300 	count = serviceArray.Count();
       
  1301 	TEST(count == 1); 
       
  1302 	TEST(serviceArray[0].Uid()==serviceUid);
       
  1303 	CleanupStack::PopAndDestroy(2);
       
  1304 	filesArray = NULL;
       
  1305 	array = NULL;
       
  1306 	}
       
  1307 	
       
  1308 /**
       
  1309  * @SYMTestCaseID T_ServicesTestStep_TestPrioritySystemL
       
  1310  *
       
  1311  * @SYMPREQ
       
  1312  *
       
  1313  * @SYMTestCaseDesc Checks that the system priority for data handlers requires
       
  1314  * WriteDeviceData capability
       
  1315  * 
       
  1316  * @SYMTestPriority High 
       
  1317  *
       
  1318  * @SYMTestStatus Implemented
       
  1319  * 
       
  1320  * @SYMTestActions \n
       
  1321  * API Calls:\n
       
  1322  * 
       
  1323  * @SYMTestExpectedResults 
       
  1324  *  
       
  1325  */
       
  1326 void CT_ServicesTestStep::TestPrioritySystemL()
       
  1327 	{
       
  1328 	INFO_PRINTF1(_L("TestPrioritySystemL about to start..."));
       
  1329 	// App 0x10207f7b has system priority and WriteDeviceData so it should
       
  1330 	// be returned and not 0x10207f7f which has only high priority
       
  1331 	const TUid KUidService1 = {0x10207f7d};
       
  1332 	TUid appUid=KNullUid;
       
  1333 	const TUid TUidExpected1 = {0x10207f7b};
       
  1334 	_LIT8(KLitMimeTypeServerData,"text/custom1");
       
  1335 	TInt ret=iApaLsSession.AppForDataTypeAndService(TDataType(KLitMimeTypeServerData), KUidService1,appUid);
       
  1336 	TEST(ret==KErrNone);
       
  1337 	TEST(appUid == TUidExpected1);
       
  1338 	
       
  1339 	// App 0x10207f7e has system priority but not WriteDeviceData so it should
       
  1340 	// be 0x10207f7f that is returned  that has high priority
       
  1341 	const TUid KUidService2 = {0x10207f7e};
       
  1342 	const TUid TUidExpected2 = {0x10207f7f};
       
  1343 	ret=iApaLsSession.AppForDataTypeAndService(TDataType(KLitMimeTypeServerData), KUidService2,appUid);
       
  1344 	TEST(ret==KErrNone);
       
  1345 	TEST(appUid == TUidExpected2);
       
  1346 	
       
  1347 	// System priority handler take precedence over user mappings
       
  1348 	const TUid KUidServerApp = {0x10004c56};
       
  1349 	ret = iApaLsSession.InsertDataMapping(TDataType(KLitMimeTypeServerData),
       
  1350 	 	1, KUidServerApp, KUidService1);
       
  1351 	TEST(ret==KErrNone);
       
  1352 	// Waits till the data type mappings are restored from the data store ini file
       
  1353 	iApaLsSession.WaitForTypeStoreUpdate();
       
  1354 	ret = iApaLsSession.AppForDataTypeAndService(TDataType(KLitMimeTypeServerData), KUidService1,appUid);
       
  1355 	TEST(ret==KErrNone);
       
  1356 	TEST(appUid == TUidExpected1);
       
  1357 	ret = iApaLsSession.DeleteDataMapping(TDataType(KLitMimeTypeServerData),KUidService1);
       
  1358 	TEST(ret==KErrNone);
       
  1359 	// Waits till the data type mappings are restored from the data store ini file
       
  1360 	iApaLsSession.WaitForTypeStoreUpdate();
       
  1361 	}
       
  1362