os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/teststepciplaybackstatus.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include "teststepciplaybackstatus.h"
sl@0
    17
#include "cidefine.h"
sl@0
    18
sl@0
    19
/*****************************************************************************/
sl@0
    20
CTestStepCIPlaybackStatus::CTestStepCIPlaybackStatus()
sl@0
    21
	{
sl@0
    22
	iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0074-HP");
sl@0
    23
	}
sl@0
    24
sl@0
    25
/*****************************************************************************/
sl@0
    26
TVerdict CTestStepCIPlaybackStatus::DoTestStepL()
sl@0
    27
	{
sl@0
    28
	iTestStepResult = EFail;
sl@0
    29
sl@0
    30
	INFO_PRINTF1(_L("Initializing test CI device"));
sl@0
    31
	
sl@0
    32
	//Initialize - with the UID of our test HwDevice
sl@0
    33
	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
sl@0
    34
	TUid testUID = {KUidPlayBackStatusTestDevice}; 
sl@0
    35
	#else
sl@0
    36
	TFourCC testUID('T','0','0','1');
sl@0
    37
	#endif
sl@0
    38
sl@0
    39
	MMMFPlaybackStatus* interface = NULL;
sl@0
    40
	interface = static_cast<MMMFPlaybackStatus*>(InitializeAndInstantiateInterfaceL(testUID, KUidPlaybackStatus));
sl@0
    41
sl@0
    42
	if (interface)
sl@0
    43
		{
sl@0
    44
		iTestStepResult = EPass;
sl@0
    45
		INFO_PRINTF1(_L("Successfully retrieved the interface."));
sl@0
    46
		}
sl@0
    47
	else
sl@0
    48
		{
sl@0
    49
		iTestStepResult = EFail;
sl@0
    50
		ERR_PRINTF1(_L("Failed to retrieve the interface"));
sl@0
    51
		}
sl@0
    52
sl@0
    53
	return iTestStepResult;
sl@0
    54
	}
sl@0
    55
sl@0
    56
/*****************************************************************************/
sl@0
    57
CTestStepCIPlaybackStatusInfo::CTestStepCIPlaybackStatusInfo()
sl@0
    58
	{
sl@0
    59
	iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0075-HP");
sl@0
    60
	}
sl@0
    61
sl@0
    62
/*****************************************************************************/
sl@0
    63
TVerdict CTestStepCIPlaybackStatusInfo::DoTestStepL()
sl@0
    64
	{
sl@0
    65
	iTestStepResult = EFail;
sl@0
    66
sl@0
    67
	INFO_PRINTF1(_L("Initializing test CI device"));
sl@0
    68
	
sl@0
    69
	//Initialize - with the UID of our test HwDevice
sl@0
    70
	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
sl@0
    71
	TUid testUID = {KUidPlayBackStatusTestDevice}; 
sl@0
    72
	#else
sl@0
    73
	TFourCC testUID('T','0','0','1');
sl@0
    74
	#endif
sl@0
    75
	
sl@0
    76
	MMMFPlaybackStatus* interface = NULL;
sl@0
    77
	interface = static_cast<MMMFPlaybackStatus*>(InitializeAndInstantiateInterfaceL(testUID, KUidPlaybackStatus));
sl@0
    78
sl@0
    79
	if (interface)
sl@0
    80
		{
sl@0
    81
		INFO_PRINTF1(_L("Successfully retrieved the interface."));
sl@0
    82
		
sl@0
    83
		MMMFPlaybackStatus::TMMFPlaybackStatus status;
sl@0
    84
		
sl@0
    85
		// Set values before call.
sl@0
    86
		status.aInputBytes = 0;
sl@0
    87
		status.aDecodedSamples = 0;
sl@0
    88
		status.aDecodedSamplesPlayed = 0;
sl@0
    89
		status.aSystemTime = 0;
sl@0
    90
		status.aTotalSamplesPlayed = 0;
sl@0
    91
		
sl@0
    92
		interface->MmpsGetPlaybackStatusInformation(status); // call method
sl@0
    93
sl@0
    94
		if(status.aInputBytes == 999 &&
sl@0
    95
			status.aDecodedSamples == 999 &&
sl@0
    96
			status.aDecodedSamplesPlayed == 999 &&
sl@0
    97
			status.aSystemTime == 999 &&
sl@0
    98
			status.aTotalSamplesPlayed == 999)
sl@0
    99
			{
sl@0
   100
			iTestStepResult = EPass;
sl@0
   101
			INFO_PRINTF1(_L("Successfully got the status information."));
sl@0
   102
			}
sl@0
   103
		else
sl@0
   104
			{
sl@0
   105
			iTestStepResult = EFail;
sl@0
   106
			ERR_PRINTF1(_L("Failed to retrieve the status information"));
sl@0
   107
			}
sl@0
   108
		}
sl@0
   109
	else
sl@0
   110
		{
sl@0
   111
		ERR_PRINTF1(_L("Failed to retrieve the interface"));		
sl@0
   112
		}
sl@0
   113
		
sl@0
   114
	return iTestStepResult;
sl@0
   115
	}
