os/mm/imagingandcamerafws/cameraunittest/src/TSU_ECM_ADV/ECamAdvTest.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 
     2 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 // All rights reserved.
     4 // This component and the accompanying materials are made available
     5 // under the terms of "Eclipse Public License v1.0"
     6 // which accompanies this distribution, and is available
     7 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 //
     9 // Initial Contributors:
    10 // Nokia Corporation - initial contribution.
    11 //
    12 // Contributors:
    13 //
    14 // Description:
    15 //
    16 
    17 #include "ECamAdvTest.h"
    18 #include <ecam.h>
    19 #include <ecam/ecamplugin.h>
    20 #include <ecamuids.hrh>
    21 
    22 #include <ecom/ecomresolverparams.h>
    23 #include "ECamUnitTestPluginUids.hrh"
    24 
    25 const TInt KEmptyKeyValue = 0;
    26 
    27 //
    28 // RECamTest
    29 //
    30 RECamTest* RECamTest::NewL(TBool aAllocTest)
    31 	{
    32 	RECamTest* self = new (ELeave) RECamTest(aAllocTest);
    33 	return self;	
    34 	}
    35 	
    36 RECamTest::RECamTest(TBool /*aAllocTest*/)
    37 	{
    38 	iTestStepName = _L("MM-ECM-ADV-U-003-HP");
    39 	}
    40 	
    41 TVerdict RECamTest::DoTestStepL()
    42 	{
    43 	TVerdict result = EPass;
    44 	CCamera* camera = NULL;
    45 	MCameraObserver* observer = NULL; 
    46 	MCameraObserver2* observer2 = NULL; 
    47 	TInt error = KErrNone;
    48 
    49 	INFO_PRINTF1(_L("Check Opening CCam gives KErrNone"));
    50 	
    51 	INFO_PRINTF1(_L("Checking basic CCamera::NewL()"));
    52 	__MM_HEAP_MARK;
    53 	TRAP(error, camera = CCamera::NewL(*observer, 0));
    54 	if (error!=KErrNone)
    55 		{
    56 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewL()"), error);
    57 		if (camera != NULL)
    58 			{
    59 			delete camera;
    60 			}
    61 		result = EFail;
    62 		}
    63 		
    64 	if (camera != NULL)	
    65 		{
    66 		delete camera;
    67 		}
    68 	
    69 	__MM_HEAP_MARKEND;
    70 	
    71 	INFO_PRINTF1(_L("Checking basic CCamera::NewDuplicateL()"));
    72 	__MM_HEAP_MARK;
    73 	TRAP(error, camera = CCamera::NewDuplicateL(*observer, 0));
    74 	if (error!=KErrNone)
    75 		{
    76 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewDuplicateL()"), error);
    77 		if (camera != NULL)
    78 			{
    79 			delete camera;
    80 			}
    81 		result = EFail;
    82 		}
    83 		
    84 	if (camera != NULL)	
    85 		{
    86 		delete camera;
    87 		}
    88 	
    89 	__MM_HEAP_MARKEND;
    90 	
    91 	INFO_PRINTF1(_L("Checking additional \"ChunkAPI\" factory functions"));
    92 	INFO_PRINTF1(_L("Checking CCamera::New2L()"));
    93 	__MM_HEAP_MARK;
    94 	TRAP(error, camera = CCamera::New2L(*observer2, 0, 0));
    95 	if (error!=KErrNone)
    96 		{
    97 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::New2L()"), error);
    98 		if (camera != NULL)
    99 			{
   100 			delete camera;
   101 			}
   102 		result = EFail;
   103 		}
   104 	
   105 	if (camera != NULL)	
   106 		{
   107 		delete camera;
   108 		}
   109 
   110 	__MM_HEAP_MARKEND;
   111 	
   112 	INFO_PRINTF1(_L("Checking CCamera::NewDuplicate2L()"));
   113 	
   114 	__MM_HEAP_MARK;
   115 	
   116 	TRAP(error, camera = CCamera::NewDuplicate2L(*observer2, 0));
   117 	if (error!=KErrNone)
   118 		{
   119 		INFO_PRINTF2(_L("Unexpected %d return from CCamera::NewDuplicate2L()"), error);
   120 		if (camera != NULL)
   121 			{
   122 			delete camera;
   123 			}
   124 		result = EFail;
   125 		}
   126 		
   127 	if (camera != NULL)	
   128 		{
   129 		delete camera;
   130 		}
   131 
   132 	__MM_HEAP_MARKEND;
   133 	
   134 	return result;
   135 	}
   136 	
   137 //
   138 // RECamInnerTest
   139 //
   140 
   141 RECamInnerTest* RECamInnerTest::NewL(TBool aAllocTest)
   142 	{
   143 	RECamInnerTest* self = new (ELeave) RECamInnerTest(aAllocTest);
   144 	return self;	
   145 	}
   146 	
   147 RECamInnerTest::RECamInnerTest(TBool /*aAllocTest*/)
   148 	{
   149 	iTestStepName = _L("MM-ECM-ADV-U-004-LP");
   150 	}
   151 	
   152 TVerdict RECamInnerTest::DoTestStepL()
   153 	{
   154 	INFO_PRINTF1(_L("Check can actually open ECam plugin"));
   155 	TVerdict result = EPass;
   156 
   157 	INFO_PRINTF1(_L("Open stub plugin directly"));
   158 		{
   159 		__MM_HEAP_MARK;
   160 		TUid implementationUid = {KUidCameraUnitTestPlugin};
   161 		TUid destructorKey = {KEmptyKeyValue};
   162 		CCamera* camera = NULL;
   163 		
   164 		TRAPD(error,
   165 			camera = static_cast<CCamera*>
   166 				(REComSession::CreateImplementationL(implementationUid, destructorKey)));
   167 				
   168 		if (error != KErrNone)
   169 			{
   170 			INFO_PRINTF2(_L("CreateImplementationL() failed - %d"), error);
   171 			result = EFail;
   172 			}
   173 		else
   174 			{
   175 			delete camera;
   176 			REComSession::DestroyedImplementation(destructorKey);
   177 			REComSession::FinalClose();
   178 			}
   179 		__MM_HEAP_MARKEND;
   180 		}
   181 
   182 	return result;
   183 	}