aboutsummaryrefslogtreecommitdiff
path: root/tests/manual-test-snap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual-test-snap.cpp')
-rw-r--r--tests/manual-test-snap.cpp53
1 files changed, 48 insertions, 5 deletions
diff --git a/tests/manual-test-snap.cpp b/tests/manual-test-snap.cpp
index 16e606a..cc24a67 100644
--- a/tests/manual-test-snap.cpp
+++ b/tests/manual-test-snap.cpp
@@ -19,18 +19,51 @@
*/
#include <datetime/appointment.h>
+#include <datetime/settings-live.h>
#include <datetime/snap.h>
+#include <datetime/timezones-live.h>
#include <glib.h>
using namespace unity::indicator::datetime;
+#define TIMEZONE_FILE ("/etc/timezone")
+
+
/***
****
***/
-int main()
+namespace
+{
+ gboolean quit_idle (gpointer gloop)
+ {
+ g_main_loop_quit(static_cast<GMainLoop*>(gloop));
+ return G_SOURCE_REMOVE;
+ };
+
+ int volume = 50;
+
+ GOptionEntry entries[] =
+ {
+ { "volume", 'v', 0, G_OPTION_ARG_INT, &volume, "Volume level [1..100]", "volume" },
+ { NULL }
+ };
+}
+
+int main(int argc, const char* argv[])
{
+ GError* error = nullptr;
+ GOptionContext* context = g_option_context_new(nullptr);
+ g_option_context_add_main_entries(context, entries, nullptr);
+ if (!g_option_context_parse(context, &argc, (gchar***)&argv, &error))
+ {
+ g_print("option parsing failed: %s\n", error->message);
+ exit(1);
+ }
+ g_option_context_free(context);
+ volume = CLAMP(volume, 1, 100);
+
Appointment a;
a.color = "green";
a.summary = "Alarm";
@@ -47,15 +80,25 @@ int main()
auto loop = g_main_loop_new(nullptr, false);
auto show = [loop](const Appointment& appt){
g_message("You clicked 'show' for appt url '%s'", appt.url.c_str());
- g_main_loop_quit(loop);
+ g_idle_add(quit_idle, loop);
};
auto dismiss = [loop](const Appointment&){
g_message("You clicked 'dismiss'");
- g_main_loop_quit(loop);
+ g_idle_add(quit_idle, loop);
};
-
- Snap snap;
+
+ // only use local, temporary settings
+ g_assert(g_setenv("GSETTINGS_SCHEMA_DIR", SCHEMA_DIR, true));
+ g_assert(g_setenv("GSETTINGS_BACKEND", "memory", true));
+ g_debug("SCHEMA_DIR is %s", SCHEMA_DIR);
+
+ auto settings = std::make_shared<LiveSettings>();
+ settings->alarm_volume.set(volume);
+ auto timezones = std::make_shared<LiveTimezones>(settings, TIMEZONE_FILE);
+ auto clock = std::make_shared<LiveClock>(timezones);
+ Snap snap (clock, settings);
snap(a, show, dismiss);
g_main_loop_run(loop);
+ g_main_loop_unref(loop);
return 0;
}