|
1 // Copyright (c) 2002-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 #include "NetConTestBases.h" |
|
17 #include "NetConLog.h" |
|
18 |
|
19 // |
|
20 // NetCon Test Base Class |
|
21 // |
|
22 |
|
23 CNetConTestBase::CNetConTestBase() |
|
24 : CActive(CActive::EPriorityStandard), iResult(EUnknown), iAction(ENone), iState(EInitialised) |
|
25 { |
|
26 |
|
27 CActiveScheduler::Add(this); |
|
28 } |
|
29 |
|
30 CNetConTestBase::~CNetConTestBase() |
|
31 { |
|
32 |
|
33 Cancel(); |
|
34 } |
|
35 |
|
36 void CNetConTestBase::RunL() |
|
37 { |
|
38 |
|
39 switch(iAction) |
|
40 { |
|
41 case EStart: |
|
42 LOG( NetConLog::Printf(_L("---------- Starting %S ----------"), &Name()); ) |
|
43 |
|
44 StartTestL(); |
|
45 break; |
|
46 |
|
47 case EStop: |
|
48 StopTest(); |
|
49 break; |
|
50 |
|
51 default: |
|
52 User::Invariant(); |
|
53 } |
|
54 } |
|
55 |
|
56 TInt CNetConTestBase::RunError(TInt aError) |
|
57 { |
|
58 |
|
59 LOG( NetConLog::Printf(_L("Error %d encountered while starting test '%S'"), aError, &Name()); ) |
|
60 |
|
61 (void)aError; // remove warning |
|
62 |
|
63 iResult = EFailed; |
|
64 |
|
65 StopTest(); |
|
66 return KErrNone; |
|
67 } |
|
68 |
|
69 void CNetConTestBase::DoCancel() |
|
70 { |
|
71 |
|
72 iResult = EUnknown; |
|
73 StopTest(); |
|
74 } |
|
75 |
|
76 void CNetConTestBase::Start() |
|
77 { |
|
78 |
|
79 iAction = EStart; |
|
80 iState = EStarting; |
|
81 |
|
82 TRequestStatus* status = (&iStatus); |
|
83 SetActive(); |
|
84 User::RequestComplete(status, KErrNone); |
|
85 |
|
86 CActiveScheduler::Start(); |
|
87 } |
|
88 |
|
89 void CNetConTestBase::CompleteTest(TResult aResult) |
|
90 { |
|
91 |
|
92 // guard against multiple completion |
|
93 if(iState==EComplete) |
|
94 { |
|
95 return; |
|
96 } |
|
97 |
|
98 iResult = aResult; |
|
99 iAction = EStop; |
|
100 iState = EComplete; |
|
101 |
|
102 TRequestStatus* status = (&iStatus); |
|
103 SetActive(); |
|
104 User::RequestComplete(status, KErrNone); |
|
105 } |
|
106 |
|
107 void CNetConTestBase::StopTest() |
|
108 { |
|
109 |
|
110 LOG ( |
|
111 NetConLog::Printf(_L("---------- %S Complete ----------"), &Name()); |
|
112 |
|
113 switch(Result()) |
|
114 { |
|
115 case EPassed: |
|
116 NetConLog::Printf(_L("Test Result: Passed")); |
|
117 break; |
|
118 |
|
119 case EFailed: |
|
120 NetConLog::Printf(_L("Test Result: Failed")); |
|
121 break; |
|
122 |
|
123 case EUnknown: |
|
124 default: |
|
125 NetConLog::Printf(_L("Test Result: Unknown")); |
|
126 } |
|
127 |
|
128 NetConLog::Printf(_L("")); |
|
129 ) |
|
130 |
|
131 CActiveScheduler::Stop(); |
|
132 } |
|
133 |
|
134 MNetConTest::TResult CNetConTestBase::Result() const |
|
135 { |
|
136 |
|
137 return iResult; |
|
138 } |
|
139 |