sl@0
   116
sl@0
   117
sl@0
   118
/*****************************************************************************/
sl@0
   119
CTestStepCIPlaybackStatusRequestNotification::CTestStepCIPlaybackStatusRequestNotification(TBool aIsCancelTest)
sl@0
   120
											: iIsCancelTest(aIsCancelTest)
sl@0
   121
	{
sl@0
   122
	if (iIsCancelTest)
sl@0
   123
		{
sl@0
   124
		iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0098-HP");
sl@0
   125
		}
sl@0
   126
	else
sl@0
   127
		{
sl@0
   128
		iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0097-HP");
sl@0
   129
		}
sl@0
   130
	}
sl@0
   131
sl@0
   132
/*****************************************************************************/
sl@0
   133
TVerdict CTestStepCIPlaybackStatusRequestNotification::DoTestStepL()
sl@0
   134
	{
sl@0
   135
	iTestStepResult = EFail;
sl@0
   136
sl@0
   137
	INFO_PRINTF1(_L("Initializing test CI device"));
sl@0
   138
	
sl@0
   139
	//Initialize - with the UID of our test HwDevice
sl@0
   140
	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
sl@0
   141
	TUid testUID = {KUidPlayBackStatusTestDevice}; 
sl@0
   142
	#else
sl@0
   143
	TFourCC testUID('T','0','0','1');
sl@0
   144
	#endif
sl@0
   145
	
sl@0
   146
	MMMFPlaybackStatus* interface = NULL;
sl@0
   147
	interface = static_cast<MMMFPlaybackStatus*>(InitializeAndInstantiateInterfaceL(testUID, KUidPlaybackStatus));
sl@0
   148
sl@0
   149
	if (interface)
sl@0
   150
		{
sl@0
   151
		INFO_PRINTF1(_L("Successfully retrieved the interface."));
sl@0
   152
sl@0
   153
		iTestStepResult = EFail;		
sl@0
   154
		if (iIsCancelTest)
sl@0
   155
			{
sl@0
   156
			DoCancelTestL(*interface);
sl@0
   157
			}
sl@0
   158
		else
sl@0
   159
			{
sl@0
   160
			DoRequestTestL(*interface);
sl@0
   161
			}
sl@0
   162
		}
sl@0
   163
	else
sl@0
   164
		{
sl@0
   165
		ERR_PRINTF1(_L("Failed to retrieve the interface"));		
sl@0
   166
		}
sl@0
   167
		
sl@0
   168
	return iTestStepResult;
sl@0
   169
	}
sl@0
   170
sl@0
   171
