mmlibs/mmfw/tsrc/mmfintegrationtest/vclnt/src/OpenFileByHandle0036.cpp
author hgs
Wed, 13 Oct 2010 12:45:32 +0100
changeset 2 5c1df44f2eed
parent 0 b8ed18f6c07b
permissions -rw-r--r--
2010wk42_01
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     1
// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     2
// All rights reserved.
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     3
// This component and the accompanying materials are made available
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     5
// which accompanies this distribution, and is available
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     7
//
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     8
// Initial Contributors:
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    10
//
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    11
// Contributors:
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    12
//
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    13
// Description:
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    14
//
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    15
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    16
#include "TestPlayer.h"
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    17
#include "OpenFileByHandle0036.h"
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    18
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    19
#include <caf/caf.h>
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    20
#include <ecom/ecom.h>
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    21
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    22
/**
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    23
 * Constructor
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    24
 */
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    25
CTestMmfVclntOpenFile0036::CTestMmfVclntOpenFile0036(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    26
	:CTestMmfVclntOpenFile0034(aTestName, aSectName, aKeyName, aPlay)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    27
	{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    28
	}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    29
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    30
CTestMmfVclntOpenFile0036* CTestMmfVclntOpenFile0036::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    31
	{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    32
	CTestMmfVclntOpenFile0036* self = new (ELeave) CTestMmfVclntOpenFile0036(aTestName,aSectName,aKeyName,aPlay);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    33
	return self;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    34
	}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    35
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    36
CTestMmfVclntOpenFile0036* CTestMmfVclntOpenFile0036::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    37
	{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    38
	CTestMmfVclntOpenFile0036* self = CTestMmfVclntOpenFile0036::NewL(aTestName,aSectName,aKeyName,aPlay);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    39
	CleanupStack::PushL(self);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    40
	return self;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    41
	}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    42
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    43
/**
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    44
 * Load and initialise an audio file.
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    45
 */
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    46
TVerdict CTestMmfVclntOpenFile0036::DoTestStepL()
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    47
	{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    48
	TVerdict iAllocTestStepResult=EPass;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    49
	TInt err = KErrNone;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    50
	TBool result = EFalse;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    51
	
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    52
	InitWservL();
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    53
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    54
	
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    55
	//>>>>>>>>>>>>>>>>>>>>>>>>Test Method Call<<<<<<<<<<<<<<<<<<<<<<<<<<
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    56
	if( PerformTestStepL() != EPass )
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    57
		{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    58
		err = iError;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    59
		}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    60
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    61
	if (err != KErrNone)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    62
		{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    63
		INFO_PRINTF2(_L("Test error, returned error code =  %d"), err);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    64
		User::Leave(err);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    65
		}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    66
	else
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    67
		{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    68
		//Check the iAllocTestStepResult
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    69
		if (iAllocTestStepResult != EPass)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    70
			{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    71
			result = ETrue;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    72
			}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    73
		}	
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    74
	
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    75
	TInt failCount = 1;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    76
	TBool completed = EFalse;
2
5c1df44f2eed 2010wk42_01
hgs
parents: 0
diff changeset
    77
	iAllocTestStepResult = EPass; // XXX check?? assume pass
0
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    78
	TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    79
	for(;;)	
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    80
		{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    81
		__UHEAP_SETFAIL(RHeap::EFailNext, failCount);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    82
		__MM_HEAP_MARK;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    83
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    84
		//INFO_PRINTF2(_L("CVideoPlayerUtility: Alloc Test Loop: %d"), failCount);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    85
		//>>>>>>>>>>>>>>>>>>>>>>>>Test Method Call<<<<<<<<<<<<<<<<<<<<<<<<<<
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    86
		TVerdict verdict = EFail;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    87
		TRAP(err, verdict = PerformTestStepL());
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    88
		if (err == KErrNone && verdict != EPass)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    89
			{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    90
			err = iError;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    91
			}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    92
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    93
		completed = EFalse;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    94
		if (err == KErrNone)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    95
			{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    96
			TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    97
			if (testAlloc == NULL)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    98
				{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    99
				reachedEnd = ETrue;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   100
				failCount -= 1;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   101
				}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   102
			else
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   103
				{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   104
				User::Free(testAlloc);	
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   105
				}			
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   106
			
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   107
			//Check the iAllocTestStepResult
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   108
			if (iAllocTestStepResult != EPass)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   109
				{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   110
				result = ETrue;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   111
				}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   112
			
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   113
			completed = reachedEnd || result;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   114
			}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   115
		else if (err != KErrNoMemory) // bad error code
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   116
			{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   117
			completed = ETrue;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   118
			result = EFail;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   119
			}			
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   120
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   121
		__MM_HEAP_MARKEND;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   122
		__UHEAP_SETFAIL(RHeap::ENone, 0);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   123
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   124
		if (completed)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   125
			{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   126
			break; // exit loop
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   127
			}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   128
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   129
		failCount++;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   130
		}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   131
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   132
	failCount -= 1; // Failcount of 1 equates to 0 successful allocs, etc
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   133
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   134
	if (err != KErrNone || result)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   135
		{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   136
		iAllocTestStepResult = EFail;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   137
		TBuf<80> format;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   138
		if (result)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   139
			{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   140
			format.Format(_L("  Bad result with %d memory allocations tested\n"), failCount);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   141
			}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   142
		else
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   143
			{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   144
			format.Format(_L("  Error(%d) with %d memory allocations tested\n"), err, failCount);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   145
			}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   146
		Log(format);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   147
		}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   148
	else 
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   149
		{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   150
		TBuf<80> format;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   151
		format.Format(_L("  Completed OK with %d memory allocations tested\n"), failCount);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   152
		Log(format);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   153
		}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   154
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   155
	return iAllocTestStepResult;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   156
	}