static bool __get_all_job();
static bool __toggle_job_cb();
static bool __publish_context();
+static bool __custom_uri();
static void __start_job_cb(ctx_sched_h scheduler, ctx_sched_job_h job, bool timeout, void *cbData);
static void __start_job_cb_with_finish(ctx_sched_h scheduler, ctx_sched_job_h job, bool timeout, void *cbData);
case 'p':
run_test_case("/scheduler/publish_context", __publish_context);
break;
+ case 'u':
+ run_test_case("/scheduler/custom_uri", __custom_uri);
+ break;
case 'q':
stop_mainloop();
return G_SOURCE_REMOVE;
g_print(" 5. DBus action test (trigger: earjack)\n");
g_print(" 6. App-control action test (trigger: earjack, target: gallery)\n");
g_print(" 7. Notification action test (trigger: earjack)\n");
- g_print(" 8. Custom trigger test\n");
- g_print(" 9. Custom requirement test (trigger: earjack)\n");
+ g_print("\n");
+ g_print(" 8. User-session agent test (trigger: contacts db, geofence\n");
+ g_print("\n");
+ g_print(" 9. Custom trigger test\n");
+ g_print("10. Custom requirement test (trigger: earjack)\n");
g_print("\n");
ctx_sched_job_h job = sched::create_job(__scheduler, read_int(" ? "));
return true;
}
+bool __custom_uri()
+{
+ int error = E_NONE;
+ bool registered = false;
+
+ error = ctx_sched_custom_register(__scheduler, "http://samsung.com/context/wrong/something");
+ ASSERT_CMPINT(error, ==, E_PARAM);
+
+ error = ctx_sched_custom_register(__scheduler, "http://samsung.com/context/custom/test_1");
+ ASSERT_CMPINT(error, ==, E_NONE);
+
+ error = ctx_sched_custom_register(__scheduler, "http://samsung.com/context/custom/test_2");
+ ASSERT_CMPINT(error, ==, E_NONE);
+
+ error = ctx_sched_custom_register(__scheduler, "http://samsung.com/context/custom/test_3");
+ ASSERT_CMPINT(error, ==, E_NONE);
+
+ error = ctx_sched_custom_unregister(__scheduler, "http://samsung.com/context/custom/test_2");
+ ASSERT_CMPINT(error, ==, E_NONE);
+
+ error = ctx_sched_custom_is_registered(__scheduler, "http://samsung.com/context/custom/test_2", "context-test", ®istered);
+ ASSERT_CMPINT(error, ==, E_NONE);
+ ASSERT(!registered);
+
+ error = ctx_sched_custom_is_registered(__scheduler, "http://samsung.com/context/custom/test_1", "context-test", ®istered);
+ ASSERT_CMPINT(error, ==, E_NONE);
+ ASSERT(registered);
+
+ return true;
+}
+
void __start_job_cb(ctx_sched_h scheduler, ctx_sched_job_h job, bool timeout, void *cbData)
{
g_print("> A job has been executed (timeout: %s).\n", timeout ? "yes" : "no");
static bool __create_dbus_test(ctx_sched_h scheduler, ctx_sched_job_h* job);
static bool __create_app_control_test(ctx_sched_h scheduler, ctx_sched_job_h* job);
static bool __create_notification_test(ctx_sched_h scheduler, ctx_sched_job_h* job);
+static bool __create_agent_test(ctx_sched_h scheduler, ctx_sched_job_h* job);
static bool __create_custom_trigger_test(ctx_sched_h scheduler, ctx_sched_job_h* job);
static bool __create_custom_requirement_test(ctx_sched_h scheduler, ctx_sched_job_h* job);
success = __create_notification_test(scheduler, &job);
break;
case 8:
- success = __create_custom_trigger_test(scheduler, &job);
+ success = __create_agent_test(scheduler, &job);
break;
case 9:
+ success = __create_custom_trigger_test(scheduler, &job);
+ break;
+ case 10:
success = __create_custom_requirement_test(scheduler, &job);
break;
default:
return true;
}
+bool __create_agent_test(ctx_sched_h scheduler, ctx_sched_job_h* job)
+{
+ int error = E_NONE;
+ bool supported = false;
+ ctx_sched_job_context_h jobContext = NULL;
+
+ // Allocate an on-demand job handle
+ error = ctx_sched_job_create_on_demand(job);
+ ASSERT_CMPINT(error, ==, E_NONE);
+
+ // Contacts DB
+ ctx_sched_job_trigger_is_supported(scheduler, CTX_SCHED_URI_CONTACTS_DB, &supported);
+ if (supported) {
+ ctx_sched_job_trigger_create(CTX_SCHED_URI_CONTACTS_DB, &jobContext);
+ ctx_sched_job_context_prepare_attribute_str(jobContext, CTX_SCHED_ATTR_NAME_EVENT);
+ ctx_sched_job_context_attribute_add_eq_str(jobContext, CTX_SCHED_ATTR_NAME_EVENT, CTX_SCHED_ATTR_VALUE_CHANGED);
+ ctx_sched_job_add_trigger(*job, jobContext);
+ } else {
+ g_print("> Contacts DB change trigger is not supported.\n");
+ }
+
+ // Geofence
+ ctx_sched_job_trigger_is_supported(scheduler, CTX_SCHED_URI_GEOFENCE, &supported);
+ if (supported) {
+ ctx_sched_job_trigger_create(CTX_SCHED_URI_GEOFENCE, &jobContext);
+
+ ctx_sched_job_context_prepare_attribute_str(jobContext, CTX_SCHED_ATTR_NAME_EVENT);
+ ctx_sched_job_context_attribute_add_eq_str(jobContext, CTX_SCHED_ATTR_NAME_EVENT, CTX_SCHED_ATTR_VALUE_IN);
+
+ ctx_sched_job_context_prepare_attribute_int(jobContext, CTX_SCHED_ATTR_NAME_PLACE_ID);
+ ctx_sched_job_context_attribute_add_eq_int(jobContext, CTX_SCHED_ATTR_NAME_PLACE_ID, 1);
+ ctx_sched_job_context_attribute_add_eq_int(jobContext, CTX_SCHED_ATTR_NAME_PLACE_ID, 2);
+
+ ctx_sched_job_add_trigger(*job, jobContext);
+ } else {
+ g_print("> Geofence trigger is not supported.\n");
+ }
+
+ error = ctx_sched_job_set_notification(*job, "Job Scheduler", "User Session Agent Test", NULL, NULL);
+ ASSERT_CMPINT(error, ==, E_NONE);
+
+ return true;
+}
+
bool __create_custom_trigger_test(ctx_sched_h scheduler, ctx_sched_job_h* job)
{
int error = E_NONE;