aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog18
-rw-r--r--include/datetime/actions-live.h2
-rw-r--r--include/datetime/actions.h4
-rw-r--r--include/datetime/appointment.h12
-rw-r--r--include/datetime/clock-mock.h4
-rw-r--r--include/datetime/clock.h12
-rw-r--r--include/datetime/date-time.h6
-rw-r--r--include/datetime/exporter.h4
-rw-r--r--include/datetime/formatter.h20
-rw-r--r--include/datetime/locations-settings.h8
-rw-r--r--include/datetime/locations.h14
-rw-r--r--include/datetime/menu.h13
-rw-r--r--include/datetime/planner.h6
-rw-r--r--include/datetime/timezone-file.h6
-rw-r--r--include/datetime/timezone.h1
-rw-r--r--include/datetime/timezones-live.h4
-rw-r--r--panel/datetime-prefs.c4
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/actions-live.cpp5
-rw-r--r--src/actions.cpp17
-rw-r--r--src/appointment.cpp (renamed from include/datetime/state-live.h)37
-rw-r--r--src/clock-live.cpp12
-rw-r--r--src/clock.cpp22
-rw-r--r--src/date-time.cpp17
-rw-r--r--src/exporter.cpp4
-rw-r--r--src/formatter-desktop.cpp8
-rw-r--r--src/formatter.cpp18
-rw-r--r--src/locations-settings.cpp4
-rw-r--r--src/locations.cpp41
-rw-r--r--src/main.cpp21
-rw-r--r--src/menu.cpp84
-rw-r--r--src/planner-eds.cpp2
-rw-r--r--src/state-live.cpp56
-rw-r--r--src/timezone-file.cpp14
-rw-r--r--src/timezones-live.cpp3
-rw-r--r--tests/planner-mock.c178
-rw-r--r--tests/test-clock.cpp8
-rw-r--r--tests/test-formatter.cc98
-rw-r--r--tests/test-formatter.cpp10
-rw-r--r--tests/test-live-actions.cpp4
-rw-r--r--tests/test-menus.cpp242
-rw-r--r--tests/test-planner.cpp6
-rw-r--r--tests/test-settings.cpp6
-rw-r--r--tests/test-timezone-geoclue.cpp59
44 files changed, 466 insertions, 650 deletions
diff --git a/debian/changelog b/debian/changelog
index d97de34..e3de384 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,21 @@
+indicator-datetime (13.10.0+14.04.20140131-0ubuntu1) trusty; urgency=low
+
+ [ Charles Kerr ]
+ * Finally land this. Other, still open bugs will be fixed in
+ subsequent commits. (LP: #793450)
+
+ [ Sebastien Bacher ]
+ * Use the correct location for datetime-dialog.ui. (LP: #1274046)
+
+ [ Lars Uebernickel ]
+ * Set calendar to the current date when the menu is popped up This
+ makes use of the "submenu-action" attribute to get notified when the
+ menu is popped up. Charles, if your big refactoring-branch should
+ land before this, do you mind adapting this patch for that? Thanks .
+ (LP: #793450)
+
+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Fri, 31 Jan 2014 11:46:16 +0000
+
indicator-datetime (13.10.0+14.04.20140124-0ubuntu1) trusty; urgency=low
[ Robert Ancell ]
diff --git a/include/datetime/actions-live.h b/include/datetime/actions-live.h
index 949222d..3607836 100644
--- a/include/datetime/actions-live.h
+++ b/include/datetime/actions-live.h
@@ -36,7 +36,7 @@ namespace datetime {
class LiveActions: public Actions
{
public:
- LiveActions(const std::shared_ptr<State>& state_in): Actions(state_in) {}
+ LiveActions(const std::shared_ptr<State>& state_in);
~LiveActions() =default;
void open_desktop_settings();
diff --git a/include/datetime/actions.h b/include/datetime/actions.h
index 3686b95..99e78f5 100644
--- a/include/datetime/actions.h
+++ b/include/datetime/actions.h
@@ -50,8 +50,8 @@ public:
virtual void open_appointment(const std::string& uid) =0;
virtual void set_location(const std::string& zone, const std::string& name)=0;
void set_calendar_date(const DateTime&);
- GActionGroup* action_group() { return G_ACTION_GROUP(m_actions); }
- std::shared_ptr<State> state() { return m_state; }
+ GActionGroup* action_group();
+ const std::shared_ptr<State> state() const;
protected:
Actions(const std::shared_ptr<State>& state);
diff --git a/include/datetime/appointment.h b/include/datetime/appointment.h
index e034c08..a5283c9 100644
--- a/include/datetime/appointment.h
+++ b/include/datetime/appointment.h
@@ -45,17 +45,7 @@ public:
DateTime begin;
DateTime end;
- bool operator== (const Appointment& that) const
- {
- return (color==that.color) &&
- (summary==that.summary) &&
- (url==that.url) &&
- (uid==that.uid) &&
- (is_event==that.is_event) &&
- (has_alarms==that.has_alarms) &&
- (begin==that.begin) &&
- (end==that.end);
- }
+ bool operator== (const Appointment& that) const;
};
} // namespace datetime
diff --git a/include/datetime/clock-mock.h b/include/datetime/clock-mock.h
index 27926ff..fb9b52f 100644
--- a/include/datetime/clock-mock.h
+++ b/include/datetime/clock-mock.h
@@ -45,9 +45,9 @@ public:
const auto old = m_localtime;
m_localtime = dt;
if (!DateTime::is_same_minute(old, m_localtime))
- minuteChanged();
+ minute_changed();
if (!DateTime::is_same_day(old, m_localtime))
- dateChanged();
+ date_changed();
}
private:
diff --git a/include/datetime/clock.h b/include/datetime/clock.h
index b3e3538..1d488d1 100644
--- a/include/datetime/clock.h
+++ b/include/datetime/clock.h
@@ -43,20 +43,20 @@ public:
virtual DateTime localtime() const =0;
/** \brief A signal which fires when the clock's minute changes */
- core::Signal<> minuteChanged;
+ core::Signal<> minute_changed;
/** \brief A signal which fires when the clock's date changes */
- core::Signal<> dateChanged;
+ core::Signal<> date_changed;
protected:
Clock();
- /** \brief Compares old and new times, emits minuteChanged() or dateChanged() signals if appropriate */
+ /** \brief Compares old and new times, emits minute_changed() or date_changed() signals if appropriate */
void maybe_emit (const DateTime& a, const DateTime& b);
private:
- static void onSystemBusReady(GObject*, GAsyncResult*, gpointer);
- static void onPrepareForSleep(GDBusConnection*, const gchar*, const gchar*, const gchar*, const gchar*, GVariant*, gpointer);
+ static void on_system_bus_ready(GObject*, GAsyncResult*, gpointer);
+ static void on_prepare_for_sleep(GDBusConnection*, const gchar*, const gchar*, const gchar*, const gchar*, GVariant*, gpointer);
GCancellable * m_cancellable = nullptr;
GDBusConnection * m_system_bus = nullptr;
@@ -79,7 +79,7 @@ class Timezones;
class LiveClock: public Clock
{
public:
- LiveClock (const std::shared_ptr<Timezones>& zones);
+ LiveClock (const std::shared_ptr<const Timezones>& zones);
virtual ~LiveClock();
virtual DateTime localtime() const;
diff --git a/include/datetime/date-time.h b/include/datetime/date-time.h
index c2429eb..2ad7856 100644
--- a/include/datetime/date-time.h
+++ b/include/datetime/date-time.h
@@ -37,9 +37,9 @@ class DateTime
public:
static DateTime NowLocal();
explicit DateTime(time_t t);
- explicit DateTime(GDateTime* in=nullptr) {reset(in);}
- DateTime& operator=(GDateTime* in) {reset(in); return *this;}
- DateTime& operator=(const DateTime& in) {m_dt=in.m_dt; return *this; }
+ explicit DateTime(GDateTime* in=nullptr);
+ DateTime& operator=(GDateTime* in);
+ DateTime& operator=(const DateTime& in);
DateTime to_timezone(const std::string& zone) const;
void reset(GDateTime* in=nullptr);
diff --git a/include/datetime/exporter.h b/include/datetime/exporter.h
index a32b941..c228cc1 100644
--- a/include/datetime/exporter.h
+++ b/include/datetime/exporter.h
@@ -45,8 +45,8 @@ public:
core::Signal<> name_lost;
- void publish(std::shared_ptr<Actions>& actions,
- std::vector<std::shared_ptr<Menu>>& menus);
+ void publish(const std::shared_ptr<Actions>& actions,
+ const std::vector<std::shared_ptr<Menu>>& menus);
private:
static void on_bus_acquired(GDBusConnection*, const gchar *name, gpointer gthis);
diff --git a/include/datetime/formatter.h b/include/datetime/formatter.h
index 3de109e..0d695e2 100644
--- a/include/datetime/formatter.h
+++ b/include/datetime/formatter.h
@@ -69,27 +69,27 @@ class Formatter
public:
/** \brief The time format string for the menu header */
- core::Property<std::string> headerFormat;
+ core::Property<std::string> header_format;
- /** \brief The time string for the menu header. (eg, the headerFormat + the clock's time */
+ /** \brief The time string for the menu header. (eg, the header_format + the clock's time */
core::Property<std::string> header;
/** \brief Signal to denote when the relativeFormat has changed.
When this is emitted, clients will want to rebuild their
menuitems that contain relative time strings
(ie, the Appointments and Locations menuitems) */
- core::Signal<> relativeFormatChanged;
+ core::Signal<> relative_format_changed;
/** \brief Generate a relative time format for some time (or time range)
from the current clock's value. For example, a full-day interval
starting at the end of the current clock's day yields "Tomorrow" */
- std::string getRelativeFormat(GDateTime* then, GDateTime* then_end=nullptr) const;
+ std::string relative_format(GDateTime* then, GDateTime* then_end=nullptr) const;
protected:
- Formatter(const std::shared_ptr<Clock>&);
+ Formatter(const std::shared_ptr<const Clock>&);
virtual ~Formatter();
- static const char* getDefaultHeaderTimeFormat(bool twelvehour, bool show_seconds);
+ static const char* default_header_time_format(bool twelvehour, bool show_seconds);
private:
@@ -107,10 +107,10 @@ private:
class DesktopFormatter: public Formatter
{
public:
- DesktopFormatter(const std::shared_ptr<Clock>&, const std::shared_ptr<Settings>&);
+ DesktopFormatter(const std::shared_ptr<const Clock>&, const std::shared_ptr<const Settings>&);
private:
- std::shared_ptr<Settings> m_settings;
+ std::shared_ptr<const Settings> m_settings;
void rebuildHeaderFormat();
const gchar* getFullTimeFormatString() const;
@@ -126,8 +126,8 @@ private:
class PhoneFormatter: public Formatter
{
public:
- PhoneFormatter(const std::shared_ptr<Clock>& clock): Formatter(clock) {
- headerFormat.set(getDefaultHeaderTimeFormat(is_locale_12h(), false));
+ PhoneFormatter(const std::shared_ptr<const Clock>& clock): Formatter(clock) {
+ header_format.set(default_header_time_format(is_locale_12h(), false));
}
};
diff --git a/include/datetime/locations-settings.h b/include/datetime/locations-settings.h
index d01cbb5..8757f43 100644
--- a/include/datetime/locations-settings.h
+++ b/include/datetime/locations-settings.h
@@ -39,12 +39,12 @@ public:
* @param[in] settings the #Settings whose locations property is to be used
* @param[in] timezones the #Timezones to always show first in the list
*/
- SettingsLocations (const std::shared_ptr<Settings>& settings,
- const std::shared_ptr<Timezones>& timezones);
+ SettingsLocations (const std::shared_ptr<const Settings>& settings,
+ const std::shared_ptr<const Timezones>& timezones);
private:
- std::shared_ptr<Settings> m_settings;
- std::shared_ptr<Timezones> m_timezones;
+ std::shared_ptr<const Settings> m_settings;
+ std::shared_ptr<const Timezones> m_timezones;
void reload();
};
diff --git a/include/datetime/locations.h b/include/datetime/locations.h
index ee67615..b840436 100644
--- a/include/datetime/locations.h
+++ b/include/datetime/locations.h
@@ -39,18 +39,10 @@ namespace datetime {
class Location
{
public:
- const std::string& zone() const { return m_zone; }
-
- const std::string& name() const { return m_name; }
-
- bool operator== (const Location& that) const
- {
- return (name() == that.name()) &&
- (zone() == that.zone()) &&
- (m_offset == that.m_offset);
- }
-
Location (const std::string& zone, const std::string& name);
+ const std::string& zone() const;
+ const std::string& name() const;
+ bool operator== (const Location& that) const;
private:
diff --git a/include/datetime/menu.h b/include/datetime/menu.h
index fcd709f..7b351c3 100644
--- a/include/datetime/menu.h
+++ b/include/datetime/menu.h
@@ -43,12 +43,12 @@ class Menu
public:
enum Profile { Desktop, DesktopGreeter, Phone, PhoneGreeter, NUM_PROFILES };
enum Section { Calendar, Appointments, Locations, Settings, NUM_SECTIONS };
- const std::string& name() const { return m_name; }
- Profile profile() const { return m_profile; }
- GMenuModel* menu_model() { return G_MENU_MODEL(m_menu); }
+ const std::string& name() const;
+ Profile profile() const;
+ GMenuModel* menu_model();
protected:
- Menu (Profile profile_in, const std::string& name_in): m_profile(profile_in), m_name(name_in) {}
+ Menu (Profile profile_in, const std::string& name_in);
virtual ~Menu() =default;
GMenu* m_menu = nullptr;
@@ -70,13 +70,12 @@ private:
class MenuFactory
{
public:
- MenuFactory (std::shared_ptr<Actions>& actions, std::shared_ptr<State>& state);
+ MenuFactory (const std::shared_ptr<Actions>& actions, const std::shared_ptr<const State>& state);
std::shared_ptr<Menu> buildMenu(Menu::Profile profile);
- std::shared_ptr<State> state() { return m_state; }
private:
std::shared_ptr<Actions> m_actions;
- std::shared_ptr<State> m_state;
+ std::shared_ptr<const State> m_state;
};
} // namespace datetime
diff --git a/include/datetime/planner.h b/include/datetime/planner.h
index a8f9941..376a31f 100644
--- a/include/datetime/planner.h
+++ b/include/datetime/planner.h
@@ -43,9 +43,9 @@ public:
virtual ~Planner() =default;
/**
- * \brief Timestamp used to determine the appointments in the `upcoming' and `thisMonth' properties.
+ * \brief Timestamp used to determine the appointments in the `upcoming' and `this_month' properties.
* Setting this value will cause the planner to re-query its backend and
- * update the `upcoming' and `thisMonth' properties.
+ * update the `upcoming' and `this_month' properties.
*/
core::Property<DateTime> time;
@@ -57,7 +57,7 @@ public:
/**
* \brief The appointments that occur in the same month as the time property
*/
- core::Property<std::vector<Appointment>> thisMonth;
+ core::Property<std::vector<Appointment>> this_month;
protected:
Planner() =default;
diff --git a/include/datetime/timezone-file.h b/include/datetime/timezone-file.h
index 7f47df6..d77aaae 100644
--- a/include/datetime/timezone-file.h
+++ b/include/datetime/timezone-file.h
@@ -37,9 +37,9 @@ namespace datetime {
class FileTimezone: public Timezone
{
public:
- FileTimezone() {}
- FileTimezone(const std::string& filename) { setFilename(filename); }
- ~FileTimezone() {clear();}
+ FileTimezone();
+ FileTimezone(const std::string& filename);
+ ~FileTimezone();
private:
void setFilename(const std::string& filename);
diff --git a/include/datetime/timezone.h b/include/datetime/timezone.h
index ffa5a84..7d2ace8 100644
--- a/include/datetime/timezone.h
+++ b/include/datetime/timezone.h
@@ -35,7 +35,6 @@ protected:
Timezone() =default;
public:
- //virtual ~Timezone() {}
core::Property<std::string> timezone;
};
diff --git a/include/datetime/timezones-live.h b/include/datetime/timezones-live.h
index 286c967..ca4ef31 100644
--- a/include/datetime/timezones-live.h
+++ b/include/datetime/timezones-live.h
@@ -38,14 +38,14 @@ namespace datetime {
class LiveTimezones: public Timezones
{
public:
- LiveTimezones(std::shared_ptr<Settings>& settings, const std::string& filename);
+ LiveTimezones(const std::shared_ptr<const Settings>& settings, const std::string& filename);
private:
void update_geolocation();
void update_timezones();
FileTimezone m_file;
- std::shared_ptr<Settings> m_settings;
+ std::shared_ptr<const Settings> m_settings;
std::shared_ptr<GeoclueTimezone> m_geo;
};
diff --git a/panel/datetime-prefs.c b/panel/datetime-prefs.c
index 02536c7..7808fa7 100644
--- a/panel/datetime-prefs.c
+++ b/panel/datetime-prefs.c
@@ -866,7 +866,11 @@ g_io_module_load (GIOModule *module)
indicator_datetime_panel_register_type (G_TYPE_MODULE (module));
g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT,
INDICATOR_DATETIME_TYPE_PANEL,
+#if USE_UNITY
+ "datetime", 0);
+#else
"indicator-datetime", 0);
+#endif
}
void
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index eb716d4..810e299 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -15,6 +15,7 @@ endif ()
add_library (${SERVICE_LIB} STATIC
actions.cpp
actions-live.cpp
+ appointment.cpp
clock.cpp
clock-live.cpp
date-time.cpp
@@ -26,7 +27,6 @@ add_library (${SERVICE_LIB} STATIC
menu.cpp
planner-eds.cpp
settings-live.cpp
- state-live.cpp
timezone-file.cpp
timezone-geoclue.cpp
timezones-live.cpp
diff --git a/src/actions-live.cpp b/src/actions-live.cpp
index afd83f4..c0fd8ff 100644
--- a/src/actions-live.cpp
+++ b/src/actions-live.cpp
@@ -31,6 +31,11 @@ namespace datetime {
****
***/
+LiveActions::LiveActions(const std::shared_ptr<State>& state_in):
+ Actions(state_in)
+{
+}
+
void LiveActions::execute_command(const std::string& cmdstr)
{
const auto cmd = cmdstr.c_str();
diff --git a/src/actions.cpp b/src/actions.cpp
index acf8fd4..d6fa698 100644
--- a/src/actions.cpp
+++ b/src/actions.cpp
@@ -65,7 +65,7 @@ void on_activate_appointment(GSimpleAction * /*action*/,
g_return_if_fail(uid && *uid);
// find url of the upcoming appointment with this uid
- for (auto& appt : self->state()->planner->upcoming.get())
+ for (const auto& appt : self->state()->planner->upcoming.get())
{
if (appt.uid == uid)
{
@@ -146,7 +146,7 @@ GVariant* create_default_header_state()
GVariant* create_calendar_state(const std::shared_ptr<State>& state)
{
gboolean days[32] = { 0 };
- for(const auto& appt : state->planner->thisMonth.get())
+ for (const auto& appt : state->planner->this_month.get())
days[appt.begin.day_of_month()] = true;
GVariantBuilder day_builder;
@@ -222,7 +222,7 @@ Actions::Actions(const std::shared_ptr<State>& state):
m_state->planner->time.changed().connect([this](const DateTime&){
update_calendar_state();
});
- m_state->planner->thisMonth.changed().connect([this](const std::vector<Appointment>&){
+ m_state->planner->this_month.changed().connect([this](const std::vector<Appointment>&){
update_calendar_state();
});
m_state->settings->show_week_numbers.changed().connect([this](bool){
@@ -249,6 +249,17 @@ void Actions::set_calendar_date(const DateTime& date)
m_state->planner->time.set(date);
}
+GActionGroup* Actions::action_group()
+{
+ return G_ACTION_GROUP(m_actions);
+}
+
+const std::shared_ptr<State> Actions::state() const
+{
+ return m_state;
+}
+
+
} // namespace datetime
} // namespace indicator
diff --git a/include/datetime/state-live.h b/src/appointment.cpp
index 2b93722..6e742c3 100644
--- a/include/datetime/state-live.h
+++ b/src/appointment.cpp
@@ -17,33 +17,32 @@
* Charles Kerr <charles.kerr@canonical.com>
*/
-#ifndef INDICATOR_DATETIME_STATE_LIVE_H
-#define INDICATOR_DATETIME_STATE_LIVE_H
-
-#include <datetime/state.h>
+#include <datetime/appointment.h>
namespace unity {
namespace indicator {
namespace datetime {
-/***
-****
-***/
+/****
+*****
+****/
-class LiveState: public State
+bool Appointment::operator==(const Appointment& that) const
{
-public:
- LiveState();
- virtual ~LiveState() =default;
-};
-
-/***
-****
-***/
-
+ return (color==that.color)
+ && (summary==that.summary)
+ && (url==that.url)
+ && (uid==that.uid)
+ && (is_event==that.is_event)
+ && (has_alarms==that.has_alarms)
+ && (begin==that.begin)
+ && (end==that.end);
+}
+
+/****
+*****
+****/
} // namespace datetime
} // namespace indicator
} // namespace unity
-
-#endif // INDICATOR_DATETIME_SETTINGS_LIVE_H
diff --git a/src/clock-live.cpp b/src/clock-live.cpp
index 69ebda7..21a18a3 100644
--- a/src/clock-live.cpp
+++ b/src/clock-live.cpp
@@ -59,7 +59,7 @@ class LiveClock::Impl
{
public:
- Impl(LiveClock& owner, const std::shared_ptr<Timezones>& tzd):
+ Impl(LiveClock& owner, const std::shared_ptr<const Timezones>& tzd):
m_owner(owner),
m_timezones(tzd)
{
@@ -95,7 +95,7 @@ private:
{
g_clear_pointer(&m_timezone, g_time_zone_unref);
m_timezone = g_time_zone_new(str.c_str());
- m_owner.minuteChanged();
+ m_owner.minute_changed();
}
/***
@@ -109,9 +109,9 @@ private:
// maybe emit change signals
const auto now = localtime();
if (!DateTime::is_same_minute(m_prev_datetime, now))
- m_owner.minuteChanged();
+ m_owner.minute_changed();
if (!DateTime::is_same_day(m_prev_datetime, now))
- m_owner.dateChanged();
+ m_owner.date_changed();
// queue up a timer to fire at the next minute
m_prev_datetime = now;
@@ -135,13 +135,13 @@ protected:
LiveClock& m_owner;
GTimeZone* m_timezone = nullptr;
- std::shared_ptr<Timezones> m_timezones;
+ std::shared_ptr<const Timezones> m_timezones;
DateTime m_prev_datetime;
unsigned int m_timer = 0;
};
-LiveClock::LiveClock(const std::shared_ptr<Timezones>& tzd):
+LiveClock::LiveClock(const std::shared_ptr<const Timezones>& tzd):
p(new Impl(*this, tzd))
{
}
diff --git a/src/clock.cpp b/src/clock.cpp
index d5293cc..f41a0cc 100644
--- a/src/clock.cpp
+++ b/src/clock.cpp
@@ -33,7 +33,7 @@ namespace datetime {
Clock::Clock():
m_cancellable(g_cancellable_new())
{
- g_bus_get(G_BUS_TYPE_SYSTEM, m_cancellable, onSystemBusReady, this);
+ g_bus_get(G_BUS_TYPE_SYSTEM, m_cancellable, on_system_bus_ready, this);
}
Clock::~Clock()
@@ -48,7 +48,7 @@ Clock::~Clock()
}
void
-Clock::onSystemBusReady(GObject*, GAsyncResult * res, gpointer gself)
+Clock::on_system_bus_ready(GObject*, GAsyncResult * res, gpointer gself)
{
GDBusConnection * system_bus;
@@ -66,22 +66,22 @@ Clock::onSystemBusReady(GObject*, GAsyncResult * res, gpointer gself)
"/org/freedesktop/login1", // object path
nullptr, // arg0
G_DBUS_SIGNAL_FLAGS_NONE,
- onPrepareForSleep,
+ on_prepare_for_sleep,
self,
nullptr);
}
}
void
-Clock::onPrepareForSleep(GDBusConnection* /*connection*/,
- const gchar* /*sender_name*/,
- const gchar* /*object_path*/,
- const gchar* /*interface_name*/,
- const gchar* /*signal_name*/,
- GVariant* /*parameters*/,
- gpointer gself)
+Clock::on_prepare_for_sleep(GDBusConnection* /*connection*/,
+ const gchar* /*sender_name*/,
+ const gchar* /*object_path*/,
+ const gchar* /*interface_name*/,
+ const gchar* /*signal_name*/,
+ GVariant* /*parameters*/,
+ gpointer gself)
{
- static_cast<Clock*>(gself)->minuteChanged();
+ static_cast<Clock*>(gself)->minute_changed();
}
/***
diff --git a/src/date-time.cpp b/src/date-time.cpp
index 40c638f..a634c5e 100644
--- a/src/date-time.cpp
+++ b/src/date-time.cpp
@@ -27,6 +27,23 @@ namespace datetime {
****
***/
+DateTime::DateTime(GDateTime* gdt)
+{
+ reset(gdt);
+}
+
+DateTime& DateTime::operator=(GDateTime* gdt)
+{
+ reset(gdt);
+ return *this;
+}
+
+DateTime& DateTime::operator=(const DateTime& that)
+{
+ m_dt = that.m_dt;
+ return *this;
+}
+
DateTime::DateTime(time_t t)
{
GDateTime * gdt = g_date_time_new_from_unix_local(t);
diff --git a/src/exporter.cpp b/src/exporter.cpp
index 86e3670..ccd6e5c 100644
--- a/src/exporter.cpp
+++ b/src/exporter.cpp
@@ -120,8 +120,8 @@ Exporter::on_name_lost(GDBusConnection* /*connection*/, const gchar* /*name*/)
***/
void
-Exporter::publish(std::shared_ptr<Actions>& actions,
- std::vector<std::shared_ptr<Menu>>& menus)
+Exporter::publish(const std::shared_ptr<Actions>& actions,
+ const std::vector<std::shared_ptr<Menu>>& menus)
{
m_actions = actions;
m_menus = menus;
diff --git a/src/formatter-desktop.cpp b/src/formatter-desktop.cpp
index d542ec4..336d2d3 100644
--- a/src/formatter-desktop.cpp
+++ b/src/formatter-desktop.cpp
@@ -64,8 +64,8 @@ std::string joinDateAndTimeFormatStrings(const char* date_string,
****
***/
-DesktopFormatter::DesktopFormatter(const std::shared_ptr<Clock>& clock_in,
- const std::shared_ptr<Settings>& settings_in):
+DesktopFormatter::DesktopFormatter(const std::shared_ptr<const Clock>& clock_in,
+ const std::shared_ptr<const Settings>& settings_in):
Formatter(clock_in),
m_settings(settings_in)
{
@@ -81,7 +81,7 @@ DesktopFormatter::DesktopFormatter(const std::shared_ptr<Clock>& clock_in,
void DesktopFormatter::rebuildHeaderFormat()
{
- headerFormat.set(getHeaderLabelFormatString());
+ header_format.set(getHeaderLabelFormatString());
}
std::string DesktopFormatter::getHeaderLabelFormatString() const
@@ -126,7 +126,7 @@ const gchar* DesktopFormatter::getFullTimeFormatString() const
break;
}
- return getDefaultHeaderTimeFormat(twelvehour, show_seconds);
+ return default_header_time_format(twelvehour, show_seconds);
}
const gchar* DesktopFormatter::getDateFormat(bool show_day, bool show_date, bool show_year) const
diff --git a/src/formatter.cpp b/src/formatter.cpp
index a15c7f8..9aa9bbb 100644
--- a/src/formatter.cpp
+++ b/src/formatter.cpp
@@ -118,12 +118,12 @@ class Formatter::Impl
{
public:
- Impl(Formatter* owner, const std::shared_ptr<Clock>& clock):
+ Impl(Formatter* owner, const std::shared_ptr<const Clock>& clock):
m_owner(owner),
m_clock(clock)
{
- m_owner->headerFormat.changed().connect([this](const std::string& /*fmt*/){update_header();});
- m_clock->minuteChanged.connect([this](){update_header();});
+ m_owner->header_format.changed().connect([this](const std::string& /*fmt*/){update_header();});
+ m_clock->minute_changed.connect([this](){update_header();});
update_header();
restartRelativeTimer();
@@ -149,7 +149,7 @@ private:
void update_header()
{
// update the header property
- const auto fmt = m_owner->headerFormat.get();
+ const auto fmt = m_owner->header_format.get();
const auto str = m_clock->localtime().format(fmt);
m_owner->header.set(str);
@@ -197,7 +197,7 @@ private:
static gboolean onRelativeTimer(gpointer gself)
{
auto self = static_cast<Formatter::Impl*>(gself);
- self->m_owner->relativeFormatChanged();
+ self->m_owner->relative_format_changed();
self->restartRelativeTimer();
return G_SOURCE_REMOVE;
}
@@ -208,14 +208,14 @@ private:
guint m_relative_timer = 0;
public:
- std::shared_ptr<Clock> m_clock;
+ std::shared_ptr<const Clock> m_clock;
};
/***
****
***/
-Formatter::Formatter(const std::shared_ptr<Clock>& clock):
+Formatter::Formatter(const std::shared_ptr<const Clock>& clock):
p(new Formatter::Impl(this, clock))
{
}
@@ -225,7 +225,7 @@ Formatter::~Formatter()
}
const char*
-Formatter::getDefaultHeaderTimeFormat(bool twelvehour, bool show_seconds)
+Formatter::default_header_time_format(bool twelvehour, bool show_seconds)
{
const char* fmt;
@@ -250,7 +250,7 @@ Formatter::getDefaultHeaderTimeFormat(bool twelvehour, bool show_seconds)
***/
std::string
-Formatter::getRelativeFormat(GDateTime* then_begin, GDateTime* then_end) const
+Formatter::relative_format(GDateTime* then_begin, GDateTime* then_end) const
{
auto cstr = generate_full_format_string_at_time (p->m_clock->localtime().get(), then_begin, then_end);
const std::string ret = cstr;
diff --git a/src/locations-settings.cpp b/src/locations-settings.cpp
index 9b90bc0..ef3085f 100644
--- a/src/locations-settings.cpp
+++ b/src/locations-settings.cpp
@@ -29,8 +29,8 @@ namespace unity {
namespace indicator {
namespace datetime {
-SettingsLocations::SettingsLocations(const std::shared_ptr<Settings>& settings,
- const std::shared_ptr<Timezones>& timezones):
+SettingsLocations::SettingsLocations(const std::shared_ptr<const Settings>& settings,
+ const std::shared_ptr<const Timezones>& timezones):
m_settings(settings),
m_timezones(timezones)
{
diff --git a/src/locations.cpp b/src/locations.cpp
index d6ab73a..0690acd 100644
--- a/src/locations.cpp
+++ b/src/locations.cpp
@@ -25,6 +25,24 @@ namespace unity {
namespace indicator {
namespace datetime {
+const std::string& Location::zone() const
+{
+ return m_zone;
+}
+
+const std::string& Location::name() const
+{
+ return m_name;
+}
+
+bool Location::operator== (const Location& that) const
+{
+ return (m_name == that.m_name)
+ && (m_zone == that.m_zone)
+ && (m_offset == that.m_offset);
+}
+
+
Location::Location(const std::string& zone_, const std::string& name_):
m_zone(zone_),
m_name(name_)
@@ -36,29 +54,6 @@ Location::Location(const std::string& zone_, const std::string& name_):
g_time_zone_unref (gzone);
}
-#if 0
-DateTime Location::localtime(const DateTime& reference_point) const
-{
-GDateTime * g_date_time_to_timezone (GDateTime *datetime,
- GTimeZone *tz);
- auto gzone = g_time_zone_new(zone().c_str());
- const auto gtime = reference_point.get();
- auto glocal = g_date_time_new (gzone,
- g_date_time_get_year(gtime),
- g_date_time_get_month(gtime),
- g_date_time_get_day_of_month(gtime),
- g_date_time_get_hour(gtime),
- g_date_time_get_minute(gtime),
- g_date_time_get_seconds(gtime));
- DateTime local(glocal);
- g_date_time_unref(glocal);
- g_message("reference: %zu", (size_t)reference_point.to_unix(), (size_t)local.to_unix());
- //g_date_time_unref(gtime);
- g_time_zone_unref(gzone);
- return local;
-}
-#endif
-
} // namespace datetime
} // namespace indicator
} // namespace unity
diff --git a/src/main.cpp b/src/main.cpp
index 2c4f160..1534777 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -17,10 +17,17 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
+
#include <datetime/actions-live.h>
+#include <datetime/clock.h>
#include <datetime/exporter.h>
+#include <datetime/locations-settings.h>
#include <datetime/menu.h>
-#include <datetime/state-live.h>
+#include <datetime/planner-eds.h>
+#include <datetime/settings-live.h>
+#include <datetime/state.h>
+#include <datetime/timezones-live.h>
#include <glib/gi18n.h> // bindtextdomain()
#include <gio/gio.h>
@@ -47,8 +54,16 @@ main(int /*argc*/, char** /*argv*/)
if(!notify_init("indicator-datetime-service"))
g_critical("libnotify initialization failed");
- // build the state and actions for the MenuFactory to use
- std::shared_ptr<State> state(new LiveState);
+ // build the state, actions, and menufactory
+ std::shared_ptr<State> state(new State);
+ std::shared_ptr<Settings> live_settings(new LiveSettings);
+ std::shared_ptr<Timezones> live_timezones(new LiveTimezones(live_settings, TIMEZONE_FILE));
+ std::shared_ptr<Clock> live_clock(new LiveClock(live_timezones));
+ state->settings = live_settings;
+ state->clock = live_clock;
+ state->locations.reset(new SettingsLocations(live_settings, live_timezones));
+ state->planner.reset(new PlannerEds);
+ state->planner->time = live_clock->localtime();
std::shared_ptr<Actions> actions(new LiveActions(state));
MenuFactory factory(actions, state);
diff --git a/src/menu.cpp b/src/menu.cpp
index 4ed0a03..bdf92c3 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -35,6 +35,33 @@ namespace datetime {
*****
****/
+Menu::Menu (Profile profile_in, const std::string& name_in):
+ m_profile(profile_in),
+ m_name(name_in)
+{
+}
+
+const std::string& Menu::name() const
+{
+ return m_name;
+}
+
+Menu::Profile Menu::profile() const
+{
+ return m_profile;
+}
+
+GMenuModel* Menu::menu_model()
+{
+ return G_MENU_MODEL(m_menu);
+}
+
+
+/****
+*****
+****/
+
+
#define FALLBACK_ALARM_CLOCK_ICON_NAME "clock"
#define CALENDAR_ICON_NAME "calendar"
@@ -43,9 +70,9 @@ class MenuImpl: public Menu
protected:
MenuImpl(const Menu::Profile profile_in,
const std::string& name_in,
- std::shared_ptr<State>& state,
+ std::shared_ptr<const State>& state,
std::shared_ptr<Actions>& actions,
- std::shared_ptr<Formatter> formatter):
+ std::shared_ptr<const Formatter> formatter):
Menu(profile_in, name_in),
m_state(state),
m_actions(actions),
@@ -60,12 +87,12 @@ protected:
m_formatter->header.changed().connect([this](const std::string&){
update_header();
});
- m_formatter->headerFormat.changed().connect([this](const std::string&){
+ m_formatter->header_format.changed().connect([this](const std::string&){
update_section(Locations); // need to update x-canonical-time-format
});
- m_formatter->relativeFormatChanged.connect([this](){
- update_section(Appointments); // uses formatter.getRelativeFormat()
- update_section(Locations); // uses formatter.getRelativeFormat()
+ m_formatter->relative_format_changed.connect([this](){
+ update_section(Appointments); // uses formatter.relative_format()
+ update_section(Locations); // uses formatter.relative_format()
});
m_state->settings->show_clock.changed().connect([this](bool){
update_header(); // update header's label
@@ -80,7 +107,7 @@ protected:
m_state->planner->upcoming.changed().connect([this](const std::vector<Appointment>&){
update_section(Appointments); // "upcoming" is the list of Appointments we show
});
- m_state->clock->dateChanged.connect([this](){
+ m_state->clock->date_changed.connect([this](){
update_section(Calendar); // need to update the Date menuitem
update_section(Locations); // locations' relative time may have changed
});
@@ -106,9 +133,9 @@ protected:
g_action_group_change_action_state(action_group, action_name.c_str(), state);
}
- std::shared_ptr<State> m_state;
+ std::shared_ptr<const State> m_state;
std::shared_ptr<Actions> m_actions;
- std::shared_ptr<Formatter> m_formatter;
+ std::shared_ptr<const Formatter> m_formatter;
GMenu* m_submenu = nullptr;
GVariant* get_serialized_alarm_icon()
@@ -281,7 +308,7 @@ private:
GDateTime* begin = appt.begin();
GDateTime* end = appt.end();
- auto fmt = m_formatter->getRelativeFormat(begin, end);
+ auto fmt = m_formatter->relative_format(begin, end);
auto unix_time = g_date_time_to_unix(begin);
auto menu_item = g_menu_item_new (appt.summary.c_str(), nullptr);
@@ -296,10 +323,10 @@ private:
else
{
g_menu_item_set_attribute (menu_item, "x-canonical-type", "s", "com.canonical.indicator.appointment");
-
- if (!appt.color.empty())
- g_menu_item_set_attribute (menu_item, "x-canonical-color", "s", appt.color.c_str());
}
+
+ if (!appt.color.empty())
+ g_menu_item_set_attribute (menu_item, "x-canonical-color", "s", appt.color.c_str());
if (profile == Phone)
g_menu_item_set_action_and_target_value (menu_item,
@@ -318,7 +345,7 @@ private:
{
auto menu = g_menu_new();
- if (((profile==Phone) || (profile==Desktop)) && m_state->settings->show_events.get())
+ if ((profile==Desktop) && m_state->settings->show_events.get())
{
add_appointments (menu, profile);
@@ -330,6 +357,15 @@ private:
g_menu_append_item(menu, menu_item);
g_object_unref(menu_item);
}
+ else if (profile==Phone)
+ {
+ auto menu_item = g_menu_item_new (_("Clock"), "indicator.activate-phone-clock-app");
+ g_menu_item_set_attribute_value (menu_item, G_MENU_ATTRIBUTE_ICON, get_serialized_alarm_icon());
+ g_menu_append_item (menu, menu_item);
+ g_object_unref (menu_item);
+
+ add_appointments (menu, profile);
+ }
return G_MENU_MODEL(menu);
}
@@ -347,7 +383,7 @@ private:
const auto& zone = location.zone();
const auto& name = location.name();
const auto zone_now = now.to_timezone(zone);
- const auto fmt = m_formatter->getRelativeFormat(zone_now.get());
+ const auto fmt = m_formatter->relative_format(zone_now.get());
auto detailed_action = g_strdup_printf("indicator.set-location::%s %s", zone.c_str(), name.c_str());
auto i = g_menu_item_new (name.c_str(), detailed_action);
g_menu_item_set_attribute(i, "x-canonical-type", "s", "com.canonical.indicator.location");
@@ -417,10 +453,10 @@ class DesktopBaseMenu: public MenuImpl
protected:
DesktopBaseMenu(Menu::Profile profile_,
const std::string& name_,
- std::shared_ptr<State>& state_,
+ std::shared_ptr<const State>& state_,
std::shared_ptr<Actions>& actions_):
MenuImpl(profile_, name_, state_, actions_,
- std::shared_ptr<Formatter>(new DesktopFormatter(state_->clock, state_->settings)))
+ std::shared_ptr<const Formatter>(new DesktopFormatter(state_->clock, state_->settings)))
{
update_header();
}
@@ -444,14 +480,14 @@ protected:
class DesktopMenu: public DesktopBaseMenu
{
public:
- DesktopMenu(std::shared_ptr<State>& state_, std::shared_ptr<Actions>& actions_):
+ DesktopMenu(std::shared_ptr<const State>& state_, std::shared_ptr<Actions>& actions_):
DesktopBaseMenu(Desktop,"desktop", state_, actions_) {}
};
class DesktopGreeterMenu: public DesktopBaseMenu
{
public:
- DesktopGreeterMenu(std::shared_ptr<State>& state_, std::shared_ptr<Actions>& actions_):
+ DesktopGreeterMenu(std::shared_ptr<const State>& state_, std::shared_ptr<Actions>& actions_):
DesktopBaseMenu(DesktopGreeter,"desktop_greeter", state_, actions_) {}
};
@@ -460,7 +496,7 @@ class PhoneBaseMenu: public MenuImpl
protected:
PhoneBaseMenu(Menu::Profile profile_,
const std::string& name_,
- std::shared_ptr<State>& state_,
+ std::shared_ptr<const State>& state_,
std::shared_ptr<Actions>& actions_):
MenuImpl(profile_, name_, state_, actions_,
std::shared_ptr<Formatter>(new PhoneFormatter(state_->clock)))
@@ -501,7 +537,7 @@ protected:
class PhoneMenu: public PhoneBaseMenu
{
public:
- PhoneMenu(std::shared_ptr<State>& state_,
+ PhoneMenu(std::shared_ptr<const State>& state_,
std::shared_ptr<Actions>& actions_):
PhoneBaseMenu(Phone, "phone", state_, actions_) {}
};
@@ -509,7 +545,7 @@ public:
class PhoneGreeterMenu: public PhoneBaseMenu
{
public:
- PhoneGreeterMenu(std::shared_ptr<State>& state_,
+ PhoneGreeterMenu(std::shared_ptr<const State>& state_,
std::shared_ptr<Actions>& actions_):
PhoneBaseMenu(PhoneGreeter, "phone_greeter", state_, actions_) {}
};
@@ -518,8 +554,8 @@ public:
*****
****/
-MenuFactory::MenuFactory(std::shared_ptr<Actions>& actions_,
- std::shared_ptr<State>& state_):
+MenuFactory::MenuFactory(const std::shared_ptr<Actions>& actions_,
+ const std::shared_ptr<const State>& state_):
m_actions(actions_),
m_state(state_)
{
diff --git a/src/planner-eds.cpp b/src/planner-eds.cpp
index 98cfe0a..cb42d6e 100644
--- a/src/planner-eds.cpp
+++ b/src/planner-eds.cpp
@@ -227,7 +227,7 @@ private:
{
getAppointments(begin, end, [this](const std::vector<Appointment>& appointments) {
g_debug("got %d appointments in this calendar month", (int)appointments.size());
- m_owner.thisMonth.set(appointments);
+ m_owner.this_month.set(appointments);
});
}
g_clear_pointer(&begin, g_date_time_unref);
diff --git a/src/state-live.cpp b/src/state-live.cpp
deleted file mode 100644
index fe1e6cd..0000000
--- a/src/state-live.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2013 Canonical Ltd.
- *
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 3, as published
- * by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranties of
- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * Authors:
- * Charles Kerr <charles.kerr@canonical.com>
- */
-
-#include <datetime/state-live.h>
-
-#include <datetime/clock.h>
-#include <datetime/locations-settings.h>
-#include <datetime/planner-eds.h>
-#include <datetime/settings-live.h>
-#include <datetime/state.h>
-#include <datetime/timezones-live.h>
-
-namespace unity {
-namespace indicator {
-namespace datetime {
-
-/***
-****
-***/
-
-LiveState::LiveState()
-{
- std::shared_ptr<Settings> live_settings(new LiveSettings);
- std::shared_ptr<Timezones> live_timezones(new LiveTimezones(live_settings, TIMEZONE_FILE));
- std::shared_ptr<Clock> live_clock(new LiveClock(live_timezones));
-
- settings = live_settings;
- clock = live_clock;
- locations.reset(new SettingsLocations(live_settings, live_timezones));
- planner.reset(new PlannerEds);
- planner->time = clock->localtime();
-}
-
-/***
-****
-***/
-
-} // namespace datetime
-} // namespace indicator
-} // namespace unity
diff --git a/src/timezone-file.cpp b/src/timezone-file.cpp
index 3a0c240..76737b4 100644
--- a/src/timezone-file.cpp
+++ b/src/timezone-file.cpp
@@ -23,6 +23,20 @@ namespace unity {
namespace indicator {
namespace datetime {
+FileTimezone::FileTimezone()
+{
+}
+
+FileTimezone::FileTimezone(const std::string& filename)
+{
+ setFilename(filename);
+}
+
+FileTimezone::~FileTimezone()
+{
+ clear();
+}
+
void
FileTimezone::clear()
{
diff --git a/src/timezones-live.cpp b/src/timezones-live.cpp
index baac05d..4902b76 100644
--- a/src/timezones-live.cpp
+++ b/src/timezones-live.cpp
@@ -25,7 +25,8 @@ namespace unity {
namespace indicator {
namespace datetime {
-LiveTimezones::LiveTimezones(std::shared_ptr<Settings>& settings, const std::string& filename):
+LiveTimezones::LiveTimezones(const std::shared_ptr<const Settings>& settings,
+ const std::string& filename):
m_file(filename),
m_settings(settings)
{
diff --git a/tests/planner-mock.c b/tests/planner-mock.c
deleted file mode 100644
index df5413e..0000000
--- a/tests/planner-mock.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright 2013 Canonical Ltd.
- *
- * Authors:
- * Charles Kerr <charles.kerr@canonical.com>
- *
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 3, as published
- * by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranties of
- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-
-#include "planner-mock.h"
-
-struct _IndicatorDatetimePlannerMockPriv
-{
- gboolean is_configured;
-};
-
-typedef IndicatorDatetimePlannerMockPriv priv_t;
-
-G_DEFINE_TYPE (IndicatorDatetimePlannerMock,
- indicator_datetime_planner_mock,
- INDICATOR_TYPE_DATETIME_PLANNER)
-
-/***
-**** IndicatorDatetimePlanner virtual funcs
-***/
-
-static void
-my_get_appointments (IndicatorDatetimePlanner * planner,
- GDateTime * begin_datetime,
- GDateTime * /*end_datetime*/,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GTask * task;
- GSList * appointments;
- struct IndicatorDatetimeAppt * appt;
- struct IndicatorDatetimeAppt * prev;
-
- task = g_task_new (planner, NULL, callback, user_data);
-
- /**
- *** Build the appointments list
- **/
-
- appointments = NULL;
-
- /* add a daily appointment that occurs at the beginning of the next minute */
- appt = g_slice_new0 (struct IndicatorDatetimeAppt);
- appt->is_daily = TRUE;
- appt->begin = g_date_time_add_seconds (begin_datetime, 60-g_date_time_get_seconds(begin_datetime));
- appt->end = g_date_time_add_minutes (appt->begin, 1);
- appt->color = g_strdup ("#00FF00");
- appt->is_event = TRUE;
- appt->summary = g_strdup ("Daily alarm");
- appt->uid = g_strdup ("this uid isn't very random.");
- appt->has_alarms = TRUE;
- appt->url = g_strdup ("alarm:///some-alarm-info-goes-here");
- appointments = g_slist_prepend (appointments, appt);
- prev = appt;
-
- /* and add one for a minute later that has an alarm uri */
- appt = g_slice_new0 (struct IndicatorDatetimeAppt);
- appt->is_daily = TRUE;
- appt->begin = g_date_time_add_minutes (prev->end, 1);
- appt->end = g_date_time_add_minutes (appt->begin, 1);
- appt->color = g_strdup ("#0000FF");
- appt->is_event = TRUE;
- appt->summary = g_strdup ("Second Daily alarm");
- appt->uid = g_strdup ("this uid isn't very random either.");
- appt->has_alarms = FALSE;
- appointments = g_slist_prepend (appointments, appt);
-
- /* done */
- g_task_return_pointer (task, appointments, NULL);
- g_object_unref (task);
-}
-
-static GSList *
-my_get_appointments_finish (IndicatorDatetimePlanner* /*self*/,
- GAsyncResult* res,
- GError** error)
-{
- return g_task_propagate_pointer(G_TASK(res), error);
-}
-
-static gboolean
-my_is_configured(IndicatorDatetimePlanner* planner)
-{
- IndicatorDatetimePlannerMock * self;
- self = INDICATOR_DATETIME_PLANNER_MOCK(planner);
- return self->priv->is_configured;
-}
-
-static void
-my_activate(IndicatorDatetimePlanner* /*self*/)
-{
- g_message("%s %s", G_STRLOC, G_STRFUNC);
-}
-
-static void
-my_activate_time(IndicatorDatetimePlanner* /*self*/,
- GDateTime* activate_time)
-{
- gchar * str = g_date_time_format(activate_time, "%F %T");
- g_message("%s %s: %s", G_STRLOC, G_STRFUNC, str);
- g_free(str);
-}
-
-/***
-**** GObject virtual funcs
-***/
-
-static void
-my_dispose(GObject * o)
-{
- G_OBJECT_CLASS(indicator_datetime_planner_mock_parent_class)->dispose(o);
-}
-
-/***
-**** Instantiation
-***/
-
-static void
-indicator_datetime_planner_mock_class_init(IndicatorDatetimePlannerMockClass* klass)
-{
- GObjectClass * object_class;
- IndicatorDatetimePlannerClass * planner_class;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = my_dispose;
-
- planner_class = INDICATOR_DATETIME_PLANNER_CLASS (klass);
- planner_class->is_configured = my_is_configured;
- planner_class->activate = my_activate;
- planner_class->activate_time = my_activate_time;
- planner_class->get_appointments = my_get_appointments;
- planner_class->get_appointments_finish = my_get_appointments_finish;
-
- g_type_class_add_private (klass, sizeof (IndicatorDatetimePlannerMockPriv));
-}
-
-static void
-indicator_datetime_planner_mock_init (IndicatorDatetimePlannerMock * self)
-{
- priv_t * p;
-
- p = G_TYPE_INSTANCE_GET_PRIVATE (self,
- INDICATOR_TYPE_DATETIME_PLANNER_MOCK,
- IndicatorDatetimePlannerMockPriv);
-
- p->is_configured = TRUE;
-
- self->priv = p;
-}
-
-/***
-**** Public
-***/
-
-IndicatorDatetimePlanner *
-indicator_datetime_planner_mock_new (void)
-{
- gpointer o = g_object_new (INDICATOR_TYPE_DATETIME_PLANNER_MOCK, NULL);
-
- return INDICATOR_DATETIME_PLANNER (o);
-}
diff --git a/tests/test-clock.cpp b/tests/test-clock.cpp
index 4271374..4287e1c 100644
--- a/tests/test-clock.cpp
+++ b/tests/test-clock.cpp
@@ -54,12 +54,12 @@ TEST_F(ClockFixture, MinuteChangedSignalShouldTriggerOncePerMinute)
LiveClock clock(zones);
wait_msec(500); // wait for the bus to set up
- // count how many times clock.minuteChanged() is emitted over the next minute
+ // count how many times clock.minute_changed() is emitted over the next minute
const DateTime now = clock.localtime();
const auto gnow = now.get();
auto gthen = g_date_time_add_minutes(gnow, 1);
int count = 0;
- clock.minuteChanged.connect([&count](){count++;});
+ clock.minute_changed.connect([&count](){count++;});
const auto msec = g_date_time_difference(gthen,gnow) / 1000;
wait_msec(msec);
EXPECT_EQ(1, count);
@@ -95,7 +95,7 @@ TEST_F(ClockFixture, TimezoneChangeTriggersSkew)
g_time_zone_unref(tz_nyc);
/// change the timezones!
- clock.minuteChanged.connect([this](){
+ clock.minute_changed.connect([this](){
g_main_loop_quit(loop);
});
g_idle_add([](gpointer gs){
@@ -124,7 +124,7 @@ TEST_F(ClockFixture, SleepTriggersSkew)
wait_msec(500); // wait for the bus to set up
bool skewed = false;
- clock.minuteChanged.connect([&skewed, this](){
+ clock.minute_changed.connect([&skewed, this](){
skewed = true;
g_main_loop_quit(loop);
return G_SOURCE_REMOVE;
diff --git a/tests/test-formatter.cc b/tests/test-formatter.cc
deleted file mode 100644
index 6a408ab..0000000
--- a/tests/test-formatter.cc
+++ /dev/null
@@ -1,98 +0,0 @@
-
-/*
- * Copyright 2013 Canonical Ltd.
- *
- * Authors:
- * Charles Kerr <charles.kerr@canonical.com>
- *
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 3, as published
- * by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranties of
- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <langinfo.h>
-#include <locale.h>
-
-#include <glib/gi18n.h>
-
-#include "utils.h"
-
-#include "glib-fixture.h"
-
-/***
-****
-***/
-
-class FormatterFixture: public GlibFixture
-{
- private:
-
- typedef GlibFixture super;
- gchar * original_locale = nullptr;
-
- protected:
-
- virtual void SetUp ()
- {
- super::SetUp ();
-
- original_locale = g_strdup (setlocale (LC_TIME, NULL));
- }
-
- virtual void TearDown ()
- {
- setlocale (LC_TIME, original_locale);
- g_clear_pointer (&original_locale, g_free);
-
- super::TearDown ();
- }
-
- bool SetLocale (const char * expected_locale, const char * name)
- {
- setlocale (LC_TIME, expected_locale);
- const char * actual_locale = setlocale (LC_TIME, NULL);
- if (!g_strcmp0 (expected_locale, actual_locale))
- {
- return true;
- }
- else
- {
- g_warning ("Unable to set locale to %s; skipping %s locale tests.", expected_locale, name);
- return false;
- }
- }
-
- inline bool Set24hLocale () { return SetLocale ("C", "24h"); }
- inline bool Set12hLocale () { return SetLocale ("en_US.utf8", "12h"); }
-};
-
-
-/**
- * Test the phone header format
- */
-TEST_F (FormatterFixture, TestPhoneHeader)
-{
- // test the default value in a 24h locale
- if (Set24hLocale ())
- {
- const gchar * format = get_terse_header_time_format_string ();
- ASSERT_NE (nullptr, format);
- ASSERT_STREQ ("%H:%M", format);
- }
-
- // test the default value in a 12h locale
- if (Set12hLocale ())
- {
- const gchar * format = get_terse_header_time_format_string ();
- ASSERT_NE (nullptr, format);
- ASSERT_STREQ ("%l:%M %p", format);
- }
-}
diff --git a/tests/test-formatter.cpp b/tests/test-formatter.cpp
index 9950453..01df4f2 100644
--- a/tests/test-formatter.cpp
+++ b/tests/test-formatter.cpp
@@ -97,7 +97,7 @@ TEST_F(FormatterFixture, TestPhoneHeader)
if(Set24hLocale())
{
PhoneFormatter formatter(clock);
- EXPECT_EQ(std::string("%H:%M"), formatter.headerFormat.get());
+ EXPECT_EQ(std::string("%H:%M"), formatter.header_format.get());
EXPECT_EQ(std::string("18:30"), formatter.header.get());
}
@@ -105,7 +105,7 @@ TEST_F(FormatterFixture, TestPhoneHeader)
if(Set12hLocale())
{
PhoneFormatter formatter(clock);
- EXPECT_EQ(std::string("%l:%M %p"), formatter.headerFormat.get());
+ EXPECT_EQ(std::string("%l:%M %p"), formatter.header_format.get());
EXPECT_EQ(std::string(" 6:30 PM"), formatter.header.get());
}
}
@@ -156,7 +156,7 @@ TEST_F(FormatterFixture, TestDesktopHeader)
m_settings->show_date.set(test_case.show_date);
m_settings->show_year.set(test_case.show_year);
- ASSERT_STREQ(test_case.expected_format_string, f.headerFormat.get().c_str());
+ ASSERT_STREQ(test_case.expected_format_string, f.header_format.get().c_str());
}
}
}
@@ -196,7 +196,7 @@ TEST_F(FormatterFixture, TestUpcomingTimes)
std::shared_ptr<Clock> clock (new MockClock(DateTime(test_case.now)));
DesktopFormatter f(clock, m_settings);
- const auto fmt = f.getRelativeFormat(test_case.then);
+ const auto fmt = f.relative_format(test_case.then);
ASSERT_EQ(test_case.expected_format_string, fmt);
g_clear_pointer(&test_case.now, g_date_time_unref);
@@ -239,7 +239,7 @@ TEST_F(FormatterFixture, TestEventTimes)
std::shared_ptr<Clock> clock(new MockClock(DateTime(test_case.now)));
DesktopFormatter f(clock, m_settings);
- const auto fmt = f.getRelativeFormat(test_case.then, test_case.then_end);
+ const auto fmt = f.relative_format(test_case.then, test_case.then_end);
ASSERT_STREQ(test_case.expected_format_string, fmt.c_str());
g_clear_pointer(&test_case.now, g_date_time_unref);
diff --git a/tests/test-live-actions.cpp b/tests/test-live-actions.cpp
index 562b358..eab8596 100644
--- a/tests/test-live-actions.cpp
+++ b/tests/test-live-actions.cpp
@@ -356,11 +356,11 @@ TEST_F(LiveActionsFixture, CalendarState)
a2.begin = next_begin;
a2.end = next_end;
- m_state->planner->thisMonth.set(std::vector<Appointment>({a1, a2}));
+ m_state->planner->this_month.set(std::vector<Appointment>({a1, a2}));
///
/// Now test the calendar state again.
- /// The thisMonth field should now contain the appointments we just added.
+ /// The this_month field should now contain the appointments we just added.
///
calendar_state = g_action_group_get_action_state (action_group, "calendar");
diff --git a/tests/test-menus.cpp b/tests/test-menus.cpp
index e9dd7df..73d6036 100644
--- a/tests/test-menus.cpp
+++ b/tests/test-menus.cpp
@@ -158,42 +158,20 @@ protected:
g_object_unref(submenu);
}
- void InspectAppointments(GMenuModel* menu_model, Menu::Profile profile)
- {
- const bool appointments_expected = (profile == Menu::Desktop)
- || (profile == Menu::Phone);
+private:
+ void InspectEmptySection(GMenuModel* menu_model, Menu::Section section)
+ {
// get the Appointments section
auto submenu = g_menu_model_get_item_link(menu_model, 0, G_MENU_LINK_SUBMENU);
+ auto menu_section = g_menu_model_get_item_link(submenu, section, G_MENU_LINK_SECTION);
+ EXPECT_EQ(0, g_menu_model_get_n_items(menu_section));
+ g_clear_object(&menu_section);
+ g_clear_object(&submenu);
+ }
- // there shouldn't be any menuitems when "show events" is false
- m_state->settings->show_events.set(false);
- wait_msec();
- auto section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION);
- EXPECT_EQ(0, g_menu_model_get_n_items(section));
- g_clear_object(&section);
-
- // when "show_events" is true,
- // there should be an "add event" button even if there aren't any appointments
- std::vector<Appointment> appointments;
- m_state->settings->show_events.set(true);
- m_state->planner->upcoming.set(appointments);
- wait_msec();
- section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION);
- int expected_n = appointments_expected ? 1 : 0;
- EXPECT_EQ(expected_n, g_menu_model_get_n_items(section));
- if (appointments_expected)
- {
- gchar* action = nullptr;
- EXPECT_TRUE(g_menu_model_get_item_attribute(section, 0, G_MENU_ATTRIBUTE_ACTION, "s", &action));
- EXPECT_STREQ("indicator.activate-planner", action);
- EXPECT_TRUE(g_action_group_has_action(m_actions->action_group(), "activate-planner"));
- g_free(action);
- }
- g_clear_object(&section);
-
- // try adding a few appointments and see if the menu updates itself
-
+ std::vector<Appointment> build_some_appointments()
+ {
const auto now = m_state->clock->localtime();
auto gdt_tomorrow = g_date_time_add_days(now.get(), 1);
const auto tomorrow = DateTime(gdt_tomorrow);
@@ -206,7 +184,6 @@ protected:
a1.uid = "example";
a1.has_alarms = true;
a1.begin = a1.end = tomorrow;
- appointments.push_back(a1);
Appointment a2; // a non-alarm appointment
a2.color = "green";
@@ -215,52 +192,183 @@ protected:
a2.uid = "monkey";
a2.has_alarms = false;
a2.begin = a2.end = tomorrow;
- appointments.push_back(a2);
- m_state->planner->upcoming.set(appointments);
- wait_msec(); // wait a moment for the menu to update
+ return std::vector<Appointment>({a1, a2});
+ }
- section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION);
- expected_n = appointments_expected ? 3 : 0;
- EXPECT_EQ(expected_n, g_menu_model_get_n_items(section));
- if (appointments_expected)
+ void InspectAppointmentMenuItem(GMenuModel* section,
+ int index,
+ const Appointment& appt)
+ {
+ // confirm it has the right x-canonical-type
+ gchar * str = nullptr;
+ g_menu_model_get_item_attribute(section, index, "x-canonical-type", "s", &str);
+ if (appt.has_alarms)
+ EXPECT_STREQ("com.canonical.indicator.alarm", str);
+ else
+ EXPECT_STREQ("com.canonical.indicator.appointment", str);
+ g_clear_pointer(&str, g_free);
+
+ // confirm it has a nonempty x-canonical-time-format
+ g_menu_model_get_item_attribute(section, index, "x-canonical-time-format", "s", &str);
+ EXPECT_TRUE(str && *str);
+ g_clear_pointer(&str, g_free);
+
+ // confirm the color hint, if it exists,
+ // is in the x-canonical-color attribute
+ if (appt.color.empty())
{
- gchar * str = nullptr;
+ EXPECT_FALSE(g_menu_model_get_item_attribute(section,
+ index,
+ "x-canonical-color",
+ "s",
+ &str));
+ }
+ else
+ {
+ EXPECT_TRUE(g_menu_model_get_item_attribute(section,
+ index,
+ "x-canonical-color",
+ "s",
+ &str));
+ EXPECT_EQ(appt.color, str);
+ }
+ g_clear_pointer(&str, g_free);
- // test the alarm
- // - confirm it has an x-canonical-type of "alarm"
- g_menu_model_get_item_attribute(section, 0, "x-canonical-type", "s", &str);
- EXPECT_STREQ("com.canonical.indicator.alarm", str);
- g_clear_pointer(&str, g_free);
- // - confirm it has a nonempty x-canonical-time-format
- g_menu_model_get_item_attribute(section, 0, "x-canonical-time-format", "s", &str);
- EXPECT_TRUE(str && *str);
- g_clear_pointer(&str, g_free);
- // - confirm it has a serialized icon attribute
- auto v = g_menu_model_get_item_attribute_value(section, 0, G_MENU_ATTRIBUTE_ICON, nullptr);
+ // confirm that alarms have an icon
+ if (appt.has_alarms)
+ {
+ auto v = g_menu_model_get_item_attribute_value(section,
+ index,
+ G_MENU_ATTRIBUTE_ICON,
+ nullptr);
EXPECT_TRUE(v != nullptr);
auto icon = g_icon_deserialize(v);
EXPECT_TRUE(icon != nullptr);
g_clear_object(&icon);
g_clear_pointer(&v, g_variant_unref);
-
- // test the appointment
- // - confirm it has an x-canonical-type of "appointment"
- g_menu_model_get_item_attribute(section, 1, "x-canonical-type", "s", &str);
- EXPECT_STREQ("com.canonical.indicator.appointment", str);
- g_clear_pointer(&str, g_free);
- // - confirm it has a nonempty x-canonical-time-format
- g_menu_model_get_item_attribute(section, 0, "x-canonical-time-format", "s", &str);
- EXPECT_TRUE(str && *str);
- g_clear_pointer(&str, g_free);
- // - confirm its color matches the one we fed the appointments vector
- g_menu_model_get_item_attribute(section, 1, "x-canonical-color", "s", &str);
- EXPECT_EQ(a2.color, str);
- g_clear_pointer(&str, g_free);
}
+ }
+
+ void InspectAppointmentMenuItems(GMenuModel* section,
+ int first_appt_index,
+ const std::vector<Appointment>& appointments)
+ {
+ // try adding a few appointments and see if the menu updates itself
+ m_state->planner->upcoming.set(appointments);
+ wait_msec(); // wait a moment for the menu to update
+
+ //auto submenu = g_menu_model_get_item_link(menu_model, 0, G_MENU_LINK_SUBMENU);
+ //auto section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION);
+ EXPECT_EQ(appointments.size()+1, g_menu_model_get_n_items(section));
+
+ for (int i=0, n=appointments.size(); i<n; i++)
+ InspectAppointmentMenuItem(section, first_appt_index+i, appointments[i]);
+
+ //g_clear_object(&section);
+ //g_clear_object(&submenu);
+ }
+
+ void InspectDesktopAppointments(GMenuModel* menu_model)
+ {
+ // get the Appointments section
+ auto submenu = g_menu_model_get_item_link(menu_model, 0, G_MENU_LINK_SUBMENU);
+
+ // there shouldn't be any menuitems when "show events" is false
+ m_state->settings->show_events.set(false);
+ wait_msec();
+ auto section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION);
+ EXPECT_EQ(0, g_menu_model_get_n_items(section));
g_clear_object(&section);
- g_object_unref(submenu);
+ // when "show_events" is true,
+ // there should be an "add event" button even if there aren't any appointments
+ std::vector<Appointment> appointments;
+ m_state->settings->show_events.set(true);
+ m_state->planner->upcoming.set(appointments);
+ wait_msec();
+ section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION);
+ EXPECT_EQ(1, g_menu_model_get_n_items(section));
+ gchar* action = nullptr;
+ EXPECT_TRUE(g_menu_model_get_item_attribute(section, 0, G_MENU_ATTRIBUTE_ACTION, "s", &action));
+ const char* expected_action = "activate-planner";
+ EXPECT_EQ(std::string("indicator.")+expected_action, action);
+ EXPECT_TRUE(g_action_group_has_action(m_actions->action_group(), expected_action));
+ g_free(action);
+ g_clear_object(&section);
+
+ // try adding a few appointments and see if the menu updates itself
+ appointments = build_some_appointments();
+ m_state->planner->upcoming.set(appointments);
+ wait_msec(); // wait a moment for the menu to update
+ section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION);
+ EXPECT_EQ(3, g_menu_model_get_n_items(section));
+ InspectAppointmentMenuItems(section, 0, appointments);
+ g_clear_object(&section);
+
+ // cleanup
+ g_clear_object(&submenu);
+ }
+
+ void InspectPhoneAppointments(GMenuModel* menu_model)
+ {
+ auto submenu = g_menu_model_get_item_link(menu_model, 0, G_MENU_LINK_SUBMENU);
+
+ // clear all the appointments
+ std::vector<Appointment> appointments;
+ m_state->planner->upcoming.set(appointments);
+ wait_msec(); // wait a moment for the menu to update
+
+ // check that there's a "clock app" menuitem even when there are no appointments
+ auto section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION);
+ const char* expected_action = "activate-phone-clock-app";
+ EXPECT_EQ(1, g_menu_model_get_n_items(section));
+ gchar* action = nullptr;
+ EXPECT_TRUE(g_menu_model_get_item_attribute(section, 0, G_MENU_ATTRIBUTE_ACTION, "s", &action));
+ EXPECT_EQ(std::string("indicator.")+expected_action, action);
+ EXPECT_TRUE(g_action_group_has_action(m_actions->action_group(), expected_action));
+ g_free(action);
+ g_clear_object(&section);
+
+ // add some appointments and test them
+ appointments = build_some_appointments();
+ m_state->planner->upcoming.set(appointments);
+ wait_msec(); // wait a moment for the menu to update
+ section = g_menu_model_get_item_link(submenu, Menu::Appointments, G_MENU_LINK_SECTION);
+ EXPECT_EQ(3, g_menu_model_get_n_items(section));
+ InspectAppointmentMenuItems(section, 1, appointments);
+ g_clear_object(&section);
+
+ // cleanup
+ g_clear_object(&submenu);
+ }
+
+protected:
+
+ void InspectAppointments(GMenuModel* menu_model, Menu::Profile profile)
+ {
+ switch (profile)
+ {
+ case Menu::Desktop:
+ InspectDesktopAppointments(menu_model);
+ break;
+
+ case Menu::DesktopGreeter:
+ InspectEmptySection(menu_model, Menu::Appointments);
+ break;
+
+ case Menu::Phone:
+ InspectPhoneAppointments(menu_model);
+ break;
+
+ case Menu::PhoneGreeter:
+ InspectEmptySection(menu_model, Menu::Appointments);
+ break;
+
+ default:
+ g_warn_if_reached();
+ break;
+ }
}
void CompareLocationsTo(GMenuModel* menu_model, const std::vector<Location>& locations)
diff --git a/tests/test-planner.cpp b/tests/test-planner.cpp
index 3072aea..b476ee8 100644
--- a/tests/test-planner.cpp
+++ b/tests/test-planner.cpp
@@ -47,9 +47,9 @@ TEST_F(PlannerFixture, EDS)
planner.time.set(DateTime(now));
wait_msec(2500);
- std::vector<Appointment> thisMonth = planner.thisMonth.get();
- std::cerr << thisMonth.size() << " appointments this month" << std::endl;
- for(const auto& a : thisMonth)
+ std::vector<Appointment> this_month = planner.this_month.get();
+ std::cerr << this_month.size() << " appointments this month" << std::endl;
+ for(const auto& a : this_month)
std::cerr << a.summary << std::endl;
}
diff --git a/tests/test-settings.cpp b/tests/test-settings.cpp
index df01cd7..980e7fa 100644
--- a/tests/test-settings.cpp
+++ b/tests/test-settings.cpp
@@ -189,9 +189,3 @@ TEST_F(SettingsFixture, Locations)
g_strfreev(tmp);
EXPECT_EQ(bv, vtmp);
}
-
-#if 0
- core::Property<std::vector<std::string>> locations;
- core::Property<TimeFormatMode> time_format_mode;
-
-#endif
diff --git a/tests/test-timezone-geoclue.cpp b/tests/test-timezone-geoclue.cpp
index 4bf08a7..3cc1393 100644
--- a/tests/test-timezone-geoclue.cpp
+++ b/tests/test-timezone-geoclue.cpp
@@ -21,64 +21,17 @@
#include <datetime/timezone-geoclue.h>
-//#include <libdbustest/dbus-test.h>
-
using unity::indicator::datetime::GeoclueTimezone;
-/***
-****
-***/
-
-class TimezoneGeoclueFixture : public GeoclueFixture
-{
-};
-
-#if 0
-namespace
+// This test looks small because the interesting
+// work is all happening in GeoclueFixture...
+TEST_F(GeoclueFixture, ChangeDetected)
{
- struct EmitAddressChangedData
- {
- DbusTestDbusMock * mock = nullptr;
- DbusTestDbusMockObject * obj_client = nullptr;
- std::string timezone;
- EmitAddressChangedData(DbusTestDbusMock * mock_,
- DbusTestDbusMockObject * obj_client_,
- const std::string& timezone_): mock(mock_), obj_client(obj_client_), timezone(timezone_) {}
- };
-
- gboolean emit_address_changed_idle(gpointer gdata)
- {
- auto data = static_cast<EmitAddressChangedData*>(gdata);
-
- GError * error = nullptr;
- dbus_test_dbus_mock_object_emit_signal(data->mock, data->obj_client,
- "org.freedesktop.Geoclue.Address",
- "AddressChanged",
- G_VARIANT_TYPE("(ia{ss}(idd))"),
- g_variant_new_parsed("(1385238033, {'timezone': 'America/Chicago'}, (3, 0.0, 0.0))"),
- &error);
- if (error)
- {
- g_warning("%s: %s", G_STRFUNC, error->message);
- g_error_free(error);
- }
-
- delete data;
- return G_SOURCE_REMOVE;
- }
-}
-#endif
-
-TEST_F(TimezoneGeoclueFixture, ChangeDetected)
-{
-// const std::string timezone_1 = "America/Denver";
- const std::string timezone_2 = "America/Chicago";
-
GeoclueTimezone tz;
wait_msec(500); // wait for the bus to get set up
EXPECT_EQ(timezone_1, tz.timezone.get());
- // start listening for a timezone change, then change the timezone
+ // Start listening for a timezone change, then change the timezone.
bool changed = false;
auto connection = tz.timezone.changed().connect(
@@ -88,10 +41,8 @@ TEST_F(TimezoneGeoclueFixture, ChangeDetected)
g_main_loop_quit(loop);
});
+ const std::string timezone_2 = "America/Chicago";
setGeoclueTimezoneOnIdle(timezone_2);
- //g_timeout_add(50, emit_address_changed_idle, new EmitAddressChangedData(mock, obj_client, timezone_2.c_str()));
g_main_loop_run(loop);
EXPECT_EQ(timezone_2, tz.timezone.get());
}
-
-