0
|
1 |
#ifndef __TEST_DEBUG_H
|
|
2 |
#define __TEST_DEBUG_H
|
|
3 |
|
|
4 |
/*
|
|
5 |
* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
6 |
* All rights reserved.
|
|
7 |
* This component and the accompanying materials are made available
|
|
8 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
9 |
* which accompanies this distribution, and is available
|
|
10 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
11 |
*
|
|
12 |
* Initial Contributors:
|
|
13 |
* Nokia Corporation - initial contribution.
|
|
14 |
*
|
|
15 |
* Contributors:
|
|
16 |
*
|
|
17 |
* Description:
|
|
18 |
* @file testdebug.h
|
|
19 |
* @internalComponent
|
|
20 |
*
|
|
21 |
*
|
|
22 |
*/
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
#include <e32debug.h>
|
|
27 |
#include <d32usbdescriptors.h>
|
|
28 |
#include <d32usbdi.h>
|
|
29 |
#include <f32file.h>
|
|
30 |
|
|
31 |
//#define LOG_INFO(x) RDebug::Print x;
|
|
32 |
|
|
33 |
#define LOG_INFO(x)
|
|
34 |
|
|
35 |
|
|
36 |
/**
|
|
37 |
Debug function to print out (log) the data for the descriptor
|
|
38 |
@param aDescriptor the host-side view of the descriptor
|
|
39 |
*/
|
|
40 |
inline void PrintDescriptorBlob(TUsbGenericDescriptor& aDescriptor);
|
|
41 |
|
|
42 |
/**
|
|
43 |
*/
|
|
44 |
class TFunctionLog
|
|
45 |
{
|
|
46 |
public:
|
|
47 |
/**
|
|
48 |
Constructor
|
|
49 |
*/
|
|
50 |
TFunctionLog(const char* aFunctionName,void* aThisPointer)
|
|
51 |
: iFunctionName(aFunctionName),
|
|
52 |
iThisPointer(aThisPointer)
|
|
53 |
{
|
|
54 |
RDebug::Printf("\nIN [%08x] %s",iThisPointer,iFunctionName);
|
|
55 |
}
|
|
56 |
|
|
57 |
/**
|
|
58 |
Destructor
|
|
59 |
*/
|
|
60 |
~TFunctionLog()
|
|
61 |
{
|
|
62 |
RDebug::Printf("OUT [%08x] %s\n",iThisPointer,iFunctionName);
|
|
63 |
}
|
|
64 |
|
|
65 |
private:
|
|
66 |
const char* iFunctionName;
|
|
67 |
void* iThisPointer;
|
|
68 |
};
|
|
69 |
|
|
70 |
/**
|
|
71 |
This class describes a logger for test case actions
|
|
72 |
Pattern: Singleton
|
|
73 |
*/
|
|
74 |
class RLog
|
|
75 |
{
|
|
76 |
public:
|
|
77 |
/**
|
|
78 |
*/
|
|
79 |
static TInt Print(const TDesC8& aLogAction)
|
|
80 |
{
|
|
81 |
return Instance().iLogFile.Write(aLogAction);
|
|
82 |
}
|
|
83 |
|
|
84 |
private:
|
|
85 |
/**
|
|
86 |
Get the singleton instance
|
|
87 |
*/
|
|
88 |
static RLog& Instance()
|
|
89 |
{
|
|
90 |
static RLog singleton;
|
|
91 |
return singleton;
|
|
92 |
}
|
|
93 |
|
|
94 |
/**
|
|
95 |
Constructor
|
|
96 |
*/
|
|
97 |
RLog()
|
|
98 |
{
|
|
99 |
TInt err(iFileServer.Connect());
|
|
100 |
if(err != KErrNone)
|
|
101 |
{
|
|
102 |
User::Panic(_L("RTEST 84"),err);
|
|
103 |
}
|
|
104 |
err = iLogFile.Replace(iFileServer,_L("usbdi_testlog.txt"),EFileWrite);
|
|
105 |
if(err != KErrNone)
|
|
106 |
{
|
|
107 |
|
|
108 |
}
|
|
109 |
else
|
|
110 |
{
|
|
111 |
|
|
112 |
}
|
|
113 |
}
|
|
114 |
|
|
115 |
/**
|
|
116 |
Destructor
|
|
117 |
*/
|
|
118 |
~RLog()
|
|
119 |
{
|
|
120 |
iLogFile.Close();
|
|
121 |
iFileServer.Close();
|
|
122 |
}
|
|
123 |
|
|
124 |
private:
|
|
125 |
/**
|
|
126 |
The session with the file server
|
|
127 |
*/
|
|
128 |
RFs iFileServer;
|
|
129 |
|
|
130 |
/**
|
|
131 |
*/
|
|
132 |
RFile iLogFile;
|
|
133 |
|
|
134 |
};
|
|
135 |
|
|
136 |
|
|
137 |
// Implementation
|
|
138 |
void PrintDescriptorBlob(TUsbGenericDescriptor& aDescriptor)
|
|
139 |
{
|
|
140 |
for(int i=0; i<aDescriptor.iBlob.Length(); i++)
|
|
141 |
{
|
|
142 |
RDebug::Printf("<Type %d><Blob 0x%02x>",aDescriptor.ibDescriptorType,aDescriptor.iBlob[i]);
|
|
143 |
}
|
|
144 |
}
|
|
145 |
|
|
146 |
|
|
147 |
#endif
|
|
148 |
|