imagingtestenv/imagingtestfw/Source/TestFrameworkServer/ServerConsole.h
changeset 0 5752a19fdefe
equal deleted inserted replaced
-1:000000000000 0:5752a19fdefe
       
     1 // Copyright (c) 2002-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 #ifndef __SERVERCONSOLE_H__
       
    17 #define __SERVERCONSOLE_H__
       
    18 
       
    19 #include <e32std.h>
       
    20 #include <e32base.h>
       
    21 #include <e32cons.h>
       
    22 
       
    23 #include <testframework.h>
       
    24 
       
    25 /**
       
    26  *
       
    27  * Console reader mixin class.
       
    28  * Any main program or class using a CServerConsole
       
    29  * should implement this class.
       
    30  *
       
    31  * @xxxx
       
    32  *
       
    33  */
       
    34 class MConsoleReader
       
    35 	{
       
    36 public:
       
    37 /**
       
    38  *
       
    39  * Processes a received keystroke.
       
    40  *
       
    41  * @param	"TKeyCode aKeystroke"
       
    42  *			The received keystroke.
       
    43  *
       
    44  * @xxxx 
       
    45  *
       
    46  */
       
    47 	virtual void InputReceived(TKeyCode aKeystroke) = 0;
       
    48 /**
       
    49  *
       
    50  * Handles console reader errors.
       
    51  *
       
    52  * @param	"TInt aError"
       
    53  *			The error code.
       
    54  *
       
    55  * @xxxx 
       
    56  *
       
    57  */
       
    58 	virtual void Error(TInt aError) = 0;
       
    59 	};
       
    60 
       
    61 /**
       
    62  *
       
    63  * Keystroke reader for CServerConsole.
       
    64  *
       
    65  *
       
    66  * @xxxx
       
    67  *
       
    68  */
       
    69 class CConsoleReader : public CActive
       
    70 	{
       
    71 public:
       
    72 	static CConsoleReader* NewL(CConsoleBase& aConsole);
       
    73 	~CConsoleReader();
       
    74 	void DoRead(MConsoleReader& aClient);
       
    75 	void DoRead();//keeping same client as before
       
    76 	void RunL();
       
    77 
       
    78 protected:
       
    79 	void DoCancel();
       
    80 
       
    81 private:
       
    82 	CConsoleReader(CConsoleBase& aConsole);
       
    83 
       
    84 private:
       
    85 	MConsoleReader* iClient;
       
    86 	CConsoleBase& iConsole;
       
    87 	TKeyCode iKeyStroke;
       
    88 	};
       
    89 
       
    90 /**
       
    91  *
       
    92  * Active console for test input.
       
    93  * To be used where manual control of testing is required
       
    94  *
       
    95  * @xxxx
       
    96  *
       
    97  */
       
    98 class CServerConsole : public CActive
       
    99 	{
       
   100 public:
       
   101 	static CServerConsole* NewL(const TDesC& aName);
       
   102 	~CServerConsole();
       
   103 
       
   104 	void SetInstructionsL(const TDesC& aInstructions);
       
   105 	void Read(MConsoleReader& aReader);
       
   106 	void ReadCancel();
       
   107 
       
   108 	void RunL();
       
   109 	void DoCancel();
       
   110 	TInt RunError(TInt aError);
       
   111 
       
   112 	// accessor
       
   113 	CConsoleBase* Console() const;
       
   114 
       
   115 private:
       
   116 	CServerConsole();
       
   117 	void ConstructL(const TDesC& aName);
       
   118 
       
   119 private:
       
   120 	CConsoleBase* iConsole;
       
   121 	TRectBuf iWindow;
       
   122 	HBufC* iWindowName;
       
   123 	HBufC* iInstructions;
       
   124 	CConsoleReader* iConsoleReader;
       
   125 	};
       
   126 
       
   127 #endif // __SERVERCONSOLE_H__