os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/OpenFileByHandle7803.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/OpenFileByHandle7803.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,119 @@
     1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include "TestPlayerUtils.h"
    1.20 +#include "OpenFileByHandle7803.h"
    1.21 +
    1.22 +#include <caf/caf.h>
    1.23 +
    1.24 +CTestMmfAclntOpenFile7803::CTestMmfAclntOpenFile7803(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
    1.25 +	: CTestMmfAclntAudioPlayerUtil(aTestName, aSectName), iKeyName(aKeyName)
    1.26 +	{}
    1.27 +
    1.28 +CTestMmfAclntOpenFile7803* CTestMmfAclntOpenFile7803::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
    1.29 +	{
    1.30 +	CTestMmfAclntOpenFile7803* self = new (ELeave) CTestMmfAclntOpenFile7803(aTestName, aSectName, aKeyName);
    1.31 +	return self;
    1.32 +	}
    1.33 +
    1.34 +/**
    1.35 + * Open new file.
    1.36 + */
    1.37 +TVerdict CTestMmfAclntOpenFile7803::DoTestL(CMdaAudioPlayerUtility* aPlayer)
    1.38 +	{
    1.39 +	return( PerformTestL( aPlayer ) );
    1.40 +	}
    1.41 +
    1.42 +TVerdict CTestMmfAclntOpenFile7803::PerformTestL(CMdaAudioPlayerUtility* aPlayer)
    1.43 +	{
    1.44 +	TVerdict ret = EPass;
    1.45 +	aPlayer->Close();
    1.46 +
    1.47 +	RFs fs;
    1.48 +
    1.49 +	// read optional test specific parameters
    1.50 +	iSkipShareProtected = iExpectToFail = EFalse;
    1.51 +	iExpectedError = KErrNone;
    1.52 +	// read the parameters, if any missing just ignore
    1.53 +	GetBoolFromConfig(iDefaultParamSet, _L("SkipShareProtected"), iSkipShareProtected);
    1.54 +	GetBoolFromConfig(iDefaultParamSet, _L("ExpectToFail"), iExpectToFail);
    1.55 +	GetIntFromConfig(iDefaultParamSet, _L("ExpectedError"), iExpectedError);
    1.56 +
    1.57 +	User::LeaveIfError(fs.Connect());
    1.58 +	CleanupClosePushL(fs);
    1.59 +	if (!iSkipShareProtected)
    1.60 +		{
    1.61 +		User::LeaveIfError(fs.ShareProtected());
    1.62 +		}
    1.63 +
    1.64 +	// get second file name
    1.65 +	TBuf<KSizeBuf>	filename2;
    1.66 +	TPtrC			filename;
    1.67 +
    1.68 +	if(!GetStringFromConfig(iSectName, iKeyName, filename))
    1.69 +		{
    1.70 +		return EInconclusive;
    1.71 +		}
    1.72 +		
    1.73 +	GetDriveName(filename2);
    1.74 +	filename2.Append(filename);
    1.75 +
    1.76 +	RFile file;
    1.77 +	User::LeaveIfError( file.Open( fs, filename2, EFileRead ) );
    1.78 +	CleanupClosePushL(file);
    1.79 +
    1.80 +	// Open second file
    1.81 +	aPlayer->OpenFileL(file);
    1.82 +	// wait for open to complete
    1.83 +	CActiveScheduler::Start();
    1.84 +
    1.85 +	INFO_PRINTF2( _L("OpenFileL completed with error %d"), iError);
    1.86 +
    1.87 +	if( iError != KErrNone )
    1.88 +		{
    1.89 +		if (iExpectToFail && iError == iExpectedError)
    1.90 +			{
    1.91 +			INFO_PRINTF2( _L("Error matches expected %d"), iExpectedError);
    1.92 +			ret = EPass;
    1.93 +			}
    1.94 +		else if (iExpectToFail)
    1.95 +			{
    1.96 +			INFO_PRINTF2( _L("Error does not match %d"), iExpectedError);
    1.97 +			ret = EFail;
    1.98 +			}
    1.99 +		else
   1.100 +			{
   1.101 +			INFO_PRINTF1( _L("No error was expected"));
   1.102 +			ret = EFail;
   1.103 +			}
   1.104 +		}
   1.105 +	else 
   1.106 +		{
   1.107 +		aPlayer->Play();
   1.108 +		CActiveScheduler::Start();
   1.109 +
   1.110 +		if( iError != KErrNone )
   1.111 +			{
   1.112 +			ret = EFail;
   1.113 +			}
   1.114 +
   1.115 +		User::After(1000000);
   1.116 +		aPlayer->Stop();
   1.117 +		aPlayer->Close();
   1.118 +		}
   1.119 +
   1.120 +	CleanupStack::PopAndDestroy(2, &fs);
   1.121 +	return ret;
   1.122 +	}