sl@0: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: LOCAL_D RTest theTest(_L("t_cacheddriveinfo")); sl@0: sl@0: // Valid Paths / Folder Name sl@0: const TPtrC KValidPathNameCSystem1Data1=_L("C:\\System1\\Data1\\"); sl@0: const TPtrC KValidDriveZ=_L("Z:\\"); sl@0: const TPtrC KValidDriveC=_L("C:\\"); sl@0: const TPtrC KValidDriveT=_L("T:\\"); sl@0: const TPtrC KValidDriveE=_L("E:\\"); sl@0: sl@0: // InValid Paths / Folder Names sl@0: const TPtrC KNoParameters=_L(""); sl@0: const TPtrC KInValidParameters=_L("3: \\52324424"); sl@0: const TPtrC KInValidDriveP=_L("P:\\"); sl@0: sl@0: // sl@0: //Test macroses and functions sl@0: LOCAL_C void Check(TInt aValue, TInt aLine) sl@0: { sl@0: if(!aValue) sl@0: { sl@0: theTest(EFalse, aLine); sl@0: } sl@0: } sl@0: #define TEST(arg) ::Check((arg), __LINE__) sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-1393 sl@0: @SYMTestCaseDesc Tests BSUL::CCachedDriveInfo sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Pass in various drives and parameters and checks 'Read Only Internal' status. sl@0: The same parameters are checked as in the tests for BaflUtils::DriveIsReadOnlyInternal sl@0: @SYMTestExpectedResults The test must not fail. sl@0: */ sl@0: void TestCachedDriveInfoL(RFs& aFs) sl@0: { sl@0: theTest.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-1393 ")); sl@0: BSUL::CCachedDriveInfo *cachedDriveInfo = BSUL::CCachedDriveInfo::NewLC(aFs); sl@0: sl@0: // the C drive should not be read-only internal sl@0: TEST(!cachedDriveInfo->IsReadOnlyInternalL(KValidPathNameCSystem1Data1)); sl@0: // the Z drive should be read-only internal sl@0: TEST(cachedDriveInfo->IsReadOnlyInternalL(KValidDriveZ)); sl@0: // a non-mounted drive should not be read-only internal sl@0: TEST(!cachedDriveInfo->IsReadOnlyInternalL(KInValidDriveP)); sl@0: // an invalide path should leave with an error sl@0: TRAPD(err, cachedDriveInfo->IsReadOnlyInternalL(KNoParameters)); sl@0: TEST(err != KErrNone); sl@0: // an invalide path should leave with an error sl@0: TRAP(err, cachedDriveInfo->IsReadOnlyInternalL(KInValidParameters)); sl@0: TEST(err != KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(cachedDriveInfo); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-1680 sl@0: @SYMTestCaseDesc Tests BSUL::CCachedDriveInfo sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Pass in various drives and parameters and checks all kinds attributes: sl@0: KDriveAttSubsted,KDriveAttRemote, KDriveAttLocal, KDriveAttInternal, KDriveAttRemovable sl@0: KDriveAttRedirected,KDriveAttRom. sl@0: @SYMTestExpectedResults The test must not fail. sl@0: */ sl@0: void TestCachedDriveInfoFlagSetL(RFs& aFs) sl@0: { sl@0: sl@0: theTest.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-1680 ")); sl@0: TFileName fileName; sl@0: TInt err; sl@0: if(!BaflUtils::PathExists(aFs, _L("C:\\Logs\\"))) sl@0: { sl@0: err = aFs.MkDir(_L("C:\\Logs\\")); sl@0: } sl@0: sl@0: err=aFs.SetSubst(_L("C:\\Logs\\"),EDriveO); sl@0: TEST(err==KErrNone); sl@0: err=aFs.Subst(fileName,EDriveO); sl@0: TEST(err==KErrNone); sl@0: TEST(fileName==_L("C:\\Logs\\")); sl@0: sl@0: BSUL::CCachedDriveInfo *cachedDriveInfo = BSUL::CCachedDriveInfo::NewLC(aFs); sl@0: sl@0: // The O drive should be subst drive sl@0: TEST(cachedDriveInfo->IsFlagSetOnDriveL(EDriveO, KDriveAttSubsted)); sl@0: sl@0: // The O drive should not be local drive sl@0: TEST(!cachedDriveInfo->IsFlagSetOnDriveL(EDriveO, KDriveAttLocal)); sl@0: sl@0: // The O drive should not be remote drive sl@0: TEST(!cachedDriveInfo->IsFlagSetOnDriveL(EDriveO, KDriveAttRemote)); sl@0: sl@0: // The C drive should be local drive sl@0: TEST(cachedDriveInfo->IsFlagSetOnDriveL(KValidDriveC, KDriveAttLocal)); sl@0: sl@0: // The C drive should be internal drive sl@0: TEST(cachedDriveInfo->IsFlagSetOnDriveL(KValidDriveC, KDriveAttInternal)); sl@0: sl@0: // The C drive should not be remote drive sl@0: TEST(!cachedDriveInfo->IsFlagSetOnDriveL(KValidDriveC, KDriveAttRemote)); sl@0: sl@0: // The C drive should not be removable drive sl@0: TEST(!cachedDriveInfo->IsFlagSetOnDriveL(KValidDriveC, KDriveAttRemovable)); sl@0: sl@0: // The C drive should be local and internal drive sl@0: TEST(cachedDriveInfo->IsFlagSetOnDriveL(KValidDriveC, KDriveAttInternal|KDriveAttInternal)); sl@0: sl@0: // The C drive should be local and internal drive, but not remote sl@0: TEST(!cachedDriveInfo->IsFlagSetOnDriveL(KValidDriveC, KDriveAttInternal|KDriveAttInternal|KDriveAttRemote)); sl@0: sl@0: // The Z drive should rom drive. sl@0: TEST(cachedDriveInfo->IsFlagSetOnDriveL(KValidDriveZ, KDriveAttRom)); sl@0: sl@0: //The Z drive should rom, and internal drive. sl@0: TEST(cachedDriveInfo->IsFlagSetOnDriveL(KValidDriveZ, KDriveAttRom|KDriveAttInternal)); sl@0: sl@0: //The Z drive should rom and internal drive, but not removable sl@0: TEST(!cachedDriveInfo->IsFlagSetOnDriveL(KValidDriveZ, KDriveAttRom|KDriveAttInternal|KDriveAttRemovable)); sl@0: sl@0: // The Z drive should not be Redirected drive sl@0: TEST(!cachedDriveInfo->IsFlagSetOnDriveL(KValidDriveZ, KDriveAttRedirected)); sl@0: sl@0: // The Z drive should rom drive, but not Redirected sl@0: TEST(!cachedDriveInfo->IsFlagSetOnDriveL(KValidDriveZ, KDriveAttRom|KDriveAttRedirected)); sl@0: sl@0: // The T drive should be a removable, local drive on winscw, E drive on hardware sl@0: #if defined __WINSCW__ sl@0: TEST(cachedDriveInfo->IsFlagSetOnDriveL(KValidDriveT, KDriveAttRemovable|KDriveAttLocal)); sl@0: #elif defined __X86GCC__ sl@0: // No removable drives on X86 platform sl@0: #else sl@0: TEST(cachedDriveInfo->IsFlagSetOnDriveL(KValidDriveE, KDriveAttRemovable|KDriveAttLocal)); sl@0: #endif sl@0: sl@0: //clean up subst drive sl@0: err=aFs.SetSubst(_L(""),EDriveO); sl@0: TEST(err==KErrNone); sl@0: CleanupStack::PopAndDestroy(cachedDriveInfo); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-4014 sl@0: @SYMTestCaseDesc Tests BSUL::CCachedDriveInfo sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Pass in various drives and media types to verify media type of drives. sl@0: @SYMTestExpectedResults The media type must be as expected for each drive. sl@0: @SYMDEF DEF109839 sl@0: */ sl@0: void TestCachedDriveMediaTypeL(RFs& aFs) sl@0: { sl@0: theTest.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4014 ")); sl@0: BSUL::CCachedDriveInfo *cachedDriveInfo = BSUL::CCachedDriveInfo::NewLC(aFs); sl@0: sl@0: // the T drive should be a hard disk media type on WINSCW, E drive on hardware sl@0: #ifdef __WINSCW__ sl@0: TEST(cachedDriveInfo->MediaTypeL(KValidDriveT,EMediaHardDisk)); sl@0: #elif defined __X86GCC__ sl@0: // No removeable drive in X86 platform sl@0: #else sl@0: TEST(cachedDriveInfo->MediaTypeL(KValidDriveE,EMediaHardDisk)); sl@0: #endif sl@0: sl@0: // the Z drive should be a Rom drive sl@0: TEST(cachedDriveInfo->MediaTypeL(KValidDriveZ,EMediaRom)); sl@0: sl@0: #ifdef __WINSCW__ sl@0: // the C drive should report as EMediaHardDisk for the PC Drive sl@0: TEST(cachedDriveInfo->MediaTypeL(KValidDriveC,EMediaHardDisk)); sl@0: #elif defined __EPOC32__ sl@0: // the C drive could be a RAM or NAND flash drive depending on how the ROM is built. sl@0: // the C drive should report as EMediaHardDisk for WDP enabled configuraion sl@0: TEST(cachedDriveInfo->MediaTypeL(KValidDriveC,EMediaRam) || cachedDriveInfo->MediaTypeL(KValidDriveC,EMediaNANDFlash) || cachedDriveInfo->MediaTypeL(KValidDriveC,EMediaHardDisk)); sl@0: #endif sl@0: sl@0: // a non-mounted drive should not be EMediaHardDisk sl@0: TMediaType actual; sl@0: TEST(!cachedDriveInfo->MediaTypeL(KInValidDriveP,EMediaHardDisk,&actual)); sl@0: TEST(actual == EMediaNotPresent); sl@0: sl@0: CleanupStack::PopAndDestroy(cachedDriveInfo); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-4015 sl@0: @SYMTestCaseDesc Tests BSUL::CCachedDriveInfo sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Call the GetDefaultRemovableMemoryCardDriveL API on WINSCW and hardware. sl@0: @SYMTestExpectedResults The MMC drive must be found. sl@0: @SYMDEF DEF109839 sl@0: */ sl@0: void TestCachedDriveRemovableMemoryCardDriveL(RFs& aFs) sl@0: { sl@0: theTest.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-4015 ")); sl@0: BSUL::CCachedDriveInfo *cachedDriveInfo = BSUL::CCachedDriveInfo::NewLC(aFs); sl@0: sl@0: // the T drive should be a hard disk media type on WINSCW, E drive on hardware sl@0: #ifdef __WINSCW__ sl@0: TEST(cachedDriveInfo->GetDefaultRemovableMemoryCardDriveL() == TDriveUnit(KValidDriveT)); sl@0: #elif defined __X86GCC__ sl@0: // No removable drives in X86 platform sl@0: TRAPD(err,cachedDriveInfo->GetDefaultRemovableMemoryCardDriveL()); sl@0: TEST(err == KErrNotFound); sl@0: #else sl@0: TEST(cachedDriveInfo->GetDefaultRemovableMemoryCardDriveL() == TDriveUnit(KValidDriveE)); sl@0: #endif sl@0: sl@0: CleanupStack::PopAndDestroy(cachedDriveInfo); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-1394 sl@0: @SYMTestCaseDesc Tests BSUL::CCachedDriveInfo sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Executes tests for BSUL::CCachedDriveInfo. sl@0: @SYMTestExpectedResults The test must not fail. sl@0: */ sl@0: void DoTests() sl@0: { sl@0: theTest.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-1394 ")); sl@0: RFs fs; sl@0: fs.Connect(); sl@0: CleanupClosePushL(fs); sl@0: sl@0: TestCachedDriveInfoL(fs); sl@0: TestCachedDriveInfoFlagSetL(fs); sl@0: TestCachedDriveMediaTypeL(fs); sl@0: TestCachedDriveRemovableMemoryCardDriveL(fs); sl@0: sl@0: CleanupStack::PopAndDestroy(&fs); sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: __UHEAP_MARK; sl@0: CTrapCleanup *cleanup=CTrapCleanup::New(); sl@0: theTest.Title(); sl@0: theTest.Start(_L("Testing t_cacheddriveinfo")); sl@0: TRAPD(err,DoTests()); sl@0: TEST(!err); sl@0: theTest.End(); sl@0: theTest.Close(); sl@0: delete cleanup; sl@0: __UHEAP_MARKEND; sl@0: return(0); sl@0: }