1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericservices/taskscheduler/Test/PlatSec/migrationtaskhandler.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,91 @@
1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include <e32test.h>
1.20 +#include <schtask.h>
1.21 +#include "platsectaskcommon.h"
1.22 +
1.23 +LOCAL_C void NotifyTestComplete()
1.24 + {
1.25 + _LIT(KSchSemaphoreName, "SCHMinimalTaskHandler");
1.26 + RSemaphore sem;
1.27 + TInt ret = sem.OpenGlobal(KSchSemaphoreName);
1.28 + if (ret == KErrNone)
1.29 + {
1.30 + sem.Signal();
1.31 + sem.Close();
1.32 + }
1.33 + }
1.34 +/**
1.35 +@SYMTestCaseID SYSLIB-SCHSVR-CT-1344
1.36 +@SYMTestCaseDesc Migration task handler test
1.37 +@SYMTestPriority High
1.38 +@SYMTestActions Attempt to create a representation of a scheduled task from a specified stream.
1.39 +@SYMTestExpectedResults Test must not fail
1.40 +@SYMREQ REQ0000
1.41 +*/
1.42 +LOCAL_C void CheckFileOkL(TFileName& aFileName, RTest& aTest)
1.43 + {
1.44 + aTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-1344 "));
1.45 + RFs fs;
1.46 + User::LeaveIfError(fs.Connect());
1.47 + CleanupClosePushL(fs);
1.48 +
1.49 + TParse parsedName;
1.50 + User::LeaveIfError(fs.Parse(aFileName, parsedName));
1.51 + CFileStore* store = CDirectFileStore::OpenLC(fs, parsedName.FullName(), EFileRead);
1.52 +
1.53 + RStoreReadStream instream;
1.54 + instream.OpenLC(*store, store->Root());
1.55 +
1.56 + TInt count = instream.ReadInt32L();
1.57 + aTest(count==1);
1.58 +
1.59 + CScheduledTask* task = CScheduledTask::NewLC(instream);
1.60 + aTest(task->Info().iName.CompareF(KPlatSecTaskName)==0);
1.61 +
1.62 + CleanupStack::PopAndDestroy(4); // task, fs, instream, store
1.63 + }
1.64 +
1.65 +LOCAL_C TInt Execute(TFileName& aFilename)
1.66 + {
1.67 + CTrapCleanup* cleanup = CTrapCleanup::New();
1.68 + if(!cleanup)
1.69 + return KErrNoMemory;
1.70 +
1.71 + _LIT(KPlatSecTestName, "MigrationTaskHandlerTest");
1.72 + RTest theTest(KPlatSecTestName);
1.73 + theTest.Start(KPlatSecTestName);
1.74 + theTest.Title();
1.75 +
1.76 + TRAPD(err, CheckFileOkL(aFilename, theTest));
1.77 + theTest(err==KErrNone);
1.78 +
1.79 + NotifyTestComplete();
1.80 +
1.81 + theTest.End();
1.82 + theTest.Close();
1.83 +
1.84 + delete cleanup;
1.85 +
1.86 + return err;
1.87 + }
1.88 +
1.89 +GLDEF_C TInt E32Main()
1.90 + {
1.91 + TBuf<0x100> cmd;
1.92 + User::CommandLine(cmd);
1.93 + return Execute(cmd);
1.94 + }