1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/imagingandcamerafws/cameraunittest/src/TSU_ECM_ADV/ECamInfoAdvTest.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,116 @@
1.4 +
1.5 +// ECamInfoAdvTest.cpp
1.6 +
1.7 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
1.8 +// All rights reserved.
1.9 +// This component and the accompanying materials are made available
1.10 +// under the terms of "Eclipse Public License v1.0"
1.11 +// which accompanies this distribution, and is available
1.12 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.13 +//
1.14 +// Initial Contributors:
1.15 +// Nokia Corporation - initial contribution.
1.16 +//
1.17 +// Contributors:
1.18 +//
1.19 +// Description:
1.20 +//
1.21 +
1.22 +#include <ecamuids.hrh>
1.23 +#include "ECamInfoAdvTest.h"
1.24 +#include <ecam.h>
1.25 +#include <ecam/ecamplugin.h>
1.26 +#include <ecam/ecaminfoplugin.h>
1.27 +#include <ecom/ecomresolverparams.h>
1.28 +#include "ECamUnitTestPluginUids.hrh"
1.29 +
1.30 +const TInt KInvalidNumberOfCameras = -1;
1.31 +const TInt KEmptyKeyValue = 0;
1.32 +//
1.33 +// RECamInfoTest
1.34 +//
1.35 +
1.36 +RECamInfoTest* RECamInfoTest::NewL(TBool aAllocTest)
1.37 + {
1.38 + RECamInfoTest* self = new (ELeave) RECamInfoTest(aAllocTest);
1.39 + return self;
1.40 + }
1.41 +
1.42 +RECamInfoTest::RECamInfoTest(TBool /*aAllocTest*/)
1.43 + {
1.44 + iTestStepName = _L("MM-ECM-ADV-U-001-HP");
1.45 + }
1.46 +
1.47 +TVerdict RECamInfoTest::DoTestStepL()
1.48 + {
1.49 + INFO_PRINTF1(_L("Check CCamera::CamerasAvailable"));
1.50 + INFO_PRINTF1(_L("using static function call"));
1.51 + __MM_HEAP_MARK;
1.52 + TInt numCameras = CCamera::CamerasAvailable();
1.53 + __MM_HEAP_MARKEND;
1.54 + // the verdict
1.55 + if (numCameras <= 0)
1.56 + {
1.57 + INFO_PRINTF2(_L("Error %d returned"), numCameras);
1.58 + return EFail;
1.59 + }
1.60 + INFO_PRINTF2(_L("Available cameras %d returned"), numCameras);
1.61 + return EPass;
1.62 + }
1.63 +
1.64 +//
1.65 +// RECamInnerInfoTest
1.66 +//
1.67 +RECamInnerInfoTest* RECamInnerInfoTest::NewL(TBool aAllocTest)
1.68 + {
1.69 + RECamInnerInfoTest* self = new (ELeave) RECamInnerInfoTest(aAllocTest);
1.70 + return self;
1.71 + }
1.72 +
1.73 +RECamInnerInfoTest::RECamInnerInfoTest(TBool /*aAllocTest*/)
1.74 + {
1.75 + iTestStepName = _L("MM-ECM-ADV-U-002-LP");
1.76 + }
1.77 +
1.78 +TVerdict RECamInnerInfoTest::DoTestStepL()
1.79 + {
1.80 + INFO_PRINTF1(_L("Check CCameraInfoPlugin"));
1.81 + INFO_PRINTF1(_L("Use CCamera::CamerasAvailable"));
1.82 + TInt numCameras = KInvalidNumberOfCameras;
1.83 + TVerdict result = EPass;
1.84 +
1.85 + INFO_PRINTF1(_L("Open set plugin directly"));
1.86 +
1.87 + __MM_HEAP_MARK;
1.88 + TUid implementationUid = {KUidCameraUnitTestInfo};
1.89 + TUid destructorKey = {KEmptyKeyValue};
1.90 + CCameraInfoPlugin* info = NULL;
1.91 + TRAPD(error, info = static_cast<CCameraInfoPlugin*>
1.92 + (REComSession::CreateImplementationL(implementationUid, destructorKey)));
1.93 +
1.94 + if (error != KErrNone)
1.95 + {
1.96 + INFO_PRINTF3(_L("CreateImplementationL InfoPlugin %x failed %d"), KUidCameraUnitTestInfo, error);
1.97 + result = EFail;
1.98 + }
1.99 + else
1.100 + {
1.101 + INFO_PRINTF2(_L("CreateImplementationL InfoPlugin %x is OK"), destructorKey.iUid);
1.102 +
1.103 + numCameras = info->CamerasAvailable();
1.104 + INFO_PRINTF2(_L("Available cameras %d returned"), numCameras);
1.105 + delete info;
1.106 + REComSession::DestroyedImplementation(destructorKey);
1.107 + REComSession::FinalClose();
1.108 + }
1.109 +
1.110 + // the verdict
1.111 + if (numCameras <= 0)
1.112 + {
1.113 + INFO_PRINTF2(_L("Error - camera %d returned"), numCameras);
1.114 + result = EFail;
1.115 + }
1.116 + __MM_HEAP_MARKEND;
1.117 +
1.118 + return result;
1.119 + }