serviceproviders/sapi_sysinfo/tsrc/dev/servicetests/tsysinfoservicetests/src/tsysinfoservicetestsblocks.cpp
changeset 22 fc9cf246af83
parent 19 989d2f495d90
child 33 50974a8b132e
equal deleted inserted replaced
19:989d2f495d90 22:fc9cf246af83
    28 #include "tuseractivitynotifier.h"
    28 #include "tuseractivitynotifier.h"
    29 #include "Tautolocknotifier.h"
    29 #include "Tautolocknotifier.h"
    30 
    30 
    31 #include "sysinfoservice.h"
    31 #include "sysinfoservice.h"
    32 #include "entitykeys.h"
    32 #include "entitykeys.h"
       
    33 #include <COEMAIN.H> 
    33 
    34 
    34 using namespace SysInfo;
    35 using namespace SysInfo;
    35 _LIT(KROMInstallDir,"\\system\\install\\");
    36 _LIT(KROMInstallDir,"\\system\\install\\");
    36 _LIT(KS60ProductIdFile,"Series60v*.sis");
    37 _LIT(KS60ProductIdFile,"Series60v*.sis");
    37 _LIT(KDisplayLanguage,"DisplayLanguage");
       
    38 
    38 
    39 	const TPtrC KFeature[] = 
    39 	const TPtrC KFeature[] = 
    40 	{
    40 	{
    41 	KCamera.operator()(),
    41 	KCamera.operator()(),
    42 	KMemoryCard.operator()(),
    42 	KMemoryCard.operator()(),
   105         ENTRY( "PredText",    Ctsysinfoservicetests::PredText),
   105         ENTRY( "PredText",    Ctsysinfoservicetests::PredText),
   106         ENTRY( "VibraStatus",    Ctsysinfoservicetests::VibraStatus),
   106         ENTRY( "VibraStatus",    Ctsysinfoservicetests::VibraStatus),
   107         ENTRY( "AvailableUSBModes",    Ctsysinfoservicetests::AvailableUSBModes),
   107         ENTRY( "AvailableUSBModes",    Ctsysinfoservicetests::AvailableUSBModes),
   108         ENTRY( "ActiveUSBModes",    Ctsysinfoservicetests::ActiveUSBModes),
   108         ENTRY( "ActiveUSBModes",    Ctsysinfoservicetests::ActiveUSBModes),
   109         ENTRY( "NotificationCancelVibra",    Ctsysinfoservicetests::NotificationCancelVibra),
   109         ENTRY( "NotificationCancelVibra",    Ctsysinfoservicetests::NotificationCancelVibra),
       
   110         ENTRY( "CameraData",    Ctsysinfoservicetests::CameraData),
       
   111         ENTRY( "CameraDataWrongEntity", Ctsysinfoservicetests::CameraDataNegativeEntity),
       
   112         ENTRY( "CameraDataWrongKey",   Ctsysinfoservicetests::CameraDataNegativeKey),
   110 //Connectivity
   113 //Connectivity
   111   		ENTRY( "ConnBluetooth",    Ctsysinfoservicetests::ConnBluetooth),
   114   		ENTRY( "ConnBluetooth",    Ctsysinfoservicetests::ConnBluetooth),
   112         ENTRY( "IRStatus",    Ctsysinfoservicetests::IRStatus),
   115         ENTRY( "IRStatus",    Ctsysinfoservicetests::IRStatus),
   113         ENTRY( "GetActiveConnections",    Ctsysinfoservicetests::GetActiveConnections),
   116         ENTRY( "GetActiveConnections",    Ctsysinfoservicetests::GetActiveConnections),
   114         ENTRY( "GetWlanMacAddress",    Ctsysinfoservicetests::GetWlanMacAddress),
   117         ENTRY( "GetWlanMacAddress",    Ctsysinfoservicetests::GetWlanMacAddress),
  2181 // -----------------------------------------------------------------------------
  2184 // -----------------------------------------------------------------------------
  2182 // Ctsysinfoservicetests::GetDisplayLang
  2185 // Ctsysinfoservicetests::GetDisplayLang
  2183 // 
  2186 // 
  2184 // -----------------------------------------------------------------------------
  2187 // -----------------------------------------------------------------------------
  2185 //
  2188 //
  2186 TInt  Ctsysinfoservicetests::GetDisplayLang(CStifItemParser& /*aItem*/)
  2189 TInt Ctsysinfoservicetests::GetDisplayLang(CStifItemParser& /*aItem*/)
  2187 	{
  2190     {
  2188 
  2191     CCoeEnv* coeSupported = NULL;
  2189 	TInt result = KErrNone;
  2192     coeSupported = CCoeEnv::Static();
  2190 	__UHEAP_MARK;
  2193     if (coeSupported)
  2191 	
  2194         {
  2192 
  2195         TInt result = KErrNone;
  2193 	_LIT( KExample, "GetDisplayLang:" );
  2196         __UHEAP_MARK;
  2194     iLog->Log( KExample );
  2197 
  2195     
  2198         _LIT(KExample, "GetDisplayLang:");
  2196 			 
  2199         iLog->Log(KExample);
  2197 	CSysInfoService* iSysInfoService = CSysInfoService::NewL();
  2200 
  2198 
  2201         CSysInfoService* iSysInfoService = CSysInfoService::NewL();
  2199 	CleanupStack::PushL(iSysInfoService);
  2202 
  2200 
  2203         CleanupStack::PushL(iSysInfoService);
  2201 	
  2204 
  2202 	CSysData* data2 = NULL;
  2205         CSysData* data2 = NULL;
  2203 
  2206 
  2204 	TRAPD(err,iSysInfoService->GetInfoL(KGeneral,KDisplayLanguage,data2));
  2207         TRAPD(err, iSysInfoService->GetInfoL(KGeneral, KDisplayLanguage,
  2205 	if( err != KErrNotFound )
  2208                 data2));
  2206 		{
  2209         if (err != KErrNotFound)
  2207 		iLog->Log( _L("Failed,Get Display language found ret err: %d"),err );
  2210             {
  2208 		result = KErrGeneral;
  2211             iLog->Log(_L("Failed,Get Display language found ret err: %d"),
  2209 		}
  2212                     err);
  2210 	else
  2213             result = KErrGeneral;
  2211 		{
  2214             }
  2212 		result = KErrNone;
  2215         else
  2213 		iLog->Log( _L("Passed Get Display language not found") );
  2216             {
  2214 		}
  2217             result = KErrNone;
  2215 		
  2218             iLog->Log(_L("Passed Get Display language not found") );
  2216 	delete data2;
  2219             }
  2217 	
  2220 
  2218 	CleanupStack::PopAndDestroy(1);
  2221         delete data2;
  2219 	__UHEAP_MARKEND;
  2222 
  2220 
  2223         CleanupStack::PopAndDestroy(1);
  2221 	return result;
  2224         __UHEAP_MARKEND;
  2222 	
  2225 
  2223 	
  2226         return result;
  2224 	}
  2227 
       
  2228         }
       
  2229     else
       
  2230         {
       
  2231         iLog->Log(_L("CCoeEnv not supported . Hence passing the test case") );
       
  2232         return 0;
       
  2233         }
       
  2234     }
  2225 
  2235 
  2226 // -----------------------------------------------------------------------------
  2236 // -----------------------------------------------------------------------------
  2227 // Ctsysinfoservicetests::SetDisplayLang
  2237 // Ctsysinfoservicetests::SetDisplayLang
  2228 // 
  2238 // 
  2229 // -----------------------------------------------------------------------------
  2239 // -----------------------------------------------------------------------------
  2230 //	
  2240 //	
  2231 TInt  Ctsysinfoservicetests::SetDisplayLang(CStifItemParser& /*aItem*/)
  2241 TInt Ctsysinfoservicetests::SetDisplayLang(CStifItemParser& /*aItem*/)
  2232 	{
  2242     {
  2233 
  2243     TInt result = KErrNone;
  2234 	TInt result = KErrNone;
  2244     __UHEAP_MARK;
  2235 
  2245     CSysInfoService* iSysInfoService = CSysInfoService::NewL();
  2236 	__UHEAP_MARK;
  2246     CleanupStack::PushL(iSysInfoService);
  2237 
  2247     CStatus* data = CStatus::NewL(10);
  2238 	CSysInfoService* iSysInfoService = CSysInfoService::NewL();
  2248     CleanupStack::PushL(data);
  2239 
  2249     TRAPD(err, iSysInfoService->SetInfoL(KGeneral, KDisplayLanguage, data));
  2240 	CleanupStack::PushL(iSysInfoService);
  2250     if (err != KErrNotFound)
  2241 
  2251         {
  2242 
  2252         iLog->Log(_L("Failed,Set Display language found ret err: %d"), err);
  2243 	CStatus* data = CStatus::NewL(10);
  2253         result = KErrGeneral;
  2244 	CleanupStack::PushL(data);
  2254         }
  2245 	TRAPD(err,iSysInfoService->SetInfoL(KGeneral,KDisplayLanguage,data));
  2255     else
  2246 	if( err != KErrNotFound )
  2256         {
  2247 		{
  2257         result = KErrNone;
  2248 		iLog->Log( _L("Failed,Set Display language found ret err: %d"),err );
  2258         iLog->Log(_L("Passed Set Display language not found") );
  2249 		result = KErrGeneral;
  2259         }
  2250 		}
  2260     CleanupStack::PopAndDestroy(data);
  2251 	else
  2261 
  2252 		{
  2262     CCoeEnv* coeSupported = NULL;
  2253 		result = KErrNone;
  2263     coeSupported = CCoeEnv::Static();
  2254 		iLog->Log( _L("Passed Set Display language not found") );
  2264     if (coeSupported)
  2255 		}
  2265         {
  2256 	CleanupStack::PopAndDestroy(data);
  2266         CSysData *data1 = NULL;
  2257 	
  2267         TRAPD(err1, iSysInfoService->GetInfoL(KGeneral, KDisplayLanguage,data1));
  2258 	CSysData *data1 = NULL;
  2268         if (err1 != KErrNotFound)
  2259 	TRAPD(err1,iSysInfoService->GetInfoL(KGeneral,KDisplayLanguage,data1));
  2269             {
  2260 	if( err1 != KErrNotFound )
  2270             iLog->Log(_L("Failed,Set Display language found ret err: %d"),err);
  2261 		{
  2271             result = KErrGeneral;
  2262 		iLog->Log( _L("Failed,Set Display language found ret err: %d"),err );
  2272             }
  2263 		result = KErrGeneral;
  2273         else
  2264 		}
  2274             {
  2265 	else
  2275             result = KErrNone;
  2266 		{
  2276             iLog->Log(_L("Passed Set Display language not found") );
  2267 		result = KErrNone;
  2277             }
  2268 		iLog->Log( _L("Passed Set Display language not found") );
  2278         delete data1;
  2269 		}
  2279         }
  2270 	delete data1;
  2280     CleanupStack::PopAndDestroy(1);
  2271 
  2281     __UHEAP_MARKEND;
  2272 	CleanupStack::PopAndDestroy(1);
  2282     return result;
  2273 	__UHEAP_MARKEND;
  2283     }
  2274 
       
  2275 	return result;
       
  2276 	
       
  2277 	
       
  2278 	}
       
  2279 // -----------------------------------------------------------------------------
  2284 // -----------------------------------------------------------------------------
  2280 // Ctsysinfoservicetests::SetInputLang
  2285 // Ctsysinfoservicetests::SetInputLang
  2281 // 
  2286 // 
  2282 // -----------------------------------------------------------------------------
  2287 // -----------------------------------------------------------------------------
  2283 //	
  2288 //	
  2567     if(ret==0)
  2572     if(ret==0)
  2568 			return KErrNone;
  2573 			return KErrNone;
  2569 		else	
  2574 		else	
  2570 			return KErrGeneral;
  2575 			return KErrGeneral;
  2571 		}	
  2576 		}	
  2572 		
  2577 
       
  2578 // -----------------------------------------------------------------------------
       
  2579 // Ctsysinfoservicetests::CameraData
       
  2580 // Positive Test for Core Class
       
  2581 // -----------------------------------------------------------------------------
       
  2582 //
       
  2583 TInt Ctsysinfoservicetests::CameraData(CStifItemParser& /*aItem*/)
       
  2584    {
       
  2585     TInt result = 0;
       
  2586     _LIT( KExample, "CameraData" );
       
  2587     iLog->Log( KExample );
       
  2588 	
       
  2589 	__UHEAP_MARK;
       
  2590 
       
  2591 	CSysInfoService *obj = CSysInfoService::NewL();
       
  2592 	CleanupStack::PushL(obj);
       
  2593 	
       
  2594 	CSysData* output=NULL;
       
  2595 	TRAPD(err,obj->GetInfoL(KCameraInfo,KCameraProperties,output));
       
  2596 	result = err;
       
  2597 	if (result == KErrNone)
       
  2598 		{
       
  2599 		iLog->Log(_L("Got Expected error code %d "),result);
       
  2600 		if(!output)
       
  2601 			{
       
  2602 			iLog->Log( _L("Output data Set to NULL") );
       
  2603 			result = -1;
       
  2604 			}
       
  2605 		else
       
  2606 			{
       
  2607 			CleanupStack::PushL(output);
       
  2608 			iLog->Log( _L("Output data Obtained") );			
       
  2609 			if( CSysData::ECameraInfo != output->DataType() )
       
  2610 				{
       
  2611 				iLog->Log( _L("Invalid output data type") );
       
  2612 				result = -1;
       
  2613 				}
       
  2614 			else
       
  2615 				{
       
  2616 				iLog->Log( _L("Valid output data type - ECameraInfo") );
       
  2617 				const CCameraInfo* camInfoTest = ((CCameraInfo*) output);	
       
  2618 				TInt count = camInfoTest->ResolutionList()->Count();
       
  2619 
       
  2620 			    iLog->Log( _L("Count is - %d"),count );
       
  2621                 for(TInt i=0; i<count; i++)
       
  2622                     {
       
  2623                     TInt val = 0;
       
  2624                     TPtrC string;
       
  2625                     camInfoTest->ResolutionList()->At(i,0,val);
       
  2626                     iLog->Log( _L("Width %d is - %d"),i+1,val );
       
  2627                     camInfoTest->ResolutionList()->At(i,1,val);
       
  2628                     iLog->Log( _L("Height %d is - %d"),i+1,val );
       
  2629                     camInfoTest->MimeTypesList()->At(i,string);
       
  2630                     iLog->Log( _L("MimeType %d is %s"),i+1,string.Ptr());
       
  2631                     }  
       
  2632                 iLog->Log(_L("Test Completed"));
       
  2633                 iLog->Log( _L("PASS"));  
       
  2634 				}//datatype	- ECameraInfo	
       
  2635 			CleanupStack::PopAndDestroy(output);
       
  2636 			}//output		
       
  2637 		}//err
       
  2638 	else
       
  2639 		{
       
  2640 		iLog->Log( _L("GetInfo API for Camera returned error %d"),result );
       
  2641         iLog->Log(_L("Test Completed"));
       
  2642         iLog->Log( _L("FAIL"));   
       
  2643 		}	
       
  2644 	
       
  2645 	CleanupStack::PopAndDestroy(obj);
       
  2646 	__UHEAP_MARKEND;
       
  2647 	return result;    
       
  2648     }	
       
  2649 
       
  2650 // -----------------------------------------------------------------------------
       
  2651 // Ctsysinfoservicetests::CameraDataNegativeEntity
       
  2652 // negative test case for core class - Wrong Entity
       
  2653 // -----------------------------------------------------------------------------
       
  2654 //
       
  2655 TInt Ctsysinfoservicetests::CameraDataNegativeEntity(CStifItemParser& /*aItem*/)
       
  2656    {
       
  2657     TInt result;
       
  2658     TInt expectedError = KErrNotFound;
       
  2659     _LIT( KExample, "CameraDataNegativeEntity" );
       
  2660     iLog->Log( KExample );
       
  2661     
       
  2662     _LIT( KCameraEntity, "CameraEntity" );
       
  2663     __UHEAP_MARK;
       
  2664 
       
  2665     CSysInfoService *obj = CSysInfoService::NewL();
       
  2666     CleanupStack::PushL(obj);
       
  2667     
       
  2668     CSysData* output=NULL; 
       
  2669     TRAPD(err,obj->GetInfoL(KCameraEntity,KCameraProperties,output));
       
  2670     result = err;
       
  2671     if (result == expectedError)
       
  2672         {
       
  2673         iLog->Log(_L("Got Expected error code %d "),result);
       
  2674         result = KErrNone;
       
  2675         iLog->Log(_L("Test Completed"));
       
  2676         iLog->Log( _L("PASS"));   
       
  2677         }//err
       
  2678     else
       
  2679         {
       
  2680         iLog->Log( _L("GetInfo API for Camera returned unexpected error") );
       
  2681         iLog->Log(_L("Test Completed"));
       
  2682         iLog->Log( _L("FAIL"));  
       
  2683         }    
       
  2684     
       
  2685     CleanupStack::PopAndDestroy(obj);
       
  2686     __UHEAP_MARKEND;
       
  2687     return result;    
       
  2688     }   
       
  2689 
       
  2690 // -----------------------------------------------------------------------------
       
  2691 // Ctsysinfoservicetests::CameraDataNegativeKey
       
  2692 // negative test case for core class - Wrong Key
       
  2693 // -----------------------------------------------------------------------------
       
  2694 //
       
  2695 TInt Ctsysinfoservicetests::CameraDataNegativeKey(CStifItemParser& /*aItem*/)
       
  2696    {
       
  2697     TInt result;
       
  2698     TInt expectedError = KErrNotFound;
       
  2699     _LIT( KExample, "CameraDataNegativeKey" );
       
  2700     iLog->Log( KExample );
       
  2701     
       
  2702     _LIT( KCameraKey, "CameraKey" );
       
  2703     __UHEAP_MARK;
       
  2704 
       
  2705     CSysInfoService *obj = CSysInfoService::NewL();
       
  2706     CleanupStack::PushL(obj);
       
  2707     
       
  2708     CSysData* output=NULL;
       
  2709     TRAPD(err,obj->GetInfoL(KCameraInfo,KCameraKey,output));
       
  2710     result = err;
       
  2711     if (result == expectedError)
       
  2712         {
       
  2713         iLog->Log(_L("Got Expected error code %d "),result);
       
  2714         result = KErrNone;
       
  2715         iLog->Log(_L("Test Completed"));
       
  2716         iLog->Log( _L("PASS"));  
       
  2717         }//err
       
  2718     else
       
  2719         {
       
  2720         iLog->Log( _L("GetInfo API for Camera returned unexpected error") );
       
  2721         iLog->Log(_L("Test Completed"));
       
  2722         iLog->Log( _L("FAIL"));   
       
  2723         }    
       
  2724     
       
  2725     CleanupStack::PopAndDestroy(obj);
       
  2726     __UHEAP_MARKEND;
       
  2727     return result;    
       
  2728     }  
       
  2729 
  2573 		
  2730 		
  2574 TInt  Ctsysinfoservicetests::ConnBluetooth(CStifItemParser& /*aItem*/)
  2731 TInt  Ctsysinfoservicetests::ConnBluetooth(CStifItemParser& /*aItem*/)
  2575 	{	int ret=0;
  2732 	{	int ret=0;
  2576     ret = ReqNotification(0, NULL);
  2733     ret = ReqNotification(0, NULL);
  2577     
  2734