forked from pocoproject/poco
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActiveTest.h
More file actions
89 lines (64 loc) · 1.54 KB
/
ActiveTest.h
File metadata and controls
89 lines (64 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//
// ActiveTest.h
//
// $Id: //poco/1.4/CppUnit/WinTestRunner/src/ActiveTest.h#1 $
//
#ifndef ActiveTest_INCLUDED
#define ActiveTest_INCLUDED
#include "CppUnit/CppUnit.h"
#include "CppUnit/TestDecorator.h"
#include <afxmt.h>
namespace CppUnit {
/* A Microsoft-specific active test
*
* An active test manages its own
* thread of execution. This one
* is very simple and only sufficient
* for the limited use we put it through
* in the TestRunner. It spawns a thread
* on run (TestResult *) and signals
* completion of the test.
*
* We assume that only one thread
* will be active at once for each
* instance.
*
*/
class ActiveTest: public TestDecorator
{
public:
ActiveTest(Test* test);
~ActiveTest();
void run(TestResult* result);
protected:
HANDLE _threadHandle;
CEvent _runCompleted;
TestResult* _currentTestResult;
void run ();
void setTestResult(TestResult* result);
static UINT threadFunction(LPVOID thisInstance);
};
// Construct the active test
inline ActiveTest::ActiveTest(Test *test): TestDecorator(test)
{
_currentTestResult = NULL;
_threadHandle = INVALID_HANDLE_VALUE;
}
// Pend until the test has completed
inline ActiveTest::~ActiveTest()
{
CSingleLock(&_runCompleted, TRUE);
CloseHandle(_threadHandle);
}
// Set the test result that we are to run
inline void ActiveTest::setTestResult(TestResult* result)
{
_currentTestResult = result;
}
// Run our test result
inline void ActiveTest::run()
{
TestDecorator::run(_currentTestResult);
}
} // namespace CppUnit
#endif // ActiveTest_INCLUDED