os/mm/imagingandcamerafws/cameraunittest/src/ecamreservetest.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
sl@0
     2
// ecamreservetest.cpp
sl@0
     3
sl@0
     4
// Copyright (c) 2007-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 "ecamreservetest.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
#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
sl@0
    28
#include <ecamconst.h>
sl@0
    29
#endif
sl@0
    30
sl@0
    31
//max. no. of camera slots =8
sl@0
    32
static const TInt KECamUnitTestMaxCameraIndex = 8;
sl@0
    33
sl@0
    34
//
sl@0
    35
// RECamReserveTest
sl@0
    36
//
sl@0
    37
sl@0
    38
RECamReserveTest* RECamReserveTest::NewL(TBool aAllocTest)
sl@0
    39
	{
sl@0
    40
	RECamReserveTest* self = new (ELeave) RECamReserveTest(aAllocTest);
sl@0
    41
	return self;	
sl@0
    42
	}
sl@0
    43
	
sl@0
    44
RECamReserveTest::RECamReserveTest(TBool /*aAllocTest*/)
sl@0
    45
	{
sl@0
    46
	iTestStepName = _L("MM-ECM-API-U-013");
sl@0
    47
	}
sl@0
    48
	
sl@0
    49
TVerdict RECamReserveTest::DoTestStepL()
sl@0
    50
	{
sl@0
    51
	TVerdict result = EPass;
sl@0
    52
	
sl@0
    53
	INFO_PRINTF1(_L("Checking Reserve Subscription"));
sl@0
    54
	__MM_HEAP_MARK;
sl@0
    55
	
sl@0
    56
	for(TInt index=0; index<(KECamUnitTestMaxCameraIndex+1); index++)
sl@0
    57
		{
sl@0
    58
		MReserveObserver* reserveObserver=NULL;
sl@0
    59
		CCameraStatusWatch* cameraStatusWatch = NULL;
sl@0
    60
sl@0
    61
		// create and install the active scheduler we need
sl@0
    62
		INFO_PRINTF1(_L("Create and install active Scheduler"));
sl@0
    63
		CActiveScheduler* activeScheduler = new(ELeave) CActiveScheduler;
sl@0
    64
		CleanupStack::PushL(activeScheduler);
sl@0
    65
		CActiveScheduler::Install(activeScheduler);
sl@0
    66
sl@0
    67
		INFO_PRINTF1(_L("SubscribeReserveInfoL and hence create CCameraStatusWatch object"));
sl@0
    68
		TRAPD(err, TReservedInfo::SubscribeReserveInfoL(*reserveObserver, index, cameraStatusWatch));
sl@0
    69
		if(index == KECamUnitTestMaxCameraIndex)
sl@0
    70
			{
sl@0
    71
			if(err != KErrArgument)
sl@0
    72
				{
sl@0
    73
				INFO_PRINTF2(_L("Checking Reserve Subscription: Error %d is unexpected!"), err);
sl@0
    74
				result = EFail;
sl@0
    75
				}
sl@0
    76
			}
sl@0
    77
		else
sl@0
    78
			{
sl@0
    79
			if(err != KErrNone)
sl@0
    80
				{
sl@0
    81
				INFO_PRINTF2(_L("Checking Reserve Subscription: Error %d is unexpected!"), err);
sl@0
    82
				result = EFail;
sl@0
    83
				}	
sl@0
    84
			}
sl@0
    85
	
sl@0
    86
		INFO_PRINTF1(_L("destroy the CCameraStatusWatch object"));
sl@0
    87
		delete cameraStatusWatch;
sl@0
    88
sl@0
    89
		INFO_PRINTF1(_L("destroy the activeScheduler"));
sl@0
    90
		CleanupStack::PopAndDestroy(activeScheduler);
sl@0
    91
		}
sl@0
    92
		
sl@0
    93
	__MM_HEAP_MARKEND;
sl@0
    94
	
sl@0
    95
	return result;
sl@0
    96
	}