1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/imagingandcamerafws/cameraunittest/src/TSU_ECM_ADV/ECamAdvTest.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,183 @@
1.4 +
1.5 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +// All rights reserved.
1.7 +// This component and the accompanying materials are made available
1.8 +// under the terms of "Eclipse Public License v1.0"
1.9 +// which accompanies this distribution, and is available
1.10 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +//
1.12 +// Initial Contributors:
1.13 +// Nokia Corporation - initial contribution.
1.14 +//
1.15 +// Contributors:
1.16 +//
1.17 +// Description:
1.18 +//
1.19 +
1.20 +#include "ECamAdvTest.h"
1.21 +#include <ecam.h>
1.22 +#include <ecam/ecamplugin.h>
1.23 +#include <ecamuids.hrh>
1.24 +
1.25 +#include <ecom/ecomresolverparams.h>
1.26 +#include "ECamUnitTestPluginUids.hrh"
1.27 +
1.28 +const TInt KEmptyKeyValue = 0;
1.29 +
1.30 +//
1.31 +// RECamTest
1.32 +//
1.33 +RECamTest* RECamTest::NewL(TBool aAllocTest)
1.34 + {
1.35 + RECamTest* self = new (ELeave) RECamTest(aAllocTest);
1.36 + return self;
1.37 + }
1.38 +
1.39 +RECamTest::RECamTest(TBool /*aAllocTest*/)
1.40 + {
1.41 + iTestStepName = _L("MM-ECM-ADV-U-003-HP");
1.42 + }
1.43 +
1.44 +TVerdict RECamTest::DoTestStepL()
1.45 + {
1.46 + TVerdict result = EPass;
1.47 + CCamera* camera = NULL;
1.48 + MCameraObserver* observer = NULL;
1.49 + MCameraObserver2* observer2 = NULL;
1.50 + TInt error = KErrNone;
1.51 +
1.52 + INFO_PRINTF1(_L("Check Opening CCam gives KErrNone"));
1.53 +
1.54 + INFO_PRINTF1(_L("Checking basic CCamera::NewL()"));
1.55 + __MM_HEAP_MARK;
1.56 + TRAP(error, camera = CCamera::NewL(*observer, 0));
1.57 + if (error!=KErrNone)
1.58 + {
1.59 + INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewL()"), error);
1.60 + if (camera != NULL)
1.61 + {
1.62 + delete camera;
1.63 + }
1.64 + result = EFail;
1.65 + }
1.66 +
1.67 + if (camera != NULL)
1.68 + {
1.69 + delete camera;
1.70 + }
1.71 +
1.72 + __MM_HEAP_MARKEND;
1.73 +
1.74 + INFO_PRINTF1(_L("Checking basic CCamera::NewDuplicateL()"));
1.75 + __MM_HEAP_MARK;
1.76 + TRAP(error, camera = CCamera::NewDuplicateL(*observer, 0));
1.77 + if (error!=KErrNone)
1.78 + {
1.79 + INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewDuplicateL()"), error);
1.80 + if (camera != NULL)
1.81 + {
1.82 + delete camera;
1.83 + }
1.84 + result = EFail;
1.85 + }
1.86 +
1.87 + if (camera != NULL)
1.88 + {
1.89 + delete camera;
1.90 + }
1.91 +
1.92 + __MM_HEAP_MARKEND;
1.93 +
1.94 + INFO_PRINTF1(_L("Checking additional \"ChunkAPI\" factory functions"));
1.95 + INFO_PRINTF1(_L("Checking CCamera::New2L()"));
1.96 + __MM_HEAP_MARK;
1.97 + TRAP(error, camera = CCamera::New2L(*observer2, 0, 0));
1.98 + if (error!=KErrNone)
1.99 + {
1.100 + INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L()"), error);
1.101 + if (camera != NULL)
1.102 + {
1.103 + delete camera;
1.104 + }
1.105 + result = EFail;
1.106 + }
1.107 +
1.108 + if (camera != NULL)
1.109 + {
1.110 + delete camera;
1.111 + }
1.112 +
1.113 + __MM_HEAP_MARKEND;
1.114 +
1.115 + INFO_PRINTF1(_L("Checking CCamera::NewDuplicate2L()"));
1.116 +
1.117 + __MM_HEAP_MARK;
1.118 +
1.119 + TRAP(error, camera = CCamera::NewDuplicate2L(*observer2, 0));
1.120 + if (error!=KErrNone)
1.121 + {
1.122 + INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewDuplicate2L()"), error);
1.123 + if (camera != NULL)
1.124 + {
1.125 + delete camera;
1.126 + }
1.127 + result = EFail;
1.128 + }
1.129 +
1.130 + if (camera != NULL)
1.131 + {
1.132 + delete camera;
1.133 + }
1.134 +
1.135 + __MM_HEAP_MARKEND;
1.136 +
1.137 + return result;
1.138 + }
1.139 +
1.140 +//
1.141 +// RECamInnerTest
1.142 +//
1.143 +
1.144 +RECamInnerTest* RECamInnerTest::NewL(TBool aAllocTest)
1.145 + {
1.146 + RECamInnerTest* self = new (ELeave) RECamInnerTest(aAllocTest);
1.147 + return self;
1.148 + }
1.149 +
1.150 +RECamInnerTest::RECamInnerTest(TBool /*aAllocTest*/)
1.151 + {
1.152 + iTestStepName = _L("MM-ECM-ADV-U-004-LP");
1.153 + }
1.154 +
1.155 +TVerdict RECamInnerTest::DoTestStepL()
1.156 + {
1.157 + INFO_PRINTF1(_L("Check can actually open ECam plugin"));
1.158 + TVerdict result = EPass;
1.159 +
1.160 + INFO_PRINTF1(_L("Open stub plugin directly"));
1.161 + {
1.162 + __MM_HEAP_MARK;
1.163 + TUid implementationUid = {KUidCameraUnitTestPlugin};
1.164 + TUid destructorKey = {KEmptyKeyValue};
1.165 + CCamera* camera = NULL;
1.166 +
1.167 + TRAPD(error,
1.168 + camera = static_cast<CCamera*>
1.169 + (REComSession::CreateImplementationL(implementationUid, destructorKey)));
1.170 +
1.171 + if (error != KErrNone)
1.172 + {
1.173 + INFO_PRINTF2(_L("CreateImplementationL() failed - %d"), error);
1.174 + result = EFail;
1.175 + }
1.176 + else
1.177 + {
1.178 + delete camera;
1.179 + REComSession::DestroyedImplementation(destructorKey);
1.180 + REComSession::FinalClose();
1.181 + }
1.182 + __MM_HEAP_MARKEND;
1.183 + }
1.184 +
1.185 + return result;
1.186 + }