2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <context_history.h>
19 #include <context_trigger.h>
20 #include "../shared.h"
21 #include "DefaultTest.h"
25 static bool __verify_context_history();
26 static bool __verify_context_trigger();
28 int test_default(int *argc, char ***argv)
31 run_test_case("/api-availability/context-history", __verify_context_history);
34 run_test_case("/api-availability/context-trigger", __verify_context_trigger);
39 bool __verify_context_history()
41 context_history_h history = NULL;
42 context_history_filter_h filter = NULL;
43 context_history_list_h queryResult = NULL;
45 context_history_create(&history);
46 context_history_filter_create(&filter);
47 context_history_filter_set_int(filter, CONTEXT_HISTORY_FILTER_RESULT_SIZE, 5);
49 int error = context_history_get_list(history, CONTEXT_HISTORY_RECENTLY_USED_APP, filter, &queryResult);
51 context_history_list_destroy(queryResult);
52 context_history_filter_destroy(filter);
53 context_history_destroy(history);
55 ASSERT(error == CONTEXT_HISTORY_ERROR_NONE || error == CONTEXT_HISTORY_ERROR_NO_DATA);
60 bool __verify_context_trigger()
62 std::vector<context_trigger_event_e> events({
63 CONTEXT_TRIGGER_EVENT_BATTERY,
64 CONTEXT_TRIGGER_EVENT_CHARGER,
65 CONTEXT_TRIGGER_EVENT_GPS,
66 CONTEXT_TRIGGER_EVENT_HEADPHONE,
67 CONTEXT_TRIGGER_EVENT_USB
70 int error = CONTEXT_TRIGGER_ERROR_NONE;
71 bool supported = false;
72 context_trigger_rule_entry_h entry = NULL;
74 for (context_trigger_event_e event : events) {
75 error = context_trigger_rule_event_is_supported(event, &supported);
76 ASSERT_CMPINT(error, ==, CONTEXT_TRIGGER_ERROR_NONE);
81 error = context_trigger_rule_event_create(event, CONTEXT_TRIGGER_LOGICAL_CONJUNCTION, &entry);
82 context_trigger_rule_entry_destroy(entry);
84 ASSERT_CMPINT(error, ==, CONTEXT_TRIGGER_ERROR_NONE);