imagingtestenv/imagingtestfw/Source/TestFrameworkServer/TestFrameworkServer.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 // TestFrameworkServer provides a console and/or log
       
    15 // which will handle all output from test threads.
       
    16 // 
       
    17 //
       
    18 
       
    19 #ifndef __TESTFRAMEWORKSERVER_H__
       
    20 #define __TESTFRAMEWORKSERVER_H__
       
    21 
       
    22 #include <testframework.h>
       
    23 #include "LogFile.h"
       
    24 #include "ServerConsole.h"
       
    25 
       
    26 #include <mmf/common/mmfipc.h> // for MmfIpc classes
       
    27 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    28 #include <mmf/common/mmfipcserver.h>
       
    29 #endif
       
    30 
       
    31 class CTestFrameworkServerSession;
       
    32 
       
    33 /**
       
    34  *
       
    35  * A timer used to shut the server down after all clients 
       
    36  * have exited.
       
    37  *
       
    38  * @xxxx
       
    39  *
       
    40  */
       
    41 class CTestFrameworkServerShutdown : public CTimer
       
    42 	{
       
    43 	enum
       
    44 		{
       
    45 		KTestFrameworkServerShutdownDelay = 5000000 // 5 seconds
       
    46 		};	
       
    47 public:
       
    48 	CTestFrameworkServerShutdown();
       
    49 	void ConstructL();
       
    50 	void Start();
       
    51 private:
       
    52 	void RunL();
       
    53 	};
       
    54 
       
    55 /**
       
    56  *
       
    57  * Window helper class, allows client and server to set/
       
    58  * modify (console) windows
       
    59  *
       
    60  * @xxxx
       
    61  *
       
    62  */
       
    63 class TWindow
       
    64 	{
       
    65 public:
       
    66 	TWindow();
       
    67 	TWindow(CTestFrameworkServerSession* aOwner);
       
    68 	void SetOwner(CTestFrameworkServerSession* aOwner);
       
    69 	void SetWinRectAndNotifyOwner(const TRect& aWinRect);
       
    70 	CTestFrameworkServerSession* Owner() {return iOwner;};
       
    71 	TBool HasOwner();
       
    72 private:
       
    73 	CTestFrameworkServerSession* iOwner;
       
    74 	};
       
    75 
       
    76 /**
       
    77  *
       
    78  * Test Framework Server.
       
    79  * Responsible for opening/closing console and writing to it.
       
    80  * Ditto log file.
       
    81  *
       
    82  * To be adapted to write to a COM port.
       
    83  *
       
    84  * @xxxx
       
    85  *
       
    86  */
       
    87 class CTestFrameworkServer : public CMmfIpcServer, public MConsoleReader
       
    88 	{
       
    89 public:
       
    90 	//construct / destruct
       
    91 	static CMmfIpcServer* NewL();
       
    92 	~CTestFrameworkServer();
       
    93 
       
    94 	void AddSession();
       
    95 	void DropSession();
       
    96 
       
    97 	void OpenLogL(const TDesC& aLogName, TInt aLogMode);
       
    98 	void WriteLog(const TDesC& aMsg, TInt aLogMode);
       
    99 	void CloseLog();
       
   100 	TInt LogStatus() const;
       
   101 
       
   102 	void AddInputWindowL(CTestFrameworkServerSession* aOwner);
       
   103 	void RemoveWindow(CTestFrameworkServerSession* aOwner);
       
   104 
       
   105 	//from MConsoleReader
       
   106 	void InputReceived(TKeyCode aKeystroke);
       
   107 	void Error(TInt aError);
       
   108 
       
   109 private:
       
   110 	CTestFrameworkServer();
       
   111 	void ConstructL();
       
   112 	//open/close a session
       
   113 	CMmfIpcSession* NewSessionL(const TVersion &aVersion) const;
       
   114 
       
   115 private:
       
   116 	TInt iSessionCount;	// The number of sessions
       
   117 	CTestFrameworkServerShutdown iShutdown;// A timer used to shut the server down after all clients have exited.
       
   118 
       
   119 	// An active console, receiving output from client messages and input from server
       
   120 	CServerConsole* iConsole;
       
   121 
       
   122 	// logging parms
       
   123 	TUint iLogMode;
       
   124 	TBuf<KMaxLogFilenameLength> iLogName;
       
   125 	CFileLogger* iFileLogger;
       
   126 
       
   127 	// last keypress
       
   128 	TInt iInputKey;
       
   129 
       
   130 	TWindow iInputWindow;
       
   131 	};
       
   132 
       
   133 /**
       
   134  *
       
   135  * Test Framework Server Session :
       
   136  * handles message passing between Test Framework client / server
       
   137  *
       
   138  * @xxxx
       
   139  *
       
   140  */
       
   141 class CTestFrameworkServerSession : public CMmfIpcSession
       
   142 	{
       
   143 public:
       
   144 	CTestFrameworkServerSession();
       
   145 	void CreateL(const CMmfIpcServer& aServer);
       
   146 	void ConstructL();
       
   147 	~CTestFrameworkServerSession();
       
   148 
       
   149 	void ServiceL(const RMmfIpcMessage &aMessage);
       
   150 	TInt RunError(const RMmfIpcMessage& aMessage, TInt aError);
       
   151 
       
   152 	void NotifyWindowChanged(const TRect& aWinRect);
       
   153 
       
   154 private:
       
   155 	// async window message handling
       
   156 	void SetOwnCopyOfWindowMessageL(const RMmfIpcMessage& aMessage);
       
   157 	void CompleteOwnCopyOfWindowMessage(TInt aReason);
       
   158 
       
   159 private:
       
   160 	CTestFrameworkServer* iServer;	//<pointer to owning server
       
   161 
       
   162 	// async window message data
       
   163 	RMmfIpcMessage iWindowMessage;
       
   164 	TBool iCanCompleteWindowMessage;
       
   165 	TBool iNeedToNotifyClientOfWindowSizeChange;
       
   166 	TRectBuf iWinRectBuf;
       
   167 	};
       
   168 
       
   169 
       
   170 
       
   171 #endif //__TESTFRAMEWORKSERVER_H__