os/mm/imagingandcamerafws/cameraunittest/src/TSU_ECM_ADV/ECamInfoAdvTest.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
sl@0
     2
// ECamInfoAdvTest.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 <ecamuids.hrh>
sl@0
    20
#include "ECamInfoAdvTest.h"
sl@0
    21
#include <ecam.h>
sl@0
    22
#include <ecam/ecamplugin.h>
sl@0
    23
#include <ecam/ecaminfoplugin.h>
sl@0
    24
#include <ecom/ecomresolverparams.h>
sl@0
    25
#include "ECamUnitTestPluginUids.hrh"
sl@0
    26
sl@0
    27
const TInt KInvalidNumberOfCameras = -1;
sl@0
    28
const TInt KEmptyKeyValue = 0;
sl@0
    29
//
sl@0
    30
// RECamInfoTest
sl@0
    31
//
sl@0
    32
sl@0
    33
RECamInfoTest* RECamInfoTest::NewL(TBool aAllocTest)
sl@0
    34
	{
sl@0
    35
	RECamInfoTest* self = new (ELeave) RECamInfoTest(aAllocTest);
sl@0
    36
	return self;	
sl@0
    37
	}
sl@0
    38
	
sl@0
    39
RECamInfoTest::RECamInfoTest(TBool /*aAllocTest*/)
sl@0
    40
	{
sl@0
    41
	iTestStepName = _L("MM-ECM-ADV-U-001-HP");
sl@0
    42
	}
sl@0
    43
	
sl@0
    44
TVerdict RECamInfoTest::DoTestStepL()
sl@0
    45
	{
sl@0
    46
	INFO_PRINTF1(_L("Check CCamera::CamerasAvailable"));
sl@0
    47
	INFO_PRINTF1(_L("using static function call"));
sl@0
    48
	__MM_HEAP_MARK;
sl@0
    49
	TInt numCameras = CCamera::CamerasAvailable();
sl@0
    50
	__MM_HEAP_MARKEND;
sl@0
    51
	// the verdict
sl@0
    52
	if (numCameras <= 0)
sl@0
    53
		{
sl@0
    54
		INFO_PRINTF2(_L("Error %d returned"), numCameras);
sl@0
    55
		return EFail;
sl@0
    56
		}
sl@0
    57
	INFO_PRINTF2(_L("Available cameras  %d returned"), numCameras);
sl@0
    58
	return EPass;
sl@0
    59
	}
sl@0
    60
	
sl@0
    61
//
sl@0
    62
// RECamInnerInfoTest
sl@0
    63
//
sl@0
    64
RECamInnerInfoTest* RECamInnerInfoTest::NewL(TBool aAllocTest)
sl@0
    65
	{
sl@0
    66
	RECamInnerInfoTest* self = new (ELeave) RECamInnerInfoTest(aAllocTest);
sl@0
    67
	return self;	
sl@0
    68
	}
sl@0
    69
	
sl@0
    70
RECamInnerInfoTest::RECamInnerInfoTest(TBool /*aAllocTest*/)
sl@0
    71
	{
sl@0
    72
	iTestStepName = _L("MM-ECM-ADV-U-002-LP");
sl@0
    73
	}
sl@0
    74
	
sl@0
    75
TVerdict RECamInnerInfoTest::DoTestStepL()
sl@0
    76
	{
sl@0
    77
	INFO_PRINTF1(_L("Check CCameraInfoPlugin"));
sl@0
    78
	INFO_PRINTF1(_L("Use CCamera::CamerasAvailable"));
sl@0
    79
	TInt numCameras = KInvalidNumberOfCameras;
sl@0
    80
	TVerdict result = EPass;
sl@0
    81
sl@0
    82
	INFO_PRINTF1(_L("Open set plugin directly"));
sl@0
    83
		
sl@0
    84
	__MM_HEAP_MARK;
sl@0
    85
	TUid implementationUid = {KUidCameraUnitTestInfo};
sl@0
    86
	TUid destructorKey = {KEmptyKeyValue};
sl@0
    87
	CCameraInfoPlugin* info = NULL;
sl@0
    88
	TRAPD(error, info = static_cast<CCameraInfoPlugin*>
sl@0
    89
						(REComSession::CreateImplementationL(implementationUid, destructorKey)));
sl@0
    90
			
sl@0
    91
	if (error != KErrNone)
sl@0
    92
		{
sl@0
    93
		INFO_PRINTF3(_L("CreateImplementationL InfoPlugin %x failed %d"), KUidCameraUnitTestInfo, error);
sl@0
    94
		result = EFail;
sl@0
    95
		}
sl@0
    96
	else
sl@0
    97
		{
sl@0
    98
		INFO_PRINTF2(_L("CreateImplementationL InfoPlugin %x is OK"), destructorKey.iUid);
sl@0
    99
sl@0
   100
		numCameras = info->CamerasAvailable();
sl@0
   101
		INFO_PRINTF2(_L("Available cameras  %d returned"), numCameras);
sl@0
   102
		delete info;
sl@0
   103
		REComSession::DestroyedImplementation(destructorKey);
sl@0
   104
		REComSession::FinalClose();
sl@0
   105
		}
sl@0
   106
	
sl@0
   107
	// the verdict	
sl@0
   108
	if (numCameras <= 0)
sl@0
   109
		{
sl@0
   110
		INFO_PRINTF2(_L("Error - camera %d returned"), numCameras);
sl@0
   111
		result = EFail;
sl@0
   112
		}	
sl@0
   113
	__MM_HEAP_MARKEND;
sl@0
   114
sl@0
   115
	return result;
sl@0
   116
	}