~alan-griffiths/mir/verify-smoke-test-runs-ok

« back to all changes in this revision

Viewing changes to tests/include/mir/test/doubles/fake_alarm_factory.h

  • Committer: Daniel van Vugt
  • Date: 2016-03-14 10:13:49 UTC
  • mfrom: (3385 development-branch)
  • mto: This revision was merged to the branch mainline in revision 3398.
  • Revision ID: daniel.van.vugt@canonical.com-20160314101349-olm4fbs915d60nfo
Merge latest trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
#include <vector>
28
28
 
29
 
namespace mt = mir::time;
30
 
 
31
29
namespace mir
32
30
{
33
31
namespace test
34
32
{
35
33
namespace doubles
36
34
{
37
 
class FakeAlarm : public mt::Alarm
38
 
{
39
 
public:
40
 
    FakeAlarm(std::function<void()> const& callback,
41
 
        std::shared_ptr<mir::time::Clock> const& clock);
42
 
 
43
 
    void time_updated();
44
 
    int wakeup_count() const;
45
 
 
46
 
    bool cancel() override;
47
 
    State state() const override;
48
 
 
49
 
    bool reschedule_in(std::chrono::milliseconds delay) override;
50
 
    bool reschedule_for(mir::time::Timestamp timeout) override;
51
 
 
52
 
private:
53
 
    int triggered_count;
54
 
    std::function<void()> const callback;
55
 
    State alarm_state;
56
 
    mir::time::Timestamp triggers_at;
57
 
    std::shared_ptr<mt::Clock> clock;
58
 
};
59
 
 
60
 
class FakeAlarmFactory : public mt::AlarmFactory
 
35
class FakeAlarmFactory : public time::AlarmFactory
61
36
{
62
37
public:
63
38
    FakeAlarmFactory();
64
39
 
65
 
    std::unique_ptr<mt::Alarm> create_alarm(
 
40
    std::unique_ptr<time::Alarm> create_alarm(
66
41
        std::function<void()> const& callback) override;
67
 
    std::unique_ptr<mt::Alarm> create_alarm(
 
42
    std::unique_ptr<time::Alarm> create_alarm(
68
43
        std::shared_ptr<mir::LockableCallback> const& callback) override;
69
44
 
70
 
    void advance_by(mt::Duration step);
71
 
    void advance_smoothly_by(mt::Duration step);
 
45
    void advance_by(time::Duration step);
 
46
    void advance_smoothly_by(time::Duration step);
72
47
    int wakeup_count() const;
73
48
 
74
49
private:
 
50
    class FakeAlarm;
 
51
 
75
52
    std::vector<FakeAlarm*> alarms;
76
53
    std::shared_ptr<AdvanceableClock> const clock;
77
54
};