|
1 /* |
|
2 * Copyright (c) 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 "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 #include "omxxmltestwrapper.h" |
|
20 #include "omxxmltestrunner.h" |
|
21 |
|
22 // SCRIPT commands |
|
23 _LIT(KNewCmd, "New"); |
|
24 _LIT(KRunTestCmd, "RunTest"); |
|
25 |
|
26 COmxXmlTestWrapper* COmxXmlTestWrapper::NewL() |
|
27 { |
|
28 COmxXmlTestWrapper* self = new(ELeave) COmxXmlTestWrapper(); |
|
29 CleanupStack::PushL(self); |
|
30 self->ConstructL(); |
|
31 CleanupStack::Pop(self); |
|
32 return self; |
|
33 } |
|
34 |
|
35 COmxXmlTestWrapper::COmxXmlTestWrapper() |
|
36 { |
|
37 |
|
38 } |
|
39 |
|
40 void COmxXmlTestWrapper::ConstructL() |
|
41 { |
|
42 iActiveCallback = CActiveCallback::NewL(*this); |
|
43 } |
|
44 |
|
45 COmxXmlTestWrapper::~COmxXmlTestWrapper() |
|
46 { |
|
47 delete iTestRunner; |
|
48 delete iActiveCallback; |
|
49 } |
|
50 |
|
51 TBool COmxXmlTestWrapper::DoCommandL(const TTEFFunction& aCommand, |
|
52 const TTEFSectionName& aSection, |
|
53 const TInt /*aAsyncErrorIndex*/) |
|
54 { |
|
55 TBool ret = ETrue; |
|
56 TInt err = KErrNone; |
|
57 if(aCommand == KNewCmd()) |
|
58 { |
|
59 // XML file name is specified in aSection |
|
60 TRAP(err, DoNewCmdL(aSection)); |
|
61 } |
|
62 else if(aCommand == KRunTestCmd()) |
|
63 { |
|
64 // XML section name is specified in aSection |
|
65 TRAP(err, DoRunTestCmdL(aSection)); |
|
66 } |
|
67 else |
|
68 { |
|
69 ERR_PRINTF2(_L("Unrecognized command %S"), &aCommand); |
|
70 ret = EFalse; |
|
71 } |
|
72 |
|
73 if(err != KErrNone) |
|
74 { |
|
75 ret = EFalse; |
|
76 } |
|
77 |
|
78 return ret; |
|
79 } |
|
80 |
|
81 TAny* COmxXmlTestWrapper::GetObject() |
|
82 { |
|
83 return iTestRunner; |
|
84 } |
|
85 |
|
86 void COmxXmlTestWrapper::DoNewCmdL(const TDesC& aFilename) |
|
87 { |
|
88 COmxXmlTestRunner* newRunner = COmxXmlTestRunner::NewL(Logger()); |
|
89 CleanupStack::PushL(newRunner); |
|
90 newRunner->SetFilenameL(aFilename); |
|
91 CleanupStack::Pop(newRunner); |
|
92 delete iTestRunner; |
|
93 iTestRunner = newRunner; |
|
94 } |
|
95 |
|
96 void COmxXmlTestWrapper::DoRunTestCmdL(const TDesC& aSectionName) |
|
97 { |
|
98 iTestRunner->RunTestL(aSectionName); |
|
99 } |
|
100 |
|
101 void COmxXmlTestWrapper::RunL(CActive* aActive, TInt aIndex) |
|
102 { |
|
103 TInt err = aActive->iStatus.Int(); |
|
104 SetAsyncError(aIndex, err); |
|
105 DecOutstanding(); |
|
106 } |