From: dyamy-lee Date: Tue, 11 Aug 2020 04:51:56 +0000 (+0900) Subject: DSWaylandProtocolTrace: add skeleton code with singleton X-Git-Tag: accepted/tizen/unified/20200820.213435~77 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=68e3d7b135ee0baf85ff559cfa9b63bc3ef2ab68;p=platform%2Fcore%2Fuifw%2Flibds.git DSWaylandProtocolTrace: add skeleton code with singleton Change-Id: I795496753aa315bff435c86d16a9c7c254904354 --- diff --git a/src/DSWaylandServer/DSWaylandProtocolTrace.cpp b/src/DSWaylandServer/DSWaylandProtocolTrace.cpp new file mode 100644 index 0000000..0f8c9a6 --- /dev/null +++ b/src/DSWaylandServer/DSWaylandProtocolTrace.cpp @@ -0,0 +1,113 @@ +/* +* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include "DSWaylandProtocolTrace.h" +#include "DSWaylandProtocolTracePrivate.h" + +namespace display_server +{ + +int DSWaylandProtocolTrace::__refCount { 0 }; +std::mutex DSWaylandProtocolTrace::__mutex; +DSWaylandProtocolTrace* DSWaylandProtocolTrace::__protocolTrace { nullptr }; + +DSWaylandProtocolTrace::DSWaylandProtocolTrace(DSObject *parent) + : DS_INIT_PRIVATE_PTR(DSWaylandProtocolTrace) +{ + //init(); +} + +DSWaylandProtocolTrace::~DSWaylandProtocolTrace() +{ + +} + +DSWaylandProtocolTrace *DSWaylandProtocolTrace::getInstance() +{ + std::lock_guard tLock(__mutex); + + if(!__protocolTrace && (__refCount == 0)) + { + __protocolTrace = new DSWaylandProtocolTrace(new DSObject); + DSLOG_INF("DSWaylandProtocolTrace", "DSWaylandProtocolTrace instance has been created !"); + } + + ++__refCount; + return __protocolTrace; +} + +void DSWaylandProtocolTrace::releaseInstance() +{ + std::lock_guard tLock(__mutex); + + --__refCount; + if(__refCount < 0) + __refCount = 0; + + if((0==__refCount) && __protocolTrace) + { + delete __protocolTrace; + __protocolTrace = nullptr; + DSLOG_INF("DSWaylandProtocolTrace", "DSWaylandProtocolTrace instance has been removed !"); + } +} + +bool DSWaylandProtocolTrace::init(void) +{ + return false; +} + +int DSWaylandProtocolTrace::enableProtocolTrace(bool state) +{ + //following state : enable, disable trace + return -1; +} + +DSWaylandProtocolTracePrivate::DSWaylandProtocolTracePrivate(DSWaylandProtocolTrace *p_ptr) + : DSObjectPrivate(p_ptr), __p_ptr(p_ptr) +{ + +} + +DSWaylandProtocolTracePrivate::~DSWaylandProtocolTracePrivate() +{ + +} + +void DSWaylandProtocolTracePrivate::protocol_rule_init(char *rule_path) +{ +} + +void DSWaylandProtocolTracePrivate::protocol_trace_init(char *trace_path) +{ +} + +void DSWaylandProtocolTracePrivate::protocol_rule_set(void) +{ +} + +void DSWaylandProtocolTracePrivate::protocol_rule_file_set(void) +{ +} + +} // namespace display_server \ No newline at end of file diff --git a/src/DSWaylandServer/DSWaylandProtocolTrace.h b/src/DSWaylandServer/DSWaylandProtocolTrace.h new file mode 100644 index 0000000..b9526df --- /dev/null +++ b/src/DSWaylandServer/DSWaylandProtocolTrace.h @@ -0,0 +1,58 @@ +/* +* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#ifndef __DS_WAYLAND_PROTOCOL_TRACE_H__ +#define __DS_WAYLAND_PROTOCOL_TRACE_H__ + +#include +#include + +namespace display_server +{ + +class DSWaylandProtocolTracePrivate; + +class DSWaylandProtocolTrace : public DSObject +{ +DS_PIMPL_USE_PRIVATE(DSWaylandProtocolTrace); + +public: + DSWaylandProtocolTrace(DSObject *parent); + virtual ~DSWaylandProtocolTrace(); + static DSWaylandProtocolTrace *getInstance(); + static void releaseInstance(); + + bool init(void); + int enableProtocolTrace(bool state); + //int registerProtocolRule(void); + +private: + static std::mutex __mutex; + static DSWaylandProtocolTrace *__protocolTrace; + static int __refCount; + +}; + +} + +#endif // __DS_WAYLAND_PROTOCOL_TRACE_H__ \ No newline at end of file diff --git a/src/DSWaylandServer/DSWaylandProtocolTracePrivate.h b/src/DSWaylandServer/DSWaylandProtocolTracePrivate.h new file mode 100644 index 0000000..d43ed9d --- /dev/null +++ b/src/DSWaylandServer/DSWaylandProtocolTracePrivate.h @@ -0,0 +1,54 @@ +/* +* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#ifndef __DS_WAYLAND_PROTOCOL_TRACE_PRIVATE_H__ +#define __DS_WAYLAND_PROTOCOL_TRACE_PRIVATE_H__ + +#include "DSWaylandProtocolTrace.h" + +namespace display_server +{ + +class DSWaylandProtocolTracePrivate : public DSObjectPrivate +{ +DS_PIMPL_USE_PUBLIC(DSWaylandProtocolTrace); + +public: + DSWaylandProtocolTracePrivate() = delete; + DSWaylandProtocolTracePrivate(DSWaylandProtocolTrace *p_ptr); + ~DSWaylandProtocolTracePrivate(); + + +protected: + void protocol_rule_init(char *rule_path); + void protocol_trace_init(char *trace_path); + + void protocol_rule_set(void); + void protocol_rule_file_set(void); +}; + +} + + + +#endif // __DS_WAYLAND_PROTOCOL_TRACE_PRIVATE_H__ \ No newline at end of file diff --git a/src/meson.build b/src/meson.build index e4ab5e5..0766802 100644 --- a/src/meson.build +++ b/src/meson.build @@ -157,6 +157,9 @@ libds_wayland_srcs = [ 'DSWaylandServer/DSWaylandTizenAppinfoPrivate.h', 'DSWaylandServer/DSWaylandTizenAppinfo.h', 'DSWaylandServer/DSWaylandTizenAppinfo.cpp', + 'DSWaylandServer/DSWaylandProtocolTracePrivate.h', + 'DSWaylandServer/DSWaylandProtocolTrace.h', + 'DSWaylandServer/DSWaylandProtocolTrace.cpp', ] libds_srcs += libds_wayland_srcs diff --git a/tests/DSWaylandProtocolTrace-test.cpp b/tests/DSWaylandProtocolTrace-test.cpp new file mode 100644 index 0000000..e02cf3e --- /dev/null +++ b/tests/DSWaylandProtocolTrace-test.cpp @@ -0,0 +1,59 @@ +/* +* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include "libds-tests.h" +#include "DSWaylandProtocolTrace.h" + +using namespace display_server; + +class DSWaylandProtocolTraceTest : public ::testing::Test +{ +public: + void SetUp(void) override + {} + void TearDown(void) override + {} + +}; + +TEST_F(DSWaylandProtocolTraceTest, NewDSWaylandProtocolTrace) +{ + DSWaylandProtocolTrace *pTrace = DSWaylandProtocolTrace::getInstance(); + EXPECT_TRUE(pTrace != nullptr); + + if(pTrace) + DSWaylandProtocolTrace::releaseInstance(); +} + +TEST_F(DSWaylandProtocolTraceTest, BasicMethods) +{ + DSWaylandProtocolTrace *pTrace = DSWaylandProtocolTrace::getInstance(); + bool trace_state = false; //disable + + if(pTrace) + { + EXPECT_TRUE(pTrace->init() == true); + EXPECT_TRUE(pTrace->enableProtocolTrace(trace_state) == 0); + DSWaylandProtocolTrace::releaseInstance(); + } +} \ No newline at end of file diff --git a/tests/meson.build b/tests/meson.build index 45e852d..946b46d 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -53,6 +53,7 @@ libds_tests_srcs = [ 'DSKeyboard-test.cpp', 'DSTouch-test.cpp', 'DSTizenAppinfo-test.cpp', + 'DSWaylandProtocolTrace-test.cpp', ] gmock_dep = dependency('gmock', method : 'pkg-config')