author | sl@SLION-WIN7.fritz.box |
Fri, 15 Jun 2012 03:10:57 +0200 | |
changeset 0 | bde4ae8d615e |
permissions | -rw-r--r-- |
sl@0 | 1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
sl@0 | 2 |
// All rights reserved. |
sl@0 | 3 |
// This component and the accompanying materials are made available |
sl@0 | 4 |
// under the terms of the License "Eclipse Public License v1.0" |
sl@0 | 5 |
// which accompanies this distribution, and is available |
sl@0 | 6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
sl@0 | 7 |
// |
sl@0 | 8 |
// Initial Contributors: |
sl@0 | 9 |
// Nokia Corporation - initial contribution. |
sl@0 | 10 |
// |
sl@0 | 11 |
// Contributors: |
sl@0 | 12 |
// |
sl@0 | 13 |
// Description: |
sl@0 | 14 |
// @internalComponent |
sl@0 | 15 |
// |
sl@0 | 16 |
// |
sl@0 | 17 |
|
sl@0 | 18 |
|
sl@0 | 19 |
#include <e32std.h> |
sl@0 | 20 |
#include <e32std_private.h> |
sl@0 | 21 |
#include <u32std.h> // unicode builds |
sl@0 | 22 |
#include <e32base.h> |
sl@0 | 23 |
#include <e32base_private.h> |
sl@0 | 24 |
#include <e32cons.h> |
sl@0 | 25 |
#include <e32Test.h> // RTest headder |
sl@0 | 26 |
#include "testcaseroot.h" |
sl@0 | 27 |
#include "testpolicy.h" |
sl@0 | 28 |
#include "testcasefactory.h" |
sl@0 | 29 |
|
sl@0 | 30 |
|
sl@0 | 31 |
|
sl@0 | 32 |
|
sl@0 | 33 |
CBasicTestPolicy* CBasicTestPolicy::NewL() |
sl@0 | 34 |
{ |
sl@0 | 35 |
CBasicTestPolicy* self = new (ELeave) CBasicTestPolicy; |
sl@0 | 36 |
CleanupStack::PushL(self); |
sl@0 | 37 |
self->ConstructL(); |
sl@0 | 38 |
CleanupStack::Pop(self); |
sl@0 | 39 |
return self; |
sl@0 | 40 |
} |
sl@0 | 41 |
|
sl@0 | 42 |
|
sl@0 | 43 |
CBasicTestPolicy::CBasicTestPolicy() |
sl@0 | 44 |
: CActive(EPriorityStandard) |
sl@0 | 45 |
{ |
sl@0 | 46 |
CActiveScheduler::Add(this); |
sl@0 | 47 |
} |
sl@0 | 48 |
|
sl@0 | 49 |
|
sl@0 | 50 |
void CBasicTestPolicy::ConstructL() |
sl@0 | 51 |
{ |
sl@0 | 52 |
LOG_FUNC |
sl@0 | 53 |
|
sl@0 | 54 |
} |
sl@0 | 55 |
|
sl@0 | 56 |
|
sl@0 | 57 |
CBasicTestPolicy::~CBasicTestPolicy() |
sl@0 | 58 |
{ |
sl@0 | 59 |
Cancel(); |
sl@0 | 60 |
if (iTestCase) |
sl@0 | 61 |
{ |
sl@0 | 62 |
delete iTestCase; |
sl@0 | 63 |
} |
sl@0 | 64 |
} |
sl@0 | 65 |
|
sl@0 | 66 |
|
sl@0 | 67 |
/* Because the test policy can be referenced from the test case, parameters to pass to |
sl@0 | 68 |
the test-case may be stored in this class in future for access on ad-hoc basis as each test |
sl@0 | 69 |
case desires, without a need to modify all test cases |
sl@0 | 70 |
*/ |
sl@0 | 71 |
void CBasicTestPolicy::RunTestCaseL(const TDesC& aTestCaseId, TRequestStatus* aNotifierStatus) |
sl@0 | 72 |
{ |
sl@0 | 73 |
LOG_FUNC |
sl@0 | 74 |
iNotifierStatus = aNotifierStatus; |
sl@0 | 75 |
// delete previous test run |
sl@0 | 76 |
if (iTestCase) |
sl@0 | 77 |
{ |
sl@0 | 78 |
delete iTestCase; |
sl@0 | 79 |
iTestCase = NULL; |
sl@0 | 80 |
} |
sl@0 | 81 |
|
sl@0 | 82 |
// create the test class |
sl@0 | 83 |
iTestCase = RTestFactory::CreateTestCaseL(aTestCaseId); |
sl@0 | 84 |
// configure it |
sl@0 | 85 |
iTestCase->SetTestPolicy(this); |
sl@0 | 86 |
|
sl@0 | 87 |
iTestCase->DisplayTestCaseOptions(); // test preconditions and detail |
sl@0 | 88 |
|
sl@0 | 89 |
// run the test-case |
sl@0 | 90 |
iTestCase->PerformTestL(); |
sl@0 | 91 |
|
sl@0 | 92 |
*iNotifierStatus = KRequestPending; |
sl@0 | 93 |
} |
sl@0 | 94 |
|
sl@0 | 95 |
|
sl@0 | 96 |
void CBasicTestPolicy::DoCancel() |
sl@0 | 97 |
{ |
sl@0 | 98 |
iTestCase->Cancel(); |
sl@0 | 99 |
|
sl@0 | 100 |
User::RequestComplete(iNotifierStatus, KErrCancel); |
sl@0 | 101 |
} |
sl@0 | 102 |
|
sl@0 | 103 |
|
sl@0 | 104 |
void CBasicTestPolicy::SignalTestComplete(TInt aCompletionCode) |
sl@0 | 105 |
{ |
sl@0 | 106 |
if (KErrNone == aCompletionCode) |
sl@0 | 107 |
{ |
sl@0 | 108 |
// Note there is no way to pass __FILE__ __LINE__ 'in' to this 'macro' |
sl@0 | 109 |
test(ETrue); |
sl@0 | 110 |
} |
sl@0 | 111 |
else |
sl@0 | 112 |
{ |
sl@0 | 113 |
test(EFalse); // failed (PANIC here) |
sl@0 | 114 |
} |
sl@0 | 115 |
|
sl@0 | 116 |
if (iNotifierStatus) // will be null if we already signalled earlier |
sl@0 | 117 |
{ |
sl@0 | 118 |
User::RequestComplete(iNotifierStatus, aCompletionCode); |
sl@0 | 119 |
} |
sl@0 | 120 |
} |
sl@0 | 121 |
|
sl@0 | 122 |
|
sl@0 | 123 |
void CBasicTestPolicy::RunL() |
sl@0 | 124 |
{ |
sl@0 | 125 |
LOG_FUNC |
sl@0 | 126 |
|
sl@0 | 127 |
} |
sl@0 | 128 |
|
sl@0 | 129 |
|
sl@0 | 130 |
TInt CBasicTestPolicy::RunError(TInt /*aError*/) |
sl@0 | 131 |
{ |
sl@0 | 132 |
return KErrNone; |
sl@0 | 133 |
} |
sl@0 | 134 |
|
sl@0 | 135 |