os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/teststepciaudiobufferprefill.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
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 "teststepciaudiobufferprefill.h"
sl@0
    17
sl@0
    18
const TInt32 KAfterThreeSeconds = 3000000;		// Three seconds
sl@0
    19
const TInt32 KEveryNinetySeconds = 90000000;	// Ninety seconds
sl@0
    20
sl@0
    21
sl@0
    22
TVerdict CTestStepCISampleBuffering::DoTestStepL()
sl@0
    23
	{
sl@0
    24
	iTestStepResult = ETestSuiteError;
sl@0
    25
sl@0
    26
	INFO_PRINTF1(_L("Initializing test CI device"));
sl@0
    27
sl@0
    28
	if (iTestStepName.Compare(_L("MM-MMF-DEVSOUNDCI-U-0069-HP")) == 0)
sl@0
    29
		{
sl@0
    30
		iTestStepResult = DoTestStep0069L();
sl@0
    31
		}
sl@0
    32
	else if (iTestStepName.Compare(_L("MM-MMF-DEVSOUNDCI-U-0070-HP")) == 0)
sl@0
    33
		{
sl@0
    34
		iTestStepResult = DoTestStep0070L();
sl@0
    35
		}
sl@0
    36
	else if (iTestStepName.Compare(_L("MM-MMF-DEVSOUNDCI-U-0071-HP")) == 0)
sl@0
    37
		{
sl@0
    38
		iTestStepResult = DoTestStep0071L();
sl@0
    39
		}
sl@0
    40
	else if (iTestStepName.Compare(_L("MM-MMF-DEVSOUNDCI-U-0072-HP")) == 0)
sl@0
    41
		{
sl@0
    42
		iTestStepResult = DoTestStep0072L();
sl@0
    43
		}
sl@0
    44
	else if (iTestStepName.Compare(_L("MM-MMF-DEVSOUNDCI-U-0073-HP")) == 0)
sl@0
    45
		{
sl@0
    46
		iTestStepResult = DoTestStep0073L();
sl@0
    47
		}
sl@0
    48
sl@0
    49
	return iTestStepResult;
sl@0
    50
	}
sl@0
    51
sl@0
    52
sl@0
    53
TVerdict CTestStepCISampleBuffering::DoTestStep0069L()
sl@0
    54
	{
sl@0
    55
	iTestStepResult = EFail;
sl@0
    56
sl@0
    57
	INFO_PRINTF1(_L("SampleBuffering - Instantiating"));
sl@0
    58
sl@0
    59
	//Initialize - with the UID of our test HwDevice
sl@0
    60
	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
sl@0
    61
	TUid testUID = {KUidSampleBufferingTestDevice}; 
sl@0
    62
	#else
sl@0
    63
	TFourCC testUID('T','0','1','2');
sl@0
    64
	#endif
sl@0
    65
sl@0
    66
	iTestStepResult = TestInitialize(testUID, EMMFStatePlaying);
sl@0
    67
sl@0
    68
	if (iTestStepResult != EPass)
sl@0
    69
		{
sl@0
    70
		INFO_PRINTF1(_L("DevSound failed to instantiate the test device"));
sl@0
    71
		return EInconclusive;
sl@0
    72
		}
sl@0
    73
sl@0
    74
	// reset the value as previous test is pass
sl@0
    75
	iTestStepResult = EFail;
sl@0
    76
sl@0
    77
	// KUidMMMFSampleBuffering
sl@0
    78
	MMMFSampleBuffering* ptr = static_cast <MMMFSampleBuffering*> (iMMFDevSound->CustomInterface(KUidSampleBuffering));
sl@0
    79
sl@0
    80
	if (ptr)
sl@0
    81
		{
sl@0
    82
		INFO_PRINTF1(_L("MMMFSampleBuffering instantiated successfully"));
sl@0
    83
sl@0
    84
		iTestStepResult = EPass;
sl@0
    85
		}
sl@0
    86
	else
sl@0
    87
		{
sl@0
    88
		ERR_PRINTF1(_L("MMMFSampleBuffering failed to retrieve the interface"));
sl@0
    89
		}
sl@0
    90
sl@0
    91
	return iTestStepResult;
sl@0
    92
	}
sl@0
    93
sl@0
    94
sl@0
    95
TVerdict CTestStepCISampleBuffering::DoTestStep0070L()
sl@0
    96
	{
sl@0
    97
	iTestStepResult = EFail;
sl@0
    98
	TInt result = KErrGeneral;
sl@0
    99
sl@0
   100
	INFO_PRINTF1(_L("SampleBuffering - MmsbEnableSampleBufferingBeforePlayback"));
sl@0
   101
sl@0
   102
	//Initialize - with the UID of our test HwDevice
sl@0
   103
	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
sl@0
   104
	TUid testUID = {KUidSampleBufferingTestDevice}; 
sl@0
   105
	#else
sl@0
   106
	TFourCC testUID('T','0','1','2');
sl@0
   107
	#endif
sl@0
   108
	
sl@0
   109
	iTestStepResult = TestInitialize(testUID, EMMFStatePlaying);
sl@0
   110
sl@0
   111
	if (iTestStepResult != EPass)
sl@0
   112
		{
sl@0
   113
		INFO_PRINTF1(_L("DevSound failed to instantiate the test device"));
sl@0
   114
		return EInconclusive;
sl@0
   115
		}
sl@0
   116
sl@0
   117
	// reset the value as previous test is pass
sl@0
   118
	iTestStepResult = EFail;
sl@0
   119
sl@0
   120
	// KUidMMMFSampleBuffering
sl@0
   121
	MMMFSampleBuffering* ptr = static_cast <MMMFSampleBuffering*> (iMMFDevSound->CustomInterface(KUidSampleBuffering));
sl@0
   122
sl@0
   123
	if (ptr)
sl@0
   124
		{
sl@0
   125
		result = ptr->MmsbEnableSampleBufferingBeforePlayback(); // call method
sl@0
   126
		
sl@0
   127
		if (result == KErrNone)
sl@0
   128
			{
sl@0
   129
			INFO_PRINTF1(_L("MMMFSampleBuffering::MmsbEnableSampleBufferingBeforePlayback finished successfully"));
sl@0
   130
sl@0
   131
			iTestStepResult = EPass;
sl@0
   132
			}
sl@0
   133
		else
sl@0
   134
			{
sl@0
   135
			ERR_PRINTF2(_L("MMMFSampleBuffering::MmsbEnableSampleBufferingBeforePlayback failed with result %d"), result);
sl@0
   136
			}
sl@0
   137
		}
sl@0
   138
	else
sl@0
   139
		{
sl@0
   140
		INFO_PRINTF1(_L("MMMFSampleBuffering failed to retrieve the interface"));
sl@0
   141
		iTestStepResult = EInconclusive;
sl@0
   142
		}
sl@0
   143
sl@0
   144
	return iTestStepResult;
sl@0
   145
	}
sl@0
   146
sl@0
   147
sl@0
   148
TVerdict CTestStepCISampleBuffering::DoTestStep0071L()
sl@0
   149
	{
sl@0
   150
	iTestStepResult = EFail;
sl@0
   151
	TInt result = KErrGeneral;
sl@0
   152
sl@0
   153
	INFO_PRINTF1(_L("SampleBuffering - MmsbDisableSampleBufferingBeforePlayback"));
sl@0
   154
sl@0
   155
	//Initialize - with the UID of our test HwDevice
sl@0
   156
	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
sl@0
   157
	TUid testUID = {KUidSampleBufferingTestDevice}; 
sl@0
   158
	#else
sl@0
   159
	TFourCC testUID('T','0','1','2');
sl@0
   160
	#endif
sl@0
   161
	
sl@0
   162
	iTestStepResult = TestInitialize(testUID, EMMFStatePlaying);
sl@0
   163
sl@0
   164
	if (iTestStepResult != EPass)
sl@0
   165
		{
sl@0
   166
		INFO_PRINTF1(_L("DevSound failed to instantiate the test device"));
sl@0
   167
		return EInconclusive;
sl@0
   168
		}
sl@0
   169
sl@0
   170
	// reset the value as previous test is pass
sl@0
   171
	iTestStepResult = EFail;
sl@0
   172
sl@0
   173
	// KUidMMMFSampleBuffering
sl@0
   174
	MMMFSampleBuffering* ptr = static_cast <MMMFSampleBuffering*> (iMMFDevSound->CustomInterface(KUidSampleBuffering));
sl@0
   175
sl@0
   176
	if (ptr)
sl@0
   177
		{
sl@0
   178
sl@0
   179
		result = ptr->MmsbDisableSampleBufferingBeforePlayback(); // call method
sl@0
   180
sl@0
   181
		if (result == KErrNone)
sl@0
   182
			{
sl@0
   183
			INFO_PRINTF1(_L("MMMFSampleBuffering::MmsbDisableSampleBufferingBeforePlayback finished successfully"));
sl@0
   184
sl@0
   185
			iTestStepResult = EPass;
sl@0
   186
			}
sl@0
   187
		else
sl@0
   188
			{
sl@0
   189
			ERR_PRINTF2(_L("MMMFSampleBuffering::MmsbDisableSampleBufferingBeforePlayback failed with result %d"), result);
sl@0
   190
			}
sl@0
   191
		}
sl@0
   192
	else
sl@0
   193
		{
sl@0
   194
		INFO_PRINTF1(_L("MMMFSampleBuffering failed to retrieve the interface"));
sl@0
   195
		iTestStepResult = EInconclusive;
sl@0
   196
		}
sl@0
   197
sl@0
   198
	return iTestStepResult;
sl@0
   199
	}
