testexecmdw/tef/tef/test/regressiontest/clienttest/src/ctefclientut.cpp
branchRCL_3
changeset 3 9397a16b6eb8
parent 1 6edeef394eb7
equal deleted inserted replaced
1:6edeef394eb7 3:9397a16b6eb8
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 /**
       
    21  @file CTEFClientUT.cpp
       
    22 */
       
    23 
       
    24 #include "ctefclientsuiteut.h"
       
    25 
       
    26 void CTEFClientSuiteUT::SetupL()
       
    27 /**
       
    28  * SetupL
       
    29  */
       
    30 	{
       
    31 	CTestFixture::SetupL();
       
    32 	}
       
    33 void CTEFClientSuiteUT::ServerConnect() 
       
    34 	{
       
    35 	TInt err = iServer.Connect(_L("te_RegStepTestSuite"));
       
    36 	INFO_PRINTF2( _L("Server(te_RegStepTestSuite) Connect returns = %d"), err );
       
    37 	}
       
    38 
       
    39 void CTEFClientSuiteUT::TearDownL()
       
    40 /**
       
    41  * TearDownL
       
    42  */
       
    43 	{
       
    44 	CTestFixture::TearDownL();
       
    45 	iServer.Close();
       
    46 	INFO_PRINTF1( _L("Server Close returns"));
       
    47 	}
       
    48 
       
    49 TInt CTEFClientSuiteUT::OpenSession(RTestSession &aSession, const TDesC& aName)
       
    50 	{
       
    51 	TInt err; 
       
    52 	ServerConnect();
       
    53 	err = aSession.Open(iServer,aName);
       
    54 	INFO_PRINTF3( _L("%S Session Open returns = %d"),&aName, err );
       
    55 	return err; 
       
    56 	}
       
    57 void CTEFClientSuiteUT::TestOpenLongStepNameL()
       
    58 	{
       
    59 	RTestSession session;
       
    60 	ASSERT_TRUE(OpenSession(session,_L("te_RegStepTestSuite"))==0);
       
    61 	CleanupClosePushL(session);
       
    62 	session.Close();
       
    63 	CleanupStack::Pop();	
       
    64 	}
       
    65 void CTEFClientSuiteUT::TestRunLongTestBlockCommandL()
       
    66 	{
       
    67 	
       
    68 	RTestSession session;	
       
    69 	TRequestStatus status;
       
    70 	TExitCategoryName panicString;
       
    71 	TBuf<10> blockArray(_L("BlockArray"));
       
    72 	ASSERT_TRUE(OpenSession(session,_L("te_RegStepTestSuite"))==0);
       
    73 	CleanupClosePushL(session);
       
    74 	HBufC8* buffer = HBufC8::NewLC(256);
       
    75 	TPtr8 block (buffer->Des());
       
    76 	block.Zero();
       
    77 	session.RunTestBlock(_L("123456789012345678901234567890123456789012345678901234567890123456789\
       
    78 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\
       
    79 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890")
       
    80 						,panicString
       
    81 						,block
       
    82 						,status
       
    83 						);
       
    84 	/*	RunTestBlock() should not send the long command to server
       
    85 	 *	if(aCommandString.Length() > KMaxTestExecuteCommandLength)
       
    86 		{
       
    87 		TRequestStatus* status = &aStatus;
       
    88 		User::RequestComplete(status,KErrTooBig);
       
    89 		return;
       
    90 		}
       
    91 		SendReceive(....,aStatus);		
       
    92 	 * 	In current we don't want change TEF beheivour, so we just let 
       
    93 	 * server send command out.
       
    94 	 * Because aStatus has be over wirted, KErrTooBig can't be return.
       
    95 	 * the ASSERT_TRUE can't be execute.
       
    96 	 */
       
    97 //	ASSERT_TRUE(status.Int() == KErrTooBig);
       
    98 	session.AbortTestStep();
       
    99 	session.Close();
       
   100 	CleanupStack::PopAndDestroy(buffer);
       
   101 	CleanupStack::Pop();
       
   102 	}
       
   103 
       
   104 void CTEFClientSuiteUT::TestRunLongTestStepCommandL()
       
   105 	{	
       
   106 	RTestSession session;
       
   107 	ASSERT_TRUE(OpenSession(session,_L("te_RegStepTestSuite"))==0);
       
   108 	CleanupClosePushL(session);
       
   109 	TRequestStatus status;
       
   110 	TExitCategoryName panicString;
       
   111 	session.RunTestStep(_L("12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890")
       
   112 						,panicString,status);
       
   113 	/*	RunTestBlock() should not send the long command to server
       
   114 	 *	if(aCommandString.Length() > KMaxTestExecuteCommandLength)
       
   115 		{
       
   116 		TRequestStatus* status = &aStatus;
       
   117 		User::RequestComplete(status,KErrTooBig);
       
   118 		return;
       
   119 		}
       
   120 		SendReceive(....,aStatus);		
       
   121 	 * 	In current we don't want change TEF beheivour, so we just let 
       
   122 	 * server send command out.
       
   123 	 * Because aStatus has be over wirted, KErrTooBig can't be return.
       
   124 	 * the ASSERT_TRUE can't be execute.
       
   125 	 */
       
   126 //	ASSERT_TRUE(status.Int() == KErrTooBig);
       
   127 	session.AbortTestStep();
       
   128 	session.Close();
       
   129 	CleanupStack::Pop();
       
   130 	}
       
   131 
       
   132 void CTEFClientSuiteUT::TestRunTestStepL()
       
   133 	{
       
   134 	RTestSession session;
       
   135 	ASSERT_TRUE(OpenSession(session,_L("te_RegStepTestSuite"))==0);
       
   136 	CleanupClosePushL(session);
       
   137 	TRequestStatus status;
       
   138 	TExitCategoryName panicString;
       
   139 	session.RunTestStep(_L("OOM=0 !Setup=0 -1 DT-TEF-TestStep-0001 c: C: C: c:\\testdata\\configs\\readwriteconfig.ini Section7"),panicString,status);
       
   140 	User::WaitForRequest(status);
       
   141 	panicString.Zero();
       
   142 	session.RunTestStep(_L("OOM=0 !Setup=0 -1 DT-TEF-TestStep-0001 c: C: C: c:\\testdata\\configs\\readwriteconfig.ini Section7"),panicString,status);
       
   143 	session.AbortTestStep();
       
   144 	session.Close();
       
   145 	CleanupStack::Pop();
       
   146 	}
       
   147 
       
   148 void CTEFClientSuiteUT::TestLongServerName()
       
   149 	{
       
   150 	TInt err;
       
   151 	err = iServer.Connect(_L("SYMScriptAuthorSYMScriptAuthorSYMScriptAuthorSYMScriptAuthorSYMScriptAuthorSYMScriptAuthorSYMScriptAuthorSYMScriptAuthorSYMScriptAuthorSYMScriptAuthorSYMScriptAuthorSYMScriptAuthorSYMScriptAuthorSYMScriptAuthorSYMScriptAuthorSYMScriptAuthorSYMScriptAutho"));	
       
   152 	INFO_PRINTF2( _L("Server Connect returns = %d"), err );	
       
   153 	ASSERT_TRUE( (KErrTooBig == err) );
       
   154 	}
       
   155 
       
   156 CTestSuite* CTEFClientSuiteUT::CreateSuiteL( const TDesC& aName )
       
   157 /**
       
   158  * CreateSuiteL
       
   159  *
       
   160  * @param aName - Suite name
       
   161  * @return - Suite
       
   162  */
       
   163 	{
       
   164 	SUB_SUITE;
       
   165 	ADD_TEST_STEP_CLASS( CTEFClientSuiteUT,TestRunTestStepL );
       
   166 	ADD_TEST_STEP_CLASS( CTEFClientSuiteUT,TestOpenLongStepNameL);
       
   167 	ADD_TEST_STEP_CLASS( CTEFClientSuiteUT,TestRunLongTestBlockCommandL);
       
   168 	ADD_TEST_STEP_CLASS( CTEFClientSuiteUT,TestRunLongTestStepCommandL);
       
   169 	ADD_TEST_STEP_CLASS( CTEFClientSuiteUT,TestLongServerName);
       
   170 	END_SUITE;
       
   171 	}