author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:34:26 +0300 | |
branch | RCL_3 |
changeset 43 | c1f20ce4abcf |
parent 0 | a41df078684a |
child 44 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1996-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 the License "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 |
// f32test\server\b_rep.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
18 |
#define __E32TEST_EXTENSION__ |
0 | 19 |
#include <f32file.h> |
20 |
#include <e32test.h> |
|
21 |
#include "t_server.h" |
|
22 |
||
23 |
GLDEF_D RTest test(_L("B_REP")); |
|
24 |
LOCAL_D RFile TheFile; |
|
25 |
GLDEF_D TFileName nameBuf1=_L("B_REP Test File.PAR"); |
|
26 |
GLDEF_D TBuf8<0x200> testPat1; |
|
27 |
GLDEF_D TBuf8<0x200> chkPat1; |
|
28 |
||
29 |
const TInt noTimes=500; |
|
30 |
const TInt len=24; |
|
31 |
||
32 |
void DoTest() |
|
33 |
{ |
|
34 |
||
35 |
TBuf8<0x10> buf; |
|
36 |
TBuf8<0x10> testBuf; |
|
37 |
buf.SetLength(sizeof(TInt)); |
|
38 |
TInt r; |
|
39 |
for (TInt numb=0;numb<noTimes;numb++) |
|
40 |
{ |
|
41 |
if ((numb&0x1f)==0) |
|
42 |
test.Printf(_L("%d\r"),numb); |
|
43 |
||
44 |
// Replace file and write data |
|
45 |
r=TheFile.Replace(TheFs,nameBuf1,EFileStream); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
46 |
test_KErrNone(r); |
0 | 47 |
r=TheFile.Write(testPat1); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
48 |
test_KErrNone(r); |
0 | 49 |
|
50 |
Mem::Copy(&buf[0],&numb,sizeof(TInt)); |
|
51 |
r=TheFile.Write(buf); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
52 |
test_KErrNone(r); |
0 | 53 |
|
54 |
// Seek to 0 and check data |
|
55 |
TInt pos=0; |
|
56 |
r=TheFile.Seek(ESeekStart,pos); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
57 |
test_KErrNone(r); |
0 | 58 |
test(pos==0); |
59 |
r=TheFile.Read(chkPat1,len); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
60 |
test_KErrNone(r); |
0 | 61 |
test(chkPat1==testPat1); |
62 |
r=TheFile.Read(testBuf,sizeof(TInt)); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
63 |
test_KErrNone(r); |
0 | 64 |
TInt chkNumb=*((TInt*)testBuf.Ptr()); |
65 |
test(chkNumb==numb); |
|
66 |
||
67 |
// Close, then re-open file and check data |
|
68 |
TheFile.Close(); |
|
69 |
r=TheFile.Open(TheFs,nameBuf1,EFileStream); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
70 |
test_KErrNone(r); |
0 | 71 |
r=TheFile.Read(chkPat1,len); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
72 |
test_KErrNone(r); |
0 | 73 |
test(chkPat1==testPat1); |
74 |
r=TheFile.Read(testBuf,sizeof(TInt)); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
75 |
test_KErrNone(r); |
0 | 76 |
chkNumb=*((TInt*)testBuf.Ptr()); |
77 |
test(chkNumb==numb); |
|
78 |
TheFile.Close(); |
|
79 |
} |
|
80 |
test.Printf(_L("\n")); |
|
81 |
r=TheFs.Delete(nameBuf1); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
82 |
test_KErrNone(r); |
0 | 83 |
} |
84 |
||
85 |
GLDEF_C void CallTestsL(void) |
|
86 |
{ |
|
87 |
testPat1=_L8("TextProcessorPa"); |
|
88 |
testPat1.Append(0); |
|
89 |
testPat1.Append(0); |
|
90 |
testPat1.Append(0); |
|
91 |
testPat1.Append(0x16); |
|
92 |
testPat1.Append(0); |
|
93 |
testPat1.Append(0); |
|
94 |
testPat1.Append(0); |
|
95 |
testPat1.Append(4); |
|
96 |
testPat1.Append(0x10); |
|
97 |
||
98 |
test.Start(_L("Root")); |
|
99 |
||
100 |
DoTest(); |
|
101 |
||
102 |
test.Next(_L("Subdirectory")); |
|
103 |
gSessionPath=_L("\\F32-TST\\TEST1\\"); |
|
104 |
TInt r=TheFs.SetSessionPath(gSessionPath); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
105 |
test_KErrNone(r); |
0 | 106 |
r=TheFs.MkDirAll(gSessionPath); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
107 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 108 |
|
109 |
DoTest(); |
|
110 |
||
111 |
test.End(); |
|
112 |
} |