|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Tests EikFileUtils::SortByTable() function. |
|
15 // |
|
16 // |
|
17 |
|
18 #include <e32test.h> |
|
19 #include <f32file.h> |
|
20 #include <bautils.h> |
|
21 |
|
22 LOCAL_D RTest test(_L("t_fileutils.exe")); |
|
23 |
|
24 const TInt KSortTableUid1=0x3f631; |
|
25 const TInt KSortTableUid2=0x276a9; |
|
26 |
|
27 /** |
|
28 @SYMTestCaseID SYSLIB-BAFL-CT-0486 |
|
29 @SYMTestCaseDesc Tests for the sorting of files containing an array of UIDs. |
|
30 @SYMTestPriority High |
|
31 @SYMTestActions Tests BaflUtils::SortByTable() function. |
|
32 @SYMTestExpectedResults Tests must not fail |
|
33 @SYMREQ REQ0000 |
|
34 */ |
|
35 void TestSortByTableL() |
|
36 { |
|
37 CDir* theFileList; |
|
38 TInt theAttribs=KEntryAttMatchMask|KEntryAttAllowUid; |
|
39 TFileName theCurrentPath = _L("Z:\\system\\documents\\baflsortbytabletest\\"); |
|
40 |
|
41 RFs fileSession; |
|
42 User::LeaveIfError(fileSession.Connect()); |
|
43 CleanupClosePushL(fileSession); |
|
44 |
|
45 TInt ret=fileSession.GetDir(theCurrentPath,theAttribs,ESortByName,theFileList); |
|
46 test(ret==KErrNone); |
|
47 CleanupStack::PushL(theFileList); |
|
48 |
|
49 CBaflFileSortTable*theTable = new (ELeave) CBaflFileSortTable(); |
|
50 CleanupStack::PushL(theTable); |
|
51 |
|
52 TInt insertErr; |
|
53 |
|
54 TRAP(insertErr,theTable->InsertL(0,TUid::Uid(KSortTableUid1))); |
|
55 test(insertErr==KErrNone); |
|
56 |
|
57 TRAP(insertErr,theTable->InsertL(1,TUid::Uid(KSortTableUid2))); |
|
58 test(insertErr==KErrNone); |
|
59 |
|
60 test.Printf(_L("\nGet the names of the files sorted by alphabetical order\n")); |
|
61 for(TInt theIndex1 = 0; theIndex1 < theFileList->Count(); theIndex1++) |
|
62 { |
|
63 TEntry theEntry = (*theFileList)[theIndex1]; |
|
64 TUid theUid1 = theEntry[2]; |
|
65 test.Printf(_L("The %d file in list %S, Uid = 0x%x\n"), theIndex1 + 1, &theEntry.iName, theUid1.iUid); |
|
66 switch(theIndex1) |
|
67 { |
|
68 case 0: |
|
69 test(theEntry.iName == _L("addcert.rsc")); |
|
70 break; |
|
71 case 1: |
|
72 test(theEntry.iName == _L("help.rsc")); |
|
73 break; |
|
74 case 2: |
|
75 test(theEntry.iName == _L("msgeditor.rsc")); |
|
76 break; |
|
77 case 3: |
|
78 test(theEntry.iName == _L("smlprogress.rsc")); |
|
79 break; |
|
80 default: |
|
81 break; |
|
82 } |
|
83 } |
|
84 |
|
85 TInt sortErr = BaflUtils::SortByTable(*theFileList, theTable); |
|
86 test(sortErr==KErrNone); |
|
87 |
|
88 test.Printf(_L("\nGet the names of the files sorted by the Uid's table\n")); |
|
89 for(TInt theIndex = 0; theIndex < theFileList->Count(); theIndex++) |
|
90 { |
|
91 TEntry theEntry = (*theFileList)[theIndex]; |
|
92 TUid theUid1 = theEntry[2]; |
|
93 |
|
94 test.Printf(_L("The %d file in list %S, Uid = 0x%x\n"), theIndex + 1, &theEntry.iName, theUid1.iUid); |
|
95 switch(theIndex) |
|
96 { |
|
97 case 0: |
|
98 test(theEntry.iName == _L("msgeditor.rsc")); |
|
99 break; |
|
100 case 1: |
|
101 test(theEntry.iName == _L("help.rsc")); |
|
102 break; |
|
103 case 2: |
|
104 test(theEntry.iName == _L("addcert.rsc")); |
|
105 break; |
|
106 case 3: |
|
107 test(theEntry.iName == _L("smlprogress.rsc")); |
|
108 break; |
|
109 default: |
|
110 break; |
|
111 } |
|
112 } |
|
113 CleanupStack::PopAndDestroy(3, &fileSession); |
|
114 } |
|
115 |
|
116 |
|
117 void DoTestsL() |
|
118 { |
|
119 __UHEAP_MARK; |
|
120 |
|
121 TRAPD(testsortErr,TestSortByTableL()); |
|
122 test(testsortErr==KErrNone); |
|
123 |
|
124 __UHEAP_MARKEND; |
|
125 } |
|
126 |
|
127 |
|
128 GLDEF_C TInt E32Main() |
|
129 { |
|
130 __UHEAP_MARK; |
|
131 |
|
132 test.Title(); |
|
133 test.Start(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0486 SORT BY TABLE TEST ")); |
|
134 |
|
135 // get clean-up stack |
|
136 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
137 |
|
138 test (cleanup!=0); |
|
139 |
|
140 TRAPD(err,DoTestsL()); |
|
141 test(err==KErrNone); |
|
142 |
|
143 delete cleanup; |
|
144 test.End(); |
|
145 test.Close(); |
|
146 |
|
147 __UHEAP_MARKEND; |
|
148 return(KErrNone); |
|
149 } |