0
|
1 |
// Copyright (c) 2007-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 the License "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 |
// @internalComponent
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
|
|
19 |
#include <e32std.h>
|
|
20 |
#include <e32std_private.h>
|
|
21 |
#include <u32std.h> // unicode builds
|
|
22 |
#include <e32base.h>
|
|
23 |
#include <e32base_private.h>
|
|
24 |
#include <e32cons.h>
|
|
25 |
#include <e32Test.h> // RTest headder
|
|
26 |
#include "testcaseroot.h"
|
|
27 |
#include "testpolicy.h"
|
|
28 |
#include "testcasefactory.h"
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
CBasicTestPolicy* CBasicTestPolicy::NewL()
|
|
34 |
{
|
|
35 |
CBasicTestPolicy* self = new (ELeave) CBasicTestPolicy;
|
|
36 |
CleanupStack::PushL(self);
|
|
37 |
self->ConstructL();
|
|
38 |
CleanupStack::Pop(self);
|
|
39 |
return self;
|
|
40 |
}
|
|
41 |
|
|
42 |
|
|
43 |
CBasicTestPolicy::CBasicTestPolicy()
|
|
44 |
: CActive(EPriorityStandard)
|
|
45 |
{
|
|
46 |
CActiveScheduler::Add(this);
|
|
47 |
}
|
|
48 |
|
|
49 |
|
|
50 |
void CBasicTestPolicy::ConstructL()
|
|
51 |
{
|
|
52 |
LOG_FUNC
|
|
53 |
|
|
54 |
}
|
|
55 |
|
|
56 |
|
|
57 |
CBasicTestPolicy::~CBasicTestPolicy()
|
|
58 |
{
|
|
59 |
Cancel();
|
|
60 |
if (iTestCase)
|
|
61 |
{
|
|
62 |
delete iTestCase;
|
|
63 |
}
|
|
64 |
}
|
|
65 |
|
|
66 |
|
|
67 |
/* Because the test policy can be referenced from the test case, parameters to pass to
|
|
68 |
the test-case may be stored in this class in future for access on ad-hoc basis as each test
|
|
69 |
case desires, without a need to modify all test cases
|
|
70 |
*/
|
|
71 |
void CBasicTestPolicy::RunTestCaseL(const TDesC& aTestCaseId, TRequestStatus* aNotifierStatus)
|
|
72 |
{
|
|
73 |
LOG_FUNC
|
|
74 |
iNotifierStatus = aNotifierStatus;
|
|
75 |
// delete previous test run
|
|
76 |
if (iTestCase)
|
|
77 |
{
|
|
78 |
delete iTestCase;
|
|
79 |
iTestCase = NULL;
|
|
80 |
}
|
|
81 |
|
|
82 |
// create the test class
|
|
83 |
iTestCase = RTestFactory::CreateTestCaseL(aTestCaseId);
|
|
84 |
// configure it
|
|
85 |
iTestCase->SetTestPolicy(this);
|
|
86 |
|
|
87 |
iTestCase->DisplayTestCaseOptions(); // test preconditions and detail
|
|
88 |
|
|
89 |
// run the test-case
|
|
90 |
iTestCase->PerformTestL();
|
|
91 |
|
|
92 |
*iNotifierStatus = KRequestPending;
|
|
93 |
}
|
|
94 |
|
|
95 |
|
|
96 |
void CBasicTestPolicy::DoCancel()
|
|
97 |
{
|
|
98 |
iTestCase->Cancel();
|
|
99 |
|
|
100 |
User::RequestComplete(iNotifierStatus, KErrCancel);
|
|
101 |
}
|
|
102 |
|
|
103 |
|
|
104 |
void CBasicTestPolicy::SignalTestComplete(TInt aCompletionCode)
|
|
105 |
{
|
|
106 |
if (KErrNone == aCompletionCode)
|
|
107 |
{
|
|
108 |
// Note there is no way to pass __FILE__ __LINE__ 'in' to this 'macro'
|
|
109 |
test(ETrue);
|
|
110 |
}
|
|
111 |
else
|
|
112 |
{
|
|
113 |
test(EFalse); // failed (PANIC here)
|
|
114 |
}
|
|
115 |
|
|
116 |
if (iNotifierStatus) // will be null if we already signalled earlier
|
|
117 |
{
|
|
118 |
User::RequestComplete(iNotifierStatus, aCompletionCode);
|
|
119 |
}
|
|
120 |
}
|
|
121 |
|
|
122 |
|
|
123 |
void CBasicTestPolicy::RunL()
|
|
124 |
{
|
|
125 |
LOG_FUNC
|
|
126 |
|
|
127 |
}
|
|
128 |
|
|
129 |
|
|
130 |
TInt CBasicTestPolicy::RunError(TInt /*aError*/)
|
|
131 |
{
|
|
132 |
return KErrNone;
|
|
133 |
}
|
|
134 |
|
|
135 |
|