utest: Add 26 test cases 32/160532/1
authorKonstantin Drabeniuk <k.drabeniuk@samsung.com>
Thu, 16 Nov 2017 15:17:12 +0000 (17:17 +0200)
committerKonstantin Drabeniuk <k.drabeniuk@samsung.com>
Thu, 16 Nov 2017 15:17:50 +0000 (17:17 +0200)
Covered API funcs. from the tdm_pp.c file.

Change-Id: I3c0c123d90fdde0929b88cdccb56a456b3d6853a
Signed-off-by: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
utests/src/ut_tdm_layer.cpp
utests/src/ut_tdm_pp.cpp
utests/src/ut_tdm_vblank.cpp

index dbcceab..21a552d 100644 (file)
@@ -72,8 +72,12 @@ protected:
 
                SetEnv();
 
+               /* FIXME: fix the error. If we initialize TBM before TDM we get fail
+                * in the tdm_output_set_dpms */
+#if 0
                tbm_bufmgr = tbm_bufmgr_init(-1);
                ASSERT_FALSE(tbm_bufmgr == NULL);
+#endif
 
                dpy = tdm_display_init(&error);
                ASSERT_TRUE(error == TDM_ERROR_NONE);
@@ -258,7 +262,8 @@ protected:
 
                utLayerCommitHandlerCounter = 0;
 
