aboutsummaryrefslogtreecommitdiff
path: root/include/datetime/clock-mock.h
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-01-14 23:07:10 -0600
committerCharles Kerr <charles.kerr@canonical.com>2014-01-14 23:07:10 -0600
commitee64bb2698adfe27e55615a8856b0e2c78ad8469 (patch)
treeb8fb6e1440ac700f7f51e5c765303abb315c6399 /include/datetime/clock-mock.h
parent3b8833efe6ab21387b6f73b4a4ef757445801623 (diff)
downloadayatana-indicator-datetime-ee64bb2698adfe27e55615a8856b0e2c78ad8469.tar.gz
ayatana-indicator-datetime-ee64bb2698adfe27e55615a8856b0e2c78ad8469.tar.bz2
ayatana-indicator-datetime-ee64bb2698adfe27e55615a8856b0e2c78ad8469.zip
Function: add fully-tested ActionGroups, per-profile Menus, state object.
Form: Add code annotations/comments. Remove dead code. Use Mir style guide. Todo: GSettings toggles, sync with new dbus-test-runner API, get GNOME Panel building again
Diffstat (limited to 'include/datetime/clock-mock.h')
-rw-r--r--include/datetime/clock-mock.h28
1 files changed, 13 insertions, 15 deletions
diff --git a/include/datetime/clock-mock.h b/include/datetime/clock-mock.h
index 814b29a..19a859b 100644
--- a/include/datetime/clock-mock.h
+++ b/include/datetime/clock-mock.h
@@ -30,30 +30,28 @@ namespace datetime {
****
***/
+/**
+ * \brief A clock that uses a client-provided time instead of the system time.
+ */
class MockClock: public Clock
{
public:
+ MockClock(const DateTime& dt): m_localtime(dt) {}
+ ~MockClock() =default;
- MockClock(GDateTime * dt) { setLocaltime(dt); }
-
- ~MockClock() {
- g_clear_pointer(&localtime_, g_date_time_unref);
- }
-
- GDateTime* localtime() const {
- g_assert (localtime_ != nullptr);
- return g_date_time_ref(localtime_);
- }
+ DateTime localtime() const { return m_localtime; }
- void setLocaltime(GDateTime* dt) {
- g_clear_pointer(&localtime_, g_date_time_unref);
- localtime_ = g_date_time_ref(dt);
+ void set_localtime(const DateTime& dt) {
+ const auto old_day = m_localtime.day_of_year();
+ m_localtime = dt;
skewDetected();
+ const auto new_day = m_localtime.day_of_year();
+ if (old_day != new_day)
+ dateChanged();
}
private:
-
- GDateTime * localtime_ = nullptr;
+ DateTime m_localtime;
};
} // namespace datetime