%manifest %{name}.manifest
%{modes_plugin_dir}/*test.so
%{modes_test_dir}/modes-gtest-*
-%{modes_test_dir}/modes-apply-mode-test
+%{modes_test_dir}/modes-mode-test
%{modes_data_dir}/mode/*
%{modes_data_dir}/rule/*
%{modes_test_dir}/*.xml
std::string getStringOfValue()
{
- std::string val;
std::ostringstream ostr;
ostr << value;
- val = ostr.str();
- return val;
+ return ostr.str();
}
int setValue(const std::string &val) override
TARGET_LINK_LIBRARIES(${GTEST_CLIENT} ${CLIENT} ${gtest_pkgs_LIBRARIES})
INSTALL(TARGETS ${GTEST_CLIENT} DESTINATION ${TEST_INSTALL_DIR})
#=======================================================================================#
-SET(TEST_APPLY_MODE "modes-apply-mode-test")
-SET(TEST_APPLY_MODE_SRC modes_apply_mode.c)
+SET(TEST_APPLY_MODE "modes-mode-test")
+SET(TEST_APPLY_MODE_SRC modes_mode_test.c)
ADD_EXECUTABLE(${TEST_APPLY_MODE} ${TEST_APPLY_MODE_SRC})
TARGET_LINK_LIBRARIES(${TEST_APPLY_MODE} ${CLIENT})
INSTALL(TARGETS ${TEST_APPLY_MODE} DESTINATION ${TEST_INSTALL_DIR})
+++ /dev/null
-/*
- * Copyright (c) 2019 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 <glib.h>
-#include <modes.h>
-
-#ifndef MDS_STDOUT
-#define MDS_STDOUT
-#endif
-#include "common/log.h"
-
-static GMainLoop *t_apply_loop;
-
-static gboolean request_idler(gpointer data)
-{
- int ret = modes_apply_mode(data);
- if (MODES_ERROR_NONE != ret)
- ERR("modes_apply_mode() Fail(%d)", ret);
-
- g_main_loop_quit(t_apply_loop);
- return G_SOURCE_REMOVE;
-}
-
-int main(int argc, char **argv)
-{
- if (2 != argc) {
- ERR("Usage) %s ModeName", argv[0]);
- return -1;
- }
-
- t_apply_loop = g_main_loop_new(NULL, FALSE);
- g_idle_add(request_idler, argv[1]);
-
- g_main_loop_run(t_apply_loop);
-
- g_main_loop_unref(t_apply_loop);
- return 0;
-}
--- /dev/null
+/*
+ * Copyright (c) 2019 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 <glib.h>
+#include <modes.h>
+
+#ifndef MDS_STDOUT
+#define MDS_STDOUT
+#endif
+#include "common/log.h"
+
+static GMainLoop *_modes_loop;
+
+#define PRINT(fmt, arg...) printf("\033[31m %d:" fmt "\n \033[0m", __LINE__, ##arg)
+
+static gboolean apply_idler(gpointer data)
+{
+ int ret = modes_apply_mode(data);
+ if (MODES_ERROR_NONE != ret)
+ PRINT("modes_apply_mode() Fail(%d)", ret);
+
+ g_main_loop_quit(_modes_loop);
+ return G_SOURCE_REMOVE;
+}
+
+static gboolean undo_idler(gpointer data)
+{
+ int ret = modes_undo_mode(data);
+ if (MODES_ERROR_NONE != ret)
+ PRINT("modes_undo_mode() Fail(%d)", ret);
+
+ g_main_loop_quit(_modes_loop);
+ return G_SOURCE_REMOVE;
+}
+
+static void print_usage(const char *exec_name)
+{
+ printf("Usage)\n");
+ printf("\t%s apply ModeName\n", exec_name);
+ printf("\t%s undo ModeName\n", exec_name);
+}
+
+int main(int argc, char **argv)
+{
+ if (3 != argc) {
+ print_usage(argv[0]);
+ return -1;
+ }
+
+ _modes_loop = g_main_loop_new(NULL, FALSE);
+ if (0 == strcasecmp(argv[1], "apply")) {
+ g_idle_add(apply_idler, argv[1]);
+ } else if (0 == strcasecmp(argv[1], "undo")) {
+ g_idle_add(undo_idler, argv[1]);
+ } else {
+ PRINT("Invalid option(%s)", argv[1]);
+ print_usage(argv[0]);
+ }
+
+ g_main_loop_run(_modes_loop);
+
+ g_main_loop_unref(_modes_loop);
+ return 0;
+}
TEST_F(ClientTest, applyModeP)
{
+ modes_undo_mode("ex1");
g_idle_add(applyModeIdler, (gpointer)"ex1");
g_main_loop_run(loop);
EXPECT_EQ(MODES_ERROR_NONE, result);