From: Doyoun Kang Date: Mon, 20 Jul 2020 15:52:17 +0000 (+0000) Subject: DSWaylandTizenPolicy: add initial code X-Git-Tag: accepted/tizen/unified/20200820.213435~218 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d151f4ee0c9dfc7381246af1125b52920d71cb94;p=platform%2Fcore%2Fuifw%2Flibds.git DSWaylandTizenPolicy: add initial code Change-Id: Ie0b559b898c380ce6f6912f6dc97845845b53391 --- diff --git a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp b/src/DSWaylandServer/DSWaylandTizenPolicy.cpp index 5e52da8..bfb0790 100644 --- a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp +++ b/src/DSWaylandServer/DSWaylandTizenPolicy.cpp @@ -1,6 +1,8 @@ #include "DSWaylandTizenPolicy.h" #include "DSWaylandTizenPolicyPrivate.h" +const int TIZEN_POLICY_VERSION = 7; + namespace display_server { ///////////////////////////////// @@ -11,189 +13,288 @@ DSWaylandTizenPolicyPrivate::DSWaylandTizenPolicyPrivate(DSWaylandTizenPolicy *p : DSObjectPrivate(p_ptr), __p_ptr(p_ptr) { + DSLOG_DBG("TizenPolicyPriv", ""); } DSWaylandTizenPolicyPrivate::~DSWaylandTizenPolicyPrivate() { + DSLOG_DBG("TizenPolicyPriv", ""); +} + +void DSWaylandTizenPolicyPrivate::tizen_policy_initialize(DSWaylandCompositor *wlCompositor) +{ + ::wl_display *display; + display = wlCompositor->display(); + + init(display, TIZEN_POLICY_VERSION); +} + +void DSWaylandTizenPolicyPrivate::tizen_policy_finalize(void) +{ + } void DSWaylandTizenPolicyPrivate::tizen_policy_bind_resource(Resource *resource) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_destroy_resource(Resource *resource) { - + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_get_visibility(Resource *resource, uint32_t id, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_get_position(Resource *resource, uint32_t id, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_activate(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_activate_below_by_res_id(Resource *resource, uint32_t res_id, uint32_t below_res_id) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_raise(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_lower(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_lower_by_res_id(Resource *resource, uint32_t res_id) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_focus_skip(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_unset_focus_skip(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_role(Resource *resource, struct ::wl_resource *surface, const std::string &role) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_type(Resource *resource, struct ::wl_resource *surface, uint32_t win_type) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_conformant(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_unset_conformant(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_get_conformant(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_notification_level(Resource *resource, struct ::wl_resource *surface, int32_t level) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_transient_for(Resource *resource, uint32_t child_id, uint32_t parent_id) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_unset_transient_for(Resource *resource, uint32_t child_id) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_window_screen_mode(Resource *resource, struct ::wl_resource *surface, uint32_t mode) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_place_subsurface_below_parent(Resource *resource, struct ::wl_resource *subsurface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_subsurface_stand_alone(Resource *resource, struct ::wl_resource *subsurface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_get_subsurface(Resource *resource, uint32_t id, struct ::wl_resource *surface, uint32_t parent_id) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_opaque_state(Resource *resource, struct ::wl_resource *surface, int32_t state) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_iconify(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_uniconify(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_add_aux_hint(Resource *resource, struct ::wl_resource *surface, int32_t id, const std::string &name, const std::string &value) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_change_aux_hint(Resource *resource, struct ::wl_resource *surface, int32_t id, const std::string &value) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_del_aux_hint(Resource *resource, struct ::wl_resource *surface, int32_t id) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_get_supported_aux_hints(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_background_state(Resource *resource, uint32_t pid) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_unset_background_state(Resource *resource, uint32_t pid) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_floating_mode(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_unset_floating_mode(Resource *resource, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_stack_mode(Resource *resource, struct ::wl_resource *surface, uint32_t mode) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_activate_above_by_res_id(Resource *resource, uint32_t res_id, uint32_t above_res_id) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_get_subsurface_watcher(Resource *resource, uint32_t id, struct ::wl_resource *surface) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_parent(Resource *resource, struct ::wl_resource *child, struct ::wl_resource *parent) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_ack_conformant_region(Resource *resource, struct ::wl_resource *surface, uint32_t serial) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_destroy(Resource *resource) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_has_video(Resource *resource, struct ::wl_resource *surface, uint32_t has) { + DSLOG_DBG("TizenPolicyPriv", ""); } void DSWaylandTizenPolicyPrivate::tizen_policy_set_appid(Resource *resource, int32_t pid, const std::string &appid) { + DSLOG_DBG("TizenPolicyPriv", ""); } -DSWaylandTizenPolicy::DSWaylandTizenPolicy() - : DS_INIT_PRIVATE_PTR(DSWaylandTizenPolicy) +DSWaylandTizenPolicy::DSWaylandTizenPolicy(DSWaylandCompositor *wlCompositor) + : DS_INIT_PRIVATE_PTR(DSWaylandTizenPolicy), + __wlCompositor(wlCompositor) { + this->initialize(__wlCompositor); } DSWaylandTizenPolicy::~DSWaylandTizenPolicy() { + DS_ASSERT(isCreated() == false); +} + +bool DSWaylandTizenPolicy::isCreated(void) +{ + return __isCreated; +} + +bool DSWaylandTizenPolicy::initialize(DSWaylandCompositor *wlCompositor) +{ + if (!wlCompositor) return false; + if (isCreated()) + { + DSLOG_ERR("TizenPolicy", "Already initialized"); + return true; + } + + DS_GET_PRIV(DSWaylandTizenPolicy); + if (!priv) return false; + + __wlCompositor = wlCompositor; + __isCreated = true; + + priv->tizen_policy_initialize(__wlCompositor); + + DSLOG_INF("TizenPolicy", "TizenPolicy initialized"); + return true; +} + +void DSWaylandTizenPolicy::finalize(void) +{ + DS_GET_PRIV(DSWaylandTizenPolicy); + priv->tizen_policy_finalize(); + + DSLOG_INF("TizenPolicy", "TizenPolicy finalized"); + __isCreated = false; +} + +DSWaylandCompositor *DSWaylandTizenPolicy::getWlCompositor() +{ + return __wlCompositor; } } // namespace display_server diff --git a/src/DSWaylandServer/DSWaylandTizenPolicy.h b/src/DSWaylandServer/DSWaylandTizenPolicy.h index 844bd5a..95b93d5 100644 --- a/src/DSWaylandServer/DSWaylandTizenPolicy.h +++ b/src/DSWaylandServer/DSWaylandTizenPolicy.h @@ -3,6 +3,7 @@ #include "DSCore.h" #include "DSObject.h" +#include "DSWaylandCompositor.h" namespace display_server { @@ -14,8 +15,19 @@ class DSWaylandTizenPolicy : public DSObject DS_PIMPL_USE_PRIVATE(DSWaylandTizenPolicy) public: - DSWaylandTizenPolicy(); + DSWaylandTizenPolicy(DSWaylandCompositor *wlCompositor); virtual ~DSWaylandTizenPolicy(); + + bool isCreated(void); + + bool initialize(DSWaylandCompositor *wlCompositor); + void finalize(void); + + DSWaylandCompositor *getWlCompositor(); + +private: + DSWaylandCompositor *__wlCompositor; + bool __isCreated; }; } diff --git a/src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h b/src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h index 0ff3bf5..634060b 100644 --- a/src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h +++ b/src/DSWaylandServer/DSWaylandTizenPolicyPrivate.h @@ -16,6 +16,9 @@ public: DSWaylandTizenPolicyPrivate(DSWaylandTizenPolicy *p_ptr); ~DSWaylandTizenPolicyPrivate() override; + void tizen_policy_initialize(DSWaylandCompositor *wlCompositor); + void tizen_policy_finalize(void); + protected: void tizen_policy_bind_resource(Resource *resource) override; void tizen_policy_destroy_resource(Resource *resource) override; diff --git a/tests/DSWaylandTizenPolicy-test.cpp b/tests/DSWaylandTizenPolicy-test.cpp index 49b96fd..a7be1c5 100644 --- a/tests/DSWaylandTizenPolicy-test.cpp +++ b/tests/DSWaylandTizenPolicy-test.cpp @@ -1,4 +1,5 @@ #include "libds-tests.h" +#include "DSWaylandCompositor.h" #include "DSWaylandTizenPolicy.h" using namespace display_server; @@ -12,10 +13,50 @@ public: {} }; -TEST_F(DSWaylandTizenPolicyTest, NewDSWaylandTizenPolicy) +TEST_F(DSWaylandTizenPolicyTest, new_P1) { - DSWaylandTizenPolicy *tizenPolicy = new DSWaylandTizenPolicy; + DSWaylandCompositor *compositor = DSWaylandCompositor::getInstance(); + DSWaylandTizenPolicy *tizenPolicy = new DSWaylandTizenPolicy(compositor); delete tizenPolicy; EXPECT_TRUE(true); + DSWaylandCompositor::releaseInstance(); } +TEST_F(DSWaylandTizenPolicyTest, initialize_P1) +{ + bool ret; + + DSWaylandCompositor *compositor = DSWaylandCompositor::getInstance(); + DSWaylandTizenPolicy *tizenPolicy = new DSWaylandTizenPolicy(compositor); + + ret = tizenPolicy->initialize(compositor); + EXPECT_TRUE(ret == true); + + delete tizenPolicy; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTizenPolicyTest, initialize_P2) +{ + bool ret; + + DSWaylandCompositor *compositor = DSWaylandCompositor::getInstance(); + DSWaylandTizenPolicy *tizenPolicy = new DSWaylandTizenPolicy(nullptr); + + ret = tizenPolicy->initialize(compositor); + EXPECT_TRUE(ret == true); + + delete tizenPolicy; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTizenPolicyTest, initialize_N1) +{ + bool ret; + DSWaylandTizenPolicy *tizenPolicy = new DSWaylandTizenPolicy(nullptr); + + ret = tizenPolicy->initialize(nullptr); + EXPECT_TRUE(ret == false); + + delete tizenPolicy; +}