int utc_context_trigger_rule_entry_add_comparison_int_p(void)
{
int error = CONTEXT_TRIGGER_ERROR_NONE;
- context_trigger_rule_entry_h event1 = NULL;
- context_trigger_rule_entry_h event2 = NULL;
- context_trigger_rule_entry_h event3 = NULL;
- context_trigger_rule_entry_h event4 = NULL;
- context_trigger_rule_entry_h condition1 = NULL;
- context_trigger_rule_entry_h condition2 = NULL;
- context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_TIME, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event1);
- context_trigger_rule_entry_add_key(event1, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_TIME_OF_DAY);
- context_trigger_rule_condition_create(CONTEXT_TRIGGER_CONDITION_TIME, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &condition1);
- context_trigger_rule_entry_add_key(condition1, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_TIME_OF_DAY);
- context_trigger_rule_entry_add_key(condition1, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_DAY_OF_MONTH);
- context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_CHARGER, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event2);
- context_trigger_rule_entry_add_key(event2, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_IS_CONNECTED);
- context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_BATTERY, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event3);
- context_trigger_rule_entry_add_key(event3, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_IS_CHARGING);
- context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_POWER_SAVING_MODE, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event4);
- context_trigger_rule_entry_add_key(event4, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_IS_ENABLED);
- context_trigger_rule_condition_create(CONTEXT_TRIGGER_CONDITION_APP_USE_FREQUENCY, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &condition2);
- context_trigger_rule_entry_add_key(condition2, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_RANK);
- context_trigger_rule_entry_add_key(condition2, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_TOTAL_COUNT);
+ bool etime_supported = false;
+ bool ctime_supported = false;
+ bool chgr_supported = false;
+ bool btr_supported = false;
+ bool psm_supported = false;
+ bool app_supported = false;
- error = context_trigger_rule_entry_add_comparison_int(event1, CONTEXT_TRIGGER_TIME_OF_DAY, CONTEXT_TRIGGER_EQUAL_TO, 16 * 60);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);
+ context_trigger_rule_event_is_supported(CONTEXT_TRIGGER_EVENT_TIME, &etime_supported);
+ context_trigger_rule_condition_is_supported(CONTEXT_TRIGGER_CONDITION_TIME, &ctime_supported);
+ context_trigger_rule_event_is_supported(CONTEXT_TRIGGER_EVENT_CHARGER, &chgr_supported);
+ context_trigger_rule_event_is_supported(CONTEXT_TRIGGER_EVENT_BATTERY, &btr_supported);
+ context_trigger_rule_event_is_supported(CONTEXT_TRIGGER_EVENT_POWER_SAVING_MODE, &psm_supported);
+ context_trigger_rule_condition_is_supported(CONTEXT_TRIGGER_CONDITION_APP_USE_FREQUENCY, &app_supported);
- error = context_trigger_rule_entry_add_comparison_int(condition1, CONTEXT_TRIGGER_TIME_OF_DAY, CONTEXT_TRIGGER_EQUAL_TO, 1000);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);
+ if (etime_supported) {
+ context_trigger_rule_entry_h event1 = NULL;
+ context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_TIME, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event1);
+ context_trigger_rule_entry_add_key(event1, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_TIME_OF_DAY);
- error = context_trigger_rule_entry_add_comparison_int(condition1, CONTEXT_TRIGGER_DAY_OF_MONTH, CONTEXT_TRIGGER_EQUAL_TO, 20);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);
+ error = context_trigger_rule_entry_add_comparison_int(event1, CONTEXT_TRIGGER_TIME_OF_DAY, CONTEXT_TRIGGER_EQUAL_TO, 16 * 60);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);
- error = context_trigger_rule_entry_add_comparison_int(event2, CONTEXT_TRIGGER_IS_CONNECTED, CONTEXT_TRIGGER_EQUAL_TO, CONTEXT_TRIGGER_TRUE);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);
+ context_trigger_rule_entry_destroy(event1);
+ } else {
+ PRINT_INFO("Not supported. Skip Test(1/6)");
+ }
- error = context_trigger_rule_entry_add_comparison_int(event3, CONTEXT_TRIGGER_IS_CHARGING, CONTEXT_TRIGGER_EQUAL_TO, CONTEXT_TRIGGER_TRUE);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);
+ if (ctime_supported) {
+ context_trigger_rule_entry_h condition1 = NULL;
+ context_trigger_rule_condition_create(CONTEXT_TRIGGER_CONDITION_TIME, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &condition1);
+ context_trigger_rule_entry_add_key(condition1, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_TIME_OF_DAY);
+ context_trigger_rule_entry_add_key(condition1, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_DAY_OF_MONTH);
- error = context_trigger_rule_entry_add_comparison_int(event4, CONTEXT_TRIGGER_IS_ENABLED, CONTEXT_TRIGGER_EQUAL_TO, CONTEXT_TRIGGER_TRUE);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);
+ error = context_trigger_rule_entry_add_comparison_int(condition1, CONTEXT_TRIGGER_TIME_OF_DAY, CONTEXT_TRIGGER_EQUAL_TO, 1000);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);
- error = context_trigger_rule_entry_add_comparison_int(condition2, CONTEXT_TRIGGER_RANK, CONTEXT_TRIGGER_EQUAL_TO, 1);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);
+ error = context_trigger_rule_entry_add_comparison_int(condition1, CONTEXT_TRIGGER_DAY_OF_MONTH, CONTEXT_TRIGGER_EQUAL_TO, 20);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);
- error = context_trigger_rule_entry_add_comparison_int(condition2, CONTEXT_TRIGGER_TOTAL_COUNT, CONTEXT_TRIGGER_EQUAL_TO, 10);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);
+ context_trigger_rule_entry_destroy(condition1);
+ } else {
+ PRINT_INFO("Not supported. Skip Test(2/6)");
+ }
- context_trigger_rule_entry_destroy(event1);
- context_trigger_rule_entry_destroy(event2);
- context_trigger_rule_entry_destroy(event3);
- context_trigger_rule_entry_destroy(event4);
- context_trigger_rule_entry_destroy(condition1);
- context_trigger_rule_entry_destroy(condition2);
+ if (chgr_supported) {
+ context_trigger_rule_entry_h event2 = NULL;
+ context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_CHARGER, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event2);
+ context_trigger_rule_entry_add_key(event2, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_IS_CONNECTED);
+
+ error = context_trigger_rule_entry_add_comparison_int(event2, CONTEXT_TRIGGER_IS_CONNECTED, CONTEXT_TRIGGER_EQUAL_TO, CONTEXT_TRIGGER_TRUE);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);
+
+ context_trigger_rule_entry_destroy(event2);
+ } else {
+ PRINT_INFO("Not supported. Skip Test(3/6)");
+ }
+
+ if (btr_supported) {
+ context_trigger_rule_entry_h event3 = NULL;
+ context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_BATTERY, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event3);
+ context_trigger_rule_entry_add_key(event3, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_IS_CHARGING);
+
+ error = context_trigger_rule_entry_add_comparison_int(event3, CONTEXT_TRIGGER_IS_CHARGING, CONTEXT_TRIGGER_EQUAL_TO, CONTEXT_TRIGGER_TRUE);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);
+
+ context_trigger_rule_entry_destroy(event3);
+ } else {
+ PRINT_INFO("Not supported. Skip Test(4/6)");
+ }
+
+ if (psm_supported) {
+ context_trigger_rule_entry_h event4 = NULL;
+ context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_POWER_SAVING_MODE, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event4);
+ context_trigger_rule_entry_add_key(event4, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_IS_ENABLED);
+
+ error = context_trigger_rule_entry_add_comparison_int(event4, CONTEXT_TRIGGER_IS_ENABLED, CONTEXT_TRIGGER_EQUAL_TO, CONTEXT_TRIGGER_TRUE);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);
+
+ context_trigger_rule_entry_destroy(event4);
+ } else {
+
+ PRINT_INFO("Not supported. Skip Test(5/6)");
+ }
+
+ if (app_supported) {
+ context_trigger_rule_entry_h condition2 = NULL;
+ context_trigger_rule_condition_create(CONTEXT_TRIGGER_CONDITION_APP_USE_FREQUENCY, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &condition2);
+ context_trigger_rule_entry_add_key(condition2, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_RANK);
+ context_trigger_rule_entry_add_key(condition2, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_TOTAL_COUNT);
+
+ error = context_trigger_rule_entry_add_comparison_int(condition2, CONTEXT_TRIGGER_RANK, CONTEXT_TRIGGER_EQUAL_TO, 1);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);
+
+ error = context_trigger_rule_entry_add_comparison_int(condition2, CONTEXT_TRIGGER_TOTAL_COUNT, CONTEXT_TRIGGER_EQUAL_TO, 10);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);
+
+ context_trigger_rule_entry_destroy(condition2);
+ } else {
+ PRINT_INFO("Not supported. Skip Test(6/6)");
+ }
return 0;
}
int utc_context_trigger_rule_entry_add_comparison_int_n(void)
{
int error = CONTEXT_TRIGGER_ERROR_NONE;
- context_trigger_rule_entry_h event = NULL;
- context_trigger_rule_entry_h event1 = NULL;
- context_trigger_rule_entry_h event2 = NULL;
- context_trigger_rule_entry_h event3 = NULL;
- context_trigger_rule_entry_h event4 = NULL;
- context_trigger_rule_entry_h condition1 = NULL;
- context_trigger_rule_entry_h condition2 = NULL;
+ bool etime_supported = false;
+ bool ctime_supported = false;
+ bool chgr_supported = false;
+ bool btr_supported= false;
+ bool psm_supported = false;
+ bool app_supported = false;
- context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_TIME, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event);
+ context_trigger_rule_event_is_supported(CONTEXT_TRIGGER_EVENT_TIME, &etime_supported);
+ context_trigger_rule_condition_is_supported(CONTEXT_TRIGGER_CONDITION_TIME, &ctime_supported);
+ context_trigger_rule_event_is_supported(CONTEXT_TRIGGER_EVENT_CHARGER, &chgr_supported);
+ context_trigger_rule_event_is_supported(CONTEXT_TRIGGER_EVENT_BATTERY, &chgr_supported);
+ context_trigger_rule_event_is_supported(CONTEXT_TRIGGER_EVENT_POWER_SAVING_MODE, &chgr_supported);
+ context_trigger_rule_condition_is_supported(CONTEXT_TRIGGER_CONDITION_APP_USE_FREQUENCY, &app_supported);
- // Err: Key not added
- error = context_trigger_rule_entry_add_comparison_int(event, CONTEXT_TRIGGER_TIME_OF_DAY, CONTEXT_TRIGGER_EQUAL_TO, 16 * 60);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_NO_DATA);
+ if (etime_supported) {
+ context_trigger_rule_entry_h event = NULL;
- context_trigger_rule_entry_add_key(event, CONTEXT_TRIGGER_LOGICAL_DISJUNCTION, CONTEXT_TRIGGER_TIME_OF_DAY);
+ context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_TIME, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event);
- // Err: Invalid parameter
- error = context_trigger_rule_entry_add_comparison_int(NULL, CONTEXT_TRIGGER_TIME_OF_DAY, CONTEXT_TRIGGER_EQUAL_TO, 16);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER);
+ // Err: Key not added
+ error = context_trigger_rule_entry_add_comparison_int(event, CONTEXT_TRIGGER_TIME_OF_DAY, CONTEXT_TRIGGER_EQUAL_TO, 16 * 60);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_NO_DATA);
- error = context_trigger_rule_entry_add_comparison_int(event, NULL, CONTEXT_TRIGGER_EQUAL_TO, 16);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER);
+ context_trigger_rule_entry_add_key(event, CONTEXT_TRIGGER_LOGICAL_DISJUNCTION, CONTEXT_TRIGGER_TIME_OF_DAY);
- error = context_trigger_rule_entry_add_comparison_int(event, CONTEXT_TRIGGER_TIME_OF_DAY, NULL, 16);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER);
+ // Err: Invalid parameter
+ error = context_trigger_rule_entry_add_comparison_int(NULL, CONTEXT_TRIGGER_TIME_OF_DAY, CONTEXT_TRIGGER_EQUAL_TO, 16);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER);
- // Err: Invalid operator
- error = context_trigger_rule_entry_add_comparison_int(event, CONTEXT_TRIGGER_TIME_OF_DAY, INVALID_OPERATOR, 16);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+ error = context_trigger_rule_entry_add_comparison_int(event, NULL, CONTEXT_TRIGGER_EQUAL_TO, 16);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER);
- // Err: Duplicated operator & value
- error = context_trigger_rule_entry_add_comparison_int(event, CONTEXT_TRIGGER_TIME_OF_DAY, CONTEXT_TRIGGER_EQUAL_TO, 16);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);
- error = context_trigger_rule_entry_add_comparison_int(event, CONTEXT_TRIGGER_TIME_OF_DAY, CONTEXT_TRIGGER_EQUAL_TO, 16);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+ error = context_trigger_rule_entry_add_comparison_int(event, CONTEXT_TRIGGER_TIME_OF_DAY, NULL, 16);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER);
- // Err: Invalid comparison value type
- context_trigger_rule_entry_add_key(event, CONTEXT_TRIGGER_LOGICAL_DISJUNCTION, CONTEXT_TRIGGER_DAY_OF_WEEK);
- error = context_trigger_rule_entry_add_comparison_int(event, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_EQUAL_TO, 16);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+ // Err: Invalid operator
+ error = context_trigger_rule_entry_add_comparison_int(event, CONTEXT_TRIGGER_TIME_OF_DAY, INVALID_OPERATOR, 16);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+
+ // Err: Duplicated operator & value
+ error = context_trigger_rule_entry_add_comparison_int(event, CONTEXT_TRIGGER_TIME_OF_DAY, CONTEXT_TRIGGER_EQUAL_TO, 16);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);
+ error = context_trigger_rule_entry_add_comparison_int(event, CONTEXT_TRIGGER_TIME_OF_DAY, CONTEXT_TRIGGER_EQUAL_TO, 16);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+
+ // Err: Invalid comparison value type
+ context_trigger_rule_entry_add_key(event, CONTEXT_TRIGGER_LOGICAL_DISJUNCTION, CONTEXT_TRIGGER_DAY_OF_WEEK);
+ error = context_trigger_rule_entry_add_comparison_int(event, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_EQUAL_TO, 16);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+
+ context_trigger_rule_entry_destroy(event);
+ } else {
+ PRINT_INFO("Not supported item. Skip test(1/7)");
+ }
// Err: Invalid comparison value
- context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_TIME, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event1);
- context_trigger_rule_entry_add_key(event1, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_TIME_OF_DAY);
- context_trigger_rule_condition_create(CONTEXT_TRIGGER_CONDITION_TIME, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &condition1);
- context_trigger_rule_entry_add_key(condition1, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_TIME_OF_DAY);
- context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_CHARGER, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event2);
- context_trigger_rule_entry_add_key(event2, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_IS_CONNECTED);
- context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_BATTERY, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event3);
- context_trigger_rule_entry_add_key(event3, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_IS_CHARGING);
- context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_POWER_SAVING_MODE, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event4);
- context_trigger_rule_entry_add_key(event4, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_IS_ENABLED);
- context_trigger_rule_condition_create(CONTEXT_TRIGGER_CONDITION_APP_USE_FREQUENCY, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &condition2);
- context_trigger_rule_entry_add_key(condition2, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_RANK);
- context_trigger_rule_entry_add_key(condition2, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_TOTAL_COUNT);
-
- error = context_trigger_rule_entry_add_comparison_int(event1, CONTEXT_TRIGGER_TIME_OF_DAY, CONTEXT_TRIGGER_EQUAL_TO, -1);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+ if (etime_supported) {
+ context_trigger_rule_entry_h event1 = NULL;
- error = context_trigger_rule_entry_add_comparison_int(event1, CONTEXT_TRIGGER_TIME_OF_DAY, CONTEXT_TRIGGER_EQUAL_TO, 1440);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+ context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_TIME, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event1);
+ context_trigger_rule_entry_add_key(event1, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_TIME_OF_DAY);
- error = context_trigger_rule_entry_add_comparison_int(condition1, CONTEXT_TRIGGER_TIME_OF_DAY, CONTEXT_TRIGGER_EQUAL_TO, -1);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+ error = context_trigger_rule_entry_add_comparison_int(event1, CONTEXT_TRIGGER_TIME_OF_DAY, CONTEXT_TRIGGER_EQUAL_TO, -1);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
- error = context_trigger_rule_entry_add_comparison_int(condition1, CONTEXT_TRIGGER_TIME_OF_DAY, CONTEXT_TRIGGER_EQUAL_TO, 1440);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+ error = context_trigger_rule_entry_add_comparison_int(event1, CONTEXT_TRIGGER_TIME_OF_DAY, CONTEXT_TRIGGER_EQUAL_TO, 1440);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
- error = context_trigger_rule_entry_add_comparison_int(condition1, CONTEXT_TRIGGER_DAY_OF_MONTH, CONTEXT_TRIGGER_EQUAL_TO, -1);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+ context_trigger_rule_entry_destroy(event1);
+ } else {
+ PRINT_INFO("Not supported item. Skip test(2/7)");
+ }
- error = context_trigger_rule_entry_add_comparison_int(condition1, CONTEXT_TRIGGER_DAY_OF_MONTH, CONTEXT_TRIGGER_EQUAL_TO, 32);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+ if (ctime_supported) {
+ context_trigger_rule_entry_h condition1 = NULL;
- error = context_trigger_rule_entry_add_comparison_int(event2, CONTEXT_TRIGGER_IS_CONNECTED, CONTEXT_TRIGGER_EQUAL_TO, -1);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+ context_trigger_rule_condition_create(CONTEXT_TRIGGER_CONDITION_TIME, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &condition1);
+ context_trigger_rule_entry_add_key(condition1, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_TIME_OF_DAY);
- error = context_trigger_rule_entry_add_comparison_int(event2, CONTEXT_TRIGGER_IS_CONNECTED, CONTEXT_TRIGGER_EQUAL_TO, 2);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+ error = context_trigger_rule_entry_add_comparison_int(condition1, CONTEXT_TRIGGER_TIME_OF_DAY, CONTEXT_TRIGGER_EQUAL_TO, -1);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
- error = context_trigger_rule_entry_add_comparison_int(event3, CONTEXT_TRIGGER_IS_CHARGING, CONTEXT_TRIGGER_EQUAL_TO, -1);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+ error = context_trigger_rule_entry_add_comparison_int(condition1, CONTEXT_TRIGGER_TIME_OF_DAY, CONTEXT_TRIGGER_EQUAL_TO, 1440);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
- error = context_trigger_rule_entry_add_comparison_int(event3, CONTEXT_TRIGGER_IS_CHARGING, CONTEXT_TRIGGER_EQUAL_TO, 2);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+ error = context_trigger_rule_entry_add_comparison_int(condition1, CONTEXT_TRIGGER_DAY_OF_MONTH, CONTEXT_TRIGGER_EQUAL_TO, -1);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
- error = context_trigger_rule_entry_add_comparison_int(event4, CONTEXT_TRIGGER_IS_ENABLED, CONTEXT_TRIGGER_EQUAL_TO, -1);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+ error = context_trigger_rule_entry_add_comparison_int(condition1, CONTEXT_TRIGGER_DAY_OF_MONTH, CONTEXT_TRIGGER_EQUAL_TO, 32);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
- error = context_trigger_rule_entry_add_comparison_int(event4, CONTEXT_TRIGGER_IS_ENABLED, CONTEXT_TRIGGER_EQUAL_TO, 2);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+ context_trigger_rule_entry_destroy(condition1);
+ } else {
+ PRINT_INFO("Not supported item. Skip test(3/7)");
+ }
- error = context_trigger_rule_entry_add_comparison_int(condition2, CONTEXT_TRIGGER_RANK, CONTEXT_TRIGGER_EQUAL_TO, -1);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+ if (chgr_supported) {
+ context_trigger_rule_entry_h event2 = NULL;
- error = context_trigger_rule_entry_add_comparison_int(condition2, CONTEXT_TRIGGER_TOTAL_COUNT, CONTEXT_TRIGGER_EQUAL_TO, -1);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+ context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_CHARGER, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event2);
+ context_trigger_rule_entry_add_key(event2, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_IS_CONNECTED);
- context_trigger_rule_entry_destroy(event);
- context_trigger_rule_entry_destroy(event1);
- context_trigger_rule_entry_destroy(event2);
- context_trigger_rule_entry_destroy(event3);
- context_trigger_rule_entry_destroy(event4);
- context_trigger_rule_entry_destroy(condition1);
- context_trigger_rule_entry_destroy(condition2);
+ error = context_trigger_rule_entry_add_comparison_int(event2, CONTEXT_TRIGGER_IS_CONNECTED, CONTEXT_TRIGGER_EQUAL_TO, -1);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+
+ error = context_trigger_rule_entry_add_comparison_int(event2, CONTEXT_TRIGGER_IS_CONNECTED, CONTEXT_TRIGGER_EQUAL_TO, 2);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+
+ context_trigger_rule_entry_destroy(event2);
+ } else {
+ PRINT_INFO("Not supported item. Skip test(4/7)");
+ }
+
+ if (btr_supported) {
+ context_trigger_rule_entry_h event3 = NULL;
+
+ context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_BATTERY, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event3);
+ context_trigger_rule_entry_add_key(event3, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_IS_CHARGING);
+
+ error = context_trigger_rule_entry_add_comparison_int(event3, CONTEXT_TRIGGER_IS_CHARGING, CONTEXT_TRIGGER_EQUAL_TO, -1);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+
+ error = context_trigger_rule_entry_add_comparison_int(event3, CONTEXT_TRIGGER_IS_CHARGING, CONTEXT_TRIGGER_EQUAL_TO, 2);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+
+ context_trigger_rule_entry_destroy(event3);
+ } else {
+ PRINT_INFO("Not supported item. Skip test(5/7)");
+ }
+
+ if (psm_supported) {
+ context_trigger_rule_entry_h event4 = NULL;
+
+ context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_POWER_SAVING_MODE, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event4);
+ context_trigger_rule_entry_add_key(event4, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_IS_ENABLED);
+
+ error = context_trigger_rule_entry_add_comparison_int(event4, CONTEXT_TRIGGER_IS_ENABLED, CONTEXT_TRIGGER_EQUAL_TO, -1);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+
+ error = context_trigger_rule_entry_add_comparison_int(event4, CONTEXT_TRIGGER_IS_ENABLED, CONTEXT_TRIGGER_EQUAL_TO, 2);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+
+ context_trigger_rule_entry_destroy(event4);
+ } else {
+ PRINT_INFO("Not supported item. Skip test(6/7)");
+ }
+
+ if (app_supported) {
+ context_trigger_rule_entry_h condition2 = NULL;
+
+ context_trigger_rule_condition_create(CONTEXT_TRIGGER_CONDITION_APP_USE_FREQUENCY, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &condition2);
+ context_trigger_rule_entry_add_key(condition2, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_RANK);
+ context_trigger_rule_entry_add_key(condition2, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_TOTAL_COUNT);
+
+ error = context_trigger_rule_entry_add_comparison_int(condition2, CONTEXT_TRIGGER_RANK, CONTEXT_TRIGGER_EQUAL_TO, -1);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+
+ error = context_trigger_rule_entry_add_comparison_int(condition2, CONTEXT_TRIGGER_TOTAL_COUNT, CONTEXT_TRIGGER_EQUAL_TO, -1);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+
+ context_trigger_rule_entry_destroy(condition2);
+ } else {
+ PRINT_INFO("Not supported item. Skip test(7/7)");
+ }
return 0;
}
context_trigger_rule_entry_h event6 = NULL;
context_trigger_rule_entry_h event7 = NULL;
- // Err: Key not added
- context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_TIME, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event);
- error = context_trigger_rule_entry_add_comparison_string(event, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_EQUAL_TO, CONTEXT_TRIGGER_WEEKEND);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_NO_DATA);
+ error = context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_TIME, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event);
+ if (error != CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED) {
+ // Err: Key not added
+ error = context_trigger_rule_entry_add_comparison_string(event, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_EQUAL_TO, CONTEXT_TRIGGER_WEEKEND);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_NO_DATA);
- context_trigger_rule_entry_add_key(event, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_DAY_OF_WEEK);
+ context_trigger_rule_entry_add_key(event, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_DAY_OF_WEEK);
- // Err: Invalid parameter
- error = context_trigger_rule_entry_add_comparison_string(NULL, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_EQUAL_TO, CONTEXT_TRIGGER_WEEKEND);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER);
+ // Err: Invalid parameter
+ error = context_trigger_rule_entry_add_comparison_string(NULL, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_EQUAL_TO, CONTEXT_TRIGGER_WEEKEND);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER);
- error = context_trigger_rule_entry_add_comparison_string(event, NULL, CONTEXT_TRIGGER_EQUAL_TO, CONTEXT_TRIGGER_WEEKEND);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER);
+ error = context_trigger_rule_entry_add_comparison_string(event, NULL, CONTEXT_TRIGGER_EQUAL_TO, CONTEXT_TRIGGER_WEEKEND);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER);
- error = context_trigger_rule_entry_add_comparison_string(event, CONTEXT_TRIGGER_DAY_OF_WEEK, NULL, CONTEXT_TRIGGER_WEEKEND);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER);
+ error = context_trigger_rule_entry_add_comparison_string(event, CONTEXT_TRIGGER_DAY_OF_WEEK, NULL, CONTEXT_TRIGGER_WEEKEND);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER);
- error = context_trigger_rule_entry_add_comparison_string(event, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_EQUAL_TO, NULL);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER);
+ error = context_trigger_rule_entry_add_comparison_string(event, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_EQUAL_TO, NULL);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER);
- // Err: Invalid operator
- error = context_trigger_rule_entry_add_comparison_string(event, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_LESS_THAN, CONTEXT_TRIGGER_WEEKEND);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+ // Err: Invalid operator
+ error = context_trigger_rule_entry_add_comparison_string(event, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_LESS_THAN, CONTEXT_TRIGGER_WEEKEND);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
- // Err: Duplicated operator & value
- error = context_trigger_rule_entry_add_comparison_string(event, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_EQUAL_TO, CONTEXT_TRIGGER_WEEKEND);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);
- error = context_trigger_rule_entry_add_comparison_string(event, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_EQUAL_TO, CONTEXT_TRIGGER_WEEKEND);
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+ // Err: Duplicated operator & value
+ error = context_trigger_rule_entry_add_comparison_string(event, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_EQUAL_TO, CONTEXT_TRIGGER_WEEKEND);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);
+ error = context_trigger_rule_entry_add_comparison_string(event, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_EQUAL_TO, CONTEXT_TRIGGER_WEEKEND);
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
- // Err: Invalid comparison vale type
- context_trigger_rule_entry_add_key(event, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_TIME_OF_DAY);
- error = context_trigger_rule_entry_add_comparison_string(event, CONTEXT_TRIGGER_TIME_OF_DAY, CONTEXT_TRIGGER_EQUAL_TO, "16");
- assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
+ // Err: Invalid comparison vale type
+ context_trigger_rule_entry_add_key(event, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_TIME_OF_DAY);
+ error = context_trigger_rule_entry_add_comparison_string(event, CONTEXT_TRIGGER_TIME_OF_DAY, CONTEXT_TRIGGER_EQUAL_TO, "16");
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_INVALID_RULE);
- context_trigger_rule_entry_destroy(event);
+ context_trigger_rule_entry_destroy(event);
+ } else {
+ PRINT_INFO("Event(%x) is not supported", CONTEXT_TRIGGER_EVENT_TIME);
+ }
// Err: Invalid comparison value
error = context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_TIME, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event1);
context_trigger_rule_entry_h condition = NULL;
context_trigger_rule_entry_h condition2 = NULL;
+ bool app_supported = false;
+ bool comm_supported = false;
+
+ context_trigger_rule_condition_is_supported(CONTEXT_TRIGGER_CONDITION_APP_USE_FREQUENCY, &app_supported);
+ context_trigger_rule_condition_is_supported(CONTEXT_TRIGGER_CONDITION_COMMUNICATION_FREQUENCY, &comm_supported);
+
+ if (!app_supported || !comm_supported) {
+ PRINT_INFO("Not supported item included. Skip test.");
+ return 0;
+ }
+
context_trigger_rule_condition_create(CONTEXT_TRIGGER_CONDITION_APP_USE_FREQUENCY, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &condition);
error = context_trigger_rule_entry_add_option_string(condition, CONTEXT_TRIGGER_APP_ID, "org.tizen.setting");
assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);
context_trigger_rule_entry_h condition = NULL;
int rule_id;
- bool ret = initialize_app_handle();
- assert_eq(ret, true);
+ bool call_supported = false;
+ bool comm_supported = false;
- error = context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_CALL, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event);
- if (error == CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED) {
- PRINT_INFO("Call event is not supported. Skip test.");
+ context_trigger_rule_event_is_supported(CONTEXT_TRIGGER_EVENT_CALL, &call_supported);
+ context_trigger_rule_condition_is_supported(CONTEXT_TRIGGER_CONDITION_COMMUNICATION_FREQUENCY, &comm_supported);
+
+ if (!call_supported || !comm_supported) {
+ PRINT_INFO("Not supported item included. Skip test.");
return 0;
}
+ bool ret = initialize_app_handle();
+
+ error = context_trigger_rule_event_create(CONTEXT_TRIGGER_EVENT_CALL, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &event);
+
context_trigger_rule_condition_create(CONTEXT_TRIGGER_CONDITION_COMMUNICATION_FREQUENCY, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &condition);
context_trigger_rule_entry_add_key(condition, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, CONTEXT_TRIGGER_RANK);
context_trigger_rule_entry_add_comparison_int(condition, CONTEXT_TRIGGER_RANK, CONTEXT_TRIGGER_EQUAL_TO, 1);
context_trigger_rule_set_action_app_control(rule, app);
error = context_trigger_add_rule(rule, &rule_id);
- if (error == CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED) {
- PRINT_INFO("Not supported");
- } else {
- assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);
- }
+ assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);
context_trigger_remove_rule(rule_id);
context_trigger_rule_entry_destroy(event);
{
int error = CONTEXT_TRIGGER_ERROR_NONE;
+ bool time_supported = false;
+ bool comm_supported = false;
+
+ context_trigger_rule_event_is_supported(CONTEXT_TRIGGER_EVENT_TIME, &time_supported);
+ context_trigger_rule_condition_is_supported(CONTEXT_TRIGGER_CONDITION_COMMUNICATION_FREQUENCY, &comm_supported);
+
+ if (!time_supported || !comm_supported) {
+ PRINT_INFO("Not supported item included. Skip test.");
+ return 0;
+ }
+
bool ret = initialize_app_handle();
assert_eq(ret, true);
assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);
context_trigger_rule_set_action_app_control(rule2, app);
- error = context_trigger_add_rule(rule2, &rule_id2);
- if (error == CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED) {
- PRINT_INFO("Not supported");
- } else {
- assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);
- }
+ context_trigger_add_rule(rule2, &rule_id2);
context_trigger_remove_rule(rule_id2);
context_trigger_rule_entry_destroy(event2);
int error = CONTEXT_TRIGGER_ERROR_NONE;
context_trigger_rule_entry_h condition = NULL;
- context_trigger_rule_condition_create(CONTEXT_TRIGGER_CONDITION_APP_USE_FREQUENCY, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &condition);
+ error = context_trigger_rule_condition_create(CONTEXT_TRIGGER_CONDITION_APP_USE_FREQUENCY, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &condition);
+ if (error == CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED) {
+ PRINT_INFO("Not supported. Skip test.");
+ return 0;
+ }
error = context_trigger_rule_entry_add_option(condition, CONTEXT_TRIGGER_APP_ID, CONTEXT_TRIGGER_DAY_OF_WEEK);
assert_eq(error, CONTEXT_TRIGGER_ERROR_NONE);