Add libtpl-egl test case version 2
authorxuelian.bai <xuelian.bai@samsung.com>
Wed, 12 Aug 2015 07:06:37 +0000 (15:06 +0800)
committerSangwon Ha <sw815.ha@samsung.com>
Tue, 18 Aug 2015 01:36:46 +0000 (10:36 +0900)
1. Add env TPL_TEST_LOG_LEVEL to control test log level
2. Add tpl buffer and surface stress test
3. Support -t to chose a single test case
4. Add resourse free procedure
5. Fix tab error and file format.

Change-Id: I090e2bbdf2b82f95d5e994bdc33e47d10dc20512

tc/src/main.c
tc/src/tpl_test_buffer.c
tc/src/tpl_test_display.c
tc/src/tpl_test_object.c
tc/src/tpl_test_surface.c
tc/src/tpl_test_util.h

index 177f93e..7304391 100644 (file)
@@ -4,7 +4,6 @@
 #include <math.h>
 #include <unistd.h>
 
-
 #include "tpl_test_util.h"
 
 #include <wayland-client.h>
@@ -12,7 +11,6 @@
 #include <tbm_surface.h>
 
 
-
 typedef struct _ProgOption ProgOption;
 
 typedef struct _ProgOption
@@ -51,7 +49,8 @@ ProgOption g_option =
        false,
        false
 };
-/////log related ////
+
+/* log related */
 #ifdef TPL_ENABLE_LOG
 bool
 __LOG( const char* func, int line, const char* fmt, ... )
@@ -65,7 +64,7 @@ __LOG( const char* func, int line, const char* fmt, ... )
        va_end( args );
 
        sprintf( str, "[tpl_test] %s[%d] %s", func, line, buff );
-    printf( "ddk:[tpl_test] %s[%d] %s\n", func, line, buff );
+       printf( "ddk:[tpl_test] %s[%d] %s\n", func, line, buff );
        __tpl_test_log_display_msg( str );
 
        return true;
@@ -76,7 +75,7 @@ __LOG_BEGIN( const char* func )
 {
        char str[NUM_ERR_STR] = { (char)0, };
        sprintf( str, "[tpl_test][B] %s", func );
-    printf( "ddk:[tpl_test][B] %s\n", func );
+       printf( "ddk:[tpl_test][B] %s\n", func );
        __tpl_test_log_display_msg( str );
 }
 
@@ -85,7 +84,7 @@ __LOG_END( const char* func )
 {
        char str[NUM_ERR_STR] = { (char)0, };
        sprintf( str, "[tpl_test][E] %s", func );
-    printf( "ddk:[tpl_test][E] %s\n", func );
+       printf( "ddk:[tpl_test][E] %s\n", func );
        __tpl_test_log_display_msg( str );
 }
 
@@ -117,29 +116,25 @@ __LOG_ERR( const char* func, int line, const char* fmt, ... )
 
 #endif /* TPL_ENABLE_LOG */
 
-
-////////wayland native related////////////////
-registry_handle_global(void *data, struct wl_registry *registry,
-                                           uint32_t id, const char *interface,
-                                           uint32_t version)
+/* wayland native related */
+registry_handle_global(void *data, struct wl_registry *registry,uint32_t id, const char *interface,uint32_t version)
 {
-    TPLNativeWnd* that = (TPLNativeWnd *)(data);
-    if (strcmp(interface, "wl_compositor") == 0) {
-        that->compositor =
-                   wl_registry_bind(registry,
-                                     id, &wl_compositor_interface, 1);
-    } else if (strcmp(interface, "wl_shell") == 0) {
-        that->shell =
-                wl_registry_bind(registry,
-                                     id, &wl_shell_interface, 1);
-    } else if (strcmp(interface, "wl_output") == 0) {
-        /*struct my_output *my_output = new struct my_output;
-        memset(my_output, 0, sizeof(*my_output));
-        my_output->output =
-                wl_registry_bind(registry,
-                                     id, &wl_output_interface, 2);*/
-
-    }
+       TPLNativeWnd* that = (TPLNativeWnd *)(data);
+
+       if (strcmp(interface, "wl_compositor") == 0)
+       {
+               that->compositor = wl_registry_bind(registry,id, &wl_compositor_interface, 1);
+       }
+       else if (strcmp(interface, "wl_shell") == 0)
+       {
+               that->shell = wl_registry_bind(registry,id, &wl_shell_interface, 1);
+       }
+       else if (strcmp(interface, "wl_output") == 0)
+       {
+               /*struct my_output *my_output = new struct my_output;
+               memset(my_output, 0, sizeof(*my_output));
+               my_output->output = wl_registry_bind(registry,id, &wl_output_interface, 2);*/
+       }
 }
 
 void
