sl@0: // Copyright (c) 2004-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 "platsectaskcommon.h" sl@0: sl@0: LOCAL_C void NotifyTestComplete() sl@0: { sl@0: _LIT(KSchSemaphoreName, "SCHMinimalTaskHandler"); sl@0: RSemaphore sem; sl@0: TInt ret = sem.OpenGlobal(KSchSemaphoreName); sl@0: if (ret == KErrNone) sl@0: { sl@0: sem.Signal(); sl@0: sem.Close(); sl@0: } sl@0: } sl@0: /** sl@0: @SYMTestCaseID SYSLIB-SCHSVR-CT-1344 sl@0: @SYMTestCaseDesc Migration task handler test sl@0: @SYMTestPriority High sl@0: @SYMTestActions Attempt to create a representation of a scheduled task from a specified stream. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void CheckFileOkL(TFileName& aFileName, RTest& aTest) sl@0: { sl@0: aTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-1344 ")); sl@0: RFs fs; sl@0: User::LeaveIfError(fs.Connect()); sl@0: CleanupClosePushL(fs); sl@0: sl@0: TParse parsedName; sl@0: User::LeaveIfError(fs.Parse(aFileName, parsedName)); sl@0: CFileStore* store = CDirectFileStore::OpenLC(fs, parsedName.FullName(), EFileRead); sl@0: sl@0: RStoreReadStream instream; sl@0: instream.OpenLC(*store, store->Root()); sl@0: sl@0: TInt count = instream.ReadInt32L(); sl@0: aTest(count==1); sl@0: sl@0: CScheduledTask* task = CScheduledTask::NewLC(instream); sl@0: aTest(task->Info().iName.CompareF(KPlatSecTaskName)==0); sl@0: sl@0: CleanupStack::PopAndDestroy(4); // task, fs, instream, store sl@0: } sl@0: sl@0: LOCAL_C TInt Execute(TFileName& aFilename) sl@0: { sl@0: CTrapCleanup* cleanup = CTrapCleanup::New(); sl@0: if(!cleanup) sl@0: return KErrNoMemory; sl@0: sl@0: _LIT(KPlatSecTestName, "MigrationTaskHandlerTest"); sl@0: RTest theTest(KPlatSecTestName); sl@0: theTest.Start(KPlatSecTestName); sl@0: theTest.Title(); sl@0: sl@0: TRAPD(err, CheckFileOkL(aFilename, theTest)); sl@0: theTest(err==KErrNone); sl@0: sl@0: NotifyTestComplete(); sl@0: sl@0: theTest.End(); sl@0: theTest.Close(); sl@0: sl@0: delete cleanup; sl@0: sl@0: return err; sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: TBuf<0x100> cmd; sl@0: User::CommandLine(cmd); sl@0: return Execute(cmd); sl@0: }