add libds-tizen-allocator-tbm tests 46/278246/1
authorSooChan Lim <sc1.lim@samsung.com>
Thu, 7 Jul 2022 23:11:23 +0000 (08:11 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Mon, 18 Jul 2022 05:59:21 +0000 (14:59 +0900)
Change-Id: I305f0b527ff2b2408f7ce5017cfa8f5107d057fb

meson.build
packaging/libds-tizen.spec
tests/meson.build [new file with mode: 0644]
tests/tc_allocator_tbm.cpp [new file with mode: 0644]

index dfe8129..d6804fe 100644 (file)
@@ -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'
   ]
 )
index 0ac145b..c5e0623 100644 (file)
@@ -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 (file)
index 0000000..1d8158c
--- /dev/null
@@ -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 (file)
index 0000000..678ad88
--- /dev/null
@@ -0,0 +1,49 @@
+#include "tc_main.h"
+#include <libds-tizen/allocator/tbm.h>
+#include <drm_fourcc.h>
+
+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);
+}