|
1 /* |
|
2 * Copyright (c) 2005-2009 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 the License "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 /** |
|
20 @file |
|
21 */ |
|
22 |
|
23 #include "performancetest.h" |
|
24 #include "t_input.h" |
|
25 #include "tvectorutils.h" |
|
26 |
|
27 _LIT8(KPerformanceTestStart, "<KPerformanceTesting>"); |
|
28 _LIT8(KPerformanceTestEnd, "</KPerformanceTesting>"); |
|
29 |
|
30 /*static*/ CPerformance* CPerformance::iPerformanceTester = NULL; |
|
31 |
|
32 /*static*/ CPerformance* CPerformance::NewL() |
|
33 { |
|
34 if (!iPerformanceTester) |
|
35 { |
|
36 iPerformanceTester = new (ELeave) CPerformance(); |
|
37 } |
|
38 |
|
39 return (iPerformanceTester); |
|
40 } |
|
41 |
|
42 /*static*/ CPerformance* CPerformance::PerformanceTester() |
|
43 { |
|
44 ASSERT(iPerformanceTester); |
|
45 return (iPerformanceTester); |
|
46 } |
|
47 |
|
48 /*static*/ void CPerformance::ClosePerformanceTester() |
|
49 { |
|
50 delete iPerformanceTester; |
|
51 iPerformanceTester = NULL; |
|
52 } |
|
53 |
|
54 |
|
55 CPerformance::CPerformance() |
|
56 : iTestingPerformance(EFalse) // Default to no performance testing |
|
57 {} |
|
58 |
|
59 CPerformance::~CPerformance() |
|
60 {} |
|
61 |
|
62 //////////////////////////////////////////////////////////////////////// |
|
63 // Use this class as a place holder to turn performance testing on/off |
|
64 //////////////////////////////////////////////////////////////////////// |
|
65 |
|
66 CTestAction* CPerformanceTest::NewL(RFs& aFs, CConsoleBase& aConsole, Output& aOut, const TTestActionSpec& aTestActionSpec) |
|
67 { |
|
68 CTestAction* me = CPerformanceTest::NewLC(aFs, aConsole, aOut, aTestActionSpec); |
|
69 CleanupStack::Pop(me); |
|
70 return (me); |
|
71 } |
|
72 |
|
73 CTestAction* CPerformanceTest::NewLC(RFs& /*aFs*/, CConsoleBase& aConsole, Output& aOut, const TTestActionSpec& aTestActionSpec) |
|
74 { |
|
75 CPerformanceTest* me = new (ELeave) CPerformanceTest(aConsole, aOut); |
|
76 CleanupStack::PushL(me); |
|
77 me->ConstructL(aTestActionSpec); |
|
78 return (static_cast<CTestAction*>(me)); |
|
79 } |
|
80 |
|
81 |
|
82 CPerformanceTest::CPerformanceTest(CConsoleBase& aConsole, Output& aOut) |
|
83 : CTestAction(aConsole, aOut) |
|
84 { |
|
85 } |
|
86 |
|
87 CPerformanceTest::~CPerformanceTest() |
|
88 { |
|
89 } |
|
90 |
|
91 void CPerformanceTest::ConstructL(const TTestActionSpec& aTestActionSpec) |
|
92 { |
|
93 CTestAction::ConstructL(aTestActionSpec); |
|
94 |
|
95 // Switch on performance testing? |
|
96 TPtrC8 enablePtr = Input::ParseElement(aTestActionSpec.iActionBody, KPerformanceTestStart, KPerformanceTestEnd); |
|
97 TBool enablePerformance = VectorUtils::ParseBoolL(enablePtr); |
|
98 CPerformance::PerformanceTester()->SetTestingPerformance(enablePerformance); |
|
99 |
|
100 iExpectedResult = KErrNone; |
|
101 } |
|
102 |
|
103 void CPerformanceTest::DoPerformPrerequisite(TRequestStatus& aStatus) |
|
104 { |
|
105 TRequestStatus* status = &aStatus; |
|
106 User::RequestComplete(status, KErrNone); |
|
107 iActionState = CTestAction::EAction; |
|
108 } |
|
109 |
|
110 void CPerformanceTest::DoPerformPostrequisite(TRequestStatus& aStatus) |
|
111 { |
|
112 TRequestStatus* status = &aStatus; |
|
113 iFinished = ETrue; |
|
114 User::RequestComplete(status, KErrNone); |
|
115 } |
|
116 |
|
117 void CPerformanceTest::PerformAction(TRequestStatus& aStatus) |
|
118 { |
|
119 iResult = ETrue; |
|
120 iFinished = ETrue; |
|
121 TRequestStatus* status = &aStatus; |
|
122 User::RequestComplete(status, KErrNone); |
|
123 } |
|
124 |