summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--supervisor/XMLGenerator.cpp5
-rw-r--r--tests/modes_test_conflict.cpp4
-rw-r--r--tests/modes_test_generator.cpp51
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({