Separate unittests (to modes-plugin)
authorYoungjae Shin <yj99.shin@samsung.com>
Wed, 2 Oct 2019 06:53:05 +0000 (15:53 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Wed, 18 Mar 2020 08:53:50 +0000 (17:53 +0900)
19 files changed:
Definitions.cmake
example/mode/tizen_btAudioConnect_mode.xml [deleted file]
example/mode/tizen_btOff_mode.xml [deleted file]
example/mode/tizen_btOn_mode.xml [deleted file]
example/mode/tizen_powerSave_mode.xml [deleted file]
example/mode/tizen_waterlock_mode.xml [deleted file]
example/mode/tizen_wifiOn_mode.xml [deleted file]
packaging/modes.spec
plugin/CMakeLists.txt
plugin/TestPluginAction.cpp
supervisor/ModeManager.cpp
supervisor/ModeXMLParser.cpp
unittest/modes-gtest-run.sh
unittest/modes_test_client.cpp
unittest/modes_test_conflict.cpp
unittest/modes_test_generator.cpp
unittest/modes_test_modemgr.cpp
unittest/modes_test_parser.cpp
unittest/modes_test_plugin.cpp

index 8ed490e467e509836faf8f92aaaca8594de127e2..cb432d0c2d0dc3ecbb61fe4c45f636c2e4822f1c 100644 (file)
@@ -18,7 +18,7 @@ ADD_DEFINITIONS("-DMODES_MODE_DEFAULT_DIR=\"${MODES_MODE_DEFAULT_DIR}\"")
 
 IF(NOT DEFINED MODES_CUSTOM_MODE_DEFAULT_DIR)
        MESSAGE("No MODES_CUSTOM_MODE_DEFAULT_DIR. Check build system")
-       SET(MODES_MODE_DEFAULT_DIR "/usr/share/modes/custom-mode")
+       SET(MODES_CUSTOM_MODE_DEFAULT_DIR "/usr/share/modes/custom-mode")
 ENDIF(NOT DEFINED MODES_CUSTOM_MODE_DEFAULT_DIR)
 ADD_DEFINITIONS("-DMODES_CUSTOM_MODE_DEFAULT_DIR=\"${MODES_CUSTOM_MODE_DEFAULT_DIR}\"")
 
diff --git a/example/mode/tizen_btAudioConnect_mode.xml b/example/mode/tizen_btAudioConnect_mode.xml
deleted file mode 100644 (file)
index d45e639..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<tizenModes xmlns="http://www.tizen.org" version="6.0">
-  <mode name="btAudioConnect" type="exclusive">
-    <action rule="bluetooth.power">on</action>
-    <action rule="bluetooth.audioConnect">08:AE:D6:5E:AE:16</action>
-  </mode>
-</tizenModes>
diff --git a/example/mode/tizen_btOff_mode.xml b/example/mode/tizen_btOff_mode.xml
deleted file mode 100644 (file)
index 0c29375..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<tizenModes xmlns="http://www.tizen.org" version="6.0">
-  <mode name="btOff" type="exclusive">
-    <action rule="bluetooth.power">off</action>
-  </mode>
-</tizenModes>
diff --git a/example/mode/tizen_btOn_mode.xml b/example/mode/tizen_btOn_mode.xml
deleted file mode 100644 (file)
index 14ee9e2..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<tizenModes xmlns="http://www.tizen.org" version="6.0">
-  <mode name="btOn" type="exclusive">
-    <action rule="bluetooth.power">on</action>
-  </mode>
-</tizenModes>
diff --git a/example/mode/tizen_powerSave_mode.xml b/example/mode/tizen_powerSave_mode.xml
deleted file mode 100644 (file)
index 5ece2f8..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<tizenModes xmlns="http://www.tizen.org" version="6.0">
-  <mode name="powerSave" type="exclusive">
-    <action rule="vconf.db.setting.psmode">SETTING_PSMODE_WEARABLE_ENHANCED</action>
-    <action rule="vconf.db.bluetooth.status">VCONFKEY_BT_STATUS_OFF</action>
-  </mode>
-</tizenModes>
diff --git a/example/mode/tizen_waterlock_mode.xml b/example/mode/tizen_waterlock_mode.xml
deleted file mode 100644 (file)
index f4bac82..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<tizenModes xmlns="http://www.tizen.org" version="6.0">
-  <mode name="waterlock" type="exclusive">
-    <action rule="bluetooth.power">off</action>
-    <action ID="wifiOff" rule="wifi.power" restrict="lock" priority="-100">off</action>
-    <action ID="1" rule="vconf.db.setting.psmode" restrict="lock" priority="-100">SETTING_PSMODE_WEARABLE_ENHANCED</action>
-    <undo ID="2" rule="vconf.db.setting.psmode" restrict="lock" priority="-100">SETTING_PSMODE_WEARABLE</undo>
-    <undo ID="3" rule="media.player">/opt/usr/data/settings/Alarms/Alarms_on_call.ogg</undo>
-  </mode>
-</tizenModes>
diff --git a/example/mode/tizen_wifiOn_mode.xml b/example/mode/tizen_wifiOn_mode.xml
deleted file mode 100644 (file)
index 0491aad..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<tizenModes xmlns="http://www.tizen.org" version="6.0">
-  <mode name="wifiOn" type="exclusive">
-    <action rule="wifi.power">on</action>
-  </mode>
-</tizenModes>
index 763c2ff816fe127f6348877c3b03b0af00a54291..0112a1427921ae636bb5257412773054ac9223a9 100644 (file)
@@ -52,7 +52,6 @@ developing plugin libararies that is used by %{name}.
 %package unittests
 Summary: Test Programs for %{name}
 Group: System/Testing
-Requires: %{name}-lib = %{version}
 
 %description unittests
 The %{name}-unittests pacakge contains programs for checking quality the %{name}.
@@ -95,10 +94,13 @@ make %{?_smp_mflags}
 %install
 %make_install
 install -d -m 755 %{buildroot}%{modes_data_dir}/mode
-install -d -m 755 %{buildroot}%{modes_data_dir}/custom-mode
 install -d -m 755 %{buildroot}%{modes_data_dir}/rule
-install -m 0644 example/mode/*_mode.xml %{buildroot}%{modes_data_dir}/mode/
-install -m 0644 example/rule/*_rule.xml %{buildroot}%{modes_data_dir}/rule/
+install -d -m 755 %{buildroot}%{modes_data_dir}/custom-mode
+install -m 0644 example/mode/*ex*_mode.xml %{buildroot}%{modes_data_dir}/mode/
+install -m 0644 example/rule/*ex*_rule.xml %{buildroot}%{modes_data_dir}/rule/
+install -m 0644 example/mode/*conflict*_mode.xml %{buildroot}%{modes_test_dir}/
+install -m 0644 example/mode/*invalid*_mode.xml %{buildroot}%{modes_test_dir}/
+install -m 0644 example/rule/*fail*_rule.xml %{buildroot}%{modes_test_dir}/
 install -m 0755 unittest/modes-gtest-run.sh %{buildroot}%{modes_test_dir}/
 
 %check
@@ -112,13 +114,16 @@ systemctl daemon-reload
 systemctl restart %{name}.service
 
 %posttrans unittests
+systemctl restart %{name}.service
 %{modes_test_dir}/modes-gtest-run.sh %{modes_data_dir} %{modes_test_dir}
 
 %preun unittests
-rm -rf %{modes_test_dir}/*.xml %{modes_test_dir}/*.xsd %{modes_test_dir}/extra
+rm -rf %{modes_test_dir}/*ex*.xml %{modes_test_dir}/*.xsd %{modes_test_dir}/extra
 
 %postun -p /sbin/ldconfig
 
+%postun unittests
+systemctl restart %{name}.service
 
 %files
 %attr(0755,system_fw,system_fw) %{modes_data_dir}/custom-mode
@@ -127,7 +132,10 @@ rm -rf %{modes_test_dir}/*.xml %{modes_test_dir}/*.xsd %{modes_test_dir}/extra
 %{_unitdir}/%{name}.service
 %{_sysconfdir}/dbus-1/system.d/%{_dbus_interface}.conf
 %{_datadir}/dbus-1/system-services/%{_dbus_interface}.service
-%{modes_data_dir}/*
+%{modes_data_dir}/schema/*
+%dir %{modes_data_dir}/mode
+%dir %{modes_data_dir}/rule
+%dir %{modes_data_dir}/custom-mode
 %license LICENSE.APLv2
 
 %files lib
@@ -150,4 +158,7 @@ rm -rf %{modes_test_dir}/*.xml %{modes_test_dir}/*.xsd %{modes_test_dir}/extra
 %{modes_plugin_dir}/*test.so
 %{modes_test_dir}/modes-gtest-*
 %{modes_test_dir}/modes-apply-mode-test
+%{modes_data_dir}/mode/*
+%{modes_data_dir}/rule/*
+%{modes_test_dir}/*.xml
 %license LICENSE.APLv2
index c8148acf9d1a4e2c921c35c3acfd83640afb9ea2..3407ca1ac10f2b24f25f730f27befd510cf864cb 100644 (file)
@@ -4,7 +4,7 @@ LINK_DIRECTORIES(${plugin_pkgs_LIBRARY_DIRS})
 ADD_DEFINITIONS("-DMDS_PLUGIN")
 
 SET(LIB_NAME modes-plugin-test)
-FILE(GLOB TEST_PLUGIN_SRCS TestPlugin.cpp)
+FILE(GLOB TEST_PLUGIN_SRCS *.cpp)
 
 ADD_LIBRARY(${LIB_NAME} SHARED ${TEST_PLUGIN_SRCS})
 TARGET_LINK_LIBRARIES(${LIB_NAME} ${plugin_pkgs_LIBRARIES})
index c7165d17308b93cbdbdc6aec6d5351ca54014506..81b2658548ce864c8b5c6c286da6d2040b31af30 100644 (file)
@@ -1,5 +1,25 @@
+/*
+ * 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 "TestPluginAction.h"
 
+#include "modes_errors.h"
+#include "common/definitions.h"
+
+MODES_NAMESPACE_USE;
+
 TestPluginAction::TestPluginAction()
 {
        setName("testAction");
@@ -8,3 +28,8 @@ TestPluginAction::TestPluginAction()
 TestPluginAction::~TestPluginAction()
 {
 }
+
+int TestPluginAction::undo()
+{
+       return MODES_ERROR_NONE;
+}
index 6e39da0777b699dd3efc7bc4ad221cfa0dcd32b3..6c8b02ee2ff3ca80b4c5c71afe1baa8df2fe7855 100644 (file)
@@ -90,12 +90,14 @@ int ModeManager::applyMode(const string &modeName)
                if (Mode::MODE_ONESHOT == mode.getModeType()) {
                        int ret = mode.applyOneShot();
                        if (MODES_ERROR_NONE != ret) {
+                               ERR("mode(%s) apply() Fail", mode.getName().c_str());
                                mode.undo();
                                return ret;
                        }
                } else {
                        int ret = mode.apply();
                        if (MODES_ERROR_NONE != ret) {
+                               ERR("mode(%s) apply() Fail", mode.getName().c_str());
                                mode.undo();
                                return ret;
                        }
index f16966abf2b7232158d1763b55bd70ccb68d4b16..b31807357ada8ba91a8fd8e44714488cc4e10440 100644 (file)
@@ -178,12 +178,9 @@ Action* ModeXMLParser::parseActionInfo(xmlNodePtr node)
 
        Action *action = ruleMgr.createAction(ruleProp);
        if (action == nullptr) {
-               WARN("ruleMgr createAction(%s) Fail", ruleProp);
-               action = new TAction<std::string>(ruleProp);
-               if (action == NULL) {
-                       ERR("Action is null");
-                       throw ModesEx(ModesEx::PARSER_ERROR, "Action is null!");
-               }
+               ERR("ruleMgr createAction(%s) Fail", ruleProp);
+               xmlFree(ruleProp);
+               throw ModesEx(ModesEx::PARSER_ERROR, "Action is null!");
        }
 
        bindPlugin(ruleProp, action);
index 3bf94ec4bc5a86de576f4c71542d6101e1dd8f1d..996a5c37464b796448769c2a75ed886d9bf63d20 100755 (executable)
@@ -16,8 +16,8 @@ CUR_DIR=$PWD
 cp $DATA_DIR/mode/*_mode.xml $WORKING_DIR
 cp $DATA_DIR/rule/*_rule.xml $WORKING_DIR
 mkdir -p $WORKING_DIR/extra
-sed s/ex1/ex3/g $DATA_DIR/mode/tizen_ex1_mode.xml > $WORKING_DIR/extra/tizen_ex3_mode.xml
-sed s/ex1/ex4/g $DATA_DIR/mode/tizen_ex1_mode.xml > $WORKING_DIR/extra/tizen_ex4_mode.xml
+sed s/ex1/ex3/g $WORKING_DIR/tizen_ex1_mode.xml > $WORKING_DIR/extra/tizen_ex3_mode.xml
+sed s/ex1/ex4/g $WORKING_DIR/tizen_ex1_mode.xml > $WORKING_DIR/extra/tizen_ex4_mode.xml
 
 pushd $WORKING_DIR
 
index 6a8de99f043292c3a7f5a32f52797f560c44bc29..7718394aaef33ae5a6cd7f9623d95a950b04f94c 100644 (file)
@@ -53,10 +53,10 @@ protected:
        {
                modes_h mode_handle = modes_create_mode("created", MODES_TYPE_MODE_NORMAL);
                action_h action_handle[2];
-               action_handle[0] = modes_create_action("wifi.power", "on");
-               modes_action_set_id(action_handle[0], "WiFiOn");
-               action_handle[1] = modes_create_action("wifi.power", "off");
-               modes_action_set_id(action_handle[1], "WiFiOff");
+               action_handle[0] = modes_create_action("test.printBool", "on");
+               modes_action_set_id(action_handle[0], "printBoolOn");
+               action_handle[1] = modes_create_action("test.printBool", "off");
+               modes_action_set_id(action_handle[1], "printBoolOff");
 
                for (int i = 0; i < 2; i++)
                        result = modes_mode_add_action(mode_handle, action_handle[i]);
@@ -96,16 +96,18 @@ TEST_F(ClientTest, registerMode)
        EXPECT_EQ(MODES_ERROR_NONE, result);
 }
 
-TEST_F(ClientTest, undoModeWifiOn)
+TEST_F(ClientTest, undoModeEx1)
 {
-       g_idle_add(undo_mode_idler, (gpointer)"wifiOn");
+       modes_undo_mode("ex1");
+       g_idle_add(undo_mode_idler, (gpointer)"ex1");
        g_main_loop_run(loop);
        EXPECT_EQ(MODES_ERROR_NONE, result);
 }
 
-TEST_F(ClientTest, undoModePsMode)
+TEST_F(ClientTest, undoModeEx2)
 {
-       g_idle_add(undo_mode_idler, (gpointer)"waterlock");
+       modes_undo_mode("ex2");
+       g_idle_add(undo_mode_idler, (gpointer)"ex2");
        g_main_loop_run(loop);
        EXPECT_EQ(MODES_ERROR_NONE, result);
 }
index 5a07fd3717e010f62234bf8a69fdfde5c29a592a..2c4546ec91912f2874846b1a71d129490693411f 100644 (file)
  */
 #include <gtest/gtest.h>
 #include "common/definitions.h"
-#include "supervisor/ConflictManager.h"
+#include "supervisor/ModesConfig.h"
 #include "supervisor/ModeXMLParser.h"
+#include "supervisor/ConflictManager.h"
 
 MODES_NAMESPACE_USE;
 
 class ConflictTest : public ::testing::Test {
+public:
+       ConflictTest();
 protected:
        void SetUp() override
        {
@@ -38,6 +41,17 @@ protected:
        ModeCareTaker careTaker;
 };
 
+ConflictTest::ConflictTest()
+{
+       ModesConfig config;
+       config.actionRuleDir = ".";
+       config.actionRuleXsdFile = "./" MODES_ACTIONRULE_DEFAULT_XSD_FILE;
+
+       ruleMgr.setOptions(config.actionRuleDir, config.actionRuleXsdFile);
+       ruleMgr.makeRuleMap();
+}
+
+
 TEST_F(ConflictTest, isSavedMode)
 {
        ModeXMLParser modeparser("tizen_conflict2_mode.xml", ruleMgr, piMgr);
@@ -71,4 +85,3 @@ TEST_F(ConflictTest, isConflict)
        ModeXMLParser modeparser("tizen_conflict2_mode.xml", ruleMgr, piMgr);
        EXPECT_TRUE(conflMgr.isConflict(modeparser.getMode()));
 }
-
index d7c26a9d9f8ff1b830d7a3dc90346be8e81e1faa..cf4e509aaa2b63dcdc452ebfffe964f01740acf0 100644 (file)
 #include <gtest/gtest.h>
 #include "supervisor/Mode.h"
 #include "supervisor/ModesEx.h"
-#include "supervisor/ModeXMLParser.h"
-#include "supervisor/XMLGenerator.h"
 #include "supervisor/RuleManager.h"
+#include "supervisor/ModesConfig.h"
+#include "supervisor/XMLGenerator.h"
+#include "supervisor/ModeXMLParser.h"
 
-MODES_NAMESPACE_USE;
 using namespace std;
+MODES_NAMESPACE_USE;
+
+MODES_NAMESPACE_BEGIN
+class GeneratorTest {
+public:
+       GeneratorTest();
+       RuleManager ruleMgr;
+       PluginManager piMgr;
+};
+MODES_NAMESPACE_END
+
+GeneratorTest::GeneratorTest()
+{
+       ModesConfig config;
+       config.actionRuleDir = ".";
+       config.actionRuleXsdFile = "./" MODES_ACTIONRULE_DEFAULT_XSD_FILE;
+
+       ruleMgr.setOptions(config.actionRuleDir, config.actionRuleXsdFile);
+       ruleMgr.makeRuleMap();
+}
 
 TEST(XMLGenerator, makeModeXML)
 {
-       PluginManager pluginManager;
-       RuleManager ruleMgr;
+       GeneratorTest broker;
 
-       ModeXMLParser modeparser("tizen_ex1_mode.xml", ruleMgr, pluginManager);
+       ModeXMLParser modeparser("tizen_ex1_mode.xml", broker.ruleMgr, broker.piMgr);
        Mode mode = modeparser.getMode();
 
        try {
@@ -41,7 +60,7 @@ TEST(XMLGenerator, makeModeXML)
                FAIL();
        }
 
-       ModeXMLParser genmodeparser("tizen_gen_ex1_mode.xml", ruleMgr, pluginManager);
+       ModeXMLParser genmodeparser("tizen_gen_ex1_mode.xml", broker.ruleMgr, broker.piMgr);
        Mode genMode = genmodeparser.getMode();
 
        EXPECT_EQ("ex1", genmodeparser.getModeName());
@@ -57,13 +76,12 @@ TEST(XMLGenerator, makeModeXML)
 
 TEST(XMLGenerator, exFileName)
 {
-       EXPECT_THROW({
-               PluginManager pluginManager;
-               RuleManager ruleMgr;
+       GeneratorTest broker;
 
-               ModeXMLParser modeparser("tizen_ex1_mode.xml", ruleMgr, pluginManager);
-               Mode mode = modeparser.getMode();
+       ModeXMLParser modeparser("tizen_ex1_mode.xml", broker.ruleMgr, broker.piMgr);
+       Mode mode = modeparser.getMode();
 
+       EXPECT_THROW({
                XMLGenerator xmlGenerator;
                xmlGenerator.makeModeXML("", mode);
        }, ModesEx);
index 94065a47105e410acda84a62e95c0c863fbeb8b1..7869516f5416216acd1086578fc2518b41408c7f 100644 (file)
@@ -20,6 +20,7 @@
 #include "supervisor/ModeManager.h"
 
 using namespace std;
+MODES_NAMESPACE_USE;
 
 MODES_NAMESPACE_BEGIN
 class ModeManagerTest {
@@ -35,8 +36,6 @@ public:
 };
 MODES_NAMESPACE_END
 
-MODES_NAMESPACE_USE;
-
 ModeManagerTest::ModeManagerTest()
        : mdMgr(rMgr, pMgr)
 {
index 04c2216efb0cef5029221d62a932b2cdc680f3f1..c9513e89f5f204c23a1d9a9a8bbe7d0c499c55a6 100644 (file)
 #include <gtest/gtest.h>
 #include "supervisor/Mode.h"
 #include "supervisor/ModesEx.h"
+#include "supervisor/ModesConfig.h"
 #include "supervisor/RuleManager.h"
 #include "supervisor/ModeXMLParser.h"
 
-MODES_NAMESPACE_USE;
 using namespace std;
+MODES_NAMESPACE_USE;
 
 MODES_NAMESPACE_BEGIN
-class ParserTest {
+class ParserTest : public ::testing::Test {
 public:
-       void initRuleManger();
-       list<std::shared_ptr<Action>> getActionList(Mode& m);
+       ParserTest();
+
+       void parserTest(const string &fileName);
+       list<shared_ptr<Action>> getActionList(Mode& m);
+
+protected:
+       void SetUp() override
+       {
+       }
+
+       void TearDown() override
+       {
+       }
 
+       PluginManager piMgr;
        RuleManager ruleMgr;
-private:
 };
 MODES_NAMESPACE_END
 
-
-void ParserTest::initRuleManger()
+ParserTest::ParserTest()
 {
-       ruleMgr.setOptions(std::string(), "./" MODES_ACTIONRULE_DEFAULT_XSD_FILE);
+       ModesConfig config;
+       config.actionRuleDir = ".";
+       config.actionRuleXsdFile = "./" MODES_ACTIONRULE_DEFAULT_XSD_FILE;
+
+       ruleMgr.setOptions(std::string(), config.actionRuleXsdFile);
        ruleMgr.parseActionRule("./tizen_ex_rule.xml");
 }
 
-list<std::shared_ptr<Action>> ParserTest::getActionList(Mode& m)
+list<shared_ptr<Action>> ParserTest::getActionList(Mode& m)
 {
        return m.actionList;
 }
 
-TEST(XMLParser, getModeName)
+TEST_F(ParserTest, getModeName)
 {
-       PluginManager pluginManager;
-       RuleManager ruleMgr;
-       ModeXMLParser modeparser("tizen_ex1_mode.xml", ruleMgr, pluginManager);
+       ModeXMLParser modeparser("tizen_ex1_mode.xml", ruleMgr, piMgr);
        string modename = modeparser.getModeName();
 
        EXPECT_EQ("ex1", modeparser.getModeName());
 }
 
-TEST(Mode, modeGetName)
+TEST_F(ParserTest, modeGetName)
 {
-       PluginManager pluginManager;
-       RuleManager ruleMgr;
-       ModeXMLParser modeparser("tizen_ex2_mode.xml", ruleMgr, pluginManager);
+       ModeXMLParser modeparser("tizen_ex2_mode.xml", ruleMgr, piMgr);
        Mode mode = modeparser.getMode();
        EXPECT_EQ("ex2", mode.getName());
 }
 
-TEST(Mode, getModeType)
+TEST_F(ParserTest, getModeType)
 {
-       PluginManager pluginManager;
-       RuleManager ruleMgr;
-       ModeXMLParser modeparser("tizen_ex1_mode.xml", ruleMgr, pluginManager);
+       ModeXMLParser modeparser("tizen_ex1_mode.xml", ruleMgr, piMgr);
        Mode mode = modeparser.getMode();
        EXPECT_EQ(Mode::MODE_NORMAL, mode.getModeType());
 }
 
-TEST(Mode, printAction)
+TEST_F(ParserTest, printAction)
 {
-       PluginManager pluginManager;
-       RuleManager ruleMgr;
-       ModeXMLParser modeparser("tizen_ex1_mode.xml", ruleMgr, pluginManager);
+       ModeXMLParser modeparser("tizen_ex1_mode.xml", ruleMgr, piMgr);
        Mode mode = modeparser.getMode();
-       ParserTest parserT;
 
-       list<std::shared_ptr<Action>> actionList = parserT.getActionList(mode);
+       list<std::shared_ptr<Action>> actionList = getActionList(mode);
        EXPECT_FALSE(actionList.empty());
 
        for (list<std::shared_ptr<Action>>::iterator it = actionList.begin(); it != actionList.end(); ++it) {
@@ -93,15 +99,11 @@ TEST(Mode, printAction)
        }
 }
 
-TEST(Mode, invalidActionValue)
+TEST_F(ParserTest, invalidActionValue)
 {
-       ParserTest parserT;
-       parserT.initRuleManger();
-
-       PluginManager piMgr;
-       ModeXMLParser modeparser1("tizen_invalid1_mode.xml", parserT.ruleMgr, piMgr);
+       ModeXMLParser modeparser1("tizen_invalid1_mode.xml", ruleMgr, piMgr);
        EXPECT_THROW(modeparser1.getMode(), ModesEx);
 
-       ModeXMLParser modeparser2("tizen_invalid2_mode.xml", parserT.ruleMgr, piMgr);
+       ModeXMLParser modeparser2("tizen_invalid2_mode.xml", ruleMgr, piMgr);
        EXPECT_THROW(modeparser2.getMode(), ModesEx);
 }
index 3b692f172e8d5ec2e1ac9ae55560209f83166d23..bc1b59cc02d779cbc5460bcfb9f6bcd391b5ba79 100644 (file)
@@ -132,140 +132,3 @@ TEST(PluginManager, getPluginTest)
        EXPECT_EQ(ret, MODES_ERROR_NONE);
        EXPECT_TRUE(broker.emptyPluginMap());
 }
-
-TEST(PluginManager, getPluginWifi)
-{
-       int ret;
-       TestPluginBroker broker;
-
-       broker.pMgr.setPluginDir(MODES_PLUGIN_DEFAULT_DIR);
-       try {
-               broker.pMgr.loadPlugins();
-       }
-       catch (ModesEx &e) {
-               broker.pMgr.setPluginDir("../plugin");
-               EXPECT_NO_THROW(broker.pMgr.loadPlugins());
-
-               ret = broker.pMgr.unloadPlugins();
-               EXPECT_EQ(ret, MODES_ERROR_NONE);
-               return;
-       }
-
-       EXPECT_FALSE(broker.emptyPluginMap());
-
-       Plugin *plugin = broker.pMgr.getPlugin("wifi");
-       ASSERT_TRUE(plugin != NULL);
-
-       ret = plugin->set("power", false, nullptr);
-       EXPECT_EQ(ret, MODES_ERROR_NONE);
-
-       ret = plugin->set("power", true, nullptr);
-       EXPECT_EQ(ret, MODES_ERROR_NONE);
-
-       ret = plugin->set("power", 0, nullptr);
-       EXPECT_EQ(ret, MODES_ERROR_NOT_SUPPORTED);
-
-       ret = plugin->set("power", 1, nullptr);
-       EXPECT_EQ(ret, MODES_ERROR_NOT_SUPPORTED);
-
-       ret = plugin->set("power", 0.0, nullptr);
-       EXPECT_EQ(ret, MODES_ERROR_NOT_SUPPORTED);
-
-       ret = plugin->set("power", 1.0, nullptr);
-       EXPECT_EQ(ret, MODES_ERROR_NOT_SUPPORTED);
-
-       ret = plugin->set("power", string("off"), nullptr);
-       EXPECT_EQ(ret, MODES_ERROR_NOT_SUPPORTED);
-
-       ret = plugin->set("power", string("on"), nullptr);
-       EXPECT_EQ(ret, MODES_ERROR_NOT_SUPPORTED);
-
-       ret = plugin->set("abcdefg", true, nullptr);
-       EXPECT_EQ(ret, MODES_ERROR_INVALID_PARAMETER);
-
-       ret = broker.pMgr.unloadPlugins();
-       EXPECT_EQ(ret, MODES_ERROR_NONE);
-       EXPECT_TRUE(broker.emptyPluginMap());
-}
-
-TEST(PluginManager, getPluginVconf)
-{
-       int ret;
-       TestPluginBroker broker;
-
-       broker.pMgr.setPluginDir(MODES_PLUGIN_DEFAULT_DIR);
-       try {
-               broker.pMgr.loadPlugins();
-       }
-       catch (ModesEx &e) {
-               broker.pMgr.setPluginDir("../plugin");
-               EXPECT_NO_THROW(broker.pMgr.loadPlugins());
-
-               ret = broker.pMgr.unloadPlugins();
-               EXPECT_EQ(ret, MODES_ERROR_NONE);
-               return;
-       }
-
-       EXPECT_FALSE(broker.emptyPluginMap());
-
-       bool boolRet;
-
-       Plugin *plugin = broker.pMgr.getPlugin("vconf");
-       ASSERT_TRUE(plugin != NULL);
-
-       ret = plugin->set("db/setting/auto_display_adjustment", true, nullptr);
-       EXPECT_TRUE(((ret == MODES_ERROR_NONE) || (ret == MODES_ERROR_NOT_SUPPORTED)));
-
-       boolRet = plugin->getBool("db/setting/auto_display_adjustment");
-       EXPECT_EQ(boolRet, true);
-
-       ret = plugin->set("db/setting/lcd_backlight_normal", 11, nullptr);
-       EXPECT_TRUE(((ret == MODES_ERROR_NONE) || (ret == MODES_ERROR_NOT_SUPPORTED)));
-
-       ret = plugin->getInt("db/setting/lcd_backlight_normal");
-       EXPECT_EQ(ret, 11);
-
-       ret = broker.pMgr.unloadPlugins();
-       EXPECT_EQ(ret, MODES_ERROR_NONE);
-       EXPECT_TRUE(broker.emptyPluginMap());
-}
-
-TEST(PluginManager, getPluginBluetooth)
-{
-       int ret;
-       TestPluginBroker broker;
-
-       broker.pMgr.setPluginDir(MODES_PLUGIN_DEFAULT_DIR);
-       try {
-               broker.pMgr.loadPlugins();
-       }
-       catch (ModesEx &e) {
-               broker.pMgr.setPluginDir("../plugin");
-               EXPECT_NO_THROW(broker.pMgr.loadPlugins());
-
-               ret = broker.pMgr.unloadPlugins();
-               EXPECT_EQ(ret, MODES_ERROR_NONE);
-               return;
-       }
-
-       EXPECT_FALSE(broker.emptyPluginMap());
-
-       Plugin *plugin = broker.pMgr.getPlugin("bluetooth");
-       ASSERT_TRUE(plugin != NULL);
-
-       ret = plugin->set("power", false, nullptr);
-       EXPECT_EQ(ret, MODES_ERROR_NONE);
-
-       ret = plugin->set("power", true, nullptr);
-       EXPECT_EQ(ret, MODES_ERROR_NONE);
-
-       ret = plugin->set("power", string("on"), nullptr);
-       EXPECT_EQ(ret, MODES_ERROR_NOT_SUPPORTED);
-
-       ret = plugin->set("abcdefg", true, nullptr);
-       EXPECT_EQ(ret, MODES_ERROR_INVALID_PARAMETER);
-
-       ret = broker.pMgr.unloadPlugins();
-       EXPECT_EQ(ret, MODES_ERROR_NONE);
-       EXPECT_TRUE(broker.emptyPluginMap());
-}