sl@0: sl@0: // ECamTest.cpp sl@0: sl@0: // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include "ECamTest.h" sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include sl@0: sl@0: #include sl@0: sl@0: // sl@0: // RECamTest sl@0: // sl@0: sl@0: RECamTest* RECamTest::NewL(TBool aAllocTest) sl@0: { sl@0: RECamTest* self = new (ELeave) RECamTest(aAllocTest); sl@0: return self; sl@0: } sl@0: sl@0: RECamTest::RECamTest(TBool /*aAllocTest*/) sl@0: { sl@0: iTestStepName = _L("MM-ECM-API-U-011"); sl@0: } sl@0: sl@0: TVerdict RECamTest::DoTestStepL() sl@0: { sl@0: TVerdict result = EPass; sl@0: CCamera* camera = NULL; sl@0: 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: MCameraObserver2* observer2 = NULL; // TODO ditto sl@0: TInt error = KErrNone; sl@0: sl@0: INFO_PRINTF1(_L("Check Opening CCam gives KErrNotSupported")); sl@0: sl@0: INFO_PRINTF1(_L("Checking basic CCamera::NewL()")); sl@0: __MM_HEAP_MARK; sl@0: TRAP(error, camera = CCamera::NewL(*observer, 0)); sl@0: if (error==KErrNone) sl@0: { sl@0: INFO_PRINTF1(_L("Unexpected KErrNone return from CCamera::NewL()")); sl@0: delete camera; sl@0: result = EFail; sl@0: } sl@0: else if (error!=KErrNotSupported) sl@0: { sl@0: INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewL()"), error); sl@0: result = EFail; sl@0: } sl@0: __MM_HEAP_MARKEND; sl@0: sl@0: INFO_PRINTF1(_L("Checking basic CCamera::NewDuplicateL()")); sl@0: __MM_HEAP_MARK; sl@0: TRAP(error, camera = CCamera::NewDuplicateL(*observer, 0)); sl@0: if (error==KErrNone) sl@0: { sl@0: INFO_PRINTF1(_L("Unexpected KErrNone return from CCamera::NewDuplicateL()")); sl@0: delete camera; sl@0: result = EFail; sl@0: } sl@0: else if (error!=KErrNotSupported) sl@0: { sl@0: INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewDuplicateL()"), error); sl@0: result = EFail; sl@0: } sl@0: __MM_HEAP_MARKEND; sl@0: sl@0: INFO_PRINTF1(_L("Checking additional \"ChunkAPI\" factory functions")); sl@0: INFO_PRINTF1(_L("Checking CCamera::NewL()")); sl@0: __MM_HEAP_MARK; sl@0: TRAP(error, camera = CCamera::NewL(*observer2, 0, 0)); sl@0: if (error==KErrNone) sl@0: { sl@0: INFO_PRINTF1(_L("Unexpected KErrNone return from CCamera::NewL()")); sl@0: delete camera; sl@0: result = EFail; sl@0: } sl@0: else if (error!=KErrNotSupported) sl@0: { sl@0: INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewL()"), error); sl@0: result = EFail; sl@0: } sl@0: __MM_HEAP_MARKEND; sl@0: sl@0: INFO_PRINTF1(_L("Checking CCamera::NewDuplicateL()")); sl@0: __MM_HEAP_MARK; sl@0: TRAP(error, camera = CCamera::NewDuplicateL(*observer2, 0)); sl@0: if (error==KErrNone) sl@0: { sl@0: INFO_PRINTF1(_L("Unexpected KErrNone return from CCamera::NewDuplicateL()")); sl@0: delete camera; sl@0: result = EFail; sl@0: } sl@0: else if (error!=KErrNotSupported) sl@0: { sl@0: INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewDuplicateL()"), error); sl@0: result = EFail; sl@0: } sl@0: __MM_HEAP_MARKEND; sl@0: sl@0: INFO_PRINTF1(_L("Checking CCamera::New2L()")); sl@0: __MM_HEAP_MARK; sl@0: TRAP(error, camera = CCamera::New2L(*observer2, 0, 0)); sl@0: if (error==KErrNone) sl@0: { sl@0: INFO_PRINTF1(_L("Unexpected KErrNone return from CCamera::New2L()")); sl@0: delete camera; sl@0: result = EFail; sl@0: } sl@0: else if (error!=KErrNotSupported) sl@0: { sl@0: INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L()"), error); sl@0: result = EFail; sl@0: } sl@0: __MM_HEAP_MARKEND; sl@0: sl@0: INFO_PRINTF1(_L("Checking CCamera::NewDuplicate2L()")); sl@0: __MM_HEAP_MARK; sl@0: TRAP(error, camera = CCamera::NewDuplicate2L(*observer2, 0)); sl@0: if (error==KErrNone) sl@0: { sl@0: INFO_PRINTF1(_L("Unexpected KErrNone return from CCamera::NewDuplicate2L()")); sl@0: delete camera; sl@0: result = EFail; sl@0: } sl@0: else if (error!=KErrNotSupported) sl@0: { sl@0: INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewDuplicate2L()"), error); sl@0: result = EFail; sl@0: } sl@0: __MM_HEAP_MARKEND; sl@0: sl@0: return result; sl@0: } sl@0: sl@0: // sl@0: // RECamInnerTest sl@0: // sl@0: sl@0: RECamInnerTest* RECamInnerTest::NewL(TBool aAllocTest) sl@0: { sl@0: RECamInnerTest* self = new (ELeave) RECamInnerTest(aAllocTest); sl@0: return self; sl@0: } sl@0: sl@0: RECamInnerTest::RECamInnerTest(TBool /*aAllocTest*/) sl@0: { sl@0: iTestStepName = _L("MM-ECM-API-U-012"); sl@0: } sl@0: sl@0: TVerdict RECamInnerTest::DoTestStepL() sl@0: { sl@0: INFO_PRINTF1(_L("Check can actually open ECam plugin")); sl@0: TVerdict result = EPass; sl@0: sl@0: sl@0: INFO_PRINTF1(_L("Open stub plugin directly")); sl@0: { sl@0: __MM_HEAP_MARK; sl@0: // TODO - would be nice to actually call CCameraPlugin::NewL, but this is not exported, so this is extract sl@0: TUid implementationUid = {KUidOnboardCameraStubPlugin}; sl@0: TUid destructorKey = {0}; sl@0: CCamera* camera = NULL; sl@0: TRAPD(error, sl@0: camera = static_cast sl@0: (REComSession::CreateImplementationL(implementationUid, destructorKey))); sl@0: sl@0: if (error != KErrNone) sl@0: { sl@0: INFO_PRINTF2(_L("CreateImplementationL() failed - %d"), error); sl@0: result = EFail; sl@0: } sl@0: else sl@0: { sl@0: delete camera; sl@0: REComSession::DestroyedImplementation(destructorKey); sl@0: REComSession::FinalClose(); sl@0: } sl@0: __MM_HEAP_MARKEND; sl@0: } sl@0: sl@0: INFO_PRINTF1(_L("Open stub plugin via interface")); sl@0: { sl@0: __MM_HEAP_MARK; sl@0: // TODO - would be nice to actually call CCameraPlugin::NewL, but this is not exported, so this is extract sl@0: TUid interfaceUid = {KUidOnboardCameraPlugin}; sl@0: TUid destructorKey = {0}; sl@0: CCamera* camera = NULL; sl@0: TRAPD(error, sl@0: camera = static_cast sl@0: (MmPluginUtils::CreateImplementationL(interfaceUid, destructorKey, KECamPluginMatchString, KRomOnlyResolverUid))); sl@0: sl@0: if (error != KErrNone) sl@0: { sl@0: INFO_PRINTF2(_L("CreateImplementationL() failed - %d"), error); sl@0: result = EFail; sl@0: } sl@0: else sl@0: { sl@0: delete camera; sl@0: REComSession::DestroyedImplementation(destructorKey); sl@0: REComSession::FinalClose(); sl@0: } sl@0: __MM_HEAP_MARKEND; sl@0: } sl@0: sl@0: return result; sl@0: }