messagingfw/msgtestfw/TestActions/Email/Imap4/src/CMtfTestActionImap4Connected.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 2003-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 // CheckConnected
       
    17 // [Action Parameters]
       
    18 // EmailMtmUid <input>:  Value of any IMAP4 MTM uid.
       
    19 // State       <input>:  The state to test (0 = not connected, 1 = connected)
       
    20 // [Action Description]
       
    21 // Checks whether the MTM is connected or not connected to an external server
       
    22 // [APIs Used]
       
    23 // none.
       
    24 // __ACTION_INFO_END__
       
    25 // 
       
    26 //
       
    27 
       
    28 /**
       
    29  @file
       
    30 */
       
    31 
       
    32 #include "CMtfTestActionImap4Connected.h"
       
    33 //#include "CMtfTestCase.h"
       
    34 //#include "CMtfTestActionParameters.h"
       
    35 
       
    36 #include "CMtfTestCase.h"
       
    37 #include "CMtfTestActionParameters.h"
       
    38 #include "MtfTestActionUtilsUser.h"
       
    39 
       
    40 //#include <miutset.h>
       
    41 #include <impcmtm.h>
       
    42 
       
    43 
       
    44 CMtfTestAction* CMtfTestActionImap4Connected::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    45 	{
       
    46 	CMtfTestActionImap4Connected* self = new (ELeave) CMtfTestActionImap4Connected(aTestCase);
       
    47 	CleanupStack::PushL(self);
       
    48 	self->ConstructL(aActionParameters);
       
    49 	CleanupStack::Pop();
       
    50 	return self;
       
    51 	}
       
    52 	
       
    53 
       
    54 CMtfTestActionImap4Connected::CMtfTestActionImap4Connected(CMtfTestCase& aTestCase)
       
    55 	: CMtfTestAction(aTestCase)
       
    56 	{
       
    57 	}
       
    58 
       
    59 
       
    60 CMtfTestActionImap4Connected::~CMtfTestActionImap4Connected()
       
    61 	{
       
    62 	}
       
    63 
       
    64 
       
    65 void CMtfTestActionImap4Connected::ExecuteActionL()
       
    66 	{
       
    67 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionImap4Connected);
       
    68 	TMsvId paramServiceId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(0));
       
    69 
       
    70 	// First parameter is the MTM
       
    71 	CImap4ClientMtm* pMtm = ObtainParameterReferenceL<CImap4ClientMtm>(TestCase(),ActionParameters().Parameter(1));
       
    72 
       
    73 	// Second parameter is the boolean state
       
    74 	TBool connected = ObtainValueParameterL<TBool>(TestCase(),ActionParameters().Parameter(2));
       
    75 	TInt  expected = KErrNone;
       
    76 	if(connected == 0)
       
    77 		expected = KErrDisconnected;
       
    78 
       
    79 	// Get the state of the MTM
       
    80 	CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
       
    81 	CleanupStack::PushL(selection);
       
    82 	selection->AppendL(paramServiceId);
       
    83 	TBuf8<16> param;
       
    84 	pMtm->InvokeSyncFunctionL(KIMAP4MTMIsConnected, *selection, param);
       
    85 	CleanupStack::PopAndDestroy();	// selection
       
    86 	TInt err = param[0];
       
    87 	
       
    88 	if((err != KErrNone && connected != 0 ) || (err == KErrNone && connected == 0 ))
       
    89 		{
       
    90 		TestCase().ERR_PRINTF3( _L("CMtfTestActionImap4Connected err(%d) != expected(%d)"), err, expected );
       
    91 		TestCase().SetTestStepResult(EFail);
       
    92 		}
       
    93 
       
    94 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionImap4Connected);
       
    95 	TestCase().ActionCompletedL(*this);
       
    96 	}
       
    97 
       
    98 
       
    99 void CMtfTestActionImap4Connected::DoCancel()
       
   100 	{
       
   101 	// No longer asynchronous
       
   102 	}
       
   103 
       
   104 
       
   105 void CMtfTestActionImap4Connected::RunL()
       
   106 	{
       
   107 	// No longer asynchronous
       
   108 	}