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)
{
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)
}
}
rulechecker_rule_print(rc);
+
+ return true;
}
else if(!strcasecmp(command, "file"))
{
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");
}
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