sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "t_clientmessagetestserver.h" sl@0: sl@0: using namespace BSUL; sl@0: sl@0: sl@0: LOCAL_D RTest Test (_L("T_ClientMessage")); sl@0: LOCAL_D RFs TheFs; sl@0: sl@0: _LIT(KServerName,"ClientMessageTestServer"); sl@0: _LIT(KServer2Name,"SecondTestServer"); sl@0: _LIT(KServerFileName,"T_ClientMessageTestServer.exe"); sl@0: sl@0: struct TExitDetails sl@0: { sl@0: TExitCategoryName iCategory; sl@0: TExitType iExitType; sl@0: TInt iReason; sl@0: }; sl@0: sl@0: typedef void (*TestFunction)(); sl@0: sl@0: sl@0: /*RClientMessageTestSession client side interface to sl@0: * CClientMessageTestServer server. This is used to pass sl@0: * messages to the server to testthe Client Message Framework. sl@0: */ sl@0: class RClientMessageTestSession : public RSessionBase sl@0: { sl@0: public: sl@0: TInt Connect(); sl@0: sl@0: TInt TestFunction0(TInt aArg0); sl@0: TInt TestFunction0(TInt aArg0, TInt aArg1); sl@0: TInt TestFunction0(TInt aArg0, TInt aArg1, TInt aArg2); sl@0: TInt TestFunction0(const TDesC8& aData0, const TDesC& aData1); sl@0: TInt TestFunction1(TInt aArg0, TInt aArg1); sl@0: TInt TestFunction2(TInt aArg0, TInt aArg1); sl@0: TInt TestFunction3(TInt aArg0, TInt aArg1); sl@0: sl@0: TInt TestFunction4(const TDesC8& aData0, const TDesC& aData1); sl@0: TInt TestFunction4(const TDesC& aData0, const TDesC8& aData1); sl@0: TInt TestFunction4(const TDesC8& aData0); sl@0: TInt TestFunction5(const TDesC8& aData0, const TDesC& aData1); sl@0: TInt TestFunction6(const TDesC8& aData0, const TDesC& aData1); sl@0: TInt TestFunction7(const TDesC8& aData0, const TDesC& aData1); sl@0: TInt TestFunction8(const TDesC8& aData0, const TDesC& aData1); sl@0: sl@0: TInt TestFunction9(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1); sl@0: TInt TestFunction9(TDes& aData0,TInt aOffset0, TDes8& aData1,TInt aOffset1); sl@0: TInt TestFunction10(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1); sl@0: TInt TestFunction11(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1); sl@0: TInt TestFunction12(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1); sl@0: TInt TestFunction13(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1); sl@0: TInt TestFunction14(const TDesC8& aData0,TInt aOffset0, TDes8& aData1); sl@0: TInt TestFunction15(const TDesC& aData0,TInt aOffset0, TDes& aData1); sl@0: sl@0: TInt TestFunction16(TAny* aData); sl@0: TInt TestFunction17(TAny* aData); sl@0: sl@0: TInt TestFunction18(TDes8& aData); sl@0: TInt TestFunction18(TDes16& aData); sl@0: TInt TestFunction19(TDes8& aData); sl@0: sl@0: TInt TestFunction20(TInt aArg0, TInt aArg1); sl@0: TInt TestFunction21(TInt aArg0, TInt aArg1); sl@0: TInt TestFunction22(TInt aArg0, TInt aArg1); sl@0: TInt TestFunction23(TInt aArg0, TInt aArg1); sl@0: TInt TestFunction24(TInt aArg0, TInt aArg1); sl@0: sl@0: TInt TestFunction25(); sl@0: TInt TestFunction26(); sl@0: TInt TestFunction27(); sl@0: TInt TestFunction28(TInt aArg0); sl@0: TInt TestFunction29(TDes& aData); sl@0: TInt TestFunction30(TDes8& aData); sl@0: TInt TestFunction31(TInt aArg0); sl@0: TInt TestFunction32(TDes8& aData); sl@0: sl@0: TInt TestInvalidFunction(TInt aFn); sl@0: sl@0: sl@0: }; sl@0: sl@0: /*RClientMessageTestSession2 client side interface to sl@0: * CClientMessageTestServer2 server. This is used to pass sl@0: * messages to the server to testthe Client Message Framework. sl@0: */ sl@0: class RClientMessageTestSession2 : public RSessionBase sl@0: { sl@0: public: sl@0: TInt Connect(); sl@0: sl@0: TInt TestFunction0(TInt aArg0, TInt aArg1); sl@0: sl@0: TInt TestFunction1(const TDesC& aData0); sl@0: sl@0: }; sl@0: sl@0: //Global process that is accessible in test code to determine the sl@0: //exit reason and category on termination sl@0: RProcess serverProcess; sl@0: sl@0: //Launch the server process sl@0: static TInt LaunchServer() sl@0: { sl@0: TInt err = serverProcess.Create(KServerFileName,_L("")); sl@0: sl@0: if(err == KErrNone) sl@0: { sl@0: TRequestStatus serverStat; sl@0: sl@0: serverProcess.SetJustInTime(EFalse); sl@0: serverProcess.Rendezvous(serverStat); sl@0: serverProcess.Resume(); sl@0: User::WaitForRequest(serverStat); sl@0: } sl@0: sl@0: return err; sl@0: } sl@0: sl@0: sl@0: /* Connect to the CClientMessageTestServer, launching sl@0: * the sevrer process if necessary sl@0: */ sl@0: TInt RClientMessageTestSession::Connect() sl@0: { sl@0: TInt retry = 2; sl@0: for(;;) sl@0: { sl@0: TInt r = CreateSession(KServerName,TVersion(1,0,0)); sl@0: sl@0: if((r != KErrNotFound)&&(r != KErrServerTerminated)) sl@0: { sl@0: return r; sl@0: } sl@0: sl@0: if(--retry == 0) sl@0: { sl@0: return r; sl@0: } sl@0: sl@0: r = LaunchServer(); sl@0: if((r != KErrNone)&&(r != KErrAlreadyExists)) sl@0: { sl@0: return r; sl@0: } sl@0: } sl@0: } sl@0: sl@0: /* These functions are used to send IPC messages to the server. sl@0: * The messages are sent with different parameters to test the sl@0: * ClientMessage framework handling of bad messages sl@0: */ sl@0: TInt RClientMessageTestSession::TestFunction0(TInt aArg0, TInt aArg1) sl@0: { sl@0: return SendReceive(ETestMessage0,TIpcArgs(aArg0,aArg1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction0(TInt aArg0) sl@0: { sl@0: return SendReceive(ETestMessage0,TIpcArgs(aArg0)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction0(TInt aArg0, TInt aArg1, TInt aArg2) sl@0: { sl@0: return SendReceive(ETestMessage0,TIpcArgs(aArg0,aArg1,aArg2)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction0(const TDesC8& aData0, const TDesC& aData1) sl@0: { sl@0: //Call the function passing invalid arguments sl@0: return SendReceive(ETestMessage0,TIpcArgs(&aData0,&aData1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction1(TInt aArg0, TInt aArg1) sl@0: { sl@0: return SendReceive(ETestMessage1,TIpcArgs(aArg0,aArg1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction2(TInt aArg0, TInt aArg1) sl@0: { sl@0: return SendReceive(ETestMessage2,TIpcArgs(aArg0,aArg1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction3(TInt aArg0, TInt aArg1) sl@0: { sl@0: return SendReceive(ETestMessage3,TIpcArgs(aArg0,aArg1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction4(const TDesC8& aData0, const TDesC& aData1) sl@0: { sl@0: return SendReceive(ETestMessage4,TIpcArgs(&aData0,&aData1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction4(const TDesC& aData0, const TDesC8& aData1) sl@0: { sl@0: return SendReceive(ETestMessage4,TIpcArgs(&aData0,&aData1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction4(const TDesC8& aData0) sl@0: { sl@0: return SendReceive(ETestMessage4,TIpcArgs(&aData0)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction5(const TDesC8& aData0, const TDesC& aData1) sl@0: { sl@0: return SendReceive(ETestMessage5,TIpcArgs(&aData0,&aData1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction6(const TDesC8& aData0, const TDesC& aData1) sl@0: { sl@0: return SendReceive(ETestMessage6,TIpcArgs(&aData0,&aData1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction7(const TDesC8& aData0, const TDesC& aData1) sl@0: { sl@0: return SendReceive(ETestMessage7,TIpcArgs(&aData0,&aData1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction8(const TDesC8& aData0, const TDesC& aData1) sl@0: { sl@0: return SendReceive(ETestMessage8,TIpcArgs(&aData0,&aData1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction9(TDes& aData0,TInt aOffset0, TDes8& aData1,TInt aOffset1) sl@0: { sl@0: return SendReceive(ETestMessage9,TIpcArgs(&aData0,aOffset0,&aData1,aOffset1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction9(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1) sl@0: { sl@0: return SendReceive(ETestMessage9,TIpcArgs(&aData0,aOffset0,&aData1,aOffset1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction10(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1) sl@0: { sl@0: return SendReceive(ETestMessage10,TIpcArgs(&aData0,aOffset0,&aData1,aOffset1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction11(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1) sl@0: { sl@0: return SendReceive(ETestMessage11,TIpcArgs(&aData0,aOffset0,&aData1,aOffset1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction12(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1) sl@0: { sl@0: return SendReceive(ETestMessage12,TIpcArgs(&aData0,aOffset0,&aData1,aOffset1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction13(TDes8& aData0,TInt aOffset0, TDes& aData1,TInt aOffset1) sl@0: { sl@0: return SendReceive(ETestMessage13,TIpcArgs(&aData0,aOffset0,&aData1,aOffset1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction14(const TDesC8& aData0,TInt aOffset0, TDes8& aData1) sl@0: { sl@0: return SendReceive(ETestMessage14,TIpcArgs(&aData0,aOffset0,&aData1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction15(const TDesC& aData0,TInt aOffset0, TDes& aData1) sl@0: { sl@0: return SendReceive(ETestMessage15,TIpcArgs(&aData0,aOffset0,&aData1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction16(TAny* aData) sl@0: { sl@0: return SendReceive(ETestMessage16,TIpcArgs(aData)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction17(TAny* aData) sl@0: { sl@0: return SendReceive(ETestMessage17,TIpcArgs(aData)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction18(TDes8& aData) sl@0: { sl@0: return SendReceive(ETestMessage18,TIpcArgs(&aData)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction18(TDes& aData) sl@0: { sl@0: return SendReceive(ETestMessage18,TIpcArgs(&aData)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction19(TDes8& aData) sl@0: { sl@0: return SendReceive(ETestMessage19,TIpcArgs(&aData)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction20(TInt aArg0, TInt aArg1) sl@0: { sl@0: return SendReceive(ETestMessage20,TIpcArgs(aArg0,aArg1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction21(TInt aArg0, TInt aArg1) sl@0: { sl@0: return SendReceive(ETestMessage21,TIpcArgs(aArg0,aArg1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction22(TInt aArg0, TInt aArg1) sl@0: { sl@0: return SendReceive(ETestMessage22,TIpcArgs(aArg0,aArg1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction23(TInt aArg0, TInt aArg1) sl@0: { sl@0: return SendReceive(ETestMessage23,TIpcArgs(aArg0,aArg1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction24(TInt aArg0, TInt aArg1) sl@0: { sl@0: return SendReceive(ETestMessage24,TIpcArgs(aArg0,aArg1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction25() sl@0: { sl@0: return SendReceive(ETestMessage25,TIpcArgs()); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction26() sl@0: { sl@0: return SendReceive(ETestMessage26,TIpcArgs()); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction27() sl@0: { sl@0: return SendReceive(ETestMessage27,TIpcArgs()); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction28(TInt aArg0) sl@0: { sl@0: return SendReceive(ETestMessage28,TIpcArgs(aArg0)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction29(TDes& aData) sl@0: { sl@0: return SendReceive(ETestMessage29,TIpcArgs(&aData)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction30(TDes8& aData) sl@0: { sl@0: return SendReceive(ETestMessage30,TIpcArgs(&aData)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction31(TInt aArg0) sl@0: { sl@0: return SendReceive(ETestMessage31,TIpcArgs(aArg0)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestFunction32(TDes8& aData) sl@0: { sl@0: return SendReceive(ETestMessage32,TIpcArgs(&aData)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession::TestInvalidFunction(TInt aFn) sl@0: { sl@0: return SendReceive(aFn,TIpcArgs()); sl@0: } sl@0: sl@0: /* This function is the entry point for a new thread. It calls the sl@0: * function passed to it as a TAny*. sl@0: */ sl@0: TInt TestFunctionLauncherL(TAny* aTestFunction) sl@0: { sl@0: CTrapCleanup* cleanup=CTrapCleanup::New(); sl@0: TInt r=KErrNoMemory; sl@0: if (cleanup) sl@0: { sl@0: TestFunction function = (TestFunction)aTestFunction; sl@0: sl@0: __UHEAP_MARK; sl@0: TRAP(r,function()); sl@0: __UHEAP_MARKEND; sl@0: sl@0: delete cleanup; sl@0: } sl@0: return r; sl@0: } sl@0: sl@0: /* This function creates a new thread and passes through the test function sl@0: * to be called. It also monitors and returns the exit reason for the launched sl@0: * thread. sl@0: */ sl@0: TExitDetails LaunchTestThreadL(const TDesC& aThreadName, TestFunction aFunction) sl@0: { sl@0: RThread thread; sl@0: TInt err = thread.Create(aThreadName, &TestFunctionLauncherL, KDefaultStackSize, NULL, (TAny*)aFunction); sl@0: sl@0: if(err != KErrAlreadyExists) sl@0: { sl@0: User::LeaveIfError(err); sl@0: } sl@0: sl@0: TRequestStatus threadStat; sl@0: thread.Logon(threadStat); sl@0: sl@0: TBool jit = User::JustInTime(); sl@0: User::SetJustInTime(EFalse); sl@0: sl@0: thread.Resume(); sl@0: User::WaitForRequest(threadStat); sl@0: sl@0: User::SetJustInTime(jit); sl@0: sl@0: TExitDetails exitDetails; sl@0: exitDetails.iCategory = thread.ExitCategory(); sl@0: exitDetails.iReason = thread.ExitReason(); sl@0: exitDetails.iExitType = thread.ExitType(); sl@0: sl@0: return exitDetails; sl@0: } sl@0: sl@0: sl@0: /* sl@0: This test function accepts 2 integer parameters as defined below sl@0: {EParamInt,-10,100},{EParamInt,0,200} sl@0: Any calls to this function with parameters outside the ranges sl@0: defined above should fail with KErrBadParameter sl@0: */ sl@0: void TestFunction0AL() sl@0: { sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: err = session.TestFunction0( 0, 100); sl@0: Test(err == KErrNone); sl@0: sl@0: err = session.TestFunction0( 100, 0); sl@0: Test(err == KErrNone); sl@0: sl@0: err = session.TestFunction0( -5, 10); sl@0: Test(err == KErrNone); sl@0: sl@0: err = session.TestFunction0( -5, -10); sl@0: Test(err == KErrBadParameter); sl@0: sl@0: err = session.TestFunction0( -15, 10); sl@0: Test(err == KErrBadParameter); sl@0: sl@0: err = session.TestFunction0( -10, 200); sl@0: Test(err == KErrNone); sl@0: sl@0: err = session.TestFunction0( 101, 102); sl@0: Test(err == KErrBadParameter); sl@0: sl@0: err = session.TestFunction0(11, 56, 43); sl@0: Test(err == KErrNone); sl@0: sl@0: err = session.TestFunction0( _L8("Des8"), _L("Des")); sl@0: Test(err == KErrBadParameter); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: sl@0: /* sl@0: This test function accepts 2 integer parameters as defined below sl@0: {EParamInt,-10,100},{EParamInt,0,200} sl@0: In the server, this function tries to access a ptr type from sl@0: an int argument. This is a programming error and should result sl@0: in the server panicking with ECMPanicWrongParameterType in UDEB sl@0: or returning KErrWrongParameterType in UREL sl@0: */ sl@0: void TestFunction1L() sl@0: { sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: err = session.TestFunction1(10,100); sl@0: sl@0: #ifdef _DEBUG sl@0: Test(err == KErrServerTerminated); sl@0: sl@0: TInt type = serverProcess.ExitType(); sl@0: Test(type == EExitPanic); sl@0: sl@0: TInt reason = serverProcess.ExitReason(); sl@0: Test(reason == ECMPanicWrongParameterType); sl@0: #else sl@0: Test(err == KErrWrongParameterType); sl@0: #endif sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts 1 integer parameter as defined below sl@0: {EParamInt,100,10} sl@0: As can be seen above, the schema is incorrectly defined as iMin is sl@0: greater than iMax. This is a programming error and should result sl@0: in the server panicking with ECMPanicBadMessageSchema in UDEB sl@0: or returning KErrBadParameter in UREL sl@0: */ sl@0: void TestFunction2L() sl@0: { sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: //this function is incorrectly defined in the sl@0: //message schema. This should result in the sl@0: //server panicking sl@0: err = session.TestFunction2(10,100); sl@0: sl@0: //In debug builds the server should panic. sl@0: //In release builds KErrBadParameter should be returned sl@0: #ifdef _DEBUG sl@0: Test(err == KErrServerTerminated); sl@0: sl@0: TInt type = serverProcess.ExitType(); sl@0: Test(type == EExitPanic); sl@0: sl@0: TInt reason = serverProcess.ExitReason(); sl@0: Test(reason == ECMPanicBadMessageSchema); sl@0: #else sl@0: Test(err == KErrBadParameter); sl@0: #endif sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts 1 integer parameter as defined below sl@0: {EParamInt,-10,-20} sl@0: As can be seen above, the schema is incorrectly defined as iMin is sl@0: greater than iMax. This is a programming error and should result sl@0: in the server panicking with ECMPanicBadMessageSchema in UDEB sl@0: or returning KErrBadParameter in UREL sl@0: */ sl@0: void TestFunction3L() sl@0: { sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: //this function is incorrectly defined in the sl@0: //message schema. This should result in the sl@0: //server panicking sl@0: err = session.TestFunction3(10,100); sl@0: sl@0: //In debug builds the server should panic. sl@0: //In release builds KErrBadParameter should be returned sl@0: #ifdef _DEBUG sl@0: Test(err == KErrServerTerminated); sl@0: sl@0: TInt type = serverProcess.ExitType(); sl@0: Test(type == EExitPanic); sl@0: sl@0: TInt reason = serverProcess.ExitReason(); sl@0: Test(reason == ECMPanicBadMessageSchema); sl@0: #else sl@0: Test(err == KErrBadParameter); sl@0: #endif sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts 2 descriptor parameters as defined below sl@0: {EParamDes8Read,2,16},{EParamDes16Read,0,32} sl@0: Any calls to this function with parameters outside the constraints sl@0: defined above should result in the client being panicked with sl@0: KErrBadDescriptor sl@0: */ sl@0: void TestFunction4AL() sl@0: { sl@0: RClientMessageTestSession session; sl@0: _LIT8(KDes8, "Des8"); sl@0: _LIT8(KShortDes8, "De"); sl@0: _LIT(KDes16, "Des16"); sl@0: _LIT(KLongDes16, "Des16 - A longer version"); sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: err = session.TestFunction4(KDes8,KDes16); sl@0: Test(err == KErrNone); sl@0: sl@0: err = session.TestFunction4(KShortDes8,KLongDes16); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts 2 descriptor parameters as defined below sl@0: {EParamDes8Read,2,16},{EParamDes16Read,0,32} sl@0: Any calls to this function with parameters outside the constraints sl@0: defined above should result in the client being panicked with sl@0: KErrBadDescriptor sl@0: */ sl@0: void TestFunction4BL() sl@0: { sl@0: RClientMessageTestSession session; sl@0: _LIT8(KDes8, "Des8"); sl@0: _LIT(KDes16, "Des16"); sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: //This should result in the server panicking the client sl@0: err = session.TestFunction4(KDes16,KDes8); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts 2 descriptor parameters as defined below sl@0: {EParamDes8Read,2,16},{EParamDes16Read,0,32} sl@0: Any calls to this function with parameters outside the constraints sl@0: defined above should result in the client being panicked with sl@0: KErrBadDescriptor sl@0: */ sl@0: void TestFunction4CL() sl@0: { sl@0: RClientMessageTestSession session; sl@0: _LIT(KDes16, "Des16"); sl@0: _LIT8(KLongDes8, "This is a long Des8"); sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: //This should result in the server panicing the client sl@0: err = session.TestFunction4(KLongDes8,KDes16); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts 2 descriptor parameters as defined below sl@0: {EParamDes8Read,2,16},{EParamDes16Read,0,32} sl@0: Any calls to this function with parameters outside the constraints sl@0: defined above should result in the client being panicked with sl@0: KErrBadDescriptor sl@0: */ sl@0: void TestFunction4DL() sl@0: { sl@0: RClientMessageTestSession session; sl@0: _LIT8(KDes8, "Des8"); sl@0: _LIT(KLongDes16, "This is a long Des16 that should cause an issue"); sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: //This should result in the server panicing the client sl@0: err = session.TestFunction4(KDes8,KLongDes16); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts 2 descriptor parameters as defined below sl@0: {EParamDes8Read,2,16},{EParamDes16Read,0,32} sl@0: Any calls to this function with parameters outside the constraints sl@0: defined above should result in the client being panicked with sl@0: KErrBadDescriptor sl@0: */ sl@0: void TestFunction4EL() sl@0: { sl@0: RClientMessageTestSession session; sl@0: _LIT(KDes16, "Des16"); sl@0: _LIT8(KEmptyDes8, ""); sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: //This should result in the server panicing the client sl@0: //as the function expects a descriptor of minimum length 2 sl@0: err = session.TestFunction4(KEmptyDes8,KDes16); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts 2 descriptor parameters as defined below sl@0: {EParamDes8Read,2,16},{EParamDes16Read,0,32} sl@0: Any calls to this function with parameters outside the constraints sl@0: defined above should result in the client being panicked with sl@0: KErrBadDescriptor sl@0: */ sl@0: void TestFunction4FL() sl@0: { sl@0: RClientMessageTestSession session; sl@0: _LIT8(KDes8, "Des8"); sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: //This should result in the server panicing the client sl@0: //as the function expects 2 descriptor arguments sl@0: err = session.TestFunction4(KDes8); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: sl@0: /* sl@0: This test function accepts 2 descriptor parameters as defined below sl@0: {EParamDes8Read,2,16},{EParamDes16Read,0,32} sl@0: The server attempts to read from the first descriptor but passes sl@0: in a buffer that is too small. This is a programming error and sl@0: should result in the server panicking with ECMPanicBadDescriptor in UDEB sl@0: and returning KErrNone in UREL sl@0: KErrBadDescriptor sl@0: */ sl@0: void TestFunction5L() sl@0: { sl@0: RClientMessageTestSession session; sl@0: _LIT8(KDes8, "Des8"); sl@0: _LIT(KDes16, "Des16"); sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: err = session.TestFunction5(KDes8,KDes16); sl@0: #ifdef _DEBUG sl@0: Test(err == KErrServerTerminated); sl@0: sl@0: TInt type = serverProcess.ExitType(); sl@0: Test(type == EExitPanic); sl@0: sl@0: TInt reason = serverProcess.ExitReason(); sl@0: Test(reason == ECMPanicBadDescriptor); sl@0: #else sl@0: Test(err == KErrNone); sl@0: #endif sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts 2 descriptor parameters as defined below sl@0: {EParamDes8Read,2,16},{EParamDes16Read,0,32} sl@0: Any calls to this function with parameters outside the constraints sl@0: defined above should result in the client being panicked with sl@0: KErrBadDescriptor sl@0: */ sl@0: void TestFunction6L() sl@0: { sl@0: RClientMessageTestSession session; sl@0: _LIT8(KDes8, "Des8"); sl@0: _LIT(KDes16, "Des16"); sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: err = session.TestFunction6(KDes8,KDes16); sl@0: Test(err == KErrArgument); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts 2 descriptor parameters as defined below sl@0: {EParamDes8Read,2,16},{EParamDes16Read,0,32} sl@0: Any calls to this function with parameters outside the constraints sl@0: defined above should result in the client being panicked with sl@0: KErrBadDescriptor sl@0: */ sl@0: void TestFunction7L() sl@0: { sl@0: RClientMessageTestSession session; sl@0: _LIT8(KDes8, "Descriptor8"); sl@0: _LIT(KDes16, "Descriptor16"); sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: err = session.TestFunction7(KDes8,KDes16); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts 1 descriptor parameter as defined below sl@0: {EParamDes8Read,0,-16} sl@0: As can be seen above, the schema is incorrectly defined as iMax is sl@0: negative. This is a programming error and should result sl@0: in the server panicking with ECMPanicBadMessageSchema in UDEB sl@0: or the client being panicked with KErrBadDescriptor in UREL sl@0: */ sl@0: void TestFunction8L() sl@0: { sl@0: RClientMessageTestSession session; sl@0: _LIT8(KDes8, "Descriptor8"); sl@0: _LIT(KDes16, "Descriptor16"); sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: //this function is incorrectly defined in the sl@0: //message schema. This should result in the sl@0: //server panicking sl@0: err = session.TestFunction8(KDes8,KDes16); sl@0: sl@0: //In debug builds the server should panic. sl@0: //In release builds the client will be panicked sl@0: #ifdef _DEBUG sl@0: Test(err == KErrServerTerminated); sl@0: sl@0: TInt type = serverProcess.ExitType(); sl@0: Test(type == EExitPanic); sl@0: sl@0: TInt reason = serverProcess.ExitReason(); sl@0: Test(reason == ECMPanicBadMessageSchema); sl@0: #endif sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: sl@0: /* sl@0: This test function accepts 2 descriptor parameters and 2 TInt sl@0: parameters as defined below sl@0: {EParamDes8,64,64},{EParamInt,0,64},{EParamDes16,128,128},{EParamInt,0,128} sl@0: Any calls to this function with descriptor parameters outside the constraints sl@0: defined above should result in the client being paniced with sl@0: KErrBadDescriptor or KErrOverflow sl@0: */ sl@0: void TestFunction9AL() sl@0: { sl@0: TBuf8<64> buf8; sl@0: TBuf<128> buf; sl@0: TBuf8<64> buf82; sl@0: TBuf<128> buf2; sl@0: sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: err = session.TestFunction9(buf8,0,buf,0); sl@0: Test(err == KErrNone); sl@0: Test(buf8.Find(_L8("CClientMessageTest")) == 0); sl@0: Test(buf.Find(_L("CClientMessageTest")) == 0); sl@0: sl@0: err = session.TestFunction9(buf82,7,buf2,73); sl@0: Test(err == KErrNone); sl@0: Test(buf82.Find(_L8("CClientMessageTest")) == 7); sl@0: Test(buf2.Find(_L("CClientMessageTest")) == 73); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts 2 descriptor parameters and 2 TInt sl@0: parameters as defined below sl@0: {EParamDes8,64,64},{EParamInt,0,64},{EParamDes16,128,128},{EParamInt,0,128} sl@0: Any calls to this function with descriptor parameters outside the constraints sl@0: defined above should result in the client being paniced with sl@0: KErrBadDescriptor sl@0: */ sl@0: void TestFunction9BL() sl@0: { sl@0: sl@0: TBuf8<32> smallBuf8; sl@0: TBuf<32> smallBuf; sl@0: sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: //this should result in a client panic with KErrBadDescriptor sl@0: err = session.TestFunction9(smallBuf8,0,smallBuf,0); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts 2 descriptor parameters and 2 TInt sl@0: parameters as defined below sl@0: {EParamDes8,64,64},{EParamInt,0,64},{EParamDes16,128,128},{EParamInt,0,128} sl@0: The server function attempts to write to the supplied descriptors at the sl@0: offsets specified by the two TInt values. In this test the server will sl@0: attempt to write to the first buffer with an offset of 60 which should sl@0: result in the client being panicked with KErrOverflow sl@0: */ sl@0: void TestFunction9CL() sl@0: { sl@0: sl@0: TBuf8<64> buf8; sl@0: TBuf<128> buf; sl@0: sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: //this will attempt to write a descriptor with an offset of 60 sl@0: //which should tresult in a client panic KErrOverflow sl@0: err = session.TestFunction9(buf8,60,buf,10); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts 2 descriptor parameters and 2 TInt sl@0: parameters as defined below sl@0: {EParamDes8,64,64},{EParamInt,0,64},{EParamDes16,128,128},{EParamInt,0,128} sl@0: The test function below calls this function but passed the 8 and 16 bit sl@0: descriptors in the wrong order which should result in the client being sl@0: panicked with KErrBadDescriptor sl@0: */ sl@0: void TestFunction9DL() sl@0: { sl@0: TBuf8<64> buf8; sl@0: TBuf<128> buf; sl@0: sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: //this should result in a client panic as the descriptors sl@0: //are passed in in the wrong order sl@0: err = session.TestFunction9(buf,0,buf8,10); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts 2 descriptor parameters and 2 TInt sl@0: parameters as defined below sl@0: {EParamDes8,64,64},{EParamInt,0,64},{EParamDes16,128,128},{EParamInt,0,128} sl@0: The server function attempts to write a descriptor that is larger than the sl@0: buffer supplied by the client which should result in the client being sl@0: panicked with KErrOverflow sl@0: */ sl@0: void TestFunction10L() sl@0: { sl@0: sl@0: TBuf8<64> buf8; sl@0: TBuf<128> buf; sl@0: sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: //This function tries to write a descriptor sl@0: //that is larger than the declared buffer sl@0: //this should result in a panic sl@0: err = session.TestFunction10(buf8,0,buf,0); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts 2 descriptor parameters and 2 TInt sl@0: parameters as defined below sl@0: {EParamDes8,64,64},{EParamInt,0,64},{EParamDes16,128,128},{EParamInt,0,128} sl@0: The server function attempts to read from a descriptor that is smaller sl@0: than the specified minimum length. This is a programming error and sl@0: should result in the server panicking with ECMPanicBadDescriptor in UDEB sl@0: and returning KErrNone in UREL sl@0: */ sl@0: void TestFunction11L() sl@0: { sl@0: _LIT8(KLongDes8,"This descriptor is longer than 32 characters"); sl@0: TBuf8<64> buf8(KLongDes8); sl@0: TBuf<128> buf; sl@0: sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: //This function tries to read from a descriptor sl@0: //into a buffer that is smaller than the allowed min length sl@0: //this should result in a server panic sl@0: err = session.TestFunction11(buf8,0,buf,0); sl@0: #ifdef _DEBUG sl@0: Test(err == KErrServerTerminated); sl@0: sl@0: TInt type = serverProcess.ExitType(); sl@0: Test(type == EExitPanic); sl@0: sl@0: TInt reason = serverProcess.ExitReason(); sl@0: Test(reason == ECMPanicBadDescriptor); sl@0: #else sl@0: Test(err == KErrNone); sl@0: #endif sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts 1 descriptor parameter as defined below sl@0: {EParamDes8,-64,64} sl@0: As can be seen above, the schema is incorrectly defined as iMin is sl@0: negative. This is a programming error and should result sl@0: in the server panicking with ECMPanicBadMessageSchema in UDEB sl@0: or returning KErrNone in UREL sl@0: */ sl@0: void TestFunction12L() sl@0: { sl@0: sl@0: TBuf8<64> buf8; sl@0: TBuf<128> buf; sl@0: sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: //this function is incorrectly defined in the sl@0: //message schema. This should result in the sl@0: //server panicking in debug builds sl@0: //In release builds KErrNone should be returned sl@0: err = session.TestFunction12(buf8,0,buf,0); sl@0: sl@0: #ifdef _DEBUG sl@0: Test(err == KErrServerTerminated); sl@0: sl@0: TInt type = serverProcess.ExitType(); sl@0: Test(type == EExitPanic); sl@0: sl@0: TInt reason = serverProcess.ExitReason(); sl@0: Test(reason == ECMPanicBadMessageSchema); sl@0: #else sl@0: Test(err == KErrNone); sl@0: #endif sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts 1 descriptor parameter as defined below sl@0: {EParamDes8,64,-64} sl@0: As can be seen above, the schema is incorrectly defined as iMax is sl@0: negative. This is a programming error and should result sl@0: in the server panicking with ECMPanicBadMessageSchema in UDEB sl@0: or panicking the client with KErrBadDescriptor in UREL sl@0: */ sl@0: void TestFunction13L() sl@0: { sl@0: sl@0: TBuf8<64> buf8; sl@0: TBuf<128> buf; sl@0: sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: //this function is incorrectly defined in the sl@0: //message schema. This should result in the sl@0: //server panicking in debug builds sl@0: err = session.TestFunction13(buf8,0,buf,0); sl@0: sl@0: #ifdef _DEBUG sl@0: Test(err == KErrServerTerminated); sl@0: sl@0: TInt type = serverProcess.ExitType(); sl@0: Test(type == EExitPanic); sl@0: sl@0: TInt reason = serverProcess.ExitReason(); sl@0: Test(reason == ECMPanicBadMessageSchema); sl@0: #endif sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts 2 8bit descriptor parameters and 1 TInt sl@0: parameter as defined below sl@0: {EParamDes8Read,0,16},{EParamInt,0,16},{EParamDes8,16,16} sl@0: The server function attempts reads from the first descriptor and sl@0: then writes into the second descriptor at the offset supplied by sl@0: the TInt value. The test function below checks that the reading sl@0: and writing with offset occurs as expected by checking the strings sl@0: written by the server. sl@0: */ sl@0: void TestFunction14L() sl@0: { sl@0: sl@0: _LIT8(KDes8, "Descriptor8"); sl@0: TBuf8<16> buf; sl@0: sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: err = session.TestFunction14(KDes8,0,buf); sl@0: Test(err == KErrNone); sl@0: Test(buf.Find(_L8("Descriptor8")) == 0); sl@0: sl@0: err = session.TestFunction14(KDes8,3,buf); sl@0: Test(err == KErrNone); sl@0: Test(buf.Find(_L8("criptor8")) == 0); sl@0: sl@0: err = session.TestFunction14(KDes8,8,buf); sl@0: Test(err == KErrNone); sl@0: Test(buf.Find(_L8("or8")) == 0); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts 2 16bit descriptor parameters and 1 TInt sl@0: parameter as defined below sl@0: {EParamDes16Read,0,64},{EParamInt,0,64},{EParamDes16,64,64} sl@0: The server function attempts reads from the first descriptor and sl@0: then writes into the second descriptor at the offset supplied by sl@0: the TInt value. The test function below checks that the reading sl@0: and writing with offset occurs as expected by checking the strings sl@0: written by the server. sl@0: */ sl@0: void TestFunction15L() sl@0: { sl@0: sl@0: _LIT(KDes, "Descriptor"); sl@0: TBuf<64> buf; sl@0: sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: err = session.TestFunction15(KDes,0,buf); sl@0: Test(err == KErrNone); sl@0: Test(buf.Find(_L("Descriptor")) == 0); sl@0: sl@0: err = session.TestFunction15(KDes,3,buf); sl@0: Test(err == KErrNone); sl@0: Test(buf.Find(_L("criptor")) == 0); sl@0: sl@0: err = session.TestFunction15(KDes,8,buf); sl@0: Test(err == KErrNone); sl@0: Test(buf.Find(_L("or")) == 0); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: sl@0: /* sl@0: This test function accepts a single TAny* parameter as below sl@0: {EParamPtr,0,0} sl@0: The server function reads the pointer value. sl@0: */ sl@0: void TestFunction16L() sl@0: { sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: err = session.TestFunction16(0); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: sl@0: /* sl@0: This test function accepts a single TAny* parameter as below sl@0: {EParamPtr,0,0} sl@0: The server function attempts to call CMessageParameterBase::WriteL sl@0: which is not defined for a Ptr type. This is a programming error and sl@0: should result in the server panicking with ECMPanicWrongParameterType sl@0: in UDEB or returning KErrWrongParameterType in UREL sl@0: */ sl@0: void TestFunction17L() sl@0: { sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: //This should result in the server panicking with ECMPanicWrongParameterType sl@0: //in UDEB or returning KErrWrongParameterType in UREL sl@0: err = session.TestFunction17(0); sl@0: #ifdef _DEBUG sl@0: Test(err == KErrServerTerminated); sl@0: sl@0: TInt type = serverProcess.ExitType(); sl@0: Test(type == EExitPanic); sl@0: sl@0: TInt reason = serverProcess.ExitReason(); sl@0: Test(reason == ECMPanicWrongParameterType); sl@0: #else sl@0: Test(err == KErrWrongParameterType); sl@0: #endif sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts a single custom TPckg parameter as below sl@0: {EParamCustom1,sizeof(CMTestStruct2),sizeof(CMTestStruct2)}. sl@0: CMTestStruct2 is defined as follows: sl@0: sl@0: struct CMTestStruct1 sl@0: { sl@0: TInt iInt; sl@0: TBuf<32> iDes; sl@0: }; sl@0: sl@0: struct CMTestStruct2 sl@0: { sl@0: TInt iCount; sl@0: CMTestStruct1* iStruct; sl@0: TCMTestEnum iEnum; sl@0: TBuf<32> iDes; sl@0: }; sl@0: sl@0: The EParamCustom1 parameter type is validated using a custom validation sl@0: function defined in the testclientmessageschema.cpp. The validation sl@0: function checks that iEnum is in the valid range for TCMTestEnum, sl@0: that iCount >= 0 and that iDes.Length() > 0. If any of these checks sl@0: fail the server should return KErrBadParameter. sl@0: */ sl@0: void TestFunction18AL() sl@0: { sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: CMTestStruct1 struct1; sl@0: struct1.iInt = 7; sl@0: struct1.iDes = _L("Test Struct"); sl@0: sl@0: CMTestStruct2 struct2; sl@0: struct2.iCount = 1; sl@0: struct2.iStruct = &struct1; sl@0: struct2.iEnum = ETestVal1; sl@0: struct2.iDes = _L("Test Struct 2"); sl@0: sl@0: TPckg pData(struct2); sl@0: sl@0: err = session.TestFunction18(pData); sl@0: Test(err == KErrNone); sl@0: sl@0: Test(struct2.iCount == 0); sl@0: sl@0: CMTestStruct1 struct3; sl@0: struct3.iInt = -1; sl@0: struct3.iDes = _L(""); sl@0: sl@0: CMTestStruct2 struct4; sl@0: struct4.iCount = 1; sl@0: struct4.iStruct = &struct3; sl@0: struct4.iEnum = -1; sl@0: struct4.iDes = _L("Test Struct 2"); sl@0: sl@0: TPckg pData2(struct4); sl@0: sl@0: //As iEnum is not in the valid range this validation should fail sl@0: err = session.TestFunction18(pData2); sl@0: Test(err == KErrBadParameter); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts a single custom TPckg parameter as below sl@0: {EParamCustom1,sizeof(CMTestStruct2),sizeof(CMTestStruct2)}. sl@0: CMTestStruct2 is defined above. sl@0: The test function below passes in a TPckg which is an sl@0: incorrect type. The server should return KErrBadDescriptor sl@0: */ sl@0: void TestFunction18BL() sl@0: { sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: CMTestStruct1 struct1; sl@0: struct1.iInt = 0; sl@0: struct1.iDes = _L("Test Struct"); sl@0: sl@0: TPckg pData(struct1); sl@0: sl@0: //This should result in a panic sl@0: err = session.TestFunction18(pData); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts a single custom TPckg parameter as below sl@0: {EParamCustom1,sizeof(CMTestStruct2),sizeof(CMTestStruct2)}. sl@0: CMTestStruct2 is defined above. sl@0: The test function below passes in an Empty TBuf the same size as a sl@0: CMTestStruct2. As this wont contain any valid data, the server should sl@0: panic the client with KErrBadParameter. sl@0: */ sl@0: void TestFunction18CL() sl@0: { sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: TBuf buf; sl@0: buf.SetLength(sizeof(CMTestStruct2)); sl@0: sl@0: //This should result in a panic sl@0: err = session.TestFunction18(buf); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts a single custom TPckg parameter as below sl@0: {EParamCustom2,sizeof(CMTestStruct1),sizeof(CMTestStruct1)}. sl@0: CMTestStruct1 is defined as follows: sl@0: sl@0: struct CMTestStruct1 sl@0: { sl@0: TInt iInt; sl@0: TBuf<32> iDes; sl@0: }; sl@0: sl@0: The EParamCustom1 parameter type is validated using a custom validation sl@0: function defined in the testclientmessageschema.cpp. The validation sl@0: function checks that iInt is > 0. If this check fails the server sl@0: should return KErrBadParameter. sl@0: The test function below passes the data to the server in a TPckgBuf sl@0: */ sl@0: void TestFunction19L() sl@0: { sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: CMTestStruct1 struct1; sl@0: struct1.iInt = 4; sl@0: struct1.iDes = _L("Test Struct"); sl@0: sl@0: TPckgBuf pData(struct1); sl@0: sl@0: err = session.TestFunction19(pData); sl@0: Test(err == KErrNone); sl@0: sl@0: struct1.iInt = -4; sl@0: TPckgBuf pData2(struct1); sl@0: sl@0: err = session.TestFunction19(pData2); sl@0: Test(err == KErrBadParameter); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function does not expect any parameters. sl@0: The schema defines a single placeholder parameter sl@0: {EParamNull,0,0} sl@0: but the number of parameters is set to 0 sl@0: */ sl@0: void TestFunction25L() sl@0: { sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: err = session.TestFunction25(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function does not expect any parameters. sl@0: The schema defines a single placeholder parameter sl@0: {EParamNull,0,0} sl@0: The schema is incorrectly defined as the number of parameters is sl@0: listed as 1 instead of 0. This is a programming error and should result sl@0: in the server panicking with ECMPanicBadMessageSchema in UDEB sl@0: or the client being panicked with KErrBadDescriptor in UREL sl@0: */ sl@0: void TestFunction26L() sl@0: { sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: err = session.TestFunction26(); sl@0: //In debug builds the server should panic. sl@0: //In release builds KErrBadParameter should be returned sl@0: #ifdef _DEBUG sl@0: Test(err == KErrServerTerminated); sl@0: sl@0: TInt type = serverProcess.ExitType(); sl@0: Test(type == EExitPanic); sl@0: sl@0: TInt reason = serverProcess.ExitReason(); sl@0: Test(reason == ECMPanicBadMessageSchema); sl@0: #else sl@0: Test(err == KErrBadMessageSchema); sl@0: #endif sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function does not expect any parameters. sl@0: The schema defines a single placeholder parameter sl@0: {453,0,0} sl@0: The schema is incorrectly defined as it contains an invalid sl@0: parameter type. This is a programming error and should result sl@0: in the server panicking with ECMPanicBadMessageSchema in UDEB sl@0: or returning KErrBadParameter in UREL sl@0: */ sl@0: void TestFunction27L() sl@0: { sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: err = session.TestFunction27(); sl@0: //In debug builds the server should panic. sl@0: //In release builds KErrBadMessageSchema should be returned sl@0: #ifdef _DEBUG sl@0: Test(err == KErrServerTerminated); sl@0: sl@0: TInt type = serverProcess.ExitType(); sl@0: Test(type == EExitPanic); sl@0: sl@0: TInt reason = serverProcess.ExitReason(); sl@0: Test(reason == ECMPanicBadMessageSchema); sl@0: #else sl@0: Test(err == KErrBadMessageSchema); sl@0: #endif sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts a single integer parameter with a sl@0: custom validation function. sl@0: {EParamCustom3,0,0} sl@0: The validation functions checks that the value passed in is a sl@0: multiple of 4. sl@0: Any calls to this function with a parameter that is not divisible sl@0: by 4 should fail with KErrBadParameter sl@0: */ sl@0: void TestFunction28L() sl@0: { sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: err = session.TestFunction28(4); sl@0: Test(err == KErrNone); sl@0: sl@0: err = session.TestFunction28(128); sl@0: Test(err == KErrNone); sl@0: sl@0: err = session.TestFunction28(73); sl@0: Test(err == KErrBadParameter); sl@0: sl@0: err = session.TestFunction28(-1); sl@0: Test(err == KErrBadParameter); sl@0: sl@0: err = session.TestFunction28(44444444); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts a single descriptor parameter with a sl@0: custom validation function. sl@0: {EParamCustom4,0,0} sl@0: The validation functions checks that the descriptor passed in sl@0: contains the string 'Expected Data' sl@0: Any calls to this function with a descriptor that is not 'Expected Data' sl@0: should fail with KErrBadParameter sl@0: */ sl@0: void TestFunction29L() sl@0: { sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: TBuf<32> data = _L("Expected Data"); sl@0: sl@0: err = session.TestFunction29(data); sl@0: Test(err == KErrNone); sl@0: sl@0: data.SetLength(5); sl@0: sl@0: err = session.TestFunction29(data); sl@0: Test(err == KErrBadParameter); sl@0: sl@0: data = _L("expected data"); sl@0: sl@0: err = session.TestFunction29(data); sl@0: Test(err == KErrBadParameter); sl@0: sl@0: data.Zero(); sl@0: sl@0: err = session.TestFunction29(data); sl@0: Test(err == KErrBadParameter); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts a single custom TPckg parameter as below sl@0: {EParamPckg,sizeof(CMTestStruct1),sizeof(CMTestStruct1)}. sl@0: CMTestStruct1 is defined as follows: sl@0: sl@0: struct CMTestStruct1 sl@0: { sl@0: TInt iInt; sl@0: TBuf<32> iDes; sl@0: }; sl@0: sl@0: The EParamCustom1 parameter type is validated using the default validation sl@0: function. This checks that the size of the TPckg passed in is sl@0: exactly that defined in the schema. If this check fails the server sl@0: should panic the client with KErrBadDescriptor. sl@0: */ sl@0: void TestFunction30L() sl@0: { sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: CMTestStruct1 struct1; sl@0: struct1.iInt = 4; sl@0: struct1.iDes = _L("Test Struct"); sl@0: sl@0: TPckg pData(struct1); sl@0: sl@0: err = session.TestFunction30(pData); sl@0: Test(err == KErrNone); sl@0: sl@0: TBuf8<16> data; sl@0: //This should cause a panic sl@0: err = session.TestFunction30(data); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* sl@0: This test function accepts an Intergeer parameter and a TAny* parameter sl@0: {EParamInt,EGetIntL,EWrite16L},{EParamPtr,0,0} sl@0: sl@0: The server function checks the value passed in the TInt parameter and calls sl@0: an appropriate CMessageParameterBase function on the second parameter. sl@0: As none of the functions called are defined for a pointer parameter, the sl@0: call defaults to the CMessageParameterBase implementation which panics the sl@0: client with ECMPanicWrongParameterType in UDEB or returns sl@0: KErrWrongParameterType in UREL sl@0: */ sl@0: void DoTest31L(TInt aType) sl@0: { sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: err = session.TestFunction31(aType); sl@0: #ifdef _DEBUG sl@0: Test(err == KErrServerTerminated); sl@0: sl@0: TInt type = serverProcess.ExitType(); sl@0: Test(type == EExitPanic); sl@0: sl@0: TInt reason = serverProcess.ExitReason(); sl@0: Test(reason == ECMPanicWrongParameterType); sl@0: #else sl@0: Test(err == KErrWrongParameterType); sl@0: #endif sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: void TestFunction31AL() sl@0: { sl@0: DoTest31L(EGetIntL); sl@0: } sl@0: sl@0: void TestFunction31BL() sl@0: { sl@0: DoTest31L(EGetDes8L); sl@0: } sl@0: sl@0: void TestFunction31CL() sl@0: { sl@0: DoTest31L(EGetDes16L); sl@0: } sl@0: sl@0: void TestFunction31DL() sl@0: { sl@0: DoTest31L(EGetDesLengthL); sl@0: } sl@0: sl@0: void TestFunction31EL() sl@0: { sl@0: DoTest31L(EGetDesMaxLengthL); sl@0: } sl@0: sl@0: void TestFunction31FL() sl@0: { sl@0: DoTest31L(ERead8L); sl@0: } sl@0: sl@0: void TestFunction31GL() sl@0: { sl@0: DoTest31L(ERead16L); sl@0: } sl@0: sl@0: void TestFunction31HL() sl@0: { sl@0: DoTest31L(EWrite8L); sl@0: } sl@0: sl@0: void TestFunction31IL() sl@0: { sl@0: DoTest31L(EWrite16L); sl@0: } sl@0: /* sl@0: This test function accepts a single custom parameter as below sl@0: {EParamCustom5,sizeof(CMTestStruct1),sizeof(CMTestStruct1)} sl@0: CMTestStruct1 is defined as follows: sl@0: sl@0: struct CMTestStruct1 sl@0: { sl@0: TInt iInt; sl@0: TBuf<32> iDes; sl@0: }; sl@0: sl@0: The EParamCustom5 parameter type enum value is defined as sl@0: (0x90000 | EParamPckg). The upper 16 bits are the index of sl@0: the validation function in the array supplied by the server. sl@0: The array only contains 5 values so the above definition is sl@0: incorrect. Calling this messge should result in the server sl@0: panicking with ECMPanicBadMessageSchema in UDEB or returning sl@0: KErrBadMessageSchema in UREL sl@0: */ sl@0: void TestFunction32L() sl@0: { sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: CMTestStruct1 struct1; sl@0: TPckg pData(struct1); sl@0: sl@0: err = session.TestFunction32(pData); sl@0: sl@0: #ifdef _DEBUG sl@0: Test(err == KErrServerTerminated); sl@0: sl@0: TInt type = serverProcess.ExitType(); sl@0: Test(type == EExitPanic); sl@0: sl@0: TInt reason = serverProcess.ExitReason(); sl@0: Test(reason == ECMPanicBadMessageSchema); sl@0: #else sl@0: Test(err == KErrBadMessageSchema); sl@0: #endif sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /* Connect to the CClientMessageTestServer, launching sl@0: * the server process if necessary sl@0: */ sl@0: TInt RClientMessageTestSession2::Connect() sl@0: { sl@0: TInt retry = 2; sl@0: for(;;) sl@0: { sl@0: TInt r = CreateSession(KServer2Name,TVersion(1,0,0)); sl@0: sl@0: if((r != KErrNotFound)&&(r != KErrServerTerminated)) sl@0: { sl@0: return r; sl@0: } sl@0: sl@0: if(--retry == 0) sl@0: { sl@0: return r; sl@0: } sl@0: sl@0: r = LaunchServer(); sl@0: if((r != KErrNone)&&(r != KErrAlreadyExists)) sl@0: { sl@0: return r; sl@0: } sl@0: } sl@0: } sl@0: sl@0: sl@0: sl@0: /* These functions are used to send IPC messages to the server. sl@0: * The messages are sent with different parameters to test the sl@0: * ClientMessage framework handling of bad messages sl@0: */ sl@0: TInt RClientMessageTestSession2::TestFunction0(TInt aArg0, TInt aArg1) sl@0: { sl@0: return SendReceive(ETestMessage0,TIpcArgs(aArg0,aArg1)); sl@0: } sl@0: sl@0: TInt RClientMessageTestSession2::TestFunction1(const TDesC& aData0) sl@0: { sl@0: return SendReceive(ETestMessage1,TIpcArgs(&aData0)); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-4040 sl@0: @SYMTestCaseDesc Tests CClientMessage handling of EParamInt type parameters sl@0: @SYMTestPriority High sl@0: @SYMTestActions Call a series of test functions expecting integer parameters. sl@0: Various argument values and types are passed to these functions. sl@0: The Server should only accept messages containing integer sl@0: values that fall within the bounds defined in the message schema. sl@0: @SYMTestExpectedResults The Server should return KErrNone if the message is sl@0: accepted or KErrBadParameter if the int parameters are outside sl@0: the bounds defined in the schema. If the message is incorrectly sl@0: defined in the mssage schema or the server code incorrectly uses sl@0: the parameter type the server should panic. sl@0: @SYMDEF INC117370 sl@0: */ sl@0: void DoIntParameterTestsL() sl@0: { sl@0: TExitDetails exitDetails; sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction0"), &TestFunction0AL); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction1"), &TestFunction1L); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction2"), &TestFunction2L); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction3"), &TestFunction3L); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction28"), &TestFunction28L); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-4041 sl@0: @SYMTestCaseDesc Tests CClientMessage handling of EParamDes8Read and sl@0: EParamDes16Read type parameters sl@0: @SYMTestPriority High sl@0: @SYMTestActions Call a series of test functions expecting Des*Read parameters. sl@0: Various argument values and types are passed to these functions. sl@0: The Server should only accept messages containing Des*Read sl@0: values that fall within the bounds defined in the message schema. sl@0: @SYMTestExpectedResults The Server should return KErrNone if the message is sl@0: accepted or panic the client with KErrBadDescriptor if the sl@0: descriptor parameters are outside the bounds defined in the schema. sl@0: If the message is incorrectly defined in the mssage schema or the sl@0: server code incorrectly uses the parameter type the server should panic. sl@0: @SYMDEF INC117370 sl@0: */ sl@0: void DoDesReadParameterTestsL() sl@0: { sl@0: TExitDetails exitDetails; sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction4A"), &TestFunction4AL); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction4B"), &TestFunction4BL); sl@0: Test(exitDetails.iExitType == EExitPanic); sl@0: Test(exitDetails.iReason == KErrBadDescriptor); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction4C"), &TestFunction4CL); sl@0: Test(exitDetails.iExitType == EExitPanic); sl@0: Test(exitDetails.iReason == KErrBadDescriptor); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction4D"), &TestFunction4DL); sl@0: Test(exitDetails.iExitType == EExitPanic); sl@0: Test(exitDetails.iReason == KErrBadDescriptor); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction4E"), &TestFunction4EL); sl@0: Test(exitDetails.iExitType == EExitPanic); sl@0: Test(exitDetails.iReason == KErrBadDescriptor); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction4F"), &TestFunction4FL); sl@0: Test(exitDetails.iExitType == EExitPanic); sl@0: Test(exitDetails.iReason == KErrBadDescriptor); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction5"), &TestFunction5L); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction6"), &TestFunction6L); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction7"), &TestFunction7L); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction8"), &TestFunction8L); sl@0: #ifdef _DEBUG sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: #else sl@0: Test(exitDetails.iExitType == EExitPanic); sl@0: Test(exitDetails.iReason == KErrBadDescriptor); sl@0: #endif sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction29"), &TestFunction29L); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-4042 sl@0: @SYMTestCaseDesc Tests CClientMessage handling of EParamDes8 and sl@0: EParamDes16 type parameters sl@0: @SYMTestPriority High sl@0: @SYMTestActions Call a series of test functions expecting Des* parameters. sl@0: Various argument values and types are passed to these functions. sl@0: The Server should only accept messages containing Des* sl@0: values that fall within the bounds defined in the message schema. sl@0: @SYMTestExpectedResults The Server should return KErrNone if the message is sl@0: accepted or panic the client with KErrBadDescriptor or KErrOverflow if the sl@0: descriptor parameters are outside the bounds defined in the schema. sl@0: If the message is incorrectly defined in the mssage schema or the sl@0: server code incorrectly uses the parameter type the server should panic. sl@0: @SYMDEF INC117370 sl@0: */ sl@0: void DoDesParameterTestsL() sl@0: { sl@0: TExitDetails exitDetails; sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction9A"), &TestFunction9AL); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction9B"), &TestFunction9BL); sl@0: Test(exitDetails.iExitType == EExitPanic); sl@0: Test(exitDetails.iReason == KErrBadDescriptor); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction9C"), &TestFunction9CL); sl@0: Test(exitDetails.iExitType == EExitPanic); sl@0: Test(exitDetails.iReason == KErrOverflow); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction9D"), &TestFunction9DL); sl@0: Test(exitDetails.iExitType == EExitPanic); sl@0: Test(exitDetails.iReason == KErrBadDescriptor); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction10"), &TestFunction10L); sl@0: Test(exitDetails.iExitType == EExitPanic); sl@0: Test(exitDetails.iReason == KErrOverflow); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction11"), &TestFunction11L); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction12"), &TestFunction12L); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction13"), &TestFunction13L); sl@0: #ifdef _DEBUG sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: #else sl@0: Test(exitDetails.iExitType == EExitPanic); sl@0: Test(exitDetails.iReason == KErrBadDescriptor); sl@0: #endif sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction14"), &TestFunction14L); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction15"), &TestFunction15L); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-4043 sl@0: @SYMTestCaseDesc Tests CClientMessage handling of EParamPtr type parameters sl@0: @SYMTestPriority High sl@0: @SYMTestActions Call test functions accepting ptr parameter types sl@0: @SYMTestExpectedResults The Server should return KErrNone if the message is sl@0: accepted. If the message is incorrectly defined in the message sl@0: schema or the server code incorrectly uses the parameter type sl@0: the server should panic sl@0: expected sl@0: @SYMDEF INC117370 sl@0: */ sl@0: void DoPtrParameterTestsL() sl@0: { sl@0: TExitDetails exitDetails; sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction16"), &TestFunction16L); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction17"), &TestFunction17L); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-4044 sl@0: @SYMTestCaseDesc Tests CClientMessage handling of EParamPckg type parameters sl@0: @SYMTestPriority High sl@0: @SYMTestActions Call a series of test functions expecting Pckg parameters. sl@0: Various argument values and types are passed to these functions. sl@0: The Server should only accept messages containing Pckg sl@0: values that fall within the bounds defined in the message schema. sl@0: @SYMTestExpectedResults The Server should return KErrNone if the message is sl@0: accepted, return KErrBadParameter if the packaged parameter is sl@0: outside the bounds described in the schema or panic the client with sl@0: KErrBadDescriptor if the descriptor parameter is outside the bounds sl@0: defined in the schema. sl@0: @SYMDEF INC117370 sl@0: */ sl@0: void DoPckgParameterTestsL() sl@0: { sl@0: TExitDetails exitDetails; sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction18A"), &TestFunction18AL); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction18B"), &TestFunction18BL); sl@0: Test(exitDetails.iExitType == EExitPanic); sl@0: Test(exitDetails.iReason == KErrBadDescriptor); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction18C"), &TestFunction18CL); sl@0: Test(exitDetails.iExitType == EExitPanic); sl@0: Test(exitDetails.iReason == KErrBadDescriptor); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction19"), &TestFunction19L); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction30"), &TestFunction30L); sl@0: Test(exitDetails.iExitType == EExitPanic); sl@0: Test(exitDetails.iReason == KErrBadDescriptor); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction32"), &TestFunction32L); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-4045 sl@0: @SYMTestCaseDesc Tests CClientMessage handling of EParamNull type parameters sl@0: @SYMTestPriority High sl@0: @SYMTestActions Call a series of test functions expecting no parameters. sl@0: @SYMTestExpectedResults The Server should return KErrNone if the message is sl@0: accepted. If the message is incorrectly defined in the message sl@0: schema or the server code incorrectly uses the parameter type sl@0: the server should panic. sl@0: @SYMDEF INC117370 sl@0: */ sl@0: void DoNullParameterTestsL() sl@0: { sl@0: sl@0: TExitDetails exitDetails; sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction25"), &TestFunction25L); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction26"), &TestFunction26L); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction27"), &TestFunction27L); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-4046 sl@0: @SYMTestCaseDesc Tests CClientMessage handling of Security policies sl@0: @SYMTestPriority High sl@0: @SYMTestActions Call several test functions with varying security policies and sl@0: verify that the ClientMessage framework handles each case as sl@0: expected sl@0: @SYMTestExpectedResults The server should return KErrNone if the client has sl@0: the required security policy, otherwise return KErrPermissionDenied sl@0: @SYMDEF INC117370 sl@0: */ sl@0: void DoSecurityPolicyTestsL() sl@0: { sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: //This function is incorrectly defined in the message table sl@0: //for this server and so the CClientMessage Object creation will fail sl@0: //This should reult in the server panicking sl@0: RDebug::Print(_L("Testing Always Fail Policy...")); sl@0: err = session.TestFunction20(0,0); sl@0: Test(err == KErrPermissionDenied); sl@0: sl@0: RDebug::Print(_L("Testing Valid SID Policy...")); sl@0: err = session.TestFunction21(0,0); sl@0: Test(err == KErrNone); sl@0: sl@0: RDebug::Print(_L("Testing Invalid SID Policy...")); sl@0: err = session.TestFunction22(0,0); sl@0: Test(err == KErrPermissionDenied); sl@0: sl@0: RDebug::Print(_L("Testing Valid Capability Policy...")); sl@0: err = session.TestFunction23(0,0); sl@0: Test(err == KErrNone); sl@0: sl@0: RDebug::Print(_L("Testing Invalid Capability Policy...")); sl@0: err = session.TestFunction24(0,0); sl@0: Test(err == KErrPermissionDenied); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-4047 sl@0: @SYMTestCaseDesc Tests CClientMessage handling of undefined messagess sl@0: @SYMTestPriority High sl@0: @SYMTestActions Call a test function which sends an unknown message request to the sl@0: server. sl@0: @SYMTestExpectedResults The ClientMessage framework should return KErrInvalidFunction sl@0: @SYMDEF INC117370 sl@0: */ sl@0: void DoInvalidMessageTestsL() sl@0: { sl@0: RClientMessageTestSession session; sl@0: sl@0: TInt err = session.Connect(); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: //This function is not defined in the message table sl@0: //for this server and so the CClientMessage Object creation will fail sl@0: //This should result in the server panicking sl@0: err = session.TestInvalidFunction(45); sl@0: Test(err == KErrInvalidFunction); sl@0: sl@0: err = session.TestInvalidFunction(5); sl@0: Test(err == KErrInvalidFunction); sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-4050 sl@0: @SYMTestCaseDesc Tests CMessageParameterBase default implementation of message access functions sl@0: @SYMTestPriority High sl@0: @SYMTestActions Calls test functions which signal the server to call one sl@0: of the Message access methods on a EParamPtr parameter type. sl@0: As none of these methods are explicitly defined for a EParamPtr sl@0: type the call will be delegated to the base class implementation sl@0: which will panic the client in UDEB and return an error in UREL sl@0: @SYMTestExpectedResults The server should panic the client with ECMPanicWrongParameterType sl@0: in UDEB and return KErrWrongParameterType in UREL sl@0: @SYMDEF INC117370 sl@0: */ sl@0: void DoCMessageParameterBaseTestL() sl@0: { sl@0: sl@0: TExitDetails exitDetails; sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction31A"), &TestFunction31AL); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction31B"), &TestFunction31BL); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction31C"), &TestFunction31CL); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction31D"), &TestFunction31DL); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction31E"), &TestFunction31EL); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction31F"), &TestFunction31FL); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction31G"), &TestFunction31GL); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction31H"), &TestFunction31HL); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: exitDetails = LaunchTestThreadL(_L("TestFunction31I"), &TestFunction31IL); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-4048 sl@0: @SYMTestCaseDesc Tests CClientMessage handling of multiple servers sl@0: @SYMTestPriority High sl@0: @SYMTestActions Calls test functions which pass the same message to two different sl@0: servers. The servers have different message schemas and data is sl@0: passed to the server to check that the correct schema is used sl@0: for the given server. sl@0: @SYMTestExpectedResults The ClientMessage framework should validate the message sl@0: against the correct schema for the given server sl@0: @SYMDEF INC117370 sl@0: */ sl@0: void DoMultipleServerTestsL() sl@0: { sl@0: sl@0: RClientMessageTestSession session1; sl@0: RClientMessageTestSession2 session2; sl@0: sl@0: TInt err = session1.Connect(); sl@0: Test(err == KErrNone); sl@0: CleanupClosePushL(session1); sl@0: sl@0: err = session2.Connect(); sl@0: Test(err == KErrNone); sl@0: CleanupClosePushL(session2); sl@0: sl@0: err = session1.TestFunction0( 0, 150); sl@0: Test(err == KErrNone); sl@0: sl@0: err = session2.TestFunction0( 0, 150); sl@0: Test(err == KErrBadParameter); sl@0: sl@0: err = session1.TestFunction0( 0, -50); sl@0: Test(err == KErrBadParameter); sl@0: sl@0: err = session2.TestFunction0( 0, -50); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(2,&session1); sl@0: sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-4051 sl@0: @SYMTestCaseDesc Tests CClientMessage allowing disabling of Panic. sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Calls test functions which pass a message to a server for which the sl@0: ESrvFlagDoNotPanicClientOnBadMessageErrors flag is set.Then invokes the client API with sl@0: incorrect arguments to create an error scenario of KErrBadDescriptor. sl@0: @SYMTestExpectedResults The ClientMessage framework should check for the above flag, and in case sl@0: its not set simply return an error instead of panicing the client. sl@0: @SYMDEF DEF125501 sl@0: */ sl@0: void DoDisablePanicTestsL() sl@0: { sl@0: sl@0: RClientMessageTestSession2 session; sl@0: _LIT(KDes16, "Descriptor"); sl@0: sl@0: TInt err = session.Connect(); sl@0: Test(err == KErrNone); sl@0: sl@0: CleanupClosePushL(session); sl@0: sl@0: /* According to schema defined, this function accepts TDesC8 only. sl@0: Validation failure occurs.Server should check if flag ESrvFlagDoNotPanicClientOnBadMessageErrors sl@0: is set, and either return with KErrBadDescriptor or Panic the client. sl@0: In this case the above flag is set for CClientMessageTestServer2. sl@0: */ sl@0: err = session.TestFunction1(KDes16); sl@0: sl@0: #ifdef _DEBUG sl@0: Test(err == KErrBadDescriptor); sl@0: sl@0: // Server is not terminated, still alive sl@0: TInt type = serverProcess.ExitType(); sl@0: Test(type == EExitPending); sl@0: #else sl@0: Test(err == KErrBadDescriptor); sl@0: #endif sl@0: sl@0: CleanupStack::PopAndDestroy(&session); sl@0: sl@0: } sl@0: sl@0: sl@0: static void DoTestsL() sl@0: { sl@0: sl@0: TExitDetails exitDetails; sl@0: sl@0: Test.Title (); sl@0: Test.Start (_L("ClientMessage Tests")); sl@0: sl@0: Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4040 Testing Message with Int Parameters ")); sl@0: DoIntParameterTestsL(); sl@0: sl@0: Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4041 Testing Message with Read Only Des Parameters ")); sl@0: DoDesReadParameterTestsL(); sl@0: sl@0: Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4042 Testing Message with Read/Write Des Parameters ")); sl@0: DoDesParameterTestsL(); sl@0: sl@0: Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4043 Testing Message with Ptr Parameters ")); sl@0: DoPtrParameterTestsL(); sl@0: sl@0: Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4044 Testing Message with Pckg Parameters ")); sl@0: DoPckgParameterTestsL(); sl@0: sl@0: Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4045 Testing Message with Null Parameters ")); sl@0: DoNullParameterTestsL(); sl@0: sl@0: Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4046 Testing Security Policy Checking ")); sl@0: exitDetails = LaunchTestThreadL(_L("SecurityPolicyTestL"), &DoSecurityPolicyTestsL); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4047 Testing Invalid Message ")); sl@0: exitDetails = LaunchTestThreadL(_L("InvalidMessageTestL"), &DoInvalidMessageTestsL); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4050 Testing CMessageParameterBase Default Implementations ")); sl@0: exitDetails = LaunchTestThreadL(_L("CMessageParameterBaseTestL"), &DoCMessageParameterBaseTestL); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4048 Testing Multiple Servers ")); sl@0: exitDetails = LaunchTestThreadL(_L("MultipleServerTestingL"), &DoMultipleServerTestsL); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: Test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4051 Testing Disable Client Panic")); sl@0: exitDetails = LaunchTestThreadL(_L("DisablePanicTesting"), &DoDisablePanicTestsL); sl@0: Test(exitDetails.iExitType == EExitKill); sl@0: sl@0: sl@0: Test.Printf(_L("Tests Completed O.K.")); sl@0: sl@0: Test.End(); sl@0: Test.Close(); sl@0: sl@0: } sl@0: sl@0: sl@0: TInt E32Main() sl@0: // sl@0: // Server process entry-point sl@0: // sl@0: { sl@0: // sl@0: CTrapCleanup* cleanup=CTrapCleanup::New(); sl@0: TInt r=KErrNoMemory; sl@0: if (cleanup) sl@0: { sl@0: TRAP(r,DoTestsL()); sl@0: delete cleanup; sl@0: } sl@0: // sl@0: return r; sl@0: }