utests: Add 83 test cases 42/160342/2
authorKonstantin Drabeniuk <k.drabeniuk@samsung.com>
Wed, 15 Nov 2017 12:09:02 +0000 (14:09 +0200)
committerSooChan Lim <sc1.lim@samsung.com>
Wed, 15 Nov 2017 12:26:43 +0000 (12:26 +0000)
Covered API funcs. from the tdm_layer.c file.

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

index 265281c..dbcceab 100644 (file)
 
 #include "gtest/gtest.h"
 #include "ut_common.h"
+#include <limits.h>
+#include <string.h>
+#include <sys/epoll.h>
+#include <sys/timerfd.h>
 
-extern "C" {
 #include "tdm.h"
+extern "C" {
 #include "tbm_bufmgr.h"
 #include "tbm_drm_helper.h"
+#include "tbm_surface.h"
+#include "tbm_surface_queue.h"
 }
 
 class TDMLayer : public ::testing::Test {
@@ -42,32 +48,76 @@ protected:
        tdm_display *dpy = NULL;
        tbm_bufmgr tbm_bufmgr = NULL;
        int master_fd = -42, tbm_fd = -42, layer_count = 0, output_count = 0;
-       tdm_layer ** tdm_layer_array = NULL;
+       tdm_layer **tdm_layer_array = NULL;
+       tbm_surface_h *tdm_layers_buffer_array = NULL;
+       tbm_surface_queue_h *tdm_layers_buffer_queue_array = NULL;
+       int *tdm_layer_output_idx = NULL;
+       const tdm_output_mode **preferred_mode_array = NULL;
        bool has_layers = false;
-       void SetUp(void)
+       virtual void SetEnv()
        {
+               setenv("TDM_DEBUG_MODULE", "all", 1);
+               setenv("TDM_DEBUG", "1", 1);
+               setenv("TDM_THREAD", "0", 1);
+               setenv("TDM_COMMIT_PER_VBLANK", "1", 1);
                setenv("TDM_DLOG", "1", 1);
                setenv("XDG_RUNTIME_DIR", ".", 1);
                setenv("TBM_DLOG", "1", 1);
                setenv("TBM_DISPLAY_SERVER", "1", 1);
+       }
+       void SetUp(void)
+       {
+               const tdm_output_mode *preferred_mode = NULL;
+               tdm_error error = TDM_ERROR_NONE;
+
+               SetEnv();
+
                tbm_bufmgr = tbm_bufmgr_init(-1);
                ASSERT_FALSE(tbm_bufmgr == NULL);
-               tdm_error error = TDM_ERROR_NONE;
+
                dpy = tdm_display_init(&error);
                ASSERT_TRUE(error == TDM_ERROR_NONE);
                ASSERT_FALSE(dpy == NULL);
+
                master_fd = tbm_drm_helper_get_master_fd();
                tbm_fd = tbm_drm_helper_get_fd();
                ASSERT_TRUE(tdm_display_get_output_count(dpy, &output_count) == TDM_ERROR_NONE);
+
+               tdm_layer_output_idx = (int *) calloc(output_count, sizeof(int));
+               ASSERT_FALSE(NULL == tdm_layer_output_idx);
+
+               preferred_mode_array = (const tdm_output_mode **)calloc(output_count, sizeof(tdm_output_mode *));
+               ASSERT_FALSE(NULL == preferred_mode_array);
+
                for (int i = 0; i < output_count; i++) {
-                       tdm_output * output = tdm_display_get_output(dpy, i, &error);
+                       tdm_output *output = tdm_display_get_output(dpy, i, &error);
+                       int output_modes_cnt = 0;
+                       const tdm_output_mode *output_modes;
+
                        if (TDM_ERROR_NONE != error || NULL == output)
                                continue;
+
                        tdm_output_conn_status status = TDM_OUTPUT_CONN_STATUS_DISCONNECTED;
                        if (TDM_ERROR_NONE != tdm_output_get_conn_status(output, &status))
                                continue;
+
                        if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED)
                                continue;
+
+                       error = tdm_output_get_available_modes(output, &output_modes, &output_modes_cnt);
+                       if (TDM_ERROR_NONE != error)
+                               continue;
+                       if (output_modes_cnt <= 0) {
+                               continue;
+                       }
+
+                       for(int j = 0; j < output_modes_cnt; j++)
+                               if(output_modes[j].type & TDM_OUTPUT_MODE_TYPE_PREFERRED)
+                                       preferred_mode = &output_modes[j];
+
+                       if (!preferred_mode)
+                               continue;
+
                        int temp_layer_count = 0;
                        if (TDM_ERROR_NONE != tdm_output_get_layer_count(output, &temp_layer_count))
                                continue;
@@ -75,15 +125,25 @@ protected:
                                continue;
                        tdm_layer_array = (tdm_layer **) realloc(tdm_layer_array,
                                                                                                         (layer_count + temp_layer_count)*sizeof(tdm_layer *));
+
                        ASSERT_FALSE(NULL == tdm_layer_array);
+
                        for (int k = layer_count; k < (layer_count + temp_layer_count); k++) {
                                tdm_layer_array[k] = tdm_output_get_layer(output, k, &error);
+                               tdm_layer_output_idx[k] = i;
                                ASSERT_TRUE(TDM_ERROR_NONE == error);
                                ASSERT_FALSE(NULL == tdm_layer_array[k]);
                        }
-                       layer_count+=temp_layer_count;
+                       layer_count += temp_layer_count;
+                       preferred_mode_array[i] = preferred_mode;
                }
 
+               tdm_layers_buffer_array = (tbm_surface_h *) calloc(layer_count, sizeof(tbm_surface_h));
+               ASSERT_FALSE(NULL == tdm_layers_buffer_array);
+
+               tdm_layers_buffer_queue_array = (tbm_surface_queue_h *) calloc(layer_count, sizeof(tbm_surface_queue_h));
+               ASSERT_FALSE(NULL == tdm_layers_buffer_queue_array);
+
 #ifdef FAIL_ON_UNSUPPORTED
                ASSERT_GT(layer_count, 0);
 #endif
@@ -92,12 +152,32 @@ protected:
        }
        void TearDown(void)
        {
+               tdm_error error;
+
+               for (int i = 0; i < layer_count; ++i) {
+                       error = tdm_layer_unset_buffer(tdm_layer_array[i]);
+                       EXPECT_TRUE(error == TDM_ERROR_NONE);
+
+                       if (tdm_layers_buffer_array[i])
+                               tbm_surface_destroy(tdm_layers_buffer_array[i]);
+
+                       if (tdm_layers_buffer_queue_array[i])
+                               tbm_surface_queue_destroy(tdm_layers_buffer_queue_array[i]);
+
+                       tdm_layers_buffer_array[i] = NULL;
+                       tdm_layers_buffer_queue_array[i] = NULL;
+               }
+
                tdm_display_deinit(dpy);
                dpy = NULL;
                tbm_bufmgr_deinit(tbm_bufmgr);
                tbm_bufmgr = NULL;
                if (tdm_layer_array)
                        free(tdm_layer_array);
+               if (tdm_layer_output_idx)
+                       free(tdm_layer_output_idx);
+               if (preferred_mode_array)
+                       free(preferred_mode_array);
                if (master_fd > -1) {
                        int temp_master_fd = tbm_drm_helper_get_master_fd();
                        EXPECT_EQ(temp_master_fd, -1) << "Fatal Error. Can't deinit tdm/tbm" << std::endl;
@@ -112,13 +192,194 @@ protected:
                                exit(1);
                        close(tbm_fd);
                }
+
+               unsetenv("TDM_DEBUG_MODULE");
+               unsetenv("TDM_DEBUG");
+               unsetenv("TDM_THREAD");
+               unsetenv("TDM_COMMIT_PER_VBLANK");
                unsetenv("TDM_DLOG");
                unsetenv("XDG_RUNTIME_DIR");
                unsetenv("TBM_DLOG");
                unsetenv("TBM_DISPLAY_SERVER");
        }
+
+       tbm_surface_h UtCreateBufferForLayer(int layer_idx, int width, int height,
+                                                                                int format, int flags)
+       {
+               tbm_surface_h buffer;
+
+               buffer = tbm_surface_internal_create_with_flags(width, height, format, flags);
+
+               tdm_layers_buffer_array[layer_idx] = buffer;
+
+               return buffer;
+       }
+
+       tbm_surface_queue_h UtCreateBufferQueueForLayer(int layer_idx, int width, int height,
+                                                                                int format, int flags)
+       {
+               tbm_surface_queue_h buffer_queue;
+
+               buffer_queue = tbm_surface_queue_create(2, width, height, format, flags);
+
+               tdm_layers_buffer_queue_array[layer_idx] = buffer_queue;
+
+               return buffer_queue;
+       }
+};
+
+class TDMLayerCommit : public TDMLayer
+{
+private:
+       int epFd = -1;
+       int timerFd = -1;
+       int tdmFd = -1;
+       static const int timeLimitSec = 0;
+       static const int timeLimitNsec = 100000000;
+
+protected:
+       static int utLayerCommitHandlerCounter;
+       static void UtLayerCommitHandler(tdm_layer *layer, unsigned int sequence,
+                                                                        unsigned int tv_sec, unsigned int tv_usec,
+                                                                        void *user_data)
+       {
+               int *data = (int *)user_data;
+               if (data)
+                       (*data)++;
+
+               utLayerCommitHandlerCounter++;
+       }
+
+       void SetUp(void)
+       {
+               tdm_error error;
+               tdm_output *output;
+               struct epoll_event ep;
+
+               utLayerCommitHandlerCounter = 0;
+
+               TDMLayer::SetUp();
+               for (int i = 0; i < output_count; ++i) {
+                       if (!preferred_mode_array[i])
+                               continue;
+
+                       output = tdm_display_get_output(dpy, i, &error);
+                       ASSERT_FALSE(output == NULL);
+                       ASSERT_TRUE(error == TDM_ERROR_NONE);
+
+                       error = tdm_output_set_mode(output, preferred_mode_array[i]);
+                       ASSERT_TRUE(error == TDM_ERROR_NONE);
+
+                       error = tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON);
+                       ASSERT_TRUE(error == TDM_ERROR_NONE);
+               }
+
+               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_output *output;
+               tdm_error error;
+
+               for (int i = 0; i < output_count; ++i) {
+                       if (!preferred_mode_array[i])
+                               continue;
+
+                       output = tdm_display_get_output(dpy, i, &error);
+                       EXPECT_FALSE(output == NULL);
+                       EXPECT_TRUE(error == TDM_ERROR_NONE);
+
+                       error = tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF);
+                       EXPECT_TRUE(error == TDM_ERROR_NONE);
+               }
+
+               TDMLayer::TearDown();
+       }
+
+       void UtHandleCommitEvent(int num_waiting_layers)
+       {
+               struct itimerspec its;
+               int count;
+               struct epoll_event ep_event[2];
+
+               if (utLayerCommitHandlerCounter == num_waiting_layers)
+                       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 (utLayerCommitHandlerCounter == num_waiting_layers)
+                                               return;
+                               }
+                       }
+               }
+       }
+};
+
+class TDMLayerCommitThread : public TDMLayerCommit
+{
+protected:
+       void SetEnv()
+       {
+               setenv("TDM_DEBUG_MODULE", "all", 1);
+               setenv("TDM_DEBUG", "1", 1);
+               setenv("TDM_THREAD", "1", 1);
+               setenv("TDM_COMMIT_PER_VBLANK", "1", 1);
+               setenv("TDM_DLOG", "1", 1);
+               setenv("XDG_RUNTIME_DIR", ".", 1);
+               setenv("TBM_DLOG", "1", 1);
+               setenv("TBM_DISPLAY_SERVER", "1", 1);
+       }
+};
+
+class TDMLayerCommitWithDisabledCommitPerVblank : public TDMLayerCommit
+{
+protected:
+       void SetEnv()
+       {
+               setenv("TDM_DEBUG_MODULE", "all", 1);
+               setenv("TDM_DEBUG", "1", 1);
+               setenv("TDM_THREAD", "0", 1);
+               setenv("TDM_COMMIT_PER_VBLANK", "0", 1);
+               setenv("TDM_DLOG", "1", 1);
+               setenv("XDG_RUNTIME_DIR", ".", 1);
+               setenv("TBM_DLOG", "1", 1);
+               setenv("TBM_DISPLAY_SERVER", "1", 1);
+       }
 };
 
