From: dyamy-lee Date: Thu, 20 Aug 2020 06:08:23 +0000 (+0900) Subject: add func of update rule and add test code X-Git-Tag: accepted/tizen/unified/20200901.160655~36 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c755d4d90af069ab069c03a9e537e522ec8c6144;p=platform%2Fcore%2Fuifw%2Flibds.git add func of update rule and add test code Change-Id: Ia7891fb079711b6198b786604e4708fa3c900fe5 --- diff --git a/src/DSWaylandServer/DSWaylandProtocolTrace.cpp b/src/DSWaylandServer/DSWaylandProtocolTrace.cpp index fe89016..869bcb7 100644 --- a/src/DSWaylandServer/DSWaylandProtocolTrace.cpp +++ b/src/DSWaylandServer/DSWaylandProtocolTrace.cpp @@ -204,6 +204,18 @@ int DSWaylandProtocolTrace::enableProtocolTrace(bool state) return -1; } + +bool DSWaylandProtocolTrace::updateProtocolRule(const int argc, const char **argv) +{ + DS_GET_PRIV(DSWaylandProtocolTrace); + DSLOG_DBG("DSWaylandProtocolTrace", "argc = %d, argv[0] = %s, argv[1] = %s", argc, argv[0], argv[1]); + + bool ret = false; + ret = priv->protocol_rule_set(argc, argv); + + return ret; +} + DSWaylandProtocolTracePrivate::DSWaylandProtocolTracePrivate(DSWaylandProtocolTrace *p_ptr) : DSObjectPrivate(p_ptr), __p_ptr(p_ptr) { @@ -265,6 +277,7 @@ bool DSWaylandProtocolTracePrivate::protocol_trace_init(char *trace_path) bool DSWaylandProtocolTracePrivate::protocol_rule_set(const int argc, const char **argv) { DSLOG_DBG("DSWaylandProtocolTracePriv", "IN >> protocol_rule_set"); + DSLOG_DBG("DSWaylandProtocolTracePriv", "(parameter) argc = %d, argv[0] = %s", argc, argv[0]); const char * command; if(argc == 0) @@ -408,6 +421,8 @@ bool DSWaylandProtocolTracePrivate::protocol_rule_set(const int argc, const char } } rulechecker_rule_print(rc); + + return true; } else if(!strcasecmp(command, "file")) { @@ -532,6 +547,7 @@ void DSWaylandProtocolTracePrivate::protocol_trace_set(void) display = __wlCompositor->display(); DSLOG_DBG("DSWaylandProtocolTracePriv","get display "); + //check working ds_wl_protocol_logger = wl_display_add_protocol_logger(display, protocol_trace_func, nullptr); DSLOG_DBG("DSWaylandProtocolTracePriv","OUT << protocol trace set"); } diff --git a/src/DSWaylandServer/DSWaylandProtocolTrace.h b/src/DSWaylandServer/DSWaylandProtocolTrace.h index 70a5d6c..b53e999 100644 --- a/src/DSWaylandServer/DSWaylandProtocolTrace.h +++ b/src/DSWaylandServer/DSWaylandProtocolTrace.h @@ -45,7 +45,7 @@ public: bool init(void); int enableProtocolTrace(bool state); - //int registerProtocolRule(void); + bool updateProtocolRule(const int argc, const char **argv); private: static std::mutex __mutex; diff --git a/tests/DSWaylandProtocolTrace-test.cpp b/tests/DSWaylandProtocolTrace-test.cpp index e02cf3e..63d0e67 100644 --- a/tests/DSWaylandProtocolTrace-test.cpp +++ b/tests/DSWaylandProtocolTrace-test.cpp @@ -45,15 +45,82 @@ TEST_F(DSWaylandProtocolTraceTest, NewDSWaylandProtocolTrace) DSWaylandProtocolTrace::releaseInstance(); } -TEST_F(DSWaylandProtocolTraceTest, BasicMethods) +TEST_F(DSWaylandProtocolTraceTest, DSWaylandProtocolTraceInit) { DSWaylandProtocolTrace *pTrace = DSWaylandProtocolTrace::getInstance(); - bool trace_state = false; //disable if(pTrace) { EXPECT_TRUE(pTrace->init() == true); + DSWaylandProtocolTrace::releaseInstance(); + } +} + +TEST_F(DSWaylandProtocolTraceTest, DSWaylandProtocolTraceUpdateRule) +{ + DSWaylandProtocolTrace *pTrace = DSWaylandProtocolTrace::getInstance(); + + if(pTrace) + { + pTrace->init(); + + int argc = 3; + char *argv[3]; + argv[0] = "add"; + argv[1] = "ALLOW"; + argv[2] = "all"; + EXPECT_TRUE(pTrace->updateProtocolRule(argc, (const char**)&(argv[0])) == true); + + argc = 2; + argv[0] = "remove"; + argv[1] = "all"; + argv[2] = nullptr; + EXPECT_TRUE(pTrace->updateProtocolRule(argc, (const char**)&(argv[0])) == true); + + argc = 1; + argv[0] = "print"; + argv[1] = nullptr; + argv[2] = nullptr; + EXPECT_TRUE(pTrace->updateProtocolRule(argc, (const char**)&(argv[0])) == true); + + argc = 1; + argv[0] = "help"; + argv[1] = nullptr; + argv[2] = nullptr; + EXPECT_TRUE(pTrace->updateProtocolRule(argc, (const char**)&(argv[0])) == true); + + argc = 1; + argv[0] = "command"; + argv[1] = nullptr; + argv[2] = nullptr; + EXPECT_TRUE(pTrace->updateProtocolRule(argc, (const char**)&(argv[0])) == true); + DSWaylandProtocolTrace::releaseInstance(); + } + +} + +TEST_F(DSWaylandProtocolTraceTest, DSWaylandProtocolTraceEnableTraceFalse) +{ + DSWaylandProtocolTrace *pTrace = DSWaylandProtocolTrace::getInstance(); + bool trace_state = false; //disable + + if(pTrace) + { + pTrace->init(); EXPECT_TRUE(pTrace->enableProtocolTrace(trace_state) == 0); DSWaylandProtocolTrace::releaseInstance(); } +} + +TEST_F(DSWaylandProtocolTraceTest, DSWaylandProtocolTraceEnableTraceTrue) +{ + DSWaylandProtocolTrace *pTrace = DSWaylandProtocolTrace::getInstance(); + bool trace_state = true; + + if(pTrace) + { + pTrace->init(); + EXPECT_TRUE(pTrace->enableProtocolTrace(trace_state) == 1); + DSWaylandProtocolTrace::releaseInstance(); + } } \ No newline at end of file