DSWaylandProtocolTrace: add skeleton code with singleton 98/241798/1
authordyamy-lee <dyamy.lee@samsung.com>
Tue, 11 Aug 2020 04:51:56 +0000 (13:51 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 20 Aug 2020 10:10:56 +0000 (19:10 +0900)
Change-Id: I795496753aa315bff435c86d16a9c7c254904354

src/DSWaylandServer/DSWaylandProtocolTrace.cpp [new file with mode: 0644]
src/DSWaylandServer/DSWaylandProtocolTrace.h [new file with mode: 0644]
src/DSWaylandServer/DSWaylandProtocolTracePrivate.h [new file with mode: 0644]
src/meson.build
tests/DSWaylandProtocolTrace-test.cpp [new file with mode: 0644]
tests/meson.build

diff --git a/src/DSWaylandServer/DSWaylandProtocolTrace.cpp b/src/DSWaylandServer/DSWaylandProtocolTrace.cpp
new file mode 100644 (file)
index 0000000..0f8c9a6
--- /dev/null
@@ -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<std::mutex> 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<std::mutex> 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 (file)
index 0000000..b9526df
--- /dev/null
@@ -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 <DSObject.h>
+#include <DSCore.h>
+
+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 (file)
index 0000000..d43ed9d
--- /dev/null
@@ -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
index e4ab5e5..0766802 100644 (file)
@@ -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 (file)
index 0000000..e02cf3e
--- /dev/null
@@ -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
index 45e852d..946b46d 100644 (file)
@@ -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')