Update contrib.
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Some helper classes to assist with writing multi-threaded tests
19 #ifndef __TEST_THREAD_H__
20 #define __TEST_THREAD_H__
24 #define __E32TEST_EXTENSION__
26 #include <e32cmn_private.h>
28 _LIT(KPanicCat, "test_thread.h");
31 static const TInt KHeapSize=0x2000;
39 A utility class for running functions in other threads/processes
44 virtual TInt WaitForExitL() = 0;
45 virtual ~TTestRemote()
48 virtual void Rendezvous(TRequestStatus& aStatus) = 0;
54 static TInt RunFunctor(TAny* aFunctor);
56 TRequestStatus iLogonStatus;
60 class TTestThread : public TTestRemote
63 TTestThread(const TDesC& aName, TThreadFunction aFn, TAny* aData, TBool aAutoResume=ETrue);
66 Run aFunctor in another thread
68 TTestThread(const TDesC& aName, TFunctor& aFunctor, TBool aAutoResume=ETrue);
75 If thread exited normally, return its return code
76 Otherwise, leave with exit reason
78 virtual TInt WaitForExitL();
80 virtual void Rendezvous(TRequestStatus& aStatus);
83 void Init(const TDesC& aName, TThreadFunction aFn, TAny* aData, TBool aAutoResume);
88 class CTest : public CBase, public TFunctor
93 virtual void operator()();
94 virtual void RunTest() = 0;
95 virtual CTest* Clone() const = 0;
98 Prints a formatted description of the test
100 void Announce() const;
102 const TDesC& Name() const;
105 Should print the type of test, with no newlines.
106 eg. "Transfer", "Fragmentation"
107 TODO drop the function, just add a test type member
109 virtual void PrintTestType() const = 0;
112 Display any information about test environment, with no newlines
114 The base class version prints nothing.
116 virtual void PrintTestInfo() const;
119 CTest(const TDesC& aName, TInt aIterations);
120 CTest(const CTest& aOther);
122 //It would be useful to have an RTest member, but this can't be
123 //initialised untill the new thread is running as it will refer to
124 //the creating thread
126 const TInt iIterations;
130 Make aNumberOfThreads copies of aTest and run
131 each in its own thread
133 @param test Reference to test object
134 @param aTest Referance
136 void MultipleTestRun(RTest& test, const CTest& aTest, TInt aNumberOfThreads);
138 void MultipleTestRun(const RPointerArray<CTest>& aTests);
139 #endif // #ifndef __TEST_THREAD_H__