#include "src/tpl-test_base.h"
-class TPLDisplay : public TPLTestBase {};
-class TPLDisplaySupport : public TPLDisplay {};
+typedef TPLTestBase DEFAULT_tpl_display_get;
-
-// Tests tpl_display_get(tpl_handle_t)
-TEST_F(TPLDisplay, tpl_display_get)
+TEST_F(DEFAULT_tpl_display_get, success)
{
tpl_display_t *tpl_display = tpl_display_get(backend->display_handle);
- ASSERT_EQ(tpl_display, backend->tpl_display);
+ ASSERT_EQ(backend->tpl_display, tpl_display);
+}
+
+TEST_F(DEFAULT_tpl_display_get, failure_null)
+{
+ tpl_display_t *tpl_display = tpl_display_get(NULL);
+
+ ASSERT_EQ((void *)NULL, tpl_display);
}
-// Tests tpl_display_get_native_handle(tpl_handle_t)
-TEST_F(TPLDisplay, tpl_display_get_native_handle)
+typedef TPLTestBase DEFAULT_tpl_display_get_native_handle;
+
+TEST_F(DEFAULT_tpl_display_get_native_handle, success)
{
tpl_handle_t display_handle =
tpl_display_get_native_handle(backend->tpl_display);
- ASSERT_EQ(display_handle, backend->display_handle);
+ ASSERT_EQ(backend->display_handle, display_handle);
}
+TEST_F(DEFAULT_tpl_display_get_native_handle, failure_invalid_display)
+{
+ tpl_handle_t display_handle =
+ tpl_display_get_native_handle(NULL);
-// Tests tpl_display_query_config(...)
-//
-// 1. Tests with normal cases
-// 2. Tests with abnormal case
-TEST_F(TPLDisplay, tpl_display_query_config)
+ ASSERT_EQ((void *)NULL, display_handle);
+}
+
+
+typedef TPLTestBase DEFAULT_tpl_display_query_config;
+
+TEST_F(DEFAULT_tpl_display_query_config, success_1)
{
tpl_result_t result;
NULL);
ASSERT_EQ(TPL_ERROR_NONE, result);
+}
+
+TEST_F(DEFAULT_tpl_display_query_config, success_2)
+{
+ tpl_result_t result;
// #2: Normal case
// Expected Value: TPL_ERROR_NONE
NULL);
ASSERT_EQ(TPL_ERROR_NONE, result);
+}
+
+TEST_F(DEFAULT_tpl_display_query_config, failure_invalid_parameter_R)
+{
+ tpl_result_t result;
// #3: Abnormal case
// Expected Value: not TPL_ERROR_NONE
}
-// Tests tpl_display_filter_config(...)
-TEST_F(TPLDisplay, tpl_display_filter_config)
+typedef TPLTestBase DEFAULT_tpl_display_filter_config;
+
+TEST_F(DEFAULT_tpl_display_filter_config, success)
{
tpl_result_t result;
int test_visual_id = GBM_FORMAT_ARGB8888;
result = tpl_display_filter_config(backend->tpl_display,
- &test_visual_id, 0);
+ &test_visual_id, 0);
- // Expected Value: TPL_ERROR_NONE
ASSERT_EQ(TPL_ERROR_NONE, result);
}
+TEST_F(DEFAULT_tpl_display_filter_config, failure_invalid_display)
+{
+ tpl_result_t result;
+ int test_visual_id = GBM_FORMAT_ARGB8888;
+ result = tpl_display_filter_config(NULL, &test_visual_id, 0);
+
+ ASSERT_EQ(TPL_ERROR_INVALID_PARAMETER, result);
+}
-// Tests tpl_display_get_native_window_info(...)
-TEST_F(TPLDisplay, tpl_display_get_native_window_info)
+
+typedef TPLTestBase DEFAULT_tpl_display_get_native_window_info;
+
+TEST_F(DEFAULT_tpl_display_get_native_window_info, success)
{
tpl_result_t result;
int width, height;
tbm_format format;
result = tpl_display_get_native_window_info(backend->tpl_display,
- backend->surface_handle, &width, &height, &format,
- config.depth, 8);
+ backend->surface_handle,
+ &width, &height, &format,
+ config.depth, 8);
EXPECT_EQ(config.width, width);
EXPECT_EQ(config.height, height);
ASSERT_EQ(TPL_ERROR_NONE, result);
}
+/* TODO: Make test - DEFAULT_tpl_display_get_native_window_info, failure */
+
+typedef TPLTestBase
+EXTRA_tpl_display_query_supported_buffer_count_from_native_window;
-TEST_F(TPLDisplaySupport,
- tpl_display_query_supported_buffer_count_from_native_window)
+TEST_F(EXTRA_tpl_display_query_supported_buffer_count_from_native_window,
+ success)
{
tpl_result_t result;
int min, max;
result = tpl_display_query_supported_buffer_count_from_native_window(
- backend->tpl_display, backend->surface_handle,
- &min, &max);
+ backend->tpl_display, backend->surface_handle, &min, &max);
// SUCCEED() if backend does not support operation
if (result == TPL_ERROR_INVALID_OPERATION) {
#include "src/tpl-test_base.h"
-class TPLObject : public TPLTestBase {};
+typedef TPLTestBase DEFAULT_tpl_object_get_type;
-
-// Tests tpl_object_get_type(tpl_object_t *)
-TEST_F(TPLObject, tpl_object_get_type)
+TEST_F(DEFAULT_tpl_object_get_type, success_get_tpl_display)
{
int obj_type = -1;
obj_type = tpl_object_get_type((tpl_object_t *)backend->tpl_display);
ASSERT_EQ(TPL_OBJECT_DISPLAY, obj_type);
+}
- obj_type = -1;
+TEST_F(DEFAULT_tpl_object_get_type, success_get_tpl_surfcae)
+{
+ int obj_type = -1;
obj_type = tpl_object_get_type((tpl_object_t *)backend->tpl_surface);
ASSERT_EQ(TPL_OBJECT_SURFACE, obj_type);
}
+TEST_F(DEFAULT_tpl_object_get_type, failure_invalid_object)
+{
+ int obj_type = -1;
+ obj_type = tpl_object_get_type(NULL);
+ ASSERT_EQ(TPL_OBJECT_ERROR, obj_type);
+}
+
+
+typedef TPLTestBase DEFAULT_tpl_object_set_get_user_data;
// Tests setting user data flow:
// 1. Set user data
// 2. Get user data
-TEST_F(TPLObject, tpl_object_userdata_test)
+TEST_F(DEFAULT_tpl_object_set_get_user_data, success_set_get)
+{
+ unsigned long key;
+
+ // set user data
+ tpl_object_set_user_data((tpl_object_t *)backend->tpl_display, &key,
+ (void *)backend->display_handle, NULL);
+
+ // get user data
+ void *get_dpy = NULL;
+ get_dpy = (void *)tpl_object_get_user_data(
+ (tpl_object_t *)backend->tpl_display, &key);
+
+ ASSERT_EQ((void *)backend->display_handle, get_dpy);
+}
+
+TEST_F(DEFAULT_tpl_object_set_get_user_data, failure_set_invalid_object)
+{
+ unsigned long key;
+ int result;
+
+ // set user data
+ result = tpl_object_set_user_data(NULL, &key,
+ (void *)backend->display_handle, NULL);
+
+ ASSERT_EQ(TPL_ERROR_INVALID_PARAMETER, result);
+}
+
+TEST_F(DEFAULT_tpl_object_set_get_user_data, failure_get_invalid_object)
+{
+ unsigned long key;
+
+ // get user data
+ void *get_dpy = NULL;
+ get_dpy = (void *)tpl_object_get_user_data(NULL, &key);
+
+ ASSERT_EQ(NULL, get_dpy);
+}
+
+TEST_F(DEFAULT_tpl_object_set_get_user_data, failure_get_invalid_key)
{
unsigned long key;
- // TODO: Check
// set user data
tpl_object_set_user_data((tpl_object_t *)backend->tpl_display, &key,
(void *)backend->display_handle, NULL);
+ unsigned long invalid_key;
+
// get user data
void *get_dpy = NULL;
get_dpy = (void *)tpl_object_get_user_data(
- (tpl_object_t *)backend->tpl_display, &key);
+ (tpl_object_t *)backend->tpl_display, &invalid_key);
- ASSERT_EQ(get_dpy, (void *)backend->display_handle);
+ ASSERT_EQ(NULL, get_dpy);
}
+
+typedef TPLTestBase DEFAULT_tpl_object_reference;
+
// Tests object reference flow:
// 1. Reference
// 2. Unreference
-TEST_F(TPLObject, tpl_object_reference)
+TEST_F(DEFAULT_tpl_object_reference, ref_unref)
{
// tpl_object_reference
tpl_object_reference((tpl_object_t *)backend->tpl_display);
ASSERT_EQ(ref_count - 1, unref_count);
}
+TEST_F(DEFAULT_tpl_object_reference, failure_ref_invalid_object)
+{
+ int result;
+ result = tpl_object_reference(NULL);
+
+ ASSERT_EQ(-1, result);
+}
+
+TEST_F(DEFAULT_tpl_object_reference, failure_unref_invalid_object)
+{
+ int result;
+ result = tpl_object_reference(NULL);
+
+ ASSERT_EQ(-1, result);
+}
+
+TEST_F(DEFAULT_tpl_object_reference, failure_get_ref_invalid_object)
+{
+ int result;
+ result = tpl_object_get_reference(NULL);
+
+ ASSERT_EQ(-1, result);
+}
+
#include "src/tpl-test_base.h"
-class TPLSurface : public TPLTestBase {};
-class TPLSurfaceSupport : public TPLSurface {};
+typedef TPLTestBase DEFAULT_tpl_surface_validate;
-
-// Tests tpl_surface_validate(tpl_surface_t *)
-TEST_F(TPLSurface, tpl_surface_validate)
+TEST_F(DEFAULT_tpl_surface_validate, success)
{
tpl_bool_t result = tpl_surface_validate(backend->tpl_surface);
- // Expected Value: TPL_TRUE
ASSERT_EQ(TPL_TRUE, result);
}
+TEST_F(DEFAULT_tpl_surface_validate, failure_invalid_surface)
+{
+ tpl_bool_t result = tpl_surface_validate(NULL);
+
+ ASSERT_EQ(TPL_FALSE, result);
+}
+
+
+typedef TPLTestBase DEFAULT_tpl_surface_get_display;
-TEST_F(TPLSurface, tpl_surface_get_args)
+TEST_F(DEFAULT_tpl_surface_get_display, success)
{
// tpl_surface_get_display test
tpl_display_t *test_dpy = tpl_surface_get_display(backend->tpl_surface);
- ASSERT_EQ(test_dpy, backend->tpl_display);
+ ASSERT_EQ(backend->tpl_display, test_dpy);
+}
+
+TEST_F(DEFAULT_tpl_surface_get_display, failure_invalid_surface)
+{
+ // tpl_surface_get_display test
+ tpl_display_t *test_dpy = tpl_surface_get_display(NULL);
+
+ ASSERT_EQ((void *)NULL, test_dpy);
+}
+
+
+typedef TPLTestBase DEFAULT_tpl_surface_get_native_handle;
+
+TEST_F(DEFAULT_tpl_surface_get_native_handle, success)
+{
// tpl_surface_get_native_handle
tpl_handle_t test_handle =
tpl_surface_get_native_handle(backend->tpl_surface);
- ASSERT_EQ(test_handle, backend->surface_handle);
+ ASSERT_EQ(backend->surface_handle, test_handle);
+}
+
+TEST_F(DEFAULT_tpl_surface_get_native_handle, failure_invalid_surface)
+{
+ // tpl_surface_get_native_handle
+ tpl_handle_t test_handle = tpl_surface_get_native_handle(NULL);
+
+ ASSERT_EQ((void *)NULL, test_handle);
+}
+
+
+typedef TPLTestBase DEFAULT_tpl_surface_get_type;
+
+TEST_F(DEFAULT_tpl_surface_get_type, success)
+{
// tpl_surface_get_type test
tpl_surface_type_t test_type = tpl_surface_get_type(backend->tpl_surface);
ASSERT_EQ(TPL_SURFACE_TYPE_WINDOW, test_type);
+}
+TEST_F(DEFAULT_tpl_surface_get_type, failure_invalid_surface)
+{
+ // tpl_surface_get_type test
+ tpl_surface_type_t test_type = tpl_surface_get_type(NULL);
+ ASSERT_EQ(TPL_SURFACE_ERROR, test_type);
+}
+
+
+typedef TPLTestBase DEFAULT_tpl_surface_get_size;
+
+TEST_F(DEFAULT_tpl_surface_get_size, success)
+{
// tpl_surface_get_size test
int width, height;
tpl_result_t test_size =
tpl_surface_get_size(backend->tpl_surface, &width, &height);
+ ASSERT_EQ(TPL_ERROR_NONE, test_size);
+
EXPECT_EQ(config.width, width);
EXPECT_EQ(config.height, height);
- ASSERT_EQ(TPL_ERROR_NONE, test_size);
}
+TEST_F(DEFAULT_tpl_surface_get_size, failure_invalid_surface)
+{
+ int width, height;
+ tpl_result_t test_size =
+ tpl_surface_get_size(NULL, &width, &height);
+
+ ASSERT_EQ(TPL_ERROR_INVALID_PARAMETER, test_size);
+}
+
+
+typedef TPLTestBase DEFAULT_tpl_surface_dequeue_enqueue;
// Tests simple normal buffer flow:
// 1. Dequeue buffer by calling tpl_surface_dequeue_buffer
// 2. Set post interval
// 3. Enqueue buffer by calling tpl_surface_enqueue_buffer
-TEST_F(TPLSurface, tpl_surface_dequeue_and_enqueue_buffer_test)
+TEST_F(DEFAULT_tpl_surface_dequeue_enqueue, deq_enq)
{
// dequeue
tbm_surface_h tbm_surf = NULL;
}
-TEST_F(TPLSurfaceSupport, tpl_surface_create_get_destroy_swapchain_test)
+typedef TPLTestBase EXTRA_tpl_surface_swapchain;
+
+TEST_F(EXTRA_tpl_surface_swapchain, success)
{
int buffer_set = 2;
tpl_result_t result;
// Create swapchain
result = tpl_surface_create_swapchain(backend->tpl_surface,
- TBM_FORMAT_ARGB8888, config.width, config.height, buffer_set,
- TPL_DISPLAY_PRESENT_MODE_IMMEDIATE);
+ TBM_FORMAT_ARGB8888,
+ config.width, config.height,
+ buffer_set,
+ TPL_DISPLAY_PRESENT_MODE_IMMEDIATE);
// SUCCEED() if backend does not support operation
if (result == TPL_ERROR_INVALID_OPERATION) {
ASSERT_EQ(TPL_ERROR_NONE, result);
- tbm_surface_h **buffers;
+ tbm_surface_h **buffers = NULL;
int buffer_get;
// Get swapchain buffers
result = tpl_surface_get_swapchain_buffers(backend->tpl_surface,
- buffers, &buffer_get);
+ buffers, &buffer_get);
EXPECT_EQ(buffer_set, buffer_get);
ASSERT_EQ(TPL_ERROR_NONE, result);