sl@0
   200
sl@0
   201
sl@0
   202
TVerdict CTestStepCISampleBuffering::DoTestStep0072L()
sl@0
   203
	{
sl@0
   204
	iTestStepResult = EFail;
sl@0
   205
	TInt err;
sl@0
   206
sl@0
   207
	INFO_PRINTF1(_L("SampleBuffering - MmsbNotifyPlayStarted"));
sl@0
   208
sl@0
   209
	//Initialize - with the UID of our test HwDevice
sl@0
   210
	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
sl@0
   211
	TUid testUID = {KUidSampleBufferingTestDevice}; 
sl@0
   212
	#else
sl@0
   213
	TFourCC testUID('T','0','1','2');
sl@0
   214
	#endif
sl@0
   215
	
sl@0
   216
	iTestStepResult = TestInitialize(testUID, EMMFStatePlaying);
sl@0
   217
	if (iTestStepResult != EPass)
sl@0
   218
		{
sl@0
   219
		INFO_PRINTF1(_L("DevSound failed to instantiate the test device"));
sl@0
   220
		return EInconclusive;
sl@0
   221
		}
sl@0
   222
sl@0
   223
	// reset the value as previous test is pass
sl@0
   224
	iTestStepResult = EFail;
sl@0
   225
sl@0
   226
	// KUidMMMFSampleBuffering
sl@0
   227
	MMMFSampleBuffering* ptr = static_cast <MMMFSampleBuffering*> (iMMFDevSound->CustomInterface(KUidSampleBuffering));
sl@0
   228
sl@0
   229
	if (ptr)
sl@0
   230
		{
sl@0
   231
		CActiveListener* listener = new(ELeave)CActiveListener;
sl@0
   232
sl@0
   233
		listener->InitialiseActiveListener();
sl@0
   234
sl@0
   235
		ptr->MmsbNotifyPlayStarted(listener->iStatus); // call method
sl@0
   236
sl@0
   237
		CActiveScheduler::Start();
sl@0
   238
sl@0
   239
		err = listener->iStatus.Int();
sl@0
   240
sl@0
   241
		delete listener;
sl@0
   242
sl@0
   243
		if (err == KErrNotSupported)
sl@0
   244
			{
sl@0
   245
			INFO_PRINTF1(_L("MMMFSampleBuffering::MmsbNotifyPlayStarted finished successfully"));
sl@0
   246
sl@0
   247
			iTestStepResult = EPass;
sl@0
   248
			}
sl@0
   249
		else
sl@0
   250
			{
sl@0
   251
			ERR_PRINTF2(_L("MMMFSampleBuffering::MmsbNotifyPlayStarted failed with err %d"), err);
sl@0
   252
			}
sl@0
   253
		}
sl@0
   254
	else
sl@0
   255
		{
sl@0
   256
		INFO_PRINTF1(_L("MMMFSampleBuffering failed to retrieve the interface"));
sl@0
   257
		iTestStepResult = EInconclusive;
sl@0
   258
		}
sl@0
   259
	
sl@0
   260
	return iTestStepResult;
sl@0
   261
	}
sl@0
   262
sl@0
   263
sl@0
   264