@@ -149,14 +144,13 @@ registry_handle_global_remove(void * data,struct wl_registry * registry,uint32_t
 
 const struct wl_registry_listener registry_listener_ =
 {
-    registry_handle_global,
-    registry_handle_global_remove
+       registry_handle_global,
+       registry_handle_global_remove
 };
 
-shell_surface_handle_ping(void * data, struct wl_shell_surface *shell_surface,
-                                              uint32_t serial)
+shell_surface_handle_ping(void * data, struct wl_shell_surface *shell_surface,uint32_t serial)
 {
-    wl_shell_surface_pong(shell_surface, serial);
+       wl_shell_surface_pong(shell_surface, serial);
 }
 
 void
@@ -165,30 +159,24 @@ shell_surface_handle_popup_done(void * data,struct wl_shell_surface * shell_surf
 }
 
 void
-shell_surface_handle_configure(void *data, struct wl_shell_surface * shell_surface,
-                                                   uint32_t edges, int32_t width, int32_t height)
+shell_surface_handle_configure(void *data, struct wl_shell_surface * shell_surface,uint32_t edges, int32_t width, int32_t height)
 {
-    TPLNativeWnd *that = (TPLNativeWnd *)(data);
-    that->width = width;
-    that->height = height;
-    wl_egl_window_resize(that->wnd, width, height, 0, 0);
+       TPLNativeWnd *that = (TPLNativeWnd *)(data);
+       that->width = width;
+       that->height = height;
+       wl_egl_window_resize(that->wnd, width, height, 0, 0);
 }
 
 
 const struct wl_shell_surface_listener shell_surface_listener_ =
 {
-    shell_surface_handle_ping,
-    shell_surface_handle_configure,
-    shell_surface_handle_popup_done
+       shell_surface_handle_ping,
+       shell_surface_handle_configure,
+       shell_surface_handle_popup_done
 };
+/* wayland native end */
 
-
-////////////////////wayland native end ///////////////////////
-
-
-
-////////////////////tpl_test related ///////////////////////
-
+/* tpl_test related */
 TPLNativeWnd*
 tpl_test_native_wnd_create( void )
 {
@@ -208,6 +196,9 @@ tpl_test_native_wnd_create( void )
        wnd->width = 0;
        wnd->height = 0;
        wnd->depth = 0;
+       tpl_display_t * tpl_display = NULL;
+       tpl_surface_t * tpl_surf = NULL;
+       tpl_buffer_t * tpl_buf = NULL;
 finish:
        return wnd;
 }
@@ -217,7 +208,6 @@ tpl_test_native_wnd_initialize( TPLNativeWnd* wnd, int x, int y, int width, int
 {
        bool res = false;
 
-
        TPL_CHK_PARAM( !wnd );
        TPL_CHK_PARAM( x < 0 );
        TPL_CHK_PARAM( y < 0 );
@@ -244,7 +234,6 @@ tpl_test_native_wnd_initialize( TPLNativeWnd* wnd, int x, int y, int width, int
        wnd->height = height;
        wnd->depth = 32;
 
-
        wnd->surface= wl_compositor_create_surface(wnd->compositor);
        wnd->wnd = wl_egl_window_create(wnd->surface,wnd->width, wnd->height);
 
@@ -252,9 +241,8 @@ tpl_test_native_wnd_initialize( TPLNativeWnd* wnd, int x, int y, int width, int
 
        wl_shell_surface_set_toplevel(wnd->shell_surface);
        if (wnd->shell_surface)
-    {
-            wl_shell_surface_add_listener(wnd->shell_surface,
-                                             &shell_surface_listener_, wnd);
+       {
+               wl_shell_surface_add_listener(wnd->shell_surface,&shell_surface_listener_, wnd);
        }
 
        wl_shell_surface_set_title(wnd->shell_surface, "tpl_testtest");
@@ -269,16 +257,14 @@ tpl_test_native_wnd_finalize( TPLNativeWnd* wnd )
 {
        bool res = false;
 
-    __log_begin();
-
        TPL_CHK_PARAM( !wnd );
        TPL_CHK_PARAM( !wnd->dpy );
 
        wl_egl_window_destroy(wnd->wnd);
        if (wnd->shell_surface)
-            wl_shell_surface_destroy(wnd->shell_surface);
-        if (wnd->surface)
-            wl_surface_destroy(wnd->surface);
+               wl_shell_surface_destroy(wnd->shell_surface);
+       if (wnd->surface)
+               wl_surface_destroy(wnd->surface);
        if (wnd->shell)
                wl_shell_destroy(wnd->shell);
 
@@ -292,76 +278,79 @@ tpl_test_native_wnd_finalize( TPLNativeWnd* wnd )
 
        res = true;
 finish:
-    __log_end();
        return res;
 }
 
+bool
+tpl_test_finalize( TPLNativeWnd* wnd )
+{
+       bool res = true;
+
+       TPL_CHK_PARAM( !wnd );
+
+       if(NULL != wnd->tpl_display)
+       {
+                tpl_object_unreference((tpl_object_t*)wnd->tpl_display);
+       }
+       if(NULL != wnd->tpl_surf)
+       {
+               tpl_object_unreference((tpl_object_t*)wnd->tpl_surf);
+       }
+
+       res = true;
+finish:
+       return res;
+}
+
+
 void
 tpl_test_native_wnd_release( TPLNativeWnd* wnd )
 {
-    __log_begin();
        TPL_CHK_PARAM( !wnd );
 
        TPL_RSM_FREE( wnd );
 finish:
-    __log_end();
        return;
 }
 
 void init_option()
 {
-    g_option.egl_r = 8;
-    g_option.egl_r = 8;
-    g_option.egl_g = 8;
-    g_option.egl_b = 8;
-    g_option.egl_a = 8;
-    g_option.egl_d = 24;
-    g_option.egl_s = 0;
-    g_option.egl_preserved = 0;
-    g_option.egl_swap_interval = 1;
-    g_option.wnd_x = 0;
-    g_option.wnd_y = 0;
-    g_option.wnd_w = 1920;
-    g_option.wnd_h = 1080;
-    g_option.frames = 10000;
-    g_option.tc_num = 0;
-    g_option.fps = 300;
-    g_option.all = true;
-    g_option.show_names = false;
+       g_option.egl_r = 8;
+       g_option.egl_r = 8;
+       g_option.egl_g = 8;
+       g_option.egl_b = 8;
+       g_option.egl_a = 8;
+       g_option.egl_d = 24;
+       g_option.egl_s = 0;
+       g_option.egl_preserved = 0;
+       g_option.egl_swap_interval = 1;
+       g_option.wnd_x = 0;
+       g_option.wnd_y = 0;
+       g_option.wnd_w = 1920;
+       g_option.wnd_h = 1080;
+       g_option.frames = 10000;
+       g_option.tc_num = 0;
+       g_option.fps = 300;
+       g_option.all = true;
+       g_option.show_names = false;
 }
 static void
 print_usage( char *name )
 {
-       const char* native_wnd_system_str =
-#if defined(WS_NULL)
-               "null";
-#elif defined(WS_X11)
-               "x11";
-#endif /* end of WS_NULL */
-
        fprintf( stderr, "\n" );
        fprintf( stderr, "Usage: %s [OPTION]...\n", name );
        fprintf( stderr, "\n" );
-       fprintf( stderr, "OpenGL ES 2.0 test program for the %s window system\n", native_wnd_system_str );
+       fprintf( stderr, "TPL test program for the libtpl-egl\n");
        fprintf( stderr, "  Build: " BLD_HOST_NAME " %s %s\n", __DATE__, __TIME__ );
        fprintf( stderr, "\n" );
        fprintf( stderr, "Options:\n" );
-       fprintf( stderr, "  -c  Specify the EGL RGBA size: 888,8888,565  default: %d%d%d%d\n", g_option.egl_r, g_option.egl_g, g_option.egl_b, g_option.egl_a );
-       fprintf( stderr, "  -d  Specify the EGL depth size               default: %d\n", g_option.egl_d );
-       fprintf( stderr, "  -s  Specify the EGL stencil size             default: %d\n", g_option.egl_s );
-       fprintf( stderr, "  -p  Specify preservation of color buffer     default: %s\n", g_option.egl_preserved ? "true" : "false" );
-       fprintf( stderr, "  -i  Specify swap interval                    default: %d\n", g_option.egl_swap_interval );
-#ifndef WS_NULL
-       fprintf( stderr, "  -x  Set left position of the window          default: %d\n", g_option.wnd_x );
-       fprintf( stderr, "  -y  Set top position of the window           default: %d\n", g_option.wnd_y );
-       fprintf( stderr, "  -w  Set width size of the window             default: %d\n", g_option.wnd_w );
-       fprintf( stderr, "  -h  Set height size of the window            default: %d\n", g_option.wnd_h );
-#endif /* end of WS_NULL */
-       fprintf( stderr, "  -f  Specify the number of frames             default: %d\n", g_option.frames );
-       fprintf( stderr, "  -t  Specify the test case number             default: %d\n", g_option.tc_num );
-       fprintf( stderr, "  -F  Specify the FPS                          default: %d\n", g_option.fps    );
-       fprintf( stderr, "  -a  Run all test cases                       default: %s\n", g_option.all ? "true" : "false" );
-       fprintf( stderr, "  -l  Show TC name                             default: %s\n", g_option.show_names ? "true" : "false" );
+
+       fprintf( stderr, "  -w  Set width size of the window             default: %d\n", g_option.wnd_w );
+       fprintf( stderr, "  -h  Set height size of the window            default: %d\n", g_option.wnd_h );
+
+       fprintf( stderr, "  -t  Specify the test case number             default: %d\n", g_option.tc_num );
+       fprintf( stderr, "  -a  Run all test cases                       default: %s\n", g_option.all ? "true" : "false" );
+       fprintf( stderr, "  -l  Show TC name                             default: %s\n", g_option.show_names ? "true" : "false" );
        fprintf( stderr, "\n" );
        exit( 1 );
 }
@@ -429,7 +418,7 @@ check_option( int argc, char** argv )
                                break;
                        case 't':
                                g_option.tc_num = atol( optarg );
-                g_option.all = false;
+                               g_option.all = false;
                                break;
                        case 'F':
                                g_option.fps = atol( optarg );
@@ -448,42 +437,55 @@ check_option( int argc, char** argv )
 
 }
 
+int tpl_test_log_level = 5;
+
 int
 main( int argc, char** argv )
 {
        TPLNativeWnd* wnd = NULL;
        bool res = false;
        int i = 0;int k=0;
-    int total_num_test = ( sizeof(tpl_test) / sizeof(TPLTest) ) - 1;
-    int tc_num = 0;
+       int total_num_test = ( sizeof(tpl_test) / sizeof(TPLTest) ) - 1;
+       int tc_num = 0;
+       char *log_env;
+       char *env;
 
-    init_option();
-    check_option( argc, argv );
+       init_option();
+       check_option( argc, argv );
 
-       char *env = getenv("TEST_SLEEP");
+       log_env = getenv("TPL_TEST_LOG_LEVEL");
+       if (log_env != NULL)
+       {
+               tpl_test_log_level = atoi(log_env);
+       }
+
+       LOG("INFO",LOG_LEVEL_LOW,"tpl_test_log_level = %d",tpl_test_log_level);
+
+       env = getenv("TEST_SLEEP");
        if (env && !strcmp(env,"yes"))
-    {
+       {
                while(k<20)
-           {
+               {
                        usleep(1000*1000);
                        printf("sleep %d\n",k++);
                }
        }
 
-    if( g_option.show_names )
+       if( g_option.show_names )
        {
-               printf( "----------------------------------------\n" );
-               printf( "  number of test cass: %d                     \n", total_num_test );
-               printf( "----------------------------------------\n" );
+               printf( "-------------------------------------------------\n" );
+               printf( "  number of test cass: %d                     \n", total_num_test );
+               printf( "-------------------------------------------------\n" );
                while( tpl_test[i].name )
                {
                        printf( "  [%2d] %s\n", i, tpl_test[i].name );
                        i++;
                }
-               printf( "----------------------------------------\n" );
+               printf( "-------------------------------------------------\n" );
 
                goto finish;
        }
+
        wnd = tpl_test_native_wnd_create();
        if( !wnd ) goto finish;
 
@@ -494,19 +496,23 @@ main( int argc, char** argv )
                        g_option.wnd_h );
        if( !res ) goto finish;
 
+       printf( "-------------------tpl test begin!!!-----------------------------------\n");
 
-    LOG("INFO", LOG_LEVEL_HIGH , "**************tpl test begin!!!**************************");
-
-    if( g_option.all )
+       if( g_option.all )
        {
                i = 0;
 
                while( tpl_test[i].name )
                {
-                       printf( "[%4d] %s\n", i, tpl_test[i].name );
-
-                       if( tpl_test[i].run ) tpl_test[i].run( wnd );
-
+                       printf( "[%4d] %-50s", i, tpl_test[i].name );
+
+                       if( tpl_test[i].run )
+                       {
+                               if(true == tpl_test[i].run( wnd ))
+                                       printf("[PASS]\n");
+                               else
+                                       printf("[FAIL]\n");
+                       }
                        i++;
                }
        }
@@ -516,53 +522,30 @@ main( int argc, char** argv )
 
                if( tc_num < 0 || tc_num > total_num_test-1 ) goto finish;
 
-               printf( "----------------------------------------\n\n" );
-               if( tpl_test[tc_num].name ) printf( "  [%2d] %s\n", tc_num, tpl_test[tc_num].name );
+               //printf( "----------------------------------------------\n\n" );
+               if( tpl_test[tc_num].name ) printf( "[%4d] %-50s", tc_num, tpl_test[tc_num].name );
                else printf( "[%4d] No test name\n", tc_num );
-               printf( "\n----------------------------------------\n\n" );
 
-               if( tpl_test[tc_num].run ) tpl_test[tc_num].run( wnd );
+               if( tpl_test[tc_num].run )
+               {
+               if(true == tpl_test[tc_num].run( wnd ))
+                       printf("[PASS]\n");
+               else
+                       printf("[FAIL]\n");
+               }
+               //printf( "\n----------------------------------------------\n\n" );
        }
-/*
-    tpl_buffer_map_unmap_test(wnd);
-    tpl_buffer_lock_unlock_test(wnd);
-    tpl_buffer_get_artpl_test(wnd);
-    tpl_buffer_create_native_buffer_test(wnd);
-
-    tpl_display_get_test (wnd);
-    tpl_display_bind_client_display_test(wnd);
-    tpl_display_get_artpl_test (wnd);
-    tpl_display_query_confitpl_test (wnd);
-    tpl_display_filter_confitpl_test (wnd);
-
-    tpl_object_get_type_test(wnd);
-    tpl_object_userdata_test(wnd);
-    tpl_object_reference_test(wnd);
-
-    tpl_surface_create_test(wnd);
-    tpl_surface_get_artpl_test( wnd);
-    tpl_surface_frame_test(wnd);
-    tpl_surface_get_buffer_test(wnd);
-    tpl_surface_post_test(wnd);
-
-    tpl_surface_abnormal_test(wnd);
-    tpl_object_abnormal_test(wnd);
-    tpl_display_abnormal_test(wnd);
-    tpl_buffer_abnormal_test( wnd);
-*/
-    LOG("INFO", LOG_LEVEL_HIGH , "**************tpl test end!!!**************************");
-finish:
 
+       printf("-------------------tpl test end!!!-------------------------------------\n");
 
+finish:
                if( wnd )
                {
-                       //tpl_test_native_wnd_finalize( wnd );
-                       //tpl_test_native_wnd_release( wnd );
+                       tpl_test_native_wnd_finalize( wnd );
+                       tpl_test_native_wnd_release( wnd );
+                       tpl_test_finalize( wnd );
                }
-        //if(tpl_buf)
-        {
 
-        }
 
        return 0;
 }
index 54f46ee..3c8e816 100644 (file)
-#ifndef __TPL_BUF_TEST__\r
-#define __TPL_BUF_TEST__\r
-\r
-#include "tpl_test_util.h"\r
-\r
-\r
-bool tpl_buffer_map_unmap_test(TPLNativeWnd* wnd )\r
-{\r
-    TPL_CHK_PARAM( !wnd );\r
-    bool ret = true;\r
-    LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);\r
-\r
-    //1.tpl_display_get\r
-    tpl_display_t *tpl_display = NULL;\r
-    tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);\r
-    if(tpl_display == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //2.tpl_surface_create\r
-    tpl_surface_t *tpl_surf = NULL;\r
-    tpl_surf = tpl_surface_create(tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);\r
-    if(tpl_surf == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //3.begin frame\r
-    tpl_surface_begin_frame(tpl_surf);\r
-\r
-    //4.get buffer\r
-    tpl_buffer_t *tpl_buf = NULL;\r
-       tpl_buf = tpl_surface_get_buffer(tpl_surf, NULL);\r
-       if (tpl_buf == NULL)\r
-    {\r
-               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");\r
-        ret = false;\r
-        goto finish;\r
-       }\r
-\r
-    //5.buffer map\r
-    void *ptr = NULL;\r
-    //int size = tpl_buf->width * tpl_buf->height * tpl_buf->depth;\r
-    int size = wnd->width * wnd->height ;\r
-    LOG("INFO", LOG_LEVEL_HIGH ,"width=%d,height=%d,size=%d\n",wnd->width , wnd->height , size);\r
-    ptr = tpl_buffer_map(tpl_buf, size);\r
-    if (ptr == NULL)\r
-    {\r
-               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_map");\r
-        ret = false;\r
-        goto finish;\r
-       }\r
-\r
-    //5.buffer unmap\r
-    tpl_buffer_unmap(tpl_buf,ptr,size);\r
-\r
-\r
-finish:\r
-    if(true == ret)\r
-        LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);\r
-    else\r
-        LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);\r
-    return ret;\r
-\r
-\r
-}\r
-\r
-bool tpl_buffer_lock_unlock_test(TPLNativeWnd* wnd )\r
-{\r
-    TPL_CHK_PARAM( !wnd );\r
-    bool ret = true;\r
-    LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);\r
-\r
-    //1.tpl_display_get\r
-    tpl_display_t *tpl_display = NULL;\r
-    tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);\r
-    if(tpl_display == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //2.tpl_surface_create\r
-    tpl_surface_t *tpl_surf = NULL;\r
-    tpl_surf = tpl_surface_create(tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);\r
-    if(tpl_surf == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //3.begin frame\r
-    tpl_surface_begin_frame(tpl_surf);\r
-\r
-    //4.get buffer\r
-    tpl_buffer_t *tpl_buf = NULL;\r
-       tpl_buf = tpl_surface_get_buffer(tpl_surf, NULL);\r
-       if (tpl_buf == NULL)\r
-    {\r
-               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");\r
-        ret = false;\r
-        goto finish;\r
-       }\r
-\r
-    //5.buffer lock\r
-    tpl_bool_t result = false;\r
-    result = tpl_buffer_lock(tpl_buf,TPL_LOCK_USAGE_GPU_READ);\r
-    if(result == true)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_lock");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-    tpl_buffer_unlock(tpl_buf);\r
-\r
-    //TPL_LOCK_USAGE_GPU_WRITE\r
-    result = tpl_buffer_lock(tpl_buf,TPL_LOCK_USAGE_GPU_WRITE);\r
-    if(result == true)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_lock");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-    tpl_buffer_unlock(tpl_buf);\r
-\r
-    //TPL_LOCK_USAGE_CPU_READ\r
-    result = tpl_buffer_lock(tpl_buf,TPL_LOCK_USAGE_CPU_READ);\r
-    if(result == true)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_lock");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-    tpl_buffer_unlock(tpl_buf);\r
-\r
-    //TPL_LOCK_USAGE_CPU_WRITE\r
-    result = tpl_buffer_lock(tpl_buf,TPL_LOCK_USAGE_CPU_WRITE);\r
-    if(result == true)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_lock");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-    tpl_buffer_unlock(tpl_buf);\r
-\r
-\r
-finish:\r
-    if(true == ret)\r
-        LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);\r
-    else\r
-        LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);\r
-    return ret;\r
-\r
-\r
-}\r
-\r
-\r
-bool tpl_buffer_get_arg_test(TPLNativeWnd* wnd )\r
-{\r
-    TPL_CHK_PARAM( !wnd );\r
-    bool ret = true;\r
-    LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);\r
-\r
-    //1.tpl_display_get\r
-    tpl_display_t *tpl_display = NULL;\r
-    tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);\r
-    if(tpl_display == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //2.tpl_surface_create\r
-    tpl_surface_t *tpl_surf = NULL;\r
-    tpl_surf = tpl_surface_create(tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);\r
-    if(tpl_surf == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //3.begin frame\r
-    tpl_surface_begin_frame(tpl_surf);\r
-\r
-    //4.get buffer\r
-    tpl_buffer_t *tpl_buf = NULL;\r
-       tpl_buf = tpl_surface_get_buffer(tpl_surf, NULL);\r
-       if (tpl_buf == NULL)\r
-    {\r
-               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");\r
-        ret = false;\r
-        goto finish;\r
-       }\r
-\r
-    //tpl_buffer_get_key\r
-    unsigned int key = 0;\r
-    key = tpl_buffer_get_key(tpl_buf);\r
-    if (key == 0)\r
-    {\r
-               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_key");\r
-        ret = false;\r
-        goto finish;\r
-       }\r
-\r
-    //tpl_buffer_get_fd\r
-    int fd = -1;\r
-    fd = tpl_buffer_get_fd(tpl_buf);\r
-    if (fd == -1)\r
-    {\r
-               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_fd");\r
-        ret = false;\r
-        goto finish;\r
-       }\r
-\r
-    //tpl_buffer_get_age\r
-    int age = -1;\r
-    age = tpl_buffer_get_age(tpl_buf);\r
-    if (age == 0)\r
-    {\r
-               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_age");\r
-        ret = false;\r
-        goto finish;\r
-       }\r
-\r
-    //tpl_buffer_get_surface\r
-    tpl_surface_t *test_surf = NULL;\r
-    test_surf = tpl_buffer_get_surface(tpl_buf);\r
-    if (test_surf == NULL)\r
-    {\r
-               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_surface");\r
-        ret = false;\r
-        goto finish;\r
-       }\r
-\r
-    //tpl_buffer_get_size\r
-    int width = 0, heigh = 0;\r
-    tpl_buffer_get_size(tpl_buf, &width, &heigh);\r
-    if ((width == 0)||(heigh == 0))\r
-    {\r
-               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_size");\r
-        ret = false;\r
-        goto finish;\r
-       }\r
-\r
-    //tpl_buffer_get_depth\r
-    int depth = 0;\r
-    depth = tpl_buffer_get_depth(tpl_buf);\r
-    if (depth == 0)\r
-    {\r
-               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_depth");\r
-        ret = false;\r
-        goto finish;\r
-       }\r
-    //tpl_buffer_get_pitch\r
-    int pitch = 0;\r
-    pitch = tpl_buffer_get_fd(tpl_buf);\r
-    if (pitch == 0)\r
-    {\r
-               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_fd");\r
-        ret = false;\r
-        goto finish;\r
-       }\r
-\r
-\r
-finish:\r
-    if(true == ret)\r
-        LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);\r
-    else\r
-        LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);\r
-    return ret;\r
-\r
-\r
-}\r
-\r
-\r
-bool tpl_buffer_create_native_buffer_test(TPLNativeWnd* wnd )\r
-{\r
-    TPL_CHK_PARAM( !wnd );\r
-    bool ret = true;\r
-    LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s---",__func__);\r
-\r
-    //1.tpl_display_get\r
-    tpl_display_t *tpl_display = NULL;\r
-    tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);\r
-    if(tpl_display == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //2.tpl_surface_create\r
-    tpl_surface_t *tpl_surf = NULL;\r
-    tpl_surf = tpl_surface_create(tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);\r
-    if(tpl_surf == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //3.begin frame\r
-    tpl_surface_begin_frame(tpl_surf);\r
-\r
-    //4.get buffer\r
-    tpl_buffer_t *tpl_buf = NULL;\r
-       tpl_buf = tpl_surface_get_buffer(tpl_surf, NULL);\r
-       if (tpl_buf == NULL)\r
-    {\r
-               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");\r
-        ret = false;\r
-        goto finish;\r
-       }\r
-\r
-    //create native buffer\r
-    void *native_buffer = NULL;\r
-    native_buffer = tpl_buffer_create_native_buffer(tpl_buf);\r
-    if (native_buffer == NULL)\r
-    {\r
-               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_create_native_buffer");\r
-        ret = false;\r
-        goto finish;\r
-       }\r
-\r
-finish:\r
-    if(true == ret)\r
-        LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);\r
-    else\r
-        LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);\r
-    return ret;\r
-}\r
-\r
-\r
-bool tpl_buffer_abnormal_test(TPLNativeWnd* wnd )\r
-{\r
-    TPL_CHK_PARAM( !wnd );\r
-    bool ret = true;\r
-    LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);\r
-\r
-    //1.tpl_display_get\r
-    tpl_display_t *tpl_display = NULL;\r
-    tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);\r
-    if(tpl_display == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //2.tpl_surface_create\r
-    tpl_surface_t *tpl_surf = NULL;\r
-    tpl_surf = tpl_surface_create(tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);\r
-    if(tpl_surf == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //3.begin frame\r
-    tpl_surface_begin_frame(tpl_surf);\r
-\r
-    //4.get buffer\r
-    tpl_buffer_t *tpl_buf = NULL;\r
-       tpl_buf = tpl_surface_get_buffer(tpl_surf, NULL);\r
-       if (tpl_buf == NULL)\r
-    {\r
-               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");\r
-        ret = false;\r
-        goto finish;\r
-       }\r
-\r
-    //abnormal test\r
-\r
-    tpl_buffer_lock(tpl_buf,TPL_LOCK_USAGE_INVALID);\r
-    int test_width = 0,test_heigh = 0;\r
-    tpl_buffer_map(NULL, 0);\r
-    tpl_buffer_unmap(NULL,NULL,0);\r
-    tpl_buffer_lock(NULL,TPL_LOCK_USAGE_INVALID);\r
-    tpl_buffer_unlock(NULL);\r
-    tpl_buffer_get_key(NULL);\r
-    tpl_buffer_get_fd(NULL);\r
-    tpl_buffer_get_age(NULL);\r
-    tpl_buffer_get_surface(NULL);\r
-    tpl_buffer_get_size(NULL, &test_width, &test_heigh);\r
-    tpl_buffer_get_depth(NULL);\r
-    tpl_buffer_get_pitch(NULL);\r
-    tpl_buffer_create_native_buffer(NULL);\r
-\r
-finish:\r
-    if(true == ret)\r
-        LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);\r
-    else\r
-        LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);\r
-    return ret;\r
-\r
-\r
-}\r
-\r
-\r
-\r
-\r
-\r
-#endif\r
-\r
-\r
+#ifndef __TPL_BUF_TEST__
+#define __TPL_BUF_TEST__
+
+#include "tpl_test_util.h"
+
+
+bool tpl_buffer_map_unmap_test(TPLNativeWnd* wnd )
+{
+       TPL_CHK_PARAM( !wnd );
+       bool ret = true;
+       LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+
+       //1.tpl_display_get
+       wnd->tpl_display = NULL;
+       wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
+       if(wnd->tpl_display == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
+               ret = false;
+               goto finish;
+       }
+
+       //2.tpl_surface_create
+       wnd->tpl_surf = NULL;
+       wnd->tpl_surf = tpl_surface_create(wnd->tpl_display , (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+       if(wnd->tpl_surf == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
+               ret = false;
+               goto finish;
+       }
+
+       //3.begin frame
+       tpl_surface_begin_frame(wnd->tpl_surf);
+
+       //4.get buffer
+       wnd->tpl_buf = NULL;
+       wnd->tpl_buf = tpl_surface_get_buffer(wnd->tpl_surf, NULL);
+       if (wnd->tpl_buf == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");
+               ret = false;
+               goto finish;
+       }
+
+       //5.buffer map
+       void *ptr = NULL;
+       //int size = tpl_buf->width * tpl_buf->height * tpl_buf->depth;
+       int size = wnd->width * wnd->height ;
+       LOG("INFO", LOG_LEVEL_LOW ,"width=%d,height=%d,size=%d\n",wnd->width , wnd->height , size);
+       ptr = tpl_buffer_map(wnd->tpl_buf, size);
+       if (ptr == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_map");
+               ret = false;
+               goto finish;
+       }
+
+       //5.buffer unmap
+       tpl_buffer_unmap(wnd->tpl_buf,ptr,size);
+
+
+finish:
+       if(true == ret)
+               LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+       else
+               LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+       return ret;
+
+
+}
+
+bool tpl_buffer_lock_unlock_test(TPLNativeWnd* wnd )
+{
+       TPL_CHK_PARAM( !wnd );
+       bool ret = true;
+       LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+
+       //1.tpl_display_get
+       wnd->tpl_display = NULL;
+       wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
+       if(wnd->tpl_display == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
+               ret = false;
+               goto finish;
+       }
+
+       //2.tpl_surface_create
+       wnd->tpl_surf = NULL;
+       wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+       if(wnd->tpl_surf == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
+               ret = false;
+               goto finish;
+       }
+
+       //3.begin frame
+       tpl_surface_begin_frame(wnd->tpl_surf);
+
+       //4.get buffer
+       wnd->tpl_buf = NULL;
+       wnd->tpl_buf = tpl_surface_get_buffer(wnd->tpl_surf, NULL);
+       if (wnd->tpl_buf == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");
+               ret = false;
+               goto finish;
+       }
+
+       //5.buffer lock
+       tpl_bool_t result = false;
+       result = tpl_buffer_lock(wnd->tpl_buf,TPL_LOCK_USAGE_GPU_READ);
+       if(result == true)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_lock");
+               ret = false;
+               goto finish;
+       }
+       tpl_buffer_unlock(wnd->tpl_buf);
+
+       //TPL_LOCK_USAGE_GPU_WRITE
+       result = tpl_buffer_lock(wnd->tpl_buf,TPL_LOCK_USAGE_GPU_WRITE);
+       if(result == true)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_lock");
+               ret = false;
+               goto finish;
+       }
+       tpl_buffer_unlock(wnd->tpl_buf);
+
+       //TPL_LOCK_USAGE_CPU_READ
+       result = tpl_buffer_lock(wnd->tpl_buf,TPL_LOCK_USAGE_CPU_READ);
+       if(result == true)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_lock");
+               ret = false;
+               goto finish;
+       }
+       tpl_buffer_unlock(wnd->tpl_buf);
+
+       //TPL_LOCK_USAGE_CPU_WRITE
+       result = tpl_buffer_lock(wnd->tpl_buf,TPL_LOCK_USAGE_CPU_WRITE);
+       if(result == true)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_lock");
+               ret = false;
+               goto finish;
+       }
+       tpl_buffer_unlock(wnd->tpl_buf);
+
+
+finish:
+       if(true == ret)
+               LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+       else
+               LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+       return ret;
+
+
+}
+
+
+bool tpl_buffer_get_arg_test(TPLNativeWnd* wnd )
+{
+       TPL_CHK_PARAM( !wnd );
+       bool ret = true;
+       LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+
+       //1.tpl_display_get
+       wnd->tpl_display = NULL;
+       wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
+       if(wnd->tpl_display == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
+               ret = false;
+               goto finish;
+       }
+
+       //2.tpl_surface_create
+       wnd->tpl_surf = NULL;
+       wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+       if(wnd->tpl_surf == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
+               ret = false;
+               goto finish;
+       }
+
+       //3.begin frame
+       tpl_surface_begin_frame(wnd->tpl_surf);
+
+       //4.get buffer
+       wnd->tpl_buf = NULL;
+       wnd->tpl_buf = tpl_surface_get_buffer(wnd->tpl_surf, NULL);
+       if (wnd->tpl_buf == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");
+               ret = false;
+               goto finish;
+       }
+
+       //tpl_buffer_get_key
+       unsigned int key = 0;
+       key = tpl_buffer_get_key(wnd->tpl_buf);
+       if (key == 0)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_key");
+               ret = false;
+               goto finish;
+       }
+
+       //tpl_buffer_get_fd
+       int fd = -1;
+       fd = tpl_buffer_get_fd(wnd->tpl_buf);
+       if (fd == -1)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_fd");
+               ret = false;
+               goto finish;
+       }
+
+       //tpl_buffer_get_age
+       int age = -1;
+       age = tpl_buffer_get_age(wnd->tpl_buf);
+       if (age == 0)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_age");
+               ret = false;
+               goto finish;
+       }
+
+       //tpl_buffer_get_surface
+       tpl_surface_t *test_surf = NULL;
+       test_surf = tpl_buffer_get_surface(wnd->tpl_buf);
+       if (test_surf == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_surface");
+               ret = false;
+               goto finish;
+       }
+
+       //tpl_buffer_get_size
+       int width = 0, heigh = 0;
+       tpl_buffer_get_size(wnd->tpl_buf, &width, &heigh);
+       if ((width == 0)||(heigh == 0))
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_size");
+               ret = false;
+               goto finish;
+       }
+
+       //tpl_buffer_get_depth
+       int depth = 0;
+       depth = tpl_buffer_get_depth(wnd->tpl_buf);
+       if (depth == 0)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_depth");
+               ret = false;
+               goto finish;
+       }
+       //tpl_buffer_get_pitch
+       int pitch = 0;
+       pitch = tpl_buffer_get_fd(wnd->tpl_buf);
+       if (pitch == 0)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_get_fd");
+               ret = false;
+               goto finish;
+       }
+
+
+finish:
+       if(true == ret)
+               LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+       else
+               LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+       return ret;
+
+
+}
+
+
+bool tpl_buffer_create_native_buffer_test(TPLNativeWnd* wnd )
+{
+       TPL_CHK_PARAM( !wnd );
+       bool ret = true;
+       LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s---",__func__);
+
+       //1.tpl_display_get
+       wnd->tpl_display = NULL;
+       wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
+       if(wnd->tpl_display == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
+               ret = false;
+               goto finish;
+       }
+
+       //2.tpl_surface_create
+       wnd->tpl_surf = NULL;
+       wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+       if(wnd->tpl_surf == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
+               ret = false;
+               goto finish;
+       }
+
+       //3.begin frame
+       tpl_surface_begin_frame(wnd->tpl_surf);
+
+       //4.get buffer
+       wnd->tpl_buf = NULL;
+       wnd->tpl_buf = tpl_surface_get_buffer(wnd->tpl_surf, NULL);
+       if (wnd->tpl_buf == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");
+               ret = false;
+               goto finish;
+       }
+
+       //create native buffer
+       void *native_buffer = NULL;
+       native_buffer = tpl_buffer_create_native_buffer(wnd->tpl_buf);
+       if (native_buffer == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_create_native_buffer");
+               ret = false;
+               goto finish;
+       }
+
+finish:
+       if(true == ret)
+               LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+       else
+               LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+       return ret;
+}
+
+
+bool tpl_buffer_abnormal_test(TPLNativeWnd* wnd )
+{
+       TPL_CHK_PARAM( !wnd );
+       bool ret = true;
+       LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+
+       //1.tpl_display_get
+       wnd->tpl_display = NULL;
+       wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
+       if(wnd->tpl_display == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
+               ret = false;
+               goto finish;
+       }
+
+       //2.tpl_surface_create
+       wnd->tpl_surf = NULL;
+       wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+       if(wnd->tpl_surf == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
+               ret = false;
+               goto finish;
+       }
+
+       //3.begin frame
+       tpl_surface_begin_frame(wnd->tpl_surf);
+
+       //4.get buffer
+       wnd->tpl_buf = NULL;
+       wnd->tpl_buf = tpl_surface_get_buffer(wnd->tpl_surf, NULL);
+       if (wnd->tpl_buf == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");
+               ret = false;
+               goto finish;
+       }
+
+       //abnormal test
+
+       tpl_buffer_lock(wnd->tpl_buf,TPL_LOCK_USAGE_INVALID);
+       int test_width = 0,test_heigh = 0;
+       tpl_buffer_map(NULL, 0);
+       tpl_buffer_unmap(NULL,NULL,0);
+       tpl_buffer_lock(NULL,TPL_LOCK_USAGE_INVALID);
+       tpl_buffer_unlock(NULL);
+       tpl_buffer_get_key(NULL);
+       tpl_buffer_get_fd(NULL);
+       tpl_buffer_get_age(NULL);
+       tpl_buffer_get_surface(NULL);
+       tpl_buffer_get_size(NULL, &test_width, &test_heigh);
+       tpl_buffer_get_depth(NULL);
+       tpl_buffer_get_pitch(NULL);
+       tpl_buffer_create_native_buffer(NULL);
+
+finish:
+       if(true == ret)
+               LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+       else
+               LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+       return ret;
+
+
+}
+
+
+bool tpl_buffer_stress_test(TPLNativeWnd* wnd )
+{
+       TPL_CHK_PARAM( !wnd );
+       bool ret = true;
+       int index = 0;int size = 0;
+       LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+
+       //1.tpl_display _get
+       wnd->tpl_display = NULL;
+       wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
+       if(wnd->tpl_display == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
+               ret = false;
+               goto finish;
+       }
+
+       //2.tpl_surface_create
+       wnd->tpl_surf = NULL;
+       wnd->tpl_surf = tpl_surface_create(wnd->tpl_display , (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+       if(wnd->tpl_surf == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
+               ret = false;
+               goto finish;
+       }
+
+       tpl_buffer_t *buf_array[STRESS_NUM]={0};
+       for(index = 0;index<STRESS_NUM;index++)
+       {
+               tpl_surface_begin_frame(wnd->tpl_surf);
+               buf_array[index] = tpl_surface_get_buffer(wnd->tpl_surf, NULL);
+               if (buf_array[index] == NULL)
+               {
+                       LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");
+                       ret = false;
+                       goto finish;
+               }
+
+               void *ptr = NULL;
+               size = wnd->width * wnd->height ;
+               ptr = tpl_buffer_map(buf_array[index], size);
+               if (ptr == NULL)
+               {
+                       LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_map");
+                       ret = false;
+                       goto finish;
+               }
+               //6.write
+               int *p = NULL;int j=0;
+               for(j = 0; j <size;j++)
+               {
+                       p = (int*) ptr;
+                       if(index%2 == 0)
+                           *(p+j) = 0xFF00;
+                       else
+                           *(p+j) = 0x00FF;
+               }
+
+               tpl_surface_end_frame(wnd->tpl_surf);
+
+               tpl_surface_post(wnd->tpl_surf);
+               usleep(500*1000);//0.5s
+       }
+
+finish:
+       if(true == ret)
+                   LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+       else
+                   LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+       return ret;
+    }
+
+
+#endif
+
+
index 4d8e79a..36258bd 100644 (file)
-#ifndef __TPL_DISPLAY_TEST__\r
-#define __TPL_DISPLAY_TEST__\r
-\r
-#include "tpl_test_util.h"\r
-\r
-\r
-bool tpl_display_get_test (TPLNativeWnd* wnd)\r
-{\r
-    TPL_CHK_PARAM( !wnd );\r
-    LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);\r
-    bool ret = true;\r
-    tpl_display_t *tpl_display = NULL;\r
-    tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);\r
-    if(tpl_display == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //abnormal test\r
-    tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, NULL);\r
-    if(tpl_display != NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "abnormal test failed:tpl_display_get");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-finish:\r
-    if(true == ret)\r
-        LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);\r
-    else\r
-        LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);\r
-    return ret;\r
-}\r
-\r
-\r
-bool tpl_display_bind_client_display_test(TPLNativeWnd* wnd)\r
-{\r
-    TPL_CHK_PARAM( !wnd );\r
-    LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s---",__func__);\r
-    bool ret = true;\r
-    tpl_display_t *tpl_display = NULL;\r
-    tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);\r
-    if(tpl_display == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    // bind display handle\r
-    tpl_bool_t result = false;\r
-    result = tpl_display_bind_client_display_handle(tpl_display,(tpl_handle_t)wnd->dpy);\r
-    if(result == false)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , " failed:tpl_display_bind_client_display_handle");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    // unbind display handle\r
-    result = false;\r
-    result = tpl_display_unbind_client_display_handle(tpl_display,(tpl_handle_t)wnd->dpy);\r
-    if(result == false)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , " failed:tpl_display_unbind_client_display_handle");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-finish:\r
-    if(true == ret)\r
-        LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);\r
-    else\r
-        LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);\r
-    return ret;\r
-}\r
-\r
-\r
-bool tpl_display_get_arg_test (TPLNativeWnd* wnd)\r
-{\r
-    TPL_CHK_PARAM( !wnd );\r
-    LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);\r
-    bool ret = true;\r
-    tpl_display_t *tpl_display = NULL;\r
-    tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);\r
-    if(tpl_display == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //tpl_display_get_backend_type\r
-    tpl_backend_type_t backend_type = tpl_display_get_backend_type(tpl_display);\r
-    if(backend_type != TPL_BACKEND_WAYLAND)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get_backend_type");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //tpl_display_get_bufmgr_fd\r
-    int test_fd = -1;\r
-    test_fd = tpl_display_get_bufmgr_fd(tpl_display);\r
-    if(test_fd == -1)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get_bufmgr_fd");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //tpl_display_get_native_handle\r
-    tpl_handle_t test_handle = NULL;\r
-    test_handle = tpl_display_get_native_handle(tpl_display);\r
-    if(test_handle == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get_native_handle");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-finish:\r
-    if(true == ret)\r
-        LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);\r
-    else\r
-        LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);\r
-    return ret;\r
-}\r
-\r
-\r
-bool tpl_display_query_config_test (TPLNativeWnd* wnd)\r
-{\r
-    TPL_CHK_PARAM( !wnd );\r
-    LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);\r
-    bool ret = true;\r
-    tpl_display_t *tpl_display = NULL;\r
-    tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);\r
-    if(tpl_display == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-    //query config\r
-    tpl_bool_t result = false;\r
-    result = tpl_display_query_config(tpl_display,\r
-                        TPL_SURFACE_TYPE_WINDOW,\r
-                        8,\r
-                        8,\r
-                        8,\r
-                        8,\r
-                        32,\r
-                        NULL,\r
-                        NULL);\r
-    if(result == false )\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_query_config");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    result = tpl_display_query_config(tpl_display,\r
-                        TPL_SURFACE_TYPE_WINDOW,\r
-                        8,\r
-                        8,\r
-                        8,\r
-                        8,\r
-                        24,\r
-                        NULL,\r
-                        NULL);\r
-    if(result == false )\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_query_config");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    result = tpl_display_query_config(tpl_display,\r
-                        TPL_SURFACE_TYPE_WINDOW,\r
-                        0,\r
-                        8,\r
-                        8,\r
-                        8,\r
-                        24,\r
-                        NULL,\r
-                        NULL);\r
-    if(result != false )//unmatched case\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_query_config");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-finish:\r
-    if(true == ret)\r
-        LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);\r
-    else\r
-        LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);\r
-    return ret;\r
-}\r
-\r
-bool tpl_display_filter_config_test (TPLNativeWnd* wnd)\r
-{\r
-    TPL_CHK_PARAM( !wnd );\r
-    LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);\r
-    bool ret = true;\r
-    tpl_display_t *tpl_display = NULL;\r
-    tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);\r
-    if(tpl_display == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //filt config\r
-    tpl_bool_t result = false;\r
-    int test_visual_id = GBM_FORMAT_ARGB8888;\r
-    result = tpl_display_filter_config(tpl_display,&test_visual_id,0);\r
-    if(result == false )\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_filter_config");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //filt config, unmatched case\r
-    result = tpl_display_filter_config(tpl_display,&test_visual_id,8);\r
-    if(result != false )\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_filter_config");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-    test_visual_id = GBM_FORMAT_XRGB8888;\r
-    result = tpl_display_filter_config(tpl_display,&test_visual_id,0);\r
-    if(result != false )\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_filter_config");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-\r
-finish:\r
-    if(true == ret)\r
-        LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);\r
-    else\r
-        LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);\r
-    return ret;\r
-}\r
-\r
-\r
-bool tpl_display_abnormal_test (TPLNativeWnd* wnd)\r
-{\r
-    TPL_CHK_PARAM( !wnd );\r
-    LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);\r
-    bool ret = true;\r
-    tpl_display_t *tpl_display = NULL;\r
-    tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);\r
-    if(tpl_display == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //abnormal test\r
-    tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, NULL);\r
-    if(tpl_display != NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "abnormal test failed:tpl_display_get");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-\r
-    //abnormal test\r
-    tpl_display_bind_client_display_handle(NULL,NULL);\r
-    tpl_display_unbind_client_display_handle(NULL,NULL);\r
-    tpl_display_get_backend_type(NULL);\r
-    tpl_display_get_bufmgr_fd(NULL);\r
-    tpl_display_get_native_handle(NULL);\r
-    tpl_display_filter_config(NULL,NULL,0);\r
-    tpl_display_query_config(NULL,\r
-                        TPL_SURFACE_TYPE_PIXMAP,\r
-                        0,\r
-                        8,\r
-                        8,\r
-                        8,\r
-                        24,\r
-                        NULL,\r
-                        NULL);\r
-\r
-\r
-\r
-finish:\r
-    if(true == ret)\r
-        LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);\r
-    else\r
-        LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);\r
-    return ret;\r
-}\r
-\r
-\r
-#endif\r
-\r
+#ifndef __TPL_DISPLAY_TEST__
+#define __TPL_DISPLAY_TEST__
+
+#include "tpl_test_util.h"
+
+
+bool tpl_display_get_test (TPLNativeWnd* wnd)
+{
+       TPL_CHK_PARAM( !wnd );
+       LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+       bool ret = true;
+       wnd->tpl_display = NULL;
+       wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
+       if(wnd->tpl_display == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
+               ret = false;
+               goto finish;
+       }
+ finish:
+       if(true == ret)
+               LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+       else
+               LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+       return ret;
+}
+
+
+bool tpl_display_bind_client_display_test(TPLNativeWnd* wnd)
+{
+       TPL_CHK_PARAM( !wnd );
+       LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s---",__func__);
+       bool ret = true;
+       wnd->tpl_display = NULL;
+       wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
+       if(wnd->tpl_display == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
+               ret = false;
+               goto finish;
+       }
+
+       // bind display handle
+       tpl_bool_t result = false;
+       result = tpl_display_bind_client_display_handle(wnd->tpl_display,(tpl_handle_t)wnd->dpy);
+       if(result == false)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , " failed:tpl_display_bind_client_display_handle");
+               ret = false;
+               goto finish;
+       }
+
+       // unbind display handle
+       result = false;
+       result = tpl_display_unbind_client_display_handle(wnd->tpl_display,(tpl_handle_t)wnd->dpy);
+       if(result == false)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , " failed:tpl_display_unbind_client_display_handle");
+               ret = false;
+               goto finish;
+       }
+
+finish:
+       if(true == ret)
+               LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+       else
+               LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+       return ret;
+}
+
+
+bool tpl_display_get_arg_test (TPLNativeWnd* wnd)
+{
+       TPL_CHK_PARAM( !wnd );
+       LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+       bool ret = true;
+       wnd->tpl_display = NULL;
+       wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
+       if(wnd->tpl_display == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
+               ret = false;
+               goto finish;
+       }
+
+       //tpl_display_get_backend_type
+       tpl_backend_type_t backend_type = tpl_display_get_backend_type(wnd->tpl_display);
+       if(backend_type != TPL_BACKEND_WAYLAND)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get_backend_type");
+               ret = false;
+               goto finish;
+       }
+
+       //tpl_display_get_bufmgr_fd
+       int test_fd = -1;
+       test_fd = tpl_display_get_bufmgr_fd(wnd->tpl_display);
+       if(test_fd == -1)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get_bufmgr_fd");
+               ret = false;
+               goto finish;
+       }
+
+       //tpl_display_get_native_handle
+       tpl_handle_t test_handle = NULL;
+       test_handle = tpl_display_get_native_handle(wnd->tpl_display);
+       if(test_handle == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get_native_handle");
+               ret = false;
+               goto finish;
+       }
+
+finish:
+       if(true == ret)
+               LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+       else
+               LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+       return ret;
+}
+
+
+bool tpl_display_query_config_test (TPLNativeWnd* wnd)
+{
+       TPL_CHK_PARAM( !wnd );
+       LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+       bool ret = true;
+       wnd->tpl_display = NULL;
+       wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
+       if(wnd->tpl_display == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
+               ret = false;
+               goto finish;
+       }
+       //query config
+       tpl_bool_t result = false;
+       result = tpl_display_query_config(wnd->tpl_display,
+                        TPL_SURFACE_TYPE_WINDOW,
+                        8,
+                        8,
+                        8,
+                        8,
+                        32,
+                        NULL,
+                        NULL);
+       if(result == false )
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_query_config");
+               ret = false;
+               goto finish;
+       }
+
+       result = tpl_display_query_config(wnd->tpl_display,
+                        TPL_SURFACE_TYPE_WINDOW,
+                        8,
+                        8,
+                        8,
+                        8,
+                        24,
+                        NULL,
+                        NULL);
+       if(result == false )
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_query_config");
+               ret = false;
+               goto finish;
+       }
+
+       result = tpl_display_query_config(wnd->tpl_display,
+                        TPL_SURFACE_TYPE_WINDOW,
+                        0,
+                        8,
+                        8,
+                        8,
+                        24,
+                        NULL,
+                        NULL);
+       if(result != false )//unmatched case
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_query_config");
+               ret = false;
+               goto finish;
+       }
+
+finish:
+       if(true == ret)
+               LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+       else
+            LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+       return ret;
+}
+
+bool tpl_display_filter_config_test (TPLNativeWnd* wnd)
+{
+       TPL_CHK_PARAM( !wnd );
+       LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+       bool ret = true;
+       wnd->tpl_display = NULL;
+       wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
+       if(wnd->tpl_display == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
+               ret = false;
+               goto finish;
+       }
+
+       //filt config
+       tpl_bool_t result = false;
+       int test_visual_id = GBM_FORMAT_ARGB8888;
+       result = tpl_display_filter_config(wnd->tpl_display,&test_visual_id,0);
+       if(result == false )
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_filter_config");
+               ret = false;
+               goto finish;
+       }
+
+       //filt config, unmatched case
+       result = tpl_display_filter_config(wnd->tpl_display,&test_visual_id,8);
+       if(result != false )
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_filter_config");
+               ret = false;
+               goto finish;
+       }
+       test_visual_id = GBM_FORMAT_XRGB8888;
+       result = tpl_display_filter_config(wnd->tpl_display,&test_visual_id,0);
+       if(result != false )
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_filter_config");
+               ret = false;
+               goto finish;
+       }
+
+
+finish:
+       if(true == ret)
+               LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+       else
+               LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+       return ret;
+}
+
+
+bool tpl_display_abnormal_test (TPLNativeWnd* wnd)
+{
+       TPL_CHK_PARAM( !wnd );
+       LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+       bool ret = true;
+       wnd->tpl_display = NULL;
+       wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
+       if(wnd->tpl_display == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
+               ret = false;
+               goto finish;
+       }
+
+       //abnormal test
+       wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, NULL);
+       if(wnd->tpl_display != NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "abnormal test failed:tpl_display_get");
+               ret = false;
+               goto finish;
+       }
+
+
+       //abnormal test
+       tpl_display_bind_client_display_handle(NULL,NULL);
+       tpl_display_unbind_client_display_handle(NULL,NULL);
+       tpl_display_get_backend_type(NULL);
+       tpl_display_get_bufmgr_fd(NULL);
+       tpl_display_get_native_handle(NULL);
+       tpl_display_filter_config(NULL,NULL,0);
+       tpl_display_query_config(NULL,TPL_SURFACE_TYPE_PIXMAP,0,8,8,8,24,NULL,NULL);
+
+
+finish:
+       if(true == ret)
+               LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+       else
+               LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+       return ret;
+}
+
+
+#endif
+
index 43852bc..f4e4186 100644 (file)
-#ifndef __TPL_OBJECT_TEST__\r
-#define __TPL_OBJECT_TEST__\r
-\r
-#include "tpl_test_util.h"\r
-\r
-\r
-bool tpl_object_get_type_test(TPLNativeWnd* wnd )\r
-{\r
-    TPL_CHK_PARAM( !wnd );\r
-    bool ret = true;\r
-    LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);\r
-\r
-    //1.tpl_display_get\r
-    tpl_display_t *tpl_display = NULL;\r
-    tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);\r
-    if(tpl_display == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //2.tpl_surface_create\r
-    tpl_surface_t *tpl_surf = NULL;\r
-    tpl_surf = tpl_surface_create(tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);\r
-    if(tpl_surf == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //3.begin frame\r
-    tpl_surface_begin_frame(tpl_surf);\r
-\r
-    //4.get buffer\r
-    tpl_buffer_t *tpl_buf = NULL;\r
-       tpl_buf = tpl_surface_get_buffer(tpl_surf, NULL);\r
-       if (tpl_buf == NULL)\r
-    {\r
-               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");\r
-        ret = false;\r
-        goto finish;\r
-       }\r
-\r
-    //tpl_object_get_type:DISPLAY\r
-    int obj_type = -1;\r
-    obj_type = tpl_object_get_type((tpl_object_t *)tpl_display);\r
-    if (obj_type != TPL_OBJECT_DISPLAY)\r
-    {\r
-               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_object_get_type");\r
-        ret = false;\r
-        goto finish;\r
-       }\r
-\r
-    //tpl_object_get_type:SURFACE\r
-    obj_type = -1;\r
-    obj_type = tpl_object_get_type((tpl_object_t *)tpl_surf);\r
-    if (obj_type != TPL_OBJECT_SURFACE)\r
-    {\r
-               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_object_get_type");\r
-        ret = false;\r
-        goto finish;\r
-       }\r
-\r
-    //tpl_object_get_type:BUFFER\r
-    obj_type = -1;\r
-    obj_type = tpl_object_get_type((tpl_object_t *)tpl_buf);\r
-    if (obj_type != TPL_OBJECT_BUFFER)\r
-    {\r
-               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_object_get_type");\r
-        ret = false;\r
-        goto finish;\r
-       }\r
-\r
-finish:\r
-    if(true == ret)\r
-        LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);\r
-    else\r
-        LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);\r
-    return ret;\r
-\r
-\r
-}\r
-\r
-\r
-bool tpl_object_userdata_test(TPLNativeWnd* wnd )\r
-{\r
-    TPL_CHK_PARAM( !wnd );\r
-    bool ret = true;\r
-    LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);\r
-\r
-    //1.tpl_display_get\r
-    tpl_display_t *tpl_display = NULL;\r
-    tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);\r
-    if(tpl_display == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //2. set userdate\r
-    tpl_object_set_user_data((tpl_object_t *)tpl_display,(void *)wnd->dpy,NULL);\r
-\r
-    //3.get userdate\r
-    void* get_dpy = NULL;\r
-       get_dpy = (void *)tpl_object_get_user_data((tpl_object_t *)tpl_display);\r
-    if(get_dpy == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_object_get_user_data");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-\r
-finish:\r
-    if(true == ret)\r
-        LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);\r
-    else\r
-        LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);\r
-    return ret;\r
-\r
-\r
-}\r
-\r
-bool tpl_object_reference_test(TPLNativeWnd* wnd )\r
-{\r
-    TPL_CHK_PARAM( !wnd );\r
-    bool ret = true;\r
-    LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);\r
-\r
-    //1.tpl_display_get\r
-    tpl_display_t *tpl_display = NULL;\r
-    tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);\r
-    if(tpl_display == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //2. tpl_object_reference\r
-    tpl_object_reference((tpl_object_t *)tpl_display);\r
-\r
-    //3.tpl_object_get_reference\r
-    int ref_count = -1;\r
-    ref_count = tpl_object_get_reference((tpl_object_t *)tpl_display);\r
-    if(ref_count == -1)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_object_get_reference");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //4.tpl_object_unreference\r
-    int unref_count = -1;\r
-    unref_count = tpl_object_unreference((tpl_object_t *)tpl_display);\r
-    if(unref_count != ref_count-1)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_object_unreference");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-finish:\r
-    if(true == ret)\r
-        LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);\r
-    else\r
-        LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);\r
-    return ret;\r
-\r
-\r
-}\r
-\r
-bool tpl_object_abnormal_test(TPLNativeWnd* wnd )\r
-{\r
-    TPL_CHK_PARAM( !wnd );\r
-    bool ret = true;\r
-    LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);\r
-\r
-\r
-    //abnormal test\r
-    tpl_object_get_type(NULL);\r
-    tpl_object_set_user_data(NULL,NULL,NULL);\r
-    tpl_object_get_user_data(NULL);\r
-    tpl_object_reference(NULL);\r
-    tpl_object_get_reference(NULL);\r
-    tpl_object_unreference(NULL);\r
-\r
-\r
-finish:\r
-    if(true == ret)\r
-        LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);\r
-    else\r
-        LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);\r
-    return ret;\r
-\r
-\r
-}\r
-\r
-\r
-\r
-\r
-#endif\r
-\r
-\r
+#ifndef __TPL_OBJECT_TEST__
+#define __TPL_OBJECT_TEST__
+
+#include "tpl_test_util.h"
+
+
+bool tpl_object_get_type_test(TPLNativeWnd* wnd )
+{
+       TPL_CHK_PARAM( !wnd );
+       bool ret = true;
+       LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+
+       //1.tpl_display_get
+       wnd->tpl_display = NULL;
+       wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
+       if(wnd->tpl_display == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
+               ret = false;
+               goto finish;
+       }
+
+       //2.tpl_surface_create
+       wnd->tpl_surf = NULL;
+       wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+       if(wnd->tpl_surf == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
+               ret = false;
+               goto finish;
+       }
+
+       //3.begin frame
+       tpl_surface_begin_frame(wnd->tpl_surf);
+
+       //4.get buffer
+       wnd->tpl_buf = NULL;
+       wnd->tpl_buf = tpl_surface_get_buffer(wnd->tpl_surf, NULL);
+       if (wnd->tpl_buf == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");
+               ret = false;
+               goto finish;
+       }
+
+       //tpl_object_get_type:DISPLAY
+       int obj_type = -1;
+       obj_type = tpl_object_get_type((tpl_object_t *)wnd->tpl_display);
+       if (obj_type != TPL_OBJECT_DISPLAY)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_object_get_type");
+               ret = false;
+               goto finish;
+       }
+
+       //tpl_object_get_type:SURFACE
+       obj_type = -1;
+       obj_type = tpl_object_get_type((tpl_object_t *)wnd->tpl_surf);
+       if (obj_type != TPL_OBJECT_SURFACE)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_object_get_type");
+               ret = false;
+               goto finish;
+       }
+
+       //tpl_object_get_type:BUFFER
+       obj_type = -1;
+       obj_type = tpl_object_get_type((tpl_object_t *)wnd->tpl_buf);
+       if (obj_type != TPL_OBJECT_BUFFER)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_object_get_type");
+               ret = false;
+               goto finish;
+       }
+
+finish:
+       if(true == ret)
+               LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+       else
+               LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+       return ret;
+
+
+}
+
+
+bool tpl_object_userdata_test(TPLNativeWnd* wnd )
+{
+       TPL_CHK_PARAM( !wnd );
+       bool ret = true;
+       LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+
+       //1.tpl_display_get
+       wnd->tpl_display = NULL;
+       wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
+       if(wnd->tpl_display == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
+               ret = false;
+               goto finish;
+       }
+
+       //2. set userdate
+       tpl_object_set_user_data((tpl_object_t *)wnd->tpl_display,(void *)wnd->dpy,NULL);
+
+       //3.get userdate
+       void* get_dpy = NULL;
+       get_dpy = (void *)tpl_object_get_user_data((tpl_object_t *)wnd->tpl_display);
+       if(get_dpy == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_object_get_user_data");
+               ret = false;
+               goto finish;
+       }
+
+
+finish:
+       if(true == ret)
+               LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+       else
+               LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+       return ret;
+
+
+}
+
+bool tpl_object_reference_test(TPLNativeWnd* wnd )
+{
+       TPL_CHK_PARAM( !wnd );
+       bool ret = true;
+       LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+
+       //1.tpl_display_get
+       wnd->tpl_display = NULL;
+       wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
+       if(wnd->tpl_display == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
+               ret = false;
+               goto finish;
+       }
+
+       //2. tpl_object_reference
+       tpl_object_reference((tpl_object_t *)wnd->tpl_display);
+
+       //3.tpl_object_get_reference
+       int ref_count = -1;
+       ref_count = tpl_object_get_reference((tpl_object_t *)wnd->tpl_display);
+       if(ref_count == -1)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_object_get_reference");
+               ret = false;
+               goto finish;
+       }
+
+       //4.tpl_object_unreference
+       int unref_count = -1;
+       unref_count = tpl_object_unreference((tpl_object_t *)wnd->tpl_display);
+       if(unref_count != ref_count-1)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_object_unreference");
+               ret = false;
+               goto finish;
+       }
+
+finish:
+       if(true == ret)
+               LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+       else
+               LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+       return ret;
+
+
+}
+
+bool tpl_object_abnormal_test(TPLNativeWnd* wnd )
+{
+       TPL_CHK_PARAM( !wnd );
+       bool ret = true;
+       LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+
+
+       //abnormal test
+       tpl_object_get_type(NULL);
+       tpl_object_set_user_data(NULL,NULL,NULL);
+       tpl_object_get_user_data(NULL);
+       tpl_object_reference(NULL);
+       tpl_object_get_reference(NULL);
+       tpl_object_unreference(NULL);
+
+
+finish:
+       if(true == ret)
+               LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+       else
+               LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+       return ret;
+
+
+}
+
+
+
+
+#endif
+
+
index 4a19b8c..ac8a30f 100644 (file)
-#ifndef __TPL_SURF_TEST__\r
-#define __TPL_SURF_TEST__\r
-\r
-#include "tpl_test_util.h"\r
-\r
-\r
-bool tpl_surface_create_test(TPLNativeWnd* wnd)\r
-{\r
-    TPL_CHK_PARAM( !wnd );\r
-    LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);\r
-    bool ret = true;\r
-    tpl_display_t *tpl_display = NULL;\r
-    //1.tpl_display_get\r
-    tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);\r
-    if(tpl_display == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-    //2.tpl_surface_create\r
-    tpl_surface_t *tpl_surf = NULL;\r
-    tpl_surf = tpl_surface_create(tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);\r
-    if(tpl_surf == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-finish:\r
-    if(true == ret)\r
-        LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);\r
-    else\r
-        LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);\r
-    return ret;\r
-}\r
-\r
-bool tpl_surface_get_arg_test(TPLNativeWnd* wnd)\r
-{\r
-    TPL_CHK_PARAM( !wnd );\r
-    LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);\r
-    bool ret = true;\r
-    tpl_display_t *tpl_display = NULL;\r
-    //1.tpl_display_get\r
-    tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);\r
-    if(tpl_display == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-    //2.tpl_surface_create\r
-    tpl_surface_t *tpl_surf = NULL;\r
-    tpl_surf = tpl_surface_create(tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);\r
-    if(tpl_surf == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //tpl_surface_get_display test\r
-    tpl_display_t* test_dpy = tpl_surface_get_display(tpl_surf);\r
-    if(test_dpy == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_display");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-    //tpl_surface_get_native_handle\r
-    tpl_handle_t test_handle = tpl_surface_get_native_handle(tpl_surf);\r
-    if(test_handle == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_native_handle");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-    //tpl_surface_get_type test\r
-    tpl_surface_type_t test_type = tpl_surface_get_type(tpl_surf);\r
-    if(test_type != TPL_SURFACE_TYPE_WINDOW)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_type");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-finish:\r
-    if(true == ret)\r
-        LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);\r
-    else\r
-        LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);\r
-    return ret;\r
-}\r
-\r
-bool tpl_surface_frame_test(TPLNativeWnd* wnd)\r
-{\r
-    TPL_CHK_PARAM( !wnd );\r
-    LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);\r
-    bool ret = true;\r
-    tpl_display_t *tpl_display = NULL;\r
-    //1.tpl_display_get\r
-    tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);\r
-    if(tpl_display == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-    //2.tpl_surface_create\r
-    tpl_surface_t *tpl_surf = NULL;\r
-    tpl_surf = tpl_surface_create(tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);\r
-    if(tpl_surf == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //3.begin frame\r
-    tpl_surface_begin_frame(tpl_surf);\r
-\r
-    //4.tpl_surface_validate_frame\r
-    tpl_bool_t isvalid = tpl_surface_validate_frame(tpl_surf);\r
-\r
-    //5. end frame\r
-    tpl_surface_end_frame(tpl_surf);\r
-\r
-\r
-finish:\r
-    if(true == ret)\r
-        LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);\r
-    else\r
-        LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);\r
-\r
-    return ret;\r
-}\r
-\r
-\r
-bool tpl_surface_get_buffer_test(TPLNativeWnd* wnd )\r
-{\r
-    TPL_CHK_PARAM( !wnd );\r
-    bool ret = true;\r
-    LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);\r
-\r
-    //1.tpl_display_get\r
-    tpl_display_t *tpl_display = NULL;\r
-    tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);\r
-    if(tpl_display == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //2.tpl_surface_create\r
-    tpl_surface_t *tpl_surf = NULL;\r
-    tpl_surf = tpl_surface_create(tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);\r
-    if(tpl_surf == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //3.begin frame\r
-    tpl_surface_begin_frame(tpl_surf);\r
-\r
-    //4.get buffer\r
-    tpl_buffer_t *tpl_buf = NULL;\r
-       tpl_buf = tpl_surface_get_buffer(tpl_surf, NULL);\r
-       if (tpl_buf == NULL)\r
-    {\r
-               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");\r
-        ret = false;\r
-        goto finish;\r
-       }\r
-\r
-    //4.get buffer reset\r
-    tpl_buffer_t *tpl_buf_r = NULL;\r
-    tpl_bool_t reset;\r
-       tpl_buf_r = tpl_surface_get_buffer(tpl_surf, &reset);\r
-       if (tpl_buf_r == NULL)\r
-    {\r
-               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");\r
-        ret = false;\r
-        goto finish;\r
-       }\r
-\r
-finish:\r
-    if(true == ret)\r
-        LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);\r
-    else\r
-        LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);\r
-    return ret;\r
-\r
-\r
-}\r
-\r
-\r
-\r
-\r
-bool tpl_surface_post_test(TPLNativeWnd* wnd )\r
-{\r
-    TPL_CHK_PARAM( !wnd );\r
-    bool ret = true;\r
-    LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);\r
-\r
-    //1.tpl_display_get\r
-    tpl_display_t *tpl_display = NULL;\r
-    tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);\r
-    if(tpl_display == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //2.tpl_surface_create\r
-    tpl_surface_t *tpl_surf = NULL;\r
-    tpl_surf = tpl_surface_create(tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);\r
-    if(tpl_surf == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //3.begin frame\r
-    tpl_surface_begin_frame(tpl_surf);\r
-\r
-    //4.get buffer\r
-    tpl_buffer_t *tpl_buf = NULL;\r
-       tpl_buf = tpl_surface_get_buffer(tpl_surf, NULL);\r
-       if (tpl_buf == NULL)\r
-    {\r
-               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");\r
-        ret = false;\r
-        goto finish;\r
-       }\r
-\r
-    //5.buffer map\r
-    void *ptr = NULL;\r
-    //int size = tpl_buf->width * tpl_buf->height * tpl_buf->depth;\r
-    int size = wnd->width * wnd->height ;\r
-    LOG("INFO", LOG_LEVEL_HIGH ,"width=%d,height=%d,size=%d\n",wnd->width , wnd->height , size);\r
-    ptr = tpl_buffer_map(tpl_buf, size);\r
-    if (ptr == NULL)\r
-    {\r
-               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_map");\r
-        ret = false;\r
-        goto finish;\r
-       }\r
-\r
-    //6.write\r
-    int *p = NULL;int j=0;\r
-    if(ptr!=NULL)\r
-    {\r
-        memset(ptr,size,0xFFFF);\r
-    }\r
-    for(j = 0; j <size;j++)\r
-    {\r
-        p = (int*) ptr;\r
-        *(p+j) = 0xFF00;\r
-    }\r
-    LOG("INFO", LOG_LEVEL_LOW , "succ:write completed!");\r
-\r
-    //7.end frame\r
-    tpl_surface_end_frame(tpl_surf);\r
-\r
-    //8.set post interval\r
-    int interval_set = 2;\r
-    tpl_surface_set_post_interval(tpl_surf, interval_set);\r
-\r
-    //9. get post interval;\r
-    int interval_get = tpl_surface_get_post_interval(tpl_surf);\r
-\r
-    if(interval_get!=interval_set)\r
-    {\r
-         LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_post_interval");\r
-         ret = false;\r
-         goto finish;\r
-    }\r
-\r
-    //10.post\r
-    //for(k=0;k<1000;k++)\r
-    {\r
-        tpl_surface_post(tpl_surf);\r
-    }\r
-    LOG("INFO", LOG_LEVEL_LOW , "After posted!!!");\r
-\r
-    int k=0;\r
-    while(k<20)\r
-       {\r
-               usleep(1000*1000);\r
-               LOG("INFO", LOG_LEVEL_LOW , "sleep %d ...",k++);\r
-       }\r
-\r
-finish:\r
-    if(true == ret)\r
-        LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);\r
-    else\r
-        LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);\r
-    return ret;\r
-\r
-\r
-}\r
-\r
-\r
-bool tpl_surface_abnormal_test(TPLNativeWnd* wnd)\r
-{\r
-    TPL_CHK_PARAM( !wnd );\r
-    LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);\r
-    bool ret = true;\r
-    tpl_surface_t *tpl_surf = NULL;\r
-\r
-    //1.tpl_display_get\r
-    tpl_display_t *tpl_display = NULL;\r
-    tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);\r
-    if(tpl_display == NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-\r
-    //abnormal test\r
-    tpl_surf = NULL;\r
-    tpl_surf = tpl_surface_create(NULL, NULL, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);\r
-    tpl_surf = tpl_surface_create(tpl_display, (tpl_handle_t)wnd->wnd, 10, TPL_FORMAT_ARGB8888);\r
-    tpl_surf = tpl_surface_create(tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_INVALID);\r
-/*    if(tpl_surf != NULL)\r
-    {\r
-        LOG("ERRO", LOG_LEVEL_HIGH , "abnormal test failed:%s",__func__);\r
-        ret = false;\r
-        goto finish;\r
-    }\r
-*/\r
-    //abnormal test\r
-    int width = 0, height = 0;\r
-    tpl_surface_get_display(NULL);\r
-    tpl_surface_get_native_handle(NULL);\r
-    tpl_surface_get_type(NULL);\r
-    tpl_surface_get_size(NULL,&width,&height);\r
-    tpl_surface_get_buffer(NULL,NULL);\r
-    tpl_surface_set_post_interval(NULL, 2);\r
-    tpl_surface_get_post_interval(NULL);\r
-    tpl_surface_post(NULL);\r
-    tpl_surface_begin_frame(NULL);\r
-    tpl_surface_validate_frame(NULL);\r
-    tpl_surface_end_frame(NULL);\r
-\r
-finish:\r
-    if(true == ret)\r
-        LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);\r
-    else\r
-        LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);\r
-    return ret;\r
-}\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-#endif\r
-\r
-\r
+#ifndef __TPL_SURF_TEST__
+#define __TPL_SURF_TEST__
+
+#include "tpl_test_util.h"
+
+
+bool tpl_surface_create_test(TPLNativeWnd* wnd)
+{
+       TPL_CHK_PARAM( !wnd );
+       LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+       bool ret = true;
+       wnd->tpl_display = NULL;
+       //1.tpl_display_get
+       wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
+       if(wnd->tpl_display == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
+               ret = false;
+               goto finish;
+       }
+       //2.tpl_surface_create
+       tpl_surface_t *tpl_surf = NULL;
+       tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+       if(tpl_surf == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
+               ret = false;
+               goto finish;
+       }
+
+finish:
+       if(true == ret)
+               LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+       else
+               LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+       return ret;
+}
+
+bool tpl_surface_get_arg_test(TPLNativeWnd* wnd)
+{
+       TPL_CHK_PARAM( !wnd );
+       LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+       bool ret = true;
+       wnd->tpl_display = NULL;
+       //1.tpl_display_get
+       wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
+       if(wnd->tpl_display == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
+               ret = false;
+               goto finish;
+       }
+       //2.tpl_surface_create
+       tpl_surface_t *tpl_surf = NULL;
+       tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+       if(tpl_surf == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
+               ret = false;
+               goto finish;
+       }
+
+       //tpl_surface_get_display test
+       tpl_display_t* test_dpy = tpl_surface_get_display(tpl_surf);
+       if(test_dpy == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_display");
+               ret = false;
+               goto finish;
+       }
+       //tpl_surface_get_native_handle
+       tpl_handle_t test_handle = tpl_surface_get_native_handle(tpl_surf);
+       if(test_handle == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_native_handle");
+               ret = false;
+               goto finish;
+       }
+       //tpl_surface_get_type test
+       tpl_surface_type_t test_type = tpl_surface_get_type(tpl_surf);
+       if(test_type != TPL_SURFACE_TYPE_WINDOW)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_type");
+               ret = false;
+               goto finish;
+       }
+
+    finish:
+       if(true == ret)
+               LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+       else
+               LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+       return ret;
+}
+
+bool tpl_surface_frame_test(TPLNativeWnd* wnd)
+{
+       TPL_CHK_PARAM( !wnd );
+       LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+       bool ret = true;
+       wnd->tpl_display = NULL;
+       //1.tpl_display_get
+       wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
+       if(wnd->tpl_display == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
+               ret = false;
+               goto finish;
+       }
+       //2.tpl_surface_create
+       tpl_surface_t *tpl_surf = NULL;
+       tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+       if(tpl_surf == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
+               ret = false;
+               goto finish;
+       }
+
+       //3.begin frame
+       tpl_surface_begin_frame(tpl_surf);
+
+       //4.tpl_surface_validate_frame
+       tpl_bool_t isvalid = tpl_surface_validate_frame(tpl_surf);
+
+       //5. end frame
+       tpl_surface_end_frame(tpl_surf);
+
+
+finish:
+       if(true == ret)
+               LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+       else
+               LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+
+       return ret;
+}
+
+
+bool tpl_surface_get_buffer_test(TPLNativeWnd* wnd )
+{
+       TPL_CHK_PARAM( !wnd );
+       bool ret = true;
+       LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+
+       //1.tpl_display_get
+       wnd->tpl_display = NULL;
+       wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
+       if(wnd->tpl_display == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
+               ret = false;
+               goto finish;
+       }
+
+       //2.tpl_surface_create
+       tpl_surface_t *tpl_surf = NULL;
+       tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+       if(tpl_surf == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
+               ret = false;
+               goto finish;
+       }
+
+       //3.begin frame
+       tpl_surface_begin_frame(tpl_surf);
+
+       //4.get buffer
+       wnd->tpl_buf = NULL;
+       wnd->tpl_buf = tpl_surface_get_buffer(tpl_surf, NULL);
+       if (wnd->tpl_buf == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");
+               ret = false;
+               goto finish;
+       }
+
+       //4.get buffer reset
+       tpl_buffer_t *tpl_buf_r = NULL;
+       tpl_bool_t reset;
+       tpl_buf_r = tpl_surface_get_buffer(tpl_surf, &reset);
+       if (tpl_buf_r == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");
+               ret = false;
+               goto finish;
+       }
+
+finish:
+       if(true == ret)
+               LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+       else
+               LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+       return ret;
+
+
+}
+
+
+
+
+bool tpl_surface_post_test(TPLNativeWnd* wnd )
+{
+       TPL_CHK_PARAM( !wnd );
+       bool ret = true;
+       LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+
+       //1.tpl_display_get
+       wnd->tpl_display = NULL;
+       wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
+       if(wnd->tpl_display == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
+               ret = false;
+               goto finish;
+       }
+
+       //2.tpl_surface_create
+       tpl_surface_t *tpl_surf = NULL;
+       tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+       if(tpl_surf == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
+               ret = false;
+               goto finish;
+       }
+
+       //3.begin frame
+       tpl_surface_begin_frame(tpl_surf);
+
+       //4.get buffer
+       wnd->tpl_buf = NULL;
+       wnd->tpl_buf = tpl_surface_get_buffer(tpl_surf, NULL);
+       if (wnd->tpl_buf == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");
+               ret = false;
+               goto finish;
+       }
+
+       //5.buffer map
+       void *ptr = NULL;
+       //int size = tpl_buf->width * tpl_buf->height * tpl_buf->depth;
+       int size = wnd->width * wnd->height ;
+       LOG("INFO", LOG_LEVEL_LOW ,"width=%d,height=%d,size=%d",wnd->width , wnd->height , size);
+       ptr = tpl_buffer_map(wnd->tpl_buf, size);
+       if (ptr == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_buffer_map");
+               ret = false;
+               goto finish;
+       }
+
+       //6.write
+       int *p = NULL;int j=0;
+       for(j = 0; j <size;j++)
+       {
+               p = (int*) ptr;
+               *(p+j) = 0xFF00;
+       }
+       LOG("INFO", LOG_LEVEL_LOW , "succ:write completed!");
+
+       //7.end frame
+       tpl_surface_end_frame(tpl_surf);
+
+       //8.set post interval
+       int interval_set = 2;
+       tpl_surface_set_post_interval(tpl_surf, interval_set);
+
+       //9. get post interval;
+       int interval_get = tpl_surface_get_post_interval(tpl_surf);
+
+       if(interval_get!=interval_set)
+       {
+                LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_post_interval");
+                ret = false;
+                goto finish;
+       }
+
+       //10.post
+       tpl_surface_post(tpl_surf);
+
+       LOG("INFO", LOG_LEVEL_LOW , "After posted!!!");
+
+       int k=1;
+       while(k<=10)
+       {
+               usleep(1000*1000);
+               LOG("INFO", LOG_LEVEL_LOW , "sleep %d ...",k);
+               //printf("%d ",k);
+               k++;
+       }
+
+finish:
+       if(true == ret)
+               LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+       else
+               LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+       return ret;
+
+
+}
+
+
+bool tpl_surface_abnormal_test(TPLNativeWnd* wnd)
+{
+       TPL_CHK_PARAM( !wnd );
+       LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+       bool ret = true;
+       wnd->tpl_surf = NULL;
+
+       //1.tpl_display_get
+       wnd->tpl_display = NULL;
+       wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
+       if(wnd->tpl_display == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
+               ret = false;
+               goto finish;
+       }
+
+       //abnormal test
+       wnd->tpl_surf = NULL;
+       wnd->tpl_surf = tpl_surface_create(NULL, NULL, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+       wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, 10, TPL_FORMAT_ARGB8888);
+       wnd->tpl_surf = tpl_surface_create(wnd->tpl_display, (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_INVALID);
+    /*   if(tpl_surf != NULL)
+       {
+           LOG("ERRO", LOG_LEVEL_HIGH , "abnormal test failed:%s",__func__);
+           ret = false;
+           goto finish;
+       }
+    */
+       //abnormal test
+       int width = 0, height = 0;
+       tpl_surface_get_display(NULL);
+       tpl_surface_get_native_handle(NULL);
+       tpl_surface_get_type(NULL);
+       tpl_surface_get_size(NULL,&width,&height);
+       tpl_surface_get_buffer(NULL,NULL);
+       tpl_surface_set_post_interval(NULL, 2);
+       tpl_surface_get_post_interval(NULL);
+       tpl_surface_post(NULL);
+       tpl_surface_begin_frame(NULL);
+       tpl_surface_validate_frame(NULL);
+       tpl_surface_end_frame(NULL);
+
+    finish:
+       if(true == ret)
+               LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+       else
+               LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+       return ret;
+}
+
+
+
+bool tpl_surface_stress_test(TPLNativeWnd* wnd )
+{
+       TPL_CHK_PARAM( !wnd );
+       bool ret = true;
+       int index = 0;
+       LOG("INFO", LOG_LEVEL_LOW , "-------begin:%s-------",__func__);
+
+       //1.tpl_display _get
+       wnd->tpl_display = NULL;
+       wnd->tpl_display = tpl_display_get(TPL_BACKEND_WAYLAND, (tpl_handle_t)wnd->dpy);
+       if(wnd->tpl_display == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_display_get");
+               ret = false;
+               goto finish;
+       }
+
+       //2.tpl_surface_create
+       wnd->tpl_surf = NULL;
+       wnd->tpl_surf = tpl_surface_create(wnd->tpl_display , (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+       if(wnd->tpl_surf == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
+               ret = false;
+               goto finish;
+       }
+
+       //3.begin frame
+       tpl_surface_begin_frame(wnd->tpl_surf);
+
+       //4.get buffer
+       wnd->tpl_buf = NULL;
+       wnd->tpl_buf = tpl_surface_get_buffer(wnd->tpl_surf, NULL);
+       if (wnd->tpl_buf == NULL)
+       {
+               LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");
+               ret = false;
+               goto finish;
+       }
+
+       tpl_buffer_t *surf_array[STRESS_NUM]={0};
+       tpl_buffer_t *buf_array[STRESS_NUM]={0};
+       for(index = 0;index<STRESS_NUM;index++)
+       {
+               surf_array[index] = tpl_surface_create(wnd->tpl_display , (tpl_handle_t)wnd->wnd, TPL_SURFACE_TYPE_WINDOW, TPL_FORMAT_ARGB8888);
+               if(wnd->tpl_surf == NULL)
+               {
+                       LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_create");
+                       ret = false;
+                       goto finish;
+               }
+
+               buf_array[index] = tpl_surface_get_buffer(wnd->tpl_surf, NULL);
+               if (buf_array[index] == NULL)
+               {
+                       LOG("ERRO", LOG_LEVEL_HIGH , "failed:tpl_surface_get_buffer");
+                       ret = false;
+                       goto finish;
+               }
+       }
+
+
+finish:
+       for(index = 0;index<STRESS_NUM;index++)
+       {
+               if (surf_array[index] != NULL)
+               {
+                       tpl_object_unreference((tpl_object_t*)surf_array[index]);
+                       surf_array[index] = NULL;
+               }
+
+       }
+       if(true == ret)
+               LOG("PASS", LOG_LEVEL_HIGH , "Pass:%s",__func__);
+       else
+               LOG("FAIL", LOG_LEVEL_HIGH , "Failed:%s",__func__);
+
+       return ret;
+
+}
+
+#endif
+
+
index 0a41d34..b58f703 100644 (file)
 #include <tpl.h>
 //#include <tpl_internal.h>
 
-
+#define STRESS_NUM   100
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-typedef struct _TPLNativeWnd   TPLNativeWnd;
-//typedef struct _GfxEgl                       GfxEgl;
+typedef struct _TPLNativeWnd TPLNativeWnd;
+
 
 struct _TPLNativeWnd
 {
-//     EGLNativeDisplayType    dpy;
-    void* dpy;
+       void* dpy;
        struct wl_registry *registry;
        struct wl_compositor *compositor;
-        struct wl_shell *shell;
-       int             screen;
-//     EGLNativeWindowType             root;
-//     EGLNativeWindowType             wnd;
-    void* root;
-    void* wnd;
+       struct wl_shell *shell;
+       int screen;
+
+       void* root;
+       void* wnd;
        struct wl_surface *surface;
        struct wl_shell_surface *shell_surface;
-       int                                             x;
-       int                                             y;
-       int                                             width;
-       int                                             height;
-       int                                             depth;
+       int x;
+       int y;
+       int width;
+       int height;
+       int depth;
+       tpl_display_t * tpl_display;
+       tpl_surface_t * tpl_surf;
+       tpl_buffer_t * tpl_buf;
 };
 
 typedef struct _TPLTest TPLTest;
@@ -57,22 +58,22 @@ struct _TPLTest
        bool (*run) (TPLNativeWnd*);
 };
 
-
-#define minLevel        1
-#define LOG_LEVEL_LOW   1
-#define LOG_LEVEL_MID   2
-#define LOG_LEVEL_HIGH  3
+extern int tpl_test_log_level;
+#define minLevel tpl_test_log_level
+#define LOG_LEVEL_LOW 1
+#define LOG_LEVEL_MID 2
+#define LOG_LEVEL_HIGH 3
 
 #define LOG(type,level, format, ...) \
     do { \
        if(level>=minLevel) fprintf(stderr, "[%s|%22s:%3d] " format "\n", \
-            type, __FILE__, __LINE__, ##__VA_ARGS__ ); \
+               type, __FILE__, __LINE__, ##__VA_ARGS__ ); \
     } while (0)
 
 #define LONGLOG(type,level, format, ...) \
     do { \
        if(level>=minLevel) fprintf(stderr, "[%s|%s@%s:%d] " format "\n", \
-            type, __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \
+               type, __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \
     } while (0)
 
 
@@ -105,68 +106,60 @@ bool tpl_object_abnormal_test(TPLNativeWnd* wnd);
 bool tpl_display_abnormal_test(TPLNativeWnd* wnd);
 bool tpl_buffer_abnormal_test(TPLNativeWnd* wnd);
 
-
+bool tpl_surface_stress_test(TPLNativeWnd* wnd );
+bool tpl_buffer_stress_test(TPLNativeWnd* wnd );
 
 static TPLTest tpl_test[] =
 {
-       { "Check TPL buffer map and unmap",                                                     tpl_buffer_map_unmap_test },
-       { "Check TPL buffer lock and unlock",                                           tpl_buffer_lock_unlock_test },
-       { "Check TPL buffer get args",                                      tpl_buffer_get_arg_test },
-       { "TPL buffer create native buffer test",                                       tpl_buffer_create_native_buffer_test },
-
-       { "TPL display get test",                               tpl_display_get_test },
-       { "Check TPL display bind client display",                                              tpl_display_bind_client_display_test },/*5*/
-       { "Check TPL display get args",                         tpl_display_get_arg_test },
-       { "TPL display query config test",                                              tpl_display_query_config_test },
-       { "TPL display filter config test",                     tpl_display_filter_config_test },
-
-       { "Check TPL object get types",                                 tpl_object_get_type_test },
-       { "Check TPL object set and get userdate",                      tpl_object_userdata_test },
-       { "Check TPL object reference and unreference",                                 tpl_object_reference_test },
-
-       { "Check TPL surface create",   tpl_surface_create_test },
-       { "Check TPL surface get args",                 tpl_surface_get_arg_test },
-       { "Check TPL surface frame operation" ,             tpl_surface_frame_test },
-       { "TPL surface get buffer test",                                                        tpl_surface_get_buffer_test },/*15*/
-       { "TPL surface post test",                                                              tpl_surface_post_test },
+       { "Check TPL buffer map and unmap", tpl_buffer_map_unmap_test },
+       { "Check TPL buffer lock and unlock",  tpl_buffer_lock_unlock_test },
+       { "Check TPL buffer get args",        tpl_buffer_get_arg_test },
+       { "TPL buffer create native buffer test",tpl_buffer_create_native_buffer_test },
+       { "TPL buffer stress test",tpl_buffer_stress_test },
+
+       { "TPL display get test",tpl_display_get_test },
+       //{ "Check TPL display bind client display",tpl_display_bind_client_display_test },/*5*/
+       { "Check TPL display get args",tpl_display_get_arg_test },
+       { "TPL display query config test",tpl_display_query_config_test },
+       { "TPL display filter config test",tpl_display_filter_config_test },
+
+       { "Check TPL object get types",tpl_object_get_type_test },
+       { "Check TPL object set and get userdate",tpl_object_userdata_test },
+       { "Check TPL object reference and unreference",tpl_object_reference_test },
+
+       { "Check TPL surface create",tpl_surface_create_test },
+       { "Check TPL surface get args",tpl_surface_get_arg_test },
+       { "Check TPL surface frame operation" ,  tpl_surface_frame_test },
+       { "TPL surface get buffer test",tpl_surface_get_buffer_test },/*15*/
+       { "TPL surface post test",tpl_surface_post_test },
+       { "TPL surface stress test",tpl_surface_stress_test },
 /*
-       { "TPL surface abnormal test",                                                                  tpl_surface_abnormal_test },
-       { "TPL object abnormal test",                                                           tpl_object_abnormal_test },
-       { "TPL display abnormal test",  tpl_display_abnormal_test },
-       { "TPL buffer abnormal test",   tpl_buffer_abnormal_test },
+       { "TPL surface abnormal test",tpl_surface_abnormal_test },
+       { "TPL object abnormal test",tpl_object_abnormal_test },
+       { "TPL display abnormal test",tpl_display_abnormal_test },
+       { "TPL buffer abnormal test",tpl_buffer_abnormal_test },
 */
-
        { NULL, NULL }
 
 };
 
-
-
-
-
-
-#define TPL_RESOURCE_BIN_SHADER_VTX_01  "data/01_vtx.bin"
+#define TPL_RESOURCE_BIN_SHADER_VTX_01 "data/01_vtx.bin"
 #define TPL_RESOURCE_BIN_SHADER_FRAG_01 "data/01_frag.bin"
-#define TPL_RESOURCE_BIN_PROGRAM_01     "data/01_program.bin"
+#define TPL_RESOURCE_BIN_PROGRAM_01 "data/01_program.bin"
 #define TPL_RESOURCE_TGA_UNCOMP_FILE_01 "data/sample_01_uncomp.tga"
-#define TPL_RESOURCE_TGA_COMP_FILE_02   "data/sample_02_comp.tga"
-/*
-# ifndef __BOOLEAN_TYPE
-#  define __BOOLEAN_TYPE
-    typedef enum { false, true } bool;
-# endif
-*/
+#define TPL_RESOURCE_TGA_COMP_FILE_02 "data/sample_02_comp.tga"
+
 
 /*-----------------------------------------------------------------
  * time
  *-----------------------------------------------------------------*/
 #define HAVE_MONOTONIC_CLOCK 1
-#define                __SEC_TO_USEC( sec )    ((sec) * 1000000)
-#define                __USEC_TO_SEC( usec )   ((float)(usec) * 1.0e-6f)
-#define                __MSEC_TO_SEC( usec )   ((float)(usec) * 1.0e-3f)
-long int       tpl_test_util_get_systime( void );
-void           tpl_test_util_init_fps( long int* s_time );
-float          tpl_test_util_get_fps( long int s_time, int frame );
+#define __SEC_TO_USEC( sec ) ((sec) * 1000000)
+#define __USEC_TO_SEC( usec ) ((float)(usec) * 1.0e-6f)
+#define __MSEC_TO_SEC( usec ) ((float)(usec) * 1.0e-3f)
+long int tpl_test_util_get_systime( void );
+void tpl_test_util_init_fps( long int* s_time );
+float tpl_test_util_get_fps( long int s_time, int frame );
 
 /*-----------------------------------------------------------------
  * performance measurement
@@ -181,30 +174,22 @@ typedef struct _GfxUtilTimer GfxUtilTimer;
 #define USE_GETTIME 1
 struct _GfxUtilTimer
 {
-       bool                    is_begin;
-       bool                    is_measured;
-       char                    func[1024];
-       int                             line;
-       char                    msg[1024];
+       bool is_begin;
+       bool is_measured;
+       char func[1024];
+       int line;
+       char msg[1024];
 #if USE_GETTIME
-       long int                begin_t;
-       long int                end_t;
+       long int begin_t;
+       long int end_t;
 #else
-       clock_t                 begin_tiks;
-       clock_t                 end_tiks;
-       struct tms              begin_buf;
-       struct tms              end_buf;
+       clock_t begin_tiks;
+       clock_t end_tiks;
+       struct tms begin_buf;
+       struct tms end_buf;
 #endif
 };
 
-//////egl related begin/////////////////////////
-//#define EGL_KHR_image 1
-//#define EGL_SEC_client_pixmap 0
-//#define GL_OES_EGL_image 1
-
-
-
-
 # define __TPL_TIMER_GLOBAL_BEGIN( timer, msg ) \
        tpl_test_util_timer_begin( timer, __func__, __LINE__, msg );
 # define __TPL_TIMER_GLOBAL_END( timer, msg ) \
@@ -216,20 +201,19 @@ struct _GfxUtilTimer
 # define __TPL_TIMER_END( msg ) \
        tpl_test_util_timer_end( &__timer, __func__, __LINE__, msg );
 
-void                   tpl_test_util_timer_list_display( void );
-void                   tpl_test_util_timer_release( GfxUtilTimer* timer );
+void           tpl_test_util_timer_list_display( void );
+void           tpl_test_util_timer_release( GfxUtilTimer* timer );
 GfxUtilTimer*  tpl_test_util_timer_copy( GfxUtilTimer* src, const char* func, int line, const char* msg );
-void                   tpl_test_util_timer_list_clear( void );
-
-void                   tpl_test_util_timer_begin( GfxUtilTimer* timer, const char* func, int line, const char* msg );
-void                   tpl_test_util_timer_end( GfxUtilTimer* timer, const char* func, int line, const char* msg );
+void           tpl_test_util_timer_list_clear( void );
+void           tpl_test_util_timer_begin( GfxUtilTimer* timer, const char* func, int line, const char* msg );
+void           tpl_test_util_timer_end( GfxUtilTimer* timer, const char* func, int line, const char* msg );
 #else
-# define __TPL_TIMER_GLOBAL_BEGIN( ... )       { ; }
-# define __TPL_TIMER_GLOBAL_END( ... )         { ; }
-# define __TPL_TIMER_BEGIN( ... )                      { ; }
-# define __TPL_TIMER_END( ... )                                { ; }
-# define tpl_test_util_timer_list_display( ... )       { ; }
-# define tpl_test_util_timer_list_clear( ... ) { ; }
+# define __TPL_TIMER_GLOBAL_BEGIN( ... ) { ; }
+# define __TPL_TIMER_GLOBAL_END( ... ) { ; }
+# define __TPL_TIMER_BEGIN( ... ) { ; }
+# define __TPL_TIMER_END( ... ) { ; }
+# define tpl_test_util_timer_list_display( ... ) { ; }
+# define tpl_test_util_timer_list_clear( ... ) { ; }
 #endif
 
 
@@ -242,22 +226,22 @@ void                      tpl_test_util_timer_end( GfxUtilTimer* timer, const char* func, int line,
 
 
 
-#define NUM_ERR_STR            512     /* length of the error logging string */
-#define DEFAULT_LOG_STREAM     stderr
+#define NUM_ERR_STR 512 /* length of the error logging string */
+#define DEFAULT_LOG_STREAM stderr
 
 #define __log_err(fmt, args...) __LOG_ERR(__func__, __LINE__, fmt, ##args)
-bool   __LOG_ERR( const char* func, int line, const char* fmt, ... );
-bool   __tpl_test_log_display_msg( const char* msg );
+bool __LOG_ERR( const char* func, int line, const char* fmt, ... );
+bool __tpl_test_log_display_msg( const char* msg );
 
 
 
 #if TPL_ENABLE_LOG
-# define __log(fmt, args...)   __LOG(__func__, __LINE__, fmt, ##args)
-# define __log_begin( ... )            __LOG_BEGIN(__func__);
-# define __log_end( ... )              __LOG_END(__func__);
-bool   __LOG( const char* func, int line, const char* fmt, ... );
-void   __LOG_BEGIN( const char* func );
-void   __LOG_END( const char* func );
+# define __log(fmt, args...) __LOG(__func__, __LINE__, fmt, ##args)
+# define __log_begin( ... ) __LOG_BEGIN(__func__);
+# define __log_end( ... ) __LOG_END(__func__);
+bool __LOG( const char* func, int line, const char* fmt, ... );
+void __LOG_BEGIN( const char* func );
+void __LOG_END( const char* func );
 #else
 # define __log( ... ) { ; }
 # define __log_begin( ... ) { ; }