~vanvugt/compiz-core/fix-880707.2

« back to all changes in this revision

Viewing changes to tests/timer/diffs/test-timer-diffs.cpp

  • Committer: Daniel van Vugt
  • Date: 2012-01-12 06:48:58 UTC
  • mfrom: (2893.2.15 compiz-core)
  • Revision ID: vanvugt@gmail.com-20120112064858-xcu22jq1dlerirmp
Merge with upstream changes (lp:compiz-core).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright © 2011 Canonical Ltd.
3
 
 *
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
13
 
 * implied warranty.
14
 
 *
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.
22
 
 *
23
 
 * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
24
 
 */
25
 
 
26
 
#include "test-timer.h"
27
 
 
28
 
bool
29
 
CompTimerTestDiffs::cb (int timernum, CompTimer *t1, CompTimer *t2, CompTimer *t3)
30
 
{
31
 
    if (timernum == 1 || timernum == 2 || timernum == 3)
32
 
    {
33
 
        std::cout << "INFO: executing timer " << timernum << std::endl;
34
 
 
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;
39
 
 
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;
44
 
 
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;
49
 
    }
50
 
 
51
 
    if (timernum == 3)
52
 
        ml->quit ();
53
 
 
54
 
    std::cout << "return false" << std::endl;
55
 
    return false;
56
 
}
57
 
 
58
 
void
59
 
CompTimerTestDiffs::precallback ()
60
 
{
61
 
    CompTimer      *t1, *t2, *t3;
62
 
 
63
 
    std::cout << "-= TEST: checking timeout diff" << std::endl;
64
 
 
65
 
    t1 = new CompTimer ();
66
 
    t2 = new CompTimer ();
67
 
    t3 = new CompTimer ();
68
 
 
69
 
    timers.push_back (t1);
70
 
    timers.push_back (t2);
71
 
    timers.push_back (t3);
72
 
 
73
 
    t1->setCallback (boost::bind (&CompTimerTestDiffs::cb, this, 1, t1, t2, t3));
74
 
    t1->setTimes (1000, 1100);
75
 
    t1->start ();
76
 
    t2->setCallback (boost::bind (&CompTimerTestDiffs::cb, this, 2, t1, t2, t3));
77
 
    t2->setTimes (2000, 2100);
78
 
    t2->start ();
79
 
    t3->setCallback (boost::bind (&CompTimerTestDiffs::cb, this, 3, t1, t2, t3));
80
 
    t3->setTimes (3000, 3100);
81
 
    t3->start ();
82
 
}