--- /dev/null
+/*
+ * Copyright (c) 2017 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 <vector>
+#include <context_history.h>
+#include <context_trigger.h>
+#include "../shared.h"
+#include "DefaultTest.h"
+
+using namespace test;
+
+static bool __verify_context_history();
+static bool __verify_context_trigger();
+
+int test_default(int *argc, char ***argv)
+{
+ g_print("\n");
+ run_test_case("/api-availability/context-history", __verify_context_history);
+
+ g_print("\n");
+ run_test_case("/api-availability/context-trigger", __verify_context_trigger);
+
+ return 0;
+}
+
+bool __verify_context_history()
+{
+ context_history_h history = NULL;
+ context_history_filter_h filter = NULL;
+ context_history_list_h queryResult = NULL;
+
+ context_history_create(&history);
+ context_history_filter_create(&filter);
+ context_history_filter_set_int(filter, CONTEXT_HISTORY_FILTER_RESULT_SIZE, 5);
+
+ int error = context_history_get_list(history, CONTEXT_HISTORY_RECENTLY_USED_APP, filter, &queryResult);
+
+ context_history_list_destroy(queryResult);
+ context_history_filter_destroy(filter);
+ context_history_destroy(history);
+
+ ASSERT(error == CONTEXT_HISTORY_ERROR_NONE || error == CONTEXT_HISTORY_ERROR_NO_DATA);
+
+ return true;
+}
+
+bool __verify_context_trigger()
+{
+ std::vector<context_trigger_event_e> events({
+ CONTEXT_TRIGGER_EVENT_BATTERY,
+ CONTEXT_TRIGGER_EVENT_CHARGER,
+ CONTEXT_TRIGGER_EVENT_GPS,
+ CONTEXT_TRIGGER_EVENT_HEADPHONE,
+ CONTEXT_TRIGGER_EVENT_USB
+ });
+
+ int error = CONTEXT_TRIGGER_ERROR_NONE;
+ bool supported = false;
+ context_trigger_rule_entry_h entry = NULL;
+
+ for (context_trigger_event_e event : events) {
+ error = context_trigger_rule_event_is_supported(event, &supported);
+ ASSERT_CMPINT(error, ==, CONTEXT_TRIGGER_ERROR_NONE);
+
+ if (!supported)
+ continue;
+
+ error = context_trigger_rule_event_create(event, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &entry);
+ context_trigger_rule_entry_destroy(entry);
+ entry = NULL;
+ ASSERT_CMPINT(error, ==, CONTEXT_TRIGGER_ERROR_NONE);
+ }
+
+ return true;
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 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.
+ */
+
+#ifndef __CONTEXT_DEFAULT_TEST_H__
+#define __CONTEXT_DEFAULT_TEST_H__
+
+int test_default(int *argc, char ***argv);
+
+#endif /* __CONTEXT_CONTEXT_DEFAULT_TEST_H__ */
#define ASSERT_RETURN(condition, ret) \
do { \
if (!(condition)) { \
- g_print("\n>> " RED("FAIL") ": %s(%d) > %s\n", __FUNCTION__, __LINE__, #condition); \
+ g_print(">> " RED("FAIL") ": %s(%d) > %s\n", __FUNCTION__, __LINE__, #condition); \
return ret; \
} \
} while (0)
#define ASSERT_CMPINT(left, comp, right) \
do { \
if (!((left) comp (right))) { \
- g_print("\n>> " RED("FAIL") ": %s(%d) > %s(%d) %s %s(%d)\n", __FUNCTION__, __LINE__, #left, (left), #comp, #right, (right)); \
+ g_print(">> " RED("FAIL") ": %s(%d) > %s(%d) %s %s(%d)\n", __FUNCTION__, __LINE__, #left, (left), #comp, #right, (right)); \
return false; \
} \
} while (0)