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