os/ossrv/lowlevellibsandfws/apputils/bsul/test/t_clientmessage/t_clientmessage.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/lowlevellibsandfws/apputils/bsul/test/t_clientmessage/t_clientmessage.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,2343 @@
     1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include <f32file.h>
    1.20 +#include <e32test.h>
    1.21 +#include <bautils.h>
    1.22 +#include <hal.h>
    1.23 +#include <e32std.h>
    1.24 +#include <bsul/bsul.h>
    1.25 +#include "t_clientmessagetestserver.h"
    1.26 +
    1.27 +using namespace BSUL;
    1.28 +
    1.29 +
    1.30 +LOCAL_D RTest				Test (_L("T_ClientMessage"));
    1.31 +LOCAL_D RFs					TheFs;
    1.32 +
    1.33 +_LIT(KServerName,"ClientMessageTestServer");
    1.34 +_LIT(KServer2Name,"SecondTestServer");
    1.35 +_LIT(KServerFileName,"T_ClientMessageTestServer.exe");
    1.36 +
    1.37 +struct TExitDetails
    1.38 +	{
    1.39 +	TExitCategoryName iCategory;
    1.40 +	TExitType iExitType;
    1.41 +	TInt iReason;
    1.42 +	};
    1.43 +
    1.44 +typedef void (*TestFunction)();
    1.45 +
    1.46 +
    1.47 +/*RClientMessageTestSession client side interface to
    1.48 + * CClientMessageTestServer server.  This is used to pass
    1.49 + * messages to the server to testthe Client Message Framework.
    1.50 + */
    1.51 +class RClientMessageTestSession : public RSessionBase
    1.52 +	{
    1.53 +public:
    1.54 +	TInt Connect();
    1.55 +
    1.56 +	TInt TestFunction0(TInt aArg0);
    1.57 +	TInt TestFunction0(TInt aArg0, TInt aArg1);
    1.58 +	TInt TestFunction0(TInt aArg0, TInt aArg1, TInt aArg2);
    1.59 +	TInt TestFunction0(const TDesC8& aData0, const TDesC& aData1);
    1.60 +	TInt TestFunction1(TInt aArg0, TInt aArg1);
    1.61 +	TInt TestFunction2(TInt aArg0, TInt aArg1);
    1.62 +	TInt TestFunction3(TInt aArg0, TInt aArg1);
    1.63 +
    1.64 +	TInt TestFunction4(const TDesC8& aData0, const TDesC& aData1);
    1.65 +	TInt TestFunction4(const TDesC& aData0, const TDesC8& aData1);
    1.66 +	TInt TestFunction4(const TDesC8& aData0);
    1.67 +	TInt TestFunction5(const TDesC8& aData0, const TDesC& aData1);
    1.68 +	TInt TestFunction6(const TDesC8& aData0, const TDesC& aData1);
    1.69 +	TInt TestFunction7(const TDesC8& aData0, const TDesC& aData1);
    1.70 +	TInt TestFunction8(const TDesC8& aData0, const TDesC& aData1);
    1.71 +
    1.72 +	TInt TestFunction9(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1);
    1.73 +	TInt TestFunction9(TDes& aData0,TInt aOffset0, TDes8& aData1,TInt aOffset1);
    1.74 +	TInt TestFunction10(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1);
    1.75 +	TInt TestFunction11(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1);
    1.76 +	TInt TestFunction12(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1);
    1.77 +	TInt TestFunction13(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1);
    1.78 +	TInt TestFunction14(const TDesC8& aData0,TInt aOffset0, TDes8& aData1);
    1.79 +	TInt TestFunction15(const TDesC& aData0,TInt aOffset0, TDes& aData1);
    1.80 +
    1.81 +	TInt TestFunction16(TAny* aData);
    1.82 +	TInt TestFunction17(TAny* aData);
    1.83 +
    1.84 +	TInt TestFunction18(TDes8& aData);
    1.85 +	TInt TestFunction18(TDes16& aData);
    1.86 +	TInt TestFunction19(TDes8& aData);
    1.87 +
    1.88 +	TInt TestFunction20(TInt aArg0, TInt aArg1);
    1.89 +	TInt TestFunction21(TInt aArg0, TInt aArg1);
    1.90 +	TInt TestFunction22(TInt aArg0, TInt aArg1);
    1.91 +	TInt TestFunction23(TInt aArg0, TInt aArg1);
    1.92 +	TInt TestFunction24(TInt aArg0, TInt aArg1);
    1.93 +
    1.94 +	TInt TestFunction25();
    1.95 +	TInt TestFunction26();
    1.96 +	TInt TestFunction27();
    1.97 +	TInt TestFunction28(TInt aArg0);
    1.98 +	TInt TestFunction29(TDes& aData);
    1.99 +	TInt TestFunction30(TDes8& aData);
   1.100 +	TInt TestFunction31(TInt aArg0);
   1.101 +	TInt TestFunction32(TDes8& aData);
   1.102 +
   1.103 +	TInt TestInvalidFunction(TInt aFn);
   1.104 +
   1.105 +
   1.106 +	};
   1.107 +
   1.108 +/*RClientMessageTestSession2 client side interface to
   1.109 + * CClientMessageTestServer2 server.  This is used to pass
   1.110 + * messages to the server to testthe Client Message Framework.
   1.111 + */
   1.112 +class RClientMessageTestSession2 : public RSessionBase
   1.113 +	{
   1.114 +public:
   1.115 +	TInt Connect();
   1.116 +
   1.117 +	TInt TestFunction0(TInt aArg0, TInt aArg1);
   1.118 +	
   1.119 +	TInt TestFunction1(const TDesC& aData0);
   1.120 +
   1.121 +	};
   1.122 +
   1.123 +//Global process that is accessible in test code to determine the
   1.124 +//exit reason and category on termination
   1.125 +RProcess serverProcess;
   1.126 +
   1.127 +//Launch the server process
   1.128 +static TInt LaunchServer()
   1.129 +	{
   1.130 +	TInt err = serverProcess.Create(KServerFileName,_L(""));
   1.131 +
   1.132 +	if(err == KErrNone)
   1.133 +		{
   1.134 +		 TRequestStatus serverStat;
   1.135 +
   1.136 +		 serverProcess.SetJustInTime(EFalse);
   1.137 +		 serverProcess.Rendezvous(serverStat);
   1.138 +		 serverProcess.Resume();
   1.139 +		 User::WaitForRequest(serverStat);
   1.140 +		}
   1.141 +
   1.142 +	return err;
   1.143 +	}
   1.144 +
   1.145 +
   1.146 +/* Connect to the CClientMessageTestServer, launching
   1.147 + * the sevrer process if necessary
   1.148 + */
   1.149 +TInt RClientMessageTestSession::Connect()
   1.150 +	{
   1.151 +	TInt retry = 2;
   1.152 +	for(;;)
   1.153 +		{
   1.154 +		TInt r = CreateSession(KServerName,TVersion(1,0,0));
   1.155 +
   1.156 +		if((r != KErrNotFound)&&(r != KErrServerTerminated))
   1.157 +			{
   1.158 +			return r;
   1.159 +			}
   1.160 +
   1.161 +		if(--retry == 0)
   1.162 +			{
   1.163 +			return r;
   1.164 +			}
   1.165 +
   1.166 +		r = LaunchServer();
   1.167 +		if((r != KErrNone)&&(r != KErrAlreadyExists))
   1.168 +			{
   1.169 +			return r;
   1.170 +			}
   1.171 +		}
   1.172 +	}
   1.173 +
   1.174 +/* These functions are used to send IPC messages to the server.
   1.175 + * The messages are sent with different parameters to test the
   1.176 + * ClientMessage framework handling of bad messages
   1.177 + */
   1.178 +TInt RClientMessageTestSession::TestFunction0(TInt aArg0, TInt aArg1)
   1.179 +	{
   1.180 +	return SendReceive(ETestMessage0,TIpcArgs(aArg0,aArg1));
   1.181 +	}
   1.182 +
   1.183 +TInt RClientMessageTestSession::TestFunction0(TInt aArg0)
   1.184 +	{
   1.185 +	return SendReceive(ETestMessage0,TIpcArgs(aArg0));
   1.186 +	}
   1.187 +
   1.188 +TInt RClientMessageTestSession::TestFunction0(TInt aArg0, TInt aArg1, TInt aArg2)
   1.189 +	{
   1.190 +	return SendReceive(ETestMessage0,TIpcArgs(aArg0,aArg1,aArg2));
   1.191 +	}
   1.192 +
   1.193 +TInt RClientMessageTestSession::TestFunction0(const TDesC8& aData0, const TDesC& aData1)
   1.194 +	{
   1.195 +	//Call the function passing invalid arguments
   1.196 +	return SendReceive(ETestMessage0,TIpcArgs(&aData0,&aData1));
   1.197 +	}
   1.198 +
   1.199 +TInt RClientMessageTestSession::TestFunction1(TInt aArg0, TInt aArg1)
   1.200 +	{
   1.201 +	return SendReceive(ETestMessage1,TIpcArgs(aArg0,aArg1));
   1.202 +	}
   1.203 +
   1.204 +TInt RClientMessageTestSession::TestFunction2(TInt aArg0, TInt aArg1)
   1.205 +	{
   1.206 +	return SendReceive(ETestMessage2,TIpcArgs(aArg0,aArg1));
   1.207 +	}
   1.208 +
   1.209 +TInt RClientMessageTestSession::TestFunction3(TInt aArg0, TInt aArg1)
   1.210 +	{
   1.211 +	return SendReceive(ETestMessage3,TIpcArgs(aArg0,aArg1));
   1.212 +	}
   1.213 +
   1.214 +TInt RClientMessageTestSession::TestFunction4(const TDesC8& aData0, const TDesC& aData1)
   1.215 +	{
   1.216 +	return SendReceive(ETestMessage4,TIpcArgs(&aData0,&aData1));
   1.217 +	}
   1.218 +
   1.219 +TInt RClientMessageTestSession::TestFunction4(const TDesC& aData0, const TDesC8& aData1)
   1.220 +	{
   1.221 +	return SendReceive(ETestMessage4,TIpcArgs(&aData0,&aData1));
   1.222 +	}
   1.223 +
   1.224 +TInt RClientMessageTestSession::TestFunction4(const TDesC8& aData0)
   1.225 +	{
   1.226 +	return SendReceive(ETestMessage4,TIpcArgs(&aData0));
   1.227 +	}
   1.228 +
   1.229 +TInt RClientMessageTestSession::TestFunction5(const TDesC8& aData0, const TDesC& aData1)
   1.230 +	{
   1.231 +	return SendReceive(ETestMessage5,TIpcArgs(&aData0,&aData1));
   1.232 +	}
   1.233 +
   1.234 +TInt RClientMessageTestSession::TestFunction6(const TDesC8& aData0, const TDesC& aData1)
   1.235 +	{
   1.236 +	return SendReceive(ETestMessage6,TIpcArgs(&aData0,&aData1));
   1.237 +	}
   1.238 +
   1.239 +TInt RClientMessageTestSession::TestFunction7(const TDesC8& aData0, const TDesC& aData1)
   1.240 +	{
   1.241 +	return SendReceive(ETestMessage7,TIpcArgs(&aData0,&aData1));
   1.242 +	}
   1.243 +
   1.244 +TInt RClientMessageTestSession::TestFunction8(const TDesC8& aData0, const TDesC& aData1)
   1.245 +	{
   1.246 +	return SendReceive(ETestMessage8,TIpcArgs(&aData0,&aData1));
   1.247 +	}
   1.248 +
   1.249 +TInt RClientMessageTestSession::TestFunction9(TDes& aData0,TInt aOffset0, TDes8& aData1,TInt aOffset1)
   1.250 +	{
   1.251 +	return SendReceive(ETestMessage9,TIpcArgs(&aData0,aOffset0,&aData1,aOffset1));
   1.252 +	}
   1.253 +
   1.254 +TInt RClientMessageTestSession::TestFunction9(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1)
   1.255 +	{
   1.256 +	return SendReceive(ETestMessage9,TIpcArgs(&aData0,aOffset0,&aData1,aOffset1));
   1.257 +	}
   1.258 +
   1.259 +TInt RClientMessageTestSession::TestFunction10(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1)
   1.260 +	{
   1.261 +	return SendReceive(ETestMessage10,TIpcArgs(&aData0,aOffset0,&aData1,aOffset1));
   1.262 +	}
   1.263 +
   1.264 +TInt RClientMessageTestSession::TestFunction11(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1)
   1.265 +	{
   1.266 +	return SendReceive(ETestMessage11,TIpcArgs(&aData0,aOffset0,&aData1,aOffset1));
   1.267 +	}
   1.268 +
   1.269 +TInt RClientMessageTestSession::TestFunction12(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1)
   1.270 +	{
   1.271 +	return SendReceive(ETestMessage12,TIpcArgs(&aData0,aOffset0,&aData1,aOffset1));
   1.272 +	}
   1.273 +
   1.274 +TInt RClientMessageTestSession::TestFunction13(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1)
   1.275 +	{
   1.276 +	return SendReceive(ETestMessage13,TIpcArgs(&aData0,aOffset0,&aData1,aOffset1));
   1.277 +	}
   1.278 +
   1.279 +TInt RClientMessageTestSession::TestFunction14(const TDesC8& aData0,TInt aOffset0, TDes8& aData1)
   1.280 +	{
   1.281 +	return SendReceive(ETestMessage14,TIpcArgs(&aData0,aOffset0,&aData1));
   1.282 +	}
   1.283 +
   1.284 +TInt RClientMessageTestSession::TestFunction15(const TDesC& aData0,TInt aOffset0, TDes& aData1)
   1.285 +	{
   1.286 +	return SendReceive(ETestMessage15,TIpcArgs(&aData0,aOffset0,&aData1));
   1.287 +	}
   1.288 +
   1.289 +TInt RClientMessageTestSession::TestFunction16(TAny* aData)
   1.290 +	{
   1.291 +	return SendReceive(ETestMessage16,TIpcArgs(aData));
   1.292 +	}
   1.293 +
   1.294 +TInt RClientMessageTestSession::TestFunction17(TAny* aData)
   1.295 +	{
   1.296 +	return SendReceive(ETestMessage17,TIpcArgs(aData));
   1.297 +	}
   1.298 +
   1.299 +TInt RClientMessageTestSession::TestFunction18(TDes8& aData)
   1.300 +	{
   1.301 +	return SendReceive(ETestMessage18,TIpcArgs(&aData));
   1.302 +	}
   1.303 +
   1.304 +TInt RClientMessageTestSession::TestFunction18(TDes& aData)
   1.305 +	{
   1.306 +	return SendReceive(ETestMessage18,TIpcArgs(&aData));
   1.307 +	}
   1.308 +
   1.309 +TInt RClientMessageTestSession::TestFunction19(TDes8& aData)
   1.310 +	{
   1.311 +	return SendReceive(ETestMessage19,TIpcArgs(&aData));
   1.312 +	}
   1.313 +
   1.314 +TInt RClientMessageTestSession::TestFunction20(TInt aArg0, TInt aArg1)
   1.315 +	{
   1.316 +	return SendReceive(ETestMessage20,TIpcArgs(aArg0,aArg1));
   1.317 +	}
   1.318 +
   1.319 +TInt RClientMessageTestSession::TestFunction21(TInt aArg0, TInt aArg1)
   1.320 +	{
   1.321 +	return SendReceive(ETestMessage21,TIpcArgs(aArg0,aArg1));
   1.322 +	}
   1.323 +
   1.324 +TInt RClientMessageTestSession::TestFunction22(TInt aArg0, TInt aArg1)
   1.325 +	{
   1.326 +	return SendReceive(ETestMessage22,TIpcArgs(aArg0,aArg1));
   1.327 +	}
   1.328 +
   1.329 +TInt RClientMessageTestSession::TestFunction23(TInt aArg0, TInt aArg1)
   1.330 +	{
   1.331 +	return SendReceive(ETestMessage23,TIpcArgs(aArg0,aArg1));
   1.332 +	}
   1.333 +
   1.334 +TInt RClientMessageTestSession::TestFunction24(TInt aArg0, TInt aArg1)
   1.335 +	{
   1.336 +	return SendReceive(ETestMessage24,TIpcArgs(aArg0,aArg1));
   1.337 +	}
   1.338 +
   1.339 +TInt RClientMessageTestSession::TestFunction25()
   1.340 +	{
   1.341 +	return SendReceive(ETestMessage25,TIpcArgs());
   1.342 +	}
   1.343 +
   1.344 +TInt RClientMessageTestSession::TestFunction26()
   1.345 +	{
   1.346 +	return SendReceive(ETestMessage26,TIpcArgs());
   1.347 +	}
   1.348 +
   1.349 +TInt RClientMessageTestSession::TestFunction27()
   1.350 +	{
   1.351 +	return SendReceive(ETestMessage27,TIpcArgs());
   1.352 +	}
   1.353 +
   1.354 +TInt RClientMessageTestSession::TestFunction28(TInt aArg0)
   1.355 +	{
   1.356 +	return SendReceive(ETestMessage28,TIpcArgs(aArg0));
   1.357 +	}
   1.358 +
   1.359 +TInt RClientMessageTestSession::TestFunction29(TDes& aData)
   1.360 +	{
   1.361 +	return SendReceive(ETestMessage29,TIpcArgs(&aData));
   1.362 +	}
   1.363 +
   1.364 +TInt RClientMessageTestSession::TestFunction30(TDes8& aData)
   1.365 +	{
   1.366 +	return SendReceive(ETestMessage30,TIpcArgs(&aData));
   1.367 +	}
   1.368 +
   1.369 +TInt RClientMessageTestSession::TestFunction31(TInt aArg0)
   1.370 +	{
   1.371 +	return SendReceive(ETestMessage31,TIpcArgs(aArg0));
   1.372 +	}
   1.373 +
   1.374 +TInt RClientMessageTestSession::TestFunction32(TDes8& aData)
   1.375 +	{
   1.376 +	return SendReceive(ETestMessage32,TIpcArgs(&aData));
   1.377 +	}
   1.378 +
   1.379 +TInt RClientMessageTestSession::TestInvalidFunction(TInt aFn)
   1.380 +	{
   1.381 +	return SendReceive(aFn,TIpcArgs());
   1.382 +	}
   1.383 +
   1.384 +/* This function is the entry point for a new thread.  It calls the
   1.385 + * function passed to it as a TAny*.
   1.386 + */
   1.387 +TInt TestFunctionLauncherL(TAny* aTestFunction)
   1.388 +	{
   1.389 +   	CTrapCleanup* cleanup=CTrapCleanup::New();
   1.390 +   	TInt r=KErrNoMemory;
   1.391 +   	if (cleanup)
   1.392 +   		{
   1.393 +   		TestFunction function = (TestFunction)aTestFunction;
   1.394 +
   1.395 +__UHEAP_MARK;
   1.396 + 		TRAP(r,function());
   1.397 +__UHEAP_MARKEND;
   1.398 +
   1.399 +   		delete cleanup;
   1.400 +   		}
   1.401 +   	return r;
   1.402 +	}
   1.403 +
   1.404 +/* This function creates a new thread and passes through the test function
   1.405 + * to be called.  It also monitors and returns the exit reason for the launched
   1.406 + * thread.
   1.407 + */
   1.408 +TExitDetails LaunchTestThreadL(const TDesC& aThreadName, TestFunction aFunction)
   1.409 +	{
   1.410 +	RThread thread;
   1.411 +	TInt err = thread.Create(aThreadName, &TestFunctionLauncherL, KDefaultStackSize, NULL, (TAny*)aFunction);
   1.412 +
   1.413 +	if(err != KErrAlreadyExists)
   1.414 +		{
   1.415 +		User::LeaveIfError(err);
   1.416 +		}
   1.417 +
   1.418 +	TRequestStatus threadStat;
   1.419 +	thread.Logon(threadStat);
   1.420 +
   1.421 +	TBool jit = User::JustInTime();
   1.422 +	User::SetJustInTime(EFalse);
   1.423 +
   1.424 +	thread.Resume();
   1.425 +	User::WaitForRequest(threadStat);
   1.426 +
   1.427 +	User::SetJustInTime(jit);
   1.428 +
   1.429 +	TExitDetails exitDetails;
   1.430 +	exitDetails.iCategory = thread.ExitCategory();
   1.431 +	exitDetails.iReason = thread.ExitReason();
   1.432 +	exitDetails.iExitType = thread.ExitType();
   1.433 +
   1.434 +	return exitDetails;
   1.435 +	}
   1.436 +
   1.437 +
   1.438 +/*
   1.439 + This test function accepts 2 integer parameters as defined below
   1.440 +{EParamInt,-10,100},{EParamInt,0,200}
   1.441 +Any calls to this function with parameters outside the ranges
   1.442 +defined above should fail with KErrBadParameter
   1.443 +*/
   1.444 +void TestFunction0AL()
   1.445 +	{
   1.446 +	RClientMessageTestSession session;
   1.447 +
   1.448 +	TInt err = session.Connect();
   1.449 +	Test(err == KErrNone);
   1.450 +
   1.451 +	CleanupClosePushL(session);
   1.452 +
   1.453 +	err = session.TestFunction0( 0, 100);
   1.454 +	Test(err == KErrNone);
   1.455 +
   1.456 +	err = session.TestFunction0( 100, 0);
   1.457 +	Test(err == KErrNone);
   1.458 +
   1.459 +	err = session.TestFunction0( -5, 10);
   1.460 +	Test(err == KErrNone);
   1.461 +
   1.462 +	err = session.TestFunction0( -5, -10);
   1.463 +	Test(err == KErrBadParameter);
   1.464 +
   1.465 +	err = session.TestFunction0( -15, 10);
   1.466 +	Test(err == KErrBadParameter);
   1.467 +
   1.468 +	err = session.TestFunction0( -10, 200);
   1.469 +	Test(err == KErrNone);
   1.470 +
   1.471 +	err = session.TestFunction0( 101, 102);
   1.472 +	Test(err == KErrBadParameter);
   1.473 +
   1.474 +	err = session.TestFunction0(11, 56, 43);
   1.475 +	Test(err == KErrNone);
   1.476 +
   1.477 +	err = session.TestFunction0( _L8("Des8"), _L("Des"));
   1.478 +	Test(err == KErrBadParameter);
   1.479 +
   1.480 +	CleanupStack::PopAndDestroy(&session);
   1.481 +	}
   1.482 +
   1.483 +
   1.484 +/*
   1.485 + This test function accepts 2 integer parameters as defined below
   1.486 +{EParamInt,-10,100},{EParamInt,0,200}
   1.487 +In the server, this function tries to access a ptr type from
   1.488 +an int argument. This is a programming error and should result
   1.489 +in the server panicking with ECMPanicWrongParameterType in UDEB
   1.490 +or returning KErrWrongParameterType in UREL
   1.491 +*/
   1.492 +void TestFunction1L()
   1.493 +	{
   1.494 +	RClientMessageTestSession session;
   1.495 +
   1.496 +	TInt err = session.Connect();
   1.497 +	Test(err == KErrNone);
   1.498 +
   1.499 +	CleanupClosePushL(session);
   1.500 +
   1.501 +	err = session.TestFunction1(10,100);
   1.502 +
   1.503 +#ifdef _DEBUG
   1.504 +	Test(err == KErrServerTerminated);
   1.505 +
   1.506 +	TInt type = serverProcess.ExitType();
   1.507 +	Test(type == EExitPanic);
   1.508 +
   1.509 +	TInt reason = serverProcess.ExitReason();
   1.510 +	Test(reason == ECMPanicWrongParameterType);
   1.511 +#else
   1.512 +	Test(err == KErrWrongParameterType);
   1.513 +#endif
   1.514 +	CleanupStack::PopAndDestroy(&session);
   1.515 +	}
   1.516 +
   1.517 +/*
   1.518 + This test function accepts 1 integer parameter as defined below
   1.519 +{EParamInt,100,10}
   1.520 +As can be seen above, the schema is incorrectly defined as iMin is
   1.521 +greater than iMax. This is a programming error and should result
   1.522 +in the server panicking with ECMPanicBadMessageSchema in UDEB
   1.523 +or returning KErrBadParameter in UREL
   1.524 +*/
   1.525 +void TestFunction2L()
   1.526 +	{
   1.527 +	RClientMessageTestSession session;
   1.528 +
   1.529 +	TInt err = session.Connect();
   1.530 +	Test(err == KErrNone);
   1.531 +
   1.532 +	CleanupClosePushL(session);
   1.533 +
   1.534 +	//this function is incorrectly defined in the
   1.535 +	//message schema. This should result in the
   1.536 +	//server panicking
   1.537 +	err = session.TestFunction2(10,100);
   1.538 +
   1.539 +	//In debug builds the server should panic.
   1.540 +	//In release builds KErrBadParameter should be returned
   1.541 +#ifdef _DEBUG
   1.542 +	Test(err == KErrServerTerminated);
   1.543 +
   1.544 +	TInt type = serverProcess.ExitType();
   1.545 +	Test(type == EExitPanic);
   1.546 +
   1.547 +	TInt reason = serverProcess.ExitReason();
   1.548 +	Test(reason == ECMPanicBadMessageSchema);
   1.549 +#else
   1.550 +	Test(err == KErrBadParameter);
   1.551 +#endif
   1.552 +
   1.553 +	CleanupStack::PopAndDestroy(&session);
   1.554 +	}
   1.555 +
   1.556 +/*
   1.557 + This test function accepts 1 integer parameter as defined below
   1.558 +{EParamInt,-10,-20}
   1.559 +As can be seen above, the schema is incorrectly defined as iMin is
   1.560 +greater than iMax. This is a programming error and should result
   1.561 +in the server panicking with ECMPanicBadMessageSchema in UDEB
   1.562 +or returning KErrBadParameter in UREL
   1.563 +*/
   1.564 +void TestFunction3L()
   1.565 +	{
   1.566 +	RClientMessageTestSession session;
   1.567 +
   1.568 +	TInt err = session.Connect();
   1.569 +	Test(err == KErrNone);
   1.570 +
   1.571 +	CleanupClosePushL(session);
   1.572 +
   1.573 +	//this function is incorrectly defined in the
   1.574 +	//message schema. This should result in the
   1.575 +	//server panicking
   1.576 +	err = session.TestFunction3(10,100);
   1.577 +
   1.578 +	//In debug builds the server should panic.
   1.579 +	//In release builds KErrBadParameter should be returned
   1.580 +#ifdef _DEBUG
   1.581 +	Test(err == KErrServerTerminated);
   1.582 +
   1.583 +	TInt type = serverProcess.ExitType();
   1.584 +	Test(type == EExitPanic);
   1.585 +
   1.586 +	TInt reason = serverProcess.ExitReason();
   1.587 +	Test(reason == ECMPanicBadMessageSchema);
   1.588 +#else
   1.589 +	Test(err == KErrBadParameter);
   1.590 +#endif
   1.591 +
   1.592 +	CleanupStack::PopAndDestroy(&session);
   1.593 +	}
   1.594 +
   1.595 +/*
   1.596 + This test function accepts 2 descriptor parameters as defined below
   1.597 +{EParamDes8Read,2,16},{EParamDes16Read,0,32}
   1.598 +Any calls to this function with parameters outside the constraints
   1.599 +defined above should result in the client being panicked with
   1.600 +KErrBadDescriptor
   1.601 +*/
   1.602 +void TestFunction4AL()
   1.603 +	{
   1.604 +	RClientMessageTestSession session;
   1.605 +	_LIT8(KDes8, "Des8");
   1.606 +	_LIT8(KShortDes8, "De");
   1.607 +	_LIT(KDes16, "Des16");
   1.608 +	_LIT(KLongDes16, "Des16 - A longer version");
   1.609 +
   1.610 +	TInt err = session.Connect();
   1.611 +	Test(err == KErrNone);
   1.612 +
   1.613 +	CleanupClosePushL(session);
   1.614 +
   1.615 +	err = session.TestFunction4(KDes8,KDes16);
   1.616 +	Test(err == KErrNone);
   1.617 +
   1.618 +	err = session.TestFunction4(KShortDes8,KLongDes16);
   1.619 +	Test(err == KErrNone);
   1.620 +
   1.621 +	CleanupStack::PopAndDestroy(&session);
   1.622 +	}
   1.623 +
   1.624 +/*
   1.625 + This test function accepts 2 descriptor parameters as defined below
   1.626 +{EParamDes8Read,2,16},{EParamDes16Read,0,32}
   1.627 +Any calls to this function with parameters outside the constraints
   1.628 +defined above should result in the client being panicked with
   1.629 +KErrBadDescriptor
   1.630 +*/
   1.631 +void TestFunction4BL()
   1.632 +	{
   1.633 +	RClientMessageTestSession session;
   1.634 +	_LIT8(KDes8, "Des8");
   1.635 +	_LIT(KDes16, "Des16");
   1.636 +
   1.637 +	TInt err = session.Connect();
   1.638 +	Test(err == KErrNone);
   1.639 +
   1.640 +	CleanupClosePushL(session);
   1.641 +
   1.642 +	//This should result in the server panicking the client
   1.643 +	err = session.TestFunction4(KDes16,KDes8);
   1.644 +
   1.645 +	CleanupStack::PopAndDestroy(&session);
   1.646 +	}
   1.647 +
   1.648 +/*
   1.649 + This test function accepts 2 descriptor parameters as defined below
   1.650 +{EParamDes8Read,2,16},{EParamDes16Read,0,32}
   1.651 +Any calls to this function with parameters outside the constraints
   1.652 +defined above should result in the client being panicked with
   1.653 +KErrBadDescriptor
   1.654 +*/
   1.655 +void TestFunction4CL()
   1.656 +	{
   1.657 +	RClientMessageTestSession session;
   1.658 +	_LIT(KDes16, "Des16");
   1.659 +	_LIT8(KLongDes8, "This is a long Des8");
   1.660 +
   1.661 +	TInt err = session.Connect();
   1.662 +	Test(err == KErrNone);
   1.663 +
   1.664 +	CleanupClosePushL(session);
   1.665 +
   1.666 +	//This should result in the server panicing the client
   1.667 +	err = session.TestFunction4(KLongDes8,KDes16);
   1.668 +
   1.669 +	CleanupStack::PopAndDestroy(&session);
   1.670 +	}
   1.671 +
   1.672 +/*
   1.673 +This test function accepts 2 descriptor parameters as defined below
   1.674 +{EParamDes8Read,2,16},{EParamDes16Read,0,32}
   1.675 +Any calls to this function with parameters outside the constraints
   1.676 +defined above should result in the client being panicked with
   1.677 +KErrBadDescriptor
   1.678 +*/
   1.679 +void TestFunction4DL()
   1.680 +	{
   1.681 +	RClientMessageTestSession session;
   1.682 +	_LIT8(KDes8, "Des8");
   1.683 +	_LIT(KLongDes16, "This is a long Des16 that should cause an issue");
   1.684 +
   1.685 +	TInt err = session.Connect();
   1.686 +	Test(err == KErrNone);
   1.687 +
   1.688 +	CleanupClosePushL(session);
   1.689 +
   1.690 +	//This should result in the server panicing the client
   1.691 +	err = session.TestFunction4(KDes8,KLongDes16);
   1.692 +
   1.693 +	CleanupStack::PopAndDestroy(&session);
   1.694 +	}
   1.695 +
   1.696 +/*
   1.697 +This test function accepts 2 descriptor parameters as defined below
   1.698 +{EParamDes8Read,2,16},{EParamDes16Read,0,32}
   1.699 +Any calls to this function with parameters outside the constraints
   1.700 +defined above should result in the client being panicked with
   1.701 +KErrBadDescriptor
   1.702 +*/
   1.703 +void TestFunction4EL()
   1.704 +	{
   1.705 +	RClientMessageTestSession session;
   1.706 +	_LIT(KDes16, "Des16");
   1.707 +	_LIT8(KEmptyDes8, "");
   1.708 +	TInt err = session.Connect();
   1.709 +	Test(err == KErrNone);
   1.710 +
   1.711 +	CleanupClosePushL(session);
   1.712 +
   1.713 +	//This should result in the server panicing the client
   1.714 +	//as the function expects a descriptor of minimum length 2
   1.715 +	err = session.TestFunction4(KEmptyDes8,KDes16);
   1.716 +
   1.717 +	CleanupStack::PopAndDestroy(&session);
   1.718 +	}
   1.719 +
   1.720 +/*
   1.721 +This test function accepts 2 descriptor parameters as defined below
   1.722 +{EParamDes8Read,2,16},{EParamDes16Read,0,32}
   1.723 +Any calls to this function with parameters outside the constraints
   1.724 +defined above should result in the client being panicked with
   1.725 +KErrBadDescriptor
   1.726 +*/
   1.727 +void TestFunction4FL()
   1.728 +	{
   1.729 +	RClientMessageTestSession session;
   1.730 +	_LIT8(KDes8, "Des8");
   1.731 +	TInt err = session.Connect();
   1.732 +	Test(err == KErrNone);
   1.733 +
   1.734 +	CleanupClosePushL(session);
   1.735 +
   1.736 +	//This should result in the server panicing the client
   1.737 +	//as the function expects 2 descriptor arguments
   1.738 +	err = session.TestFunction4(KDes8);
   1.739 +
   1.740 +	CleanupStack::PopAndDestroy(&session);
   1.741 +	}
   1.742 +
   1.743 +
   1.744 +/*
   1.745 +This test function accepts 2 descriptor parameters as defined below
   1.746 +{EParamDes8Read,2,16},{EParamDes16Read,0,32}
   1.747 +The server attempts to read from the first descriptor but passes
   1.748 +in a buffer that is too small.  This is a programming error and
   1.749 +should result in the server panicking with ECMPanicBadDescriptor in UDEB
   1.750 +and returning KErrNone in UREL
   1.751 +KErrBadDescriptor
   1.752 +*/
   1.753 +void TestFunction5L()
   1.754 +	{
   1.755 +	RClientMessageTestSession session;
   1.756 +	_LIT8(KDes8, "Des8");
   1.757 +	_LIT(KDes16, "Des16");
   1.758 +
   1.759 +	TInt err = session.Connect();
   1.760 +	Test(err == KErrNone);
   1.761 +
   1.762 +	CleanupClosePushL(session);
   1.763 +
   1.764 +	err = session.TestFunction5(KDes8,KDes16);
   1.765 +#ifdef _DEBUG
   1.766 +	Test(err == KErrServerTerminated);
   1.767 +
   1.768 +	TInt type = serverProcess.ExitType();
   1.769 +	Test(type == EExitPanic);
   1.770 +
   1.771 +	TInt reason = serverProcess.ExitReason();
   1.772 +	Test(reason == ECMPanicBadDescriptor);
   1.773 +#else
   1.774 +	Test(err == KErrNone);
   1.775 +#endif
   1.776 +
   1.777 +	CleanupStack::PopAndDestroy(&session);
   1.778 +	}
   1.779 +
   1.780 +/*
   1.781 +This test function accepts 2 descriptor parameters as defined below
   1.782 +{EParamDes8Read,2,16},{EParamDes16Read,0,32}
   1.783 +Any calls to this function with parameters outside the constraints
   1.784 +defined above should result in the client being panicked with
   1.785 +KErrBadDescriptor
   1.786 +*/
   1.787 +void TestFunction6L()
   1.788 +	{
   1.789 +	RClientMessageTestSession session;
   1.790 +	_LIT8(KDes8, "Des8");
   1.791 +	_LIT(KDes16, "Des16");
   1.792 +
   1.793 +	TInt err = session.Connect();
   1.794 +	Test(err == KErrNone);
   1.795 +
   1.796 +	CleanupClosePushL(session);
   1.797 +
   1.798 +	err = session.TestFunction6(KDes8,KDes16);
   1.799 +	Test(err == KErrArgument);
   1.800 +
   1.801 +	CleanupStack::PopAndDestroy(&session);
   1.802 +	}
   1.803 +
   1.804 +/*
   1.805 +This test function accepts 2 descriptor parameters as defined below
   1.806 +{EParamDes8Read,2,16},{EParamDes16Read,0,32}
   1.807 +Any calls to this function with parameters outside the constraints
   1.808 +defined above should result in the client being panicked with
   1.809 +KErrBadDescriptor
   1.810 +*/
   1.811 +void TestFunction7L()
   1.812 +	{
   1.813 +	RClientMessageTestSession session;
   1.814 +	_LIT8(KDes8, "Descriptor8");
   1.815 +	_LIT(KDes16, "Descriptor16");
   1.816 +
   1.817 +	TInt err = session.Connect();
   1.818 +	Test(err == KErrNone);
   1.819 +
   1.820 +	CleanupClosePushL(session);
   1.821 +
   1.822 +	err = session.TestFunction7(KDes8,KDes16);
   1.823 +	Test(err == KErrNone);
   1.824 +
   1.825 +	CleanupStack::PopAndDestroy(&session);
   1.826 +	}
   1.827 +
   1.828 +/*
   1.829 +This test function accepts 1 descriptor parameter as defined below
   1.830 +{EParamDes8Read,0,-16}
   1.831 +As can be seen above, the schema is incorrectly defined as iMax is
   1.832 +negative. This is a programming error and should result
   1.833 +in the server panicking with ECMPanicBadMessageSchema in UDEB
   1.834 +or the client being panicked with KErrBadDescriptor in UREL
   1.835 +*/
   1.836 +void TestFunction8L()
   1.837 +	{
   1.838 +	RClientMessageTestSession session;
   1.839 +	_LIT8(KDes8, "Descriptor8");
   1.840 +	_LIT(KDes16, "Descriptor16");
   1.841 +
   1.842 +	TInt err = session.Connect();
   1.843 +	Test(err == KErrNone);
   1.844 +
   1.845 +	CleanupClosePushL(session);
   1.846 +
   1.847 +	//this function is incorrectly defined in the
   1.848 +	//message schema. This should result in the
   1.849 +	//server panicking
   1.850 +	err = session.TestFunction8(KDes8,KDes16);
   1.851 +
   1.852 +	//In debug builds the server should panic.
   1.853 +	//In release builds the client will be panicked
   1.854 +#ifdef _DEBUG
   1.855 +	Test(err == KErrServerTerminated);
   1.856 +
   1.857 +	TInt type = serverProcess.ExitType();
   1.858 +	Test(type == EExitPanic);
   1.859 +
   1.860 +	TInt reason = serverProcess.ExitReason();
   1.861 +	Test(reason == ECMPanicBadMessageSchema);
   1.862 +#endif
   1.863 +
   1.864 +	CleanupStack::PopAndDestroy(&session);
   1.865 +	}
   1.866 +
   1.867 +
   1.868 +/*
   1.869 +This test function accepts 2 descriptor parameters and 2 TInt
   1.870 +parameters as defined below
   1.871 +{EParamDes8,64,64},{EParamInt,0,64},{EParamDes16,128,128},{EParamInt,0,128}
   1.872 +Any calls to this function with descriptor parameters outside the constraints
   1.873 +defined above should result in the client being paniced with
   1.874 +KErrBadDescriptor or KErrOverflow
   1.875 +*/
   1.876 +void TestFunction9AL()
   1.877 +	{
   1.878 +	TBuf8<64> buf8;
   1.879 +	TBuf<128> buf;
   1.880 +	TBuf8<64> buf82;
   1.881 +	TBuf<128> buf2;
   1.882 +
   1.883 +	RClientMessageTestSession session;
   1.884 +
   1.885 +	TInt err = session.Connect();
   1.886 +	Test(err == KErrNone);
   1.887 +
   1.888 +	CleanupClosePushL(session);
   1.889 +
   1.890 +	err = session.TestFunction9(buf8,0,buf,0);
   1.891 +	Test(err == KErrNone);
   1.892 +	Test(buf8.Find(_L8("CClientMessageTest")) == 0);
   1.893 +	Test(buf.Find(_L("CClientMessageTest")) == 0);
   1.894 +
   1.895 +	err = session.TestFunction9(buf82,7,buf2,73);
   1.896 +	Test(err == KErrNone);
   1.897 +	Test(buf82.Find(_L8("CClientMessageTest")) == 7);
   1.898 +	Test(buf2.Find(_L("CClientMessageTest")) == 73);
   1.899 +
   1.900 +	CleanupStack::PopAndDestroy(&session);
   1.901 +	}
   1.902 +
   1.903 +/*
   1.904 +This test function accepts 2 descriptor parameters and 2 TInt
   1.905 +parameters as defined below
   1.906 +{EParamDes8,64,64},{EParamInt,0,64},{EParamDes16,128,128},{EParamInt,0,128}
   1.907 +Any calls to this function with descriptor parameters outside the constraints
   1.908 +defined above should result in the client being paniced with
   1.909 +KErrBadDescriptor
   1.910 +*/
   1.911 +void TestFunction9BL()
   1.912 +	{
   1.913 +
   1.914 +	TBuf8<32> smallBuf8;
   1.915 +	TBuf<32> smallBuf;
   1.916 +
   1.917 +	RClientMessageTestSession session;
   1.918 +
   1.919 +	TInt err = session.Connect();
   1.920 +	Test(err == KErrNone);
   1.921 +
   1.922 +	CleanupClosePushL(session);
   1.923 +
   1.924 +	//this should result in a  client panic with KErrBadDescriptor
   1.925 +	err = session.TestFunction9(smallBuf8,0,smallBuf,0);
   1.926 +
   1.927 +	CleanupStack::PopAndDestroy(&session);
   1.928 +	}
   1.929 +
   1.930 +/*
   1.931 +This test function accepts 2 descriptor parameters and 2 TInt
   1.932 +parameters as defined below
   1.933 +{EParamDes8,64,64},{EParamInt,0,64},{EParamDes16,128,128},{EParamInt,0,128}
   1.934 +The server function attempts to write to the supplied descriptors at the
   1.935 +offsets specified by the two TInt values.  In this test the server will
   1.936 +attempt to write to the first buffer with an offset of 60 which should
   1.937 +result in the client being panicked with KErrOverflow
   1.938 +*/
   1.939 +void TestFunction9CL()
   1.940 +	{
   1.941 +
   1.942 +	TBuf8<64> buf8;
   1.943 +	TBuf<128> buf;
   1.944 +
   1.945 +	RClientMessageTestSession session;
   1.946 +
   1.947 +	TInt err = session.Connect();
   1.948 +	Test(err == KErrNone);
   1.949 +
   1.950 +	CleanupClosePushL(session);
   1.951 +
   1.952 +	//this will attempt to write a descriptor with an offset of 60
   1.953 +	//which should tresult in a client panic KErrOverflow
   1.954 +	err = session.TestFunction9(buf8,60,buf,10);
   1.955 +
   1.956 +	CleanupStack::PopAndDestroy(&session);
   1.957 +	}
   1.958 +
   1.959 +/*
   1.960 +This test function accepts 2 descriptor parameters and 2 TInt
   1.961 +parameters as defined below
   1.962 +{EParamDes8,64,64},{EParamInt,0,64},{EParamDes16,128,128},{EParamInt,0,128}
   1.963 +The test function below calls this function but passed the 8 and 16 bit
   1.964 +descriptors in the wrong order which should result in the client being
   1.965 +panicked with KErrBadDescriptor
   1.966 +*/
   1.967 +void TestFunction9DL()
   1.968 +	{
   1.969 +	TBuf8<64> buf8;
   1.970 +	TBuf<128> buf;
   1.971 +
   1.972 +	RClientMessageTestSession session;
   1.973 +
   1.974 +	TInt err = session.Connect();
   1.975 +	Test(err == KErrNone);
   1.976 +
   1.977 +	CleanupClosePushL(session);
   1.978 +
   1.979 +	//this should result in a client panic as the descriptors
   1.980 +	//are passed in in the wrong order
   1.981 +	err = session.TestFunction9(buf,0,buf8,10);
   1.982 +
   1.983 +	CleanupStack::PopAndDestroy(&session);
   1.984 +	}
   1.985 +
   1.986 +/*
   1.987 +This test function accepts 2 descriptor parameters and 2 TInt
   1.988 +parameters as defined below
   1.989 +{EParamDes8,64,64},{EParamInt,0,64},{EParamDes16,128,128},{EParamInt,0,128}
   1.990 +The server function attempts to write a descriptor that is larger than the
   1.991 +buffer supplied by the client which should result in the client being
   1.992 +panicked with KErrOverflow
   1.993 +*/
   1.994 +void TestFunction10L()
   1.995 +	{
   1.996 +
   1.997 +	TBuf8<64> buf8;
   1.998 +	TBuf<128> buf;
   1.999 +
  1.1000 +	RClientMessageTestSession session;
  1.1001 +
  1.1002 +	TInt err = session.Connect();
  1.1003 +	Test(err == KErrNone);
  1.1004 +
  1.1005 +	CleanupClosePushL(session);
  1.1006 +
  1.1007 +	//This function tries to write a descriptor
  1.1008 +	//that is larger than the declared buffer
  1.1009 +	//this should result in a panic
  1.1010 +	err = session.TestFunction10(buf8,0,buf,0);
  1.1011 +
  1.1012 +	CleanupStack::PopAndDestroy(&session);
  1.1013 +	}
  1.1014 +
  1.1015 +/*
  1.1016 +This test function accepts 2 descriptor parameters and 2 TInt
  1.1017 +parameters as defined below
  1.1018 +{EParamDes8,64,64},{EParamInt,0,64},{EParamDes16,128,128},{EParamInt,0,128}
  1.1019 +The server function attempts to read from a descriptor that is smaller
  1.1020 +than the specified minimum length.  This is a programming error and
  1.1021 +should result in the server panicking with ECMPanicBadDescriptor in UDEB
  1.1022 +and returning KErrNone in UREL
  1.1023 +*/
  1.1024 +void TestFunction11L()
  1.1025 +	{
  1.1026 +	_LIT8(KLongDes8,"This descriptor is longer than 32 characters");
  1.1027 +	TBuf8<64> buf8(KLongDes8);
  1.1028 +	TBuf<128> buf;
  1.1029 +
  1.1030 +	RClientMessageTestSession session;
  1.1031 +
  1.1032 +	TInt err = session.Connect();
  1.1033 +	Test(err == KErrNone);
  1.1034 +
  1.1035 +	CleanupClosePushL(session);
  1.1036 +
  1.1037 +	//This function tries to read from a descriptor
  1.1038 +	//into a buffer that is smaller than the allowed min length
  1.1039 +	//this should result in a server panic
  1.1040 +	err = session.TestFunction11(buf8,0,buf,0);
  1.1041 +#ifdef _DEBUG
  1.1042 +	Test(err == KErrServerTerminated);
  1.1043 +
  1.1044 +	TInt type = serverProcess.ExitType();
  1.1045 +	Test(type == EExitPanic);
  1.1046 +
  1.1047 +	TInt reason = serverProcess.ExitReason();
  1.1048 +	Test(reason == ECMPanicBadDescriptor);
  1.1049 +#else
  1.1050 +	Test(err == KErrNone);
  1.1051 +#endif
  1.1052 +
  1.1053 +	CleanupStack::PopAndDestroy(&session);
  1.1054 +	}
  1.1055 +
  1.1056 +/*
  1.1057 +This test function accepts 1 descriptor parameter as defined below
  1.1058 +{EParamDes8,-64,64}
  1.1059 +As can be seen above, the schema is incorrectly defined as iMin is
  1.1060 +negative. This is a programming error and should result
  1.1061 +in the server panicking with ECMPanicBadMessageSchema in UDEB
  1.1062 +or returning KErrNone in UREL
  1.1063 +*/
  1.1064 +void TestFunction12L()
  1.1065 +	{
  1.1066 +
  1.1067 +	TBuf8<64> buf8;
  1.1068 +	TBuf<128> buf;
  1.1069 +
  1.1070 +	RClientMessageTestSession session;
  1.1071 +
  1.1072 +	TInt err = session.Connect();
  1.1073 +	Test(err == KErrNone);
  1.1074 +
  1.1075 +	CleanupClosePushL(session);
  1.1076 +
  1.1077 +	//this function is incorrectly defined in the
  1.1078 +	//message schema. This should result in the
  1.1079 +	//server panicking in debug builds
  1.1080 +	//In release builds KErrNone should be returned
  1.1081 +	err = session.TestFunction12(buf8,0,buf,0);
  1.1082 +
  1.1083 +#ifdef _DEBUG
  1.1084 +	Test(err == KErrServerTerminated);
  1.1085 +
  1.1086 +	TInt type = serverProcess.ExitType();
  1.1087 +	Test(type == EExitPanic);
  1.1088 +
  1.1089 +	TInt reason = serverProcess.ExitReason();
  1.1090 +	Test(reason == ECMPanicBadMessageSchema);
  1.1091 +#else
  1.1092 +	Test(err == KErrNone);
  1.1093 +#endif
  1.1094 +	CleanupStack::PopAndDestroy(&session);
  1.1095 +	}
  1.1096 +
  1.1097 +/*
  1.1098 +This test function accepts 1 descriptor parameter as defined below
  1.1099 +{EParamDes8,64,-64}
  1.1100 +As can be seen above, the schema is incorrectly defined as iMax is
  1.1101 +negative. This is a programming error and should result
  1.1102 +in the server panicking with ECMPanicBadMessageSchema in UDEB
  1.1103 +or panicking the client with KErrBadDescriptor in UREL
  1.1104 +*/
  1.1105 +void TestFunction13L()
  1.1106 +	{
  1.1107 +
  1.1108 +	TBuf8<64> buf8;
  1.1109 +	TBuf<128> buf;
  1.1110 +
  1.1111 +	RClientMessageTestSession session;
  1.1112 +
  1.1113 +	TInt err = session.Connect();
  1.1114 +	Test(err == KErrNone);
  1.1115 +
  1.1116 +	CleanupClosePushL(session);
  1.1117 +
  1.1118 +	//this function is incorrectly defined in the
  1.1119 +	//message schema. This should result in the
  1.1120 +	//server panicking in debug builds
  1.1121 +	err = session.TestFunction13(buf8,0,buf,0);
  1.1122 +
  1.1123 +#ifdef _DEBUG
  1.1124 +	Test(err == KErrServerTerminated);
  1.1125 +
  1.1126 +	TInt type = serverProcess.ExitType();
  1.1127 +	Test(type == EExitPanic);
  1.1128 +
  1.1129 +	TInt reason = serverProcess.ExitReason();
  1.1130 +	Test(reason == ECMPanicBadMessageSchema);
  1.1131 +#endif
  1.1132 +
  1.1133 +	CleanupStack::PopAndDestroy(&session);
  1.1134 +	}
  1.1135 +
  1.1136 +/*
  1.1137 +This test function accepts 2 8bit descriptor parameters and 1 TInt
  1.1138 +parameter as defined below
  1.1139 +{EParamDes8Read,0,16},{EParamInt,0,16},{EParamDes8,16,16}
  1.1140 +The server function attempts reads from the first descriptor and
  1.1141 +then writes into the second descriptor at the offset supplied by
  1.1142 +the TInt value.  The test function below checks that the reading
  1.1143 +and writing with offset occurs as expected by checking the strings
  1.1144 +written by the server.
  1.1145 +*/
  1.1146 +void TestFunction14L()
  1.1147 +	{
  1.1148 +
  1.1149 +	_LIT8(KDes8, "Descriptor8");
  1.1150 +	TBuf8<16> buf;
  1.1151 +
  1.1152 +	RClientMessageTestSession session;
  1.1153 +
  1.1154 +	TInt err = session.Connect();
  1.1155 +	Test(err == KErrNone);
  1.1156 +
  1.1157 +	CleanupClosePushL(session);
  1.1158 +
  1.1159 +	err = session.TestFunction14(KDes8,0,buf);
  1.1160 +	Test(err == KErrNone);
  1.1161 +	Test(buf.Find(_L8("Descriptor8")) == 0);
  1.1162 +
  1.1163 +	err = session.TestFunction14(KDes8,3,buf);
  1.1164 +	Test(err == KErrNone);
  1.1165 +	Test(buf.Find(_L8("criptor8")) == 0);
  1.1166 +
  1.1167 +	err = session.TestFunction14(KDes8,8,buf);
  1.1168 +	Test(err == KErrNone);
  1.1169 +	Test(buf.Find(_L8("or8")) == 0);
  1.1170 +
  1.1171 +	CleanupStack::PopAndDestroy(&session);
  1.1172 +	}
  1.1173 +
  1.1174 +/*
  1.1175 +This test function accepts 2 16bit descriptor parameters and 1 TInt
  1.1176 +parameter as defined below
  1.1177 +{EParamDes16Read,0,64},{EParamInt,0,64},{EParamDes16,64,64}
  1.1178 +The server function attempts reads from the first descriptor and
  1.1179 +then writes into the second descriptor at the offset supplied by
  1.1180 +the TInt value.  The test function below checks that the reading
  1.1181 +and writing with offset occurs as expected by checking the strings
  1.1182 +written by the server.
  1.1183 +*/
  1.1184 +void TestFunction15L()
  1.1185 +	{
  1.1186 +
  1.1187 +	_LIT(KDes, "Descriptor");
  1.1188 +	TBuf<64> buf;
  1.1189 +
  1.1190 +	RClientMessageTestSession session;
  1.1191 +
  1.1192 +	TInt err = session.Connect();
  1.1193 +	Test(err == KErrNone);
  1.1194 +
  1.1195 +	CleanupClosePushL(session);
  1.1196 +
  1.1197 +	err = session.TestFunction15(KDes,0,buf);
  1.1198 +	Test(err == KErrNone);
  1.1199 +	Test(buf.Find(_L("Descriptor")) == 0);
  1.1200 +
  1.1201 +	err = session.TestFunction15(KDes,3,buf);
  1.1202 +	Test(err == KErrNone);
  1.1203 +	Test(buf.Find(_L("criptor")) == 0);
  1.1204 +
  1.1205 +	err = session.TestFunction15(KDes,8,buf);
  1.1206 +	Test(err == KErrNone);
  1.1207 +	Test(buf.Find(_L("or")) == 0);
  1.1208 +
  1.1209 +	CleanupStack::PopAndDestroy(&session);
  1.1210 +	}
  1.1211 +
  1.1212 +
  1.1213 +/*
  1.1214 +This test function accepts a single TAny* parameter as below
  1.1215 +{EParamPtr,0,0}
  1.1216 +The server function reads the pointer value.
  1.1217 +*/
  1.1218 +void TestFunction16L()
  1.1219 +	{
  1.1220 +	RClientMessageTestSession session;
  1.1221 +
  1.1222 +	TInt err = session.Connect();
  1.1223 +	Test(err == KErrNone);
  1.1224 +
  1.1225 +	CleanupClosePushL(session);
  1.1226 +
  1.1227 +	err = session.TestFunction16(0);
  1.1228 +	Test(err == KErrNone);
  1.1229 +
  1.1230 +	CleanupStack::PopAndDestroy(&session);
  1.1231 +	}
  1.1232 +
  1.1233 +
  1.1234 +/*
  1.1235 +This test function accepts a single TAny* parameter as below
  1.1236 +{EParamPtr,0,0}
  1.1237 +The server function attempts to call CMessageParameterBase::WriteL
  1.1238 +which is not defined for a Ptr type. This is a programming error and
  1.1239 +should result in the server panicking with ECMPanicWrongParameterType
  1.1240 +in UDEB or returning KErrWrongParameterType in UREL
  1.1241 +*/
  1.1242 +void TestFunction17L()
  1.1243 +	{
  1.1244 +	RClientMessageTestSession session;
  1.1245 +
  1.1246 +	TInt err = session.Connect();
  1.1247 +	Test(err == KErrNone);
  1.1248 +
  1.1249 +	CleanupClosePushL(session);
  1.1250 +
  1.1251 +	//This should result in the server panicking with ECMPanicWrongParameterType
  1.1252 +	//in UDEB or returning KErrWrongParameterType in UREL
  1.1253 +	err = session.TestFunction17(0);
  1.1254 +#ifdef _DEBUG
  1.1255 +	Test(err == KErrServerTerminated);
  1.1256 +
  1.1257 +	TInt type = serverProcess.ExitType();
  1.1258 +	Test(type == EExitPanic);
  1.1259 +
  1.1260 +	TInt reason = serverProcess.ExitReason();
  1.1261 +	Test(reason == ECMPanicWrongParameterType);
  1.1262 +#else
  1.1263 +	Test(err == KErrWrongParameterType);
  1.1264 +#endif
  1.1265 +
  1.1266 +	CleanupStack::PopAndDestroy(&session);
  1.1267 +	}
  1.1268 +
  1.1269 +/*
  1.1270 +This test function accepts a single custom TPckg parameter as below
  1.1271 +{EParamCustom1,sizeof(CMTestStruct2),sizeof(CMTestStruct2)}.
  1.1272 +CMTestStruct2 is defined as follows:
  1.1273 +
  1.1274 +struct CMTestStruct1
  1.1275 +	{
  1.1276 +	TInt iInt;
  1.1277 +	TBuf<32> iDes;
  1.1278 +	};
  1.1279 +
  1.1280 +struct CMTestStruct2
  1.1281 +	{
  1.1282 +	TInt iCount;
  1.1283 +	CMTestStruct1* iStruct;
  1.1284 +	TCMTestEnum iEnum;
  1.1285 +	TBuf<32> iDes;
  1.1286 +	};
  1.1287 +
  1.1288 +The EParamCustom1 parameter type is validated using a custom validation
  1.1289 +function defined in the testclientmessageschema.cpp.  The validation
  1.1290 +function checks that iEnum is in the valid range for TCMTestEnum,
  1.1291 +that iCount >= 0 and that iDes.Length() > 0.  If any of these checks
  1.1292 +fail the server should return KErrBadParameter.
  1.1293 +*/
  1.1294 +void TestFunction18AL()
  1.1295 +	{
  1.1296 +	RClientMessageTestSession session;
  1.1297 +
  1.1298 +	TInt err = session.Connect();
  1.1299 +	Test(err == KErrNone);
  1.1300 +
  1.1301 +	CleanupClosePushL(session);
  1.1302 +
  1.1303 +	CMTestStruct1 struct1;
  1.1304 +	struct1.iInt = 7;
  1.1305 +	struct1.iDes = _L("Test Struct");
  1.1306 +
  1.1307 +	CMTestStruct2 struct2;
  1.1308 +	struct2.iCount = 1;
  1.1309 +	struct2.iStruct = &struct1;
  1.1310 +	struct2.iEnum = ETestVal1;
  1.1311 +	struct2.iDes = _L("Test Struct 2");
  1.1312 +
  1.1313 +	TPckg<CMTestStruct2> pData(struct2);
  1.1314 +
  1.1315 +	err = session.TestFunction18(pData);
  1.1316 +	Test(err == KErrNone);
  1.1317 +
  1.1318 +	Test(struct2.iCount == 0);
  1.1319 +
  1.1320 +	CMTestStruct1 struct3;
  1.1321 +	struct3.iInt = -1;
  1.1322 +	struct3.iDes = _L("");
  1.1323 +
  1.1324 +	CMTestStruct2 struct4;
  1.1325 +	struct4.iCount = 1;
  1.1326 +	struct4.iStruct = &struct3;
  1.1327 +	struct4.iEnum = -1;
  1.1328 +	struct4.iDes = _L("Test Struct 2");
  1.1329 +
  1.1330 +	TPckg<CMTestStruct2> pData2(struct4);
  1.1331 +
  1.1332 +	//As iEnum is not in the valid range this validation should fail
  1.1333 +	err = session.TestFunction18(pData2);
  1.1334 +	Test(err == KErrBadParameter);
  1.1335 +
  1.1336 +	CleanupStack::PopAndDestroy(&session);
  1.1337 +	}
  1.1338 +
  1.1339 +/*
  1.1340 +This test function accepts a single custom TPckg parameter as below
  1.1341 +{EParamCustom1,sizeof(CMTestStruct2),sizeof(CMTestStruct2)}.
  1.1342 +CMTestStruct2 is defined above.
  1.1343 +The test function below passes in a TPckg<CMTestStruct1> which is an
  1.1344 +incorrect type.  The server should return KErrBadDescriptor
  1.1345 +*/
  1.1346 +void TestFunction18BL()
  1.1347 +	{
  1.1348 +	RClientMessageTestSession session;
  1.1349 +
  1.1350 +	TInt err = session.Connect();
  1.1351 +	Test(err == KErrNone);
  1.1352 +
  1.1353 +	CleanupClosePushL(session);
  1.1354 +
  1.1355 +	CMTestStruct1 struct1;
  1.1356 +	struct1.iInt = 0;
  1.1357 +	struct1.iDes = _L("Test Struct");
  1.1358 +
  1.1359 +	TPckg<CMTestStruct1> pData(struct1);
  1.1360 +
  1.1361 +	//This should result in a panic
  1.1362 +	err = session.TestFunction18(pData);
  1.1363 +
  1.1364 +	CleanupStack::PopAndDestroy(&session);
  1.1365 +	}
  1.1366 +
  1.1367 +/*
  1.1368 +This test function accepts a single custom TPckg parameter as below
  1.1369 +{EParamCustom1,sizeof(CMTestStruct2),sizeof(CMTestStruct2)}.
  1.1370 +CMTestStruct2 is defined above.
  1.1371 +The test function below passes in an Empty TBuf the same size as a
  1.1372 +CMTestStruct2. As this wont contain any valid data, the server should
  1.1373 +panic the client with KErrBadParameter.
  1.1374 +*/
  1.1375 +void TestFunction18CL()
  1.1376 +	{
  1.1377 +	RClientMessageTestSession session;
  1.1378 +
  1.1379 +	TInt err = session.Connect();
  1.1380 +	Test(err == KErrNone);
  1.1381 +
  1.1382 +	CleanupClosePushL(session);
  1.1383 +
  1.1384 +	TBuf<sizeof(CMTestStruct2)> buf;
  1.1385 +	buf.SetLength(sizeof(CMTestStruct2));
  1.1386 +
  1.1387 +	//This should result in a panic
  1.1388 +	err = session.TestFunction18(buf);
  1.1389 +
  1.1390 +	CleanupStack::PopAndDestroy(&session);
  1.1391 +	}
  1.1392 +
  1.1393 +/*
  1.1394 +This test function accepts a single custom TPckg parameter as below
  1.1395 +{EParamCustom2,sizeof(CMTestStruct1),sizeof(CMTestStruct1)}.
  1.1396 +CMTestStruct1 is defined as follows:
  1.1397 +
  1.1398 +struct CMTestStruct1
  1.1399 +	{
  1.1400 +	TInt iInt;
  1.1401 +	TBuf<32> iDes;
  1.1402 +	};
  1.1403 +
  1.1404 +The EParamCustom1 parameter type is validated using a custom validation
  1.1405 +function defined in the testclientmessageschema.cpp.  The validation
  1.1406 +function checks that iInt is > 0.  If this check fails the server
  1.1407 +should return KErrBadParameter.
  1.1408 +The test function below passes the data to the server in a TPckgBuf
  1.1409 +*/
  1.1410 +void TestFunction19L()
  1.1411 +	{
  1.1412 +	RClientMessageTestSession session;
  1.1413 +
  1.1414 +	TInt err = session.Connect();
  1.1415 +	Test(err == KErrNone);
  1.1416 +
  1.1417 +	CleanupClosePushL(session);
  1.1418 +
  1.1419 +	CMTestStruct1 struct1;
  1.1420 +	struct1.iInt = 4;
  1.1421 +	struct1.iDes = _L("Test Struct");
  1.1422 +
  1.1423 +	TPckgBuf<CMTestStruct1> pData(struct1);
  1.1424 +
  1.1425 +	err = session.TestFunction19(pData);
  1.1426 +	Test(err == KErrNone);
  1.1427 +
  1.1428 +	struct1.iInt = -4;
  1.1429 +	TPckgBuf<CMTestStruct1> pData2(struct1);
  1.1430 +
  1.1431 +	err = session.TestFunction19(pData2);
  1.1432 +	Test(err == KErrBadParameter);
  1.1433 +
  1.1434 +	CleanupStack::PopAndDestroy(&session);
  1.1435 +	}
  1.1436 +
  1.1437 +/*
  1.1438 +This test function does not expect any parameters.
  1.1439 +The schema defines a single placeholder parameter
  1.1440 +{EParamNull,0,0}
  1.1441 +but the number of parameters is set to 0
  1.1442 +*/
  1.1443 +void TestFunction25L()
  1.1444 +	{
  1.1445 +	RClientMessageTestSession session;
  1.1446 +
  1.1447 +	TInt err = session.Connect();
  1.1448 +	Test(err == KErrNone);
  1.1449 +
  1.1450 +	CleanupClosePushL(session);
  1.1451 +
  1.1452 +	err = session.TestFunction25();
  1.1453 +	Test(err == KErrNone);
  1.1454 +
  1.1455 +	CleanupStack::PopAndDestroy(&session);
  1.1456 +	}
  1.1457 +
  1.1458 +/*
  1.1459 +This test function does not expect any parameters.
  1.1460 +The schema defines a single placeholder parameter
  1.1461 +{EParamNull,0,0}
  1.1462 +The schema is incorrectly defined as the number of parameters is
  1.1463 +listed as 1 instead of 0.  This is a programming error and should result
  1.1464 +in the server panicking with ECMPanicBadMessageSchema in UDEB
  1.1465 +or the client being panicked with KErrBadDescriptor in UREL
  1.1466 +*/
  1.1467 +void TestFunction26L()
  1.1468 +	{
  1.1469 +	RClientMessageTestSession session;
  1.1470 +
  1.1471 +	TInt err = session.Connect();
  1.1472 +	Test(err == KErrNone);
  1.1473 +
  1.1474 +	CleanupClosePushL(session);
  1.1475 +
  1.1476 +	err = session.TestFunction26();
  1.1477 +	//In debug builds the server should panic.
  1.1478 +	//In release builds KErrBadParameter should be returned
  1.1479 +#ifdef _DEBUG
  1.1480 +	Test(err == KErrServerTerminated);
  1.1481 +
  1.1482 +	TInt type = serverProcess.ExitType();
  1.1483 +	Test(type == EExitPanic);
  1.1484 +
  1.1485 +	TInt reason = serverProcess.ExitReason();
  1.1486 +	Test(reason == ECMPanicBadMessageSchema);
  1.1487 +#else
  1.1488 +	Test(err == KErrBadMessageSchema);
  1.1489 +#endif
  1.1490 +
  1.1491 +	CleanupStack::PopAndDestroy(&session);
  1.1492 +	}
  1.1493 +
  1.1494 +/*
  1.1495 +This test function does not expect any parameters.
  1.1496 +The schema defines a single placeholder parameter
  1.1497 +{453,0,0}
  1.1498 +The schema is incorrectly defined as it contains an invalid
  1.1499 +parameter type. This is a programming error and should result
  1.1500 +in the server panicking with ECMPanicBadMessageSchema in UDEB
  1.1501 +or returning KErrBadParameter in UREL
  1.1502 +*/
  1.1503 +void TestFunction27L()
  1.1504 +	{
  1.1505 +	RClientMessageTestSession session;
  1.1506 +
  1.1507 +	TInt err = session.Connect();
  1.1508 +	Test(err == KErrNone);
  1.1509 +
  1.1510 +	CleanupClosePushL(session);
  1.1511 +
  1.1512 +	err = session.TestFunction27();
  1.1513 +	//In debug builds the server should panic.
  1.1514 +	//In release builds KErrBadMessageSchema should be returned
  1.1515 +#ifdef _DEBUG
  1.1516 +	Test(err == KErrServerTerminated);
  1.1517 +
  1.1518 +	TInt type = serverProcess.ExitType();
  1.1519 +	Test(type == EExitPanic);
  1.1520 +
  1.1521 +	TInt reason = serverProcess.ExitReason();
  1.1522 +	Test(reason == ECMPanicBadMessageSchema);
  1.1523 +#else
  1.1524 +	Test(err == KErrBadMessageSchema);
  1.1525 +#endif
  1.1526 +
  1.1527 +	CleanupStack::PopAndDestroy(&session);
  1.1528 +	}
  1.1529 +
  1.1530 +/*
  1.1531 +This test function accepts a single integer parameter with a
  1.1532 +custom validation function.
  1.1533 +{EParamCustom3,0,0}
  1.1534 +The validation functions checks that the value passed in is a
  1.1535 +multiple of 4.
  1.1536 +Any calls to this function with a parameter that is not divisible
  1.1537 +by 4 should fail with KErrBadParameter
  1.1538 +*/
  1.1539 +void TestFunction28L()
  1.1540 +	{
  1.1541 +	RClientMessageTestSession session;
  1.1542 +
  1.1543 +	TInt err = session.Connect();
  1.1544 +	Test(err == KErrNone);
  1.1545 +
  1.1546 +	CleanupClosePushL(session);
  1.1547 +
  1.1548 +	err = session.TestFunction28(4);
  1.1549 +	Test(err == KErrNone);
  1.1550 +
  1.1551 +	err = session.TestFunction28(128);
  1.1552 +	Test(err == KErrNone);
  1.1553 +
  1.1554 +	err = session.TestFunction28(73);
  1.1555 +	Test(err == KErrBadParameter);
  1.1556 +
  1.1557 +	err = session.TestFunction28(-1);
  1.1558 +	Test(err == KErrBadParameter);
  1.1559 +
  1.1560 +	err = session.TestFunction28(44444444);
  1.1561 +	Test(err == KErrNone);
  1.1562 +
  1.1563 +	CleanupStack::PopAndDestroy(&session);
  1.1564 +	}
  1.1565 +
  1.1566 +/*
  1.1567 +This test function accepts a single descriptor parameter with a
  1.1568 +custom validation function.
  1.1569 +{EParamCustom4,0,0}
  1.1570 +The validation functions checks that the descriptor passed in
  1.1571 +contains the string 'Expected Data'
  1.1572 +Any calls to this function with a descriptor that is not 'Expected Data'
  1.1573 +should fail with KErrBadParameter
  1.1574 +*/
  1.1575 +void TestFunction29L()
  1.1576 +	{
  1.1577 +	RClientMessageTestSession session;
  1.1578 +
  1.1579 +	TInt err = session.Connect();
  1.1580 +	Test(err == KErrNone);
  1.1581 +
  1.1582 +	CleanupClosePushL(session);
  1.1583 +
  1.1584 +	TBuf<32> data = _L("Expected Data");
  1.1585 +
  1.1586 +	err = session.TestFunction29(data);
  1.1587 +	Test(err == KErrNone);
  1.1588 +
  1.1589 +	data.SetLength(5);
  1.1590 +
  1.1591 +	err = session.TestFunction29(data);
  1.1592 +	Test(err == KErrBadParameter);
  1.1593 +
  1.1594 +	data = _L("expected data");
  1.1595 +
  1.1596 +	err = session.TestFunction29(data);
  1.1597 +	Test(err == KErrBadParameter);
  1.1598 +
  1.1599 +	data.Zero();
  1.1600 +
  1.1601 +	err = session.TestFunction29(data);
  1.1602 +	Test(err == KErrBadParameter);
  1.1603 +
  1.1604 +	CleanupStack::PopAndDestroy(&session);
  1.1605 +	}
  1.1606 +
  1.1607 +/*
  1.1608 +This test function accepts a single custom TPckg parameter as below
  1.1609 +{EParamPckg,sizeof(CMTestStruct1),sizeof(CMTestStruct1)}.
  1.1610 +CMTestStruct1 is defined as follows:
  1.1611 +
  1.1612 +struct CMTestStruct1
  1.1613 +	{
  1.1614 +	TInt iInt;
  1.1615 +	TBuf<32> iDes;
  1.1616 +	};
  1.1617 +
  1.1618 +The EParamCustom1 parameter type is validated using the default validation
  1.1619 +function.  This checks that the size of the TPckg passed in is
  1.1620 +exactly that defined in the schema. If this check fails the server
  1.1621 +should panic the client with KErrBadDescriptor.
  1.1622 +*/
  1.1623 +void TestFunction30L()
  1.1624 +	{
  1.1625 +	RClientMessageTestSession session;
  1.1626 +
  1.1627 +	TInt err = session.Connect();
  1.1628 +	Test(err == KErrNone);
  1.1629 +
  1.1630 +	CleanupClosePushL(session);
  1.1631 +
  1.1632 +	CMTestStruct1 struct1;
  1.1633 +	struct1.iInt = 4;
  1.1634 +	struct1.iDes = _L("Test Struct");
  1.1635 +
  1.1636 +	TPckg<CMTestStruct1> pData(struct1);
  1.1637 +
  1.1638 +	err = session.TestFunction30(pData);
  1.1639 +	Test(err == KErrNone);
  1.1640 +
  1.1641 +	TBuf8<16> data;
  1.1642 +	//This should cause a panic
  1.1643 +	err = session.TestFunction30(data);
  1.1644 +
  1.1645 +	CleanupStack::PopAndDestroy(&session);
  1.1646 +	}
  1.1647 +
  1.1648 +/*
  1.1649 +This test function accepts an Intergeer parameter and a TAny* parameter
  1.1650 +{EParamInt,EGetIntL,EWrite16L},{EParamPtr,0,0}
  1.1651 +
  1.1652 +The server function checks the value passed in the TInt parameter and calls
  1.1653 +an appropriate CMessageParameterBase function on the second parameter.
  1.1654 +As none of the functions called are defined for a pointer parameter, the
  1.1655 +call defaults to the CMessageParameterBase implementation which panics the
  1.1656 +client with ECMPanicWrongParameterType in UDEB or returns
  1.1657 +KErrWrongParameterType in UREL
  1.1658 +*/
  1.1659 +void DoTest31L(TInt aType)
  1.1660 +	{
  1.1661 +	RClientMessageTestSession session;
  1.1662 +
  1.1663 +	TInt err = session.Connect();
  1.1664 +	Test(err == KErrNone);
  1.1665 +
  1.1666 +	CleanupClosePushL(session);
  1.1667 +
  1.1668 +	err = session.TestFunction31(aType);
  1.1669 +#ifdef _DEBUG
  1.1670 +	Test(err == KErrServerTerminated);
  1.1671 +
  1.1672 +	TInt type = serverProcess.ExitType();
  1.1673 +	Test(type == EExitPanic);
  1.1674 +
  1.1675 +	TInt reason = serverProcess.ExitReason();
  1.1676 +	Test(reason == ECMPanicWrongParameterType);
  1.1677 +#else
  1.1678 +	Test(err == KErrWrongParameterType);
  1.1679 +#endif
  1.1680 +
  1.1681 +	CleanupStack::PopAndDestroy(&session);
  1.1682 +	}
  1.1683 +
  1.1684 +void TestFunction31AL()
  1.1685 +	{
  1.1686 +	DoTest31L(EGetIntL);
  1.1687 +	}
  1.1688 +
  1.1689 +void TestFunction31BL()
  1.1690 +	{
  1.1691 +	DoTest31L(EGetDes8L);
  1.1692 +	}
  1.1693 +
  1.1694 +void TestFunction31CL()
  1.1695 +	{
  1.1696 +	DoTest31L(EGetDes16L);
  1.1697 +	}
  1.1698 +
  1.1699 +void TestFunction31DL()
  1.1700 +	{
  1.1701 +	DoTest31L(EGetDesLengthL);
  1.1702 +	}
  1.1703 +
  1.1704 +void TestFunction31EL()
  1.1705 +	{
  1.1706 +	DoTest31L(EGetDesMaxLengthL);
  1.1707 +	}
  1.1708 +
  1.1709 +void TestFunction31FL()
  1.1710 +	{
  1.1711 +	DoTest31L(ERead8L);
  1.1712 +	}
  1.1713 +
  1.1714 +void TestFunction31GL()
  1.1715 +	{
  1.1716 +	DoTest31L(ERead16L);
  1.1717 +	}
  1.1718 +
  1.1719 +void TestFunction31HL()
  1.1720 +	{
  1.1721 +	DoTest31L(EWrite8L);
  1.1722 +	}
  1.1723 +
  1.1724 +void TestFunction31IL()
  1.1725 +	{
  1.1726 +	DoTest31L(EWrite16L);
  1.1727 +	}
  1.1728 +/*
  1.1729 +This test function accepts a single custom parameter as below
  1.1730 +{EParamCustom5,sizeof(CMTestStruct1),sizeof(CMTestStruct1)}
  1.1731 +CMTestStruct1 is defined as follows:
  1.1732 +
  1.1733 +struct CMTestStruct1
  1.1734 +	{
  1.1735 +	TInt iInt;
  1.1736 +	TBuf<32> iDes;
  1.1737 +	};
  1.1738 +
  1.1739 +The EParamCustom5 parameter type enum value is  defined as
  1.1740 +(0x90000 | EParamPckg).  The upper 16 bits are the index of
  1.1741 +the validation function in the array supplied by the server.
  1.1742 +The array only contains 5 values so the above definition is
  1.1743 +incorrect.  Calling this messge should result in the server
  1.1744 +panicking with ECMPanicBadMessageSchema in UDEB or returning
  1.1745 +KErrBadMessageSchema in UREL
  1.1746 +*/
  1.1747 +void TestFunction32L()
  1.1748 +	{
  1.1749 +	RClientMessageTestSession session;
  1.1750 +
  1.1751 +	TInt err = session.Connect();
  1.1752 +	Test(err == KErrNone);
  1.1753 +
  1.1754 +	CleanupClosePushL(session);
  1.1755 +
  1.1756 +	CMTestStruct1 struct1;
  1.1757 +	TPckg<CMTestStruct1> pData(struct1);
  1.1758 +
  1.1759 +	err = session.TestFunction32(pData);
  1.1760 +
  1.1761 +#ifdef _DEBUG
  1.1762 +	Test(err == KErrServerTerminated);
  1.1763 +
  1.1764 +	TInt type = serverProcess.ExitType();
  1.1765 +	Test(type == EExitPanic);
  1.1766 +
  1.1767 +	TInt reason = serverProcess.ExitReason();
  1.1768 +	Test(reason == ECMPanicBadMessageSchema);
  1.1769 +#else
  1.1770 +	Test(err == KErrBadMessageSchema);
  1.1771 +#endif
  1.1772 +
  1.1773 +	CleanupStack::PopAndDestroy(&session);
  1.1774 +	}
  1.1775 +
  1.1776 +/* Connect to the CClientMessageTestServer, launching
  1.1777 + * the server process if necessary
  1.1778 + */
  1.1779 +TInt RClientMessageTestSession2::Connect()
  1.1780 +	{
  1.1781 +	TInt retry = 2;
  1.1782 +	for(;;)
  1.1783 +		{
  1.1784 +		TInt r = CreateSession(KServer2Name,TVersion(1,0,0));
  1.1785 +
  1.1786 +		if((r != KErrNotFound)&&(r != KErrServerTerminated))
  1.1787 +			{
  1.1788 +			return r;
  1.1789 +			}
  1.1790 +
  1.1791 +		if(--retry == 0)
  1.1792 +			{
  1.1793 +			return r;
  1.1794 +			}
  1.1795 +
  1.1796 +		r = LaunchServer();
  1.1797 +		if((r != KErrNone)&&(r != KErrAlreadyExists))
  1.1798 +			{
  1.1799 +			return r;
  1.1800 +			}
  1.1801 +		}
  1.1802 +	}
  1.1803 +
  1.1804 +
  1.1805 +
  1.1806 +/* These functions are used to send IPC messages to the server.
  1.1807 + * The messages are sent with different parameters to test the
  1.1808 + * ClientMessage framework handling of bad messages
  1.1809 + */
  1.1810 +TInt RClientMessageTestSession2::TestFunction0(TInt aArg0, TInt aArg1)
  1.1811 +	{
  1.1812 +	return SendReceive(ETestMessage0,TIpcArgs(aArg0,aArg1));
  1.1813 +	}
  1.1814 +
  1.1815 +TInt RClientMessageTestSession2::TestFunction1(const TDesC& aData0)
  1.1816 +	{
  1.1817 +	return SendReceive(ETestMessage1,TIpcArgs(&aData0));
  1.1818 +	}
  1.1819 +
  1.1820 +
  1.1821 +/**
  1.1822 +@SYMTestCaseID SYSLIB-BAFL-CT-4040
  1.1823 +@SYMTestCaseDesc Tests CClientMessage handling of EParamInt type parameters
  1.1824 +@SYMTestPriority High
  1.1825 +@SYMTestActions Call a series of test functions expecting integer parameters.
  1.1826 +				Various argument values and types are passed to these functions.
  1.1827 +				The Server should only accept messages containing integer
  1.1828 +				values that fall within the bounds defined in the message schema.
  1.1829 +@SYMTestExpectedResults The Server should return KErrNone if the message is
  1.1830 +				accepted or KErrBadParameter if the int parameters are outside
  1.1831 +				the bounds defined in the schema.  If the message is incorrectly
  1.1832 +				defined in the mssage schema or the server code incorrectly uses
  1.1833 +				the parameter type the server should panic.
  1.1834 +@SYMDEF         INC117370
  1.1835 +*/
  1.1836 +void DoIntParameterTestsL()
  1.1837 +	{
  1.1838 +	TExitDetails exitDetails;
  1.1839 +
  1.1840 +	exitDetails = LaunchTestThreadL(_L("TestFunction0"), &TestFunction0AL);
  1.1841 +	Test(exitDetails.iExitType == EExitKill);
  1.1842 +
  1.1843 +	exitDetails = LaunchTestThreadL(_L("TestFunction1"), &TestFunction1L);
  1.1844 +	Test(exitDetails.iExitType == EExitKill);
  1.1845 +
  1.1846 +	exitDetails = LaunchTestThreadL(_L("TestFunction2"), &TestFunction2L);
  1.1847 +	Test(exitDetails.iExitType == EExitKill);
  1.1848 +
  1.1849 +	exitDetails = LaunchTestThreadL(_L("TestFunction3"), &TestFunction3L);
  1.1850 +	Test(exitDetails.iExitType == EExitKill);
  1.1851 +
  1.1852 +	exitDetails = LaunchTestThreadL(_L("TestFunction28"), &TestFunction28L);
  1.1853 +	Test(exitDetails.iExitType == EExitKill);
  1.1854 +	}
  1.1855 +
  1.1856 +/**
  1.1857 +@SYMTestCaseID SYSLIB-BAFL-CT-4041
  1.1858 +@SYMTestCaseDesc Tests CClientMessage handling of EParamDes8Read and
  1.1859 +				EParamDes16Read type parameters
  1.1860 +@SYMTestPriority High
  1.1861 +@SYMTestActions Call a series of test functions expecting Des*Read parameters.
  1.1862 +				Various argument values and types are passed to these functions.
  1.1863 +				The Server should only accept messages containing Des*Read
  1.1864 +				values that fall within the bounds defined in the message schema.
  1.1865 +@SYMTestExpectedResults The Server should return KErrNone if the message is
  1.1866 +				accepted or panic the client with KErrBadDescriptor if the
  1.1867 +				descriptor parameters are outside the bounds defined in the schema.
  1.1868 +				If the message is incorrectly defined in the mssage schema or the
  1.1869 +				server code incorrectly uses the parameter type the server should panic.
  1.1870 +@SYMDEF         INC117370
  1.1871 +*/
  1.1872 +void DoDesReadParameterTestsL()
  1.1873 +	{
  1.1874 +	TExitDetails exitDetails;
  1.1875 +
  1.1876 +	exitDetails = LaunchTestThreadL(_L("TestFunction4A"), &TestFunction4AL);
  1.1877 +	Test(exitDetails.iExitType == EExitKill);
  1.1878 +
  1.1879 +	exitDetails = LaunchTestThreadL(_L("TestFunction4B"), &TestFunction4BL);
  1.1880 +	Test(exitDetails.iExitType == EExitPanic);
  1.1881 +	Test(exitDetails.iReason == KErrBadDescriptor);
  1.1882 +
  1.1883 +	exitDetails = LaunchTestThreadL(_L("TestFunction4C"), &TestFunction4CL);
  1.1884 +	Test(exitDetails.iExitType == EExitPanic);
  1.1885 +	Test(exitDetails.iReason == KErrBadDescriptor);
  1.1886 +
  1.1887 +	exitDetails = LaunchTestThreadL(_L("TestFunction4D"), &TestFunction4DL);
  1.1888 +	Test(exitDetails.iExitType == EExitPanic);
  1.1889 +	Test(exitDetails.iReason == KErrBadDescriptor);
  1.1890 +
  1.1891 +	exitDetails = LaunchTestThreadL(_L("TestFunction4E"), &TestFunction4EL);
  1.1892 +	Test(exitDetails.iExitType == EExitPanic);
  1.1893 +	Test(exitDetails.iReason == KErrBadDescriptor);
  1.1894 +
  1.1895 +	exitDetails = LaunchTestThreadL(_L("TestFunction4F"), &TestFunction4FL);
  1.1896 +	Test(exitDetails.iExitType == EExitPanic);
  1.1897 +	Test(exitDetails.iReason == KErrBadDescriptor);
  1.1898 +
  1.1899 +	exitDetails = LaunchTestThreadL(_L("TestFunction5"), &TestFunction5L);
  1.1900 +	Test(exitDetails.iExitType == EExitKill);
  1.1901 +
  1.1902 +	exitDetails = LaunchTestThreadL(_L("TestFunction6"), &TestFunction6L);
  1.1903 +	Test(exitDetails.iExitType == EExitKill);
  1.1904 +
  1.1905 +	exitDetails = LaunchTestThreadL(_L("TestFunction7"), &TestFunction7L);
  1.1906 +	Test(exitDetails.iExitType == EExitKill);
  1.1907 +
  1.1908 +	exitDetails = LaunchTestThreadL(_L("TestFunction8"), &TestFunction8L);
  1.1909 +#ifdef _DEBUG
  1.1910 +	Test(exitDetails.iExitType == EExitKill);
  1.1911 +#else
  1.1912 +	Test(exitDetails.iExitType == EExitPanic);
  1.1913 +	Test(exitDetails.iReason == KErrBadDescriptor);
  1.1914 +#endif
  1.1915 +
  1.1916 +	exitDetails = LaunchTestThreadL(_L("TestFunction29"), &TestFunction29L);
  1.1917 +	Test(exitDetails.iExitType == EExitKill);
  1.1918 +
  1.1919 +	}
  1.1920 +
  1.1921 +/**
  1.1922 +@SYMTestCaseID SYSLIB-BAFL-CT-4042
  1.1923 +@SYMTestCaseDesc Tests CClientMessage handling of EParamDes8 and
  1.1924 +				EParamDes16 type parameters
  1.1925 +@SYMTestPriority High
  1.1926 +@SYMTestActions Call a series of test functions expecting Des* parameters.
  1.1927 +				Various argument values and types are passed to these functions.
  1.1928 +				The Server should only accept messages containing Des*
  1.1929 +				values that fall within the bounds defined in the message schema.
  1.1930 +@SYMTestExpectedResults The Server should return KErrNone if the message is
  1.1931 +				accepted or panic the client with KErrBadDescriptor or KErrOverflow if the
  1.1932 +				descriptor parameters are outside the bounds defined in the schema.
  1.1933 +				If the message is incorrectly defined in the mssage schema or the
  1.1934 +				server code incorrectly uses the parameter type the server should panic.
  1.1935 +@SYMDEF         INC117370
  1.1936 +*/
  1.1937 +void DoDesParameterTestsL()
  1.1938 +	{
  1.1939 +	TExitDetails exitDetails;
  1.1940 +	exitDetails = LaunchTestThreadL(_L("TestFunction9A"), &TestFunction9AL);
  1.1941 +	Test(exitDetails.iExitType == EExitKill);
  1.1942 +
  1.1943 +	exitDetails = LaunchTestThreadL(_L("TestFunction9B"), &TestFunction9BL);
  1.1944 +	Test(exitDetails.iExitType == EExitPanic);
  1.1945 +	Test(exitDetails.iReason == KErrBadDescriptor);
  1.1946 +
  1.1947 +	exitDetails = LaunchTestThreadL(_L("TestFunction9C"), &TestFunction9CL);
  1.1948 +	Test(exitDetails.iExitType == EExitPanic);
  1.1949 +	Test(exitDetails.iReason == KErrOverflow);
  1.1950 +
  1.1951 +	exitDetails = LaunchTestThreadL(_L("TestFunction9D"), &TestFunction9DL);
  1.1952 +	Test(exitDetails.iExitType == EExitPanic);
  1.1953 +	Test(exitDetails.iReason == KErrBadDescriptor);
  1.1954 +
  1.1955 +	exitDetails = LaunchTestThreadL(_L("TestFunction10"), &TestFunction10L);
  1.1956 +	Test(exitDetails.iExitType == EExitPanic);
  1.1957 +	Test(exitDetails.iReason == KErrOverflow);
  1.1958 +
  1.1959 +	exitDetails = LaunchTestThreadL(_L("TestFunction11"), &TestFunction11L);
  1.1960 +	Test(exitDetails.iExitType == EExitKill);
  1.1961 +
  1.1962 +	exitDetails = LaunchTestThreadL(_L("TestFunction12"), &TestFunction12L);
  1.1963 +	Test(exitDetails.iExitType == EExitKill);
  1.1964 +
  1.1965 +	exitDetails = LaunchTestThreadL(_L("TestFunction13"), &TestFunction13L);
  1.1966 +#ifdef _DEBUG
  1.1967 +	Test(exitDetails.iExitType == EExitKill);
  1.1968 +#else
  1.1969 +	Test(exitDetails.iExitType == EExitPanic);
  1.1970 +	Test(exitDetails.iReason == KErrBadDescriptor);
  1.1971 +#endif
  1.1972 +
  1.1973 +	exitDetails = LaunchTestThreadL(_L("TestFunction14"), &TestFunction14L);
  1.1974 +	Test(exitDetails.iExitType == EExitKill);
  1.1975 +
  1.1976 +	exitDetails = LaunchTestThreadL(_L("TestFunction15"), &TestFunction15L);
  1.1977 +	Test(exitDetails.iExitType == EExitKill);
  1.1978 +	}
  1.1979 +
  1.1980 +/**
  1.1981 +@SYMTestCaseID SYSLIB-BAFL-CT-4043
  1.1982 +@SYMTestCaseDesc Tests CClientMessage handling of EParamPtr type parameters
  1.1983 +@SYMTestPriority High
  1.1984 +@SYMTestActions Call test functions accepting ptr parameter types
  1.1985 +@SYMTestExpectedResults The Server should return KErrNone if the message is
  1.1986 +				accepted. If the message is incorrectly defined in the message
  1.1987 +				schema or the server code incorrectly uses the parameter type
  1.1988 +				the server should panic
  1.1989 +				expected
  1.1990 +@SYMDEF         INC117370
  1.1991 +*/
  1.1992 +void DoPtrParameterTestsL()
  1.1993 +	{
  1.1994 +	TExitDetails exitDetails;
  1.1995 +	exitDetails = LaunchTestThreadL(_L("TestFunction16"), &TestFunction16L);
  1.1996 +	Test(exitDetails.iExitType == EExitKill);
  1.1997 +
  1.1998 +	exitDetails = LaunchTestThreadL(_L("TestFunction17"), &TestFunction17L);
  1.1999 +	Test(exitDetails.iExitType == EExitKill);
  1.2000 +	}
  1.2001 +
  1.2002 +/**
  1.2003 +@SYMTestCaseID SYSLIB-BAFL-CT-4044
  1.2004 +@SYMTestCaseDesc Tests CClientMessage handling of EParamPckg type parameters
  1.2005 +@SYMTestPriority High
  1.2006 +@SYMTestActions Call a series of test functions expecting Pckg parameters.
  1.2007 +				Various argument values and types are passed to these functions.
  1.2008 +				The Server should only accept messages containing Pckg
  1.2009 +				values that fall within the bounds defined in the message schema.
  1.2010 +@SYMTestExpectedResults The Server should return KErrNone if the message is
  1.2011 +				accepted, return KErrBadParameter if the packaged parameter is
  1.2012 +				outside the bounds described in the schema or panic the client with
  1.2013 +				KErrBadDescriptor if the descriptor parameter is outside the bounds
  1.2014 +				defined in the schema.
  1.2015 +@SYMDEF         INC117370
  1.2016 +*/
  1.2017 +void DoPckgParameterTestsL()
  1.2018 +	{
  1.2019 +	TExitDetails exitDetails;
  1.2020 +	exitDetails = LaunchTestThreadL(_L("TestFunction18A"), &TestFunction18AL);
  1.2021 +	Test(exitDetails.iExitType == EExitKill);
  1.2022 +
  1.2023 +	exitDetails = LaunchTestThreadL(_L("TestFunction18B"), &TestFunction18BL);
  1.2024 +	Test(exitDetails.iExitType == EExitPanic);
  1.2025 +	Test(exitDetails.iReason == KErrBadDescriptor);
  1.2026 +
  1.2027 +	exitDetails = LaunchTestThreadL(_L("TestFunction18C"), &TestFunction18CL);
  1.2028 +	Test(exitDetails.iExitType == EExitPanic);
  1.2029 +	Test(exitDetails.iReason == KErrBadDescriptor);
  1.2030 +
  1.2031 +	exitDetails = LaunchTestThreadL(_L("TestFunction19"), &TestFunction19L);
  1.2032 +	Test(exitDetails.iExitType == EExitKill);
  1.2033 +
  1.2034 +	exitDetails = LaunchTestThreadL(_L("TestFunction30"), &TestFunction30L);
  1.2035 +	Test(exitDetails.iExitType == EExitPanic);
  1.2036 +	Test(exitDetails.iReason == KErrBadDescriptor);
  1.2037 +
  1.2038 +	exitDetails = LaunchTestThreadL(_L("TestFunction32"), &TestFunction32L);
  1.2039 +	Test(exitDetails.iExitType == EExitKill);
  1.2040 +	}
  1.2041 +
  1.2042 +
  1.2043 +/**
  1.2044 +@SYMTestCaseID SYSLIB-BAFL-CT-4045
  1.2045 +@SYMTestCaseDesc Tests CClientMessage handling of EParamNull type parameters
  1.2046 +@SYMTestPriority High
  1.2047 +@SYMTestActions Call a series of test functions expecting no parameters.
  1.2048 +@SYMTestExpectedResults The Server should return KErrNone if the message is
  1.2049 +				accepted. If the message is incorrectly defined in the message
  1.2050 +				schema or the server code incorrectly uses the parameter type
  1.2051 +				the server should panic.
  1.2052 +@SYMDEF         INC117370
  1.2053 +*/
  1.2054 +void DoNullParameterTestsL()
  1.2055 +	{
  1.2056 +
  1.2057 +	TExitDetails exitDetails;
  1.2058 +	exitDetails = LaunchTestThreadL(_L("TestFunction25"), &TestFunction25L);
  1.2059 +	Test(exitDetails.iExitType == EExitKill);
  1.2060 +
  1.2061 +	exitDetails = LaunchTestThreadL(_L("TestFunction26"), &TestFunction26L);
  1.2062 +	Test(exitDetails.iExitType == EExitKill);
  1.2063 +
  1.2064 +	exitDetails = LaunchTestThreadL(_L("TestFunction27"), &TestFunction27L);
  1.2065 +	Test(exitDetails.iExitType == EExitKill);
  1.2066 +
  1.2067 +	}
  1.2068 +
  1.2069 +/**
  1.2070 +@SYMTestCaseID SYSLIB-BAFL-CT-4046
  1.2071 +@SYMTestCaseDesc Tests CClientMessage handling of Security policies
  1.2072 +@SYMTestPriority High
  1.2073 +@SYMTestActions Call several test functions with varying security policies and
  1.2074 +				verify that the ClientMessage framework handles each case as
  1.2075 +				expected
  1.2076 +@SYMTestExpectedResults The server should return KErrNone if the client has
  1.2077 +				the required security policy, otherwise return KErrPermissionDenied
  1.2078 +@SYMDEF         INC117370
  1.2079 +*/
  1.2080 +void DoSecurityPolicyTestsL()
  1.2081 +	{
  1.2082 +	RClientMessageTestSession session;
  1.2083 +
  1.2084 +	TInt err = session.Connect();
  1.2085 +
  1.2086 +	CleanupClosePushL(session);
  1.2087 +
  1.2088 +	//This function is incorrectly defined in the message table
  1.2089 +	//for this server and so the CClientMessage Object creation will fail
  1.2090 +	//This should reult in the server panicking
  1.2091 +	RDebug::Print(_L("Testing Always Fail Policy..."));
  1.2092 +	err = session.TestFunction20(0,0);
  1.2093 +	Test(err == KErrPermissionDenied);
  1.2094 +
  1.2095 +	RDebug::Print(_L("Testing Valid SID Policy..."));
  1.2096 +	err = session.TestFunction21(0,0);
  1.2097 +	Test(err == KErrNone);
  1.2098 +
  1.2099 +	RDebug::Print(_L("Testing Invalid SID Policy..."));
  1.2100 +	err = session.TestFunction22(0,0);
  1.2101 +	Test(err == KErrPermissionDenied);
  1.2102 +
  1.2103 +	RDebug::Print(_L("Testing Valid Capability Policy..."));
  1.2104 +	err = session.TestFunction23(0,0);
  1.2105 +	Test(err == KErrNone);
  1.2106 +
  1.2107 +	RDebug::Print(_L("Testing Invalid Capability Policy..."));
  1.2108 +	err = session.TestFunction24(0,0);
  1.2109 +	Test(err == KErrPermissionDenied);
  1.2110 +
  1.2111 +	CleanupStack::PopAndDestroy(&session);
  1.2112 +	}
  1.2113 +
  1.2114 +/**
  1.2115 +@SYMTestCaseID SYSLIB-BAFL-CT-4047
  1.2116 +@SYMTestCaseDesc Tests CClientMessage handling of undefined messagess
  1.2117 +@SYMTestPriority High
  1.2118 +@SYMTestActions Call a test function which sends an unknown message request to the
  1.2119 +				server.
  1.2120 +@SYMTestExpectedResults The ClientMessage framework should return KErrInvalidFunction
  1.2121 +@SYMDEF         INC117370
  1.2122 +*/
  1.2123 +void DoInvalidMessageTestsL()
  1.2124 +	{
  1.2125 +	RClientMessageTestSession session;
  1.2126 +
  1.2127 +	TInt err = session.Connect();
  1.2128 +
  1.2129 +	CleanupClosePushL(session);
  1.2130 +
  1.2131 +	//This function is not defined in the message table
  1.2132 +	//for this server and so the CClientMessage Object creation will fail
  1.2133 +	//This should result in the server panicking
  1.2134 +	err = session.TestInvalidFunction(45);
  1.2135 +	Test(err == KErrInvalidFunction);
  1.2136 +
  1.2137 +	err = session.TestInvalidFunction(5);
  1.2138 +	Test(err == KErrInvalidFunction);
  1.2139 +
  1.2140 +	CleanupStack::PopAndDestroy(&session);
  1.2141 +	}
  1.2142 +
  1.2143 +/**
  1.2144 +@SYMTestCaseID SYSLIB-BAFL-CT-4050
  1.2145 +@SYMTestCaseDesc Tests CMessageParameterBase default implementation of message access functions
  1.2146 +@SYMTestPriority High
  1.2147 +@SYMTestActions Calls test functions which signal the server to call one
  1.2148 +				of the Message access methods on a EParamPtr parameter type.
  1.2149 +				As none of these methods are explicitly defined for a EParamPtr
  1.2150 +				type the call will be delegated to the base class implementation
  1.2151 +				which will panic the client in UDEB and return an error in UREL
  1.2152 +@SYMTestExpectedResults The server should panic the client with ECMPanicWrongParameterType
  1.2153 +				in UDEB and return KErrWrongParameterType in UREL
  1.2154 +@SYMDEF         INC117370
  1.2155 +*/
  1.2156 +void DoCMessageParameterBaseTestL()
  1.2157 +	{
  1.2158 +
  1.2159 +	TExitDetails exitDetails;
  1.2160 +	exitDetails = LaunchTestThreadL(_L("TestFunction31A"), &TestFunction31AL);
  1.2161 +	Test(exitDetails.iExitType == EExitKill);
  1.2162 +
  1.2163 +	exitDetails = LaunchTestThreadL(_L("TestFunction31B"), &TestFunction31BL);
  1.2164 +	Test(exitDetails.iExitType == EExitKill);
  1.2165 +
  1.2166 +	exitDetails = LaunchTestThreadL(_L("TestFunction31C"), &TestFunction31CL);
  1.2167 +	Test(exitDetails.iExitType == EExitKill);
  1.2168 +
  1.2169 +	exitDetails = LaunchTestThreadL(_L("TestFunction31D"), &TestFunction31DL);
  1.2170 +	Test(exitDetails.iExitType == EExitKill);
  1.2171 +
  1.2172 +	exitDetails = LaunchTestThreadL(_L("TestFunction31E"), &TestFunction31EL);
  1.2173 +	Test(exitDetails.iExitType == EExitKill);
  1.2174 +
  1.2175 +	exitDetails = LaunchTestThreadL(_L("TestFunction31F"), &TestFunction31FL);
  1.2176 +	Test(exitDetails.iExitType == EExitKill);
  1.2177 +
  1.2178 +	exitDetails = LaunchTestThreadL(_L("TestFunction31G"), &TestFunction31GL);
  1.2179 +	Test(exitDetails.iExitType == EExitKill);
  1.2180 +
  1.2181 +	exitDetails = LaunchTestThreadL(_L("TestFunction31H"), &TestFunction31HL);
  1.2182 +	Test(exitDetails.iExitType == EExitKill);
  1.2183 +
  1.2184 +	exitDetails = LaunchTestThreadL(_L("TestFunction31I"), &TestFunction31IL);
  1.2185 +	Test(exitDetails.iExitType == EExitKill);
  1.2186 +
  1.2187 +	}
  1.2188 +
  1.2189 +
  1.2190 +/**
  1.2191 +@SYMTestCaseID SYSLIB-BAFL-CT-4048
  1.2192 +@SYMTestCaseDesc Tests CClientMessage handling of multiple servers
  1.2193 +@SYMTestPriority High
  1.2194 +@SYMTestActions Calls test functions which pass the same message to two different
  1.2195 + 				servers.  The servers have different message schemas and data is
  1.2196 + 				passed to the server to check that the correct schema is used
  1.2197 + 				for the given server.
  1.2198 +@SYMTestExpectedResults The ClientMessage framework should validate the message
  1.2199 +						against the correct schema for the given server
  1.2200 +@SYMDEF         INC117370
  1.2201 +*/
  1.2202 +void DoMultipleServerTestsL()
  1.2203 +	{
  1.2204 +
  1.2205 +	RClientMessageTestSession session1;
  1.2206 +	RClientMessageTestSession2 session2;
  1.2207 +
  1.2208 +	TInt err = session1.Connect();
  1.2209 +	Test(err == KErrNone);
  1.2210 +	CleanupClosePushL(session1);
  1.2211 +
  1.2212 +	err = session2.Connect();
  1.2213 +	Test(err == KErrNone);
  1.2214 +	CleanupClosePushL(session2);
  1.2215 +
  1.2216 +	err = session1.TestFunction0( 0, 150);
  1.2217 +	Test(err == KErrNone);
  1.2218 +
  1.2219 +	err = session2.TestFunction0( 0, 150);
  1.2220 +	Test(err == KErrBadParameter);
  1.2221 +
  1.2222 +	err = session1.TestFunction0( 0, -50);
  1.2223 +	Test(err == KErrBadParameter);
  1.2224 +
  1.2225 +	err = session2.TestFunction0( 0, -50);
  1.2226 +	Test(err == KErrNone);
  1.2227 +
  1.2228 +	CleanupStack::PopAndDestroy(2,&session1);
  1.2229 +
  1.2230 +	}
  1.2231 +
  1.2232 +/**
  1.2233 +@SYMTestCaseID SYSLIB-BAFL-CT-4051
  1.2234 +@SYMTestCaseDesc Tests CClientMessage allowing disabling of Panic.
  1.2235 +@SYMTestPriority Medium
  1.2236 +@SYMTestActions Calls test functions which pass a message to a server for which the 
  1.2237 +				ESrvFlagDoNotPanicClientOnBadMessageErrors flag is set.Then invokes the client	API with 
  1.2238 +				incorrect arguments to create an error scenario of KErrBadDescriptor.
  1.2239 +@SYMTestExpectedResults The ClientMessage framework should check for the above flag, and in case 
  1.2240 +			its not set simply return an error instead of panicing the client.
  1.2241 +@SYMDEF         DEF125501
  1.2242 +*/
  1.2243 +void DoDisablePanicTestsL()
  1.2244 +	{
  1.2245 +	
  1.2246 +	RClientMessageTestSession2 session;
  1.2247 +	_LIT(KDes16, "Descriptor");
  1.2248 +	
  1.2249 +	TInt err = session.Connect();
  1.2250 +	Test(err == KErrNone);
  1.2251 +
  1.2252 +	CleanupClosePushL(session);
  1.2253 +
  1.2254 +	/* According to schema defined, this function accepts TDesC8 only.
  1.2255 +	Validation failure occurs.Server should check if flag ESrvFlagDoNotPanicClientOnBadMessageErrors
  1.2256 +	is set, and either return with KErrBadDescriptor or Panic the client.
  1.2257 +	In this case the above flag is set for CClientMessageTestServer2.
  1.2258 +	*/
  1.2259 +	err = session.TestFunction1(KDes16);
  1.2260 +	
  1.2261 +#ifdef _DEBUG
  1.2262 +	Test(err == KErrBadDescriptor);
  1.2263 +
  1.2264 +	// Server is not terminated, still alive
  1.2265 +	TInt type = serverProcess.ExitType();
  1.2266 +	Test(type == EExitPending);
  1.2267 +#else
  1.2268 +	Test(err == KErrBadDescriptor);
  1.2269 +#endif
  1.2270 +
  1.2271 +	CleanupStack::PopAndDestroy(&session);
  1.2272 +	
  1.2273 +	}
  1.2274 +
  1.2275 +
  1.2276 +static void DoTestsL()
  1.2277 +	{
  1.2278 +
  1.2279 +	TExitDetails exitDetails;
  1.2280 +
  1.2281 +	Test.Title ();
  1.2282 +	Test.Start (_L("ClientMessage Tests"));
  1.2283 +
  1.2284 +	Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4040 Testing Message with Int Parameters "));
  1.2285 +	DoIntParameterTestsL();
  1.2286 +
  1.2287 +	Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4041 Testing Message with Read Only Des Parameters "));
  1.2288 +	DoDesReadParameterTestsL();
  1.2289 +
  1.2290 +	Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4042 Testing Message with Read/Write Des Parameters "));
  1.2291 +	DoDesParameterTestsL();
  1.2292 +
  1.2293 +	Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4043 Testing Message with Ptr Parameters "));
  1.2294 +	DoPtrParameterTestsL();
  1.2295 +
  1.2296 +	Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4044 Testing Message with Pckg Parameters "));
  1.2297 +	DoPckgParameterTestsL();
  1.2298 +
  1.2299 +	Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4045 Testing Message with Null Parameters "));
  1.2300 +	DoNullParameterTestsL();
  1.2301 +
  1.2302 +	Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4046 Testing Security Policy Checking "));
  1.2303 +	exitDetails = LaunchTestThreadL(_L("SecurityPolicyTestL"), &DoSecurityPolicyTestsL);
  1.2304 +	Test(exitDetails.iExitType == EExitKill);
  1.2305 +
  1.2306 +	Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4047 Testing Invalid Message "));
  1.2307 +	exitDetails = LaunchTestThreadL(_L("InvalidMessageTestL"), &DoInvalidMessageTestsL);
  1.2308 +	Test(exitDetails.iExitType == EExitKill);
  1.2309 +
  1.2310 +	Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4050 Testing CMessageParameterBase Default Implementations "));
  1.2311 +	exitDetails = LaunchTestThreadL(_L("CMessageParameterBaseTestL"), &DoCMessageParameterBaseTestL);
  1.2312 +	Test(exitDetails.iExitType == EExitKill);
  1.2313 +
  1.2314 +	Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4048 Testing Multiple Servers "));
  1.2315 +	exitDetails = LaunchTestThreadL(_L("MultipleServerTestingL"), &DoMultipleServerTestsL);
  1.2316 +	Test(exitDetails.iExitType == EExitKill);
  1.2317 +
  1.2318 +	Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4051 Testing Disable Client Panic"));
  1.2319 +	exitDetails = LaunchTestThreadL(_L("DisablePanicTesting"), &DoDisablePanicTestsL);
  1.2320 +	Test(exitDetails.iExitType == EExitKill);
  1.2321 +	
  1.2322 +	
  1.2323 +	Test.Printf(_L("Tests Completed O.K."));
  1.2324 +
  1.2325 +	Test.End();
  1.2326 +	Test.Close();
  1.2327 +
  1.2328 +	}
  1.2329 +
  1.2330 +
  1.2331 +TInt E32Main()
  1.2332 +   //
  1.2333 +   // Server process entry-point
  1.2334 +   //
  1.2335 +   	{
  1.2336 +   	//
  1.2337 +   	CTrapCleanup* cleanup=CTrapCleanup::New();
  1.2338 +   	TInt r=KErrNoMemory;
  1.2339 +   	if (cleanup)
  1.2340 +   		{
  1.2341 + 		TRAP(r,DoTestsL());
  1.2342 +   		delete cleanup;
  1.2343 +   		}
  1.2344 +   	//
  1.2345 +   	return r;
  1.2346 +   	}