1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/testDRM.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,767 @@
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 "rightsdatabase.h"
1.20 +#include "TestDRM.h"
1.21 +#include <caf/caf.h>
1.22 +
1.23 +const TInt KDefaultRightsID = 1;
1.24 +const TInt KDefaultRightsCount = 2;
1.25 +
1.26 +const TInt KMaxMimeLength = 256;
1.27 +/**
1.28 + * Constructor
1.29 + */
1.30 +CTestMmfAclntDRMPlayerNoRights::CTestMmfAclntDRMPlayerNoRights()
1.31 + {
1.32 + // store the name of this test case
1.33 + // this is the name that is used by the script file
1.34 + // Each test step initialises it's own name
1.35 + iTestStepName = _L("MM-MMF-ACLNT-I-9000-LP");
1.36 +
1.37 + }
1.38 +
1.39 +CTestMmfAclntDRMPlayerNoRights* CTestMmfAclntDRMPlayerNoRights::NewL()
1.40 + {
1.41 + CTestMmfAclntDRMPlayerNoRights* self = new (ELeave) CTestMmfAclntDRMPlayerNoRights();
1.42 + return self;
1.43 + }
1.44 +
1.45 +CTestMmfAclntDRMPlayerNoRights* CTestMmfAclntDRMPlayerNoRights::NewLC()
1.46 + {
1.47 + CTestMmfAclntDRMPlayerNoRights* self = CTestMmfAclntDRMPlayerNoRights::NewL();
1.48 + CleanupStack::PushL(self);
1.49 + return self;
1.50 + }
1.51 +
1.52 +void CTestMmfAclntDRMPlayerNoRights::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds &aDuration)
1.53 + {
1.54 + iError = aError;
1.55 + iDuration = aDuration;
1.56 + INFO_PRINTF1( _L("MMdaAudioPlayerCallback Init Complete"));
1.57 + CActiveScheduler::Stop();
1.58 + }
1.59 +
1.60 +void CTestMmfAclntDRMPlayerNoRights::MapcPlayComplete(TInt aError)
1.61 + {
1.62 + iError = aError;
1.63 + INFO_PRINTF1( _L("MMdaAudioPlayerCallback Play Complete"));
1.64 + CActiveScheduler::Stop();
1.65 + }
1.66 +
1.67 +
1.68 +
1.69 +/** Load and initialise an audio file.
1.70 + */
1.71 +TVerdict CTestMmfAclntDRMPlayerNoRights::DoTestStepL( void )
1.72 + {
1.73 + INFO_PRINTF1( _L("TestPlayerUtils : File"));
1.74 + TVerdict ret = EFail;
1.75 +
1.76 + iError = KErrTimedOut;
1.77 +
1.78 + CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one
1.79 + delete rights; // the database will now be reset and have no entries in it
1.80 +
1.81 + TBuf<KSizeBuf> filename;
1.82 + TPtrC filename1;
1.83 + if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavFile"),filename1))
1.84 + return EInconclusive;
1.85 + GetDriveName(filename);
1.86 + filename.Append(filename1);
1.87 +
1.88 + CMdaAudioPlayerUtility* player = NULL;
1.89 + player = CMdaAudioPlayerUtility::NewFilePlayerL(filename, *this);
1.90 +
1.91 +
1.92 + // Wait for initialisation callback
1.93 + INFO_PRINTF1( _L("Initialise CMdaAudioPlayerUtility"));
1.94 + CActiveScheduler::Start();
1.95 +
1.96 + if (iError == KErrCANoRights)
1.97 + ret = EPass;
1.98 + else
1.99 + ret = EFail;
1.100 +
1.101 + delete player;
1.102 + User::After(KOneSecond); // wait for deletion to shut down devsound
1.103 + return ret;
1.104 + }
1.105 +//--------------------------------------------------------------------------------
1.106 +
1.107 +/**
1.108 + * Constructor
1.109 + */
1.110 +CTestMmfAclntDRMPlayerRightsCount::CTestMmfAclntDRMPlayerRightsCount()
1.111 + {
1.112 + // store the name of this test case
1.113 + // this is the name that is used by the script file
1.114 + // Each test step initialises it's own name
1.115 + iTestStepName = _L("MM-MMF-ACLNT-I-9001-LP");
1.116 +
1.117 + }
1.118 +
1.119 +CTestMmfAclntDRMPlayerRightsCount* CTestMmfAclntDRMPlayerRightsCount::NewL()
1.120 + {
1.121 + CTestMmfAclntDRMPlayerRightsCount* self = new (ELeave) CTestMmfAclntDRMPlayerRightsCount();
1.122 + return self;
1.123 + }
1.124 +
1.125 +CTestMmfAclntDRMPlayerRightsCount* CTestMmfAclntDRMPlayerRightsCount::NewLC()
1.126 + {
1.127 + CTestMmfAclntDRMPlayerRightsCount* self = CTestMmfAclntDRMPlayerRightsCount::NewL();
1.128 + CleanupStack::PushL(self);
1.129 + return self;
1.130 + }
1.131 +
1.132 +void CTestMmfAclntDRMPlayerRightsCount::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds &aDuration)
1.133 + {
1.134 + iError = aError;
1.135 + iDuration = aDuration;
1.136 + INFO_PRINTF1( _L("MMdaAudioPlayerCallback Init Complete"));
1.137 + CActiveScheduler::Stop();
1.138 + }
1.139 +
1.140 +void CTestMmfAclntDRMPlayerRightsCount::MapcPlayComplete(TInt aError)
1.141 + {
1.142 + iError = aError;
1.143 + INFO_PRINTF1( _L("MMdaAudioPlayerCallback Play Complete"));
1.144 + CActiveScheduler::Stop();
1.145 + }
1.146 +
1.147 +
1.148 +
1.149 +/** Load and initialise an audio file.
1.150 + */
1.151 +TVerdict CTestMmfAclntDRMPlayerRightsCount::DoTestStepL( void )
1.152 + {
1.153 + INFO_PRINTF1( _L("TestPlayerUtils : File"));
1.154 + TVerdict ret = EFail;
1.155 +
1.156 + iError = KErrTimedOut;
1.157 +
1.158 + CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one
1.159 + CleanupStack::PushL(rights);
1.160 + rights->AddRightsL(KDefaultRightsID,KDefaultRightsCount); // add rights count
1.161 + CleanupStack::PopAndDestroy(rights); // cleanup rights object
1.162 +
1.163 + TBuf<KSizeBuf> filename;
1.164 + TPtrC filename1;
1.165 + if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavFile"),filename1))
1.166 + return EInconclusive;
1.167 + GetDriveName(filename);
1.168 + filename.Append(filename1);
1.169 +
1.170 + CMdaAudioPlayerUtility* player = NULL;
1.171 + player = CMdaAudioPlayerUtility::NewFilePlayerL(filename, *this);
1.172 +
1.173 +
1.174 + // Wait for initialisation callback
1.175 + INFO_PRINTF1( _L("Initialise CMdaAudioPlayerUtility"));
1.176 + CActiveScheduler::Start();
1.177 +
1.178 + // Check for errors.
1.179 + if (iError == KErrNone && player != NULL)
1.180 + {
1.181 + iError = KErrTimedOut;
1.182 +
1.183 + for (TInt i=0;i<KDefaultRightsCount;i++)
1.184 + {
1.185 + player->Play();
1.186 +
1.187 + // Wait for play callback
1.188 + INFO_PRINTF2( _L("Play CMdaAudioPlayerUtility: DRM play number %d"),i);
1.189 + CActiveScheduler::Start();
1.190 +
1.191 + if (iError != KErrNone)
1.192 + {
1.193 + INFO_PRINTF2(_L("Unexpected error %d"),iError);
1.194 + break;
1.195 + }
1.196 + }
1.197 +
1.198 + if (iError == KErrNone)
1.199 + {
1.200 + player->Play();
1.201 +
1.202 + // Wait for play callback
1.203 + INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility with expired rights"));
1.204 + CActiveScheduler::Start();
1.205 +
1.206 + if (iError != KErrCANoPermission)
1.207 + {
1.208 + INFO_PRINTF3(_L("Unexpected error %d, expected %d"),iError,KErrCANoPermission);
1.209 + }
1.210 + else
1.211 + {
1.212 + INFO_PRINTF1(_L("Expected failure: rights denied"));
1.213 + ret = EPass;
1.214 + }
1.215 +
1.216 + }
1.217 + }
1.218 +
1.219 + delete player;
1.220 + User::After(KOneSecond); // wait for deletion to shut down devsound
1.221 + return ret;
1.222 + }
1.223 +
1.224 +//----------------------------------------------------------------------------------------
1.225 +
1.226 +/**
1.227 + * Constructor
1.228 + */
1.229 +CTestMmfAclntDRMRecorderNoRights::CTestMmfAclntDRMRecorderNoRights()
1.230 + {
1.231 + // store the name of this test case
1.232 + // this is the name that is used by the script file
1.233 + // Each test step initialises it's own name
1.234 + iTestStepName = _L("MM-MMF-ACLNT-I-9002-LP");
1.235 +
1.236 + }
1.237 +
1.238 +CTestMmfAclntDRMRecorderNoRights* CTestMmfAclntDRMRecorderNoRights::NewL()
1.239 + {
1.240 + CTestMmfAclntDRMRecorderNoRights* self = new (ELeave) CTestMmfAclntDRMRecorderNoRights();
1.241 + return self;
1.242 + }
1.243 +
1.244 +CTestMmfAclntDRMRecorderNoRights* CTestMmfAclntDRMRecorderNoRights::NewLC()
1.245 + {
1.246 + CTestMmfAclntDRMRecorderNoRights* self = CTestMmfAclntDRMRecorderNoRights::NewL();
1.247 + CleanupStack::PushL(self);
1.248 + return self;
1.249 + }
1.250 +
1.251 +
1.252 +/** Load and initialise an audio file.
1.253 + */
1.254 +TVerdict CTestMmfAclntDRMRecorderNoRights::DoTestStepL( void )
1.255 + {
1.256 + INFO_PRINTF1( _L("TestRecorderUtils : File"));
1.257 + TVerdict ret = EFail;
1.258 +
1.259 + iError = KErrTimedOut;
1.260 +
1.261 + CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one
1.262 + delete rights; // the database will now be reset and have no entries in it
1.263 +
1.264 + TBuf<KSizeBuf> filename;
1.265 + TPtrC filename1;
1.266 + if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavFile"),filename1))
1.267 + return EInconclusive;
1.268 + GetDriveName(filename);
1.269 + filename.Append(filename1);
1.270 +
1.271 + CMdaAudioRecorderUtility* recorder = CMdaAudioRecorderUtility::NewL(*this);
1.272 + CleanupStack::PushL(recorder);
1.273 +
1.274 + recorder->OpenFileL(filename);
1.275 +
1.276 + // Wait for initialisation callback
1.277 + INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility"));
1.278 + CActiveScheduler::Start();
1.279 +
1.280 + if (iError == KErrCANoRights)
1.281 + ret = EPass;
1.282 + else
1.283 + ret = EFail;
1.284 +
1.285 + CleanupStack::PopAndDestroy(recorder);
1.286 + User::After(KOneSecond); // wait for deletion to shut down devsound
1.287 + return ret;
1.288 + }
1.289 +
1.290 +
1.291 +void CTestMmfAclntDRMRecorderNoRights::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
1.292 + {
1.293 + iError = aErrorCode;
1.294 + //iObject = aObject;
1.295 + iPreviousState = aPreviousState;
1.296 + iCurrentState = aCurrentState;
1.297 +
1.298 + INFO_PRINTF1( _L("CTestMmfAclntRecord : MMdaObjectStateChangeObserver Callback for CMdaAudioRecorderUtility complete"));
1.299 + INFO_PRINTF4( _L("iError %d iPreviousState %d iCurrentState %d"), iError, iPreviousState, iCurrentState);
1.300 + CActiveScheduler::Stop();
1.301 + }
1.302 +
1.303 +//--------------------------------------------------------------------------------
1.304 +
1.305 +/**
1.306 + * Constructor
1.307 + */
1.308 +CTestMmfAclntDRMRecorderRightsCount::CTestMmfAclntDRMRecorderRightsCount()
1.309 + {
1.310 + // store the name of this test case
1.311 + // this is the name that is used by the script file
1.312 + // Each test step initialises it's own name
1.313 + iTestStepName = _L("MM-MMF-ACLNT-I-9003-LP");
1.314 +
1.315 + }
1.316 +
1.317 +CTestMmfAclntDRMRecorderRightsCount* CTestMmfAclntDRMRecorderRightsCount::NewL()
1.318 + {
1.319 + CTestMmfAclntDRMRecorderRightsCount* self = new (ELeave) CTestMmfAclntDRMRecorderRightsCount();
1.320 + return self;
1.321 + }
1.322 +
1.323 +CTestMmfAclntDRMRecorderRightsCount* CTestMmfAclntDRMRecorderRightsCount::NewLC()
1.324 + {
1.325 + CTestMmfAclntDRMRecorderRightsCount* self = CTestMmfAclntDRMRecorderRightsCount::NewL();
1.326 + CleanupStack::PushL(self);
1.327 + return self;
1.328 + }
1.329 +
1.330 +/** Load and initialise an audio file.
1.331 + */
1.332 +TVerdict CTestMmfAclntDRMRecorderRightsCount::DoTestStepL( void )
1.333 + {
1.334 + INFO_PRINTF1( _L("TestRecorderUtils : File"));
1.335 + TVerdict ret = EFail;
1.336 +
1.337 + iError = KErrTimedOut;
1.338 +
1.339 + CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one
1.340 + CleanupStack::PushL(rights);
1.341 + rights->AddRightsL(KDefaultRightsID,KDefaultRightsCount); // add rights count
1.342 + CleanupStack::PopAndDestroy(rights); // cleanup rights object
1.343 +
1.344 + TBuf<KSizeBuf> filename;
1.345 + TPtrC filename1;
1.346 + if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavFile"),filename1))
1.347 + return EInconclusive;
1.348 + GetDriveName(filename);
1.349 + filename.Append(filename1);
1.350 +
1.351 + CMdaAudioRecorderUtility* recorder = CMdaAudioRecorderUtility::NewL(*this);
1.352 + CleanupStack::PushL(recorder);
1.353 +
1.354 + recorder->OpenFileL(filename);
1.355 +
1.356 + // Wait for initialisation callback
1.357 + INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility"));
1.358 + CActiveScheduler::Start();
1.359 +
1.360 + // Check for errors.
1.361 + if (iError == KErrNone && recorder != NULL)
1.362 + {
1.363 + iError = KErrTimedOut;
1.364 +
1.365 + for (TInt i=0;i<KDefaultRightsCount;i++)
1.366 + {
1.367 + recorder->PlayL();
1.368 +
1.369 + // Wait for play callback
1.370 + INFO_PRINTF2( _L("Play CMdaAudioRecorderUtility: DRM play number %d"),i);
1.371 + CActiveScheduler::Start();
1.372 +
1.373 + if (iError != KErrNone)
1.374 + {
1.375 + INFO_PRINTF2(_L("Unexpected error %d"),iError);
1.376 + break;
1.377 + }
1.378 + }
1.379 +
1.380 + if (iError == KErrNone)
1.381 + {
1.382 + recorder->PlayL();
1.383 +
1.384 + // Wait for play callback
1.385 + INFO_PRINTF1( _L("Play CMdaAudioRecorderUtility with expired rights"));
1.386 + CActiveScheduler::Start();
1.387 +
1.388 + if (iError != KErrCANoPermission)
1.389 + {
1.390 + INFO_PRINTF3(_L("Unexpected error %d, expected %d"),iError,KErrCANoPermission);
1.391 + }
1.392 + else
1.393 + {
1.394 + INFO_PRINTF1(_L("Expected failure: rights denied"));
1.395 + ret = EPass;
1.396 + }
1.397 +
1.398 + }
1.399 + }
1.400 +
1.401 + CleanupStack::PopAndDestroy(recorder);
1.402 + User::After(KOneSecond); // wait for deletion to shut down devsound
1.403 + return ret;
1.404 + }
1.405 +
1.406 +
1.407 +
1.408 +
1.409 +void CTestMmfAclntDRMRecorderRightsCount::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
1.410 + {
1.411 + iError = aErrorCode;
1.412 + //iObject = aObject;
1.413 + iPreviousState = aPreviousState;
1.414 + iCurrentState = aCurrentState;
1.415 +
1.416 + TBool busy = (iCurrentState == CMdaAudioClipUtility::ERecording || iCurrentState == CMdaAudioClipUtility::EPlaying);
1.417 + if (!busy || iError!=KErrNone)
1.418 + CActiveScheduler::Stop();
1.419 +
1.420 + INFO_PRINTF1( _L("CTestMmfAclntRecord : MMdaObjectStateChangeObserver Callback for CMdaAudioRecorderUtility complete"));
1.421 + INFO_PRINTF4( _L("iError %d iPreviousState %d iCurrentState %d"), iError, iPreviousState, iCurrentState);
1.422 +
1.423 + }
1.424 +
1.425 +//--------------------------------------------------------------------------------
1.426 +
1.427 +/**
1.428 + * Constructor
1.429 + */
1.430 +CTestMmfAclntDRMPlayerOpen::CTestMmfAclntDRMPlayerOpen()
1.431 + {
1.432 + // store the name of this test case
1.433 + // this is the name that is used by the script file
1.434 + // Each test step initialises it's own name
1.435 + iTestStepName = _L("MM-MMF-ACLNT-I-9004-LP");
1.436 +
1.437 + }
1.438 +
1.439 +CTestMmfAclntDRMPlayerOpen* CTestMmfAclntDRMPlayerOpen::NewL()
1.440 + {
1.441 + CTestMmfAclntDRMPlayerOpen* self = new (ELeave) CTestMmfAclntDRMPlayerOpen();
1.442 + return self;
1.443 + }
1.444 +
1.445 +CTestMmfAclntDRMPlayerOpen* CTestMmfAclntDRMPlayerOpen::NewLC()
1.446 + {
1.447 + CTestMmfAclntDRMPlayerOpen* self = CTestMmfAclntDRMPlayerOpen::NewL();
1.448 + CleanupStack::PushL(self);
1.449 + return self;
1.450 + }
1.451 +
1.452 +void CTestMmfAclntDRMPlayerOpen::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds &aDuration)
1.453 + {
1.454 + iError = aError;
1.455 + iDuration = aDuration;
1.456 + INFO_PRINTF1( _L("MMdaAudioPlayerCallback Init Complete"));
1.457 + CActiveScheduler::Stop();
1.458 + }
1.459 +
1.460 +void CTestMmfAclntDRMPlayerOpen::MapcPlayComplete(TInt aError)
1.461 + {
1.462 + iError = aError;
1.463 + INFO_PRINTF1( _L("MMdaAudioPlayerCallback Play Complete"));
1.464 + CActiveScheduler::Stop();
1.465 + }
1.466 +
1.467 +/** Load and initialise an audio file.
1.468 + */
1.469 +TVerdict CTestMmfAclntDRMPlayerOpen::DoTestStepL( void )
1.470 + {
1.471 + INFO_PRINTF1( _L("TestPlayerUtils : File"));
1.472 + TVerdict ret = EFail;
1.473 + TInt err=KErrNone;
1.474 + iError = KErrTimedOut;
1.475 +
1.476 + //fectch MIME type from config file
1.477 + TBuf8<KMaxMimeLength> mimeType;
1.478 + TPtrC mimeTypePtr;
1.479 + if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavMime"),mimeTypePtr))
1.480 + return EInconclusive;
1.481 + mimeType.Copy(mimeTypePtr);
1.482 +
1.483 +
1.484 + //setup file to open
1.485 + TBuf<KSizeBuf> filename;
1.486 + TPtrC filename1;
1.487 + if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavFile"),filename1))
1.488 + return EInconclusive;
1.489 + GetDriveName(filename);
1.490 + filename.Append(filename1);
1.491 +
1.492 + //setup DRM rights
1.493 + CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one
1.494 + CleanupStack::PushL(rights);
1.495 + rights->AddRightsL(KDefaultRightsID,KDefaultRightsCount,mimeType); // add rights count
1.496 + CleanupStack::PopAndDestroy(rights); // cleanup rights object
1.497 +
1.498 + //create instance of Audio Player, which should try open the file as well
1.499 + CMdaAudioPlayerUtility* player = NULL;
1.500 + TRAP(err, player = CMdaAudioPlayerUtility::NewFilePlayerL(filename, *this));
1.501 +
1.502 + if (iError == KErrNone)//call back OK
1.503 + {
1.504 + // Wait for initialisation callback
1.505 + INFO_PRINTF1( _L("Initialise CMdaAudioPlayerUtility"));
1.506 + CActiveScheduler::Start();
1.507 + }
1.508 + else
1.509 + {
1.510 + INFO_PRINTF2(_L("Unexpected error %d"),iError);
1.511 + }
1.512 +
1.513 +
1.514 + if (err != KErrNone)
1.515 + {
1.516 + INFO_PRINTF3(_L("Unexpected error %d, expected %d"),iError,KErrCANoPermission);
1.517 + }
1.518 + else
1.519 + {
1.520 + INFO_PRINTF1(_L("Expected: PASS"));
1.521 + ret = EPass;
1.522 + }
1.523 +
1.524 + delete player;
1.525 + User::After(KOneSecond); // wait for deletion to shut down devsound
1.526 + return ret;
1.527 + }
1.528 +
1.529 +//--------------------------------------------------------------------------------
1.530 +
1.531 +/**
1.532 + * Constructor
1.533 + */
1.534 +CTestMmfAclntDRMRecorderPlay::CTestMmfAclntDRMRecorderPlay()
1.535 + {
1.536 + // store the name of this test case
1.537 + // this is the name that is used by the script file
1.538 + // Each test step initialises it's own name
1.539 + iTestStepName = _L("MM-MMF-ACLNT-I-9005-LP");
1.540 +
1.541 + }
1.542 +
1.543 +CTestMmfAclntDRMRecorderPlay* CTestMmfAclntDRMRecorderPlay::NewL()
1.544 + {
1.545 + CTestMmfAclntDRMRecorderPlay* self = new (ELeave) CTestMmfAclntDRMRecorderPlay();
1.546 + return self;
1.547 + }
1.548 +
1.549 +CTestMmfAclntDRMRecorderPlay* CTestMmfAclntDRMRecorderPlay::NewLC()
1.550 + {
1.551 + CTestMmfAclntDRMRecorderPlay* self = CTestMmfAclntDRMRecorderPlay::NewL();
1.552 + CleanupStack::PushL(self);
1.553 + return self;
1.554 + }
1.555 +
1.556 +/** Load and initialise an audio file.
1.557 + */
1.558 +TVerdict CTestMmfAclntDRMRecorderPlay::DoTestStepL( void )
1.559 + {
1.560 + INFO_PRINTF1( _L("TestRecorderUtils : File"));
1.561 + TVerdict ret = EFail;
1.562 +
1.563 + iError = KErrTimedOut;
1.564 +
1.565 + //fectch MIME type from config file
1.566 + TBuf8<KMaxMimeLength> mimeType;
1.567 + TPtrC mimeTypePtr;
1.568 + if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavMime"),mimeTypePtr))
1.569 + return EInconclusive;
1.570 + mimeType.Copy(mimeTypePtr);
1.571 +
1.572 + //setup DRM rights
1.573 + CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one
1.574 + CleanupStack::PushL(rights);
1.575 + rights->AddRightsL(KDefaultRightsID,KDefaultRightsCount,mimeType); // add rights count
1.576 + CleanupStack::PopAndDestroy(rights); // cleanup rights object
1.577 +
1.578 +
1.579 + TBuf<KSizeBuf> filename;
1.580 + TPtrC filename1;
1.581 + if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavFile"),filename1))
1.582 + return EInconclusive;
1.583 + GetDriveName(filename);
1.584 + filename.Append(filename1);
1.585 +
1.586 + CMdaAudioRecorderUtility* recorder = CMdaAudioRecorderUtility::NewL(*this);
1.587 + CleanupStack::PushL(recorder);
1.588 +
1.589 + recorder->OpenFileL(filename);
1.590 +
1.591 + // Wait for initialisation callback
1.592 + INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility"));
1.593 + CActiveScheduler::Start();
1.594 +
1.595 + // Check for errors.
1.596 + if (iError == KErrNone && recorder != NULL)
1.597 + {
1.598 + iError = KErrTimedOut;
1.599 +
1.600 + recorder->PlayL();
1.601 +
1.602 + // Wait for play callback
1.603 + INFO_PRINTF1( _L("Play DRM protected file with CMdaAudioRecorderUtility(with sufficient permission)"));
1.604 + CActiveScheduler::Start();
1.605 +
1.606 + if (iError != KErrNone)
1.607 + {
1.608 + INFO_PRINTF2(_L("Unexpected error trying to play protected file %d"),iError);
1.609 + }
1.610 + else
1.611 + {
1.612 + INFO_PRINTF1(_L("DRM Protected file played successfully"));
1.613 + ret = EPass;
1.614 + }
1.615 + }
1.616 +
1.617 + CleanupStack::PopAndDestroy(recorder);
1.618 + User::After(KOneSecond); // wait for deletion to shut down devsound
1.619 + return ret;
1.620 + }
1.621 +
1.622 +
1.623 +
1.624 +
1.625 +void CTestMmfAclntDRMRecorderPlay::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
1.626 + {
1.627 + iError = aErrorCode;
1.628 + //iObject = aObject;
1.629 + iPreviousState = aPreviousState;
1.630 + iCurrentState = aCurrentState;
1.631 +
1.632 + TBool busy = (iCurrentState == CMdaAudioClipUtility::ERecording || iCurrentState == CMdaAudioClipUtility::EPlaying);
1.633 + if (!busy || iError!=KErrNone)
1.634 + CActiveScheduler::Stop();
1.635 +
1.636 + INFO_PRINTF1( _L("CTestMmfAclntRecord : MMdaObjectStateChangeObserver Callback for CMdaAudioRecorderUtility complete"));
1.637 + INFO_PRINTF4( _L("iError %d iPreviousState %d iCurrentState %d"), iError, iPreviousState, iCurrentState);
1.638 +
1.639 + }
1.640 +
1.641 +
1.642 +//--------------------------------------------------------------------------------
1.643 +
1.644 +/**
1.645 + * Constructor
1.646 + */
1.647 +CTestMmfAclntDRMConverterFail::CTestMmfAclntDRMConverterFail()
1.648 + {
1.649 + // store the name of this test case
1.650 + // this is the name that is used by the script file
1.651 + // Each test step initialises it's own name
1.652 + iTestStepName = _L("MM-MMF-ACLNT-I-9006-LP");
1.653 +
1.654 + }
1.655 +
1.656 +CTestMmfAclntDRMConverterFail* CTestMmfAclntDRMConverterFail::NewL()
1.657 + {
1.658 + CTestMmfAclntDRMConverterFail* self = new (ELeave) CTestMmfAclntDRMConverterFail();
1.659 + return self;
1.660 + }
1.661 +
1.662 +CTestMmfAclntDRMConverterFail* CTestMmfAclntDRMConverterFail::NewLC()
1.663 + {
1.664 + CTestMmfAclntDRMConverterFail* self = CTestMmfAclntDRMConverterFail::NewL();
1.665 + CleanupStack::PushL(self);
1.666 + return self;
1.667 + }
1.668 +
1.669 +/** Load and initialise an audio file.
1.670 + */
1.671 +TVerdict CTestMmfAclntDRMConverterFail::DoTestStepL( void )
1.672 + {
1.673 + INFO_PRINTF1( _L("TestconverterUtils : File"));
1.674 + TVerdict ret = EFail;
1.675 +
1.676 + iError = KErrTimedOut;
1.677 +
1.678 + //fectch MIME type from config file
1.679 + TBuf8<KMaxMimeLength> mimeType;
1.680 + TPtrC mimeTypePtr;
1.681 + if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavMime"),mimeTypePtr))
1.682 + return EInconclusive;
1.683 + mimeType.Copy(mimeTypePtr);
1.684 +
1.685 + //setup DRM rights
1.686 + CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one
1.687 + CleanupStack::PushL(rights);
1.688 + rights->AddRightsL(KDefaultRightsID,KDefaultRightsCount,mimeType); // add rights count
1.689 + CleanupStack::PopAndDestroy(rights); // cleanup rights object
1.690 +
1.691 +
1.692 + TBuf<KSizeBuf> filename;
1.693 + TBuf<KSizeBuf> destFilename;
1.694 + TPtrC filename1;
1.695 + TPtrC filename2;
1.696 + if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavFile"),filename1))
1.697 + return EInconclusive;
1.698 + if(!GetStringFromConfig(_L("SectionDRM"),_L("TestConvertFile"),filename2))
1.699 + return EInconclusive;
1.700 + GetDriveName(filename);
1.701 + filename.Append(filename1);
1.702 + GetDriveName(destFilename);
1.703 + destFilename.Append(filename2);
1.704 +
1.705 + RFs theFs;
1.706 + theFs.Connect();
1.707 + theFs.Delete(destFilename);
1.708 + theFs.Close();
1.709 +
1.710 +
1.711 + iError = KErrTimedOut;
1.712 + TMdaFileClipLocation location(destFilename);
1.713 + TMdaWavClipFormat format;
1.714 + TMdaPcmWavCodec codec;
1.715 +
1.716 + CMdaAudioConvertUtility* converter = CMdaAudioConvertUtility::NewL(*this);
1.717 + CleanupStack::PushL(converter);
1.718 +
1.719 + converter->OpenL(filename, &location, &format, &codec);
1.720 +
1.721 + // Wait for initialisation callback
1.722 + INFO_PRINTF1( _L("Initialise CMdaAudioConvertUtility"));
1.723 + CActiveScheduler::Start();
1.724 +
1.725 + // Check for errors.
1.726 + if (iError == KErrNone && converter != NULL)
1.727 + {
1.728 + iError = KErrTimedOut;
1.729 +
1.730 + converter->ConvertL();
1.731 +
1.732 + // Wait for convert callback
1.733 + INFO_PRINTF1( _L("Convert CMdaAudioconverterUtility: DRM play number"));
1.734 + CActiveScheduler::Start();
1.735 +
1.736 + if (iError == KErrNotSupported)
1.737 + {
1.738 + INFO_PRINTF1(_L("Correctly received KErrNotSupported, for converting protected file"));
1.739 + ret = EPass;
1.740 + }
1.741 + else
1.742 + {
1.743 + INFO_PRINTF3(_L("Unexpected error %d, expecting %d"),iError, KErrNotSupported);
1.744 + }
1.745 + }
1.746 +
1.747 + CleanupStack::PopAndDestroy(converter);
1.748 + User::After(KOneSecond); // wait for deletion to shut down devsound
1.749 + return ret;
1.750 + }
1.751 +
1.752 +
1.753 +
1.754 +
1.755 +void CTestMmfAclntDRMConverterFail::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
1.756 + {
1.757 + iError = aErrorCode;
1.758 + //iObject = aObject;
1.759 + iPreviousState = aPreviousState;
1.760 + iCurrentState = aCurrentState;
1.761 +
1.762 + TBool busy = (iCurrentState == CMdaAudioClipUtility::ERecording || iCurrentState == CMdaAudioClipUtility::EPlaying);
1.763 + if (!busy || iError!=KErrNone)
1.764 + CActiveScheduler::Stop();
1.765 +
1.766 + INFO_PRINTF1( _L("CTestMmfAclntRecord : MMdaObjectStateChangeObserver Callback for CMdaAudioconverterUtility complete"));
1.767 + INFO_PRINTF4( _L("iError %d iPreviousState %d iCurrentState %d"), iError, iPreviousState, iCurrentState);
1.768 +
1.769 + }
1.770 +