diff -r 839377eedc2b -r befca0ec475f videocollection/mpxmyvideoscollection/tsrc/mpxmvcolltest/src/VCXMyVideosCollectionPluginTestBlocks.cpp --- a/videocollection/mpxmyvideoscollection/tsrc/mpxmvcolltest/src/VCXMyVideosCollectionPluginTestBlocks.cpp Tue Aug 31 15:15:55 2010 +0300 +++ b/videocollection/mpxmyvideoscollection/tsrc/mpxmvcolltest/src/VCXMyVideosCollectionPluginTestBlocks.cpp Wed Sep 01 12:30:28 2010 +0100 @@ -11,9 +11,10 @@ * * Contributors: * -* Description: +* Description: ?Description* */ + // INCLUDE FILES #include // CleanupResetAndDestroyPushL #include @@ -23,35 +24,30 @@ #include #include "VCXTestLog.h" -#include "VCXMyVideosTestUtils.h" -#include "CVcxTestActiveWait.h" -#include "CVcxTestTimer.h" +#include "VCXTestCommon.h" +#include "CIptvTestActiveWait.h" +#include "CIptvTestTimer.h" +#include "VCXTestStatsKeeper.h" #include "VCXMyVideosCollectionPluginTest.h" #include "VCXMyVideosCollectionPluginTester.h" -#include "VCXMyVideosTestUtils.h" +#include "VCXMyVideosTestCommon.h" +#include "VCXMyVideosTestDlWatcher.h" +#include "VCXMyVideosTestServiceEmu.h" #include "VCXTestMdsDbModifier.h" -#include "VCXMyVideosTestCommon.h" #include #include #include -#include "vcxmyvideosdefs.h" #include "vcxmyvideosuids.h" // CONSTANTS const TInt KVcxTestFileSize3GB = -999; -_LIT(KAbout2050CharsString, "asdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjaiasdfiajsdfasdfiasdjfijasdifjisdfjisdjfiasdjfidjai"); -_LIT(KVcxTestEmptyString, ""); - -_LIT(KStifScriptInvalidRequest, "InvalidRequest"); -_LIT(KStifScriptEmptyString, "EmptyString"); -_LIT(KStifScript2KString, "2KString"); - // MACROS +#define VCXMVTEST_ERR(err) ( iStatsEnabled ) ? KErrNone : err // MODULE DATA STRUCTURES @@ -110,8 +106,8 @@ iSideloadFolders.ResetAndDestroy(); - delete iTestUtils; - iTestUtils = NULL; + delete iTestCommon; + iTestCommon = NULL; #ifdef __WINSCW__ iClient.Close(); @@ -148,6 +144,9 @@ delete iMpxMedia; iMpxMedia = NULL; + delete iServiceEmu; + iServiceEmu = NULL; + delete iMdsDbModifier; iMdsDbModifier = NULL; @@ -155,6 +154,9 @@ iFileMan = NULL; iFs.Close(); + + delete iStats; + iStats = NULL; VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::EnableStatsL ---------->"); + // Print to UI + _LIT( KVCXMyVideosCollectionPluginTest, "VCXMyVideosCollectionPluginTest" ); + _LIT( KWhere, "In EnableStatsL" ); + TestModuleIf().Printf( 0, KVCXMyVideosCollectionPluginTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); + + TPtrC statsName; + TPtrC fileName; + User::LeaveIfError( aItem.GetNextString( statsName) ); + User::LeaveIfError( aItem.GetNextString( fileName) ); + + TRAP_IGNORE( iStats->StartStatsKeepingL( statsName, fileName ) ); + iStatsEnabled = ETrue; + + VCXLOGLO1("<<SetAutoResume( iAutoResume ); + + iServiceEmu = CVCXMyVideosTestServiceEmu::NewL(); + iMdsDbModifier = CVCXTestMdsDbModifier::NewL(); iCurrentSortOrder = EVcxMyVideosSortingNone; @@ -291,6 +334,40 @@ } // ----------------------------------------------------------------------------- +// CVCXMyVideosCollectionPluginTest::SetPreferredMemoryL +// ----------------------------------------------------------------------------- +// +TInt CVCXMyVideosCollectionPluginTest::SetPreferredMemoryL( CStifItemParser& aItem ) + { + VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTest::SetPreferredMemoryL ---------->"); + // Print to UI + _LIT( KVCXMyVideosCollectionPluginTest, "VCXMyVideosCollectionPluginTest" ); + _LIT( KWhere, "In SetPreferredMemoryL" ); + TestModuleIf().Printf( 0, KVCXMyVideosCollectionPluginTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); + + TInt drive(0); + User::LeaveIfError( GetDriveParam( aItem, drive ) ); + + // These were defined in CVcxMyVideosDownloadUtil::PreferredMemoryDesL() + const TInt KVcxCenRepUid = 0x102750E2; // same as KIptvCenRepUid in CIptvUtil.h + const TInt KVcxCenRepPreferredMemoryKey = 0x01; // same as KIptvCenRepPreferredMemoryKey in CIptvUtil.h + + TUid uid; + uid.iUid = KVcxCenRepUid; + + CRepository* cenRep = CRepository::NewLC( uid ); + User::LeaveIfError( cenRep->Set( KVcxCenRepPreferredMemoryKey, drive ) ); + CleanupStack::PopAndDestroy( cenRep ); + + VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::DisableDownloadCheckL"); + if( iTester ) + { + iTester->GetDownloadWatcher()->DisableDownloadCheck(); + } + VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::SetUseCopiedMediasL"); - - TInt value(0); - User::LeaveIfError( aItem.GetNextInt( value ) ); - TBool set = static_cast(value); - iTester->SetUseCopiedMediasL( set ); - - VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::SetAutoResumeL ---------->"); + // Print to UI + _LIT( KVCXMyVideosCollectionPluginTest, "VCXMyVideosCollectionPluginTest" ); + _LIT( KWhere, "In SetAutoResumeL" ); + TestModuleIf().Printf( 0, KVCXMyVideosCollectionPluginTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + TInt autoResume(0); + User::LeaveIfError( aItem.GetNextInt( autoResume ) ); + iAutoResume = autoResume; + if( iTester ) + { + iTester->SetAutoResume( iAutoResume ); + } + + VCXLOGLO1("<<Log( KWhere ); aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); - - TPtrC name; - User::LeaveIfError( aItem.GetNextString( name ) ); - VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: levelName: %S", &name); - - iLastReceivedMessage = -1; - - TInt err( KErrNotReady ); - if( iTester ) - { - TRAP( err, iTester->OpenLevelL( name ) ); - } - - if( err != KErrNone ) - VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: err: %d", err); - - VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::OpenLevelByIndexL ---------->"); - // Print to UI - _LIT( KVCXMyVideosCollectionPluginTest, "VCXMyVideosCollectionPluginTest" ); - _LIT( KWhere, "In OpenLevelL" ); - TestModuleIf().Printf( 0, KVCXMyVideosCollectionPluginTest, KWhere ); - // Print to log file - iLog->Log( KWhere ); - - aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); TInt index; User::LeaveIfError( aItem.GetNextInt( index ) ); VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: index: %d", index); @@ -546,8 +612,8 @@ if( err != KErrNone ) VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: err: %d", err); - VCXLOGLO1("<<= iTester->GetMediaCount() ) { - if( itemIndex < 0 || itemIndex >= iTester->GetMediaCount() ) - { - VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: Error. Index (%d) out of bounds.", itemIndex); - User::Leave( KErrArgument ); - } - } - else - { - itemIndex = iTester->GetIndexOfMediaWithNameL( itemIndexOrName ); - } - - if( itemIndex == KErrNotFound ) - { + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: Error. Index (%d) out of bounds.", itemIndex); User::Leave( KErrArgument ); } - // Attribute to be checked - TInt mpxAttributeMappingId(0); User::LeaveIfError( aItem.GetNextInt( mpxAttributeMappingId ) ); - // It's type. - TVcxTestMediaAttributeType type; TMPXAttributeData mpxMediaAttribute; User::LeaveIfError( MapMpxMediaAttribute( static_cast(mpxAttributeMappingId), mpxMediaAttribute, type ) ); - // Get the media to be checked. - CMPXMedia* media( NULL ); + CMPXMedia* media( NULL ); TRAP( err, media = iTester->GetMediaL( drive, itemIndex ) ); // If attribute is not supported, fetch full media details. @@ -900,7 +945,7 @@ if( err != KErrNone ) { VCXLOGLO1("<<IsSupported( mpxMediaAttribute ) ) @@ -911,7 +956,7 @@ iTester->PrintMPXMediaL( *media, ETrue ); VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::CheckAlbumCountL ---------->"); - // Print to UI - _LIT( KVCXMyVideosCollectionPluginTest, "VCXMyVideosCollectionPluginTest" ); - _LIT( KWhere, "In CheckAlbumCountL" ); - TestModuleIf().Printf( 0, KVCXMyVideosCollectionPluginTest, KWhere ); - // Print to log file - iLog->Log( KWhere ); - - WaitForRefreshL( EFalse ); // Wait for possible refresh to finish. - - aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); - - TInt expectedCount(0); - User::LeaveIfError(aItem.GetNextInt(expectedCount)); - - // File check - TInt videoCount = iTester->GetMediaCount(); - - // attribute check that they are in allowed values - - int err(KErrNone); - int actualCount(0); - - for( TInt i = videoCount-1; i >= 0; i-- ) - { - CMPXMedia* media = iTester->GetMediaL( -1, i ); - - // Skip categories with empty names, they are for photos. - if( !media->IsSupported( KMPXMediaGeneralTitle ) ) - { - continue; - } - - TMPXItemId itemId = *( media->Value( KMPXMediaGeneralId ) ); - - if(itemId.iId2 == KVcxMvcMediaTypeAlbum) - { - actualCount++; - } - } - - if ( actualCount != expectedCount ) - { - VCXLOGLO2("CVCXMyVideosCollectionPluginTest: Error! Count of albums is wrong: %d", actualCount ); - err = KErrCorrupt; - } - - VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::CheckDownloadCountL ---------->"); + // Print to UI + _LIT( KVCXMyVideosCollectionPluginTest, "VCXMyVideosCollectionPluginTest" ); + _LIT( KWhere, "In CheckMediaCountL" ); + TestModuleIf().Printf( 0, KVCXMyVideosCollectionPluginTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); + + WaitForRefreshL( EFalse ); // Wait for possible refresh to finish. + + TInt expectedCount(0); + User::LeaveIfError(aItem.GetNextInt(expectedCount)); + + TInt err( KErrNotReady ); + if( iTester ) + { + err = KErrNone; + if( iTester->GetDownloadWatcher()->GetDownloadCount() != expectedCount ) + { + err = KErrCorrupt; + VCXLOGLO1("CVCXMyVideosCollectionPluginTest:: ERROR: Not expected count of downloads!"); + } + } + + VCXLOGLO1("<<GetMediaCount(); + + // Store info about the mpx items. + RArray mpxIds; + CleanupClosePushL( mpxIds ); + + RArray downloadIds; + CleanupClosePushL( downloadIds ); + + RArray downloadStates; + CleanupClosePushL( downloadStates ); + + RPointerArray filePaths; + CleanupResetAndDestroyPushL( filePaths ); + + // Get ids and other needed details. + + for( TInt i=0; iGetMediaL( -1, i ) ); + + if( error != KErrNone ) + { + CleanupStack::PopAndDestroy( &filePaths ); + CleanupStack::PopAndDestroy( &downloadStates ); + CleanupStack::PopAndDestroy( &downloadIds ); + CleanupStack::PopAndDestroy( &mpxIds ); + + VCXLOGLO1("<<IsSupported( KMPXMediaGeneralUri ) ) + { + TUint32 downloadId = 0; + if( media->IsSupported( KVcxMediaMyVideosDownloadId ) ) + { + downloadId = media->ValueTObjectL( KVcxMediaMyVideosDownloadId ); + } + + TInt state = -1; + if( media->IsSupported( KVcxMediaMyVideosDownloadState ) ) + { + state = media->ValueTObjectL( KVcxMediaMyVideosDownloadState ); + } + + HBufC* path( NULL ); + if( media->IsSupported( KMPXMediaGeneralUri ) ) + { + path = media->ValueText( KMPXMediaGeneralUri ).AllocL(); + } + else + { + path = HBufC::NewL( 32 ); + } + + TMPXItemId itemId = *(media->Value( KMPXMediaGeneralId )); + + filePaths.Append( path ); + downloadIds.Append( downloadId ); + downloadStates.Append( state ); + mpxIds.Append( itemId.iId1 ); + } + } + + // Cancel downloads. + + for( TInt i = mpxIds.Count()-1; i >= 0; i-- ) + { + if( downloadIds[i] != 0 || downloadStates[i] != -1 ) + { + // Cancel the download. + RArray messages; + if( BaflUtils::FileExists( iFs, filePaths[i]->Des() ) ) + { + messages.Append( KVCXMYVideosTestMessageMpxItemDeleted ); + } + messages.Append( KVCXMYVideosTestMessageCommandComplete ); + messages.Append( KVCXMYVideosTestMessageCollectionOpened ); + TRAP( error, iTester->CancelDownloadL( mpxIds[i], downloadIds[i], filePaths[i]->Des(), EFalse ) ); + if( error == KErrNone ) + { + TRAP( error, WaitForMessagesL( ETrue, messages, 30, ETrue ) ); + } + messages.Reset(); + // Error occured, lets hope deleting works. + if( error != KErrNone ) + { + downloadIds[i] = 0; + downloadStates[i] = -1; + } + } + } + // Get current list of medias. CMPXMediaArray* medias( NULL ); @@ -1961,6 +2082,16 @@ iLastReceivedMessage = -1; + CleanupStack::PopAndDestroy( &filePaths ); + CleanupStack::PopAndDestroy( &downloadStates ); + CleanupStack::PopAndDestroy( &downloadIds ); + CleanupStack::PopAndDestroy( &mpxIds ); + + if( iTester && iTester->GetDownloadWatcher() ) + { + iTester->GetDownloadWatcher()->Reset(); + } + if( iTester->GetMediaCount() > 0 ) { VCXLOGLO1("CVCXMyVideosCollectionPluginTest:: All medias could not be removed."); @@ -1968,11 +2099,11 @@ } VCXLOGLO1("<<EnsureMediaFilesAreNotInUseL() ); - err = err; + err = VCXMVTEST_ERR( err ); if( err == KErrNone ) { TRAP( err, iTester->MoveMediasL( sourceDrive, index, index+1, destDrive, syncCall ) ); @@ -2021,11 +2152,11 @@ VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: err: %d", err); VCXLOGLO1("<<EnsureMediaFilesAreNotInUseL() ); - err = err; + err = VCXMVTEST_ERR( err ); if( err == KErrNone ) { TRAP( err, iTester->MoveMediasL( sourceDrive, index, endIndex, destDrive, syncCall ) ); @@ -2077,11 +2208,11 @@ VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: err: %d", err); VCXLOGLO1("<<EnsureMediaFilesAreNotInUseL() ); - err = err; + err = VCXMVTEST_ERR( err ); if( err == KErrNone ) { TRAP( err, iTester->DeleteMediasL( sourceDrive, index, index+1, syncCall ) ); @@ -2304,11 +2435,11 @@ VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: err: %d", err); VCXLOGLO1("<<EnsureMediaFilesAreNotInUseL() ); - err = err; + err = VCXMVTEST_ERR( err ); if( err == KErrNone ) { TRAP( err, iTester->DeleteMediasL( sourceDrive, index, endIndex, syncCall ) ); @@ -2359,11 +2490,11 @@ } VCXLOGLO1("<<EnsureMediaFilesAreNotInUseL() ); - err = err; + err = VCXMVTEST_ERR( err ); if( err == KErrNone ) { TRAP( err, iTester->DeleteAllMediaFilesL() ); @@ -2490,297 +2621,11 @@ } VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::CreateAlbumL ---------->"); - // Print to UI - _LIT( KVCXMyVideosCollectionPluginTest, "VCXMyVideosCollectionPluginTest" ); - _LIT( KWhere, "In CreateAlbumL" ); - TestModuleIf().Printf( 0, KVCXMyVideosCollectionPluginTest, KWhere ); - // Print to log file - iLog->Log( KWhere ); - - aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); - - iLastReceivedMessage = -1; - - TInt err( KErrNotReady ); - if( iTester ) - { - TPtrC albumName; - User::LeaveIfError( aItem.GetNextString( albumName ) ); - - TInt sync; - if( aItem.GetNextInt( sync ) != KErrNone ) - { - sync = EFalse; - } - - if( albumName.Compare( KStifScript2KString ) == KErrNone ) - { - TRAP( err, iTester->CreateAlbumL( KAbout2050CharsString, sync ) ); - } - else if( albumName.Compare( KStifScriptEmptyString ) == KErrNone ) - { - TRAP( err, iTester->CreateAlbumL( KVcxTestEmptyString, sync ) ); - } - else if( albumName.Compare( KStifScriptInvalidRequest ) == KErrNone ) - { - TRAP( err, iTester->CreateAlbumL( KVcxTestEmptyString, sync, ETrue ) ); - } - else - { - TRAP( err, iTester->CreateAlbumL( albumName, sync ) ); - } - } - - VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::DeleteAlbumsL ---------->"); - // Print to UI - _LIT( KVCXMyVideosCollectionPluginTest, "VCXMyVideosCollectionPluginTest" ); - _LIT( KWhere, "In DeleteAlbumsL" ); - TestModuleIf().Printf( 0, KVCXMyVideosCollectionPluginTest, KWhere ); - // Print to log file - iLog->Log( KWhere ); - - aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); - - iLastReceivedMessage = -1; - - TInt err( KErrNotReady ); - - if( iTester ) - { - TPtrC albumName; - RArray albumNames; - - while( aItem.GetNextString( albumName ) == KErrNone ) - { - albumNames.Append( albumName ); - } - - if( albumNames.Count() < 1 ) - { - VCXLOGLO1("CVCXMyVideosCollectionPluginTest::DeleteAlbumsL: No albums specified!"); - err = KErrArgument; - } - else - { - TRAP( err, iTester->DeleteAlbumsL( albumNames ) ); - } - } - - VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::DeleteAllAlbumsL ---------->"); - // Print to UI - _LIT( KVCXMyVideosCollectionPluginTest, "VCXMyVideosCollectionPluginTest" ); - _LIT( KWhere, "In DeleteAllAlbumsL" ); - TestModuleIf().Printf( 0, KVCXMyVideosCollectionPluginTest, KWhere ); - // Print to log file - iLog->Log( KWhere ); - - aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); - - iLastReceivedMessage = -1; - - TInt err( KErrNotReady ); - - if( iTester ) - { - TRAP( err, iTester->DeleteAllAlbumsL() ); - } - - VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::AddMediasToAlbumL ---------->"); - // Print to UI - _LIT( KVCXMyVideosCollectionPluginTest, "VCXMyVideosCollectionPluginTest" ); - _LIT( KWhere, "In AddMediasToAlbumL" ); - TestModuleIf().Printf( 0, KVCXMyVideosCollectionPluginTest, KWhere ); - // Print to log file - iLog->Log( KWhere ); - - aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); - - iLastReceivedMessage = -1; - - TInt err( KErrNotReady ); - - if( iTester ) - { - TPtrC albumName; - User::LeaveIfError( aItem.GetNextString( albumName ) ); - - TInt sourceDrive(0); - User::LeaveIfError( GetDriveParam( aItem, sourceDrive ) ); - - TInt index(0); - User::LeaveIfError( aItem.GetNextInt( index ) ); - - TInt endIndex(0); - User::LeaveIfError( aItem.GetNextInt( endIndex ) ); - - TRAP( err, iTester->AddMediasToAlbumL( albumName, sourceDrive, index, endIndex ) ); - } - - VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::RemoveMediasFromAlbumL ---------->"); - // Print to UI - _LIT( KVCXMyVideosCollectionPluginTest, "VCXMyVideosCollectionPluginTest" ); - _LIT( KWhere, "In RemoveMediasFromAlbumL" ); - TestModuleIf().Printf( 0, KVCXMyVideosCollectionPluginTest, KWhere ); - // Print to log file - iLog->Log( KWhere ); - - aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); - - iLastReceivedMessage = -1; - - TInt err( KErrNotReady ); - - if( iTester ) - { - TPtrC albumName; - User::LeaveIfError( aItem.GetNextString( albumName ) ); - - TInt sourceDrive(0); - User::LeaveIfError( GetDriveParam( aItem, sourceDrive ) ); - - TInt index(0); - User::LeaveIfError( aItem.GetNextInt( index ) ); - - TInt endIndex(0); - User::LeaveIfError( aItem.GetNextInt( endIndex ) ); - - TRAP( err, iTester->RemoveMediasFromAlbumL( albumName, sourceDrive, index, endIndex ) ); - } - - VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::RenameAlbumL ---------->"); - // Print to UI - _LIT( KVCXMyVideosCollectionPluginTest, "VCXMyVideosCollectionPluginTest" ); - _LIT( KWhere, "In RenameAlbumL" ); - TestModuleIf().Printf( 0, KVCXMyVideosCollectionPluginTest, KWhere ); - // Print to log file - iLog->Log( KWhere ); - - WaitForRefreshL( EFalse ); // Wait for possible refresh to finish. - - aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); - - int err( KErrNotReady ); - - if( iTester ) - { - TPtrC albumName; - User::LeaveIfError( aItem.GetNextString( albumName ) ); - - TPtrC newAlbumName; - User::LeaveIfError( aItem.GetNextString( newAlbumName ) ); - - if( newAlbumName.Compare( KStifScript2KString ) == KErrNone ) - { - TRAP( err, iTester->RenameAlbumL( albumName, KAbout2050CharsString ) ); - } - else if( newAlbumName.Compare( KStifScriptEmptyString ) == KErrNone ) - { - TRAP( err, iTester->RenameAlbumL( albumName, KVcxTestEmptyString ) ); - } - else - { - TRAP( err, iTester->RenameAlbumL( albumName, newAlbumName ) ); - } - } - - VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::CheckAlbumExistsL ---------->"); - // Print to UI - _LIT( KVCXMyVideosCollectionPluginTest, "VCXMyVideosCollectionPluginTest" ); - _LIT( KWhere, "In CheckAlbumExistsL" ); - TestModuleIf().Printf( 0, KVCXMyVideosCollectionPluginTest, KWhere ); - // Print to log file - iLog->Log( KWhere ); - - WaitForRefreshL( EFalse ); // Wait for possible refresh to finish. - - aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); - - int err( KErrNotReady ); - - if( iTester ) - { - TPtrC albumName; - User::LeaveIfError( aItem.GetNextString( albumName ) ); - - TRAP( err, iTester->GetAlbumIdL(albumName) ); - } - - VCXLOGLO1("<<(temp); + videoType = static_cast(temp); VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: videoType: %d", videoType); // Parameter drive letter TPtrC driveLetter; User::LeaveIfError(aItem.GetNextString(driveLetter)); +#ifdef __WINSCW__ + driveLetter.Set(_L("C")); +#endif // Parameter path and filename TPtrC filename; @@ -2832,11 +2680,11 @@ TRAPD( err, CreateVideoFileL( videoType, driveLetter, filename, size, count, ETrue ) ); VCXLOGLO1("<<(temp); + videoType = static_cast(temp); VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: videoType: %d", videoType); // Parameter drive letter TPtrC driveLetter; User::LeaveIfError(aItem.GetNextString(driveLetter)); +#ifdef __WINSCW__ + driveLetter.Set(_L("C")); +#endif // Parameter path and filename TPtrC filename; @@ -2890,14 +2741,14 @@ TRAPD( err, CreateVideoFileL( videoType, driveLetter, filename, size, count, EFalse ) ); VCXLOGLO1("<<"); - return err; + return VCXMVTEST_ERR( err ); } // ----------------------------------------------------------------------------- -// CVcxMyVideosApiTest::CreateVideoFileL +// CIptvMyVideosApiTest::CreateVideoFileL // ----------------------------------------------------------------------------- // -void CVCXMyVideosCollectionPluginTest::CreateVideoFileL( CVCXMyVideosTestUtils::TVcxTestVideoType aType, const TDesC& aDriveLetter, const TDesC& aFileName, TInt aSize, TInt aVideoCount, TBool aDoSync ) +void CVCXMyVideosCollectionPluginTest::CreateVideoFileL( CIptvTestVideoCreator::TIptvTestVideoType aType, const TDesC& aDriveLetter, const TDesC& aFileName, TInt aSize, TInt aVideoCount, TBool aDoSync ) { HBufC* path = HBufC::NewL( 2048 ); CleanupStack::PushL(path); @@ -2970,48 +2821,7 @@ TInt err( KErrNone ); iLastReceivedMessage = -1; - - if(aDoSync) - { - // Disable automatic refresh. - iTester->SetAutomaticRefresh( EFalse ); - } - - RArray messages; - - for(int i = 0; i < aVideoCount; i++) - { - // Create the video. - TRAP( err, iTestUtils->CreateVideoFileL( aType, *path, aSize, ETrue ) ); - if(err != KErrNone) - { - VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: CreateVideoFileL returned error: %d:", err); - } - - if( aDoSync && iTester->GetCurrentLevel() == 3 ) - { - // Wait for insertion event. - messages.Append( KVCXMYVideosTestMessageMpxVideoInserted ); - WaitForMessagesL( ETrue, messages, 60, ETrue ); - messages.Reset(); - } - } - - if( aDoSync ) - { - // Refresh. - messages.Reset(); - iTester->RefreshContentsL(); - messages.Append( KVCXMYVideosTestMessageCollectionOpened ); - CleanupClosePushL( messages ); - WaitForMessagesL( ETrue, messages, 30, ETrue ); - CleanupStack::PopAndDestroy( &messages ); - iTester->SetAutomaticRefresh( ETrue ); - } - - CleanupStack::PopAndDestroy( path ); - -#if 0 + if( aVideoCount == 1 ) { // Save the path for later use. @@ -3019,19 +2829,24 @@ iSideloadedFiles.Append( path ); // Create the video. - TRAP( err, iTestUtils->CreateVideoFileL( aType, *path, aSize ) ); + TRAP( err, iTestCommon->CreateVideoFileL( aType, *path, aSize ) ); if(err != KErrNone) { VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: CreateVideoFileL returned error: %d:", err); } + TRAP_IGNORE( iStats->ActionStartL( KSideloadVideoActionId, _L("Sideload video") ) ); } else { - TRAP( err, iTestUtils->CreateVideoFilesL( aType, *path, aVideoCount, iSideloadedFiles ) ); + TRAP( err, iTestCommon->CreateVideoFilesL( aType, *path, aVideoCount, iSideloadedFiles ) ); if(err != KErrNone) { VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: CreateVideoFilesL returned error: %d:", err); } + for( TInt i = 0; i < aVideoCount; i++ ) + { + TRAP_IGNORE( iStats->ActionStartL( KSideloadVideoActionId, _L("Sideload video") ) ); + } CleanupStack::PopAndDestroy( path ); } @@ -3051,7 +2866,7 @@ RArray messages; for( TInt i=0; i amount ) @@ -3166,7 +2980,7 @@ } VCXLOGLO1("<<EnsureFileIsNotInUse( *path ); + iTestCommon->EnsureFileIsNotInUse( *path ); TInt err = iFs.Delete( path->Des() ); if( err != KErrNone ) { @@ -3246,7 +3060,7 @@ } // ----------------------------------------------------------------------------- -// CVcxMyVideosApiTest::SetDeleteSideloadedVideos +// CIptvMyVideosApiTest::SetDeleteSideloadedVideos // ----------------------------------------------------------------------------- // TInt CVCXMyVideosCollectionPluginTest::SetDeleteSideloadedVideos( CStifItemParser& /* aItem */ ) @@ -3258,7 +3072,601 @@ } // ----------------------------------------------------------------------------- -// CVcxMyVideosApiTest::WaitForMessageL +// CIptvMyVideosApiTest::DownloadL +// ----------------------------------------------------------------------------- +// +TInt CVCXMyVideosCollectionPluginTest::DownloadL( CStifItemParser& aItem ) + { + VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTest::DownloadL ---------->"); + iLastReceivedMessage = -1; + TRAPD( err, DownloadOrResumeL( aItem, EFalse, EFalse ) ); + VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::ResumeDownloadL ---------->"); + iLastReceivedMessage = -1; + TRAPD( err, DownloadOrResumeL( aItem, EFalse, ETrue ) ); + VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::ResumeAllDownloadsL ---------->"); + // Print to UI + _LIT( KVCXMyVideosCollectionPluginTest, "VCXMyVideosCollectionPluginTest" ); + _LIT( KWhere, "In ResumeAllDownloadsL" ); + TestModuleIf().Printf( 0, KVCXMyVideosCollectionPluginTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + TRAPD( err, iTester->ResumeAllDownloadsL() ); + + VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::DownloadUsingMediaL ---------->"); + + if( !iMpxMedia ) + { + VCXLOGLO1("CVCXMyVideosCollectionPluginTest:: Error. iMpxMedia not set!"); + User::Leave( KErrArgument ); + } + + iLastReceivedMessage = -1; + + TRAPD( err, DownloadOrResumeL( aItem, ETrue, EFalse ) ); + VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::ResumeDownloadUsingMediaL ---------->"); + + if( !iMpxMedia ) + { + VCXLOGLO1("CVCXMyVideosCollectionPluginTest:: Error. iMpxMedia not set!"); + User::Leave( KErrArgument ); + } + + iLastReceivedMessage = -1; + + TRAPD( err, DownloadOrResumeL( aItem, ETrue, ETrue ) ); + VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::DownloadOrResumeL"); + // Print to UI + _LIT( KVCXMyVideosCollectionPluginTest, "VCXMyVideosCollectionPluginTest" ); + _LIT( KWhere, "In DownloadOrResumeL" ); + TestModuleIf().Printf( 0, KVCXMyVideosCollectionPluginTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); + + iLastReceivedMessage = -1; + + TUint32 iapId(0); + TPtrC iapName; + User::LeaveIfError( aItem.GetNextString( iapName ) ); + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: iapName: %S", &iapName); + + if( iapName == KVCXTestZeroIap ) + { + iapId = 0; + } + else + if( iapName == KVCXTestInvalidIap ) + { + iapId = 10001; + } + else + { + User::LeaveIfError( iTestCommon->GetIapIdL(iapName, iapId) ); + } + + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: iapId: %d", iapId); + + TPtrC serviceName; + User::LeaveIfError( aItem.GetNextString( serviceName ) ); + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: serviceName: %S", &serviceName); + + TInt serviceId(0); + User::LeaveIfError( iServiceEmu->GetServiceIdL(serviceName, serviceId) ); + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: serviceId: %d", serviceId); + + TInt contentId(0); + User::LeaveIfError( aItem.GetNextInt( contentId ) ); + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: contentId: %d", contentId); + + TInt syncCallInt(0); + User::LeaveIfError( aItem.GetNextInt( syncCallInt ) ); + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: callTypeInt: %d", syncCallInt); + TBool syncCall = static_cast(syncCallInt); + + TPtrC userName; + if( KErrNone == aItem.GetNextString( userName ) ) + { + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: userName: %S", &userName); + } + else + { + userName.Set( _L("") ); + } + + TPtrC password; + if( KErrNone == aItem.GetNextString( password ) ) + { + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: password: %S", &password); + } + else + { + password.Set( _L("") ); + } + + const TPtrC url = iServiceEmu->GetContentUrlL( serviceId, contentId ); + const TPtrC title = iServiceEmu->GetContentTitleL( serviceId, contentId ); + + TInt err(0); + if( !aUseCurrentMedia ) + { + if( !aResume ) + { + TRAP( err, iTester->StartDownloadL( title, iapId, serviceId, contentId, url, syncCall, userName, password, NULL ) ); + } + else + { + TRAP( err, iTester->ResumeDownloadL( title, iapId, serviceId, contentId, url, syncCall, userName, password, NULL ) ); + } + } + else + { + VCXLOGLO1("CVCXMyVideosCollectionPluginTest:: passing current media to MPX plugin."); + if( !aResume ) + { + TRAP( err, iTester->StartDownloadL( title, iapId, serviceId, contentId, url, syncCall, userName, password, iMpxMedia ) ); + } + else + { + TRAP( err, iTester->ResumeDownloadL( title, iapId, serviceId, contentId, url, syncCall, userName, password, iMpxMedia ) ); + } + } + + // Set autoresume on if there's only one paused download. + CVCXMyVideosTestDlWatcher* dlWatcher = iTester->GetDownloadWatcher(); + if( aResume && dlWatcher && !iAutoResume ) + { + TInt pausedDlCount = 0; + for( TInt i=0; iGetDownloadCount(); i++ ) + { + CVCXMyVideosTestDownload* dl = dlWatcher->GetDownloadByIndex( i ); + if( dl->iState == EVcxMyVideosDlStatePaused ) + { + pausedDlCount++; + } + } + if( pausedDlCount == 1 ) + { + iAutoResume = ETrue; + iTester->SetAutoResume( ETrue ); + } + } + + if( err != KErrNone ) + { + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: err: %d", err); + User::Leave( err ); + } + + VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::DownloadUrlL ---------->"); + // Print to UI + _LIT( KVCXMyVideosCollectionPluginTest, "VCXMyVideosCollectionPluginTest" ); + _LIT( KWhere, "In DownloadUrlL" ); + TestModuleIf().Printf( 0, KVCXMyVideosCollectionPluginTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + iLastReceivedMessage = -1; + + aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); + + TUint32 iapId(0); + TPtrC iapName; + User::LeaveIfError( aItem.GetNextString( iapName ) ); + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: iapName: %S", &iapName); + User::LeaveIfError( iTestCommon->GetIapIdL(iapName, iapId) ); + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: iapId: %d", iapId); + + TPtrC url; + User::LeaveIfError( aItem.GetNextString( url ) ); + + TInt syncCallInt(0); + User::LeaveIfError( aItem.GetNextInt( syncCallInt ) ); + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: callTypeInt: %d", syncCallInt); + TBool syncCall = static_cast(syncCallInt); + + TPtrC userName; + if( KErrNone == aItem.GetNextString( userName ) ) + { + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: userName: %S", &userName); + } + else + { + userName.Set( _L("") ); + } + + TPtrC password; + if( KErrNone == aItem.GetNextString( password ) ) + { + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: password: %S", &password); + } + else + { + password.Set( _L("") ); + } + + if( url == KVCXTestZeroUrl) + { + url.Set( _L("" ) ); + } + + TInt err( KErrNone ); + + if( iTester ) + { + if( url == KVCXMYVideosTest2kURLTag ) + { + TRAP( err, iTester->StartDownloadL( _L("2kcharsurl"), iapId, 0, 0, KVCXMYVideosTest2kURL, syncCall, userName, password, NULL ) ); + } + else + if( url == KVCXMYVideosTest1kURLTag ) + { + TRAP( err, iTester->StartDownloadL( _L("1kcharsurl"), iapId, 0, 0, KVCXMYVideosTest1kURL, syncCall, userName, password, NULL ) ); + } + else + { + TRAP( err, iTester->StartDownloadL( _L("urldl"), iapId, 0, 0, url, syncCall, userName, password, NULL ) ); + } + } + + if( err != KErrNone ) + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: err: %d", err); + + VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::CancelDownloadL ---------->"); + // Print to UI + _LIT( KVCXMyVideosCollectionPluginTest, "VCXMyVideosCollectionPluginTest" ); + _LIT( KWhere, "In CancelDownloadL" ); + TestModuleIf().Printf( 0, KVCXMyVideosCollectionPluginTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + iLastReceivedMessage = -1; + + aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); + + TPtrC serviceName; + User::LeaveIfError( aItem.GetNextString( serviceName ) ); + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: serviceName: %S", &serviceName); + + TInt serviceId(0); + User::LeaveIfError( iServiceEmu->GetServiceIdL(serviceName, serviceId) ); + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: serviceId: %d", serviceId); + + TInt contentId(0); + User::LeaveIfError( aItem.GetNextInt( contentId ) ); + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: contentId: %d", contentId); + + TInt syncCallInt(0); + User::LeaveIfError( aItem.GetNextInt( syncCallInt ) ); + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: callTypeInt: %d", syncCallInt); + TBool syncCall = static_cast(syncCallInt); + + const TPtrC url = iServiceEmu->GetContentUrlL( serviceId, contentId ); + + CVCXMyVideosTestDownload* dl = iTester->GetDownloadWatcher()->GetDownload( serviceId, contentId, url ); + + TInt err( KErrNotReady ); + if( !dl ) + { + VCXLOGLO1("CVCXMyVideosCollectionPluginTest:: Could not find download with specified params!"); + } + else + if( iTester ) + { + TRAP( err, iTester->CancelDownloadL( dl, syncCall ) ); + } + + if( err != KErrNone ) + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: err: %d", err); + + VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::CancelDownloadByIdL ---------->"); + // Print to UI + _LIT( KVCXMyVideosCollectionPluginTest, "VCXMyVideosCollectionPluginTest" ); + _LIT( KWhere, "In CancelDownloadByIdL" ); + TestModuleIf().Printf( 0, KVCXMyVideosCollectionPluginTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + iLastReceivedMessage = -1; + + aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); + + TInt mpxId(0); + User::LeaveIfError( aItem.GetNextInt( mpxId ) ); + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: mpxId: %d", mpxId); + + TInt downloadId(0); + User::LeaveIfError( aItem.GetNextInt( downloadId ) ); + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: downloadId: %d", downloadId); + + TInt syncCallInt(0); + User::LeaveIfError( aItem.GetNextInt( syncCallInt ) ); + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: callTypeInt: %d", syncCallInt); + TBool syncCall = static_cast(syncCallInt); + + _LIT(KVCxTestEmptyString, "NULL"); + TPtrC downloadPath; + if( aItem.GetNextString( downloadPath ) != KErrNone ) + { + downloadPath.Set( KVCxTestEmptyString ); + } + + TInt err( KErrNotReady ); + if( iTester ) + { + TRAP( err, iTester->CancelDownloadL( mpxId, downloadId, downloadPath, syncCall ) ); + } + + if( err != KErrNone ) + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: err: %d", err); + + VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::PauseDownloadL ---------->"); + // Print to UI + _LIT( KVCXMyVideosCollectionPluginTest, "VCXMyVideosCollectionPluginTest" ); + _LIT( KWhere, "In PauseDownloadL" ); + TestModuleIf().Printf( 0, KVCXMyVideosCollectionPluginTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + iLastReceivedMessage = -1; + + aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); + + TPtrC serviceName; + User::LeaveIfError( aItem.GetNextString( serviceName ) ); + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: serviceName: %S", &serviceName); + + TInt serviceId(0); + User::LeaveIfError( iServiceEmu->GetServiceIdL(serviceName, serviceId) ); + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: serviceId: %d", serviceId); + + TInt contentId(0); + User::LeaveIfError( aItem.GetNextInt( contentId ) ); + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: contentId: %d", contentId); + + TInt syncCallInt(0); + User::LeaveIfError( aItem.GetNextInt( syncCallInt ) ); + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: callTypeInt: %d", syncCallInt); + TBool syncCall = static_cast(syncCallInt); + + const TPtrC url = iServiceEmu->GetContentUrlL( serviceId, contentId ); + + TInt err( KErrNotReady ); + if( iTester ) + { + // Disable autoresume + iAutoResume = EFalse; + iTester->SetAutoResume( iAutoResume ); + + TRAP( err, iTester->PauseDownloadL( serviceId, contentId, url, syncCall ) ); + } + + if( err != KErrNone ) + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: err: %d", err); + + VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::PauseDownloadByUrlL ---------->"); + // Print to UI + _LIT( KVCXMyVideosCollectionPluginTest, "VCXMyVideosCollectionPluginTest" ); + _LIT( KWhere, "In PauseDownloadByUrlL" ); + TestModuleIf().Printf( 0, KVCXMyVideosCollectionPluginTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + iLastReceivedMessage = -1; + + aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); + + TPtrC url; + User::LeaveIfError( aItem.GetNextString( url ) ); + + TInt err( KErrNotReady ); + if( iTester ) + { + // Disable autoresume + iAutoResume = EFalse; + iTester->SetAutoResume( iAutoResume ); + + TRAP( err, iTester->PauseDownloadL( url, EFalse ) ); + } + + if( err != KErrNone ) + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: err: %d", err); + + VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::CheckDownloadProgressL ---------->"); + // Print to UI + _LIT( KVCXMyVideosCollectionPluginTest, "VCXMyVideosCollectionPluginTest" ); + _LIT( KWhere, "In CheckDownloadProgressL" ); + TestModuleIf().Printf( 0, KVCXMyVideosCollectionPluginTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + iLastReceivedMessage = -1; + + aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing ); + + TPtrC serviceName; + User::LeaveIfError( aItem.GetNextString( serviceName ) ); + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: serviceName: %S", &serviceName); + + TInt serviceId(0); + User::LeaveIfError( iServiceEmu->GetServiceIdL(serviceName, serviceId) ); + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: serviceId: %d", serviceId); + + TInt contentId(0); + User::LeaveIfError( aItem.GetNextInt( contentId ) ); + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: contentId: %d", contentId); + + TInt minimumProgress( 0 ); + User::LeaveIfError( aItem.GetNextInt( minimumProgress ) ); + + const TPtrC url = iServiceEmu->GetContentUrlL( serviceId, contentId ); + + CVCXMyVideosTestDlWatcher* dlWatcher = iTester->GetDownloadWatcher(); + + TInt err( KErrNotReady ); + + if( dlWatcher ) + { + CVCXMyVideosTestDownload* dl = dlWatcher->GetDownload( serviceId, contentId, url ); + + if( dl ) + { + if( dl->iProgress < minimumProgress ) + { + err = KErrCorrupt; + } + else + { + err = KErrNone; + } + } + } + + VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::WaitAllDownloadsL ---------->"); + // Print to UI + _LIT( KVCXMyVideosCollectionPluginTest, "VCXMyVideosCollectionPluginTest" ); + _LIT( KWhere, "In WaitAllDownloadsL" ); + TestModuleIf().Printf( 0, KVCXMyVideosCollectionPluginTest, KWhere ); + // Print to log file + iLog->Log( KWhere ); + + TInt err( KErrNone ); + + TInt minutes(0); + if( aItem.GetNextInt( minutes ) != KErrNone ) + { + minutes = 10; + } + iTimeoutTimer->After( KTimeoutMinute * minutes ); + + iWaitingForAllDownloads = ETrue; + + VCXLOGLO1("<<& aMessages, TInt aTimeout, @@ -3480,7 +3888,7 @@ } // ----------------------------------------------------------------------------- -// CVcxMyVideosApiTest::MapMpxMediaAttribute +// CIptvMyVideosApiTest::MapMpxMediaAttribute // ----------------------------------------------------------------------------- // TInt CVCXMyVideosCollectionPluginTest::MapMpxMediaAttribute( @@ -3745,11 +4153,11 @@ } VCXLOGLO1("<<>>CVCXMyVideosCollectionPluginTest::CheckMediasL"); - WaitForRefreshL( false ); - TInt actualVideoCount(0); // File check @@ -3973,7 +4359,20 @@ actualVideoCount++; - if( !iFileCheckDisabled ) + TInt state = -1; + if( media->IsSupported( KVcxMediaMyVideosDownloadState ) ) + { + state = media->ValueTObjectL( KVcxMediaMyVideosDownloadState ); + } + + TUint32 downloadId = 0; + if( media->IsSupported( KVcxMediaMyVideosDownloadId ) ) + { + downloadId = media->ValueTObjectL( KVcxMediaMyVideosDownloadId ); + } + + // No file check for ongoing downloads + if( !iFileCheckDisabled && ( downloadId == 0 || state == EVcxMyVideosDlStateDownloaded ) ) { if( !iFs.IsValidName( localFilePath ) ) { @@ -4050,7 +4449,7 @@ } // ----------------------------------------------------------------------------- -// CVcxMyVideosApiTest::GetDriveParam +// CIptvMyVideosApiTest::GetDriveParam // ----------------------------------------------------------------------------- // TInt CVCXMyVideosCollectionPluginTest::GetDriveParam( CStifItemParser& aItem, TInt& aDrive ) @@ -4072,11 +4471,11 @@ } } - return err; + return VCXMVTEST_ERR( err ); } // ----------------------------------------------------------------------------- -// CVcxMyVideosApiTest::DoTotalRefreshL +// CIptvMyVideosApiTest::DoTotalRefreshL // ----------------------------------------------------------------------------- // void CVCXMyVideosCollectionPluginTest::DoTotalRefreshL() @@ -4112,7 +4511,7 @@ } // ----------------------------------------------------------------------------- -// CVcxMyVideosApiTest::WaitForRefreshL +// CIptvMyVideosApiTest::WaitForRefreshL // ----------------------------------------------------------------------------- // void CVCXMyVideosCollectionPluginTest::WaitForRefreshL( TBool aForcedWait ) @@ -4128,7 +4527,7 @@ } // ----------------------------------------------------------------------------- -// CVcxMyVideosApiTest::GetMediasForLevelL +// CIptvMyVideosApiTest::GetMediasForLevelL // ----------------------------------------------------------------------------- // CMPXMediaArray* CVCXMyVideosCollectionPluginTest::GetMediasForLevelL( TInt aLevel, TUint aFlagsFilter ) @@ -4235,7 +4634,7 @@ } // ----------------------------------------------------------------------------- -// CVcxMyVideosApiTest::HandleVcxMvTesterMessageL +// CIptvMyVideosApiTest::HandleVcxMvTesterMessageL // ----------------------------------------------------------------------------- // void CVCXMyVideosCollectionPluginTest::HandleVcxMvTesterMessageL( TInt aMessage, TInt aError ) @@ -4264,17 +4663,13 @@ aMessage == KVCXMYVideosTestMessageCollectionOpened || aMessage == KVCXMYVideosTestMessageGotMediasByKMpxId ) { + _LIT(KWhat, "VidCount"); + _LIT(KDesc, "%d"); TInt videoCount = iTester->GetMediaCount(); - if( iTester->GetCurrentOpenLevelIndex() == -1 ) - { - TestModuleIf().Printf( 0, _L("Mv"), _L("CatCount %d"), videoCount ); - } - else - { - TestModuleIf().Printf( 0, _L("Mv"), _L("VidCount %d"), videoCount ); - } + TestModuleIf().Printf( 0, KWhat, KDesc, videoCount ); } + // Waiting for messages from mpx plugin to stop. if( iCoolDownWait ) { @@ -4283,6 +4678,78 @@ VCXLOGLO1("<<GetActiveDownloadCountL(); + TInt downloads = iTester->GetDownloadWatcher()->GetDownloadCount(); + _LIT(KWhat, "Downloads"); + _LIT(KDesc, "%d/%d"); + TestModuleIf().Printf( 0, KWhat, KDesc, activeDownloads, downloads ); + + if( aError != KErrNone ) + { + iLastDownloadError = aError; + } + } + + // Inform script of paused download when auto resume is off. + if( !iWaitingForAllDownloads && aMessage == KVCXMYVideosTestMessageDlPaused && !iAutoResume ) + { + // Add message to waited list and continue processing, check for signaling is done later. + iWaitedTestMessages.Reset(); + iWaitedTestMessages.AppendL( aMessage ); + } + + // Waiting for all downloads to complete. Check downloads and signal if needed. + if( iWaitingForAllDownloads ) + { + TInt activeDownloads = iTester->GetActiveDownloadCountL(); + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: Ongoing download count: %d", activeDownloads); + + if( activeDownloads <= 0 ) + { + iTimeoutTimer->CancelTimer(); + iWaitingForAllDownloads = EFalse; + + TInt downloadCount = iTester->GetDownloadWatcher()->GetDownloadCount(); + TInt maxFailsToSucceed = downloadCount / 3; + TInt fails = iTester->GetDownloadWatcher()->GetFailedDownloadCount(); + + if( maxFailsToSucceed <= 0 ) + { + maxFailsToSucceed = 0; + } + + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: download count: %d", downloadCount); + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: failed download count: %d", fails); + VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: max allowed fails: %d", maxFailsToSucceed); + + if( fails > maxFailsToSucceed ) + { + if( iLastDownloadError != KErrNone ) + { + iEventError = iLastDownloadError; + } + else + { + iEventError = KVCXMYVideosTestMessageDlFailed; + } + } + else + { + iEventError = KErrNone; + } + + // Add message to waited list and continue processing, check for signaling is done later. + iWaitedTestMessages.Reset(); + iWaitedTestMessages.AppendL( aMessage ); + } + } // See if there's cancel needed for move, copy or delete. if( aError == KErrNone && iCancelNextOperation ) @@ -4300,7 +4767,7 @@ } // Check for errors. - if( aError != KErrNone ) + if( aError != KErrNone && !iWaitingForAllDownloads ) { VCXLOGLO1("CVCXMyVideosCollectionPluginTest:: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); VCXLOGLO2("CVCXMyVideosCollectionPluginTest:: ----------> MsgQueue: Error: %d <----------", aError); @@ -4310,7 +4777,7 @@ if( !iMessageWaitIsBlocking ) { VCXLOGLO1("CVCXMyVideosCollectionPluginTest:: ----------> MsgQueue: Signaling <----------"); - Signal( aError ); + Signal( VCXMVTEST_ERR( aError ) ); TestModuleIf().Printf( 0, _L("Signal"), _L("%d"), aError ); iEventError = KErrNone; } @@ -4379,7 +4846,7 @@ if( !iMessageWaitIsBlocking ) { VCXLOGLO1("CVCXMyVideosCollectionPluginTest:: ----------> MsgQueue: Signaling <----------"); - Signal( iEventError ); + Signal( VCXMVTEST_ERR( iEventError ) ); TestModuleIf().Printf( 0, _L("Signal"), _L("%d"), iEventError ); iEventError = KErrNone; } @@ -4400,7 +4867,7 @@ } // ----------------------------------------------------------------------------- -// CVcxEpgEngineTest::TimerComplete +// CIptvEpgEngineTest::TimerComplete // ----------------------------------------------------------------------------- // void CVCXMyVideosCollectionPluginTest::TimerComplete(TInt aTimerId, TInt aError) @@ -4421,8 +4888,11 @@ if( !iMessageWaitIsBlocking ) { VCXLOGLO2( "CVCXMyVideosCollectionPluginTest:: Signaling: %d", iEventError); - Signal( iEventError ); + Signal( VCXMVTEST_ERR( iEventError ) ); } + + TRAP_IGNORE( iStats->ActionEndL( 0, iEventError ) ); + TestModuleIf().Printf( 0, _L("Timedout"), _L("%d"), iEventError ); } } @@ -4433,6 +4903,7 @@ iActiveWait->Stop(); iCoolDownWait = EFalse; + iWaitingForAllDownloads = EFalse; iWaitedTestMessages.Reset(); iLastReceivedMessage = 0; }