servicediscoveryandcontrol/pnp/test/integtest/inc/testpnpmanager.h
changeset 0 f5a58ecadc66
equal deleted inserted replaced
-1:000000000000 0:f5a58ecadc66
       
     1 // Copyright (c) 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 // Contains declaration of CTestPnPManager, CTestPnPObserver 
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef __TEST_PNP_MANAGER_H__
       
    19 #define __TEST_PNP_MANAGER_H__
       
    20 
       
    21 // System Includes
       
    22 #include <testexecutestepbase.h>
       
    23 #include <e32base.h>
       
    24 #include <e32cmn.h>
       
    25 #include <e32std.h>
       
    26 #include <pnp/rpnpservicediscovery.h>
       
    27 #include <pnp/rpnpservicepublisher.h>
       
    28 #include <pnp/mpnpobserver.h>
       
    29 #include <pnp/pnpparameterbundle.h>
       
    30 #include <e32des8.h>
       
    31 
       
    32 
       
    33 // User Includes
       
    34 #include "constants.h"
       
    35 #include "ctestcontrolchannel.h"
       
    36 #include "testpnpparamset.h"
       
    37 
       
    38 // Forward declarations
       
    39 class CTestPnPObserver;
       
    40 class CTestTimer;
       
    41 
       
    42 class MTimerObserver
       
    43 	{
       
    44 public:
       
    45 	virtual void TimedOut() = 0;		
       
    46 	};
       
    47 
       
    48 /*
       
    49 CTestPnPManager class which is derived from the CTestStep and provides the
       
    50 functionalities to perform Create (and open) an individual TestStep (testcase or part testcase), Run a TestStep
       
    51 with defined pre and post processing, Abort a TestStep, Close a TestStep session.
       
    52 Also performs the creation control point or service point, performs a sequence of pnp operations
       
    53 and get back the results to compare them against expected results.
       
    54 */
       
    55 class CTestPnPManager : public CTestStep,
       
    56 						public MTimerObserver
       
    57 	{
       
    58 public:
       
    59 	CTestPnPManager();
       
    60 	~CTestPnPManager();
       
    61 
       
    62 	virtual TVerdict doTestStepPreambleL();
       
    63 	virtual TVerdict doTestStepPostambleL();
       
    64 	virtual TVerdict doTestStepL();
       
    65 
       
    66 	void SetCurrentSection(const TDesC& aCurrentSection);
       
    67 	TDesC& GetCurrentSection();
       
    68 	
       
    69 	// Operation  related functions
       
    70 	void InitializeL();
       
    71 	void SequenceOperationsL();
       
    72 	void PerformDesiredOperationsL(const TDesC& aSequence);
       
    73 
       
    74 	// TestPnP API related functions
       
    75 	void OpenPublisherL();	
       
    76 	void OpenDiscovererL();
       
    77 	void DiscoverL();
       
    78 	void PublishServiceL(const TDesC& aOperationType);
       
    79 	void DescribeL();
       
    80 	void DescribeServiceL();
       
    81 	void RegisterForAnnouncementsL();
       
    82 	void InitiateActionL();
       
    83 	void SubscribeForStateChangeNotificationsL();
       
    84 	void SendNotificationsL();
       
    85     void OpenDiscovererFailed();
       
    86 	void OpenPublisherFailed();
       
    87 	
       
    88 	// Cancellation related functions
       
    89 	void CancelDiscoverL();
       
    90 	void CancelNotifyAnnouncementL ();	
       
    91 	void CancelDescribeL();
       
    92 
       
    93 	// Utility functions
       
    94 	void TokenizeStringL(const TDesC& aString, RArray<TPtrC>& aList, TChar aSeparator = ',');
       
    95 	const TDesC& ScriptFileName();
       
    96 	
       
    97 	// from MTimerObserver
       
    98 	void TimedOut();
       
    99 
       
   100 	
       
   101 private:
       
   102     
       
   103     CActiveScheduler*					    iScheduler;
       
   104 	RPnPServiceDiscovery					iControlPoint;
       
   105 	RPnPServicePublisher   		        	iServicePoint;
       
   106 	RControlChannel							iControlChannel;	
       
   107 	TControlMessage                         iMsg;
       
   108 	TRequestStatus                          iStatus;	
       
   109 
       
   110 private:	
       
   111 	TBuf<KMaxBufLength>					iCurrentSection;
       
   112 	TBuf<KMaxBufLength> 				iScriptName;
       
   113 	TBool								iCancelDiscovery;
       
   114 	
       
   115 	};
       
   116 
       
   117 /*
       
   118 CTestPnPObserver class which is derived from CBase and MPnPObserver to provide the
       
   119 following functionalities. It supports the methods capture the results when an
       
   120 pnp event is hit after performing any pnp operation.
       
   121 */
       
   122 class CTestPnPObserver: public CBase, MPnPObserver
       
   123 	{
       
   124 public:
       
   125 	static CTestPnPObserver* NewL(CTestPnPManager* aManager);
       
   126 	~CTestPnPObserver();
       
   127 	void OnPnPEventL (RPnPParameterBundleBase& aServiceEventInfo);
       
   128 	void OnPnPError (TInt aError);
       
   129 	CTestPnPManager& Manager();
       
   130 	void SequenceOperationsL();
       
   131 
       
   132 private:
       
   133 	CTestPnPObserver();
       
   134 	void ConstructL(CTestPnPManager* aManager);
       
   135 
       
   136 private:
       
   137 	  CTestPnPManager* 					iManager;
       
   138 	  TUint								iSequence;
       
   139 	};
       
   140 	
       
   141 
       
   142 class CTestTimer:public CActive
       
   143 	{
       
   144 public:
       
   145 	static CTestTimer* NewL(MTimerObserver& aObserver);
       
   146 	~CTestTimer();
       
   147 	void After(TTimeIntervalMicroSeconds32 aInterval);
       
   148 	
       
   149 private:
       
   150 	CTestTimer(MTimerObserver& aObserver);
       
   151 			
       
   152 public:
       
   153 	void RunL();
       
   154 	void DoCancel();
       
   155 	
       
   156 private:
       
   157 	RTimer		iTimer;
       
   158 	MTimerObserver& iObserver;	
       
   159 	};	
       
   160 
       
   161 
       
   162 #endif //__TEST_PNP_MANAGER_H__
       
   163