fbs/fontandbitmapserver/tfbs/twdp.cpp
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2008-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 #include "twdp.h"
       
    17 #include "utils.h"
       
    18 
       
    19 namespace t_fbservwdptest
       
    20 	{
       
    21 	_LIT(KT_WDPTestCaseNumber,"CaseNumber");
       
    22 	_LIT(KT_TestPanicTxt, "t_fbservwdptest");
       
    23 	}
       
    24 
       
    25 using namespace t_fbservwdptest;
       
    26 
       
    27 CTWDP::CTWDP(CTestStep* aStep):
       
    28 	CTGraphicsBase(aStep),
       
    29 	iFbs(NULL)
       
    30 	{
       
    31 	}
       
    32 
       
    33 CTWDP::~CTWDP()
       
    34 	{
       
    35 	iSharedHeapChunk.Close();
       
    36 	iBitmapChunk.Close();
       
    37 	RFbsSession::Disconnect();
       
    38 	}
       
    39 
       
    40 void CTWDP::ConstructL()
       
    41 	{
       
    42 	User::LeaveIfError(RFbsSession::Connect());
       
    43 	iFbs = RFbsSession::GetSession();
       
    44 	}
       
    45 
       
    46 void CTWDP::RunTestCaseL(TInt aCurTestCase)
       
    47 	{
       
    48 	TBool res = iStep->GetIntFromConfig(iStep->ConfigSection(), KT_WDPTestCaseNumber, aCurTestCase);	
       
    49 	if(!res)
       
    50 		{
       
    51 		User::Leave(KErrNotFound);
       
    52 		}
       
    53 	
       
    54 	switch(aCurTestCase)
       
    55 		{
       
    56 	case 1:
       
    57 		TestFbservPaged();
       
    58 		break;
       
    59 	case 2:
       
    60 		TestFbservUnPaged();
       
    61 		break;
       
    62 	case 3:
       
    63 		TestBitmapDataPagedL();
       
    64 		break;
       
    65 	case 4:
       
    66 		TestBitmapDataAndSharedHeapPagedL();
       
    67 		break;
       
    68 	default:
       
    69 		User::Panic(KT_TestPanicTxt, KErrNotFound);  //Unexpected value!
       
    70 		break;
       
    71 		}
       
    72 	
       
    73 	TestComplete();	
       
    74 	}
       
    75 
       
    76 void CTWDP::TestFbservPaged()
       
    77 	{
       
    78 	TBool ret=DefaultDataPaged();
       
    79 	if (ret)
       
    80 		{
       
    81 		INFO_PRINTF1(_L("fbserv.DefaultDataPaged() returned --> 1, Expected --> 1"));
       
    82 		}
       
    83 	else
       
    84 		{
       
    85 		INFO_PRINTF1(_L("fbserv.DefaultDataPaged() returned --> 0, Expected --> 1"));		
       
    86 		}			
       
    87 	TEST(ret);
       
    88 	}
       
    89 
       
    90 void CTWDP::TestFbservUnPaged()
       
    91 	{
       
    92 	TBool ret=DefaultDataPaged();
       
    93 	if (!ret)
       
    94 		{
       
    95 		INFO_PRINTF1(_L("fbserv.DefaultDataPaged() returned --> 0, Expected --> 0"));
       
    96 		}
       
    97 	else
       
    98 		{
       
    99 		INFO_PRINTF1(_L("fbserv.DefaultDataPaged() returned --> 1, Expected --> 0"));
       
   100 		}					
       
   101 	TEST(!ret);	
       
   102 	}
       
   103 
       
   104 void CTWDP::TestBitmapDataPagedL()
       
   105 	{
       
   106 	TEST(BitmapDataPagedL());
       
   107 	}
       
   108 
       
   109 void CTWDP::TestBitmapDataAndSharedHeapPagedL()
       
   110 	{
       
   111 	TBool ret = BitmapDataPagedL();
       
   112 	if (ret)
       
   113 		{
       
   114 		User::LeaveIfError(iSharedHeapChunk.OpenGlobal(KFBSERVSharedChunkName,ETrue));
       
   115 		ret = iSharedHeapChunk.IsPaged();
       
   116 		if (ret)
       
   117 			{
       
   118 			INFO_PRINTF1(_L("iSharedHeapChunk.IsPaged() returned --> 1, Expected --> 1"));
       
   119 			}
       
   120 		else
       
   121 			{
       
   122 			INFO_PRINTF1(_L("iSharedHeapChunk.IsPaged() returned --> 0, Expected --> 1"));		
       
   123 			}
       
   124 		}	
       
   125 	TEST(ret);	
       
   126 	}
       
   127 
       
   128 TBool CTWDP::DefaultDataPaged()
       
   129 	{
       
   130 	RProcess proc = RProcess();
       
   131 	_LIT(KPattern, "*fbserv*");
       
   132 	TFindProcess findProc(KPattern);
       
   133 	TFullName fullName;
       
   134 	TInt err=KErrNone;
       
   135 		
       
   136 	INFO_PRINTF2(_L("TFindProcess: Find a process whose name match the pattern %S "), &KPattern());
       
   137 	if(findProc.Next(fullName)!= KErrNone)
       
   138 		{
       
   139 		INFO_PRINTF1(_L("Error: Process whose name match the above pattern not found"));
       
   140 		User::LeaveIfError(err);
       
   141 		}
       
   142 	else
       
   143 		{
       
   144 		INFO_PRINTF2(_L("TFindProcess.Next() found process --> %S "), &fullName );
       
   145 		}
       
   146 	
       
   147 	if(findProc.Next(fullName) != KErrNotFound)
       
   148 		{
       
   149 		INFO_PRINTF2(_L("Error: TFindProcess found more than 1 process matching the pattern --> %S "), &fullName );
       
   150 		User::Leave(KErrGeneral);
       
   151 		}
       
   152 
       
   153 	if( (err=proc.Open(fullName)) != KErrNone)
       
   154 		{
       
   155 		INFO_PRINTF2(_L("Error: RProcess.Open() returned --> %d"), err);
       
   156 		User::LeaveIfError(err);
       
   157 		}
       
   158 	
       
   159 	TBool ret = proc.DefaultDataPaged();
       
   160 	proc.Close();
       
   161 	return ret;	
       
   162 	 }
       
   163 
       
   164 TBool CTWDP::BitmapDataPagedL()
       
   165 	{
       
   166 	User::LeaveIfError(iBitmapChunk.OpenGlobal(KFBSERVLargeChunkName,ETrue));
       
   167 	TBool ret=iBitmapChunk.IsPaged();
       
   168 	if (ret)
       
   169 		{
       
   170 		INFO_PRINTF1(_L("iBitmapChunk.IsPaged() returned --> 1, Expected --> 1"));
       
   171 		}
       
   172 	else
       
   173 		{
       
   174 		INFO_PRINTF1(_L("iBitmapChunk.IsPaged() returned --> 0, Expected --> 1"));		
       
   175 		}	
       
   176 	return ret;		
       
   177 	}
       
   178 
       
   179 //--------------
       
   180 __CONSTRUCT_STEP__(WDP)