TVerdict CTestStepCISampleBuffering::DoTestStep0073L()
sl@0
   265
	{
sl@0
   266
	iTestStepResult = EFail;
sl@0
   267
	TInt err;
sl@0
   268
sl@0
   269
	INFO_PRINTF1(_L("SampleBuffering - MmsbCancelNotifyPlayStarted"));
sl@0
   270
sl@0
   271
	TCallBack callback(CTestStepCISampleBuffering::Callback, this);
sl@0
   272
sl@0
   273
	iTimer = CPeriodic::NewL(EPriorityNormal);
sl@0
   274
sl@0
   275
	// Here we use periodic timer to enable us to call MmsbCancelNotifyPlayStarted() after three
sl@0
   276
	// seconds of issuing MmsbNotifyPlayStarted(). Ninety seconds is long enough to stop the timer
sl@0
   277
	// before sending a second MmsbCancelNotifyPlayStarted() .
sl@0
   278
	iTimer->Start(KAfterThreeSeconds, KEveryNinetySeconds, callback);
sl@0
   279
sl@0
   280
	//Initialize - with the UID of our test HwDevice
sl@0
   281
	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
sl@0
   282
	TUid testUID = {KUidSampleBufferingTestDevice}; 
sl@0
   283
	#else
sl@0
   284
	TFourCC testUID('T','0','1','2');
sl@0
   285
	#endif
sl@0
   286
	
sl@0
   287
	iTestStepResult = TestInitialize(testUID, EMMFStatePlaying);
sl@0
   288
sl@0
   289
	if (iTestStepResult != EPass)
sl@0
   290
		{
sl@0
   291
		INFO_PRINTF1(_L("DevSound failed to instantiate the test device"));
sl@0
   292
		return EInconclusive;
sl@0
   293
		}
sl@0
   294
sl@0
   295
	// reset the value as previous test is pass
sl@0
   296
	iTestStepResult = EFail;
sl@0
   297
sl@0
   298
	// KUidMMMFSampleBuffering
sl@0
   299
	iInterfacePtr = static_cast <MMMFSampleBuffering*> (iMMFDevSound->CustomInterface(KUidSampleBuffering));
sl@0
   300
sl@0
   301
	if (iInterfacePtr)
sl@0
   302
		{
sl@0
   303
		CActiveListener* listener = new(ELeave) CActiveListener;
sl@0
   304
		listener->InitialiseActiveListener();
sl@0
   305
sl@0
   306
		iInterfacePtr->MmsbNotifyPlayStarted(listener->iStatus); // call method
sl@0
   307
sl@0
   308
		CActiveScheduler::Start();
sl@0
   309
sl@0
   310
		err = listener->iStatus.Int();
sl@0
   311
sl@0
   312
		delete listener;
sl@0
   313
		
sl@0
   314
		if (err == KErrCancel)
sl@0
   315
			{
sl@0
   316
			INFO_PRINTF1(_L("MMMFSampleBuffering::MmsbCancelNotifyPlayStarted Successfully completed"));
sl@0
   317
sl@0
   318
			iTestStepResult = EPass;
sl@0
   319
			}
sl@0
   320
		else
sl@0
   321
			{
sl@0
   322
			ERR_PRINTF2(_L("Device didn't wait for the expected duration  err %d"), err);
sl@0
   323
			}
sl@0
   324
		}
sl@0
   325
	else
sl@0
   326
		{
sl@0
   327
		INFO_PRINTF1(_L("MMMFSampleBuffering failed to retrieve the interface"));
sl@0
   328
		iTestStepResult = EInconclusive;
sl@0
   329
		}
sl@0
   330
sl@0
   331
	delete iTimer;
sl@0
   332
sl@0
   333
	return iTestStepResult;
sl@0
   334
	}
sl@0
   335
sl@0
   336
sl@0
   337
TInt CTestStepCISampleBuffering::Callback(TAny* aAny)
sl@0
   338
	{
sl@0
   339
	CTestStepCISampleBuffering* me = reinterpret_cast<CTestStepCISampleBuffering*>(aAny);
sl@0
   340
	me->DoCallback();
sl@0
   341
	return KErrNone;
sl@0
   342
	}
sl@0
   343
sl@0
   344
void CTestStepCISampleBuffering::DoCallback()
sl@0
   345
	{
sl@0
   346
	iTimer->Cancel();
sl@0
   347
	iInterfacePtr->MmsbCancelNotifyPlayStarted();	// call method
sl@0
   348
	}