commonuisupport/uikon/test/tmessageserv/messageactive.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 2005-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 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalComponent - Internal Symbian test code 
       
    19 */
       
    20 
       
    21 #include "messageactive.h"
       
    22 
       
    23 const TInt STOP_SERVER_CODE	= 0xff;
       
    24 
       
    25 CMessageActive::CMessageActive() 
       
    26 	: CActive(EPriorityLow)
       
    27 	{
       
    28 	}
       
    29 	
       
    30 EXPORT_C CMessageActive::~CMessageActive()
       
    31 	{
       
    32 	}
       
    33 
       
    34 /**
       
    35    Auxiliary function for TestCaseID TPACKAGESTARTER-doTestStepL
       
    36   
       
    37    This method creates an active object of class CMessageActive and adds it to
       
    38    the active scheduler.
       
    39   
       
    40  */
       
    41 EXPORT_C CMessageActive* CMessageActive::NewL()
       
    42 	{
       
    43 	CMessageActive*	theMessage = new CMessageActive;
       
    44     CActiveScheduler::Add(theMessage);
       
    45 	
       
    46 	RThread	thread;
       
    47 	theMessage->iID = thread.Id();
       
    48 	return theMessage;
       
    49 	}
       
    50 	
       
    51 /**
       
    52    Auxiliary function for TestCaseID TPACKAGESTARTER-doTestStepL
       
    53   
       
    54    This method is an override from CActive.It handles the client message request
       
    55    completion event. On completion of copying message from client to the server
       
    56    this method logs the information gathered from the message.
       
    57   
       
    58  */
       
    59 void CMessageActive::RunL()
       
    60 	{
       
    61 	if(iStatus.Int() == KErrNone)
       
    62 		{
       
    63 		CTestExecuteLogger& logger = iStep->Logger();
       
    64 		logger.LogExtra(((TText8*)(iFileName.PtrZ())), iLineNumber, ESevrInfo, iMsg);
       
    65 		}
       
    66 	else if(iStatus.Int() == STOP_SERVER_CODE)
       
    67 		{
       
    68 		CActiveScheduler::Stop();
       
    69 		}
       
    70 	else
       
    71 		{
       
    72 		CTestExecuteLogger& logger = iStep->Logger();
       
    73 		iStep->testBooleanTrueWithErrorCode(0, iError, ((TText8*)(iFileName.PtrZ())), iLineNumber );
       
    74 		if(iError != 0)
       
    75 			{
       
    76 			logger.LogExtra(((TText8*)(iFileName.PtrZ())), iLineNumber, ESevrErr, iMsg, iError);
       
    77 			}
       
    78 		else
       
    79 			{
       
    80 			logger.LogExtra(((TText8*)(iFileName.PtrZ())), iLineNumber, ESevrErr, iMsg);
       
    81 			}
       
    82 		}
       
    83 	}
       
    84 
       
    85 /**
       
    86    Auxiliary function for TestCaseID TPACKAGESTARTER-doTestStepL
       
    87   
       
    88    This method sets the request status to be complete and sets the request to be
       
    89    outstanding so that the active scheduler invokes the RunL() method of the
       
    90    active object CMessageActive.
       
    91   
       
    92  */
       
    93 void CMessageActive::Init()
       
    94 	{
       
    95 	TRequestStatus *pS=(&iStatus);
       
    96 	User::RequestComplete(pS,0);
       
    97 	*pS=KRequestPending;
       
    98 	SetActive();
       
    99 	}
       
   100 /**
       
   101   Auxiliary function for TestCaseID TPACKAGESTARTER-doTestStepL
       
   102   
       
   103   This method is an override from CActive. It is used for cancellation of an
       
   104   outstanding request.
       
   105   
       
   106  */
       
   107 void CMessageActive::DoCancel()
       
   108 	{
       
   109 	}
       
   110 /**
       
   111    Auxiliary function for TestCaseID TPACKAGESTARTER-doTestStepL
       
   112   
       
   113    This method is used to activate CMessageActive class to output the message
       
   114    to logs.
       
   115   
       
   116  */
       
   117 void CMessageActive::RequestForTheMessageOutput(TInt aCode)
       
   118 {
       
   119 	RThread	thread;
       
   120 	TRequestStatus *pS=(&iStatus);
       
   121 
       
   122 	*pS=KRequestPending;
       
   123 	SetActive();
       
   124 
       
   125 	thread.Open(iID);
       
   126 	thread.RequestComplete(pS, aCode);
       
   127 }