messagingfw/msgtestfw/TestActions/SendAs/src/CMtfTestActionConnectSendAsServer.cpp
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // __ACTION_INFO_BEGIN__ 
       
    15 // [Action Name]
       
    16 // ConnectSendAsServer
       
    17 // [Action Parameters]
       
    18 // messageSlots  TInt		<input>	: Number of message slots
       
    19 // rSendAs		 RSendAs	<output>: Created RSendAs object
       
    20 // [Action Description]
       
    21 // Establishes a connection with SendAs server
       
    22 // [APIs Used]
       
    23 // RSendAs::Connect
       
    24 // __ACTION_INFO_END__
       
    25 // 
       
    26 //
       
    27 
       
    28 /**
       
    29  @file
       
    30 */
       
    31 
       
    32 //user include 
       
    33 #include "CMtfTestActionConnectSendAsServer.h"
       
    34 #include "CMtfTestCase.h"
       
    35 #include "CMtfTestActionParameters.h"
       
    36 
       
    37 /**
       
    38   NewL()
       
    39   Constructs a CMtfTestActionConnectSendAsServer object.
       
    40   Uses two phase construction
       
    41   @internalTechnology
       
    42   @param	aTestCase			Test Case to which this Test Action belongs
       
    43   @param	aActionParameters	Test Action parameters, must not be NULL
       
    44   @return	Created object of type CMtfTestActionConnectSendAsServer 
       
    45   @pre		None
       
    46   @post		CMtfTestActionConnectSendAsServer object is created
       
    47 */
       
    48 CMtfTestAction* CMtfTestActionConnectSendAsServer::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    49 	{
       
    50 	CMtfTestActionConnectSendAsServer* self = new (ELeave) CMtfTestActionConnectSendAsServer(aTestCase);
       
    51 	CleanupStack::PushL(self);
       
    52 	self->ConstructL(aActionParameters);
       
    53 	CleanupStack::Pop();
       
    54 	return self;
       
    55 	}
       
    56 	
       
    57 /**
       
    58   CMtfTestActionConnectSendAsServer constructor
       
    59   Calls the base class' constructor
       
    60   @internalTechnology  
       
    61   @param  aTestCase  Test Case to which this Test Action belongs
       
    62   @pre    None
       
    63   @post   None
       
    64 */ 
       
    65 CMtfTestActionConnectSendAsServer::CMtfTestActionConnectSendAsServer(CMtfTestCase& aTestCase)
       
    66 	: CMtfSynchronousTestAction(aTestCase)
       
    67 	{
       
    68 	}
       
    69 
       
    70 /**
       
    71   Destructor
       
    72 */
       
    73 CMtfTestActionConnectSendAsServer::~CMtfTestActionConnectSendAsServer()
       
    74 	{
       
    75 	}
       
    76 
       
    77 
       
    78 /**
       
    79   ExecuteActionL
       
    80   Creates an RSendAs object and establishes a connection with SendAs server
       
    81   @internalTechnology 
       
    82   @pre    None
       
    83   @post   None
       
    84   @leave  System wide errors
       
    85 */
       
    86 void CMtfTestActionConnectSendAsServer::ExecuteActionL()
       
    87 	{
       
    88 	if((TestCase().TestStepResult()) == EPass)
       
    89 		{
       
    90 		TestCase().INFO_PRINTF2(_L("Test Action %S Start..."), &KTestActionConnectSendAsServer);
       
    91 		
       
    92 		// Get the number of message slots to be supported
       
    93 		TInt messageSlots = ObtainValueParameterL<TInt> (TestCase(),
       
    94 									ActionParameters().Parameter(0));
       
    95 		
       
    96 		// Create an RSendAs object and establish connection with SendAs server
       
    97 		RSendAs rSendAs;
       
    98 		TInt err = rSendAs.Connect(messageSlots);
       
    99 
       
   100 		// Fail the Test Case if the connection is not established
       
   101 		if (err != KErrNone)
       
   102 			{
       
   103 			TestCase().ERR_PRINTF2(_L("Connection with the SendAs server is failed with error %d "), err);
       
   104 			TestCase().SetTestStepResult(EFail);
       
   105 			}
       
   106 		else
       
   107 			{
       
   108 			// Connection successful, Provide the RSendAs object as an output of the Test Action
       
   109 			StoreParameterL<RSendAs>(TestCase(),rSendAs,ActionParameters().Parameter(1));
       
   110 			}
       
   111 		}
       
   112 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionConnectSendAsServer);
       
   113 	TestCase().ActionCompletedL(*this);
       
   114 	}