|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #include <aknutils.h> |
|
21 |
|
22 #include <alf/alfenv.h> |
|
23 #include <alf/alfevent.h> |
|
24 |
|
25 #include "AlfPerfAppSuiteTestCaseControl.h" |
|
26 |
|
27 |
|
28 // ============================= MEMBER FUNCTIONS ============================== |
|
29 |
|
30 CAlfPerfAppSuiteTestCaseControl::CAlfPerfAppSuiteTestCaseControl() |
|
31 { |
|
32 } |
|
33 |
|
34 CAlfPerfAppSuiteTestCaseControl::~CAlfPerfAppSuiteTestCaseControl() |
|
35 { |
|
36 CompleteNow( KErrCancel ); |
|
37 } |
|
38 |
|
39 void CAlfPerfAppSuiteTestCaseControl::ConstructL( |
|
40 CAlfEnv& aEnv, TInt aCaseId, const TRect& aVisibleArea ) |
|
41 { |
|
42 iCaseId = aCaseId; |
|
43 iVisibleArea = aVisibleArea; |
|
44 CAlfControl::ConstructL( aEnv ); |
|
45 TFileName privatePath; |
|
46 CEikonEnv::Static()->FsSession().PrivatePath( privatePath ); |
|
47 ::CompleteWithAppPath( privatePath ); |
|
48 aEnv.TextureManager().SetImagePathL( privatePath ); |
|
49 } |
|
50 |
|
51 void CAlfPerfAppSuiteTestCaseControl::StartExecuteL( TRequestStatus& aStatus ) |
|
52 { |
|
53 iStatus = &aStatus; |
|
54 *iStatus = KRequestPending; |
|
55 |
|
56 TRAPD( err, DoStartExecuteL() ); |
|
57 if ( err != KErrNone ) |
|
58 { |
|
59 iStatus = NULL; |
|
60 User::Leave( err ); |
|
61 } |
|
62 } |
|
63 |
|
64 void CAlfPerfAppSuiteTestCaseControl::CancelExecution() |
|
65 { |
|
66 CompleteNow( KErrCancel ); |
|
67 } |
|
68 |
|
69 void CAlfPerfAppSuiteTestCaseControl::DoStartExecuteL() |
|
70 { |
|
71 CompleteNow( KErrNone ); |
|
72 } |
|
73 |
|
74 void CAlfPerfAppSuiteTestCaseControl::SetVisibleArea( |
|
75 const TRect& /*aVisibleArea*/ ) |
|
76 { |
|
77 } |
|
78 |
|
79 TBool CAlfPerfAppSuiteTestCaseControl::OfferEventL( const TAlfEvent& aEvent ) |
|
80 { |
|
81 if ( aEvent.IsCustomEvent() && |
|
82 aEvent.CustomParameter() == KAlfPerfAppSuiteCmdCompleteNow ) |
|
83 { |
|
84 CompleteNow( KErrNone ); |
|
85 return ETrue; |
|
86 } |
|
87 |
|
88 return CAlfControl::OfferEventL( aEvent ); |
|
89 } |
|
90 |
|
91 void CAlfPerfAppSuiteTestCaseControl::CompleteAfterL( TInt aDuration ) |
|
92 { |
|
93 // In order to use this service, base class StartExecuteL must |
|
94 // have been called. |
|
95 __ASSERT_ALWAYS( iStatus, User::Invariant() ); |
|
96 |
|
97 TAlfCustomEventCommand command( KAlfPerfAppSuiteCmdCompleteNow, this ); |
|
98 User::LeaveIfError( Env().Send( command, aDuration ) ); |
|
99 } |
|
100 |
|
101 void CAlfPerfAppSuiteTestCaseControl::CompleteNow( TInt aErrorCode ) |
|
102 { |
|
103 if ( iStatus ) |
|
104 { |
|
105 User::RequestComplete( iStatus, aErrorCode ); |
|
106 iStatus = NULL; |
|
107 } |
|
108 } |
|
109 |
|
110 inline TInt CAlfPerfAppSuiteTestCaseControl::CaseId() const |
|
111 { |
|
112 return iCaseId; |
|
113 } |
|
114 |
|
115 TBool CAlfPerfAppSuiteTestCaseControl::IsExecutionOngoing() const |
|
116 { |
|
117 return ( iStatus != NULL ); |
|
118 } |
|
119 |
|
120 // end of file |