os/mm/imagingandcamerafws/cameraunittest/src/TSU_ECM_ADV/ECamInfoAdvTest.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 
     2 // ECamInfoAdvTest.cpp
     3 
     4 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     5 // All rights reserved.
     6 // This component and the accompanying materials are made available
     7 // under the terms of "Eclipse Public License v1.0"
     8 // which accompanies this distribution, and is available
     9 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    10 //
    11 // Initial Contributors:
    12 // Nokia Corporation - initial contribution.
    13 //
    14 // Contributors:
    15 //
    16 // Description:
    17 //
    18 
    19 #include <ecamuids.hrh>
    20 #include "ECamInfoAdvTest.h"
    21 #include <ecam.h>
    22 #include <ecam/ecamplugin.h>
    23 #include <ecam/ecaminfoplugin.h>
    24 #include <ecom/ecomresolverparams.h>
    25 #include "ECamUnitTestPluginUids.hrh"
    26 
    27 const TInt KInvalidNumberOfCameras = -1;
    28 const TInt KEmptyKeyValue = 0;
    29 //
    30 // RECamInfoTest
    31 //
    32 
    33 RECamInfoTest* RECamInfoTest::NewL(TBool aAllocTest)
    34 	{
    35 	RECamInfoTest* self = new (ELeave) RECamInfoTest(aAllocTest);
    36 	return self;	
    37 	}
    38 	
    39 RECamInfoTest::RECamInfoTest(TBool /*aAllocTest*/)
    40 	{
    41 	iTestStepName = _L("MM-ECM-ADV-U-001-HP");
    42 	}
    43 	
    44 TVerdict RECamInfoTest::DoTestStepL()
    45 	{
    46 	INFO_PRINTF1(_L("Check CCamera::CamerasAvailable"));
    47 	INFO_PRINTF1(_L("using static function call"));
    48 	__MM_HEAP_MARK;
    49 	TInt numCameras = CCamera::CamerasAvailable();
    50 	__MM_HEAP_MARKEND;
    51 	// the verdict
    52 	if (numCameras <= 0)
    53 		{
    54 		INFO_PRINTF2(_L("Error %d returned"), numCameras);
    55 		return EFail;
    56 		}
    57 	INFO_PRINTF2(_L("Available cameras  %d returned"), numCameras);
    58 	return EPass;
    59 	}
    60 	
    61 //
    62 // RECamInnerInfoTest
    63 //
    64 RECamInnerInfoTest* RECamInnerInfoTest::NewL(TBool aAllocTest)
    65 	{
    66 	RECamInnerInfoTest* self = new (ELeave) RECamInnerInfoTest(aAllocTest);
    67 	return self;	
    68 	}
    69 	
    70 RECamInnerInfoTest::RECamInnerInfoTest(TBool /*aAllocTest*/)
    71 	{
    72 	iTestStepName = _L("MM-ECM-ADV-U-002-LP");
    73 	}
    74 	
    75 TVerdict RECamInnerInfoTest::DoTestStepL()
    76 	{
    77 	INFO_PRINTF1(_L("Check CCameraInfoPlugin"));
    78 	INFO_PRINTF1(_L("Use CCamera::CamerasAvailable"));
    79 	TInt numCameras = KInvalidNumberOfCameras;
    80 	TVerdict result = EPass;
    81 
    82 	INFO_PRINTF1(_L("Open set plugin directly"));
    83 		
    84 	__MM_HEAP_MARK;
    85 	TUid implementationUid = {KUidCameraUnitTestInfo};
    86 	TUid destructorKey = {KEmptyKeyValue};
    87 	CCameraInfoPlugin* info = NULL;
    88 	TRAPD(error, info = static_cast<CCameraInfoPlugin*>
    89 						(REComSession::CreateImplementationL(implementationUid, destructorKey)));
    90 			
    91 	if (error != KErrNone)
    92 		{
    93 		INFO_PRINTF3(_L("CreateImplementationL InfoPlugin %x failed %d"), KUidCameraUnitTestInfo, error);
    94 		result = EFail;
    95 		}
    96 	else
    97 		{
    98 		INFO_PRINTF2(_L("CreateImplementationL InfoPlugin %x is OK"), destructorKey.iUid);
    99 
   100 		numCameras = info->CamerasAvailable();
   101 		INFO_PRINTF2(_L("Available cameras  %d returned"), numCameras);
   102 		delete info;
   103 		REComSession::DestroyedImplementation(destructorKey);
   104 		REComSession::FinalClose();
   105 		}
   106 	
   107 	// the verdict	
   108 	if (numCameras <= 0)
   109 		{
   110 		INFO_PRINTF2(_L("Error - camera %d returned"), numCameras);
   111 		result = EFail;
   112 		}	
   113 	__MM_HEAP_MARKEND;
   114 
   115 	return result;
   116 	}