void CTestStepCIPlaybackStatusRequestNotification::DoRequestTestL(MMMFPlaybackStatus& aInterface)
sl@0
   172
	{
sl@0
   173
	// Make the request.
sl@0
   174
	TInt err = aInterface.MmpsRequestLossOfSyncNotification();
sl@0
   175
	
sl@0
   176
	if (err == KErrNone)
sl@0
   177
		{
sl@0
   178
		// Get the result
sl@0
   179
		TBool testResult = EFalse;
sl@0
   180
		DoReadFromFileL(testResult);
sl@0
   181
		
sl@0
   182
		if (testResult)
sl@0
   183
			{
sl@0
   184
			// Value should be ETrue!
sl@0
   185
			iTestStepResult = EPass;
sl@0
   186
			INFO_PRINTF1(_L("Successfully requested the notification."));			
sl@0
   187
			}
sl@0
   188
		else
sl@0
   189
			{		
sl@0
   190
			ERR_PRINTF2(_L("Failed to request the notification"), err);	
sl@0
   191
			}
sl@0
   192
		}
sl@0
   193
	else
sl@0
   194
		{
sl@0
   195
		ERR_PRINTF2(_L("Failed to request the notification"), err);		
sl@0
   196
		}
sl@0
   197
	}
sl@0
   198
	
sl@0
   199
void CTestStepCIPlaybackStatusRequestNotification::DoCancelTestL(MMMFPlaybackStatus& aInterface)
sl@0
   200
	{
sl@0
   201
	// Make the request.
sl@0
   202
	TInt err = aInterface.MmpsCancelLossOfSyncNotification();
sl@0
   203
	
sl@0
   204
	if (err == KErrNone)
sl@0
   205
		{
sl@0
   206
		// Get the result
sl@0
   207
		TBool testResult = ETrue;
sl@0
   208
		DoReadFromFileL(testResult);
sl@0
   209
		
sl@0
   210
		if (!testResult)
sl@0
   211
			{
sl@0
   212
			// Value should be EFalse!
sl@0
   213
			iTestStepResult = EPass;
sl@0
   214
			INFO_PRINTF1(_L("Successfully cancelled the notification."));			
sl@0
   215
			}
sl@0
   216
		else
sl@0
   217
			{		
sl@0
   218
			ERR_PRINTF2(_L("Failed to cancel the notification"), err);	
sl@0
   219
			}
sl@0
   220
		}
sl@0
   221
	else
sl@0
   222
		{
sl@0
   223
		ERR_PRINTF2(_L("Failed to cancel the notification"), err);		
sl@0
   224
		}
sl@0
   225
	}
sl@0
   226
sl@0
   227
void CTestStepCIPlaybackStatusRequestNotification::DoReadFromFileL(TBool& aFlag)
sl@0
   228
	{
sl@0
   229
	RFs fs;
sl@0
   230
	CleanupClosePushL(fs);
sl@0
   231
	User::LeaveIfError(fs.Connect());
sl@0
   232
	
sl@0
   233
	RFile file;
sl@0
   234
	CleanupClosePushL(file);
sl@0
   235
	
sl@0
   236
	// File should already exist
sl@0
   237
	User::LeaveIfError(file.Open(fs, KCITestFileName, EFileRead));
sl@0
   238
	// Size should be 1!
sl@0
   239
	TInt fileSize = 0;
sl@0
   240
	User::LeaveIfError(file.Size(fileSize));
sl@0
   241
	if (fileSize != KMaxCITestFileDataLength)
sl@0
   242
		{
sl@0
   243
		User::Leave(KErrCorrupt);
sl@0
   244
		}
sl@0
   245
	TBuf8<KMaxCITestFileDataLength> inputBuf;
sl@0
   246
	User::LeaveIfError(file.Read(inputBuf));
sl@0
   247
	TChar val = inputBuf[0];
sl@0
   248
	aFlag = val.GetNumericValue();
sl@0
   249
sl@0
   250
	CleanupStack::PopAndDestroy(); // file	
sl@0
   251
sl@0
   252
	// It is the responsibility of this function to delete the file after use	
sl@0
   253
	User::LeaveIfError(fs.Delete(KCITestFileName));
sl@0
   254
sl@0
   255
	CleanupStack::PopAndDestroy(); // fs
sl@0
   256
	}
sl@0
   257