phoneclientserver/phoneclient/tsrc/public/basic/ut_ussd/ut_testenv.h
changeset 15 d7fc66ccd6fb
child 27 7eb70891911c
equal deleted inserted replaced
13:e32024264ebb 15:d7fc66ccd6fb
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // include files
       
    20 #include <e32cmn.h>
       
    21 #include <e32base.h>
       
    22 #include <f32file.h>
       
    23 #include "mphsrvphoneinterface.h" // base class
       
    24 
       
    25 // forward declarations
       
    26 class RTelServer;
       
    27 class RMobilePhone;
       
    28 class RMmCustomAPI;
       
    29 class CPhSrvResourceManager;
       
    30 class CPhSrvUssdManager;
       
    31 
       
    32 /**
       
    33  * Mode for current test execution
       
    34  */
       
    35 class TestMode
       
    36 {
       
    37 public:
       
    38 	enum {Immediate=50};
       
    39 	enum Event{Normal,NoResp,NetworkRelease};
       
    40 
       
    41 	TestMode(Event event,int error=KErrNone,int timeout=Immediate)
       
    42 		{m_event=event;m_error=error;m_timeout=timeout;}
       
    43 	TestMode(int error,int timeout=Immediate)
       
    44 		{m_event=Normal;m_error=error;m_timeout=timeout;}
       
    45 	TestMode()
       
    46 		{m_event=Normal;m_error=KErrNone;m_timeout=Immediate;}
       
    47 	Event m_event;
       
    48 	int m_error;
       
    49 	int m_timeout;
       
    50 };
       
    51 
       
    52 /**
       
    53  * ETEL message loop
       
    54  */
       
    55 class EtelMsgLoop
       
    56 {
       
    57 public:
       
    58 	EtelMsgLoop();
       
    59 
       
    60 	// methods
       
    61 	void receive( const TDesC8& msg, const TDesC8& attr );
       
    62 	void networkRelease( const TDesC8& msg, const TDesC8& attr );
       
    63 
       
    64 	//data
       
    65 	TRequestStatus* mSendMessageReqStatus;
       
    66 
       
    67 	TRequestStatus* mReceiveMessageReqStatus;
       
    68 	TDes8* mReceiveMessageData;
       
    69 	TDes8* mReceiveMessageAttributes;
       
    70 
       
    71 	TRequestStatus* mNetworkReleaseReqStatus;
       
    72 	TDes8* mNetworkReleaseMessageData;
       
    73 	TDes8* mNetworkReleaseMessageAttributes;
       
    74 
       
    75 };
       
    76 
       
    77 
       
    78 
       
    79 /**
       
    80  * test environment
       
    81  */
       
    82 class TestEnv: public MPhSrvPhoneInterface
       
    83 {
       
    84 	public:
       
    85 
       
    86 		static void create();
       
    87 		static void destroy();
       
    88 		static TestEnv& env(); // the singleton
       
    89 
       
    90 		TestEnv();
       
    91 		void construct();
       
    92 		~TestEnv();
       
    93 
       
    94 		CPhSrvUssdManager& ussdManager() {return *m_ussdManager;}
       
    95 
       
    96 		void setTestMode(const TestMode& testMode) {m_testMode = testMode;}
       
    97 		const TestMode& testMode() {return m_testMode;}
       
    98 
       
    99 		EtelMsgLoop& etelMsgLoop() {return m_etelMsgLoop;}
       
   100 		
       
   101 		RMessage2& fakeMessage() {return *m_fakeMessage;}
       
   102 		
       
   103 	protected: // stubbed MPhSrvPhoneInterface
       
   104 
       
   105 		RTelServer& PhSrvETelServer();
       
   106 		RMobilePhone& PhSrvMobilePhone();
       
   107 		RMmCustomAPI& PhSrvCustomPhone();
       
   108 
       
   109 	private:
       
   110 		
       
   111 		// file manager. Never actually connected to
       
   112 		RFs m_fs;
       
   113 
       
   114 		// resource manager mock
       
   115 		CPhSrvResourceManager* m_resourceManager;
       
   116 
       
   117 		// ussd manager (server main ussd class)
       
   118 		CPhSrvUssdManager* m_ussdManager;
       
   119 
       
   120 		// test mode
       
   121 		TestMode m_testMode;
       
   122 
       
   123 		// etel msg loop
       
   124 		EtelMsgLoop m_etelMsgLoop;
       
   125 		
       
   126 		// temp message
       
   127 		RMessage2* m_fakeMessage;
       
   128 
       
   129 	    static TestEnv* m_singleton;
       
   130 
       
   131 };
       
   132 
       
   133 
       
   134 
       
   135 
       
   136