os/persistentdata/persistentstorage/centralrepository/pccenrep/test/t_cenrepcs.cpp
Update contrib.
1 // Copyright (c) 2008-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include <centralrepository.h>
19 #include "../../test/t_cenrep_helper.h"
21 _LIT( KCentralRepositoryServerName, "Centralrepositorysrv");
30 RTest TheTest(_L("Central Repository Tests"));
33 //uid for txt testing purpose
34 const TUid uid={0x000001FF};
35 //uid for cre testing purpose
36 const TUid uidcre={0x00001FFF};
37 const TUid uidcretest = {0x000002FF};
38 const TUid uidmetatest = {0x00022222};
40 /** FILES FOR AUTO NEWL TESTING */
41 _LIT(KPrivateTemplateCreOutFile,"c:\\private\\10202be9\\persists\\00001fff.cre");
42 _LIT(KPrivateTemplateTxtOutFile,"c:\\private\\10202be9\\persists\\000001ff.cre");
44 _LIT(KPersistCreFileTxt,"c:\\private\\10202be9\\persists\\000001ff.cre");
45 _LIT(KPersistCreFileCre,"c:\\private\\10202be9\\persists\\000002ff.cre");
46 _LIT(KPersistMetaTestFile,"c:\\private\\10202be9\\persists\\00022222.cre");
48 _LIT(KTxtTestRefFile,"c:\\private\\00000000\\ref_winscwtxt.cre");
49 _LIT(KCreTestRefFile,"c:\\private\\00000000\\ref_winscwcre.cre");
51 _LIT(KMetaTestRefFile,"c:\\private\\00000000\\ref_00022222.cre");
53 _LIT(KCrcRecordFile,"c:\\crc.txt");
55 ///////////////////////////////////////////////////////////////////////////////////////
58 //DEFINED IN THE COMMON CPP FILE
59 extern TInt CopyFile(const TDesC& aSource, const TDesC& aTarget);
60 extern void ObjectCreateDeleteOOM(TUid aUid,const TDesC& aInFilePath,const TDesC& aOutFilePath,TUint aTestMode);
61 extern void OomTest(void (*testFuncL)(CRepository* aRepository),TUid aUid,const TDesC& aInFilePath,const TDesC& aOutFilePath,TUint aTestMode);
62 extern void BasicFunctionL(TUid aUid,const TDesC& aInFilePath,const TDesC& aOutFilePath,TUint aTestMode);
63 extern void OomBasicFunction(TUid aUid,const TDesC& aInFilePath,const TDesC& aOutFilePath,TUint aTestMode);
64 extern void DoFileCompL(const TDesC& aGenerated, const TDesC& aReference, TUint32& aCrcValue);
65 extern void DEF130394L(TUid aUid);
67 void InitialiseLC(CRepository*& aRepository,TUid aUid,const TDesC& /**aInFilePath */,const TDesC& /**aOutFilePath*/,TUint /**aTestMode*/)
69 aRepository=CRepository::NewLC(aUid);
72 void SetupEnv(const TDesC& /**aInFilePath*/,const TDesC& aOutFilePath,TUint aTestMode)
74 if (aTestMode==EAutoCre || aTestMode==EAutoTxt)
75 TheFs.Delete(aOutFilePath);
78 void CrcReferenceGenL()
80 KillProcess(KCentralRepositoryServerName);
82 TheFs.Delete(KCrcRecordFile);
86 BasicFunctionL(uidcretest, KNullDesC, KPersistCreFileCre, EAutoCre);
87 DoFileCompL(KPersistCreFileCre, KCreTestRefFile, crcCre);
91 BasicFunctionL(uid, KNullDesC(), KPersistCreFileTxt, EAutoTxt);
92 DoFileCompL(KPersistCreFileTxt, KTxtTestRefFile, crcTxt);
95 buf.Format(_L8("%u-%u"), crcTxt, crcCre);
98 file.Create(TheFs, KCrcRecordFile, EFileWrite);
103 @SYMTestCaseID PDS-CENTRALREPOSITORY-CT-4080
104 @SYMTestCaseDesc Test for DEF130394
105 @SYMTestPriority Normal
106 @SYMTestActions This is Part 1 of the test - Part 2 is in t_cenrreppc.cpp
107 Loading a repository multiple times and copy the created cre file
108 to the test location of PC test.
109 @SYMTestExpectedResults A reference cre file in PC test test location
112 void TestForDEF130394L()
114 TheFs.Delete(KPersistMetaTestFile);
115 DEF130394L(uidmetatest);
116 CopyFile(KPersistMetaTestFile, KMetaTestRefFile);
120 @SYMTestCaseID SYSLIB-CENTRALREPOSITORY-CT-4043
121 @SYMTestCaseDesc Client-Server-side CentralRepository functionality test
122 @SYMTestPriority High
123 @SYMTestActions Wrapper function calling up test functions. Test functions include test for basic
124 functions of the component, OOm test and CRC comparison test.
125 @SYMTestExpectedResults Test must not fail
130 //Note these files are equivalent, the cre being generated from txt
131 TheTest.Start(_L("Functional TXT tests"));
133 User::LeaveIfError(TheFs.Connect());
136 TheTest.Next(_L("Functional NewLC Auto CRE tests"));
137 BasicFunctionL(uidcre,KNullDesC(),KPrivateTemplateCreOutFile(),EAutoCre);
138 TheTest.Next(_L("OOM NewLC Auto CRE tests"));
139 ObjectCreateDeleteOOM(uidcre,KNullDesC(),KPrivateTemplateCreOutFile(),EAutoCre);
140 OomBasicFunction(uidcre,KNullDesC(),KPrivateTemplateCreOutFile(),EAutoCre);
143 TheTest.Next(_L("Functional NewLC Auto TXT tests"));
144 BasicFunctionL(uid,KNullDesC(),KPrivateTemplateTxtOutFile(),EAutoTxt);
145 TheTest.Next(_L("OOM NewLC Auto TXT tests"));
146 ObjectCreateDeleteOOM(uid,KNullDesC(),KPrivateTemplateTxtOutFile(),EAutoTxt);
147 OomBasicFunction(uid,KNullDesC(),KPrivateTemplateTxtOutFile(),EAutoTxt);
149 #ifdef __WINSCW__ // no need to run on ARM
150 TheTest.Next(_L("CRC comparison preparation for PC side test"));
153 TheTest.Next(_L("Test for DEF130394L"));
165 CTrapCleanup* cleanup = CTrapCleanup::New();
171 User::Panic(_L("Testing failed: "), err);