From 81cb74f424ed1877183b71640bd65e2ce30bd10b Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 8 Jul 2022 08:11:23 +0900 Subject: [PATCH] add libds-tizen-allocator-tbm tests Change-Id: I305f0b527ff2b2408f7ce5017cfa8f5107d057fb --- meson.build | 5 +++-- packaging/libds-tizen.spec | 1 + tests/meson.build | 21 ++++++++++++++++++++ tests/tc_allocator_tbm.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 tests/meson.build create mode 100644 tests/tc_allocator_tbm.cpp diff --git a/meson.build b/meson.build index dfe8129..d6804fe 100644 --- a/meson.build +++ b/meson.build @@ -1,9 +1,10 @@ -project('libds_tizen', 'c', +project('libds_tizen', + ['c', 'cpp'], license: 'MIT', version: '0.1.2', default_options: [ 'warning_level=1', - 'c_std=gnu99', + 'c_std=gnu99', 'cpp_std=c++20', 'buildtype=debug' ] ) diff --git a/packaging/libds-tizen.spec b/packaging/libds-tizen.spec index 0ac145b..c5e0623 100644 --- a/packaging/libds-tizen.spec +++ b/packaging/libds-tizen.spec @@ -152,6 +152,7 @@ ninja -C builddir install %{_includedir}/libds-tizen/allocator/tbm.h %{_libdir}/pkgconfig/libds-tizen-allocator-tbm.pc %{_libdir}/libds-tizen-allocator-tbm.so +%{_bindir}/libds-tizen-allocator-tbm-tests %files backend-tdm %manifest %{name}.manifest diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 0000000..1d8158c --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,21 @@ +deps_test_common = [ + deps_libds_tizen, + dependency('gmock', required: true), + dependency('wayland-client', required: true), +] + +tc_allocator_tbm_files = [ + 'tc_main.cpp', + 'tc_allocator_tbm.cpp', +] + +executable('libds-tizen-allocator-tbm-tests', + tc_allocator_tbm_files, + dependencies: [ + deps_test_common, + deps_libds_tizen_allocator_tbm, + dependency('libdrm', required: true), + ], + install_dir: libds_tizen_bindir, + install : true +) diff --git a/tests/tc_allocator_tbm.cpp b/tests/tc_allocator_tbm.cpp new file mode 100644 index 0000000..678ad88 --- /dev/null +++ b/tests/tc_allocator_tbm.cpp @@ -0,0 +1,49 @@ +#include "tc_main.h" +#include +#include + +class AllocatorTbmTest : public ::testing::Test +{ + public: + void SetUp(void) override; + void TearDown(void) override; +}; + +void +AllocatorTbmTest::SetUp(void) +{ +} + +void +AllocatorTbmTest::TearDown(void) +{ +} + +TEST_F(AllocatorTbmTest, Create_P) +{ + struct ds_allocator *allocator; + + allocator = ds_tbm_allocator_create(); + EXPECT_TRUE(allocator != NULL); + + ds_allocator_destroy(allocator); +} + +TEST_F(AllocatorTbmTest, GetSurface_P) +{ + struct ds_allocator *allocator; + struct ds_buffer *buffer; + void *tbm_buffer; + + allocator = ds_tbm_allocator_create(); + EXPECT_TRUE(allocator != NULL); + + buffer = + ds_allocator_create_buffer(allocator, 100, 100, DRM_FORMAT_XRGB8888); + EXPECT_TRUE(buffer != NULL); + + tbm_buffer = ds_tbm_buffer_get_surface(buffer); + EXPECT_TRUE(tbm_buffer != NULL); + + ds_allocator_destroy(allocator); +} -- 2.7.4