--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <calendar.h>
+#include <time.h>
+
+#include "utc-calendar-debug.h"
+#include "utc-calendar-util.h"
+#include "utc-calendar-db.h"
+
+static int g_startup_err = CALENDAR_ERROR_NONE;
+
+/**
+ * @function utc_calendar_recurrence_startup
+ * @description Called before each test
+ * @parameter NA
+ * @return NA
+ */
+void utc_calendar_recurrence_startup(void)
+{
+ g_startup_err = calendar_connect();
+ if (g_startup_err != CALENDAR_ERROR_NONE) {
+ fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__);
+ fprintf(stderr, "calendar_connect failed (code: %d)\n", g_startup_err);
+ }
+ _clean_db();
+}
+
+/**
+ * @function utc_calendar_recurrence_cleanup
+ * @description Called after each test
+ * @parameter NA
+ * @return NA
+ */
+void utc_calendar_recurrence_cleanup(void)
+{
+ _clean_db();
+ calendar_disconnect();
+}
+
+time_t __get_utime(int y, int m, int d, int h, int n, int s)
+{
+ struct tm st = {0};
+ st.tm_year = y - 1900;
+ st.tm_mon = m - 1;
+ st.tm_mday = d;
+ st.tm_hour = h;
+ st.tm_min = n;
+ st.tm_sec = s;
+ return mktime(&st);
+}
+
+void _create_event(calendar_record_h *out_event)
+{
+ calendar_record_h event = NULL;
+ calendar_record_create(_calendar_event._uri, &event);
+
+ const char *set_tzid = "Asia/Seoul";
+
+ calendar_record_set_str(event, _calendar_event.start_tzid, set_tzid);
+ calendar_time_s st = {0};
+ st.type = CALENDAR_TIME_UTIME;
+ int set_start_year = 2012;
+ int set_start_month = 9;
+ int set_start_mday = 3;
+
+ calendar_record_set_str(event, _calendar_event.end_tzid, set_tzid);
+ calendar_time_s et = {0};
+ et.type = CALENDAR_TIME_UTIME;
+ int set_end_year = 2012;
+ int set_end_month = 9;
+ int set_end_mday = 3;
+
+ st.time.utime = __get_utime(set_start_year, set_start_month, set_start_mday, 10, 0, 0);
+ et.time.utime = __get_utime(set_end_year, set_end_month, set_end_mday, 11, 0, 0);
+
+ calendar_record_set_caltime(event, _calendar_event.start_time, st);
+ calendar_record_set_caltime(event, _calendar_event.end_time, et);
+
+ const char *set_summary_origin = "test_origin";
+ calendar_record_set_str(event, _calendar_event.summary, set_summary_origin);
+ const char *set_description = "description";
+ calendar_record_set_str(event, _calendar_event.description, set_description);
+ const char *set_location = "location";
+ calendar_record_set_str(event, _calendar_event.location, set_location);
+ const char *set_categories = "categories";
+ calendar_record_set_str(event, _calendar_event.categories, set_categories);
+ int set_event_status = CALENDAR_EVENT_STATUS_CONFIRMED;
+ calendar_record_set_int(event, _calendar_event.event_status, set_event_status);
+
+ int set_priority = CALENDAR_EVENT_PRIORITY_NORMAL;
+ calendar_record_set_int(event, _calendar_event.priority, set_priority);
+ int set_busy_status = CALENDAR_EVENT_BUSY_STATUS_BUSY;
+ calendar_record_set_int(event, _calendar_event.busy_status, set_busy_status);
+ int set_sensitivity = CALENDAR_SENSITIVITY_PRIVATE;
+ calendar_record_set_int(event, _calendar_event.sensitivity, set_sensitivity);
+ const char *set_uid = "uid";
+ calendar_record_set_str(event, _calendar_event.uid, set_uid);
+ const char *set_organizer_name = "organizer_name";
+ calendar_record_set_str(event, _calendar_event.organizer_name, set_organizer_name);
+ const char *set_organizer_email = "organizer_email";
+ calendar_record_set_str(event, _calendar_event.organizer_email, set_organizer_email);
+ int set_meeting_status = CALENDAR_MEETING_STATUS_MEETING;
+ calendar_record_set_int(event, _calendar_event.meeting_status, set_meeting_status);
+ double set_latitude = 36.7;
+ calendar_record_set_double(event, _calendar_event.latitude, set_latitude);
+ double set_longitude = 139.3;
+ calendar_record_set_double(event, _calendar_event.longitude, set_longitude);
+ int set_calendar_system_type = CALENDAR_SYSTEM_GREGORIAN;
+ calendar_record_set_int(event, _calendar_event.calendar_system_type, set_calendar_system_type);
+ const char *set_sync_data1 = "sync_data1";
+ calendar_record_set_str(event, _calendar_event.sync_data1, set_sync_data1);
+ const char *set_sync_data2 = "sync_data2";
+ calendar_record_set_str(event, _calendar_event.sync_data2, set_sync_data2);
+ const char *set_sync_data3 = "sync_data3";
+ calendar_record_set_str(event, _calendar_event.sync_data3, set_sync_data3);
+ const char *set_sync_data4 = "sync_data4";
+ calendar_record_set_str(event, _calendar_event.sync_data4, set_sync_data4);
+
+ // recurrence
+ int set_freq = CALENDAR_RECURRENCE_MONTHLY;
+ calendar_record_set_int(event, _calendar_event.freq, set_freq);
+ int set_wkst = CALENDAR_MONDAY;
+ calendar_record_set_int(event, _calendar_event.wkst, set_wkst);
+ int set_interval = 1;
+ calendar_record_set_int(event, _calendar_event.interval, set_interval);
+ const char *set_bymonthday = "3,4,5";
+ calendar_record_set_str(event, _calendar_event.bymonthday, set_bymonthday);
+
+ int set_range_type = CALENDAR_RANGE_COUNT;
+ calendar_record_set_int(event, _calendar_event.range_type, set_range_type);
+ int set_count = 8;
+ calendar_record_set_int(event, _calendar_event.count, set_count);
+
+ // alarm
+ calendar_record_h alarm = NULL;
+ calendar_record_create(_calendar_alarm._uri, &alarm);
+ int set_alarm_tick = 5;
+ calendar_record_set_int(alarm, _calendar_alarm.tick, set_alarm_tick);
+ int set_alarm_unit = CALENDAR_ALARM_TIME_UNIT_MINUTE;
+ calendar_record_set_int(alarm, _calendar_alarm.tick_unit, set_alarm_unit);
+ const char *set_alarm_description = "alarm_description";
+ calendar_record_set_str(alarm, _calendar_alarm.description, set_alarm_description);
+ const char *set_alarm_summary = "alarm_summary";
+ calendar_record_set_str(alarm, _calendar_alarm.summary, set_alarm_summary);
+ int set_alarm_action = 1;
+ calendar_record_set_int(alarm, _calendar_alarm.action, set_alarm_action);
+ const char *set_alarm_attach = "alarm_attach";
+ calendar_record_set_str(alarm, _calendar_alarm.attach, set_alarm_attach);
+
+ calendar_record_add_child_record(event, _calendar_event.calendar_alarm, alarm);
+
+ // attendee
+ calendar_record_h attendee = NULL;
+ calendar_record_create(_calendar_attendee._uri, &attendee);
+
+ const char *set_attendee_number = "010-1234-1234";
+ calendar_record_set_str(attendee, _calendar_attendee.number, set_attendee_number);
+ int set_attendee_cutype = CALENDAR_ATTENDEE_CUTYPE_GROUP;
+ calendar_record_set_int(attendee, _calendar_attendee.cutype, set_attendee_cutype);
+ int set_attendee_person_id = 4;
+ calendar_record_set_int(attendee, _calendar_attendee.person_id, set_attendee_person_id);
+ const char *set_attendee_uid = "attendee_uid";
+ calendar_record_set_str(attendee, _calendar_attendee.uid, set_attendee_uid);
+ const char *set_attendee_group = "company";
+ calendar_record_set_str(attendee, _calendar_attendee.group, set_attendee_group);
+ const char *set_attendee_email = "abc@company.com";
+ calendar_record_set_str(attendee, _calendar_attendee.email, set_attendee_email);
+ int set_attendee_role = CALENDAR_ATTENDEE_ROLE_CHAIR;
+ calendar_record_set_int(attendee, _calendar_attendee.role, set_attendee_role);
+ int set_attendee_status = CALENDAR_ATTENDEE_STATUS_TENTATIVE;
+ calendar_record_set_int(attendee, _calendar_attendee.status, set_attendee_status);
+ int set_attendee_rsvp = 2;
+ calendar_record_set_int(attendee, _calendar_attendee.rsvp, set_attendee_rsvp);
+ const char *set_attendee_delegatee_uri = "Lee";
+ calendar_record_set_str(attendee, _calendar_attendee.delegatee_uri, set_attendee_delegatee_uri);
+ const char *set_attendee_delegator_uri = "Kim";
+ calendar_record_set_str(attendee, _calendar_attendee.delegator_uri, set_attendee_delegator_uri);
+ const char *set_attendee_name = "Mr.";
+ calendar_record_set_str(attendee, _calendar_attendee.name, set_attendee_name);
+ const char *set_attendee_member = "member";
+ calendar_record_set_str(attendee, _calendar_attendee.member, set_attendee_member);
+
+ calendar_record_add_child_record(event, _calendar_event.calendar_attendee, attendee);
+
+ if (out_event)
+ *out_event = event;
+}
+
+static int _del_instance(int event_id)
+{
+ int ret = 0;
+
+ calendar_record_h get_event = NULL;
+ ret = calendar_db_get_record(_calendar_event._uri, event_id, &get_event);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+
+ const char *set_exdate = "20121104T010000Z";
+ ret = calendar_record_set_str(get_event, _calendar_event.exdate, set_exdate);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+
+ ret = calendar_db_update_record(get_event);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+ ret = calendar_record_destroy(get_event, true);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+
+ return ret;
+};
+
+static int _mod_instance(int event_id)
+{
+ int ret = 0;
+
+ calendar_record_h get_event = NULL;
+ ret = calendar_db_get_record(_calendar_event._uri, event_id, &get_event);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+
+ calendar_record_h clone = NULL;
+ ret = calendar_record_clone(get_event, &clone);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+ ret = calendar_record_set_str(clone, _calendar_event.summary, "test_mod");
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+ ret = calendar_record_set_int(clone, _calendar_event.original_event_id, event_id);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+ ret = calendar_record_set_str(clone, _calendar_event.recurrence_id, "20121005T010000Z");
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+
+ int clone_id = 0;
+ ret = calendar_db_insert_record(clone, &clone_id);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+
+ ret = calendar_record_destroy(clone, true);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+ ret = calendar_record_destroy(get_event, true);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+
+ return ret;
+}
+
+/**
+ * @testcase utc_calendar_recurrence_p
+ * @since_tizen 3.0
+ * @description Test for exception in recurrence event.
+ */
+
+int utc_calendar_recurrence_p(void)
+{
+ int ret = 0;
+ int event_id = 0;
+ calendar_record_h event = NULL;
+ _create_event(&event);
+ ret = calendar_db_insert_record(event, &event_id);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+ ret = calendar_record_destroy(event, true);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+
+ ret = _del_instance(event_id);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+ ret = _mod_instance(event_id);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+ calendar_db_delete_record(_calendar_event._uri, event_id);
+
+ return ret;
+}
+
fprintf(stderr, "Startup error at %s:%d", __FILE__, __LINE__);
fprintf(stderr, "calendar_connect failed (code: %d)", g_startup_err);
}
+ _clean_db();
}
/**
*/
void utc_calendar_reminder_cleanup(void)
{
+ _clean_db();
calendar_disconnect();
}
return calendar_db_delete_record(_calendar_event._uri, event_id);
}
-static int _reminder_utime(int64_t utime, int unit, int recurrence, int *out_id)
+static int _delete_todo(int todo_id)
+{
+ return calendar_db_delete_record(_calendar_todo._uri, todo_id);
+}
+
+static int _add_reminder_utime_in_event(int64_t utime, int unit, int recurrence, int *out_id)
{
int ret = 0;
int event_id = 0;
return 0;
}
-static int _reminder_localtime(struct tm *local, int unit, int recurrence, int *out_id)
+static int _add_reminder_localtime_in_event(struct tm *local, int unit, int recurrence, int *out_id)
{
int ret = 0;
int event_id = 0;
return 0;
}
+static int _add_reminder_utime_in_todo(int64_t utime, int unit, int recurrence, int *out_id)
+{
+ int ret = 0;
+ int todo_id = 0;
+
+ struct tm now_s = {0};
+ time_t now_t = (time_t)utime;
+ localtime_r(&now_t, &now_s);
+ DBG("Alarm set (%04d/%02d/%02d %02d:%02d:%02d) and alarm (%d)secs before",
+ now_s.tm_year + 1900, now_s.tm_mon + 1, now_s.tm_mday, now_s.tm_hour,
+ now_s.tm_min, now_s.tm_sec, unit);
+
+ calendar_time_s due_time = {0};
+ due_time.type = CALENDAR_TIME_UTIME;
+ due_time.time.utime = utime;
+
+ calendar_record_h alarm = NULL;
+ ret = calendar_record_create(_calendar_alarm._uri, &alarm);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+ ret = calendar_record_set_int(alarm, _calendar_alarm.tick_unit, unit);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+ switch (unit) {
+ case CALENDAR_ALARM_TIME_UNIT_SPECIFIC:
+ ret = calendar_record_set_caltime(alarm, _calendar_alarm.alarm_time, due_time);
+ break;
+ default:
+ ret = calendar_record_set_int(alarm, _calendar_alarm.tick, 1);
+ }
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+
+ calendar_record_h todo = NULL;
+ ret = calendar_record_create(_calendar_todo._uri, &todo);
+ if (CALENDAR_ALARM_TIME_UNIT_SPECIFIC != unit) {
+ ret = calendar_record_set_caltime(todo, _calendar_todo.due_time, due_time);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+ }
+ ret = calendar_record_add_child_record(todo, _calendar_todo.calendar_alarm, alarm);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+ ret = calendar_db_insert_record(todo, &todo_id);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+
+ *out_id = todo_id;
+
+ int time_id = 0;
+ g_checked = false;
+ g_mainloop = g_main_loop_new(NULL, false);
+ ret = calendar_reminder_add_cb(_reminder_cb, NULL);
+ time_id = g_timeout_add(10000, _timeout_cb, g_mainloop);
+ g_main_loop_run(g_mainloop);
+
+ ret = calendar_reminder_remove_cb(_reminder_cb, NULL);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+ calendar_record_destroy(todo, true);
+
+ if (false == g_checked) {
+ DBG("fail");
+ return -1;
+ }
+
+ g_source_remove(time_id);
+
+ return 0;
+}
+
+static int _add_reminder_localtime_in_todo(struct tm *local, int unit, int recurrence, int *out_id)
+{
+ int ret = 0;
+ int todo_id = 0;
+
+ DBG("Alarm set : (%04d/%02d/%02d %02d:%02d:%02d) - (%d)secs",
+ local->tm_year + 1900, local->tm_mon + 1, local->tm_mday, local->tm_hour,
+ local->tm_min, local->tm_sec, unit);
+
+ calendar_time_s due_time = {0};
+ due_time.type = CALENDAR_TIME_LOCALTIME;
+ due_time.time.date.year = local->tm_year + 1900;
+ due_time.time.date.month = local->tm_mon + 1;
+ due_time.time.date.mday = local->tm_mday;
+ due_time.time.date.hour = local->tm_hour;
+ due_time.time.date.minute = local->tm_min;
+ due_time.time.date.second = local->tm_sec;
+
+ calendar_record_h alarm = NULL;
+ ret = calendar_record_create(_calendar_alarm._uri, &alarm);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+ ret = calendar_record_set_int(alarm, _calendar_alarm.tick_unit, unit);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+ switch (unit) {
+ case CALENDAR_ALARM_TIME_UNIT_SPECIFIC:
+ ret = calendar_record_set_caltime(alarm, _calendar_alarm.alarm_time, due_time);
+ break;
+ default:
+ ret = calendar_record_set_int(alarm, _calendar_alarm.tick, 1);
+ }
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+
+ calendar_record_h todo = NULL;
+ ret = calendar_record_create(_calendar_todo._uri, &todo);
+ if (CALENDAR_ALARM_TIME_UNIT_SPECIFIC != unit) {
+ ret = calendar_record_set_caltime(todo, _calendar_todo.due_time, due_time);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+ }
+ ret = calendar_record_add_child_record(todo, _calendar_todo.calendar_alarm, alarm);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+ ret = calendar_db_insert_record(todo, &todo_id);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+
+ *out_id = todo_id;
+
+ int time_id = 0;
+ g_checked = false;
+ g_mainloop = g_main_loop_new(NULL, false);
+ ret = calendar_reminder_add_cb(_reminder_cb, NULL);
+ time_id = g_timeout_add(10000, _timeout_cb, g_mainloop);
+ g_main_loop_run(g_mainloop);
+
+ ret = calendar_reminder_remove_cb(_reminder_cb, NULL);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+ calendar_record_destroy(todo, true);
+
+ if (false == g_checked) {
+ DBG("fail");
+ return -1;
+ }
+
+ g_source_remove(time_id);
+
+ return 0;
+}
+
/**
* @testcase utc_calendar_reminder_add_cb_p
* @since_tizen 3.0
now_t = time(NULL);
now_t += 5;
now_t += 60; /* add 1 min */
- ret = _reminder_utime((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_MINUTE,
+ ret = _add_reminder_utime_in_event((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_MINUTE,
CALENDAR_RECURRENCE_NONE, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t = time(NULL);
now_t += 5;
now_t += (60 * 60); /* add 1 hour */
- ret = _reminder_utime((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_HOUR,
+ ret = _add_reminder_utime_in_event((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_HOUR,
CALENDAR_RECURRENCE_NONE, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t = time(NULL);
now_t += 5;
now_t += (60 * 60 * 24); /* add 1 day */
- ret = _reminder_utime((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_DAY,
+ ret = _add_reminder_utime_in_event((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_DAY,
CALENDAR_RECURRENCE_NONE, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t = time(NULL);
now_t += 5;
now_t += (60 * 60 * 24 * 7); /* add 1 week */
- ret = _reminder_utime((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_WEEK,
+ ret = _add_reminder_utime_in_event((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_WEEK,
CALENDAR_RECURRENCE_NONE, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t += 5;
now_t += 60; /* add 1 min */
now_t -= (60 * 60 * 24); /* 1 day before */
- ret = _reminder_utime((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_MINUTE,
+ ret = _add_reminder_utime_in_event((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_MINUTE,
CALENDAR_RECURRENCE_DAILY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t += 5;
now_t += (60 * 60); /* add 1 hour */
now_t -= (60 * 60 * 24); /* 1 day before */
- ret = _reminder_utime((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_HOUR,
+ ret = _add_reminder_utime_in_event((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_HOUR,
CALENDAR_RECURRENCE_DAILY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t += 5;
now_t += (60 * 60 * 24); /* add 1 day */
now_t -= (60 * 60 * 24); /* 1 day before */
- ret = _reminder_utime((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_DAY,
+ ret = _add_reminder_utime_in_event((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_DAY,
CALENDAR_RECURRENCE_DAILY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t += 5;
now_t += (60 * 60 * 24 * 7); /* add 1 week */
now_t -= (60 * 60 * 24); /* 1 day before */
- ret = _reminder_utime((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_WEEK,
+ ret = _add_reminder_utime_in_event((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_WEEK,
CALENDAR_RECURRENCE_DAILY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t += 5;
now_t += 60; /* add 1 min */
now_t -= (60 * 60 * 24 * 7); /* 1 week before */
- ret = _reminder_utime((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_MINUTE,
+ ret = _add_reminder_utime_in_event((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_MINUTE,
CALENDAR_RECURRENCE_WEEKLY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t += 5;
now_t += (60 * 60); /* add 1 hour */
now_t -= (60 * 60 * 24 * 7); /* 1 week before */
- ret = _reminder_utime((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_HOUR,
+ ret = _add_reminder_utime_in_event((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_HOUR,
CALENDAR_RECURRENCE_WEEKLY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t += 5;
now_t += (60 * 60 * 24); /* add 1 day */
now_t -= (60 * 60 * 24 * 7); /* 1 week before */
- ret = _reminder_utime((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_DAY,
+ ret = _add_reminder_utime_in_event((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_DAY,
CALENDAR_RECURRENCE_WEEKLY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t += 5;
now_t += (60 * 60 * 24 * 7); /* add 1 week */
now_t -= (60 * 60 * 24 * 7); /* 1 week before */
- ret = _reminder_utime((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_WEEK,
+ ret = _add_reminder_utime_in_event((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_WEEK,
CALENDAR_RECURRENCE_WEEKLY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_s.tm_mon--;
}
now_t = (int64_t)mktime(&now_s);
- ret = _reminder_utime((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_MINUTE,
+ ret = _add_reminder_utime_in_event((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_MINUTE,
CALENDAR_RECURRENCE_MONTHLY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_s.tm_mon--;
}
now_t = (int64_t)mktime(&now_s);
- ret = _reminder_utime((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_HOUR,
+ ret = _add_reminder_utime_in_event((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_HOUR,
CALENDAR_RECURRENCE_MONTHLY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_s.tm_mon--;
}
now_t = (int64_t)mktime(&now_s);
- ret = _reminder_utime((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_DAY,
+ ret = _add_reminder_utime_in_event((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_DAY,
CALENDAR_RECURRENCE_MONTHLY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_s.tm_mon--;
}
now_t = (int64_t)mktime(&now_s);
- ret = _reminder_utime((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_WEEK,
+ ret = _add_reminder_utime_in_event((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_WEEK,
CALENDAR_RECURRENCE_MONTHLY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
localtime_r(&now_t, &now_s);
now_s.tm_year--;
now_t = (int64_t)mktime(&now_s);
- ret = _reminder_utime((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_MINUTE,
+ ret = _add_reminder_utime_in_event((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_MINUTE,
CALENDAR_RECURRENCE_YEARLY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
localtime_r(&now_t, &now_s);
now_s.tm_year--;
now_t = (int64_t)mktime(&now_s);
- ret = _reminder_utime((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_HOUR,
+ ret = _add_reminder_utime_in_event((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_HOUR,
CALENDAR_RECURRENCE_YEARLY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
localtime_r(&now_t, &now_s);
now_s.tm_year--;
now_t = (int64_t)mktime(&now_s);
- ret = _reminder_utime((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_DAY,
+ ret = _add_reminder_utime_in_event((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_DAY,
CALENDAR_RECURRENCE_YEARLY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
localtime_r(&now_t, &now_s);
now_s.tm_year--;
now_t = (int64_t)mktime(&now_s);
- ret = _reminder_utime((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_WEEK,
+ ret = _add_reminder_utime_in_event((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_WEEK,
CALENDAR_RECURRENCE_YEARLY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t = time(NULL);
now_t += 5; /* add 5 secs */
- ret = _reminder_utime((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_SPECIFIC,
+ ret = _add_reminder_utime_in_event((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_SPECIFIC,
CALENDAR_RECURRENCE_NONE, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t += 5;
now_t += 60; /* add 1 hour */
localtime_r(&now_t, &now_s);
- ret = _reminder_localtime(&now_s, CALENDAR_ALARM_TIME_UNIT_MINUTE,
+ ret = _add_reminder_localtime_in_event(&now_s, CALENDAR_ALARM_TIME_UNIT_MINUTE,
CALENDAR_RECURRENCE_NONE, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t += 5;
now_t += (60 * 60); /* add 1 hour */
localtime_r(&now_t, &now_s);
- ret = _reminder_localtime(&now_s, CALENDAR_ALARM_TIME_UNIT_HOUR,
+ ret = _add_reminder_localtime_in_event(&now_s, CALENDAR_ALARM_TIME_UNIT_HOUR,
CALENDAR_RECURRENCE_NONE, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t += 5;
now_t += (60 * 60 * 24); /* add 1 day */
localtime_r(&now_t, &now_s);
- ret = _reminder_localtime(&now_s, CALENDAR_ALARM_TIME_UNIT_DAY,
+ ret = _add_reminder_localtime_in_event(&now_s, CALENDAR_ALARM_TIME_UNIT_DAY,
CALENDAR_RECURRENCE_NONE, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t += 5;
now_t += (60 * 60 * 24 * 7); /* add 1 week */
localtime_r(&now_t, &now_s);
- ret = _reminder_localtime(&now_s, CALENDAR_ALARM_TIME_UNIT_WEEK,
+ ret = _add_reminder_localtime_in_event(&now_s, CALENDAR_ALARM_TIME_UNIT_WEEK,
CALENDAR_RECURRENCE_NONE, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t += 60; /* add 1 min */
now_t -= (60 * 60 * 24); /* 1 day before */
localtime_r(&now_t, &now_s);
- ret = _reminder_localtime(&now_s, CALENDAR_ALARM_TIME_UNIT_MINUTE,
+ ret = _add_reminder_localtime_in_event(&now_s, CALENDAR_ALARM_TIME_UNIT_MINUTE,
CALENDAR_RECURRENCE_DAILY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t += (60 * 60); /* add 1 hour */
now_t -= (60 * 60 * 24); /* 1 day before */
localtime_r(&now_t, &now_s);
- ret = _reminder_localtime(&now_s, CALENDAR_ALARM_TIME_UNIT_HOUR,
+ ret = _add_reminder_localtime_in_event(&now_s, CALENDAR_ALARM_TIME_UNIT_HOUR,
CALENDAR_RECURRENCE_DAILY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t += (60 * 60 * 24); /* add 1 day */
now_t -= (60 * 60 * 24); /* 1 day before */
localtime_r(&now_t, &now_s);
- ret = _reminder_localtime(&now_s, CALENDAR_ALARM_TIME_UNIT_DAY,
+ ret = _add_reminder_localtime_in_event(&now_s, CALENDAR_ALARM_TIME_UNIT_DAY,
CALENDAR_RECURRENCE_DAILY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t += (60 * 60 * 24 * 7); /* add 1 week */
now_t -= (60 * 60 * 24); /* 1 day before */
localtime_r(&now_t, &now_s);
- ret = _reminder_localtime(&now_s, CALENDAR_ALARM_TIME_UNIT_WEEK,
+ ret = _add_reminder_localtime_in_event(&now_s, CALENDAR_ALARM_TIME_UNIT_WEEK,
CALENDAR_RECURRENCE_DAILY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t += 60; /* add 1 min */
now_t -= (60 * 60 * 24 * 7); /* 1 week before */
localtime_r(&now_t, &now_s);
- ret = _reminder_localtime(&now_s, CALENDAR_ALARM_TIME_UNIT_MINUTE,
+ ret = _add_reminder_localtime_in_event(&now_s, CALENDAR_ALARM_TIME_UNIT_MINUTE,
CALENDAR_RECURRENCE_WEEKLY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t += (60 * 60); /* add 1 hour */
now_t -= (60 * 60 * 24 * 7); /* 1 week before */
localtime_r(&now_t, &now_s);
- ret = _reminder_localtime(&now_s, CALENDAR_ALARM_TIME_UNIT_HOUR,
+ ret = _add_reminder_localtime_in_event(&now_s, CALENDAR_ALARM_TIME_UNIT_HOUR,
CALENDAR_RECURRENCE_WEEKLY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t += (60 * 60 * 24); /* add 1 day */
now_t -= (60 * 60 * 24 * 7); /* 1 week before */
localtime_r(&now_t, &now_s);
- ret = _reminder_localtime(&now_s, CALENDAR_ALARM_TIME_UNIT_DAY,
+ ret = _add_reminder_localtime_in_event(&now_s, CALENDAR_ALARM_TIME_UNIT_DAY,
CALENDAR_RECURRENCE_WEEKLY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t += (60 * 60 * 24 * 7); /* add 1 week */
now_t -= (60 * 60 * 24 * 7); /* 1 week before */
localtime_r(&now_t, &now_s);
- ret = _reminder_localtime(&now_s, CALENDAR_ALARM_TIME_UNIT_WEEK,
+ ret = _add_reminder_localtime_in_event(&now_s, CALENDAR_ALARM_TIME_UNIT_WEEK,
CALENDAR_RECURRENCE_WEEKLY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
} else {
now_s.tm_mon--;
}
- ret = _reminder_localtime(&now_s, CALENDAR_ALARM_TIME_UNIT_MINUTE,
+ ret = _add_reminder_localtime_in_event(&now_s, CALENDAR_ALARM_TIME_UNIT_MINUTE,
CALENDAR_RECURRENCE_MONTHLY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
} else {
now_s.tm_mon--;
}
- ret = _reminder_localtime(&now_s, CALENDAR_ALARM_TIME_UNIT_HOUR,
+ ret = _add_reminder_localtime_in_event(&now_s, CALENDAR_ALARM_TIME_UNIT_HOUR,
CALENDAR_RECURRENCE_MONTHLY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
} else {
now_s.tm_mon--;
}
- ret = _reminder_localtime(&now_s, CALENDAR_ALARM_TIME_UNIT_DAY,
+ ret = _add_reminder_localtime_in_event(&now_s, CALENDAR_ALARM_TIME_UNIT_DAY,
CALENDAR_RECURRENCE_MONTHLY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
} else {
now_s.tm_mon--;
}
- ret = _reminder_localtime(&now_s, CALENDAR_ALARM_TIME_UNIT_WEEK,
+ ret = _add_reminder_localtime_in_event(&now_s, CALENDAR_ALARM_TIME_UNIT_WEEK,
CALENDAR_RECURRENCE_MONTHLY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t += 60; /* add 1 min */
localtime_r(&now_t, &now_s);
now_s.tm_year--;
- ret = _reminder_localtime(&now_s, CALENDAR_ALARM_TIME_UNIT_MINUTE,
+ ret = _add_reminder_localtime_in_event(&now_s, CALENDAR_ALARM_TIME_UNIT_MINUTE,
CALENDAR_RECURRENCE_YEARLY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t += (60 * 60); /* add 1 hour */
localtime_r(&now_t, &now_s);
now_s.tm_year--;
- ret = _reminder_localtime(&now_s, CALENDAR_ALARM_TIME_UNIT_HOUR,
+ ret = _add_reminder_localtime_in_event(&now_s, CALENDAR_ALARM_TIME_UNIT_HOUR,
CALENDAR_RECURRENCE_YEARLY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t += (60 * 60 * 24); /* add 1 day */
localtime_r(&now_t, &now_s);
now_s.tm_year--;
- ret = _reminder_localtime(&now_s, CALENDAR_ALARM_TIME_UNIT_DAY,
+ ret = _add_reminder_localtime_in_event(&now_s, CALENDAR_ALARM_TIME_UNIT_DAY,
CALENDAR_RECURRENCE_YEARLY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t += (60 * 60 * 24 * 7); /* add 1 week */
localtime_r(&now_t, &now_s);
now_s.tm_year--;
- ret = _reminder_localtime(&now_s, CALENDAR_ALARM_TIME_UNIT_WEEK,
+ ret = _add_reminder_localtime_in_event(&now_s, CALENDAR_ALARM_TIME_UNIT_WEEK,
CALENDAR_RECURRENCE_YEARLY, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
now_t = time(NULL);
now_t += 5; /* add 5 secs */
localtime_r(&now_t, &now_s);
- ret = _reminder_localtime(&now_s, CALENDAR_ALARM_TIME_UNIT_SPECIFIC,
+ ret = _add_reminder_localtime_in_event(&now_s, CALENDAR_ALARM_TIME_UNIT_SPECIFIC,
CALENDAR_RECURRENCE_NONE, &event_id);
assert_eq(ret, CALENDAR_ERROR_NONE);
ret = _delete_event(event_id);
}
/**
+ * @testcase utc_calendar_reminder_add_cb_todo_utime_once_p
+ * @since_tizen 3.0
+ * @description Test adding a callback to get a notification when an todo alarm alerts.
+ */
+int utc_calendar_reminder_add_cb_todo_utime_once_p(void)
+{
+ DBG("[%s]", __func__);
+
+ assert_eq(g_startup_err, CALENDAR_ERROR_NONE);
+ int ret = 0;
+ int todo_id = 0;
+ time_t now_t = 0;
+
+ now_t = time(NULL);
+ now_t += 5;
+ now_t += 60; /* add 1 min */
+ ret = _add_reminder_utime_in_todo((int64_t)now_t, CALENDAR_ALARM_TIME_UNIT_MINUTE,
+ CALENDAR_RECURRENCE_NONE, &todo_id);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+ ret = _delete_todo(todo_id);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+
+ return 0;
+}
+
+/**
+ * @testcase utc_calendar_reminder_add_cb_todo_localtime_once_p
+ * @since_tizen 3.0
+ * @description Test adding a callback to get a notification when an once todo alarm alerts.
+ */
+int utc_calendar_reminder_add_cb_todo_localtime_once_p(void)
+{
+ DBG("[%s]", __func__);
+
+ assert_eq(g_startup_err, CALENDAR_ERROR_NONE);
+ int ret = 0;
+ int todo_id = 0;
+ time_t now_t = 0;
+ struct tm now_s = {0};
+
+ now_t = time(NULL);
+ now_t += 5;
+ now_t += 60; /* add 1 hour */
+ localtime_r(&now_t, &now_s);
+ ret = _add_reminder_localtime_in_todo(&now_s, CALENDAR_ALARM_TIME_UNIT_MINUTE,
+ CALENDAR_RECURRENCE_NONE, &todo_id);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+ ret = _delete_todo(todo_id);
+ assert_eq(ret, CALENDAR_ERROR_NONE);
+
+ return 0;
+}
+
+/**
* @testcase utc_calendar_reminder_add_cb_n
* @since_tizen 2.3
* @description Test fail adding a callback to get an alarm notification with invalid parameters.