diff options
author | Youngjae Shin <yj99.shin@samsung.com> | 2020-06-15 16:07:16 +0900 |
---|---|---|
committer | Youngjae Shin <yj99.shin@samsung.com> | 2020-06-15 16:23:16 +0900 |
commit | feffb9131a8b085e3d9347a3a5d0e01c4feee897 (patch) | |
tree | dc5f08ab0fc6e125b21e9ca6d349561aa74b4f73 | |
parent | f8989abe620a85ad5e92973a9af37ed59db94eee (diff) | |
download | modes-feffb9131a8b085e3d9347a3a5d0e01c4feee897.tar.gz modes-feffb9131a8b085e3d9347a3a5d0e01c4feee897.tar.bz2 modes-feffb9131a8b085e3d9347a3a5d0e01c4feee897.zip |
revise generator and its tests
Change-Id: Icc8114b9e516c159946a60dda8058f5a1ff95c2a
-rw-r--r-- | supervisor/XMLGenerator.cpp | 5 | ||||
-rw-r--r-- | tests/modes_test_conflict.cpp | 4 | ||||
-rw-r--r-- | tests/modes_test_generator.cpp | 51 |
3 files changed, 39 insertions, 21 deletions
diff --git a/supervisor/XMLGenerator.cpp b/supervisor/XMLGenerator.cpp index 45619d9..47a4884 100644 --- a/supervisor/XMLGenerator.cpp +++ b/supervisor/XMLGenerator.cpp @@ -129,11 +129,6 @@ void XMLGenerator::makeUndoInfoXML(const std::string &path, const Mode &mode) throw ModesEx(ModesEx::INVALID_ARG); } - if (0 != remove(path.c_str()) && ENOENT != errno) { - ERR("remove(%s) Fail(%d)", path.c_str(), errno); - throw ModesEx(ModesEx::SYSTEM_ERROR); - } - createRootNode(); xmlNodePtr undoInfoNode = xmlNewNode(NULL, ModesXMLTag::UNDO_INFO); diff --git a/tests/modes_test_conflict.cpp b/tests/modes_test_conflict.cpp index c9b0df8..7903e43 100644 --- a/tests/modes_test_conflict.cpp +++ b/tests/modes_test_conflict.cpp @@ -34,7 +34,7 @@ protected: void TearDown() override { Mode mode; - careTaker.popMode("conflict1", mode); + careTaker.popMode("http://tizen.org/mode/example.conflict1", mode); } bool checkConflictAction(const Mode &mode) @@ -47,14 +47,12 @@ protected: }; MODES_NAMESPACE_END - ConflictTest::ConflictTest() : ruleMgr(".", "./" MODES_RULE_DEFAULT_XSD_FILE, "../../.." MODES_PLUGIN_DEFAULT_DIR), careTaker(".") { ruleMgr.start(); } - TEST_F(ConflictTest, isSavedMode) { ModeXMLParser modeparser("tizen_conflictErrBase_mode.xml", ruleMgr); diff --git a/tests/modes_test_generator.cpp b/tests/modes_test_generator.cpp index 99cf52e..2ed7f93 100644 --- a/tests/modes_test_generator.cpp +++ b/tests/modes_test_generator.cpp @@ -26,35 +26,49 @@ using namespace std; MODES_NAMESPACE_USE; MODES_NAMESPACE_BEGIN -class GeneratorTest { +class GeneratorTest : public ::testing::Test { public: GeneratorTest(); + +protected: + void SetUp() override + { + } + + void TearDown() override + { + if (0 != remove(genXmlPath.c_str()) && ENOENT != errno) { + ERR("remove(%s) Fail(%d)", genXmlPath.c_str(), errno); + FAIL(); + } + } + RuleManager ruleMgr; + const string genXmlPath; }; MODES_NAMESPACE_END GeneratorTest::GeneratorTest() - : ruleMgr(".", "./" MODES_RULE_DEFAULT_XSD_FILE, "../../.." MODES_PLUGIN_DEFAULT_DIR) + : ruleMgr(".", "./" MODES_RULE_DEFAULT_XSD_FILE, "../../.." MODES_PLUGIN_DEFAULT_DIR), + genXmlPath("tizen_generatedEx1_mode.xml") { ruleMgr.start(); } -TEST(XMLGenerator, makeModeXML) +TEST_F(GeneratorTest, makeModeXML) { - GeneratorTest broker; - - ModeXMLParser modeParser("tizen_normalEx1_mode.xml", broker.ruleMgr); + ModeXMLParser modeParser("tizen_normalEx1_mode.xml", ruleMgr); Mode mode = modeParser.getMode(); try { XMLGenerator xmlGenerator; - xmlGenerator.makeModeXML("tizen_generatedEx1_mode.xml", mode); + xmlGenerator.makeModeXML(genXmlPath, mode); } catch (ModesEx &e) { - ERR("XMLGenerator(tizen_generatedEx1_mode.xml) Fail(%s)", e.what()); + ERR("XMLGenerator(%s) Fail(%s)", genXmlPath.c_str(), e.what()); FAIL(); } - ModeXMLParser genModeParser("tizen_generatedEx1_mode.xml", broker.ruleMgr); + ModeXMLParser genModeParser(genXmlPath, ruleMgr); Mode genMode = genModeParser.getMode(); EXPECT_EQ("ex1", genMode.getName()); @@ -66,13 +80,24 @@ TEST(XMLGenerator, makeModeXML) cout << "\t\t- Restrict : " << (*it)->getRestrict() << endl; cout << "\t\t- Content : " << (*it)->getStringOfValue() << endl; } + + try { + XMLGenerator xmlGenerator; + xmlGenerator.makeModeXML(genXmlPath, mode); + } catch (ModesEx &e) { + if (e.getErrCode() != ModesEx::SYSTEM_ERROR) { + ERR("XMLGenerator(%s) Fail(%s)", genXmlPath.c_str(), e.what()); + FAIL(); + } + + return; + } + FAIL(); } -TEST(XMLGenerator, exFileName) +TEST_F(GeneratorTest, exFileName) { - GeneratorTest broker; - - ModeXMLParser modeParser("tizen_normalEx1_mode.xml", broker.ruleMgr); + ModeXMLParser modeParser("tizen_normalEx1_mode.xml", ruleMgr); Mode mode = modeParser.getMode(); EXPECT_THROW({ |