kerneltest/e32test/usbho/t_usbdi/src/testdeviceb.cpp
branchRCL_3
changeset 44 3e88ff8f41d5
parent 43 c1f20ce4abcf
equal deleted inserted replaced
43:c1f20ce4abcf 44:3e88ff8f41d5
     1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    17 //
    17 //
    18 
    18 
    19 #include "modelleddevices.h"
    19 #include "modelleddevices.h"
    20 #include "testinterfacesettingbase.h"
    20 #include "testinterfacesettingbase.h"
    21 #include "testinterfacebase.h"
    21 #include "testinterfacebase.h"
    22 #include "OstTraceDefinitions.h"
       
    23 #ifdef OST_TRACE_COMPILER_IN_USE
       
    24 #include "testdevicebTraces.h"
       
    25 #endif
       
    26 #include <e32test.h>
    22 #include <e32test.h>
    27 
    23 
    28 namespace NUnitTesting_USBDI
    24 namespace NUnitTesting_USBDI
    29 	{
    25 	{
    30 
    26 
    31 RUsbDeviceB::RUsbDeviceB()
    27 RUsbDeviceB::RUsbDeviceB()
    32 	{
    28 	{
    33 	OstTraceFunctionEntry1( RUSBDEVICEB_RUSBDEVICEB_ENTRY, this );
       
    34 	OstTraceFunctionExit1( RUSBDEVICEB_RUSBDEVICEB_EXIT, this );
       
    35 	}
    29 	}
    36 	
    30 	
    37 RUsbDeviceB::RUsbDeviceB(CBaseTestCase* aTestCase):RUsbTestDevice(aTestCase)
    31 RUsbDeviceB::RUsbDeviceB(CBaseTestCase* aTestCase):RUsbTestDevice(aTestCase)
    38 	{
    32 	{
    39 	OstTraceFunctionEntryExt( RUSBDEVICEB_RUSBDEVICEB_ENTRY_DUP01, this );
    33 	LOG_FUNC	
    40 	OstTraceFunctionExit1( RUSBDEVICEB_RUSBDEVICEB_EXIT_DUP01, this );
       
    41 	}
    34 	}
    42 
    35 
    43 RUsbDeviceB::~RUsbDeviceB()
    36 RUsbDeviceB::~RUsbDeviceB()
    44 	{
    37 	{
    45 	OstTraceFunctionEntry1( RUSBDEVICEB_RUSBDEVICEB_ENTRY_DUP02, this );
       
    46 	OstTraceFunctionExit1( RUSBDEVICEB_RUSBDEVICEB_EXIT_DUP02, this );
       
    47 	}
    38 	}
    48 
    39 
    49 
    40 
    50 void RUsbDeviceB::OpenL(const TDesC& aSerialNumber)
    41 void RUsbDeviceB::OpenL(const TDesC& aSerialNumber)
    51 	{
    42 	{
    52 	OstTraceFunctionEntryExt( RUSBDEVICEB_OPENL_ENTRY, this );
    43 	LOG_FUNC
    53 	
    44 	
    54 	RUsbTestDevice::OpenL();
    45 	RUsbTestDevice::OpenL();
    55 	
    46 	
    56 	// Device/Product information
    47 	// Device/Product information
    57 	SetUsbSpecification(0x0200); // Usb spec. 2.0
    48 	SetUsbSpecification(0x0200); // Usb spec. 2.0
    85 	// Interface 0
    76 	// Interface 0
    86 	
    77 	
    87 	TInt err(iClientDriver.SetInterface(0,interfaceSetting));
    78 	TInt err(iClientDriver.SetInterface(0,interfaceSetting));
    88 	if(err != KErrNone)
    79 	if(err != KErrNone)
    89 		{
    80 		{
    90 		OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL, "<Error %d> Unable to set interface setting 0",err);
    81 		RDebug::Printf("<Error %d> Unable to set interface setting 0",err);
    91 		User::Leave(err);
    82 		User::Leave(err);
    92 		}
    83 		}
    93 		
    84 		
    94 	// class-specific.....
    85 	// class-specific.....
    95 	
    86 	
    96 	// .....interface
    87 	// .....interface
    97 	
    88 	
    98 	err = iClientDriver.SetCSInterfaceDescriptorBlock(0,cs_interfaceDescriptor);
    89 	err = iClientDriver.SetCSInterfaceDescriptorBlock(0,cs_interfaceDescriptor);
    99 	if(err != KErrNone)
    90 	if(err != KErrNone)
   100 		{
    91 		{
   101 		OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP01, "<Error %d> Unable to set class-specific interface setting 0 descriptor",err);
    92 		RDebug::Printf("<Error %d> Unable to set class-specific interface setting 0 descriptor",err);
   102 		User::Leave(err);
    93 		User::Leave(err);
   103 		}
    94 		}
   104 
    95 
   105 	// .....endpoints
    96 	// .....endpoints
   106 	
    97 	
   107 	err = iClientDriver.SetCSEndpointDescriptorBlock(0,1,cs_endpointDescriptor);
    98 	err = iClientDriver.SetCSEndpointDescriptorBlock(0,1,cs_endpointDescriptor);
   108 	if(err != KErrNone)
    99 	if(err != KErrNone)
   109 		{
   100 		{
   110 		OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP02, "<Error %d> Unable to set class-specific endpoint 1 descriptor on setting 0",err);
   101 		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 1 descriptor on setting 0",err);
   111 		User::Leave(err);
   102 		User::Leave(err);
   112 		}
   103 		}
   113 			
   104 			
   114 	err = iClientDriver.SetCSEndpointDescriptorBlock(0,2,cs_endpointDescriptor);
   105 	err = iClientDriver.SetCSEndpointDescriptorBlock(0,2,cs_endpointDescriptor);
   115 	if(err != KErrNone)
   106 	if(err != KErrNone)
   116 		{
   107 		{
   117 		OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP03, "<Error %d> Unable to set class-specific endpoint 2 descriptor on setting 0",err);
   108 		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 2 descriptor on setting 0",err);
   118 		User::Leave(err);
   109 		User::Leave(err);
   119 		}	
   110 		}	
   120 		
   111 		
   121 	err = iClientDriver.SetCSEndpointDescriptorBlock(0,3,cs_endpointDescriptor);
   112 	err = iClientDriver.SetCSEndpointDescriptorBlock(0,3,cs_endpointDescriptor);
   122 	if(err != KErrNone)
   113 	if(err != KErrNone)
   123 		{
   114 		{
   124 		OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP04, "<Error %d> Unable to set class-specific endpoint 3 descriptor on setting 0",err);
   115 		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 3 descriptor on setting 0",err);
   125 		User::Leave(err);
   116 		User::Leave(err);
   126 		}
   117 		}
   127 	
   118 	
   128 	// Interface 1
   119 	// Interface 1
   129 	
   120 	
   130 	err = iClientDriver.SetInterface(1,interfaceSetting);
   121 	err = iClientDriver.SetInterface(1,interfaceSetting);
   131 	if(err != KErrNone)
   122 	if(err != KErrNone)
   132 		{
   123 		{
   133 		OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP05, "<Error %d> Unable to set interface setting 1",err);
   124 		RDebug::Printf("<Error %d> Unable to set interface setting 1",err);
   134 		User::Leave(err);
   125 		User::Leave(err);
   135 		}
   126 		}
   136 	
   127 	
   137 	// class-specific......
   128 	// class-specific......
   138 	
   129 	
   139 	// ......interface
   130 	// ......interface
   140 	
   131 	
   141 	err = iClientDriver.SetCSInterfaceDescriptorBlock(1,cs_interfaceDescriptor);
   132 	err = iClientDriver.SetCSInterfaceDescriptorBlock(1,cs_interfaceDescriptor);
   142 	if(err != KErrNone)
   133 	if(err != KErrNone)
   143 		{
   134 		{
   144 		OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP06, "<Error %d> Unable to set class-specific interface setting 1 descriptor",err);
   135 		RDebug::Printf("<Error %d> Unable to set class-specific interface setting 1 descriptor",err);
   145 		User::Leave(err);
   136 		User::Leave(err);
   146 		}
   137 		}
   147 
   138 
   148 	// .....endpoints
   139 	// .....endpoints
   149 		
   140 		
   150 	err = iClientDriver.SetCSEndpointDescriptorBlock(1,1,cs_endpointDescriptor);
   141 	err = iClientDriver.SetCSEndpointDescriptorBlock(1,1,cs_endpointDescriptor);
   151 	if(err != KErrNone)
   142 	if(err != KErrNone)
   152 		{
   143 		{
   153 		OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP07, "<Error %d> Unable to set class-specific endpoint 1 descriptor on setting 1",err);
   144 		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 1 descriptor on setting 1",err);
   154 		User::Leave(err);
   145 		User::Leave(err);
   155 		}
   146 		}
   156 	
   147 	
   157 	err = iClientDriver.SetCSEndpointDescriptorBlock(1,2,cs_endpointDescriptor);
   148 	err = iClientDriver.SetCSEndpointDescriptorBlock(1,2,cs_endpointDescriptor);
   158 	if(err != KErrNone)
   149 	if(err != KErrNone)
   159 		{
   150 		{
   160 		OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP08, "<Error %d> Unable to set class-specific endpoint 2 descriptor on setting 1",err);
   151 		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 2 descriptor on setting 1",err);
   161 		User::Leave(err);
   152 		User::Leave(err);
   162 		}
   153 		}
   163 		
   154 		
   164 	err = iClientDriver.SetCSEndpointDescriptorBlock(1,3,cs_endpointDescriptor);
   155 	err = iClientDriver.SetCSEndpointDescriptorBlock(1,3,cs_endpointDescriptor);
   165 	if(err != KErrNone)
   156 	if(err != KErrNone)
   166 		{
   157 		{
   167 		OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP09, "<Error %d> Unable to set class-specific endpoint 3 descriptor on setting 1",err);
   158 		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 3 descriptor on setting 1",err);
   168 		User::Leave(err);
   159 		User::Leave(err);
   169 		}
   160 		}
   170 
   161 
   171 	// Interface 2
   162 	// Interface 2
   172 
   163 
   173 	err = iClientDriver.SetInterface(2,interfaceSetting);
   164 	err = iClientDriver.SetInterface(2,interfaceSetting);
   174 	if(err != KErrNone)
   165 	if(err != KErrNone)
   175 		{
   166 		{
   176 		OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP10, "<Error %d> Unable to set interface setting 2",err);
   167 		RDebug::Printf("<Error %d> Unable to set interface setting 2",err);
   177 		User::Leave(err);
   168 		User::Leave(err);
   178 		}
   169 		}
   179 
   170 
   180 	// class-specific......
   171 	// class-specific......
   181 	
   172 	
   182 	// ......interface	
   173 	// ......interface	
   183 
   174 
   184 	err = iClientDriver.SetCSInterfaceDescriptorBlock(2,cs_interfaceDescriptor);
   175 	err = iClientDriver.SetCSInterfaceDescriptorBlock(2,cs_interfaceDescriptor);
   185 	if(err != KErrNone)
   176 	if(err != KErrNone)
   186 		{
   177 		{
   187 		OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP11, "<Error %d> Unable to set class-specific interface setting 2 descriptor",err);
   178 		RDebug::Printf("<Error %d> Unable to set class-specific interface setting 2 descriptor",err);
   188 		User::Leave(err);
   179 		User::Leave(err);
   189 		}
   180 		}
   190 
   181 
   191 	// ......endpoints		
   182 	// ......endpoints		
   192 		
   183 		
   193 	err = iClientDriver.SetCSEndpointDescriptorBlock(2,1,cs_endpointDescriptor);
   184 	err = iClientDriver.SetCSEndpointDescriptorBlock(2,1,cs_endpointDescriptor);
   194 	if(err != KErrNone)
   185 	if(err != KErrNone)
   195 		{
   186 		{
   196 		OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP12, "<Error %d> Unable to set class-specific endpoint 1 descriptor on setting 2",err);
   187 		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 1 descriptor on setting 2",err);
   197 		User::Leave(err);
   188 		User::Leave(err);
   198 		}
   189 		}
   199 	
   190 	
   200 	err = iClientDriver.SetCSEndpointDescriptorBlock(2,2,cs_endpointDescriptor);
   191 	err = iClientDriver.SetCSEndpointDescriptorBlock(2,2,cs_endpointDescriptor);
   201 	if(err != KErrNone)
   192 	if(err != KErrNone)
   202 		{
   193 		{
   203 		OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP13, "<Error %d> Unable to set class-specific endpoint 2 descriptor on setting 2",err);
   194 		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 2 descriptor on setting 2",err);
   204 		User::Leave(err);
   195 		User::Leave(err);
   205 		}
   196 		}
   206 		
   197 		
   207 	err = iClientDriver.SetCSEndpointDescriptorBlock(2,3,cs_endpointDescriptor);
   198 	err = iClientDriver.SetCSEndpointDescriptorBlock(2,3,cs_endpointDescriptor);
   208 	if(err != KErrNone)
   199 	if(err != KErrNone)
   209 		{
   200 		{
   210 		OstTrace1(TRACE_NORMAL, RUSBDEVICEB_OPENL_DUP14, "<Error %d> Unable to set class-specific endpoint 3 descriptor on setting 2",err);
   201 		RDebug::Printf("<Error %d> Unable to set class-specific endpoint 3 descriptor on setting 2",err);
   211 		User::Leave(err);
   202 		User::Leave(err);
   212 		}
   203 		}
   213 	OstTraceFunctionExit1( RUSBDEVICEB_OPENL_EXIT, this );
       
   214 	}
   204 	}
   215 
   205 
   216 
   206 
   217 void RUsbDeviceB::OnStateChangeL(TUsbcDeviceState aNewState)
   207 void RUsbDeviceB::OnStateChangeL(TUsbcDeviceState aNewState)
   218 	{
   208 	{
   219 	OstTraceFunctionEntryExt( RUSBDEVICEB_ONSTATECHANGEL_ENTRY, this );
   209 	LOG_FUNC
   220 	OstTraceFunctionExit1( RUSBDEVICEB_ONSTATECHANGEL_EXIT, this );
   210 	}
   221 	}
   211 	
   222 	
   212 	
   223 	
   213 	}
   224 	}
   214 
   225 
   215 
   226