|
1 // Copyright (c) 2001-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 // Class to handle the acumulation of pass/fail data on the tests |
|
15 // |
|
16 // |
|
17 |
|
18 #include "result.h" |
|
19 #include "logger.h" |
|
20 |
|
21 CTOCSPResult* CTOCSPResult::NewLC() |
|
22 { |
|
23 CTOCSPResult* self = NewL(); |
|
24 CleanupStack::PushL(self); |
|
25 return self; |
|
26 } |
|
27 |
|
28 |
|
29 CTOCSPResult* CTOCSPResult::NewL() |
|
30 { |
|
31 CTOCSPResult* self = new (ELeave) CTOCSPResult; |
|
32 return self; |
|
33 } |
|
34 |
|
35 |
|
36 CTOCSPResult::~CTOCSPResult() |
|
37 { |
|
38 iNames.ResetAndDestroy(); |
|
39 iResults.Close(); |
|
40 } |
|
41 |
|
42 |
|
43 // Call this when you're starting a new test |
|
44 void CTOCSPResult::NewTestL(const TDesC& aName) |
|
45 { |
|
46 CheckL(); |
|
47 |
|
48 HBufC* name = aName.AllocLC(); |
|
49 User::LeaveIfError(iNames.Append(name)); |
|
50 CleanupStack::Pop(name); |
|
51 |
|
52 iTotal++; |
|
53 } |
|
54 |
|
55 |
|
56 // Then call this to say if it passed |
|
57 void CTOCSPResult::ResultL(const TBool aResult) |
|
58 { |
|
59 User::LeaveIfError(iResults.Append(aResult)); |
|
60 |
|
61 if (aResult) |
|
62 { |
|
63 iPassed++; |
|
64 } |
|
65 else |
|
66 { |
|
67 iFailed++; |
|
68 } |
|
69 |
|
70 CheckL(); |
|
71 } |
|
72 |
|
73 |
|
74 void CTOCSPResult::CheckL() const |
|
75 { |
|
76 if (iTotal != iPassed + iFailed |
|
77 || iTotal != iNames.Count() |
|
78 || iTotal != iResults.Count()) |
|
79 { |
|
80 User::Leave(KErrCorrupt); |
|
81 } |
|
82 } |
|
83 |
|
84 |
|
85 void CTOCSPResult::LogSummaryL(CTOCSPLogger& aLog) |
|
86 { |
|
87 // Allow one less test result than test started, |
|
88 // assume this meanswe crashed out of last test |
|
89 if (iTotal == (iPassed + iFailed + 1)) |
|
90 { |
|
91 User::LeaveIfError(iResults.Append(EFalse)); |
|
92 ++iFailed; |
|
93 } |
|
94 |
|
95 CheckL(); |
|
96 |
|
97 aLog.LogL(_L("Run: ")); |
|
98 aLog.LogL(iTotal); |
|
99 aLog.LogL(_L("\nPassed: ")); |
|
100 aLog.LogL(iPassed); |
|
101 |
|
102 aLog.LogL(_L("\n")); |
|
103 aLog.LogL(iFailed); |
|
104 aLog.LogL(_L(" tests failed out of ")); |
|
105 aLog.LogL(iTotal); |
|
106 aLog.LogL(_L("\n")); |
|
107 |
|
108 aLog.LogL(_L("Failed tests: ")); |
|
109 TInt tally = 0; |
|
110 for (TInt i = 0; i < iTotal; ++i) |
|
111 { |
|
112 if (!iResults[i]) |
|
113 { |
|
114 aLog.LogL(*iNames[i]); |
|
115 aLog.LogL(_L(" (")); |
|
116 aLog.LogL(i); |
|
117 aLog.LogL(_L(")")); |
|
118 |
|
119 if (++tally < iFailed) |
|
120 { |
|
121 aLog.LogL(_L(", ")); |
|
122 } |
|
123 else |
|
124 { |
|
125 aLog.LogL(_L("\n")); |
|
126 } |
|
127 } |
|
128 } |
|
129 aLog.LogL(_L("\r\n</pre></body></html>\r\n")); |
|
130 } |