author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Thu, 07 Jan 2010 13:38:45 +0200 | |
changeset 6 | 0173bcd7697c |
parent 0 | a41df078684a |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
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". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* |
|
16 |
*/ |
|
17 |
#include <e32test.h> |
|
18 |
#include <f32file.h> |
|
6
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
19 |
#include <d32locd.h> |
0 | 20 |
|
21 |
static RTest test(_L("Testing t_multislot")); |
|
22 |
_LIT(KYes, "yes"); |
|
23 |
_LIT(KNo, "no"); |
|
24 |
static RFs fs; |
|
25 |
||
26 |
// this function was copied from t_sdpartition.cpp |
|
27 |
TInt FindMmcLocalDriveNumber(TChar aDriveChar, TInt& aLocalDriveNum, TInt aDriveNum) |
|
28 |
{ |
|
29 |
TInt r = fs.CharToDrive(aDriveChar, aDriveNum); |
|
30 |
test(r==KErrNone); |
|
31 |
||
32 |
TDriveInfo driveInfo; |
|
33 |
r = fs.Drive(driveInfo, aDriveNum); |
|
34 |
test(r==KErrNone); |
|
35 |
||
36 |
||
37 |
TVolumeInfo vi; |
|
38 |
r = fs.Volume(vi, aDriveNum); |
|
39 |
test(r==KErrNone); |
|
40 |
||
41 |
||
42 |
TMediaSerialNumber serialNum; |
|
43 |
r = fs.GetMediaSerialNumber(serialNum, aDriveNum); |
|
44 |
test(r==KErrNone); |
|
45 |
||
46 |
||
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); |
|
50 |
TInt n; |
|
51 |
for (n=0; n<len; n+=16) |
|
52 |
{ |
|
53 |
TBuf16<16*3 +1> buf; |
|
54 |
for (TInt m=n; m<n+16; m++) |
|
55 |
{ |
|
56 |
TBuf16<3> hexBuf; |
|
57 |
hexBuf.Format(_L("%02X "),serialNum[m]); |
|
58 |
buf.Append(hexBuf); |
|
59 |
} |
|
60 |
buf.Append(_L("\n")); |
|
61 |
test.Printf(buf); |
|
62 |
} |
|
63 |
||
64 |
TBusLocalDrive drv; |
|
65 |
TBool chg(EFalse); |
|
66 |
aLocalDriveNum = -1; |
|
67 |
TInt serialNumbersMatched = 0; |
|
68 |
for (n=0; n<KMaxLocalDrives; n++) |
|
69 |
{ |
|
70 |
r = drv.Connect(n, chg); //for user area |
|
71 |
//RDebug::Print(_L("TBusLocalDrive::Connect(%d) %d"), n, r); |
|
72 |
||
73 |
if(r != KErrNone) |
|
74 |
{ |
|
75 |
test.Printf(_L("drive %d: TBusLocalDrive::Connect() failed %d\n"), n, r); |
|
76 |
continue; |
|
77 |
} |
|
78 |
||
79 |
TLocalDriveCapsV5Buf capsBuf; |
|
80 |
TLocalDriveCapsV5& caps = capsBuf(); |
|
81 |
r = drv.Caps(capsBuf); |
|
82 |
if(r != KErrNone) |
|
83 |
{ |
|
84 |
test.Printf(_L("drive %d: TBusLocalDrive::Caps() failed %d\n"), n, r); |
|
85 |
continue; |
|
86 |
} |
|
87 |
||
88 |
//RDebug::Print(_L("areaSize %ld cardCapacity %ld"), caps.iSize, caps.iFormatInfo.iCapacity); |
|
89 |
||
90 |
TPtrC8 localSerialNum(caps.iSerialNum, caps.iSerialNumLength); |
|
91 |
if (serialNum.Compare(localSerialNum) == 0) |
|
92 |
{ |
|
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); |
|
96 |
if (sizeMatch) |
|
97 |
{ |
|
98 |
aLocalDriveNum = n; |
|
99 |
drv.Disconnect(); |
|
100 |
break; |
|
101 |
} |
|
102 |
} |
|
103 |
drv.Disconnect(); |
|
104 |
} |
|
105 |
||
106 |
||
107 |
return aLocalDriveNum == -1?KErrNotFound:KErrNone; |
|
108 |
} |
|
109 |
||
110 |
||
111 |
// Manual test - requires user to move a card between two physical slots |
|
112 |
extern TInt E32Main() |
|
113 |
{ |
|
114 |
test.Start(_L("T_MULTISLOT Test")); |
|
115 |
test(fs.Connect()==KErrNone); |
|
116 |
||
117 |
// Get the list of removable drive driver-letters |
|
118 |
TDriveList driveList; |
|
119 |
test(fs.DriveList(driveList,KDriveAttRemovable)==KErrNone); |
|
120 |
||
121 |
||
122 |
TInt length=driveList.Length(); |
|
123 |
TBool pass = EFalse; |
|
124 |
||
125 |
// i is drive letter (as int) |
|
126 |
// for every removable media logical drive |
|
127 |
for(TInt i=0; i<length; i++) |
|
128 |
{ |
|
129 |
if(driveList[i] == 0) |
|
130 |
{ |
|
131 |
continue; |
|
132 |
} |
|
133 |
||
134 |
TChar driveChar = i+'A'; |
|
135 |
test.Next(_L("Testing Logical Drive")); |
|
136 |
||
137 |
||
138 |
TInt FirstlocDrvNum = KErrNotFound; |
|
139 |
TInt SecondlocDrvNum = KErrNotFound; |
|
140 |
TInt driveNum = -1; |
|
141 |
driveNum = i+'A'; |
|
142 |
test.Printf(_L("Logical Drive : %d"), driveNum); |
|
143 |
||
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>")); |
|
149 |
test.Getch(); |
|
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) |
|
153 |
{ |
|
154 |
pass=ETrue; |
|
155 |
break; |
|
156 |
} |
|
157 |
// else perhaps this wasn't a multislot drive |
|
158 |
} |
|
159 |
test(pass); |
|
160 |
test.End(); |
|
161 |
test.Close(); |
|
162 |
||
163 |
fs.Close(); |
|
164 |
return KErrNone; |
|
165 |
} |
|
166 |