From: JinWang An Date: Wed, 29 Apr 2020 03:55:11 +0000 (+0900) Subject: Insert delete mode X-Git-Tag: submit/tizen/20200513.090930~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3cc6a3b28008974ef3f05954a441da85c2186c4d;p=platform%2Fcore%2Fsystem%2Fmodes.git Insert delete mode --- diff --git a/client/mdsc_insert_del_mode.c b/client/mdsc_insert_del_mode.c new file mode 100644 index 0000000..b2cdfb1 --- /dev/null +++ b/client/mdsc_insert_del_mode.c @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2019-2020 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 "modes.h" + +#include +#include +#include "mdsc.h" +#include "common/dbus.h" +#include "common/dbus_def.h" + +struct mds_action_handle { + char *id; + char *rule; + char *value; +}; + +struct mds_mode_handle { + char *name; + modes_type_mode_e type; + bool hidden; + GList *action_list; +}; + +static int _mdsc_dbus_add_mode_sync(mdsDbus *mdsc_dbus, GVariant *mode_data) +{ + int result = MODES_ERROR_NONE; + gboolean ret; + GError *error = NULL; + + RETV_IF(NULL == mode_data, MODES_ERROR_INVALID_PARAMETER); + + ret = mds_dbus_call_add_mode_sync(mdsc_dbus, mode_data, &result, NULL, &error); + if (FALSE == ret) { + ERR("mds_dbus_call_add_mode_sync() Fail(%s)", error ? error->message : "unknown"); + g_error_free(error); + return MODES_ERROR_SYSTEM; + } + + return result; +} + +static int _mdsc_dbus_remove_mode_sync(mdsDbus *mdsc_dbus, const char *mode) +{ + int result = MODES_ERROR_NONE; + gboolean ret; + GError *error = NULL; + + RETV_IF(NULL == mode, MODES_ERROR_INVALID_PARAMETER); + + ret = mds_dbus_call_remove_mode_sync(mdsc_dbus, mode, &result, NULL, &error); + if (FALSE == ret) { + ERR("mds_dbus_call_remove_mode_sync() Fail(%s)", error ? error->message : "unknown"); + g_error_free(error); + return MODES_ERROR_SYSTEM; + } + + return result; +} + +static void _mdsc_free_action(gpointer data) +{ + RET_IF(NULL == data); + + struct mds_action_handle *action_data = data; + + free(action_data->id); + free(action_data->rule); + free(action_data->value); + free(action_data); +} + +static GVariant* _mdsc_create_mode_data(modes_mode_h mode) +{ + RETV_IF(NULL == mode, NULL); + + GVariantBuilder *action_builder = g_variant_builder_new(G_VARIANT_TYPE(MODES_DBUS_ACTION_LIST_SIG)); + GList *it = g_list_first(mode->action_list); + + while (NULL != it) { + struct mds_action_handle *action_data = (struct mds_action_handle *)it->data; + g_variant_builder_add(action_builder, MODES_DBUS_ACTION_SIG, MODES_DBUS_SAFE_STR(action_data->id), + MODES_DBUS_SAFE_STR(action_data->rule), MODES_DBUS_SAFE_STR(action_data->value)); + it = g_list_next(it); + } + + GVariant *action = g_variant_new(MODES_DBUS_ACTION_LIST_SIG, action_builder); + GVariant *mode_data = g_variant_new(MODES_DBUS_MODE_SIG, mode->name, mode->type, mode->hidden, action); + g_variant_builder_unref(action_builder); + + return mode_data; +} + +API modes_mode_h modes_create_mode(const char *name, modes_type_mode_e type) +{ + struct mds_mode_handle *mode; + + RETV_IF(NULL == name, NULL); + + mode = malloc(sizeof(struct mds_mode_handle)); + RETV_IF(NULL == mode, NULL); + + mode->name = strdup(name); + mode->type = type; + mode->hidden = false; + mode->action_list = NULL; + + return mode; +} + +API int modes_set_hidden(modes_mode_h mode, bool hidden) +{ + RETV_IF(NULL == mode, MODES_ERROR_INVALID_PARAMETER); + + mode->hidden = hidden; + + return MODES_ERROR_NONE; +} + +API modes_action_h modes_create_action(const char *name, const char *value) +{ + struct mds_action_handle *action; + + RETV_IF(NULL == name, NULL); + RETV_IF(NULL == value, NULL); + + action = malloc(sizeof(struct mds_action_handle)); + RETV_IF(NULL == action, NULL); + + action->rule = strdup(name); + action->value = strdup(value); + action->id = NULL; + + return action; +} + +API int modes_mode_add_action(modes_mode_h mode, modes_action_h action) +{ + RETV_IF(NULL == mode, MODES_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == action, MODES_ERROR_INVALID_PARAMETER); + + mode->action_list = g_list_append(mode->action_list, action); + + return MODES_ERROR_NONE; +} + +API int modes_add_mode(modes_h handle, modes_mode_h mode) +{ + int ret; + + RETV_IF(NULL == handle, MODES_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == mode, MODES_ERROR_INVALID_PARAMETER); + + GVariant *mode_data = _mdsc_create_mode_data(mode); + RETV_IF(NULL == mode_data, MODES_ERROR_INVALID_PARAMETER); + + ret = _mdsc_dbus_add_mode_sync(handle->conn, mode_data); + if (MODES_ERROR_NONE != ret) { + ERR("_mdsc_dbus_add_mode_sync() Fail(%d)", ret); + return ret; + } + + return MODES_ERROR_NONE; +} + +API int modes_remove_mode(modes_h handle, const char *name) +{ + int ret; + RETV_IF(NULL == handle, MODES_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == name, MODES_ERROR_INVALID_PARAMETER); + + ret = _mdsc_dbus_remove_mode_sync(handle->conn, name); + if (MODES_ERROR_NONE != ret) { + ERR("_mdsc_dbus_remove_mode_sync() Fail(%d)", ret); + return ret; + } + + return MODES_ERROR_NONE; +} + +API void modes_destroy_mode(modes_mode_h mode) +{ + RET_IF(NULL == mode); + + free(mode->name); + + g_list_free_full(mode->action_list, _mdsc_free_action); + + free(mode); +} + diff --git a/client/mdsc_register_mode.c b/client/mdsc_register_mode.c deleted file mode 100644 index e630063..0000000 --- a/client/mdsc_register_mode.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2019-2020 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 "modes.h" - -#include -#include -#include "mdsc.h" -#include "common/dbus.h" -#include "common/dbus_def.h" - -struct mds_action_handle { - char *id; - char *rule; - char *value; -}; - -struct mds_mode_handle { - char *name; - modes_type_mode_e type; - bool hidden; - GList *action_list; -}; - -static int _mdsc_dbus_register_mode_sync(mdsDbus *mdsc_dbus, GVariant *mode_data) -{ - int result = MODES_ERROR_NONE; - gboolean ret; - GError *error = NULL; - - RETV_IF(NULL == mode_data, MODES_ERROR_INVALID_PARAMETER); - - ret = mds_dbus_call_register_mode_sync(mdsc_dbus, mode_data, &result, NULL, &error); - if (FALSE == ret) { - ERR("mds_dbus_call_register_mode_sync() Fail(%s)", error ? error->message : "unknown"); - g_error_free(error); - return MODES_ERROR_SYSTEM; - } - - return result; -} - -static void _mdsc_free_action(gpointer data) -{ - RET_IF(NULL == data); - - struct mds_action_handle *action_data = data; - - free(action_data->id); - free(action_data->rule); - free(action_data->value); - free(action_data); -} - -static GVariant* _mdsc_create_mode_data(modes_mode_h mode) -{ - RETV_IF(NULL == mode, NULL); - - GVariantBuilder *action_builder = g_variant_builder_new(G_VARIANT_TYPE(MODES_DBUS_ACTION_LIST_SIG)); - GList *it = g_list_first(mode->action_list); - - while (NULL != it) { - struct mds_action_handle *action_data = (struct mds_action_handle *)it->data; - g_variant_builder_add(action_builder, MODES_DBUS_ACTION_SIG, MODES_DBUS_SAFE_STR(action_data->id), - MODES_DBUS_SAFE_STR(action_data->rule), MODES_DBUS_SAFE_STR(action_data->value)); - it = g_list_next(it); - } - - GVariant *action = g_variant_new(MODES_DBUS_ACTION_LIST_SIG, action_builder); - GVariant *mode_data = g_variant_new(MODES_DBUS_MODE_SIG, mode->name, mode->type, mode->hidden, action); - g_variant_builder_unref(action_builder); - - return mode_data; -} - -API modes_mode_h modes_create_mode(const char *name, modes_type_mode_e type) -{ - struct mds_mode_handle *mode; - - RETV_IF(NULL == name, NULL); - - mode = malloc(sizeof(struct mds_mode_handle)); - RETV_IF(NULL == mode, NULL); - - mode->name = strdup(name); - mode->type = type; - mode->hidden = false; - mode->action_list = NULL; - - return mode; -} - -API int modes_set_hidden(modes_mode_h mode, bool hidden) -{ - RETV_IF(NULL == mode, MODES_ERROR_INVALID_PARAMETER); - - mode->hidden = hidden; - - return MODES_ERROR_NONE; -} - -API modes_action_h modes_create_action(const char *name, const char *value) -{ - struct mds_action_handle *action; - - RETV_IF(NULL == name, NULL); - RETV_IF(NULL == value, NULL); - - action = malloc(sizeof(struct mds_action_handle)); - RETV_IF(NULL == action, NULL); - - action->rule = strdup(name); - action->value = strdup(value); - action->id = NULL; - - return action; -} - -API int modes_mode_add_action(modes_mode_h mode, modes_action_h action) -{ - RETV_IF(NULL == mode, MODES_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == action, MODES_ERROR_INVALID_PARAMETER); - - mode->action_list = g_list_append(mode->action_list, action); - - return MODES_ERROR_NONE; -} - -API int modes_register_mode(modes_h handle, modes_mode_h mode) -{ - int ret; - - RETV_IF(NULL == handle, MODES_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == mode, MODES_ERROR_INVALID_PARAMETER); - - GVariant *mode_data = _mdsc_create_mode_data(mode); - RETV_IF(NULL == mode_data, MODES_ERROR_INVALID_PARAMETER); - - ret = _mdsc_dbus_register_mode_sync(handle->conn, mode_data); - if (MODES_ERROR_NONE != ret) { - ERR("_mdsc_bus_client_change_mode_sync() Fail(%d)", ret); - return ret; - } - - return MODES_ERROR_NONE; -} - -API void modes_destroy_mode(modes_mode_h mode) -{ - RET_IF(NULL == mode); - - free(mode->name); - - g_list_free_full(mode->action_list, _mdsc_free_action); - - free(mode); -} - diff --git a/common/dbus.xml b/common/dbus.xml index 683a1ac..15e8abf 100644 --- a/common/dbus.xml +++ b/common/dbus.xml @@ -12,10 +12,14 @@ - + + + + + diff --git a/include/modes.h b/include/modes.h index 1b27f88..e2675ef 100644 --- a/include/modes.h +++ b/include/modes.h @@ -169,20 +169,20 @@ modes_action_h modes_create_action(const char *rule, const char *value); int modes_mode_add_action(modes_mode_h mode, modes_action_h action); /** - * @brief Register Mode. - * @details Calls this function to register mode. + * @brief Add Mode. + * @details Calls this function to add mode. * @since_tizen 6.0 * @privlevel platform * @privilege http://tizen.org/privilege/systemsettings.admin * @param[in] Handle of modes server - * @param[in] Mode handle to register + * @param[in] Mode handle to add * @return @c 0 on success, * otherwise a negative error value * @retval #MODES_ERROR_NONE Successful * @retval #MODES_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MODES_ERROR_SYSTEM System errors */ -int modes_register_mode(modes_h handle, modes_mode_h mode); +int modes_add_mode(modes_h handle, modes_mode_h mode); /** * @brief Destroy Mode handle @@ -194,6 +194,23 @@ int modes_register_mode(modes_h handle, modes_mode_h mode); */ void modes_destroy_mode(modes_mode_h mode); +/** + * @brief Remove Mode. + * @details Calls this function to remove mode. + * @since_tizen 6.0 + * @privlevel platform + * @privilege http://tizen.org/privilege/systemsettings.admin + * @param[in] Handle of modes server + * @param[in] Mode name to be removed + * @return @c 0 on success, + * otherwise a negative error value + * @retval #MODES_ERROR_NONE Successful + * @retval #MODES_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MODES_ERROR_CONFLICT Try to remove applied mode. + * @retval #MODES_ERROR_SYSTEM System errors + */ +int modes_remove_mode(modes_h handle, const char *name); + /** * @brief Adds callback for recognizing the changed of mode. * @details Sets a function to be called when the mode is changed. diff --git a/supervisor/ModeManager.cpp b/supervisor/ModeManager.cpp index d9f8d2f..873c663 100644 --- a/supervisor/ModeManager.cpp +++ b/supervisor/ModeManager.cpp @@ -127,9 +127,9 @@ int ModeManager::applyMode(const string &modeName, ClientPrivilege &priv, bool i return MODES_ERROR_NONE; } -int ModeManager::registerMode(const Mode &mode) +int ModeManager::addMode(const Mode &mode) { - string filename; + string filename = MODES_CUSTOM_MODE_DEFAULT_DIR "/tizen_" + mode.getName() + "_mode.xml"; XMLGenerator xmlWriter; auto element = std::make_pair(mode.getName(), std::make_tuple(filename, mode.getModeType(), false)); @@ -140,7 +140,6 @@ int ModeManager::registerMode(const Mode &mode) } try { - filename = MODES_CUSTOM_MODE_DEFAULT_DIR "/tizen_" + mode.getName() + "_mode.xml"; xmlWriter.makeModeXML(filename, mode); } catch (ModesEx &e) { ERR("XML generator Fail(%s)", e.what()); @@ -148,7 +147,37 @@ int ModeManager::registerMode(const Mode &mode) return MODES_ERROR_INVALID_PARAMETER; } - DBG("[%zu] Register modeName : %s, modePath : %s, type : %d, hidden : false", modeMap.size(), mode.getName().c_str(), filename.c_str(), mode.getModeType()); + DBG("[%zu] addMode modeName : %s, modePath : %s, type : %d, hidden : false", modeMap.size(), mode.getName().c_str(), filename.c_str(), mode.getModeType()); + + return MODES_ERROR_NONE; +} + +int ModeManager::removeMode(const string &modeName) +{ + if (true == careTaker.isSavedMode(modeName)) { + ERR("Mode(%s) is applied.", modeName.c_str()); + return MODES_ERROR_CONFLICT; + } + + auto result = modeMap.find(modeName); + if (result == modeMap.end()) { + ERR("Invalid mode(%s), not found", modeName.c_str()); + return MODES_ERROR_INVALID_PARAMETER; + } + + string filename = std::get<0>(result->second); + if (string::npos == filename.find(MODES_CUSTOM_MODE_DEFAULT_DIR)) + { + ERR("Invalid mode(%s), custom mode only can be removed.", modeName.c_str()); + return MODES_ERROR_INVALID_PARAMETER; + } + + modeMap.erase(result); + + if (0 != remove(filename.c_str())) + ERR("remove(%s) Fail(%d)", filename.c_str(), errno); + + DBG("[%zu] Remove modeName : %s, modePath : %s", modeMap.size(), modeName.c_str(), filename.c_str()); return MODES_ERROR_NONE; } diff --git a/supervisor/ModeManager.h b/supervisor/ModeManager.h index 5ba709e..57af4ac 100644 --- a/supervisor/ModeManager.h +++ b/supervisor/ModeManager.h @@ -34,7 +34,8 @@ public: void init(); void addModeDirectory(const std::string &dirPath); int applyMode(const std::string &modeName, ClientPrivilege &priv, bool isTest); - int registerMode(const Mode &mode); + int addMode(const Mode &mode); + int removeMode(const std::string &modeName); int undoMode(const std::string &modeName); int undoMode(const std::string &modeName, ClientPrivilege &priv); std::list> getModes(); diff --git a/supervisor/RequestHandler.cpp b/supervisor/RequestHandler.cpp index 5dd5a01..f58e8f6 100644 --- a/supervisor/RequestHandler.cpp +++ b/supervisor/RequestHandler.cpp @@ -93,7 +93,7 @@ gboolean RequestHandler::undoModeHandler(mdsDbus *object, GDBusMethodInvocation return TRUE; } -gboolean RequestHandler::registerModeHandler(mdsDbus *object, GDBusMethodInvocation *invocation, +gboolean RequestHandler::addModeHandler(mdsDbus *object, GDBusMethodInvocation *invocation, GVariant *modeData, gpointer userData) { RETV_IF(NULL == modeMgr, FALSE); @@ -101,10 +101,10 @@ gboolean RequestHandler::registerModeHandler(mdsDbus *object, GDBusMethodInvocat try { Mode mode = getModefromData(modeData); - int ret = modeMgr->registerMode(mode); - mds_dbus_complete_register_mode(object, invocation, ret); + int ret = modeMgr->addMode(mode); + mds_dbus_complete_add_mode(object, invocation, ret); } catch (ModesEx &e) { - mds_dbus_complete_register_mode(object, + mds_dbus_complete_add_mode(object, invocation, MODES_ERROR_INVALID_PARAMETER); } @@ -114,6 +114,18 @@ gboolean RequestHandler::registerModeHandler(mdsDbus *object, GDBusMethodInvocat return TRUE; } +gboolean RequestHandler::removeModeHandler(mdsDbus *object, GDBusMethodInvocation *invocation, + const gchar *modeName, gpointer userData) +{ + RETV_IF(NULL == modeMgr, FALSE); + RETV_IF(NULL == modeName, FALSE); + + int ret = modeMgr->removeMode(modeName); + mds_dbus_complete_remove_mode(object, invocation, ret); + + return TRUE; +} + gboolean RequestHandler::getModesHandler(mdsDbus *object, GDBusMethodInvocation *invocation, gpointer userData) { int ret = MODES_ERROR_NONE; diff --git a/supervisor/RequestHandler.h b/supervisor/RequestHandler.h index c302b61..bef677e 100644 --- a/supervisor/RequestHandler.h +++ b/supervisor/RequestHandler.h @@ -30,8 +30,10 @@ public: const gchar *modeName, gpointer userData); static gboolean undoModeHandler(mdsDbus * object, GDBusMethodInvocation *invocation, const gchar *modeName, gpointer userData); - static gboolean registerModeHandler(mdsDbus *object, GDBusMethodInvocation *invocation, + static gboolean addModeHandler(mdsDbus *object, GDBusMethodInvocation *invocation, GVariant *arg_modeData, gpointer userData); + static gboolean removeModeHandler(mdsDbus *object, GDBusMethodInvocation *invocation, + const gchar *modeName, gpointer userData); static gboolean getModesHandler(mdsDbus *object, GDBusMethodInvocation *invocation, gpointer userData); diff --git a/supervisor/Supervisor.cpp b/supervisor/Supervisor.cpp index e2b7fe8..1b01890 100644 --- a/supervisor/Supervisor.cpp +++ b/supervisor/Supervisor.cpp @@ -61,6 +61,7 @@ void Supervisor::registerHandler() clientConn.addRequestHandler("handle-can-apply", (GCallback)&RequestHandler::canApplyModeHandler); clientConn.addRequestHandler("handle-apply-mode", (GCallback)&RequestHandler::applyModeHandler); clientConn.addRequestHandler("handle-undo-mode", (GCallback)&RequestHandler::undoModeHandler); - clientConn.addRequestHandler("handle-register-mode", (GCallback)&RequestHandler::registerModeHandler); + clientConn.addRequestHandler("handle-add-mode", (GCallback)&RequestHandler::addModeHandler); + clientConn.addRequestHandler("handle-remove-mode", (GCallback)&RequestHandler::removeModeHandler); clientConn.addRequestHandler("handle-get-modes", (GCallback)&RequestHandler::getModesHandler); } diff --git a/supervisor/org.tizen.modes.dbus.conf.in b/supervisor/org.tizen.modes.dbus.conf.in index d64aa31..e35958a 100644 --- a/supervisor/org.tizen.modes.dbus.conf.in +++ b/supervisor/org.tizen.modes.dbus.conf.in @@ -17,7 +17,8 @@ - + + diff --git a/unittest/modes_test_client.cpp b/unittest/modes_test_client.cpp index 4784f46..23acfa4 100644 --- a/unittest/modes_test_client.cpp +++ b/unittest/modes_test_client.cpp @@ -19,8 +19,6 @@ #include #include "common/definitions.h" -#define CREATED_MODE_NAME "created" - class ClientTest : public ::testing::Test { protected: void SetUp() override @@ -39,7 +37,7 @@ protected: static gboolean applyModeIdler(gpointer data) { - result = modes_apply_mode(handle, (const char*)data); + result = modes_apply_mode(handle, (char*)data); g_main_loop_quit(loop); return G_SOURCE_REMOVE; @@ -47,18 +45,18 @@ protected: static gboolean undoModeIdler(gpointer data) { - result = modes_apply_mode(handle, (const char*)data); + result = modes_apply_mode(handle, (char*)data); EXPECT_EQ(MODES_ERROR_NONE, result); sleep(1); - result = modes_undo_mode(handle, (const char*)data); + result = modes_undo_mode(handle, (char*)data); g_main_loop_quit(loop); return G_SOURCE_REMOVE; } - static gboolean registerModeIdler(gpointer data) + static void addModeTest(gpointer data) { - modes_mode_h created_mode = modes_create_mode(CREATED_MODE_NAME, MODES_TYPE_MODE_NORMAL); + modes_mode_h created_mode = modes_create_mode((char*)data, MODES_TYPE_MODE_NORMAL); modes_action_h action_handle[2]; action_handle[0] = modes_create_action("test.printBool", "on"); action_handle[1] = modes_create_action("test.printBool", "off"); @@ -71,8 +69,34 @@ protected: result = modes_set_hidden(created_mode, true); EXPECT_EQ(MODES_ERROR_NONE, result); - result = modes_register_mode(handle, created_mode); + result = modes_add_mode(handle, created_mode); modes_destroy_mode(created_mode); + EXPECT_EQ(MODES_ERROR_NONE, result); + + result = modes_apply_mode(handle, (char*)data); + EXPECT_EQ(MODES_ERROR_NONE, result); + } + + static gboolean addModeIdler(gpointer data) + { + addModeTest(data); + modes_undo_mode(handle, (char*)data); + modes_remove_mode(handle, (char*)data); + g_main_loop_quit(loop); + + return G_SOURCE_REMOVE; + } + + static gboolean removeModeIdler(gpointer data) + { + addModeTest(data); + + result = modes_remove_mode(handle, (char*)data); + EXPECT_EQ(MODES_ERROR_CONFLICT, result); + + modes_undo_mode(handle, (char*)data); + result = modes_remove_mode(handle, (char*)data); + EXPECT_EQ(MODES_ERROR_NONE, result); g_main_loop_quit(loop); return G_SOURCE_REMOVE; @@ -115,14 +139,21 @@ TEST_F(ClientTest, canApplyModeN) EXPECT_EQ(MODES_ERROR_NO_DATA, ret); } -TEST_F(ClientTest, registerMode) +TEST_F(ClientTest, addMode) { - g_idle_add(registerModeIdler, NULL); + g_idle_add(addModeIdler, (gpointer)"created"); g_main_loop_run(loop); EXPECT_EQ(MODES_ERROR_NONE, result); - if (0 != remove(MODES_CUSTOM_MODE_DEFAULT_DIR "/tizen_" CREATED_MODE_NAME "_mode.xml")) { - std::cout << "remove() Fail :" << MODES_CUSTOM_MODE_DEFAULT_DIR "/tizen_" CREATED_MODE_NAME "_mode.xml" << " errno = " << errno << std::endl; - } +} + +TEST_F(ClientTest, removeMode) +{ + g_idle_add(removeModeIdler, (gpointer)"deltest"); + g_main_loop_run(loop); + EXPECT_EQ(MODES_ERROR_NONE, result); + + int ret = modes_remove_mode(handle, "deltestN"); + EXPECT_EQ(MODES_ERROR_INVALID_PARAMETER, ret); } TEST_F(ClientTest, undoModeEx1) @@ -144,8 +175,8 @@ TEST_F(ClientTest, undoModeEx2) TEST_F(ClientTest, getModes) { const char* const typeList[2] = { - "MODES_TYPE_MODE_NORMAL", - "MODES_TYPE_MODE_ONESHOT" + "MODES_TYPE_MODE_NORMAL", + "MODES_TYPE_MODE_ONESHOT" }; GList *list, *cur;