os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/teststepciplaybackstatus.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/teststepciplaybackstatus.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,257 @@
1.4 +// Copyright (c) 2007-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 "teststepciplaybackstatus.h"
1.20 +#include "cidefine.h"
1.21 +
1.22 +/*****************************************************************************/
1.23 +CTestStepCIPlaybackStatus::CTestStepCIPlaybackStatus()
1.24 + {
1.25 + iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0074-HP");
1.26 + }
1.27 +
1.28 +/*****************************************************************************/
1.29 +TVerdict CTestStepCIPlaybackStatus::DoTestStepL()
1.30 + {
1.31 + iTestStepResult = EFail;
1.32 +
1.33 + INFO_PRINTF1(_L("Initializing test CI device"));
1.34 +
1.35 + //Initialize - with the UID of our test HwDevice
1.36 + #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
1.37 + TUid testUID = {KUidPlayBackStatusTestDevice};
1.38 + #else
1.39 + TFourCC testUID('T','0','0','1');
1.40 + #endif
1.41 +
1.42 + MMMFPlaybackStatus* interface = NULL;
1.43 + interface = static_cast<MMMFPlaybackStatus*>(InitializeAndInstantiateInterfaceL(testUID, KUidPlaybackStatus));
1.44 +
1.45 + if (interface)
1.46 + {
1.47 + iTestStepResult = EPass;
1.48 + INFO_PRINTF1(_L("Successfully retrieved the interface."));
1.49 + }
1.50 + else
1.51 + {
1.52 + iTestStepResult = EFail;
1.53 + ERR_PRINTF1(_L("Failed to retrieve the interface"));
1.54 + }
1.55 +
1.56 + return iTestStepResult;
1.57 + }
1.58 +
1.59 +/*****************************************************************************/
1.60 +CTestStepCIPlaybackStatusInfo::CTestStepCIPlaybackStatusInfo()
1.61 + {
1.62 + iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0075-HP");
1.63 + }
1.64 +
1.65 +/*****************************************************************************/
1.66 +TVerdict CTestStepCIPlaybackStatusInfo::DoTestStepL()
1.67 + {
1.68 + iTestStepResult = EFail;
1.69 +
1.70 + INFO_PRINTF1(_L("Initializing test CI device"));
1.71 +
1.72 + //Initialize - with the UID of our test HwDevice
1.73 + #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
1.74 + TUid testUID = {KUidPlayBackStatusTestDevice};
1.75 + #else
1.76 + TFourCC testUID('T','0','0','1');
1.77 + #endif
1.78 +
1.79 + MMMFPlaybackStatus* interface = NULL;
1.80 + interface = static_cast<MMMFPlaybackStatus*>(InitializeAndInstantiateInterfaceL(testUID, KUidPlaybackStatus));
1.81 +
1.82 + if (interface)
1.83 + {
1.84 + INFO_PRINTF1(_L("Successfully retrieved the interface."));
1.85 +
1.86 + MMMFPlaybackStatus::TMMFPlaybackStatus status;
1.87 +
1.88 + // Set values before call.
1.89 + status.aInputBytes = 0;
1.90 + status.aDecodedSamples = 0;
1.91 + status.aDecodedSamplesPlayed = 0;
1.92 + status.aSystemTime = 0;
1.93 + status.aTotalSamplesPlayed = 0;
1.94 +
1.95 + interface->MmpsGetPlaybackStatusInformation(status); // call method
1.96 +
1.97 + if(status.aInputBytes == 999 &&
1.98 + status.aDecodedSamples == 999 &&
1.99 + status.aDecodedSamplesPlayed == 999 &&
1.100 + status.aSystemTime == 999 &&
1.101 + status.aTotalSamplesPlayed == 999)
1.102 + {
1.103 + iTestStepResult = EPass;
1.104 + INFO_PRINTF1(_L("Successfully got the status information."));
1.105 + }
1.106 + else
1.107 + {
1.108 + iTestStepResult = EFail;
1.109 + ERR_PRINTF1(_L("Failed to retrieve the status information"));
1.110 + }
1.111 + }
1.112 + else
1.113 + {
1.114 + ERR_PRINTF1(_L("Failed to retrieve the interface"));
1.115 + }
1.116 +
1.117 + return iTestStepResult;
1.118 + }
1.119 +
1.120 +
1.121 +/*****************************************************************************/
1.122 +CTestStepCIPlaybackStatusRequestNotification::CTestStepCIPlaybackStatusRequestNotification(TBool aIsCancelTest)
1.123 + : iIsCancelTest(aIsCancelTest)
1.124 + {
1.125 + if (iIsCancelTest)
1.126 + {
1.127 + iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0098-HP");
1.128 + }
1.129 + else
1.130 + {
1.131 + iTestStepName = _L("MM-MMF-DEVSOUNDCI-U-0097-HP");
1.132 + }
1.133 + }
1.134 +
1.135 +/*****************************************************************************/
1.136 +TVerdict CTestStepCIPlaybackStatusRequestNotification::DoTestStepL()
1.137 + {
1.138 + iTestStepResult = EFail;
1.139 +
1.140 + INFO_PRINTF1(_L("Initializing test CI device"));
1.141 +
1.142 + //Initialize - with the UID of our test HwDevice
1.143 + #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
1.144 + TUid testUID = {KUidPlayBackStatusTestDevice};
1.145 + #else
1.146 + TFourCC testUID('T','0','0','1');
1.147 + #endif
1.148 +
1.149 + MMMFPlaybackStatus* interface = NULL;
1.150 + interface = static_cast<MMMFPlaybackStatus*>(InitializeAndInstantiateInterfaceL(testUID, KUidPlaybackStatus));
1.151 +
1.152 + if (interface)
1.153 + {
1.154 + INFO_PRINTF1(_L("Successfully retrieved the interface."));
1.155 +
1.156 + iTestStepResult = EFail;
1.157 + if (iIsCancelTest)
1.158 + {
1.159 + DoCancelTestL(*interface);
1.160 + }
1.161 + else
1.162 + {
1.163 + DoRequestTestL(*interface);
1.164 + }
1.165 + }
1.166 + else
1.167 + {
1.168 + ERR_PRINTF1(_L("Failed to retrieve the interface"));
1.169 + }
1.170 +
1.171 + return iTestStepResult;
1.172 + }
1.173 +
1.174 +void CTestStepCIPlaybackStatusRequestNotification::DoRequestTestL(MMMFPlaybackStatus& aInterface)
1.175 + {
1.176 + // Make the request.
1.177 + TInt err = aInterface.MmpsRequestLossOfSyncNotification();
1.178 +
1.179 + if (err == KErrNone)
1.180 + {
1.181 + // Get the result
1.182 + TBool testResult = EFalse;
1.183 + DoReadFromFileL(testResult);
1.184 +
1.185 + if (testResult)
1.186 + {
1.187 + // Value should be ETrue!
1.188 + iTestStepResult = EPass;
1.189 + INFO_PRINTF1(_L("Successfully requested the notification."));
1.190 + }
1.191 + else
1.192 + {
1.193 + ERR_PRINTF2(_L("Failed to request the notification"), err);
1.194 + }
1.195 + }
1.196 + else
1.197 + {
1.198 + ERR_PRINTF2(_L("Failed to request the notification"), err);
1.199 + }
1.200 + }
1.201 +
1.202 +void CTestStepCIPlaybackStatusRequestNotification::DoCancelTestL(MMMFPlaybackStatus& aInterface)
1.203 + {
1.204 + // Make the request.
1.205 + TInt err = aInterface.MmpsCancelLossOfSyncNotification();
1.206 +
1.207 + if (err == KErrNone)
1.208 + {
1.209 + // Get the result
1.210 + TBool testResult = ETrue;
1.211 + DoReadFromFileL(testResult);
1.212 +
1.213 + if (!testResult)
1.214 + {
1.215 + // Value should be EFalse!
1.216 + iTestStepResult = EPass;
1.217 + INFO_PRINTF1(_L("Successfully cancelled the notification."));
1.218 + }
1.219 + else
1.220 + {
1.221 + ERR_PRINTF2(_L("Failed to cancel the notification"), err);
1.222 + }
1.223 + }
1.224 + else
1.225 + {
1.226 + ERR_PRINTF2(_L("Failed to cancel the notification"), err);
1.227 + }
1.228 + }
1.229 +
1.230 +void CTestStepCIPlaybackStatusRequestNotification::DoReadFromFileL(TBool& aFlag)
1.231 + {
1.232 + RFs fs;
1.233 + CleanupClosePushL(fs);
1.234 + User::LeaveIfError(fs.Connect());
1.235 +
1.236 + RFile file;
1.237 + CleanupClosePushL(file);
1.238 +
1.239 + // File should already exist
1.240 + User::LeaveIfError(file.Open(fs, KCITestFileName, EFileRead));
1.241 + // Size should be 1!
1.242 + TInt fileSize = 0;
1.243 + User::LeaveIfError(file.Size(fileSize));
1.244 + if (fileSize != KMaxCITestFileDataLength)
1.245 + {
1.246 + User::Leave(KErrCorrupt);
1.247 + }
1.248 + TBuf8<KMaxCITestFileDataLength> inputBuf;
1.249 + User::LeaveIfError(file.Read(inputBuf));
1.250 + TChar val = inputBuf[0];
1.251 + aFlag = val.GetNumericValue();
1.252 +
1.253 + CleanupStack::PopAndDestroy(); // file
1.254 +
1.255 + // It is the responsibility of this function to delete the file after use
1.256 + User::LeaveIfError(fs.Delete(KCITestFileName));
1.257 +
1.258 + CleanupStack::PopAndDestroy(); // fs
1.259 + }
1.260 +