|
1 // Copyright (c) 2007-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 // |
|
15 |
|
16 #define KHttpLogsDirName _L("http") |
|
17 const TInt KTestMaxLogLineLength = 128; |
|
18 |
|
19 inline RTest& CHTTPTestUtils::Test() |
|
20 // |
|
21 // Return iTest |
|
22 { |
|
23 return iTest; |
|
24 } |
|
25 |
|
26 inline void CHTTPTestUtils::DoResourceLeakTest(TBool aValue) |
|
27 // |
|
28 // Turn on/off the resource handle leak test |
|
29 { |
|
30 iDoResourceLeakTest = aValue; |
|
31 } |
|
32 |
|
33 inline void CHTTPTestUtils::DefaultLogFileName(TDes& aFileName) |
|
34 // |
|
35 // Sets aFilename to "KLogsDir\KHttpLogsDirName\<TEST HARNESS NAME>.<PLATFORM>.<VARIANT>.log" |
|
36 { |
|
37 aFileName.Copy(RProcess().FileName()); |
|
38 TInt start = aFileName.LocateReverse('\\'); |
|
39 TInt end = aFileName.LocateReverse('.'); |
|
40 aFileName = aFileName.Mid(start + 1, end - start - 1); |
|
41 |
|
42 // create the log filename |
|
43 aFileName.Insert(0, _L("\\")); |
|
44 aFileName.Insert(0, KHttpLogsDirName); |
|
45 aFileName.Insert(0, KLogsDir); |
|
46 |
|
47 #if defined(__WINS__) |
|
48 aFileName.Append(_L(".WINS.")); |
|
49 #else |
|
50 aFileName.Append(_L(".MARM.")); |
|
51 #endif |
|
52 |
|
53 #if defined(_DEBUG) |
|
54 aFileName.Append(_L("DEB.")); |
|
55 #else |
|
56 aFileName.Append(_L("REL.")); |
|
57 #endif |
|
58 |
|
59 aFileName.Append(_L("LOG")); |
|
60 } |
|
61 |
|
62 inline void CHTTPTestUtils::WriteComment(const TDesC& aComment) |
|
63 // |
|
64 // Writes aComment to test log file, logging file and test harness |
|
65 { |
|
66 if (!iSilent) |
|
67 iTest.Printf(_L("%S\n"), &aComment); |
|
68 |
|
69 __LOG(aComment); |
|
70 |
|
71 // If the flogger connection was made successfully |
|
72 if(iTestSummaryLogger.Handle() != 0) |
|
73 { |
|
74 TPtrC line; |
|
75 line.Set(aComment); |
|
76 |
|
77 while (line.Length() > KTestMaxLogLineLength) |
|
78 { |
|
79 iTestSummaryLogger.Write(line.Left(KTestMaxLogLineLength)); |
|
80 line.Set(line.Right(line.Length() - KTestMaxLogLineLength)); |
|
81 } |
|
82 iTestSummaryLogger.Write(line.Left(line.Length())); |
|
83 } |
|
84 } |
|
85 |
|
86 |
|
87 inline TBool CHTTPTestUtils::IsSilent() const |
|
88 // |
|
89 // Returns errorcode |
|
90 { |
|
91 return iSilent; |
|
92 } |
|
93 |
|
94 |
|
95 inline void CHTTPTestUtils::SetSilent(TBool aSilent) |
|
96 // |
|
97 // Sets silence on or off |
|
98 { |
|
99 iSilent = aSilent; |
|
100 } |
|
101 |
|
102 |
|
103 inline TPtr CHTTPTestUtils::CTestInfo::Name() const |
|
104 // |
|
105 // Returns name |
|
106 { |
|
107 return iName->Des(); |
|
108 } |
|
109 |
|
110 inline TInt CHTTPTestUtils::CTestInfo::Number() const |
|
111 // |
|
112 // Returns number |
|
113 { |
|
114 return iNumber; |
|
115 } |
|
116 |
|
117 inline TInt CHTTPTestUtils::CTestInfo::ErrorCode() const |
|
118 // |
|
119 // Returns errorcode |
|
120 { |
|
121 return iErrorCode; |
|
122 } |