-               TDMLayer::SetUp();
+               ASSERT_NO_FATAL_FAILURE(TDMLayer::SetUp());
+
                for (int i = 0; i < output_count; ++i) {
                        if (!preferred_mode_array[i])
                                continue;
@@ -1813,10 +1818,10 @@ TEST_F(TDMLayerCommitWithDisabledCommitPerVblank, LayerSetBufferQueueSuccessRemo
        for (int i = 0; i < layer_count; ++i) {
                tbm_surface_h surface;
 
-               tbm_err = tbm_surface_queue_dequeue(buffer_queue, &surface);
+               tbm_err = tbm_surface_queue_dequeue(tdm_layers_buffer_queue_array[i], &surface);
                ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, error);
 
-               tbm_err = tbm_surface_queue_enqueue(buffer_queue, surface);
+               tbm_err = tbm_surface_queue_enqueue(tdm_layers_buffer_queue_array[i], surface);
                ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, error);
 
                error = tdm_layer_unset_buffer_queue(tdm_layer_array[i]);
index 5ea127a..fdd1353 100644 (file)
 
 #include "gtest/gtest.h"
 #include "ut_common.h"
-extern "C" {
 #include "tdm.h"
+extern "C" {
 #include "tbm_bufmgr.h"
 #include "tbm_drm_helper.h"
 }
 
-class TDMPP : public testing::Test {
+#include <sys/epoll.h>
+#include <sys/timerfd.h>
+#include <list>
+#include <limits.h>
+
+#define SIZE_ALIGN(value, base) (((value) + ((base) - 1)) & ~((base) - 1))
+
+class TDMPPWithoutCreation : public testing::Test {
 protected:
        tdm_display *dpy = NULL;
-       tdm_pp_capability pp_capabilities = (tdm_pp_capability) -42;
+       tbm_bufmgr bufmgr;
+       tdm_display_capability display_capability = (tdm_display_capability)0;
        bool has_pp = false;
-       void SetUp(void)
+       std::list<tbm_surface_h> buffers_list;
+
+       virtual void SetEnvs()
        {
                setenv("TDM_DLOG", "1", 1);
                setenv("XDG_RUNTIME_DIR", ".", 1);
                setenv("TBM_DLOG", "1", 1);
+               setenv("TDM_DEBUG_MODULE", "all", 1);
+               setenv("TDM_DEBUG", "1", 1);
+               setenv("TBM_DISPLAY_SERVER", "1", 1);
+       }
+
+       virtual void UnsetEnvs()
+       {
+               unsetenv("TDM_DLOG");
+               unsetenv("XDG_RUNTIME_DIR");
+               unsetenv("TBM_DLOG");
+               unsetenv("TDM_DEBUG_MODULE");
+               unsetenv("TDM_DEBUG");
+               unsetenv("TBM_DISPLAY_SERVER");
+       }
+
+       void SetUp(void)
+       {
                tdm_error error = TDM_ERROR_NONE;
+
+               SetEnvs();
+
+               bufmgr = tbm_bufmgr_init(-1);
+               ASSERT_FALSE(bufmgr == NULL);
+
                dpy = tdm_display_init(&error);
                ASSERT_TRUE(error == TDM_ERROR_NONE);
                ASSERT_FALSE(dpy == NULL);
-               error = tdm_display_get_pp_capabilities(dpy, &pp_capabilities);
+
+               error = tdm_display_get_capabilities(dpy, &display_capability);
 #ifdef FAIL_ON_UNSUPPORTED
-               ASSERT_GT(pp_capabilities, 0);
+               ASSERT_TRUE(display_capability & TDM_DISPLAY_CAPABILITY_PP);
 #endif
-               if (pp_capabilities > 0)
+               ASSERT_TRUE(error == TDM_ERROR_NONE);
+
+               if (display_capability & TDM_DISPLAY_CAPABILITY_PP)
                        has_pp = true;
        }
+
        void TearDown(void)
        {
-               tdm_display_deinit(dpy);
-               dpy = NULL;
-               unsetenv("TDM_DLOG");
-               unsetenv("XDG_RUNTIME_DIR");
-               unsetenv("TBM_DLOG");
-               unsetenv("TBM_DISPLAY_SERVER");
+               if (dpy)
+                       tdm_display_deinit(dpy);
+               if (bufmgr)
+                       tbm_bufmgr_deinit(bufmgr);
+
+               UnsetEnvs();
+       }
+};
+
+class TDMPP : public TDMPPWithoutCreation {
+protected:
+       tdm_pp *pp = NULL;
+       const tbm_format *formats = NULL;
+       int format_count = 0;
+       int min_w = 0;
+       int min_h = 0;
+       int max_w = 0;
+       int max_h = 0;
+       int preferred_align = 0;
+       int default_src_w = 128;
+       int default_src_h = 256;
+       int default_dst_w = 512;
+       int default_dst_h = 1024;
+
+       void SetUp(void)
+       {
+               tdm_error error;
+
+               ASSERT_NO_FATAL_FAILURE(TDMPPWithoutCreation::SetUp());
+
+               if (!has_pp)
+                       return;
+
+               pp = tdm_display_create_pp(dpy, &error);
+               ASSERT_NE(NULL, pp);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               error =
+                       tdm_display_get_pp_available_formats(dpy, &formats, &format_count);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+               ASSERT_NE(NULL, formats);
+               ASSERT_GE(format_count, 0);
+
+               error =
+                               tdm_display_get_pp_available_size(dpy, &min_w, &min_h,
+                                                                                                 &max_w, &max_h, &preferred_align);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+               if (preferred_align > 0) {
+                       default_src_w = SIZE_ALIGN(default_src_w, preferred_align);
+                       default_src_h = SIZE_ALIGN(default_src_h, preferred_align);
+                       default_dst_w = SIZE_ALIGN(default_dst_w, preferred_align);
+                       default_dst_h = SIZE_ALIGN(default_dst_h, preferred_align);
+               }
+               if (min_w > default_src_w)
+                       default_src_w = min_w;
+               if (min_h > default_src_h)
+                       default_src_h = min_h;
+               if (max_w > 0 && max_w < default_dst_w)
+                       default_dst_w = max_w;
+               if (max_h > 0 && max_h < default_dst_h)
+                       default_dst_h = max_h;
+       }
+
+       void TearDown(void)
+       {
+               if (pp)
+                       tdm_pp_destroy(pp);
+
+               for (auto it = buffers_list.begin(); it != buffers_list.end(); ++it) {
+                       tbm_surface_destroy(*it);
+               }
+
+               buffers_list.clear();
+
+               TDMPPWithoutCreation::TearDown();
+       }
+
+       void UtGetPPInfoWithScale(tdm_info_pp *info)
+       {
+               memset((void *)info, 0, sizeof(tdm_info_pp));
+
+               info->src_config.size.h = default_src_w;
+               info->src_config.size.v = default_src_h;
+               info->src_config.pos.x = 0;
+               info->src_config.pos.y = 0;
+               info->src_config.pos.w = default_src_w;
+               info->src_config.pos.h = default_src_h;
+               info->src_config.format = formats[0];
+               info->dst_config.size.h = default_dst_w;
+               info->dst_config.size.v = default_dst_h;
+               info->dst_config.pos.x = 0;
+               info->dst_config.pos.y = 0;
+               info->dst_config.pos.w = default_dst_w;
+               info->dst_config.pos.h = default_dst_h;
+               info->dst_config.format = formats[0];
+       }
+
+       void UtGetPPInfoWithScaleAndTransform(tdm_info_pp *info)
+       {
+               UtGetPPInfoWithScale(info);
+
+               info->transform = TDM_TRANSFORM_180;
+       }
+
+       void UtGetPPInfoWithWrongInfo(tdm_info_pp *info)
+       {
+               info->src_config.size.h = UINT_MAX;
+               info->src_config.size.v = UINT_MAX;
+               info->src_config.pos.x = 0;
+               info->src_config.pos.y = 0;
+               info->src_config.pos.w = UINT_MAX;
+               info->src_config.pos.h = UINT_MAX;
+               info->src_config.format = INT_MAX;
+               info->dst_config.size.h = UINT_MAX;
+               info->dst_config.size.v = UINT_MAX;
+               info->dst_config.pos.x = 0;
+               info->dst_config.pos.y = 0;
+               info->dst_config.pos.w = UINT_MAX;
+               info->dst_config.pos.h = UINT_MAX;
+               info->dst_config.format = INT_MAX;
+       }
+
+       tbm_surface_h
+       UtCreateBuffer(int w, int h, tbm_format format)
+       {
+               tbm_surface_h buffer;
+
+               buffer = tbm_surface_create(w, h, format);
+               if (buffer)
+                       buffers_list.push_back(buffer);
+
+               return buffer;
        }
 };
 
-TEST_F(TDMPP, DisplayGetPPAvailableFormatsSuccessful)
+void UtPpDoneHandler(tdm_pp *pp, tbm_surface_h src,
+                                                       tbm_surface_h dst, void *user_data);
+
+class TDMPPCommit : public TDMPP {
+public:
+       friend void UtPpDoneHandler(tdm_pp *pp, tbm_surface_h src,
+                                                               tbm_surface_h dst, void *user_data);
+private:
+       int epFd = -1;
+       int timerFd = -1;
+       int tdmFd = -1;
+       static const int timeLimitSec = 0;
+       static const int timeLimitNsec = 100000000;
+protected:
+       int utPpDoneHandlerSuccessCounter = 0;
+
+       void SetUp(void)
+       {
+               tdm_error error;
+               tdm_output *output;
+               struct epoll_event ep;
+               tdm_pp_capability pp_capability;
+
+               ASSERT_NO_FATAL_FAILURE(TDMPP::SetUp());
+
+               epFd = epoll_create1(0);
+               ASSERT_TRUE(epFd != -1);
+
+               timerFd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
+               ASSERT_TRUE(timerFd != -1);
+
+               memset(&ep, 0, sizeof ep);
+               ep.events |= EPOLLIN;
+               ep.data.fd = timerFd;
+               ASSERT_TRUE(epoll_ctl(epFd, EPOLL_CTL_ADD, timerFd, &ep) == 0);
+
+               ASSERT_TRUE(tdm_display_get_fd(dpy, &tdmFd) == TDM_ERROR_NONE);
+
+               memset(&ep, 0, sizeof ep);
+               ep.events |= EPOLLIN;
+               ep.data.fd = tdmFd;
+               ASSERT_TRUE(epoll_ctl(epFd, EPOLL_CTL_ADD, tdmFd, &ep) == 0);
+       }
+
+       void TearDown(void)
+       {
+               tdm_error error;
+
+               if (epFd)
+                       close(epFd);
+               if (timerFd)
+                       close(timerFd);
+
+               TDMPP::TearDown();
+       }
+
+       void UtHandlePPEvent(int num_attached_buffers)
+       {
+               struct itimerspec its;
+               int count;
+               struct epoll_event ep_event[2];
+
+               if (utPpDoneHandlerSuccessCounter == num_attached_buffers)
+                       return;
+
+               its.it_interval.tv_sec = 0;
+               its.it_interval.tv_nsec = 0;
+               its.it_value.tv_sec = timeLimitSec;
+               its.it_value.tv_nsec = timeLimitNsec;
+
+               ASSERT_TRUE(timerfd_settime(timerFd, 0, &its, NULL) == 0);
+
+               while (1) {
+                       count = epoll_wait(epFd, ep_event, sizeof(ep_event), -1);
+                       ASSERT_TRUE(count >= 0);
+
+                       for (int i = 0; i < count; i++) {
+                               if (ep_event[i].data.fd == timerFd) {
+                                       return;
+                               } else {
+                                       ASSERT_TRUE(tdm_display_handle_events(dpy) == TDM_ERROR_NONE);
+                                       if (utPpDoneHandlerSuccessCounter == num_attached_buffers)
+                                               return;
+                               }
+                       }
+               }
+       }
+
+       int UtPrepareToPP(tdm_info_pp *info)
+       {
+               tdm_error error;
+               tbm_surface_h src_buf, dst_buf;
+
+               error = tdm_pp_set_done_handler(pp, UtPpDoneHandler, this);
+               EXPECT_EQ(TDM_ERROR_NONE, error);
+               if (error != TDM_ERROR_NONE)
+                       return -1;
+
+               error = tdm_pp_set_info(pp, info);
+               EXPECT_EQ(TDM_ERROR_NONE, error);
+               if (error != TDM_ERROR_NONE)
+                       return -1;
+
+               src_buf = UtCreateBuffer(info->src_config.pos.w, info->src_config.pos.h,
+                                                                info->src_config.format);
+               EXPECT_NE(NULL, src_buf);
+               if (!src_buf)
+                       return -1;
+
+               dst_buf = UtCreateBuffer(info->dst_config.pos.w, info->dst_config.pos.h,
+                                                                info->dst_config.format);
+               EXPECT_NE(NULL, dst_buf);
+               if (!dst_buf)
+                       return -1;
+
+               error = tdm_pp_attach(pp, src_buf, dst_buf);
+               EXPECT_EQ(TDM_ERROR_NONE, error);
+               if (error != TDM_ERROR_NONE)
+                       return -1;
+
+       }
+
+       int UtPrepareToPPWithScale()
+       {
+               tdm_info_pp info = {0};
+               tdm_error error;
+               tbm_surface_h src_buf, dst_buf;
+
+               UtGetPPInfoWithScale(&info);
+
+               return UtPrepareToPP(&info);
+       }
+
+       int UtPrepareToPPWithScaleAndTransform()
+       {
+               tdm_info_pp info = {0};
+               tdm_error error;
+               tbm_surface_h src_buf, dst_buf;
+
+               UtGetPPInfoWithScaleAndTransform(&info);
+
+               return UtPrepareToPP(&info);
+       }
+
+       int UtPrepareToPPWithWrongInfo()
+       {
+               tdm_info_pp info = {0};
+               tdm_error error;
+               tbm_surface_h src_buf, dst_buf;
+               int ret;
+
+               UtGetPPInfoWithScale(&info);
+
+               ret = UtPrepareToPP(&info);
+               if (ret < 0)
+                       return ret;
+
+               UtGetPPInfoWithWrongInfo(&info);
+
+               error = tdm_pp_set_info(pp, &info);
+               EXPECT_EQ(TDM_ERROR_NONE, error);
+               if (error != TDM_ERROR_NONE)
+                       return -1;
+
+               return 0;
+       }
+
+};
+
+class TDMPPCommitThread : public TDMPPCommit {
+protected:
+       void SetEnvs()
+       {
+               TDMPPCommit::SetEnvs();
+               setenv("TDM_THREAD", "1", 1);
+       }
+       void UnsetEnvs()
+       {
+               TDMPPCommit::UnsetEnvs();
+               unsetenv("TDM_THREAD");
+       }
+};
+
+void UtPpDoneHandler(tdm_pp *pp, tbm_surface_h src,
+                                                       tbm_surface_h dst, void *user_data)
+{
+       TDMPPCommit *pp_commit = (TDMPPCommit *)user_data;
+       bool src_valid, dst_valid;
+
+       if (!pp_commit)
+               return;
+
+       for (auto it = pp_commit->buffers_list.begin(); it != pp_commit->buffers_list.end(); ++it) {
+               if (*it == src)
+                       src_valid = true;
+               if (*it == dst)
+                       dst_valid = true;
+       }
+
+       if (src_valid && dst_valid)
+               pp_commit->utPpDoneHandlerSuccessCounter++;
+}
+
+TEST_F(TDMPPWithoutCreation, DisplayGetPPAvailableFormatsSuccessful)
 {
        SKIP_FLAG(has_pp);
-       const tbm_format * formats = NULL;
+       const tbm_format *formats = NULL;
        int count = -42;
        ASSERT_TRUE(TDM_ERROR_NONE == tdm_display_get_pp_available_formats(dpy, &formats, &count));
        ASSERT_FALSE(-42 == count);
        ASSERT_FALSE(NULL == formats);
 }
+
+/* tdm_display_create_pp() */
+
+TEST_F(TDMPPWithoutCreation, DisplayCreatePPNullAll)
+{
+       SKIP_FLAG(has_pp);
+       tdm_pp *pp;
+
+       pp = tdm_display_create_pp(NULL, NULL);
+       ASSERT_EQ(NULL, pp);
+}
+
+TEST_F(TDMPPWithoutCreation, DisplayCreatePPNullDpy)
+{
+       SKIP_FLAG(has_pp);
+       tdm_pp *pp;
+       tdm_error error;
+
+       pp = tdm_display_create_pp(NULL, &error);
+       ASSERT_EQ(NULL, pp);
+       ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_F(TDMPPWithoutCreation, DisplayCreatePPSuccessNullError)
+{
+       SKIP_FLAG(has_pp);
+       tdm_pp *pp;
+
+       pp = tdm_display_create_pp(dpy, NULL);
+       ASSERT_NE(NULL, pp);
+}
+
+TEST_F(TDMPPWithoutCreation, DisplayCreatePPSuccess)
+{
+       SKIP_FLAG(has_pp);
+       tdm_pp *pp;
+       tdm_error error;
+
+       pp = tdm_display_create_pp(dpy, &error);
+       ASSERT_NE(NULL, pp);
+       ASSERT_EQ(TDM_ERROR_NONE, error);
+}
+
+/* tdm_pp_set_info() */
+
+TEST_F(TDMPP, PpSetInfoNullAll)
+{
+       SKIP_FLAG(has_pp);
+       tdm_error error;
+
+       error = tdm_pp_set_info(NULL, NULL);
+       ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_F(TDMPP, PpSetInfoNullPP)
+{
+       SKIP_FLAG(has_pp);
+       tdm_error error;
+       tdm_info_pp info;
+
+       error = tdm_pp_set_info(NULL, &info);
+       ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_F(TDMPP, PpSetInfoNullInfo)
+{
+       SKIP_FLAG(has_pp);
+       tdm_error error;
+
+       error = tdm_pp_set_info(pp, NULL);
+       ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_F(TDMPP, PpSetInfoSuccess)
+{
+       SKIP_FLAG(has_pp);
+       tdm_error error;
+       tdm_info_pp info;
+
+       UtGetPPInfoWithScale(&info);
+
+       error = tdm_pp_set_info(pp, &info);
+       ASSERT_EQ(TDM_ERROR_NONE, error);
+}
+
+/* tdm_pp_set_done_handler() */
+
+TEST_F(TDMPP, PpSetDoneHandlerFailNullAll)
+{
+       SKIP_FLAG(has_pp);
+       tdm_error error;
+
+       error = tdm_pp_set_done_handler(NULL, NULL, NULL);
+       ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_F(TDMPP, PpSetDoneHandlerFailNullPP)
+{
+       SKIP_FLAG(has_pp);
+       tdm_error error;
+       int data;
+
+       error = tdm_pp_set_done_handler(NULL, UtPpDoneHandler, this);
+       ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_F(TDMPP, PpSetDoneHandlerSuccessNullFailNullFunc)
+{
+       SKIP_FLAG(has_pp);
+       tdm_error error;
+       int data;
+
+       error = tdm_pp_set_done_handler(pp, NULL, &data);
+       ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_F(TDMPP, PpSetDoneHandlerSuccessNullData)
+{
+       SKIP_FLAG(has_pp);
+       tdm_error error;
+
+       error = tdm_pp_set_done_handler(pp, UtPpDoneHandler, this);
+       ASSERT_EQ(TDM_ERROR_NONE, error);
+}
+
+TEST_F(TDMPP, PpSetDoneHandlerSuccess)
+{
+       SKIP_FLAG(has_pp);
+       tdm_error error;
+       int data;
+
+       error = tdm_pp_set_done_handler(pp, UtPpDoneHandler, this);
+       ASSERT_EQ(TDM_ERROR_NONE, error);
+}
+
+/* tdm_pp_attach() */
+
+TEST_F(TDMPP, PpAttachFailNullAll)
+{
+       SKIP_FLAG(has_pp);
+       tdm_error error;
+
+       error = tdm_pp_attach(NULL, NULL, NULL);
+       ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_F(TDMPP, PpAttachFailNullPp)
+{
+       SKIP_FLAG(has_pp);
+       tdm_error error;
+       tbm_surface_h dst_buf, src_buf;
+
+       src_buf = UtCreateBuffer(default_src_w, default_src_h, formats[0]);
+       ASSERT_NE(NULL, src_buf);
+
+       dst_buf = UtCreateBuffer(default_dst_w, default_dst_h, formats[0]);
+       ASSERT_NE(NULL, dst_buf);
+
+       error = tdm_pp_attach(NULL, src_buf, dst_buf);
+       ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_F(TDMPP, PpAttachFailNullSrc)
+{
+       SKIP_FLAG(has_pp);
+       tdm_error error;
+       tbm_surface_h dst_buf;
+
+       dst_buf = UtCreateBuffer(default_dst_w, default_dst_h, formats[0]);
+       ASSERT_NE(NULL, dst_buf);
+
+       error = tdm_pp_attach(pp, NULL, dst_buf);
+       ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_F(TDMPP, PpAttachFailNullDst)
+{
+       SKIP_FLAG(has_pp);
+       tdm_error error;
+       tbm_surface_h src_buf;
+
+       src_buf = UtCreateBuffer(default_src_w, default_src_h, formats[0]);
+       ASSERT_NE(NULL, src_buf);
+
+       error = tdm_pp_attach(pp, src_buf, NULL);
+       ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_F(TDMPP, PpAttachSuccess)
+{
+       SKIP_FLAG(has_pp);
+       tdm_error error;
+       tbm_surface_h dst_buf, src_buf;
+
+       src_buf = UtCreateBuffer(default_src_w, default_src_h, formats[0]);
+       ASSERT_NE(NULL, src_buf);
+
+       dst_buf = UtCreateBuffer(default_dst_w, default_dst_h, formats[0]);
+       ASSERT_NE(NULL, dst_buf);
+
+       error = tdm_pp_attach(pp, src_buf, dst_buf);
+       ASSERT_EQ(TDM_ERROR_NONE, error);
+}
+
+/* tdm_pp_commit() */
+
+TEST_F(TDMPP, PpCommitFailNullPP)
+{
+       SKIP_FLAG(has_pp);
+       tdm_error error;
+
+       error = tdm_pp_commit(NULL);
+       ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_F(TDMPPCommit, PpCommitFailWrongInfo)
+{
+       SKIP_FLAG(has_pp);
+       tdm_error error;
+
+       ASSERT_NE(-1, UtPrepareToPPWithWrongInfo());
+
+       error = tdm_pp_commit(pp);
+       ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_F(TDMPPCommit, PpCommitSuccessScale)
+{
+       SKIP_FLAG(has_pp);
+       tdm_error error;
+
+       ASSERT_NE(-1, UtPrepareToPPWithScale());
+
+       error = tdm_pp_commit(pp);
+       ASSERT_EQ(TDM_ERROR_NONE, error);
+
+       UtHandlePPEvent(1);
+
+       ASSERT_EQ(1, utPpDoneHandlerSuccessCounter);
+}
+
+TEST_F(TDMPPCommit, PpCommitSuccessScaleAndTransform)
+{
+       SKIP_FLAG(has_pp);
+       tdm_error error;
+
+       ASSERT_NE(-1, UtPrepareToPPWithScale());
+
+       error = tdm_pp_commit(pp);
+       ASSERT_EQ(TDM_ERROR_NONE, error);
+
+       UtHandlePPEvent(1);
+
+       ASSERT_EQ(1, utPpDoneHandlerSuccessCounter);
+}
+
+TEST_F(TDMPPCommitThread, PpCommitSuccessScale)
+{
+       SKIP_FLAG(has_pp);
+       tdm_error error;
+
+       ASSERT_NE(-1, UtPrepareToPPWithScale());
+
+       error = tdm_pp_commit(pp);
+       ASSERT_EQ(TDM_ERROR_NONE, error);
+
+       UtHandlePPEvent(1);
+
+       ASSERT_EQ(1, utPpDoneHandlerSuccessCounter);
+}
+
+TEST_F(TDMPPCommitThread, PpCommitSuccessScaleAndTransform)
+{
+       SKIP_FLAG(has_pp);
+       tdm_error error;
+
+       ASSERT_NE(-1, UtPrepareToPPWithScale());
+
+       error = tdm_pp_commit(pp);
+       ASSERT_EQ(TDM_ERROR_NONE, error);
+
+       UtHandlePPEvent(1);
+
+       ASSERT_EQ(1, utPpDoneHandlerSuccessCounter);
+}
+
+/* tdm_pp_destroy() */
+
+void UtBufferReleaseHandler(tbm_surface_h buffer,
+                                                          void *user_data)
+{
+       int *data = (int *)user_data;
+       if (!data)
+               return;
+
+       (*data)++;
+}
+
+TEST_F(TDMPPCommit, PPDestroySuccessAfterCommit)
+{
+       SKIP_FLAG(has_pp);
+       tdm_error error;
+       int release_data = 0;
+
+       ASSERT_NE(-1, UtPrepareToPPWithScale());
+
+       for (auto it = buffers_list.begin(); it != buffers_list.end(); ++it) {
+               tdm_buffer_add_release_handler((tbm_surface_h)*it, UtBufferReleaseHandler, &release_data);
+       }
+
+       error = tdm_pp_commit(pp);
+       ASSERT_EQ(TDM_ERROR_NONE, error);
+
+       tdm_pp_destroy(pp);
+       pp = NULL;
+
+       ASSERT_EQ(2, release_data);
+}
index 746d4c7..b8701ab 100644 (file)
@@ -57,8 +57,12 @@ protected:
                setenv("TBM_DLOG", "1", 1);
                setenv("TBM_DISPLAY_SERVER", "1", 1);
 
-               bufmgr = tbm_bufmgr_init(-1);
-               ASSERT_FALSE(bufmgr == NULL);
+               /* FIXME: fix the error. If we initialize TBM before TDM we get fail
+                * in the tdm_output_set_dpms */
+#if 0
+               tbm_bufmgr = tbm_bufmgr_init(-1);
+               ASSERT_FALSE(tbm_bufmgr == NULL);
+#endif
 
                dpy = tdm_display_init(&error);
                ASSERT_TRUE(error == TDM_ERROR_NONE);
@@ -138,7 +142,7 @@ protected:
        {
                tdm_error error;
 
-               TDMVblankWithoutCreating::SetUp();
+               ASSERT_NO_FATAL_FAILURE(TDMVblankWithoutCreating::SetUp());
 
                if (connected_output && setModeAndDpms) {
                        int primary_index;
@@ -250,7 +254,8 @@ protected:
                utVblankHandlerIsCalled = 0;
 
                setModeAndDpms = 1;
-               TDMVblank::SetUp();
+
+               ASSERT_NO_FATAL_FAILURE(TDMVblank::SetUp());
 
                epFd = epoll_create1(0);
                ASSERT_TRUE(epFd != -1);
@@ -309,7 +314,7 @@ protected:
        void SetUp(void)
        {
                setenv("TDM_THREAD", "1", 1);
-               TDMVblankWait::SetUp();
+               ASSERT_NO_FATAL_FAILURE(TDMVblankWait::SetUp());
        }
 };