First public contribution.
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
21 static RTest test(_L("Testing t_multislot"));
26 // this function was copied from t_sdpartition.cpp
27 TInt FindMmcLocalDriveNumber(TChar aDriveChar, TInt& aLocalDriveNum, TInt aDriveNum)
29 TInt r = fs.CharToDrive(aDriveChar, aDriveNum);
33 r = fs.Drive(driveInfo, aDriveNum);
38 r = fs.Volume(vi, aDriveNum);
42 TMediaSerialNumber serialNum;
43 r = fs.GetMediaSerialNumber(serialNum, aDriveNum);
47 test.Printf(_L("Drive %C size %ld\n"), (char) aDriveChar, vi.iSize);
48 TInt len = serialNum.Length();
49 test.Printf(_L("Serial number (len %d) :"), len);
51 for (n=0; n<len; n+=16)
54 for (TInt m=n; m<n+16; m++)
57 hexBuf.Format(_L("%02X "),serialNum[m]);
67 TInt serialNumbersMatched = 0;
68 for (n=0; n<KMaxLocalDrives; n++)
70 r = drv.Connect(n, chg); //for user area
71 //RDebug::Print(_L("TBusLocalDrive::Connect(%d) %d"), n, r);
75 test.Printf(_L("drive %d: TBusLocalDrive::Connect() failed %d\n"), n, r);
79 TLocalDriveCapsV5Buf capsBuf;
80 TLocalDriveCapsV5& caps = capsBuf();
81 r = drv.Caps(capsBuf);
84 test.Printf(_L("drive %d: TBusLocalDrive::Caps() failed %d\n"), n, r);
88 //RDebug::Print(_L("areaSize %ld cardCapacity %ld"), caps.iSize, caps.iFormatInfo.iCapacity);
90 TPtrC8 localSerialNum(caps.iSerialNum, caps.iSerialNumLength);
91 if (serialNum.Compare(localSerialNum) == 0)
93 serialNumbersMatched++;
94 TBool sizeMatch = (vi.iSize < caps.iSize);
95 test.Printf(_L("drive %d: Serial number match, size match: %S\n"), n, sizeMatch?&KYes:&KNo);
107 return aLocalDriveNum == -1?KErrNotFound:KErrNone;
111 // Manual test - requires user to move a card between two physical slots
112 extern TInt E32Main()
114 test.Start(_L("T_MULTISLOT Test"));
115 test(fs.Connect()==KErrNone);
117 // Get the list of removable drive driver-letters
118 TDriveList driveList;
119 test(fs.DriveList(driveList,KDriveAttRemovable)==KErrNone);
122 TInt length=driveList.Length();
125 // i is drive letter (as int)
126 // for every removable media logical drive
127 for(TInt i=0; i<length; i++)
129 if(driveList[i] == 0)
134 TChar driveChar = i+'A';
135 test.Next(_L("Testing Logical Drive"));
138 TInt FirstlocDrvNum = KErrNotFound;
139 TInt SecondlocDrvNum = KErrNotFound;
142 test.Printf(_L("Logical Drive : %d"), driveNum);
144 // Get local drive number by gettin ghr Serial number fo the card (RFs call), then
145 // enumerating the TBusLocalDrives and finding one that matches.
146 test(FindMmcLocalDriveNumber(driveChar,FirstlocDrvNum,driveNum)==KErrNone);
147 // Got first local drive number, now move card into second slot.
148 test.Printf(_L("<Move MMC Card to second slot, then press any key>"));
150 // Get second local drive number for same logical drive (should be different local drive number).
151 test(FindMmcLocalDriveNumber(driveChar,SecondlocDrvNum,driveNum)==KErrNone);
152 if(FirstlocDrvNum!=SecondlocDrvNum)
157 // else perhaps this wasn't a multislot drive