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