Remove the trigger testcases, which use the legacy context internal API 31/140831/1
authorMu-Woong Lee <muwoong.lee@samsung.com>
Wed, 26 Jul 2017 12:15:14 +0000 (21:15 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Wed, 26 Jul 2017 12:15:14 +0000 (21:15 +0900)
Change-Id: I361db55e4a115a58d61c5a4723d03fffcfd2ddf9
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
testsuite/src/trigger/condition.cpp [deleted file]
testsuite/src/trigger/condition.h [deleted file]
testsuite/src/trigger/event.cpp [deleted file]
testsuite/src/trigger/event.h [deleted file]
testsuite/src/trigger/request_handler.cpp [deleted file]
testsuite/src/trigger/request_handler.h [deleted file]

diff --git a/testsuite/src/trigger/condition.cpp b/testsuite/src/trigger/condition.cpp
deleted file mode 100644 (file)
index 851ffec..0000000
+++ /dev/null
@@ -1,484 +0,0 @@
-/*
- * Copyright (c) 2015 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 <context_trigger.h>
-#include <context_history.h>
-#include <ProviderTypes.h>
-
-#include "../shared.h"
-#include "request_handler.h"
-#include "condition.h"
-
-using namespace ctx::test;
-
-int test_trigger_condition(int *argc, char ***argv)
-{
-       runTestCase("/trigger/cond/battery", _trigger_cond_battery);
-       runTestCase("/trigger/cond/charger", _trigger_cond_charger);
-       runTestCase("/trigger/cond/gps", _trigger_cond_gps);
-       runTestCase("/trigger/cond/headphone", _trigger_cond_headphone);
-       runTestCase("/trigger/cond/usb", _trigger_cond_usb);
-       runTestCase("/trigger/cond/wifi", _trigger_cond_wifi);
-       runTestCase("/trigger/cond/psmode", _trigger_cond_psmode);
-       runTestCase("/trigger/cond/call", _trigger_cond_call);
-       runTestCase("/trigger/cond/time", _trigger_cond_time);
-
-       runTestCase("/trigger/cond/app_freq1", _trigger_cond_app_use_freq1);
-       runTestCase("/trigger/cond/app_freq2", _trigger_cond_app_use_freq2);
-       runTestCase("/trigger/cond/app_freq3", _trigger_cond_app_use_freq3);
-       runTestCase("/trigger/cond/app_freq4", _trigger_cond_app_use_freq4);
-
-       runTestCase("/trigger/cond/comm_freq1", _trigger_cond_comm_freq1);
-       runTestCase("/trigger/cond/comm_freq2", _trigger_cond_comm_freq2);
-       runTestCase("/trigger/cond/comm_freq3", _trigger_cond_comm_freq3);
-       runTestCase("/trigger/cond/comm_freq4", _trigger_cond_comm_freq4);
-
-       runTestCase("/trigger/cond/music_freq1", _trigger_cond_music_freq1);
-       runTestCase("/trigger/cond/music_freq2", _trigger_cond_music_freq2);
-       runTestCase("/trigger/cond/music_freq3", _trigger_cond_music_freq3);
-       runTestCase("/trigger/cond/music_freq4", _trigger_cond_music_freq4);
-
-       runTestCase("/trigger/cond/video_freq1", _trigger_cond_video_freq1);
-       runTestCase("/trigger/cond/video_freq2", _trigger_cond_video_freq2);
-       runTestCase("/trigger/cond/video_freq3", _trigger_cond_video_freq3);
-       runTestCase("/trigger/cond/video_freq4", _trigger_cond_video_freq4);
-
-       return 0;
-}
-
-static bool __support(context_trigger_condition_e cond)
-{
-       lastError = context_trigger_rule_condition_is_supported(cond, &value::boolean);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       if (!value::boolean) {
-               g_print(YELLOW("Not Supported") "\n");
-               return false;
-       }
-
-       return true;
-}
-
-bool _trigger_cond_battery()
-{
-       if (!__support(CONTEXT_TRIGGER_CONDITION_BATTERY)) return false;
-
-       lastError = ctx::request_handler::read_sync(SUBJ_STATE_BATTERY, NULL, &req_id, &json_val);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_LEVEL);
-       ASSERT_CONTAIN_INT(json_val, CONTEXT_TRIGGER_IS_CHARGING);
-
-       return true;
-}
-
-bool _trigger_cond_charger()
-{
-       if (!__support(CONTEXT_TRIGGER_CONDITION_CHARGER)) return false;
-
-       lastError = ctx::request_handler::read_sync(SUBJ_STATE_CHARGER, NULL, &req_id, &json_val);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-       ASSERT_CONTAIN_INT(json_val, CONTEXT_TRIGGER_IS_CONNECTED);
-
-       return true;
-}
-
-bool _trigger_cond_gps()
-{
-       if (!__support(CONTEXT_TRIGGER_CONDITION_GPS)) return false;
-
-       lastError = ctx::request_handler::read_sync(SUBJ_STATE_GPS, NULL, &req_id, &json_val);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_STATE);
-
-       return true;
-}
-
-bool _trigger_cond_headphone()
-{
-       if (!__support(CONTEXT_TRIGGER_CONDITION_HEADPHONE)) return false;
-
-       lastError = ctx::request_handler::read_sync(SUBJ_STATE_HEADPHONE, NULL, &req_id, &json_val);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       ASSERT_CONTAIN_INT(json_val, CONTEXT_TRIGGER_IS_CONNECTED);
-       if (value::int32 == CONTEXT_TRIGGER_FALSE) return true;
-
-       ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_TYPE);
-
-       return true;
-}
-
-bool _trigger_cond_usb()
-{
-       if (!__support(CONTEXT_TRIGGER_CONDITION_USB)) return false;
-
-       lastError = ctx::request_handler::read_sync(SUBJ_STATE_USB, NULL, &req_id, &json_val);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       ASSERT_CONTAIN_INT(json_val, CONTEXT_TRIGGER_IS_CONNECTED);
-
-       return true;
-}
-
-bool _trigger_cond_wifi()
-{
-       if (!__support(CONTEXT_TRIGGER_CONDITION_WIFI)) return false;
-
-       lastError = ctx::request_handler::read_sync(SUBJ_STATE_WIFI, NULL, &req_id, &json_val);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_STATE);
-
-       if (value::str == CONTEXT_TRIGGER_CONNECTED)
-               ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_BSSID);
-
-       return true;
-}
-
-bool _trigger_cond_psmode()
-{
-       if (!__support(CONTEXT_TRIGGER_CONDITION_POWER_SAVING_MODE)) return false;
-
-       lastError = ctx::request_handler::read_sync(SUBJ_STATE_PSMODE, NULL, &req_id, &json_val);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       ASSERT_CONTAIN_INT(json_val, CONTEXT_TRIGGER_IS_ENABLED);
-
-       return true;
-}
-
-bool _trigger_cond_call()
-{
-       if (!__support(CONTEXT_TRIGGER_CONDITION_CALL)) return false;
-
-       lastError = ctx::request_handler::read_sync(SUBJ_STATE_CALL, NULL, &req_id, &json_val);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_STATE);
-       if (value::str == CONTEXT_TRIGGER_IDLE) return true;
-
-       ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_MEDIUM);
-       ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_ADDRESS);
-
-       return true;
-}
-
-bool _trigger_cond_time()
-{
-       if (!__support(CONTEXT_TRIGGER_CONDITION_TIME)) return false;
-
-       lastError = ctx::request_handler::read_sync(SUBJ_STATE_TIME, NULL, &req_id, &json_val);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       ASSERT_CONTAIN_INT(json_val, CONTEXT_TRIGGER_TIME_OF_DAY);
-       ASSERT_CONTAIN_INT(json_val, CONTEXT_TRIGGER_DAY_OF_MONTH);
-       ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_DAY_OF_WEEK);
-
-       return true;
-}
-
-static std::string& __get_objective_app_id()
-{
-       static std::string app_id;
-
-       if (!app_id.empty())
-               return app_id;
-
-       int list_size = 0;
-       context_history_h handle = NULL;
-       context_history_filter_h filter = NULL;
-       context_history_list_h list = NULL;
-
-       context_history_create(&handle);
-       context_history_filter_create(&filter);
-       context_history_filter_set_int(filter, CONTEXT_HISTORY_FILTER_RESULT_SIZE, 1);
-       context_history_get_list(handle, CONTEXT_HISTORY_FREQUENTLY_USED_APP, filter, &list);
-       context_history_list_get_count(list, &list_size);
-
-       if (list_size > 0) {
-               char *buffer = NULL;
-               context_history_record_h record = NULL;
-               context_history_list_get_current(list, &record);
-               context_history_record_get_string(record, CONTEXT_HISTORY_APP_ID, &buffer);
-               if (buffer) {
-                       app_id = buffer;
-                       g_free(buffer);
-               }
-               context_history_record_destroy(record);
-       }
-
-       context_history_list_destroy(list);
-       context_history_filter_destroy(filter);
-       context_history_destroy(handle);
-
-       if (app_id.empty())
-               app_id = "org.tizen.gallery";
-
-       return app_id;
-}
-
-static bool __trigger_cond_app_use_freq_base(ctx::CtxJson1 option)
-{
-       if (!__support(CONTEXT_TRIGGER_CONDITION_APP_USE_FREQUENCY)) return false;
-
-       lastError = ctx::request_handler::read_sync(SUBJ_APP_FREQUENCY, &option, &req_id, &json_val);
-       if (lastError == E_NO_DATA) {
-               g_print(RED("No Data "));
-               return true;
-       }
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_APP_ID);
-       ASSERT_CONTAIN_INT(json_val, CONTEXT_TRIGGER_RANK);
-       ASSERT_CONTAIN_INT(json_val, CONTEXT_TRIGGER_TOTAL_COUNT);
-
-       return true;
-}
-
-bool _trigger_cond_app_use_freq1()
-{
-       /* Case 1: App ID only */
-       ctx::CtxJson1 option;
-       option.set(NULL, CONTEXT_TRIGGER_APP_ID, __get_objective_app_id());
-
-       return __trigger_cond_app_use_freq_base(option);
-}
-
-bool _trigger_cond_app_use_freq2()
-{
-       /* Case 2: App ID, Day of Week */
-       ctx::CtxJson1 option;
-       option.set(NULL, CONTEXT_TRIGGER_APP_ID, __get_objective_app_id());
-       option.set(NULL, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_WEEKDAY);
-
-       return __trigger_cond_app_use_freq_base(option);
-}
-
-bool _trigger_cond_app_use_freq3()
-{
-       /* Case 3: App ID, Time of Day */
-       ctx::CtxJson1 option;
-       option.set(NULL, CONTEXT_TRIGGER_APP_ID, __get_objective_app_id());
-       option.set(NULL, CONTEXT_TRIGGER_TIME_OF_DAY, "10-16");
-
-       return __trigger_cond_app_use_freq_base(option);
-}
-
-bool _trigger_cond_app_use_freq4()
-{
-       /* Case 3: App ID, Time of Day, Day of Week */
-       ctx::CtxJson1 option;
-       option.set(NULL, CONTEXT_TRIGGER_APP_ID, __get_objective_app_id());
-       option.set(NULL, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_WEEKDAY);
-       option.set(NULL, CONTEXT_TRIGGER_TIME_OF_DAY, "10-16");
-
-       return __trigger_cond_app_use_freq_base(option);
-}
-
-static std::string& __get_objective_address()
-{
-       static std::string address;
-
-       if (!address.empty())
-               return address;
-
-       int list_size = 0;
-       context_history_h handle = NULL;
-       context_history_filter_h filter = NULL;
-       context_history_list_h list = NULL;
-
-       context_history_create(&handle);
-       context_history_filter_create(&filter);
-       context_history_filter_set_int(filter, CONTEXT_HISTORY_FILTER_RESULT_SIZE, 1);
-       context_history_get_list(handle, CONTEXT_HISTORY_FREQUENTLY_COMMUNICATED_ADDRESS, filter, &list);
-       context_history_list_get_count(list, &list_size);
-
-       if (list_size > 0) {
-               char *buffer = NULL;
-               context_history_record_h record = NULL;
-               context_history_list_get_current(list, &record);
-               context_history_record_get_string(record, CONTEXT_HISTORY_ADDRESS, &buffer);
-               if (buffer) {
-                       address = buffer;
-                       g_free(buffer);
-               }
-               context_history_record_destroy(record);
-       }
-
-       context_history_list_destroy(list);
-       context_history_filter_destroy(filter);
-       context_history_destroy(handle);
-
-       if (address.empty())
-               address = "000-000-0000";
-
-       return address;
-}
-
-static bool __trigger_cond_comm_freq_base(ctx::CtxJson1 option)
-{
-       if (!__support(CONTEXT_TRIGGER_CONDITION_COMMUNICATION_FREQUENCY)) return false;
-
-       lastError = ctx::request_handler::read_sync(SUBJ_SOCIAL_FREQUENCY, &option, &req_id, &json_val);
-       if (lastError == E_NO_DATA) {
-               g_print(RED("No Data "));
-               return true;
-       }
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_ADDRESS);
-       ASSERT_CONTAIN_INT(json_val, CONTEXT_TRIGGER_RANK);
-       ASSERT_CONTAIN_INT(json_val, CONTEXT_TRIGGER_TOTAL_COUNT);
-
-       return true;
-}
-
-bool _trigger_cond_comm_freq1()
-{
-       /* Case 1: Address only */
-       ctx::CtxJson1 option;
-       option.set(NULL, CONTEXT_TRIGGER_ADDRESS, __get_objective_address());
-
-       return __trigger_cond_comm_freq_base(option);
-}
-
-bool _trigger_cond_comm_freq2()
-{
-       /* Case 2: Address, Day of Week */
-       ctx::CtxJson1 option;
-       option.set(NULL, CONTEXT_TRIGGER_ADDRESS, __get_objective_address());
-       option.set(NULL, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_WEEKDAY);
-
-       return __trigger_cond_comm_freq_base(option);
-}
-
-bool _trigger_cond_comm_freq3()
-{
-       /* Case 3: Address, Time of Day */
-       ctx::CtxJson1 option;
-       option.set(NULL, CONTEXT_TRIGGER_ADDRESS, __get_objective_address());
-       option.set(NULL, CONTEXT_TRIGGER_TIME_OF_DAY, "10-16");
-
-       return __trigger_cond_comm_freq_base(option);
-}
-
-bool _trigger_cond_comm_freq4()
-{
-       /* Case 4: Address, Day of Week, Time of Day */
-       ctx::CtxJson1 option;
-       option.set(NULL, CONTEXT_TRIGGER_ADDRESS, __get_objective_address());
-       option.set(NULL, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_WEEKDAY);
-       option.set(NULL, CONTEXT_TRIGGER_TIME_OF_DAY, "10-16");
-
-       return __trigger_cond_comm_freq_base(option);
-}
-
-static bool __trigger_cond_media_freq_base(context_trigger_condition_e item, const char *item_str, ctx::CtxJson1 option)
-{
-       if (!__support(item)) return false;
-
-       lastError = ctx::request_handler::read_sync(item_str, &option, &req_id, &json_val);
-       if (lastError == E_NO_DATA) {
-               g_print(YELLOW("No Data "));
-               return true;
-       }
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-       ASSERT_CONTAIN_INT(json_val, CONTEXT_TRIGGER_TOTAL_COUNT);
-
-       return true;
-}
-
-bool _trigger_cond_music_freq1()
-{
-       ctx::CtxJson1 option;
-
-       return __trigger_cond_media_freq_base(
-                       CONTEXT_TRIGGER_CONDITION_MUSIC_PLAYBACK_FREQUENCY,
-                       SUBJ_MUSIC_FREQUENCY, option);
-}
-
-bool _trigger_cond_music_freq2()
-{
-       ctx::CtxJson1 option;
-       option.set(NULL, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_WEEKDAY);
-
-       return __trigger_cond_media_freq_base(
-                       CONTEXT_TRIGGER_CONDITION_MUSIC_PLAYBACK_FREQUENCY,
-                       SUBJ_MUSIC_FREQUENCY, option);
-}
-
-bool _trigger_cond_music_freq3()
-{
-       ctx::CtxJson1 option;
-       option.set(NULL, CONTEXT_TRIGGER_TIME_OF_DAY, "10-16");
-
-       return __trigger_cond_media_freq_base(
-                       CONTEXT_TRIGGER_CONDITION_MUSIC_PLAYBACK_FREQUENCY,
-                       SUBJ_MUSIC_FREQUENCY, option);
-}
-
-bool _trigger_cond_music_freq4()
-{
-       ctx::CtxJson1 option;
-       option.set(NULL, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_WEEKDAY);
-       option.set(NULL, CONTEXT_TRIGGER_TIME_OF_DAY, "10-16");
-
-       return __trigger_cond_media_freq_base(
-                       CONTEXT_TRIGGER_CONDITION_MUSIC_PLAYBACK_FREQUENCY,
-                       SUBJ_MUSIC_FREQUENCY, option);
-}
-
-bool _trigger_cond_video_freq1()
-{
-       ctx::CtxJson1 option;
-
-       return __trigger_cond_media_freq_base(
-                       CONTEXT_TRIGGER_CONDITION_VIDEO_PLAYBACK_FREQUENCY,
-                       SUBJ_VIDEO_FREQUENCY, option);
-}
-
-bool _trigger_cond_video_freq2()
-{
-       ctx::CtxJson1 option;
-       option.set(NULL, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_WEEKDAY);
-
-       return __trigger_cond_media_freq_base(
-                       CONTEXT_TRIGGER_CONDITION_VIDEO_PLAYBACK_FREQUENCY,
-                       SUBJ_VIDEO_FREQUENCY, option);
-}
-
-bool _trigger_cond_video_freq3()
-{
-       ctx::CtxJson1 option;
-       option.set(NULL, CONTEXT_TRIGGER_TIME_OF_DAY, "10-16");
-
-       return __trigger_cond_media_freq_base(
-                       CONTEXT_TRIGGER_CONDITION_VIDEO_PLAYBACK_FREQUENCY,
-                       SUBJ_VIDEO_FREQUENCY, option);
-}
-
-bool _trigger_cond_video_freq4()
-{
-       ctx::CtxJson1 option;
-       option.set(NULL, CONTEXT_TRIGGER_DAY_OF_WEEK, CONTEXT_TRIGGER_WEEKDAY);
-       option.set(NULL, CONTEXT_TRIGGER_TIME_OF_DAY, "10-16");
-
-       return __trigger_cond_media_freq_base(
-                       CONTEXT_TRIGGER_CONDITION_VIDEO_PLAYBACK_FREQUENCY,
-                       SUBJ_VIDEO_FREQUENCY, option);
-}
diff --git a/testsuite/src/trigger/condition.h b/testsuite/src/trigger/condition.h
deleted file mode 100644 (file)
index d2a8282..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2015 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_TEST_TRIGGER_CONDITION_H__
-#define __CONTEXT_TEST_TRIGGER_CONDITION_H__
-
-int test_trigger_condition(int *argc, char ***argv);
-
-bool _trigger_cond_battery();
-bool _trigger_cond_charger();
-bool _trigger_cond_gps();
-bool _trigger_cond_headphone();
-bool _trigger_cond_usb();
-bool _trigger_cond_wifi();
-bool _trigger_cond_psmode();
-bool _trigger_cond_call();
-bool _trigger_cond_time();
-
-bool _trigger_cond_app_use_freq1();
-bool _trigger_cond_app_use_freq2();
-bool _trigger_cond_app_use_freq3();
-bool _trigger_cond_app_use_freq4();
-
-bool _trigger_cond_comm_freq1();
-bool _trigger_cond_comm_freq2();
-bool _trigger_cond_comm_freq3();
-bool _trigger_cond_comm_freq4();
-
-bool _trigger_cond_music_freq1();
-bool _trigger_cond_music_freq2();
-bool _trigger_cond_music_freq3();
-bool _trigger_cond_music_freq4();
-
-bool _trigger_cond_video_freq1();
-bool _trigger_cond_video_freq2();
-bool _trigger_cond_video_freq3();
-bool _trigger_cond_video_freq4();
-
-#endif
diff --git a/testsuite/src/trigger/event.cpp b/testsuite/src/trigger/event.cpp
deleted file mode 100644 (file)
index 1f19e82..0000000
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- * Copyright (c) 2015 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 <time.h>
-#include <context_trigger.h>
-#include <ProviderTypes.h>
-
-#include "../shared.h"
-#include "request_handler.h"
-#include "event.h"
-
-using namespace ctx::test;
-
-static void __domain_cb(const char *item, int rid, int error, ctx::CtxJson1 data)
-{
-       g_print("[%d] %s: Error=%#x, Data=%s\n", callback_count--, item, error, data.str().c_str());
-
-       if (callback_count == 0) {
-               json_val = data;
-               stopMainloop();
-       }
-}
-
-int test_trigger_event(int *argc, char ***argv)
-{
-       g_test_init(argc, argv, NULL);
-
-       ctx::request_handler::register_callback(SUBJ_STATE_BATTERY, __domain_cb);
-       ctx::request_handler::register_callback(SUBJ_STATE_CHARGER, __domain_cb);
-       ctx::request_handler::register_callback(SUBJ_STATE_GPS, __domain_cb);
-       ctx::request_handler::register_callback(SUBJ_STATE_HEADPHONE, __domain_cb);
-       ctx::request_handler::register_callback(SUBJ_STATE_PSMODE, __domain_cb);
-       ctx::request_handler::register_callback(SUBJ_STATE_USB, __domain_cb);
-       ctx::request_handler::register_callback(SUBJ_STATE_WIFI, __domain_cb);
-       ctx::request_handler::register_callback(SUBJ_STATE_CALL, __domain_cb);
-       ctx::request_handler::register_callback(SUBJ_STATE_ALARM, __domain_cb);
-       ctx::request_handler::register_callback(SUBJ_STATE_EMAIL, __domain_cb);
-       ctx::request_handler::register_callback(SUBJ_STATE_MESSAGE, __domain_cb);
-       ctx::request_handler::register_callback(SUBJ_ACTIVITY_STATIONARY, __domain_cb);
-       ctx::request_handler::register_callback(SUBJ_ACTIVITY_WALKING, __domain_cb);
-       ctx::request_handler::register_callback(SUBJ_ACTIVITY_RUNNING, __domain_cb);
-       ctx::request_handler::register_callback(SUBJ_ACTIVITY_IN_VEHICLE, __domain_cb);
-       ctx::request_handler::register_callback(SUBJ_PLACE_GEOFENCE, __domain_cb);
-
-       runTestCase("/trigger/event/battery", _trigger_event_battery);
-       runTestCase("/trigger/event/charger", _trigger_event_charger);
-       runTestCase("/trigger/event/gps", _trigger_event_gps);
-       runTestCase("/trigger/event/headphone", _trigger_event_headphone);
-       runTestCase("/trigger/event/usb", _trigger_event_usb);
-       runTestCase("/trigger/event/wifi", _trigger_event_wifi);
-       runTestCase("/trigger/event/psmode", _trigger_event_psmode);
-       runTestCase("/trigger/event/call", _trigger_event_call);
-       runTestCase("/trigger/event/time", _trigger_event_time);
-       runTestCase("/trigger/event/email", _trigger_event_email);
-       runTestCase("/trigger/event/message", _trigger_event_message);
-       runTestCase("/trigger/event/activity", _trigger_event_activity);
-       runTestCase("/trigger/event/place", _trigger_event_place);
-
-       return g_test_run();
-}
-
-static bool __support(context_trigger_event_e ev)
-{
-       lastError = context_trigger_rule_event_is_supported(ev, &value::boolean);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       if (!value::boolean) {
-               g_print(YELLOW("Not Supported") "\n");
-               return false;
-       }
-
-       return true;
-}
-
-bool _trigger_event_battery()
-{
-       if (!__support(CONTEXT_TRIGGER_EVENT_BATTERY)) return false;
-
-       lastError = ctx::request_handler::subscribe(SUBJ_STATE_BATTERY, NULL, &req_id, NULL);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       g_print("\n> Change the battery lavel (or charging status) %d times.\n", CALLBACK_COUNT);
-       startMainloop();
-
-       ctx::request_handler::unsubscribe(SUBJ_STATE_BATTERY, req_id);
-
-       ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_LEVEL);
-       ASSERT_CONTAIN_INT(json_val, CONTEXT_TRIGGER_IS_CHARGING);
-
-       return true;
-}
-
-bool _trigger_event_charger()
-{
-       if (!__support(CONTEXT_TRIGGER_EVENT_CHARGER)) return false;
-
-       lastError = ctx::request_handler::subscribe(SUBJ_STATE_CHARGER, NULL, &req_id, NULL);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       g_print("\n> Change the charger connection state %d times.\n", CALLBACK_COUNT);
-       startMainloop();
-
-       ctx::request_handler::unsubscribe(SUBJ_STATE_CHARGER, req_id);
-
-       ASSERT_CONTAIN_INT(json_val, CONTEXT_TRIGGER_IS_CONNECTED);
-
-       return true;
-}
-
-bool _trigger_event_gps()
-{
-       if (!__support(CONTEXT_TRIGGER_EVENT_GPS)) return false;
-
-       lastError = ctx::request_handler::subscribe(SUBJ_STATE_GPS, NULL, &req_id, NULL);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       g_print("\n> Change the GPS status %d times.\n", CALLBACK_COUNT);
-       startMainloop();
-
-       ctx::request_handler::unsubscribe(SUBJ_STATE_GPS, req_id);
-
-       ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_STATE);
-
-       return true;
-}
-
-bool _trigger_event_headphone()
-{
-       if (!__support(CONTEXT_TRIGGER_EVENT_HEADPHONE)) return false;
-
-       lastError = ctx::request_handler::subscribe(SUBJ_STATE_HEADPHONE, NULL, &req_id, NULL);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       g_print("\n> Connect/disconnect a headphone %d times.\n", CALLBACK_COUNT);
-       startMainloop();
-
-       ctx::request_handler::unsubscribe(SUBJ_STATE_HEADPHONE, req_id);
-
-       ASSERT_CONTAIN_INT(json_val, CONTEXT_TRIGGER_IS_CONNECTED);
-       if (value::int32 == CONTEXT_TRIGGER_FALSE) return true;
-
-       ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_TYPE);
-
-       return true;
-}
-
-bool _trigger_event_usb()
-{
-       if (!__support(CONTEXT_TRIGGER_EVENT_USB)) return false;
-
-       lastError = ctx::request_handler::subscribe(SUBJ_STATE_USB, NULL, &req_id, NULL);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       g_print("\n> Connect/disconnect USB %d times.\n", CALLBACK_COUNT);
-       startMainloop();
-
-       ctx::request_handler::unsubscribe(SUBJ_STATE_USB, req_id);
-
-       ASSERT_CONTAIN_INT(json_val, CONTEXT_TRIGGER_IS_CONNECTED);
-
-       return true;
-}
-
-bool _trigger_event_wifi()
-{
-       if (!__support(CONTEXT_TRIGGER_EVENT_WIFI)) return false;
-
-       lastError = ctx::request_handler::subscribe(SUBJ_STATE_WIFI, NULL, &req_id, NULL);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       g_print("\n> Change the WiFi state %d times.\n", CALLBACK_COUNT);
-       startMainloop();
-
-       ctx::request_handler::unsubscribe(SUBJ_STATE_WIFI, req_id);
-
-       ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_STATE);
-
-       if (value::str == CONTEXT_TRIGGER_CONNECTED)
-               ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_BSSID);
-
-       return true;
-}
-
-bool _trigger_event_psmode()
-{
-       if (!__support(CONTEXT_TRIGGER_EVENT_POWER_SAVING_MODE)) return false;
-
-       lastError = ctx::request_handler::subscribe(SUBJ_STATE_PSMODE, NULL, &req_id, NULL);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       g_print("\n> Turn on/off the power-saving mode %d times.\n", CALLBACK_COUNT);
-       startMainloop();
-
-       ctx::request_handler::unsubscribe(SUBJ_STATE_PSMODE, req_id);
-
-       ASSERT_CONTAIN_INT(json_val, CONTEXT_TRIGGER_IS_ENABLED);
-
-       return true;
-}
-
-bool _trigger_event_call()
-{
-       if (!__support(CONTEXT_TRIGGER_EVENT_CALL)) return false;
-
-       lastError = ctx::request_handler::subscribe(SUBJ_STATE_CALL, NULL, &req_id, NULL);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       g_print("\n> Make a phone call to this device to change call state %d times.\n", CALLBACK_COUNT);
-       startMainloop();
-
-       ctx::request_handler::unsubscribe(SUBJ_STATE_CALL, req_id);
-
-       ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_STATE);
-       if (value::str == CONTEXT_TRIGGER_IDLE) return true;
-
-       ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_MEDIUM);
-       ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_ADDRESS);
-
-       return true;
-}
-
-bool _trigger_event_time()
-{
-       if (!__support(CONTEXT_TRIGGER_EVENT_TIME)) return false;
-
-       time_t rawtime;
-       struct tm timeinfo;
-       time(&rawtime);
-       tzset();
-       localtime_r(&rawtime, &timeinfo);
-       int dow = timeinfo.tm_wday;
-       int tod = timeinfo.tm_hour * 3600 + timeinfo.tm_min * 60 + timeinfo.tm_sec;
-       tod = (tod + 70) / 60;
-
-       std::string dow_str;
-       switch (dow) {
-       case 0:
-               dow_str = CONTEXT_TRIGGER_SUN;
-               break;
-       case 1:
-               dow_str = CONTEXT_TRIGGER_MON;
-               break;
-       case 2:
-               dow_str = CONTEXT_TRIGGER_TUE;
-               break;
-       case 3:
-               dow_str = CONTEXT_TRIGGER_WED;
-               break;
-       case 4:
-               dow_str = CONTEXT_TRIGGER_THU;
-               break;
-       case 5:
-               dow_str = CONTEXT_TRIGGER_FRI;
-               break;
-       case 6:
-               dow_str = CONTEXT_TRIGGER_SAT;
-               break;
-       default:
-               dow_str = CONTEXT_TRIGGER_WEEKDAY;
-               break;
-       }
-       ctx::CtxJson1 option;
-       option.append(NULL, CONTEXT_TRIGGER_DAY_OF_WEEK, dow_str);
-       option.append(NULL, CONTEXT_TRIGGER_TIME_OF_DAY, tod);
-
-       lastError = ctx::request_handler::subscribe(SUBJ_STATE_ALARM, &option, &req_id, NULL);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       callback_count = 1;
-       g_print("\n> Wait until %02d:%02d %s.\n", tod / 60, tod % 60, dow_str.c_str());
-       startMainloop();
-
-       ctx::request_handler::unsubscribe(SUBJ_STATE_CALL, req_id);
-
-       ASSERT_CONTAIN_INT(json_val, CONTEXT_TRIGGER_TIME_OF_DAY);
-       ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_DAY_OF_WEEK);
-
-       return true;
-}
-
-bool _trigger_event_email()
-{
-       if (!__support(CONTEXT_TRIGGER_EVENT_EMAIL)) return false;
-
-       lastError = ctx::request_handler::subscribe(SUBJ_STATE_EMAIL, NULL, &req_id, NULL);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       g_print("\n> Send/receive emails %d times.\n", CALLBACK_COUNT);
-       startMainloop();
-
-       ctx::request_handler::unsubscribe(SUBJ_STATE_EMAIL, req_id);
-
-       ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_EVENT);
-
-       return true;
-}
-
-bool _trigger_event_message()
-{
-       if (!__support(CONTEXT_TRIGGER_EVENT_MESSAGE)) return false;
-
-       lastError = ctx::request_handler::subscribe(SUBJ_STATE_MESSAGE, NULL, &req_id, NULL);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       g_print("\n> Receive SMS/MMS %d times.\n", CALLBACK_COUNT);
-       startMainloop();
-
-       ctx::request_handler::unsubscribe(SUBJ_STATE_MESSAGE, req_id);
-
-       ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_EVENT);
-       ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_TYPE);
-
-       return true;
-}
-
-bool _trigger_event_activity()
-{
-       if (!__support(CONTEXT_TRIGGER_EVENT_ACTIVITY_STATIONARY)) return false;
-       if (!__support(CONTEXT_TRIGGER_EVENT_ACTIVITY_WALKING)) return false;
-       if (!__support(CONTEXT_TRIGGER_EVENT_ACTIVITY_RUNNING)) return false;
-       if (!__support(CONTEXT_TRIGGER_EVENT_ACTIVITY_IN_VEHICLE)) return false;
-
-       int req_ids[4];
-
-       lastError = ctx::request_handler::subscribe(SUBJ_ACTIVITY_STATIONARY, NULL, &req_ids[0], NULL);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       lastError = ctx::request_handler::subscribe(SUBJ_ACTIVITY_WALKING, NULL, &req_ids[1], NULL);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       lastError = ctx::request_handler::subscribe(SUBJ_ACTIVITY_RUNNING, NULL, &req_ids[2], NULL);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       lastError = ctx::request_handler::subscribe(SUBJ_ACTIVITY_IN_VEHICLE, NULL, &req_ids[3], NULL);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       g_print("\n> Mimic any type of activity %d times.\n", CALLBACK_COUNT);
-       startMainloop();
-
-       ctx::request_handler::unsubscribe(SUBJ_ACTIVITY_STATIONARY, req_ids[0]);
-       ctx::request_handler::unsubscribe(SUBJ_ACTIVITY_WALKING, req_ids[1]);
-       ctx::request_handler::unsubscribe(SUBJ_ACTIVITY_RUNNING, req_ids[2]);
-       ctx::request_handler::unsubscribe(SUBJ_ACTIVITY_IN_VEHICLE, req_ids[3]);
-
-       ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_EVENT);
-       ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_ACCURACY);
-
-       return true;
-}
-
-bool _trigger_event_place()
-{
-       if (!__support(CONTEXT_TRIGGER_EVENT_PLACE)) return false;
-
-       ctx::CtxJson1 option;
-       option.set(NULL, CONTEXT_TRIGGER_PLACE_ID, 2);  /* 2 => office */
-
-       lastError = ctx::request_handler::subscribe(SUBJ_PLACE_GEOFENCE, &option, &req_id, NULL);
-       ASSERT_CMPINT(lastError, ==, E_NONE);
-
-       g_print("\n> Mimic fence in/out event to office %d times.\n", CALLBACK_COUNT);
-       startMainloop();
-
-       ctx::request_handler::unsubscribe(SUBJ_PLACE_GEOFENCE, req_id);
-
-       ASSERT_CONTAIN_STR(json_val, CONTEXT_TRIGGER_EVENT);
-
-       return true;
-}
diff --git a/testsuite/src/trigger/event.h b/testsuite/src/trigger/event.h
deleted file mode 100644 (file)
index 54a65bb..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2015 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_TEST_TRIGGER_EVENT_H__
-#define __CONTEXT_TEST_TRIGGER_EVENT_H__
-
-int test_trigger_event(int *argc, char ***argv);
-
-bool _trigger_event_battery();
-bool _trigger_event_charger();
-bool _trigger_event_gps();
-bool _trigger_event_headphone();
-bool _trigger_event_usb();
-bool _trigger_event_wifi();
-bool _trigger_event_psmode();
-bool _trigger_event_call();
-bool _trigger_event_time();
-bool _trigger_event_email();
-bool _trigger_event_message();
-bool _trigger_event_activity();
-bool _trigger_event_place();
-
-#endif
diff --git a/testsuite/src/trigger/request_handler.cpp b/testsuite/src/trigger/request_handler.cpp
deleted file mode 100644 (file)
index d92ae27..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2015 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.
- */
-
-/* TODO: Remove this request_handler. All APIs and the testsuite should use DBusClient directly. */
-
-#include <string>
-#include <map>
-
-#include <Types.h>
-#include <ScopeMutex.h>
-#include <DBusClient.h>
-#include "request_handler.h"
-
-using namespace ctx;
-
-class DBusClientListenerImpl : public IDBusClientListener {
-public:
-       DBusClientListenerImpl() {}
-       ~DBusClientListenerImpl() {}
-       void setCb(std::string subject, request_handler::subject_response_cb cb);
-       void onPublish(std::string subject, int reqId, int error, CtxJson1 event);
-private:
-       std::map<std::string, request_handler::subject_response_cb> __callbackMap;
-};
-
-void DBusClientListenerImpl::setCb(std::string subject, request_handler::subject_response_cb cb)
-{
-       __callbackMap[subject] = cb;
-}
-
-void DBusClientListenerImpl::onPublish(std::string subject, int reqId, int error, CtxJson1 event)
-{
-       auto it = __callbackMap.find(subject);
-       IF_FAIL_VOID_TAG(it != __callbackMap.end(), _W, "Unregistered subject");
-       it->second(subject.c_str(), reqId, error, event);
-}
-
-static DBusClientListenerImpl __dbusListener;
-static DBusClient __dbusClient;
-
-int ctx::request_handler::subscribe(const char* subject, ctx::CtxJson1* option, int* req_id, ctx::CtxJson1* request_result)
-{
-       return __dbusClient.subscribe(subject, option ? *option : NULL, req_id, request_result);
-}
-
-int ctx::request_handler::unsubscribe(const char* subject, int req_id)
-{
-       return __dbusClient.unsubscribe(subject, req_id);
-}
-
-int ctx::request_handler::read(const char* subject, ctx::CtxJson1* option, int* req_id, ctx::CtxJson1* request_result)
-{
-       return __dbusClient.read(subject, option ? *option : NULL, req_id, request_result);
-}
-
-int ctx::request_handler::read_sync(const char* subject, ctx::CtxJson1* option, int* req_id, ctx::CtxJson1* data_read)
-{
-       return __dbusClient.readSync(subject, option ? *option : NULL, req_id, data_read);
-}
-
-int ctx::request_handler::write(const char* subject, ctx::CtxJson1* data)
-{
-       return __dbusClient.write(subject, *data);
-}
-
-int ctx::request_handler::write_with_reply(const char* subject, ctx::CtxJson1* data, ctx::CtxJson1* request_result)
-{
-       return __dbusClient.write(subject, *data, request_result);
-}
-
-int ctx::request_handler::is_supported(const char* subject)
-{
-       return __dbusClient.isSupported(subject);
-}
-
-int ctx::request_handler::call(const char* method)
-{
-       return __dbusClient.call(method);
-}
-
-bool ctx::request_handler::register_callback(const char* subject, subject_response_cb callback)
-{
-       __dbusListener.setCb(subject, callback);
-       __dbusClient.addListener(subject, &__dbusListener);
-       return true;
-}
diff --git a/testsuite/src/trigger/request_handler.h b/testsuite/src/trigger/request_handler.h
deleted file mode 100644 (file)
index 9a91338..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2015 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_LIB_REQUEST_HANDLER_H__
-#define __CONTEXT_LIB_REQUEST_HANDLER_H__
-
-#include <CtxJson1.h>
-
-namespace ctx { namespace request_handler {
-
-       /*
-        */
-       typedef void(* subject_response_cb)(const char* subject, int req_id, int error, ctx::CtxJson1 response);
-
-       /*
-        */
-       bool register_callback(const char* subject, subject_response_cb callback);
-
-       /*
-        */
-       int subscribe(const char* subject, ctx::CtxJson1* option, int* req_id, ctx::CtxJson1* request_result = NULL);
-
-       /*
-        */
-       int unsubscribe(const char* subject, int req_id);
-
-       /*
-        */
-       int read(const char* subject, ctx::CtxJson1* option, int* req_id, ctx::CtxJson1* request_result = NULL);
-
-       /*
-        */
-       int read_sync(const char* subject, ctx::CtxJson1* option, int* req_id, ctx::CtxJson1* data_read);
-
-       /*
-        */
-       int write(const char* subject, ctx::CtxJson1* data);
-
-       /*
-        */
-       int write_with_reply(const char* subject, ctx::CtxJson1* data, ctx::CtxJson1* request_result = NULL);
-
-       /*
-        */
-       int is_supported(const char* subject);
-
-       int call(const char* method);
-
-} }    /* namespace ctx::request_handler */
-
-#endif // __CONTEXT_LIB_REQUEST_HANDLER_H__