|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: alfperfapp abstract test case class definition. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_ALFPERFAPPTESTCASE_H |
|
20 #define C_ALFPERFAPPTESTCASE_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <eikenv.h> |
|
24 |
|
25 #include "alfperfappmodel.h" |
|
26 class CAlfEnv; |
|
27 |
|
28 /** |
|
29 * MAlfPerfAppTestCaseInterface class. |
|
30 * It is interface from test case to execution environment. It allows |
|
31 * test case to ask measurements to be performed. |
|
32 */ |
|
33 class MAlfPerfAppTestCaseInterface |
|
34 { |
|
35 public: |
|
36 |
|
37 /** |
|
38 * Asks execution enrivonment to perform measurements. |
|
39 */ |
|
40 virtual void MeasureNow() = 0; |
|
41 |
|
42 }; |
|
43 |
|
44 /** |
|
45 * CAlfPerfAppTestCase class. |
|
46 * It's abstract class from which all concrete test cases needs to be derived |
|
47 * from. |
|
48 * Destruction of an instance of this type must complete ongoing requests. |
|
49 */ |
|
50 class CAlfPerfAppTestCase : public CBase |
|
51 { |
|
52 public: |
|
53 |
|
54 /** |
|
55 * Sets interface towards execution environment. |
|
56 */ |
|
57 inline void SetInterface( MAlfPerfAppTestCaseInterface* aInterface ); |
|
58 |
|
59 /** |
|
60 * Starts set up phase. |
|
61 * @param aEnv reference to alf environment instance. |
|
62 * @param aVisibleArea visible area. |
|
63 * @param aStatus request status that needs to be completed when |
|
64 * test case is ready to be executed. |
|
65 */ |
|
66 virtual void SetupL( |
|
67 CAlfEnv& aEnv, |
|
68 const TRect& aVisibleArea, |
|
69 TRequestStatus& aStatus ) = 0; |
|
70 |
|
71 /** |
|
72 * Starts test case execution. |
|
73 * @param aStatus request status that needs to be completed when |
|
74 * execution is finished. |
|
75 */ |
|
76 virtual void ExecuteL( TRequestStatus& aStatus ) = 0; |
|
77 |
|
78 /** |
|
79 * Tears down. |
|
80 */ |
|
81 virtual void TearDown() = 0; |
|
82 |
|
83 /** |
|
84 * Handles visible area changes. |
|
85 * @param aRect new visible area rect. |
|
86 */ |
|
87 virtual void HandleVisibleAreaChange( const TRect& aRect ) = 0; |
|
88 |
|
89 /** |
|
90 * Returns CaseID of this test case |
|
91 */ |
|
92 virtual TInt CaseID() = 0; |
|
93 |
|
94 /* |
|
95 * Used to get test case specific results. |
|
96 * Default definition just returns empty TTestCaseSpecificResultText |
|
97 * This should be reimplemented in actual test case classes if case specific results are needed. |
|
98 * Notes: |
|
99 * - Latest non-zero returning value of this is shown in DisplayResults. All are still |
|
100 * recorded to file. |
|
101 */ |
|
102 virtual TTestCaseSpecificResultText getCaseSpecificResultL(); |
|
103 |
|
104 |
|
105 TInt SequenceIndex(); |
|
106 |
|
107 protected: |
|
108 |
|
109 /** |
|
110 * Perform measurements. |
|
111 */ |
|
112 inline void MeasureNow(); |
|
113 |
|
114 /** |
|
115 * Completes request status now. |
|
116 * @param aStatus request status to be completed. |
|
117 * @param aErrorCode completion error code to be used. |
|
118 */ |
|
119 inline static void CompleteNow( TRequestStatus& aStatus, TInt aErrorCode ); |
|
120 |
|
121 /* |
|
122 * Gives access to stored CEikonEnv pointer |
|
123 */ |
|
124 CEikonEnv* EikonEnv(); |
|
125 |
|
126 /* |
|
127 * Protected constructor |
|
128 */ |
|
129 CAlfPerfAppTestCase(TInt aSequenceIndex); |
|
130 |
|
131 private: |
|
132 /** |
|
133 * Interface towards execution environment. |
|
134 * Not owned. |
|
135 */ |
|
136 MAlfPerfAppTestCaseInterface* iInterface; |
|
137 |
|
138 /* |
|
139 * Pointer to CEikonEnv. |
|
140 */ |
|
141 CEikonEnv* iEnv; |
|
142 |
|
143 /* |
|
144 * Tells which iteration of this same case this is. |
|
145 * 0 Means that this is not a sequence case. |
|
146 */ |
|
147 TInt iSequenceIndex; |
|
148 |
|
149 }; |
|
150 |
|
151 inline void CAlfPerfAppTestCase::SetInterface( |
|
152 MAlfPerfAppTestCaseInterface* aInterface ) |
|
153 { |
|
154 iInterface = aInterface; |
|
155 } |
|
156 |
|
157 inline void CAlfPerfAppTestCase::MeasureNow() |
|
158 { |
|
159 if ( iInterface ) |
|
160 { |
|
161 iInterface->MeasureNow(); |
|
162 } |
|
163 } |
|
164 |
|
165 inline void CAlfPerfAppTestCase::CompleteNow( TRequestStatus& aStatus, TInt aErrorCode ) |
|
166 { |
|
167 __ASSERT_ALWAYS( aStatus.Int() == KRequestPending, User::Invariant() ); |
|
168 TRequestStatus* status = &aStatus; |
|
169 User::RequestComplete( status, aErrorCode ); |
|
170 } |
|
171 |
|
172 #endif // C_ALFPERFAPPTESTCASE_H |
|
173 |