messagingfw/msgtestfw/TestActions/Pigeon/src/CMtfTestActionLaunchSchSendExe.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     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 // CMtfTestActionLaunchSchSendExe.h
       
    15 // __ACTION_INFO_BEGIN__ 
       
    16 // [Action Name]
       
    17 // LaunchSchSendExe
       
    18 // [Action Parameters]
       
    19 // None
       
    20 // [Action Description]
       
    21 // Launches SchSendExe.exe passing SMTP Service Id as parameter.
       
    22 // LaunchSchSendExe Test Action is intended to verify that the SchSendExe.exe cant be launched by
       
    23 // any other process, other than Task Scheduler.
       
    24 // To verify this conditon, the test action launches the SchSendExe.exe and compares the process 
       
    25 // completion result with the expected result.
       
    26 // If the ScheduleSend is secured, then the expected result is KErrPermissionDenied, otherwise 
       
    27 // KErrNone. 
       
    28 // If the ScheduleSend process completion result is not equal to the expected result, 
       
    29 // the Test Action is failed.
       
    30 // [APIs Used]
       
    31 // RProcess::Create
       
    32 // RProcess::Resume
       
    33 // RProcess::Close
       
    34 // __ACTION_INFO_END__
       
    35 // 
       
    36 //
       
    37 
       
    38 // System includes
       
    39 #include <msvstd.h>
       
    40 #include <e32std.h>
       
    41 #include <imcmutil.h>
       
    42 #include <e32cmn.h>
       
    43 
       
    44 // User includes
       
    45 #include "CMtfTestActionLaunchSchSendExe.h"
       
    46 #include "CMtfTestCase.h"
       
    47 #include "CMtfTestActionParameters.h"
       
    48 
       
    49 
       
    50 // Path of the SchSendExe.exe
       
    51 _LIT(KMsvSchSendExe, "Z:\\system\\PROGRAMS\\schsendexe.exe");
       
    52 
       
    53 // UID of LaunchSchSendExe.exe
       
    54 const TUid KMsvSchSendExeUid = {0x100056A1}; 
       
    55 
       
    56 /**
       
    57   Function : NewL
       
    58   Description				:Creates a new CMtfTestActionLaunchSchSendExe object
       
    59   @internalTechnology
       
    60   @param : aTestCase 		:Reference to the Test case
       
    61   @param : aActionParams 	:Test Action parameters 
       
    62   @return : CMtfTestAction* :a base class pointer to the newly created object
       
    63   @pre none
       
    64   @post none
       
    65 */
       
    66 CMtfTestAction* CMtfTestActionLaunchSchSendExe::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    67 	{
       
    68 	CMtfTestActionLaunchSchSendExe* self = new (ELeave) CMtfTestActionLaunchSchSendExe(aTestCase);
       
    69 	CleanupStack::PushL(self);
       
    70 	self->ConstructL(aActionParameters);
       
    71 	CleanupStack::Pop(self);
       
    72 	return self;
       
    73 	}
       
    74 
       
    75 
       
    76 /**
       
    77   Function : CMtfTestActionLaunchSchSendExe
       
    78   Description : Constructor
       
    79   @internalTechnology
       
    80   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    81   @pre none
       
    82   @post none
       
    83 */
       
    84 CMtfTestActionLaunchSchSendExe::CMtfTestActionLaunchSchSendExe(CMtfTestCase& aTestCase)
       
    85 	: CMtfSynchronousTestAction(aTestCase)
       
    86 	{
       
    87 	}
       
    88 
       
    89 
       
    90 /**
       
    91   Function : ~CMtfTestActionLaunchSchSendExe
       
    92   Description : Destructor
       
    93   @internalTechnology
       
    94 */
       
    95 CMtfTestActionLaunchSchSendExe::~CMtfTestActionLaunchSchSendExe()
       
    96 	{
       
    97 	}
       
    98 
       
    99 
       
   100 /**
       
   101   Function : ExecuteActionL
       
   102   Description		: Launches the schsendexe.exe and verifies the result of process 
       
   103 					  completion with that of the expected result.
       
   104   @internalTechnology
       
   105   @param			: none
       
   106   @return			: void
       
   107   @pre	 
       
   108   @post	: none
       
   109 */
       
   110 void CMtfTestActionLaunchSchSendExe::ExecuteActionL()
       
   111 	{
       
   112 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionLaunchSchSendExe);
       
   113 	// Expected result
       
   114 	TInt expectedResult  = KErrPermissionDenied;
       
   115 	
       
   116 	TBuf<20> cmdString;
       
   117 	
       
   118 	// Return KErrNotSupported in case of Wins
       
   119 	TInt returnValue = KErrNotSupported;
       
   120 	
       
   121 	TRequestStatus status = KRequestPending;
       
   122 
       
   123 	RProcess process;					
       
   124 	User::LeaveIfError(process.Create(KMsvSchSendExe, cmdString, TUidType(KNullUid, KNullUid, KMsvSchSendExeUid)));
       
   125 	TestCase().INFO_PRINTF2(_L("RProcess::Create() is successful %S "), &KTestActionLaunchSchSendExe);
       
   126 
       
   127 	// Make the process eligible for execution
       
   128 	process.Logon(status);
       
   129 	process.Resume();
       
   130 
       
   131 	// Wait for the process completion
       
   132 	User::WaitForRequest(status);
       
   133 				
       
   134 	// Check the exit reason of the process.If Panic occurs the return value is set to KErrGeneral as the 
       
   135 	// focus of test action is to check if KErrPermissionDenied is returned.
       
   136 	returnValue = (process.ExitType() == EExitPanic)? KErrGeneral: status.Int();
       
   137 
       
   138 	process.Close();
       
   139 
       
   140 	TestCase().INFO_PRINTF4(_L("Test Action %S completed with %d, while expected %d "), &KTestActionLaunchSchSendExe,returnValue, expectedResult );
       
   141 	
       
   142 	if(returnValue != expectedResult )
       
   143 		{
       
   144 		TestCase().SetTestStepResult(EFail);
       
   145 		}
       
   146 		
       
   147 	TestCase().ActionCompletedL(*this);
       
   148 	}