+int TDMLayerCommit::utLayerCommitHandlerCounter = 0;
+
 TEST_F(TDMLayer, LayerGetCapabilitiesSuccessful)
 {
        SKIP_FLAG(has_layers);
@@ -178,3 +439,1435 @@ TEST_F(TDMLayer, OutputGetPrimaryIndexFailOnlyOutput)
                                }
                                exit(0);}, ::testing::ExitedWithCode(0), "");
 }
+
+/* tdm_layer_get_available_formats() */
+
+TEST_F(TDMLayer, LayerGetAvailableFormatsFailNullAll)
+{
+       SKIP_FLAG(has_layers);
+       ASSERT_EXIT({if (tdm_layer_get_available_formats(NULL, NULL, NULL) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerGetAvailableFormatsFailNullLayer)
+{
+       SKIP_FLAG(has_layers);
+       ASSERT_EXIT({const tbm_format *formats;
+                                int count;
+                                if (tdm_layer_get_available_formats(NULL, &formats, &count) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerGetAvailableFormatsFailNullFormats)
+{
+       SKIP_FLAG(has_layers);
+       ASSERT_EXIT({int count;
+                                for (int i = 0; i < layer_count; i++) {
+                                        if (tdm_layer_get_available_formats(tdm_layer_array[i], NULL, &count) == TDM_ERROR_NONE) exit(1);
+                               }
+                               exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerGetAvailableFormatsFailNullCount)
+{
+       SKIP_FLAG(has_layers);
+       ASSERT_EXIT({const tbm_format *formats;
+                                for (int i = 0; i < layer_count; i++) {
+                                        if (tdm_layer_get_available_formats(tdm_layer_array[i], &formats, NULL) == TDM_ERROR_NONE) exit(1);
+                               }
+                               exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerGetAvailableFormatsSuccess)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       const tbm_format *formats;
+       int count;
+
+       for (int i = 0; i < layer_count; ++i) {
+               error = tdm_layer_get_available_formats(tdm_layer_array[i], &formats, &count);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+               ASSERT_NE(NULL, formats);
+               ASSERT_NE(0, count);
+       }
+}
+
+/* tdm_layer_get_available_properties() */
+
+TEST_F(TDMLayer, LayerGetAvailablePropertiesFailNullAll)
+{
+       SKIP_FLAG(has_layers);
+       ASSERT_EXIT({if (tdm_layer_get_available_properties(NULL, NULL, NULL) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerGetAvailablePropertiesFailNullLayer)
+{
+       SKIP_FLAG(has_layers);
+       ASSERT_EXIT({const tdm_prop *props;
+                                int count;
+                                if (tdm_layer_get_available_properties(NULL, &props, &count) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerGetAvailablePropertiesFailNullFormats)
+{
+       SKIP_FLAG(has_layers);
+       ASSERT_EXIT({int count;
+                                for (int i = 0; i < layer_count; i++) {
+                                        if (tdm_layer_get_available_properties(tdm_layer_array[i], NULL, &count) == TDM_ERROR_NONE) exit(1);
+                               }
+                               exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerGetAvailablePropertiesFailNullCount)
+{
+       SKIP_FLAG(has_layers);
+       ASSERT_EXIT({const tdm_prop *props;
+                                for (int i = 0; i < layer_count; i++) {
+                                        if (tdm_layer_get_available_properties(tdm_layer_array[i], &props, NULL) == TDM_ERROR_NONE) exit(1);
+                               }
+                               exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerGetAvailablePropertiesSuccess)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       const tdm_prop *props;
+       int count;
+
+       for (int i = 0; i < layer_count; ++i) {
+               error = tdm_layer_get_available_properties(tdm_layer_array[i], &props, &count);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+       }
+}
+
+/* tdm_layer_get_zpos() */
+
+TEST_F(TDMLayer, LayerGetZposFailNullAll)
+{
+       SKIP_FLAG(has_layers);
+       ASSERT_EXIT({if (tdm_layer_get_zpos(NULL, NULL) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer,  LayerGetZposFailNullLayer)
+{
+       SKIP_FLAG(has_layers);
+       ASSERT_EXIT({const tdm_prop *props;
+                                int zpos;
+                                if (tdm_layer_get_zpos(NULL, &zpos) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerGetZposFailNullZpos)
+{
+       SKIP_FLAG(has_layers);
+       ASSERT_EXIT({int count;
+                                for (int i = 0; i < layer_count; i++) {
+                                        if (tdm_layer_get_zpos(tdm_layer_array[i], NULL) == TDM_ERROR_NONE) exit(1);
+                               }
+                               exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerGetZposSuccess)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+
+       for (int i = 0; i < layer_count; ++i) {
+               int zpos = INT_MIN;
+               error = tdm_layer_get_zpos(tdm_layer_array[i], &zpos);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+               ASSERT_NE(INT_MIN, zpos);
+       }
+}
+
+/* tdm_layer_set_property() */
+
+TEST_F(TDMLayer,  LayerSetPropertyFailNullLayer)
+{
+       SKIP_FLAG(has_layers);
+       ASSERT_EXIT({tdm_value value;
+                                int id = INT_MAX;
+                                if (tdm_layer_set_property(NULL, id, value) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer,  LayerSetPropertyFailWrongId)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       tdm_value value;
+       int id = INT_MAX;
+
+       for (int i = 0; i < layer_count; ++i) {
+               error = tdm_layer_set_property(tdm_layer_array[i], id, value);
+               ASSERT_NE(TDM_ERROR_NONE, error);
+       }
+}
+
+/* tdm_layer_get_property() */
+
+TEST_F(TDMLayer,  LayerGetPropertyFailNullLayer)
+{
+       SKIP_FLAG(has_layers);
+       ASSERT_EXIT({tdm_value value;
+                                int id = INT_MAX;
+                                if (tdm_layer_get_property(NULL, id, &value) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer,  LayerGetPropertyFailNullValue)
+{
+       SKIP_FLAG(has_layers);
+       ASSERT_EXIT({tdm_value value;
+                                int id = INT_MAX;
+                                for (int i = 0; i < layer_count; ++i) {
+                                       if (tdm_layer_get_property(tdm_layer_array[i], id, NULL) == TDM_ERROR_NONE) exit(1);
+                                }
+                               exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer,  LayerGetPropertyFailWrongId)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       tdm_value value;
+       int id = INT_MAX;
+
+       for (int i = 0; i < layer_count; ++i) {
+               error = tdm_layer_get_property(tdm_layer_array[i], id, &value);
+               ASSERT_NE(TDM_ERROR_NONE, error);
+       }
+}
+
+/* tdm_layer_set_info() */
+
+TEST_F(TDMLayer,  LayerSetInfoFailNullAll)
+{
+       SKIP_FLAG(has_layers);
+       ASSERT_EXIT({tdm_value value;
+                                int id = INT_MAX;
+                                if (tdm_layer_set_info(NULL, NULL) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer,  LayerSetInfoFailNullLayer)
+{
+       SKIP_FLAG(has_layers);
+
+       ASSERT_EXIT({tdm_info_layer info = {0};
+                                if (tdm_layer_set_info(NULL, &info) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer,  LayerSetInfoFailNullInfo)
+{
+       SKIP_FLAG(has_layers);
+
+       ASSERT_EXIT({tdm_info_layer info = {0};
+                                for (int i = 0; i < layer_count; ++i)
+                                       if (tdm_layer_set_info(tdm_layer_array[i], NULL) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+tdm_error
+_ut_tdm_layer_set_info(tdm_layer *layer, int w, int h)
+{
+       tdm_info_layer info = {0};
+
+       info.src_config.size.h = w;
+       info.src_config.size.v = h;
+       info.src_config.pos.x = 0;
+       info.src_config.pos.y = 0;
+       info.src_config.pos.w = w;
+       info.src_config.pos.h = h;
+       info.src_config.format = TBM_FORMAT_ARGB8888;
+       info.dst_pos.x = 0;
+       info.dst_pos.y = 0;
+       info.dst_pos.w = w;
+       info.dst_pos.h = h;
+       info.transform = TDM_TRANSFORM_NORMAL;
+
+       return tdm_layer_set_info(layer, &info);
+}
+
+TEST_F(TDMLayer,  LayerSetInfoSuccess)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+
+       for (int i = 0; i < layer_count; ++i) {
+               error = _ut_tdm_layer_set_info(tdm_layer_array[i], 128, 128);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+       }
+}
+
+/* tdm_layer_get_info() */
+
+TEST_F(TDMLayer,  LayerGetInfoFailNullAll)
+{
+       SKIP_FLAG(has_layers);
+       ASSERT_EXIT({tdm_value value;
+                                int id = INT_MAX;
+                                if (tdm_layer_get_info(NULL, NULL) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer,  LayerGetInfoFailNullLayer)
+{
+       SKIP_FLAG(has_layers);
+
+       ASSERT_EXIT({tdm_info_layer info = {0};
+                                if (tdm_layer_get_info(NULL, &info) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer,  LayerGetInfoFailNullInfo)
+{
+       SKIP_FLAG(has_layers);
+
+       ASSERT_EXIT({tdm_info_layer info = {0};
+                                for (int i = 0; i < layer_count; ++i)
+                                       if (tdm_layer_get_info(tdm_layer_array[i], NULL) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer,  LayerGetInfoSuccess)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       tdm_info_layer set_info = {0};
+       tdm_info_layer ret_info = {0};
+
+       set_info.src_config.size.h = 128;
+       set_info.src_config.size.v = 128;
+       set_info.src_config.pos.x = 0;
+       set_info.src_config.pos.y = 0;
+       set_info.src_config.pos.w = 128;
+       set_info.src_config.pos.h = 128;
+       set_info.src_config.format = TBM_FORMAT_ARGB8888;
+       set_info.dst_pos.x = 0;
+       set_info.dst_pos.y = 0;
+       set_info.dst_pos.w = 128;
+       set_info.dst_pos.h = 128;
+       set_info.transform = TDM_TRANSFORM_NORMAL;
+
+       for (int i = 0; i < layer_count; ++i) {
+               error = tdm_layer_get_info(tdm_layer_array[i], &set_info);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               error = tdm_layer_get_info(tdm_layer_array[i], &ret_info);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               ASSERT_TRUE(!memcmp(&ret_info, &set_info, sizeof(tdm_info_layer)));
+       }
+}
+
+/* tdm_layer_set_buffer() */
+
+TEST_F(TDMLayer, LayerSetBufferFailNullAll)
+{
+       SKIP_FLAG(has_layers);
+       ASSERT_EXIT({if (tdm_layer_set_buffer(NULL, NULL) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerSetBufferFailNullLayer)
+{
+       SKIP_FLAG(has_layers);
+
+       ASSERT_EXIT({tdm_error error;
+                                tbm_surface_h buffer = UtCreateBufferForLayer(0, 128, 128, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
+                                if (!buffer) exit(1);
+                                error = tdm_layer_set_buffer(NULL, buffer);
+                                if (error == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerSetBufferFailNullBuffer)
+{
+       SKIP_FLAG(has_layers);
+
+       ASSERT_EXIT({for (int i = 0; i < layer_count; ++i)
+                                       if (tdm_layer_set_buffer(tdm_layer_array[i], NULL) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerSetBufferSuccess)
+{
+       SKIP_FLAG(has_layers);
+       tbm_surface_h buffer;
+       tdm_error error;
+
+       for (int i = 0; i < layer_count; ++i) {
+               buffer = UtCreateBufferForLayer(i, 128, 128, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
+               ASSERT_NE(NULL, buffer);
+
+               error = tdm_layer_set_buffer(tdm_layer_array[i], buffer);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+       }
+}
+
+TEST_F(TDMLayer, LayerSetBufferSuccessTwice)
+{
+       SKIP_FLAG(has_layers);
+       tbm_surface_h buffer;
+       tdm_error error;
+
+       for (int i = 0; i < layer_count; ++i) {
+               buffer = UtCreateBufferForLayer(i, 128, 128, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
+               ASSERT_NE(NULL, buffer);
+
+               error = tdm_layer_set_buffer(tdm_layer_array[i], buffer);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               error = tdm_layer_set_buffer(tdm_layer_array[i], buffer);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+       }
+}
+
+/* tdm_layer_unset_buffer() */
+
+TEST_F(TDMLayer, LayerUnsetBufferFailNullLayer)
+{
+       SKIP_FLAG(has_layers);
+
+       ASSERT_EXIT({tdm_error error;
+                                error = tdm_layer_unset_buffer(NULL);
+                                if (error == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerUnsetBufferSuccess)
+{
+       SKIP_FLAG(has_layers);
+       tbm_surface_h buffer;
+       tdm_error error;
+
+       for (int i = 0; i < layer_count; ++i) {
+               buffer = UtCreateBufferForLayer(i, 128, 128, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
+               ASSERT_NE(NULL, buffer);
+
+               error = tdm_layer_set_buffer(tdm_layer_array[i], buffer);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               error = tdm_layer_unset_buffer(tdm_layer_array[i]);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+       }
+}
+
+/* tdm_layer_commit() */
+
+TEST_F(TDMLayer, LayerCommitFailNullAll)
+{
+       SKIP_FLAG(has_layers);
+
+       ASSERT_EXIT({tdm_error error;
+                                error = tdm_layer_commit(NULL, NULL, NULL);
+                                if (error == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerCommitFailDpmsOff)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+
+       for (int i = 0; i < layer_count; ++i) {
+               error = tdm_layer_commit(tdm_layer_array[i], NULL, NULL);
+               ASSERT_NE(TDM_ERROR_NONE, error);
+       }
+}
+
+TEST_F(TDMLayerCommit, LayerCommitSuccess)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       int data = 0;
+
+       for (int i = 0; i < layer_count; ++i) {
+               tbm_surface_h buffer = NULL;
+               tdm_layer_capability layer_capability;
+
+               int w = preferred_mode_array[tdm_layer_output_idx[i]]->hdisplay;
+               int h = preferred_mode_array[tdm_layer_output_idx[i]]->vdisplay;
+
+               error = tdm_layer_get_capabilities(tdm_layer_array[i], &layer_capability);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               if (!(layer_capability & TDM_LAYER_CAPABILITY_PRIMARY)) {
+                       w /= 2;
+                       h /= 2;
+               }
+
+               error = _ut_tdm_layer_set_info(tdm_layer_array[i], w, h);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               buffer = UtCreateBufferForLayer(i, w, h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
+               ASSERT_NE(NULL, buffer);
+
+               error = tdm_layer_set_buffer(tdm_layer_array[i], buffer);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               error = tdm_layer_commit(tdm_layer_array[i], UtLayerCommitHandler, &data);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+       }
+
+       UtHandleCommitEvent(layer_count);
+
+       ASSERT_EQ(layer_count, utLayerCommitHandlerCounter);
+       ASSERT_EQ(layer_count, data);
+}
+
+TEST_F(TDMLayerCommitThread, LayerCommitSuccess)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       int data = 0;
+
+       for (int i = 0; i < layer_count; ++i) {
+               tbm_surface_h buffer = NULL;
+               tdm_layer_capability layer_capability;
+
+               int w = preferred_mode_array[tdm_layer_output_idx[i]]->hdisplay;
+               int h = preferred_mode_array[tdm_layer_output_idx[i]]->vdisplay;
+
+               error = tdm_layer_get_capabilities(tdm_layer_array[i], &layer_capability);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               if (!(layer_capability & TDM_LAYER_CAPABILITY_PRIMARY)) {
+                       w /= 2;
+                       h /= 2;
+               }
+
+               error = _ut_tdm_layer_set_info(tdm_layer_array[i], w, h);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               buffer = UtCreateBufferForLayer(i, w, h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
+               ASSERT_NE(NULL, buffer);
+
+               error = tdm_layer_set_buffer(tdm_layer_array[i], buffer);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               error = tdm_layer_commit(tdm_layer_array[i], UtLayerCommitHandler, &data);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+       }
+
+       UtHandleCommitEvent(layer_count);
+
+       ASSERT_EQ(layer_count, utLayerCommitHandlerCounter);
+       ASSERT_EQ(layer_count, data);
+}
+
+TEST_F(TDMLayerCommit, LayerCommitSuccessOnlyPrimaryLayers)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       int data = 0;
+       int num_waiting_layers = 0;
+
+       for (int i = 0; i < layer_count; ++i) {
+               tbm_surface_h buffer = NULL;
+               tdm_layer_capability layer_capability;
+
+               int w = preferred_mode_array[tdm_layer_output_idx[i]]->hdisplay;
+               int h = preferred_mode_array[tdm_layer_output_idx[i]]->vdisplay;
+
+               error = tdm_layer_get_capabilities(tdm_layer_array[i], &layer_capability);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               if (!(layer_capability & TDM_LAYER_CAPABILITY_PRIMARY))
+                       continue;
+
+               num_waiting_layers++;
+
+               error = _ut_tdm_layer_set_info(tdm_layer_array[i], w, h);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               buffer = UtCreateBufferForLayer(i, w, h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
+               ASSERT_NE(NULL, buffer);
+
+               error = tdm_layer_set_buffer(tdm_layer_array[i], buffer);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               error = tdm_layer_commit(tdm_layer_array[i], UtLayerCommitHandler, &data);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+       }
+
+       UtHandleCommitEvent(num_waiting_layers);
+
+       ASSERT_EQ(num_waiting_layers, utLayerCommitHandlerCounter);
+       ASSERT_EQ(num_waiting_layers, data);
+}
+
+TEST_F(TDMLayerCommitThread, LayerCommitSuccessOnlyPrimaryLayers)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       int data = 0;
+       int num_waiting_layers = 0;
+
+       for (int i = 0; i < layer_count; ++i) {
+               tbm_surface_h buffer = NULL;
+               tdm_layer_capability layer_capability;
+
+               int w = preferred_mode_array[tdm_layer_output_idx[i]]->hdisplay;
+               int h = preferred_mode_array[tdm_layer_output_idx[i]]->vdisplay;
+
+               error = tdm_layer_get_capabilities(tdm_layer_array[i], &layer_capability);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               if (!(layer_capability & TDM_LAYER_CAPABILITY_PRIMARY))
+                       continue;
+
+               num_waiting_layers++;
+
+               error = _ut_tdm_layer_set_info(tdm_layer_array[i], w, h);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               buffer = UtCreateBufferForLayer(i, w, h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
+               ASSERT_NE(NULL, buffer);
+
+               error = tdm_layer_set_buffer(tdm_layer_array[i], buffer);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               error = tdm_layer_commit(tdm_layer_array[i], UtLayerCommitHandler, &data);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+       }
+
+       UtHandleCommitEvent(num_waiting_layers);
+
+       ASSERT_EQ(num_waiting_layers, utLayerCommitHandlerCounter);
+       ASSERT_EQ(num_waiting_layers, data);
+}
+
+TEST_F(TDMLayerCommitWithDisabledCommitPerVblank, LayerCommitSuccess)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       int data = 0;
+
+       for (int i = 0; i < layer_count; ++i) {
+               tbm_surface_h buffer = NULL;
+               tdm_layer_capability layer_capability;
+
+               int w = preferred_mode_array[tdm_layer_output_idx[i]]->hdisplay;
+               int h = preferred_mode_array[tdm_layer_output_idx[i]]->vdisplay;
+
+               error = tdm_layer_get_capabilities(tdm_layer_array[i], &layer_capability);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               if (!(layer_capability & TDM_LAYER_CAPABILITY_PRIMARY)) {
+                       w /= 2;
+                       h /= 2;
+               }
+
+               error = _ut_tdm_layer_set_info(tdm_layer_array[i], w, h);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               buffer = UtCreateBufferForLayer(i, w, h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
+               ASSERT_NE(NULL, buffer);
+
+               error = tdm_layer_set_buffer(tdm_layer_array[i], buffer);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               error = tdm_layer_commit(tdm_layer_array[i], UtLayerCommitHandler, &data);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+       }
+
+       UtHandleCommitEvent(layer_count);
+
+       ASSERT_EQ(layer_count, utLayerCommitHandlerCounter);
+       ASSERT_EQ(layer_count, data);
+}
+
+TEST_F(TDMLayerCommitWithDisabledCommitPerVblank, LayerCommitSuccessOnlyPrimaryLayers)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       int data = 0;
+       int num_waiting_layers = 0;
+
+       for (int i = 0; i < layer_count; ++i) {
+               tbm_surface_h buffer = NULL;
+               tdm_layer_capability layer_capability;
+
+               int w = preferred_mode_array[tdm_layer_output_idx[i]]->hdisplay;
+               int h = preferred_mode_array[tdm_layer_output_idx[i]]->vdisplay;
+
+               error = tdm_layer_get_capabilities(tdm_layer_array[i], &layer_capability);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               if (!(layer_capability & TDM_LAYER_CAPABILITY_PRIMARY))
+                       continue;
+
+               num_waiting_layers++;
+
+               error = _ut_tdm_layer_set_info(tdm_layer_array[i], w, h);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               buffer = UtCreateBufferForLayer(i, w, h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
+               ASSERT_NE(NULL, buffer);
+
+               error = tdm_layer_set_buffer(tdm_layer_array[i], buffer);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               error = tdm_layer_commit(tdm_layer_array[i], UtLayerCommitHandler, &data);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+       }
+
+       UtHandleCommitEvent(num_waiting_layers);
+
+       ASSERT_EQ(num_waiting_layers, utLayerCommitHandlerCounter);
+       ASSERT_EQ(num_waiting_layers, data);
+}
+
+TEST_F(TDMLayerCommit, LayerCommitSuccessUnsetAfterCommit)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       int data = 0;
+
+       for (int i = 0; i < layer_count; ++i) {
+               tbm_surface_h buffer = NULL;
+               tdm_layer_capability layer_capability;
+
+               int w = preferred_mode_array[tdm_layer_output_idx[i]]->hdisplay;
+               int h = preferred_mode_array[tdm_layer_output_idx[i]]->vdisplay;
+
+               error = tdm_layer_get_capabilities(tdm_layer_array[i], &layer_capability);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               if (!(layer_capability & TDM_LAYER_CAPABILITY_PRIMARY)) {
+                       w /= 2;
+                       h /= 2;
+               }
+
+               error = _ut_tdm_layer_set_info(tdm_layer_array[i], w, h);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               buffer = UtCreateBufferForLayer(i, w, h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
+               ASSERT_NE(NULL, buffer);
+
+               error = tdm_layer_set_buffer(tdm_layer_array[i], buffer);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               error = tdm_layer_commit(tdm_layer_array[i], UtLayerCommitHandler, &data);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+       }
+
+       for (int i = 0; i < layer_count; ++i) {
+               error = tdm_layer_unset_buffer(tdm_layer_array[i]);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+       }
+
+       UtHandleCommitEvent(layer_count);
+       ASSERT_EQ(0, utLayerCommitHandlerCounter);
+       ASSERT_EQ(0, data);
+}
+
+TEST_F(TDMLayerCommit, LayerCommitSuccessUnsetBeforeCommit_2)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       int data = 0;
+
+       for (int i = 0; i < layer_count; ++i) {
+               tbm_surface_h buffer = NULL;
+               tdm_layer_capability layer_capability;
+
+               int w = preferred_mode_array[tdm_layer_output_idx[i]]->hdisplay;
+               int h = preferred_mode_array[tdm_layer_output_idx[i]]->vdisplay;
+
+               error = tdm_layer_get_capabilities(tdm_layer_array[i], &layer_capability);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               if (!(layer_capability & TDM_LAYER_CAPABILITY_PRIMARY)) {
+                       w /= 2;
+                       h /= 2;
+               }
+
+               error = _ut_tdm_layer_set_info(tdm_layer_array[i], w, h);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               buffer = UtCreateBufferForLayer(i, w, h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
+               ASSERT_NE(NULL, buffer);
+
+               error = tdm_layer_set_buffer(tdm_layer_array[i], buffer);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               error = tdm_layer_commit(tdm_layer_array[i], UtLayerCommitHandler, &data);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+       }
+
+       UtHandleCommitEvent(layer_count);
+       ASSERT_EQ(layer_count, utLayerCommitHandlerCounter);
+       ASSERT_EQ(layer_count, data);
+
+       for (int i = 0; i < layer_count; ++i) {
+               error = tdm_layer_unset_buffer(tdm_layer_array[i]);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+       }
+}
+
+/* tdm_layer_is_committing() */
+
+TEST_F(TDMLayer, LayerIsCommittingFailNullAll)
+{
+       SKIP_FLAG(has_layers);
+
+       ASSERT_EXIT({tdm_error error;
+                                error = tdm_layer_is_committing(NULL, NULL);
+                                if (error == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerIsCommittingFailNullLayer)
+{
+       SKIP_FLAG(has_layers);
+       unsigned int committing;
+
+       ASSERT_EXIT({tdm_error error;
+                                error = tdm_layer_is_committing(NULL, &committing);
+                                if (error == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerIsCommittingFailNullCommitting)
+{
+       SKIP_FLAG(has_layers);
+
+       ASSERT_EXIT({tdm_error error;
+                                error = tdm_layer_is_committing(tdm_layer_array[0], NULL);
+                                if (error == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerIsCommittingSuccessWithoutCommit)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       unsigned int committing;
+
+       for (int i = 0; i < layer_count; ++i) {
+               error = tdm_layer_is_committing(tdm_layer_array[0], &committing);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               ASSERT_EQ(0, committing);
+       }
+}
+
+TEST_F(TDMLayerCommit, LayerIsCommittingSuccess)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       unsigned int committing;
+
+       for (int i = 0; i < layer_count; ++i) {
+               tbm_surface_h buffer = NULL;
+               tdm_layer_capability layer_capability;
+
+               int w = preferred_mode_array[tdm_layer_output_idx[i]]->hdisplay;
+               int h = preferred_mode_array[tdm_layer_output_idx[i]]->vdisplay;
+
+               error = tdm_layer_get_capabilities(tdm_layer_array[i], &layer_capability);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               if (!(layer_capability & TDM_LAYER_CAPABILITY_PRIMARY)) {
+                       w /= 2;
+                       h /= 2;
+               }
+
+               error = _ut_tdm_layer_set_info(tdm_layer_array[i], w, h);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               buffer = UtCreateBufferForLayer(i, w, h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
+               ASSERT_NE(NULL, buffer);
+
+               error = tdm_layer_set_buffer(tdm_layer_array[i], buffer);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               error = tdm_layer_commit(tdm_layer_array[i], NULL, NULL);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               error = tdm_layer_is_committing(tdm_layer_array[0], &committing);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               ASSERT_EQ(1, committing);
+       }
+}
+
+/* tdm_layer_remove_commit_handler() */
+
+TEST_F(TDMLayer, LayerRemoveCommitHandlerFailNullAll)
+{
+       SKIP_FLAG(has_layers);
+
+       ASSERT_EXIT({tdm_error error;
+                                error = tdm_layer_remove_commit_handler(NULL, NULL, NULL);
+                                if (error == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayerCommit, LayerRemoveCommitHandlerSuccess)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       int data = 0;
+
+       for (int i = 0; i < layer_count; ++i) {
+               tbm_surface_h buffer = NULL;
+               tdm_layer_capability layer_capability;
+
+               int w = preferred_mode_array[tdm_layer_output_idx[i]]->hdisplay;
+               int h = preferred_mode_array[tdm_layer_output_idx[i]]->vdisplay;
+
+               error = tdm_layer_get_capabilities(tdm_layer_array[i], &layer_capability);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               if (!(layer_capability & TDM_LAYER_CAPABILITY_PRIMARY)) {
+                       w /= 2;
+                       h /= 2;
+               }
+
+               error = _ut_tdm_layer_set_info(tdm_layer_array[i], w, h);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               buffer = UtCreateBufferForLayer(i, w, h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
+               ASSERT_NE(NULL, buffer);
+
+               error = tdm_layer_set_buffer(tdm_layer_array[i], buffer);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               error = tdm_layer_commit(tdm_layer_array[i], UtLayerCommitHandler, &data);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               error = tdm_layer_remove_commit_handler(tdm_layer_array[i], UtLayerCommitHandler, &data);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+       }
+
+       UtHandleCommitEvent(layer_count);
+       ASSERT_EQ(0, utLayerCommitHandlerCounter);
+       ASSERT_EQ(0, data);
+}
+
+/* tdm_layer_get_displaying_buffer() */
+
+TEST_F(TDMLayerCommit, LayerGetDisplayingBufferFailNullAll)
+{
+       SKIP_FLAG(has_layers);
+
+       ASSERT_EXIT({if (tdm_layer_get_displaying_buffer(NULL, NULL) != NULL) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayerCommit, LayerGetDisplayingBufferFailWithoutCommit)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+
+       for (int i = 0; i < layer_count; ++i) {
+               ASSERT_EQ(NULL, tdm_layer_get_displaying_buffer(tdm_layer_array[i], &error));
+               ASSERT_NE(TDM_ERROR_NONE, error);
+       }
+}
+
+TEST_F(TDMLayerCommit, LayerGetDisplayingBufferSuccess)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       int data = 0;
+
+       for (int i = 0; i < layer_count; ++i) {
+               tbm_surface_h buffer = NULL;
+               tdm_layer_capability layer_capability;
+
+               int w = preferred_mode_array[tdm_layer_output_idx[i]]->hdisplay;
+               int h = preferred_mode_array[tdm_layer_output_idx[i]]->vdisplay;
+
+               error = tdm_layer_get_capabilities(tdm_layer_array[i], &layer_capability);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               if (!(layer_capability & TDM_LAYER_CAPABILITY_PRIMARY)) {
+                       w /= 2;
+                       h /= 2;
+               }
+
+               error = _ut_tdm_layer_set_info(tdm_layer_array[i], w, h);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               buffer = UtCreateBufferForLayer(i, w, h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
+               ASSERT_NE(NULL, buffer);
+
+               error = tdm_layer_set_buffer(tdm_layer_array[i], buffer);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               error = tdm_layer_commit(tdm_layer_array[i], UtLayerCommitHandler, &data);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+       }
+
+       UtHandleCommitEvent(layer_count);
+       ASSERT_EQ(layer_count, utLayerCommitHandlerCounter);
+       ASSERT_EQ(layer_count, data);
+
+       for (int i = 0; i < layer_count; ++i) {
+               ASSERT_EQ(tdm_layers_buffer_array[i], tdm_layer_get_displaying_buffer(tdm_layer_array[i], &error));
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+       }
+}
+
+/* tdm_layer_is_usable() */
+
+TEST_F(TDMLayer, LayerIsUsableFailNullAll)
+{
+       SKIP_FLAG(has_layers);
+
+       ASSERT_EXIT({if (tdm_layer_is_usable(NULL, NULL) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerIsUsableFailNullLayer)
+{
+       SKIP_FLAG(has_layers);
+       unsigned int usable;
+
+       ASSERT_EXIT({if (tdm_layer_is_usable(NULL, &usable) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerIsUsableFailNullUsable)
+{
+       SKIP_FLAG(has_layers);
+
+       ASSERT_EXIT({if (tdm_layer_is_usable(tdm_layer_array[0], NULL) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerIsUsableSuccessAllUsable)
+{
+       SKIP_FLAG(has_layers);
+       unsigned int usable;
+       tdm_error error;
+
+       for (int i = 0; i < layer_count; ++i) {
+               error = tdm_layer_is_usable(tdm_layer_array[i], &usable);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+               ASSERT_NE(0, usable);
+       }
+}
+
+TEST_F(TDMLayer, LayerIsUsableSuccessAllUsable_2)
+{
+       SKIP_FLAG(has_layers);
+       unsigned int usable;
+       tdm_error error;
+
+       for (int i = 0; i < layer_count; ++i) {
+               tbm_surface_h buffer;
+
+               int w = preferred_mode_array[tdm_layer_output_idx[i]]->hdisplay;
+               int h = preferred_mode_array[tdm_layer_output_idx[i]]->vdisplay;
+
+               buffer = UtCreateBufferForLayer(i, w, h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
+               ASSERT_NE(NULL, buffer);
+
+               error = tdm_layer_set_buffer(tdm_layer_array[i], buffer);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               error = tdm_layer_unset_buffer(tdm_layer_array[i]);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               error = tdm_layer_is_usable(tdm_layer_array[i], &usable);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+               ASSERT_NE(0, usable);
+       }
+}
+
+TEST_F(TDMLayer, LayerIsUsableSuccessAllNoUsable)
+{
+       SKIP_FLAG(has_layers);
+       unsigned int usable;
+       tdm_error error;
+
+       for (int i = 0; i < layer_count; ++i) {
+               tbm_surface_h buffer;
+
+               int w = preferred_mode_array[tdm_layer_output_idx[i]]->hdisplay;
+               int h = preferred_mode_array[tdm_layer_output_idx[i]]->vdisplay;
+
+               buffer = UtCreateBufferForLayer(i, w, h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
+               ASSERT_NE(NULL, buffer);
+
+               error = tdm_layer_set_buffer(tdm_layer_array[i], buffer);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               error = tdm_layer_is_usable(tdm_layer_array[i], &usable);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+               ASSERT_EQ(0, usable);
+       }
+}
+
+/* tdm_layer_set_video_pos() */
+
+TEST_F(TDMLayer, LayerSetVideoPosFailNullAll)
+{
+       SKIP_FLAG(has_layers);
+
+       ASSERT_EXIT({if (tdm_layer_set_video_pos(NULL, -1) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerSetVideoPosFailNoVideoLayers)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       tdm_layer_capability layer_capability;
+
+       for (int i = 0; i < layer_count; ++i) {
+               error = tdm_layer_get_capabilities(tdm_layer_array[i], &layer_capability);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               if (layer_capability & TDM_LAYER_CAPABILITY_VIDEO)
+                       continue;
+
+               error = tdm_layer_set_video_pos(tdm_layer_array[i], -1);
+               ASSERT_NE(TDM_ERROR_NONE, error);
+       }
+}
+
+TEST_F(TDMLayer, LayerSetVideoPosSuccess)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       tdm_layer_capability layer_capability;
+
+       for (int i = 0; i < layer_count; ++i) {
+               error = tdm_layer_get_capabilities(tdm_layer_array[i], &layer_capability);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               if (!(layer_capability & TDM_LAYER_CAPABILITY_VIDEO))
+                       continue;
+
+               error = tdm_layer_set_video_pos(tdm_layer_array[i], -1);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+       }
+}
+
+/* tdm_layer_create_capture() */
+
+TEST_F(TDMLayer, LayerCreateCaptureNullAll)
+{
+       SKIP_FLAG(has_layers);
+
+       ASSERT_EXIT({if (tdm_layer_create_capture(NULL, NULL) != NULL) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerCreateCaptureSuccess)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       tdm_capture *capture;
+
+       for (int i = 0; i < layer_count; ++i) {
+               capture = tdm_layer_create_capture(tdm_layer_array[i], &error);
+               if (error == TDM_ERROR_NO_CAPABILITY)
+                       return;
+
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+               ASSERT_NE(NULL, capture);
+       }
+}
+
+/* tdm_layer_get_buffer_flags() */
+
+TEST_F(TDMLayer, LayerGetBufferFlagsNullAll)
+{
+       SKIP_FLAG(has_layers);
+
+       ASSERT_EXIT({if (tdm_layer_get_buffer_flags(NULL, NULL) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerGetBufferFlagsNullLayer)
+{
+       SKIP_FLAG(has_layers);
+       unsigned int flags;
+
+       ASSERT_EXIT({if (tdm_layer_get_buffer_flags(NULL, &flags) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerGetBufferFlagsNullFlags)
+{
+       SKIP_FLAG(has_layers);
+
+       ASSERT_EXIT({if (tdm_layer_get_buffer_flags(tdm_layer_array[0], NULL) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerGetBufferFlagsSuccess)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       unsigned int flags;
+
+       for (int i = 0; i < layer_count; ++i) {
+               error = tdm_layer_get_buffer_flags(tdm_layer_array[i], &flags);
+               if (error == TDM_ERROR_NOT_IMPLEMENTED)
+                       return;
+
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+       }
+}
+
+/* tdm_layer_set_buffer_queue() */
+
+TEST_F(TDMLayer, LayerSetBufferQueueFailNullAll)
+{
+       SKIP_FLAG(has_layers);
+
+       ASSERT_EXIT({if (tdm_layer_set_buffer_queue(NULL, NULL) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerSetBufferQueueFailNullLayer)
+{
+       SKIP_FLAG(has_layers);
+       tbm_surface_queue_h bufer_queue;
+
+       bufer_queue = UtCreateBufferQueueForLayer(0, 128, 128, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
+       ASSERT_NE(NULL, bufer_queue);
+
+       ASSERT_EXIT({if (tdm_layer_set_buffer_queue(NULL, bufer_queue) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerSetBufferQueueFailNullBufferQueue)
+{
+       SKIP_FLAG(has_layers);
+
+       ASSERT_EXIT({if (tdm_layer_set_buffer_queue(tdm_layer_array[0], NULL) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerSetBufferQueueSuccess)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       tbm_surface_queue_h buffer_queue;
+       tdm_layer_capability layer_capability;
+
+       for (int i = 0; i < layer_count; ++i) {
+               int w = preferred_mode_array[tdm_layer_output_idx[i]]->hdisplay;
+               int h = preferred_mode_array[tdm_layer_output_idx[i]]->vdisplay;
+
+               error = tdm_layer_get_capabilities(tdm_layer_array[i], &layer_capability);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               if (!(layer_capability & TDM_LAYER_CAPABILITY_PRIMARY)) {
+                       w /= 2;
+                       h /= 2;
+               }
+
+               buffer_queue = UtCreateBufferQueueForLayer(i, w, h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
+               ASSERT_NE(NULL, buffer_queue);
+
+               error = tdm_layer_set_buffer_queue(tdm_layer_array[i], buffer_queue);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+       }
+}
+
+TEST_F(TDMLayer, LayerSetBufferQueueSuccessTwice)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       tbm_surface_queue_h buffer_queue;
+       tdm_layer_capability layer_capability;
+
+       for (int i = 0; i < layer_count; ++i) {
+               int w = preferred_mode_array[tdm_layer_output_idx[i]]->hdisplay;
+               int h = preferred_mode_array[tdm_layer_output_idx[i]]->vdisplay;
+
+               error = tdm_layer_get_capabilities(tdm_layer_array[i], &layer_capability);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               if (!(layer_capability & TDM_LAYER_CAPABILITY_PRIMARY)) {
+                       w /= 2;
+                       h /= 2;
+               }
+
+               buffer_queue = UtCreateBufferQueueForLayer(i, w, h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
+               ASSERT_NE(NULL, buffer_queue);
+
+               error = tdm_layer_set_buffer_queue(tdm_layer_array[i], buffer_queue);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               error = tdm_layer_set_buffer_queue(tdm_layer_array[i], buffer_queue);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+       }
+}
+
+TEST_F(TDMLayerCommitThread, LayerSetBufferQueueSuccessRemoveBufferQueue)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       tbm_surface_queue_error_e tbm_err;
+       tbm_surface_queue_h buffer_queue;
+       tdm_layer_capability layer_capability;
+
+       for (int i = 0; i < layer_count; ++i) {
+               tbm_surface_h surface;
+
+               int w = preferred_mode_array[tdm_layer_output_idx[i]]->hdisplay;
+               int h = preferred_mode_array[tdm_layer_output_idx[i]]->vdisplay;
+
+               error = tdm_layer_get_capabilities(tdm_layer_array[i], &layer_capability);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               if (!(layer_capability & TDM_LAYER_CAPABILITY_PRIMARY)) {
+                       w /= 2;
+                       h /= 2;
+               }
+
+               error = _ut_tdm_layer_set_info(tdm_layer_array[i], w, h);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               buffer_queue = UtCreateBufferQueueForLayer(i, w, h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
+               ASSERT_NE(NULL, buffer_queue);
+
+               error = tdm_layer_set_buffer_queue(tdm_layer_array[i], buffer_queue);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               tbm_err = tbm_surface_queue_dequeue(buffer_queue, &surface);
+               ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, error);
+
+               tdm_layer_commit(tdm_layer_array[i], NULL, NULL);
+
+               tbm_err = tbm_surface_queue_enqueue(buffer_queue, surface);
+               ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, error);
+       }
+
+       /* FIXME: use another func. */
+       UtHandleCommitEvent(1);
+
+       for (int i = 0; i < layer_count; ++i) {
+               ASSERT_NE(NULL, tdm_layer_get_displaying_buffer(tdm_layer_array[i], &error));
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               tbm_surface_queue_destroy(tdm_layers_buffer_queue_array[i]);
+               tdm_layers_buffer_queue_array[i] = NULL;
+
+               ASSERT_EQ(NULL, tdm_layer_get_displaying_buffer(tdm_layer_array[i], &error));
+               ASSERT_NE(TDM_ERROR_NONE, error);
+       }
+}
+
+TEST_F(TDMLayerCommitWithDisabledCommitPerVblank, LayerSetBufferQueueSuccessRemoveBufferQueue)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       tbm_surface_queue_error_e tbm_err;
+       tbm_surface_queue_h buffer_queue;
+       tdm_layer_capability layer_capability;
+
+       for (int i = 0; i < layer_count; ++i) {
+               tbm_surface_h surface;
+
+               int w = preferred_mode_array[tdm_layer_output_idx[i]]->hdisplay;
+               int h = preferred_mode_array[tdm_layer_output_idx[i]]->vdisplay;
+
+               error = tdm_layer_get_capabilities(tdm_layer_array[i], &layer_capability);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               if (!(layer_capability & TDM_LAYER_CAPABILITY_PRIMARY)) {
+                       w /= 2;
+                       h /= 2;
+               }
+
+               error = _ut_tdm_layer_set_info(tdm_layer_array[i], w, h);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               buffer_queue = UtCreateBufferQueueForLayer(i, w, h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
+               ASSERT_NE(NULL, buffer_queue);
+
+               error = tdm_layer_set_buffer_queue(tdm_layer_array[i], buffer_queue);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               tbm_err = tbm_surface_queue_dequeue(buffer_queue, &surface);
+               ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, error);
+
+               tdm_layer_commit(tdm_layer_array[i], NULL, NULL);
+
+               tbm_err = tbm_surface_queue_enqueue(buffer_queue, surface);
+               ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, error);
+       }
+
+       /* FIXME: use another func. */
+       UtHandleCommitEvent(1);
+
+       for (int i = 0; i < layer_count; ++i) {
+               tbm_surface_h surface;
+
+               tbm_err = tbm_surface_queue_dequeue(buffer_queue, &surface);
+               ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, error);
+
+               tbm_err = tbm_surface_queue_enqueue(buffer_queue, surface);
+               ASSERT_EQ(TBM_SURFACE_QUEUE_ERROR_NONE, error);
+
+               error = tdm_layer_unset_buffer_queue(tdm_layer_array[i]);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+       }
+
+       /* FIXME: use another func. */
+       UtHandleCommitEvent(1);
+
+       for (int i = 0; i < layer_count; ++i) {
+               ASSERT_EQ(NULL, tdm_layer_get_displaying_buffer(tdm_layer_array[i], &error));
+               ASSERT_NE(TDM_ERROR_NONE, error);
+       }
+}
+
+/* tdm_layer_unset_buffer_queue() */
+
+TEST_F(TDMLayer, LayerUnsetBufferQueueFailNullAll)
+{
+       SKIP_FLAG(has_layers);
+
+       ASSERT_EXIT({if (tdm_layer_unset_buffer_queue(NULL) == TDM_ERROR_NONE) exit(1);
+                                exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMLayer, LayerUnsetBufferQueueSuccess)
+{
+       SKIP_FLAG(has_layers);
+       tdm_error error;
+       tbm_surface_queue_h buffer_queue;
+       tdm_layer_capability layer_capability;
+
+       for (int i = 0; i < layer_count; ++i) {
+               int w = preferred_mode_array[tdm_layer_output_idx[i]]->hdisplay;
+               int h = preferred_mode_array[tdm_layer_output_idx[i]]->vdisplay;
+
+               error = tdm_layer_get_capabilities(tdm_layer_array[i], &layer_capability);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               if (!(layer_capability & TDM_LAYER_CAPABILITY_PRIMARY)) {
+                       w /= 2;
+                       h /= 2;
+               }
+
+               buffer_queue = UtCreateBufferQueueForLayer(i, w, h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
+               ASSERT_NE(NULL, buffer_queue);
+
+               error = tdm_layer_set_buffer_queue(tdm_layer_array[i], buffer_queue);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+
+               error = tdm_layer_unset_buffer_queue(tdm_layer_array[i]);
+               ASSERT_EQ(TDM_ERROR_NONE, error);
+       }
+}