sl@0
|
1 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <centralrepository.h>
|
sl@0
|
17 |
#include <e32test.h>
|
sl@0
|
18 |
#include <f32file.h>
|
sl@0
|
19 |
#include "../../test/t_cenrep_helper.h"
|
sl@0
|
20 |
|
sl@0
|
21 |
_LIT( KCentralRepositoryServerName, "Centralrepositorysrv");
|
sl@0
|
22 |
|
sl@0
|
23 |
enum TestMode{
|
sl@0
|
24 |
ETxt,
|
sl@0
|
25 |
ECre,
|
sl@0
|
26 |
EAutoCre,
|
sl@0
|
27 |
EAutoTxt
|
sl@0
|
28 |
};
|
sl@0
|
29 |
|
sl@0
|
30 |
RTest TheTest(_L("Central Repository Tests"));
|
sl@0
|
31 |
RFs TheFs;
|
sl@0
|
32 |
|
sl@0
|
33 |
//uid for txt testing purpose
|
sl@0
|
34 |
const TUid uid={0x000001FF};
|
sl@0
|
35 |
//uid for cre testing purpose
|
sl@0
|
36 |
const TUid uidcre={0x00001FFF};
|
sl@0
|
37 |
const TUid uidcretest = {0x000002FF};
|
sl@0
|
38 |
const TUid uidmetatest = {0x00022222};
|
sl@0
|
39 |
|
sl@0
|
40 |
/** FILES FOR AUTO NEWL TESTING */
|
sl@0
|
41 |
_LIT(KPrivateTemplateCreOutFile,"c:\\private\\10202be9\\persists\\00001fff.cre");
|
sl@0
|
42 |
_LIT(KPrivateTemplateTxtOutFile,"c:\\private\\10202be9\\persists\\000001ff.cre");
|
sl@0
|
43 |
|
sl@0
|
44 |
_LIT(KPersistCreFileTxt,"c:\\private\\10202be9\\persists\\000001ff.cre");
|
sl@0
|
45 |
_LIT(KPersistCreFileCre,"c:\\private\\10202be9\\persists\\000002ff.cre");
|
sl@0
|
46 |
_LIT(KPersistMetaTestFile,"c:\\private\\10202be9\\persists\\00022222.cre");
|
sl@0
|
47 |
|
sl@0
|
48 |
_LIT(KTxtTestRefFile,"c:\\private\\00000000\\ref_winscwtxt.cre");
|
sl@0
|
49 |
_LIT(KCreTestRefFile,"c:\\private\\00000000\\ref_winscwcre.cre");
|
sl@0
|
50 |
|
sl@0
|
51 |
_LIT(KMetaTestRefFile,"c:\\private\\00000000\\ref_00022222.cre");
|
sl@0
|
52 |
|
sl@0
|
53 |
_LIT(KCrcRecordFile,"c:\\crc.txt");
|
sl@0
|
54 |
|
sl@0
|
55 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
56 |
|
sl@0
|
57 |
|
sl@0
|
58 |
//DEFINED IN THE COMMON CPP FILE
|
sl@0
|
59 |
extern TInt CopyFile(const TDesC& aSource, const TDesC& aTarget);
|
sl@0
|
60 |
extern void ObjectCreateDeleteOOM(TUid aUid,const TDesC& aInFilePath,const TDesC& aOutFilePath,TUint aTestMode);
|
sl@0
|
61 |
extern void OomTest(void (*testFuncL)(CRepository* aRepository),TUid aUid,const TDesC& aInFilePath,const TDesC& aOutFilePath,TUint aTestMode);
|
sl@0
|
62 |
extern void BasicFunctionL(TUid aUid,const TDesC& aInFilePath,const TDesC& aOutFilePath,TUint aTestMode);
|
sl@0
|
63 |
extern void OomBasicFunction(TUid aUid,const TDesC& aInFilePath,const TDesC& aOutFilePath,TUint aTestMode);
|
sl@0
|
64 |
extern void DoFileCompL(const TDesC& aGenerated, const TDesC& aReference, TUint32& aCrcValue);
|
sl@0
|
65 |
extern void DEF130394L(TUid aUid);
|
sl@0
|
66 |
|
sl@0
|
67 |
void InitialiseLC(CRepository*& aRepository,TUid aUid,const TDesC& /**aInFilePath */,const TDesC& /**aOutFilePath*/,TUint /**aTestMode*/)
|
sl@0
|
68 |
{
|
sl@0
|
69 |
aRepository=CRepository::NewLC(aUid);
|
sl@0
|
70 |
}
|
sl@0
|
71 |
|
sl@0
|
72 |
void SetupEnv(const TDesC& /**aInFilePath*/,const TDesC& aOutFilePath,TUint aTestMode)
|
sl@0
|
73 |
{
|
sl@0
|
74 |
if (aTestMode==EAutoCre || aTestMode==EAutoTxt)
|
sl@0
|
75 |
TheFs.Delete(aOutFilePath);
|
sl@0
|
76 |
}
|
sl@0
|
77 |
|
sl@0
|
78 |
void CrcReferenceGenL()
|
sl@0
|
79 |
{
|
sl@0
|
80 |
KillProcess(KCentralRepositoryServerName);
|
sl@0
|
81 |
|
sl@0
|
82 |
TheFs.Delete(KCrcRecordFile);
|
sl@0
|
83 |
|
sl@0
|
84 |
// Auto Cre Test
|
sl@0
|
85 |
TUint32 crcCre;
|
sl@0
|
86 |
BasicFunctionL(uidcretest, KNullDesC, KPersistCreFileCre, EAutoCre);
|
sl@0
|
87 |
DoFileCompL(KPersistCreFileCre, KCreTestRefFile, crcCre);
|
sl@0
|
88 |
|
sl@0
|
89 |
// Auto Txt Test
|
sl@0
|
90 |
TUint32 crcTxt = 0;
|
sl@0
|
91 |
BasicFunctionL(uid, KNullDesC(), KPersistCreFileTxt, EAutoTxt);
|
sl@0
|
92 |
DoFileCompL(KPersistCreFileTxt, KTxtTestRefFile, crcTxt);
|
sl@0
|
93 |
|
sl@0
|
94 |
TBuf8<100> buf;
|
sl@0
|
95 |
buf.Format(_L8("%u-%u"), crcTxt, crcCre);
|
sl@0
|
96 |
|
sl@0
|
97 |
RFile file;
|
sl@0
|
98 |
file.Create(TheFs, KCrcRecordFile, EFileWrite);
|
sl@0
|
99 |
file.Write(buf);
|
sl@0
|
100 |
}
|
sl@0
|
101 |
|
sl@0
|
102 |
/**
|
sl@0
|
103 |
@SYMTestCaseID PDS-CENTRALREPOSITORY-CT-4080
|
sl@0
|
104 |
@SYMTestCaseDesc Test for DEF130394
|
sl@0
|
105 |
@SYMTestPriority Normal
|
sl@0
|
106 |
@SYMTestActions This is Part 1 of the test - Part 2 is in t_cenrreppc.cpp
|
sl@0
|
107 |
Loading a repository multiple times and copy the created cre file
|
sl@0
|
108 |
to the test location of PC test.
|
sl@0
|
109 |
@SYMTestExpectedResults A reference cre file in PC test test location
|
sl@0
|
110 |
@SYMDEF DEF130394
|
sl@0
|
111 |
*/
|
sl@0
|
112 |
void TestForDEF130394L()
|
sl@0
|
113 |
{
|
sl@0
|
114 |
TheFs.Delete(KPersistMetaTestFile);
|
sl@0
|
115 |
DEF130394L(uidmetatest);
|
sl@0
|
116 |
CopyFile(KPersistMetaTestFile, KMetaTestRefFile);
|
sl@0
|
117 |
}
|
sl@0
|
118 |
|
sl@0
|
119 |
/**
|
sl@0
|
120 |
@SYMTestCaseID SYSLIB-CENTRALREPOSITORY-CT-4043
|
sl@0
|
121 |
@SYMTestCaseDesc Client-Server-side CentralRepository functionality test
|
sl@0
|
122 |
@SYMTestPriority High
|
sl@0
|
123 |
@SYMTestActions Wrapper function calling up test functions. Test functions include test for basic
|
sl@0
|
124 |
functions of the component, OOm test and CRC comparison test.
|
sl@0
|
125 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
126 |
@SYMPREQ PREQ2111
|
sl@0
|
127 |
*/
|
sl@0
|
128 |
LOCAL_C void MainL()
|
sl@0
|
129 |
{
|
sl@0
|
130 |
//Note these files are equivalent, the cre being generated from txt
|
sl@0
|
131 |
TheTest.Start(_L("Functional TXT tests"));
|
sl@0
|
132 |
|
sl@0
|
133 |
User::LeaveIfError(TheFs.Connect());
|
sl@0
|
134 |
|
sl@0
|
135 |
//CRE exists only
|
sl@0
|
136 |
TheTest.Next(_L("Functional NewLC Auto CRE tests"));
|
sl@0
|
137 |
BasicFunctionL(uidcre,KNullDesC(),KPrivateTemplateCreOutFile(),EAutoCre);
|
sl@0
|
138 |
TheTest.Next(_L("OOM NewLC Auto CRE tests"));
|
sl@0
|
139 |
ObjectCreateDeleteOOM(uidcre,KNullDesC(),KPrivateTemplateCreOutFile(),EAutoCre);
|
sl@0
|
140 |
OomBasicFunction(uidcre,KNullDesC(),KPrivateTemplateCreOutFile(),EAutoCre);
|
sl@0
|
141 |
|
sl@0
|
142 |
//TXT exists only
|
sl@0
|
143 |
TheTest.Next(_L("Functional NewLC Auto TXT tests"));
|
sl@0
|
144 |
BasicFunctionL(uid,KNullDesC(),KPrivateTemplateTxtOutFile(),EAutoTxt);
|
sl@0
|
145 |
TheTest.Next(_L("OOM NewLC Auto TXT tests"));
|
sl@0
|
146 |
ObjectCreateDeleteOOM(uid,KNullDesC(),KPrivateTemplateTxtOutFile(),EAutoTxt);
|
sl@0
|
147 |
OomBasicFunction(uid,KNullDesC(),KPrivateTemplateTxtOutFile(),EAutoTxt);
|
sl@0
|
148 |
|
sl@0
|
149 |
#ifdef __WINSCW__ // no need to run on ARM
|
sl@0
|
150 |
TheTest.Next(_L("CRC comparison preparation for PC side test"));
|
sl@0
|
151 |
CrcReferenceGenL();
|
sl@0
|
152 |
|
sl@0
|
153 |
TheTest.Next(_L("Test for DEF130394L"));
|
sl@0
|
154 |
TestForDEF130394L();
|
sl@0
|
155 |
#endif
|
sl@0
|
156 |
|
sl@0
|
157 |
TheFs.Close();
|
sl@0
|
158 |
TheTest.End();
|
sl@0
|
159 |
TheTest.Close();
|
sl@0
|
160 |
}
|
sl@0
|
161 |
|
sl@0
|
162 |
TInt E32Main()
|
sl@0
|
163 |
{
|
sl@0
|
164 |
__UHEAP_MARK;
|
sl@0
|
165 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
sl@0
|
166 |
if(!cleanup)
|
sl@0
|
167 |
return KErrNoMemory;
|
sl@0
|
168 |
|
sl@0
|
169 |
TRAPD(err, MainL());
|
sl@0
|
170 |
if (err != KErrNone)
|
sl@0
|
171 |
User::Panic(_L("Testing failed: "), err);
|
sl@0
|
172 |
|
sl@0
|
173 |
delete cleanup;
|
sl@0
|
174 |
__UHEAP_MARKEND;
|
sl@0
|
175 |
|
sl@0
|
176 |
return 0;
|
sl@0
|
177 |
}
|