2
* Copyright © 2011 Canonical Ltd.
4
* Permission to use, copy, modify, distribute, and sell this software
5
* and its documentation for any purpose is hereby granted without
6
* fee, provided that the above copyright notice appear in all copies
7
* and that both that copyright notice and this permission notice
8
* appear in supporting documentation, and that the name of
9
* Canonical Ltd. not be used in advertising or publicity pertaining to
10
* distribution of the software without specific, written prior permission.
11
* Canonical Ltd. makes no representations about the suitability of this
12
* software for any purpose. It is provided "as is" without express or
15
* CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17
* NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23
* Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
26
#include "test-timer.h"
29
CompTimerTestDiffs::cb (int timernum, CompTimer *t1, CompTimer *t2, CompTimer *t3)
31
if (timernum == 1 || timernum == 2 || timernum == 3)
33
std::cout << "INFO: executing timer " << timernum << std::endl;
35
std::cout << "INFO: t1->minLeft " << t1->minLeft () << std::endl << \
36
"INFO: t1->maxLeft " << t1->maxLeft () << std::endl << \
37
"INFO: t1->minTime " << t1->minTime () << std::endl << \
38
"INFO: t1->maxTime " << t1->maxTime () << std::endl;
40
std::cout << "INFO: t2->minLeft " << t2->minLeft () << std::endl << \
41
"INFO: t2->maxLeft " << t2->maxLeft () << std::endl << \
42
"INFO: t2->minTime " << t2->minTime () << std::endl << \
43
"INFO: t2->maxTime " << t2->maxTime () << std::endl;
45
std::cout << "INFO: t3->minLeft " << t3->minLeft () << std::endl << \
46
"INFO: t3->maxLeft " << t3->maxLeft () << std::endl << \
47
"INFO: t3->minTime " << t3->minTime () << std::endl << \
48
"INFO: t3->maxTime " << t3->maxTime () << std::endl;
54
std::cout << "return false" << std::endl;
59
CompTimerTestDiffs::precallback ()
61
CompTimer *t1, *t2, *t3;
63
std::cout << "-= TEST: checking timeout diff" << std::endl;
65
t1 = new CompTimer ();
66
t2 = new CompTimer ();
67
t3 = new CompTimer ();
69
timers.push_back (t1);
70
timers.push_back (t2);
71
timers.push_back (t3);
73
t1->setCallback (boost::bind (&CompTimerTestDiffs::cb, this, 1, t1, t2, t3));
74
t1->setTimes (1000, 1100);
76
t2->setCallback (boost::bind (&CompTimerTestDiffs::cb, this, 2, t1, t2, t3));
77
t2->setTimes (2000, 2100);
79
t3->setCallback (boost::bind (&CompTimerTestDiffs::cb, this, 3, t1, t2, t3));
80
t3->setTimes (3000, 3100);