sl@0
|
1 |
|
sl@0
|
2 |
// ECamTest.cpp
|
sl@0
|
3 |
|
sl@0
|
4 |
// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
5 |
// All rights reserved.
|
sl@0
|
6 |
// This component and the accompanying materials are made available
|
sl@0
|
7 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
8 |
// which accompanies this distribution, and is available
|
sl@0
|
9 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Initial Contributors:
|
sl@0
|
12 |
// Nokia Corporation - initial contribution.
|
sl@0
|
13 |
//
|
sl@0
|
14 |
// Contributors:
|
sl@0
|
15 |
//
|
sl@0
|
16 |
// Description:
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
#include "ECamTest.h"
|
sl@0
|
20 |
#include <ecam.h>
|
sl@0
|
21 |
#include <ecam/ecamplugin.h>
|
sl@0
|
22 |
#include <ecamuids.hrh>
|
sl@0
|
23 |
|
sl@0
|
24 |
#include <ecom/ecomresolverparams.h>
|
sl@0
|
25 |
|
sl@0
|
26 |
#include <mm/mmpluginutils.h>
|
sl@0
|
27 |
|
sl@0
|
28 |
//
|
sl@0
|
29 |
// RECamTest
|
sl@0
|
30 |
//
|
sl@0
|
31 |
|
sl@0
|
32 |
RECamTest* RECamTest::NewL(TBool aAllocTest)
|
sl@0
|
33 |
{
|
sl@0
|
34 |
RECamTest* self = new (ELeave) RECamTest(aAllocTest);
|
sl@0
|
35 |
return self;
|
sl@0
|
36 |
}
|
sl@0
|
37 |
|
sl@0
|
38 |
RECamTest::RECamTest(TBool /*aAllocTest*/)
|
sl@0
|
39 |
{
|
sl@0
|
40 |
iTestStepName = _L("MM-ECM-API-U-011");
|
sl@0
|
41 |
}
|
sl@0
|
42 |
|
sl@0
|
43 |
TVerdict RECamTest::DoTestStepL()
|
sl@0
|
44 |
{
|
sl@0
|
45 |
TVerdict result = EPass;
|
sl@0
|
46 |
CCamera* camera = NULL;
|
sl@0
|
47 |
MCameraObserver* observer = NULL; // should not be used, so pass silly value. TODO make this an MCameraObserver, or arrange would not KernExec3 on real plugin
|
sl@0
|
48 |
MCameraObserver2* observer2 = NULL; // TODO ditto
|
sl@0
|
49 |
TInt error = KErrNone;
|
sl@0
|
50 |
|
sl@0
|
51 |
INFO_PRINTF1(_L("Check Opening CCam gives KErrNotSupported"));
|
sl@0
|
52 |
|
sl@0
|
53 |
INFO_PRINTF1(_L("Checking basic CCamera::NewL()"));
|
sl@0
|
54 |
__MM_HEAP_MARK;
|
sl@0
|
55 |
TRAP(error, camera = CCamera::NewL(*observer, 0));
|
sl@0
|
56 |
if (error==KErrNone)
|
sl@0
|
57 |
{
|
sl@0
|
58 |
INFO_PRINTF1(_L("Unexpected KErrNone return from CCamera::NewL()"));
|
sl@0
|
59 |
delete camera;
|
sl@0
|
60 |
result = EFail;
|
sl@0
|
61 |
}
|
sl@0
|
62 |
else if (error!=KErrNotSupported)
|
sl@0
|
63 |
{
|
sl@0
|
64 |
INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewL()"), error);
|
sl@0
|
65 |
result = EFail;
|
sl@0
|
66 |
}
|
sl@0
|
67 |
__MM_HEAP_MARKEND;
|
sl@0
|
68 |
|
sl@0
|
69 |
INFO_PRINTF1(_L("Checking basic CCamera::NewDuplicateL()"));
|
sl@0
|
70 |
__MM_HEAP_MARK;
|
sl@0
|
71 |
TRAP(error, camera = CCamera::NewDuplicateL(*observer, 0));
|
sl@0
|
72 |
if (error==KErrNone)
|
sl@0
|
73 |
{
|
sl@0
|
74 |
INFO_PRINTF1(_L("Unexpected KErrNone return from CCamera::NewDuplicateL()"));
|
sl@0
|
75 |
delete camera;
|
sl@0
|
76 |
result = EFail;
|
sl@0
|
77 |
}
|
sl@0
|
78 |
else if (error!=KErrNotSupported)
|
sl@0
|
79 |
{
|
sl@0
|
80 |
INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewDuplicateL()"), error);
|
sl@0
|
81 |
result = EFail;
|
sl@0
|
82 |
}
|
sl@0
|
83 |
__MM_HEAP_MARKEND;
|
sl@0
|
84 |
|
sl@0
|
85 |
INFO_PRINTF1(_L("Checking additional \"ChunkAPI\" factory functions"));
|
sl@0
|
86 |
INFO_PRINTF1(_L("Checking CCamera::NewL()"));
|
sl@0
|
87 |
__MM_HEAP_MARK;
|
sl@0
|
88 |
TRAP(error, camera = CCamera::NewL(*observer2, 0, 0));
|
sl@0
|
89 |
if (error==KErrNone)
|
sl@0
|
90 |
{
|
sl@0
|
91 |
INFO_PRINTF1(_L("Unexpected KErrNone return from CCamera::NewL()"));
|
sl@0
|
92 |
delete camera;
|
sl@0
|
93 |
result = EFail;
|
sl@0
|
94 |
}
|
sl@0
|
95 |
else if (error!=KErrNotSupported)
|
sl@0
|
96 |
{
|
sl@0
|
97 |
INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewL()"), error);
|
sl@0
|
98 |
result = EFail;
|
sl@0
|
99 |
}
|
sl@0
|
100 |
__MM_HEAP_MARKEND;
|
sl@0
|
101 |
|
sl@0
|
102 |
INFO_PRINTF1(_L("Checking CCamera::NewDuplicateL()"));
|
sl@0
|
103 |
__MM_HEAP_MARK;
|
sl@0
|
104 |
TRAP(error, camera = CCamera::NewDuplicateL(*observer2, 0));
|
sl@0
|
105 |
if (error==KErrNone)
|
sl@0
|
106 |
{
|
sl@0
|
107 |
INFO_PRINTF1(_L("Unexpected KErrNone return from CCamera::NewDuplicateL()"));
|
sl@0
|
108 |
delete camera;
|
sl@0
|
109 |
result = EFail;
|
sl@0
|
110 |
}
|
sl@0
|
111 |
else if (error!=KErrNotSupported)
|
sl@0
|
112 |
{
|
sl@0
|
113 |
INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewDuplicateL()"), error);
|
sl@0
|
114 |
result = EFail;
|
sl@0
|
115 |
}
|
sl@0
|
116 |
__MM_HEAP_MARKEND;
|
sl@0
|
117 |
|
sl@0
|
118 |
INFO_PRINTF1(_L("Checking CCamera::New2L()"));
|
sl@0
|
119 |
__MM_HEAP_MARK;
|
sl@0
|
120 |
TRAP(error, camera = CCamera::New2L(*observer2, 0, 0));
|
sl@0
|
121 |
if (error==KErrNone)
|
sl@0
|
122 |
{
|
sl@0
|
123 |
INFO_PRINTF1(_L("Unexpected KErrNone return from CCamera::New2L()"));
|
sl@0
|
124 |
delete camera;
|
sl@0
|
125 |
result = EFail;
|
sl@0
|
126 |
}
|
sl@0
|
127 |
else if (error!=KErrNotSupported)
|
sl@0
|
128 |
{
|
sl@0
|
129 |
INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L()"), error);
|
sl@0
|
130 |
result = EFail;
|
sl@0
|
131 |
}
|
sl@0
|
132 |
__MM_HEAP_MARKEND;
|
sl@0
|
133 |
|
sl@0
|
134 |
INFO_PRINTF1(_L("Checking CCamera::NewDuplicate2L()"));
|
sl@0
|
135 |
__MM_HEAP_MARK;
|
sl@0
|
136 |
TRAP(error, camera = CCamera::NewDuplicate2L(*observer2, 0));
|
sl@0
|
137 |
if (error==KErrNone)
|
sl@0
|
138 |
{
|
sl@0
|
139 |
INFO_PRINTF1(_L("Unexpected KErrNone return from CCamera::NewDuplicate2L()"));
|
sl@0
|
140 |
delete camera;
|
sl@0
|
141 |
result = EFail;
|
sl@0
|
142 |
}
|
sl@0
|
143 |
else if (error!=KErrNotSupported)
|
sl@0
|
144 |
{
|
sl@0
|
145 |
INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewDuplicate2L()"), error);
|
sl@0
|
146 |
result = EFail;
|
sl@0
|
147 |
}
|
sl@0
|
148 |
__MM_HEAP_MARKEND;
|
sl@0
|
149 |
|
sl@0
|
150 |
return result;
|
sl@0
|
151 |
}
|
sl@0
|
152 |
|
sl@0
|
153 |
//
|
sl@0
|
154 |
// RECamInnerTest
|
sl@0
|
155 |
//
|
sl@0
|
156 |
|
sl@0
|
157 |
RECamInnerTest* RECamInnerTest::NewL(TBool aAllocTest)
|
sl@0
|
158 |
{
|
sl@0
|
159 |
RECamInnerTest* self = new (ELeave) RECamInnerTest(aAllocTest);
|
sl@0
|
160 |
return self;
|
sl@0
|
161 |
}
|
sl@0
|
162 |
|
sl@0
|
163 |
RECamInnerTest::RECamInnerTest(TBool /*aAllocTest*/)
|
sl@0
|
164 |
{
|
sl@0
|
165 |
iTestStepName = _L("MM-ECM-API-U-012");
|
sl@0
|
166 |
}
|
sl@0
|
167 |
|
sl@0
|
168 |
TVerdict RECamInnerTest::DoTestStepL()
|
sl@0
|
169 |
{
|
sl@0
|
170 |
INFO_PRINTF1(_L("Check can actually open ECam plugin"));
|
sl@0
|
171 |
TVerdict result = EPass;
|
sl@0
|
172 |
|
sl@0
|
173 |
|
sl@0
|
174 |
INFO_PRINTF1(_L("Open stub plugin directly"));
|
sl@0
|
175 |
{
|
sl@0
|
176 |
__MM_HEAP_MARK;
|
sl@0
|
177 |
// TODO - would be nice to actually call CCameraPlugin::NewL, but this is not exported, so this is extract
|
sl@0
|
178 |
TUid implementationUid = {KUidOnboardCameraStubPlugin};
|
sl@0
|
179 |
TUid destructorKey = {0};
|
sl@0
|
180 |
CCamera* camera = NULL;
|
sl@0
|
181 |
TRAPD(error,
|
sl@0
|
182 |
camera = static_cast<CCamera*>
|
sl@0
|
183 |
(REComSession::CreateImplementationL(implementationUid, destructorKey)));
|
sl@0
|
184 |
|
sl@0
|
185 |
if (error != KErrNone)
|
sl@0
|
186 |
{
|
sl@0
|
187 |
INFO_PRINTF2(_L("CreateImplementationL() failed - %d"), error);
|
sl@0
|
188 |
result = EFail;
|
sl@0
|
189 |
}
|
sl@0
|
190 |
else
|
sl@0
|
191 |
{
|
sl@0
|
192 |
delete camera;
|
sl@0
|
193 |
REComSession::DestroyedImplementation(destructorKey);
|
sl@0
|
194 |
REComSession::FinalClose();
|
sl@0
|
195 |
}
|
sl@0
|
196 |
__MM_HEAP_MARKEND;
|
sl@0
|
197 |
}
|
sl@0
|
198 |
|
sl@0
|
199 |
INFO_PRINTF1(_L("Open stub plugin via interface"));
|
sl@0
|
200 |
{
|
sl@0
|
201 |
__MM_HEAP_MARK;
|
sl@0
|
202 |
// TODO - would be nice to actually call CCameraPlugin::NewL, but this is not exported, so this is extract
|
sl@0
|
203 |
TUid interfaceUid = {KUidOnboardCameraPlugin};
|
sl@0
|
204 |
TUid destructorKey = {0};
|
sl@0
|
205 |
CCamera* camera = NULL;
|
sl@0
|
206 |
TRAPD(error,
|
sl@0
|
207 |
camera = static_cast<CCamera*>
|
sl@0
|
208 |
(MmPluginUtils::CreateImplementationL(interfaceUid, destructorKey, KECamPluginMatchString, KRomOnlyResolverUid)));
|
sl@0
|
209 |
|
sl@0
|
210 |
if (error != KErrNone)
|
sl@0
|
211 |
{
|
sl@0
|
212 |
INFO_PRINTF2(_L("CreateImplementationL() failed - %d"), error);
|
sl@0
|
213 |
result = EFail;
|
sl@0
|
214 |
}
|
sl@0
|
215 |
else
|
sl@0
|
216 |
{
|
sl@0
|
217 |
delete camera;
|
sl@0
|
218 |
REComSession::DestroyedImplementation(destructorKey);
|
sl@0
|
219 |
REComSession::FinalClose();
|
sl@0
|
220 |
}
|
sl@0
|
221 |
__MM_HEAP_MARKEND;
|
sl@0
|
222 |
}
|
sl@0
|
223 |
|
sl@0
|
224 |
return result;
|
sl@0
|
225 |
}
|