405.2.10
by Charles Kerr
add EDS tests to confirm valarm attachments are loaded properly and trigger in the AlarmQueue |
1 |
/*
|
2 |
* Copyright 2015 Canonical Ltd.
|
|
3 |
*
|
|
4 |
* This program is free software: you can redistribute it and/or modify it
|
|
5 |
* under the terms of the GNU General Public License version 3, as published
|
|
6 |
* by the Free Software Foundation.
|
|
7 |
*
|
|
8 |
* This program is distributed in the hope that it will be useful, but
|
|
9 |
* WITHOUT ANY WARRANTY; without even the implied warranties of
|
|
10 |
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
|
|
11 |
* PURPOSE. See the GNU General Public License for more details.
|
|
12 |
*
|
|
13 |
* You should have received a copy of the GNU General Public License along
|
|
14 |
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
15 |
*
|
|
16 |
* Authors:
|
|
17 |
* Charles Kerr <charles.kerr@canonical.com>
|
|
18 |
*/
|
|
19 |
||
20 |
#ifndef INDICATOR_DATETIME_WAKEUP_TIMER_MOCK_H
|
|
21 |
#define INDICATOR_DATETIME_WAKEUP_TIMER_MOCK_H
|
|
22 |
||
23 |
#include <datetime/clock.h> |
|
24 |
#include <datetime/wakeup-timer.h> |
|
25 |
||
26 |
namespace unity { |
|
27 |
namespace indicator { |
|
28 |
namespace datetime { |
|
29 |
||
30 |
/***
|
|
31 |
****
|
|
32 |
***/
|
|
33 |
||
34 |
/**
|
|
35 |
* \brief A one-shot timer that emits a signal when its timeout is reached.
|
|
36 |
*/
|
|
37 |
class MockWakeupTimer: public WakeupTimer |
|
38 |
{
|
|
39 |
public: |
|
40 |
explicit MockWakeupTimer(const std::shared_ptr<Clock>& clock): |
|
41 |
m_clock(clock) |
|
42 |
{
|
|
43 |
m_clock->minute_changed.connect([this](){ |
|
44 |
test_for_wakeup(); |
|
45 |
});
|
|
46 |
}
|
|
47 |
||
48 |
virtual ~MockWakeupTimer() =default; |
|
49 |
||
50 |
virtual void set_wakeup_time (const DateTime& wakeup_time) override { |
|
51 |
m_wakeup_time = wakeup_time; |
|
52 |
test_for_wakeup(); |
|
53 |
}
|
|
54 |
||
55 |
virtual core::Signal<>& timeout() override { return m_timeout; } |
|
56 |
||
57 |
private: |
|
58 |
||
59 |
void test_for_wakeup() |
|
60 |
{
|
|
61 |
if (DateTime::is_same_minute(m_clock->localtime(), m_wakeup_time)) |
|
62 |
m_timeout(); |
|
63 |
}
|
|
64 |
||
65 |
core::Signal<> m_timeout; |
|
66 |
const std::shared_ptr<Clock>& m_clock; |
|
67 |
DateTime m_wakeup_time; |
|
68 |
};
|
|
69 |
||
70 |
/***
|
|
71 |
****
|
|
72 |
***/
|
|
73 |
||
74 |
} // namespace datetime |
|
75 |
} // namespace indicator |
|
76 |
} // namespace unity |
|
77 |
||
78 |
#endif // INDICATOR_DATETIME_WAKEUP_TIMER_MOCK_H |