add scenario
authorYoungjae Shin <yj99.shin@samsung.com>
Sun, 26 May 2019 23:47:11 +0000 (08:47 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Wed, 18 Mar 2020 08:53:50 +0000 (17:53 +0900)
example/tizen_action_schema.xml
example/tizen_powerSave_mode.xml [new file with mode: 0644]
example/tizen_wifiOn_mode.xml [new file with mode: 0644]
packaging/modes.spec
unittest/CMakeLists.txt
unittest/modes_apply_mode.c [new file with mode: 0644]
unittest/modes_test_client.cpp

index 9de399e..c8d664c 100644 (file)
       <desc>test</desc>
       <domain>System</domain>
     </action>
+    <action name="vconf.db.bluetooth.status" type="int" since="5.5" plugin="vconf">
+      <alias name="VCONFKEY_BT_STATUS_OFF">0</alias>
+      <alias name="VCONFKEY_BT_STATUS_ON">1</alias>
+      <alias name="VCONFKEY_BT_STATUS_BT_VISIBLE">2</alias>
+      <alias name="VCONFKEY_BT_STATUS_TRANSFER">4</alias>
+      <defaultVal>0</defaultVal>
+      <desc>test</desc>
+      <domain>Network &amp; Connectivity</domain>
+    </action>
     <action name="browser.url" type="string" since="5.5" plugin="web">
       <defaultVal>about:blank</defaultVal>
       <desc>browser</desc>
diff --git a/example/tizen_powerSave_mode.xml b/example/tizen_powerSave_mode.xml
new file mode 100644 (file)
index 0000000..a5df75c
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<tizenModes xmlns="http://www.tizen.org" version="5.5">
+  <mode name="powerSave" type="exclusive">
+    <req action="vconf.db.setting.psmode">SETTING_PSMODE_WEARABLE_ENHANCED</req>
+    <req action="vconf.db.bluetooth.status">VCONFKEY_BT_STATUS_OFF</req>
+  </mode>
+</tizenModes>
diff --git a/example/tizen_wifiOn_mode.xml b/example/tizen_wifiOn_mode.xml
new file mode 100644 (file)
index 0000000..56b4205
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<tizenModes xmlns="http://www.tizen.org" version="5.5">
+  <mode name="wifiOn" type="exclusive">
+    <req action="wifi.power">on</req>
+  </mode>
+</tizenModes>
index 7fc5bb0..c5e2362 100644 (file)
@@ -148,3 +148,4 @@ rm -rf %{modes_test_dir}/*.xml %{modes_test_dir}/*.xsd %{modes_test_dir}/extra
 %manifest %{name}.manifest
 %license LICENSE.APLv2
 %{modes_test_dir}/modes-gtest-*
+%{modes_test_dir}/modes-apply-mode-test
index 8cc9c28..a2a365f 100644 (file)
@@ -61,26 +61,14 @@ INSTALL(TARGETS ${GTEST_PARSER} DESTINATION ${TEST_INSTALL_DIR})
 
 #=======================================================================================#
 SET(GTEST_CLIENT "modes-gtest-client")
-SET(GTEST_CLIENT_SRCS
-               ${SUPERVISOR_DIR}/XMLParser.cpp
-               ${SUPERVISOR_DIR}/ModeManager.cpp
-               ${SUPERVISOR_DIR}/ModeXMLParser.cpp
-               ${SUPERVISOR_DIR}/Req.cpp
-               ${SUPERVISOR_DIR}/ActionSchema.cpp
-               ${SUPERVISOR_DIR}/ActionSchemaManager.cpp
-               ${SUPERVISOR_DIR}/Mode.cpp
-               ${SUPERVISOR_DIR}/ModesEx.cpp
-               ${SUPERVISOR_DIR}/PluginManager.cpp
-               ${SUPERVISOR_DIR}/Supervisor.cpp
-               ${SUPERVISOR_DIR}/ArgumentParser.cpp
-               ${SUPERVISOR_DIR}/RequestHandler.cpp
-               ${SUPERVISOR_DIR}/ClientConnection.cpp
-               ${CMAKE_SOURCE_DIR}/client/mdsc.c
-               ${CMAKE_SOURCE_DIR}/common/dbus.c
-               "modes_test_client.cpp"
-       )
+SET(GTEST_CLIENT_SRCS "modes_test_client.cpp")
 ADD_EXECUTABLE(${GTEST_CLIENT} ${SRC} ${GTEST_CLIENT_SRCS})
-ADD_DEPENDENCIES(${GTEST_CLIENT} GENERATED_DBUS_CODE)
-TARGET_LINK_LIBRARIES(${GTEST_CLIENT} ${gtest_pkgs_LIBRARIES} dl)
+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")
+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})
diff --git a/unittest/modes_apply_mode.c b/unittest/modes_apply_mode.c
new file mode 100644 (file)
index 0000000..d0ae8d5
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * 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>
+
+#define MDS_STDOUT
+#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;
+}
index daa027a..5634d2e 100644 (file)
  */
 #include <glib.h>
 #include <gtest/gtest.h>
-#include "modes.h"
-#include "supervisor/Supervisor.h"
-
-MODES_NAMESPACE_USE;
+#include <modes.h>
 
 class ClientTest : public ::testing::Test {
 protected: