sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include "../../test/t_cenrep_helper.h" sl@0: sl@0: _LIT( KCentralRepositoryServerName, "Centralrepositorysrv"); sl@0: sl@0: enum TestMode{ sl@0: ETxt, sl@0: ECre, sl@0: EAutoCre, sl@0: EAutoTxt sl@0: }; sl@0: sl@0: RTest TheTest(_L("Central Repository Tests")); sl@0: RFs TheFs; sl@0: sl@0: //uid for txt testing purpose sl@0: const TUid uid={0x000001FF}; sl@0: //uid for cre testing purpose sl@0: const TUid uidcre={0x00001FFF}; sl@0: const TUid uidcretest = {0x000002FF}; sl@0: const TUid uidmetatest = {0x00022222}; sl@0: sl@0: /** FILES FOR AUTO NEWL TESTING */ sl@0: _LIT(KPrivateTemplateCreOutFile,"c:\\private\\10202be9\\persists\\00001fff.cre"); sl@0: _LIT(KPrivateTemplateTxtOutFile,"c:\\private\\10202be9\\persists\\000001ff.cre"); sl@0: sl@0: _LIT(KPersistCreFileTxt,"c:\\private\\10202be9\\persists\\000001ff.cre"); sl@0: _LIT(KPersistCreFileCre,"c:\\private\\10202be9\\persists\\000002ff.cre"); sl@0: _LIT(KPersistMetaTestFile,"c:\\private\\10202be9\\persists\\00022222.cre"); sl@0: sl@0: _LIT(KTxtTestRefFile,"c:\\private\\00000000\\ref_winscwtxt.cre"); sl@0: _LIT(KCreTestRefFile,"c:\\private\\00000000\\ref_winscwcre.cre"); sl@0: sl@0: _LIT(KMetaTestRefFile,"c:\\private\\00000000\\ref_00022222.cre"); sl@0: sl@0: _LIT(KCrcRecordFile,"c:\\crc.txt"); sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: sl@0: //DEFINED IN THE COMMON CPP FILE sl@0: extern TInt CopyFile(const TDesC& aSource, const TDesC& aTarget); sl@0: extern void ObjectCreateDeleteOOM(TUid aUid,const TDesC& aInFilePath,const TDesC& aOutFilePath,TUint aTestMode); sl@0: extern void OomTest(void (*testFuncL)(CRepository* aRepository),TUid aUid,const TDesC& aInFilePath,const TDesC& aOutFilePath,TUint aTestMode); sl@0: extern void BasicFunctionL(TUid aUid,const TDesC& aInFilePath,const TDesC& aOutFilePath,TUint aTestMode); sl@0: extern void OomBasicFunction(TUid aUid,const TDesC& aInFilePath,const TDesC& aOutFilePath,TUint aTestMode); sl@0: extern void DoFileCompL(const TDesC& aGenerated, const TDesC& aReference, TUint32& aCrcValue); sl@0: extern void DEF130394L(TUid aUid); sl@0: sl@0: void InitialiseLC(CRepository*& aRepository,TUid aUid,const TDesC& /**aInFilePath */,const TDesC& /**aOutFilePath*/,TUint /**aTestMode*/) sl@0: { sl@0: aRepository=CRepository::NewLC(aUid); sl@0: } sl@0: sl@0: void SetupEnv(const TDesC& /**aInFilePath*/,const TDesC& aOutFilePath,TUint aTestMode) sl@0: { sl@0: if (aTestMode==EAutoCre || aTestMode==EAutoTxt) sl@0: TheFs.Delete(aOutFilePath); sl@0: } sl@0: sl@0: void CrcReferenceGenL() sl@0: { sl@0: KillProcess(KCentralRepositoryServerName); sl@0: sl@0: TheFs.Delete(KCrcRecordFile); sl@0: sl@0: // Auto Cre Test sl@0: TUint32 crcCre; sl@0: BasicFunctionL(uidcretest, KNullDesC, KPersistCreFileCre, EAutoCre); sl@0: DoFileCompL(KPersistCreFileCre, KCreTestRefFile, crcCre); sl@0: sl@0: // Auto Txt Test sl@0: TUint32 crcTxt = 0; sl@0: BasicFunctionL(uid, KNullDesC(), KPersistCreFileTxt, EAutoTxt); sl@0: DoFileCompL(KPersistCreFileTxt, KTxtTestRefFile, crcTxt); sl@0: sl@0: TBuf8<100> buf; sl@0: buf.Format(_L8("%u-%u"), crcTxt, crcCre); sl@0: sl@0: RFile file; sl@0: file.Create(TheFs, KCrcRecordFile, EFileWrite); sl@0: file.Write(buf); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID PDS-CENTRALREPOSITORY-CT-4080 sl@0: @SYMTestCaseDesc Test for DEF130394 sl@0: @SYMTestPriority Normal sl@0: @SYMTestActions This is Part 1 of the test - Part 2 is in t_cenrreppc.cpp sl@0: Loading a repository multiple times and copy the created cre file sl@0: to the test location of PC test. sl@0: @SYMTestExpectedResults A reference cre file in PC test test location sl@0: @SYMDEF DEF130394 sl@0: */ sl@0: void TestForDEF130394L() sl@0: { sl@0: TheFs.Delete(KPersistMetaTestFile); sl@0: DEF130394L(uidmetatest); sl@0: CopyFile(KPersistMetaTestFile, KMetaTestRefFile); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-CENTRALREPOSITORY-CT-4043 sl@0: @SYMTestCaseDesc Client-Server-side CentralRepository functionality test sl@0: @SYMTestPriority High sl@0: @SYMTestActions Wrapper function calling up test functions. Test functions include test for basic sl@0: functions of the component, OOm test and CRC comparison test. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMPREQ PREQ2111 sl@0: */ sl@0: LOCAL_C void MainL() sl@0: { sl@0: //Note these files are equivalent, the cre being generated from txt sl@0: TheTest.Start(_L("Functional TXT tests")); sl@0: sl@0: User::LeaveIfError(TheFs.Connect()); sl@0: sl@0: //CRE exists only sl@0: TheTest.Next(_L("Functional NewLC Auto CRE tests")); sl@0: BasicFunctionL(uidcre,KNullDesC(),KPrivateTemplateCreOutFile(),EAutoCre); sl@0: TheTest.Next(_L("OOM NewLC Auto CRE tests")); sl@0: ObjectCreateDeleteOOM(uidcre,KNullDesC(),KPrivateTemplateCreOutFile(),EAutoCre); sl@0: OomBasicFunction(uidcre,KNullDesC(),KPrivateTemplateCreOutFile(),EAutoCre); sl@0: sl@0: //TXT exists only sl@0: TheTest.Next(_L("Functional NewLC Auto TXT tests")); sl@0: BasicFunctionL(uid,KNullDesC(),KPrivateTemplateTxtOutFile(),EAutoTxt); sl@0: TheTest.Next(_L("OOM NewLC Auto TXT tests")); sl@0: ObjectCreateDeleteOOM(uid,KNullDesC(),KPrivateTemplateTxtOutFile(),EAutoTxt); sl@0: OomBasicFunction(uid,KNullDesC(),KPrivateTemplateTxtOutFile(),EAutoTxt); sl@0: sl@0: #ifdef __WINSCW__ // no need to run on ARM sl@0: TheTest.Next(_L("CRC comparison preparation for PC side test")); sl@0: CrcReferenceGenL(); sl@0: sl@0: TheTest.Next(_L("Test for DEF130394L")); sl@0: TestForDEF130394L(); sl@0: #endif sl@0: sl@0: TheFs.Close(); sl@0: TheTest.End(); sl@0: TheTest.Close(); sl@0: } sl@0: sl@0: TInt E32Main() sl@0: { sl@0: __UHEAP_MARK; sl@0: CTrapCleanup* cleanup = CTrapCleanup::New(); sl@0: if(!cleanup) sl@0: return KErrNoMemory; sl@0: sl@0: TRAPD(err, MainL()); sl@0: if (err != KErrNone) sl@0: User::Panic(_L("Testing failed: "), err); sl@0: sl@0: delete cleanup; sl@0: __UHEAP_MARKEND; sl@0: sl@0: return 0; sl@0: }