4
// $Id: //poco/1.2/Foundation/testsuite/src/ActivityTest.cpp#1 $
6
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
9
// Permission is hereby granted, free of charge, to any person or organization
10
// obtaining a copy of the software and accompanying documentation covered by
11
// this license (the "Software") to use, reproduce, display, distribute,
12
// execute, and transmit the Software, and to prepare derivative works of the
13
// Software, and to permit third-parties to whom the Software is furnished to
14
// do so, all subject to the following:
16
// The copyright notices in the Software and this entire statement, including
17
// the above license grant, this restriction and the following disclaimer,
18
// must be included in all copies of the Software, in whole or in part, and
19
// all derivative works of the Software, unless such copies or derivative
20
// works are solely in the form of machine-executable object code generated by
21
// a source language processor.
23
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
26
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
27
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
28
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29
// DEALINGS IN THE SOFTWARE.
33
#include "ActivityTest.h"
34
#include "CppUnit/TestCaller.h"
35
#include "CppUnit/TestSuite.h"
36
#include "Poco/Activity.h"
37
#include "Poco/Thread.h"
50
_activity(this, &ActiveObject::run),
59
Activity<ActiveObject>& activity()
72
while (!_activity.isStopped())
77
Activity<ActiveObject> _activity;
83
ActivityTest::ActivityTest(const std::string& name): CppUnit::TestCase(name)
88
ActivityTest::~ActivityTest()
93
void ActivityTest::testActivity()
95
ActiveObject activeObj;
96
assert (activeObj.activity().isStopped());
97
activeObj.activity().start();
98
assert (!activeObj.activity().isStopped());
100
assert (activeObj.activity().isRunning());
101
activeObj.activity().stop();
102
activeObj.activity().wait();
103
assert (activeObj.count() > 0);
107
void ActivityTest::setUp()
112
void ActivityTest::tearDown()
117
CppUnit::Test* ActivityTest::suite()
119
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ActivityTest");
121
CppUnit_addTest(pSuite, ActivityTest, testActivity);