summaryrefslogtreecommitdiff
path: root/ivi-layermanagement-api/test/ilm_control_notification_test.cpp
diff options
context:
space:
mode:
authorEugen Friedrich <efriedrich@de.adit-jv.com>2023-04-28 09:15:24 +0200
committerEugen Friedrich <efriedrich@de.adit-jv.com>2023-04-28 09:15:24 +0200
commit6405590f6a8786b986e1cf153e369bc3791f067a (patch)
treebe399ddd26f01fe938e723c1fe4a891f49178fd5 /ivi-layermanagement-api/test/ilm_control_notification_test.cpp
parente8cef46a8339e3f930a5bd436a3807ffa8889d4f (diff)
parentd65adaebc70cd36da3878c44980fcd99d24c9b6c (diff)
downloadwayland-ivi-extension-6405590f6a8786b986e1cf153e369bc3791f067a.tar.gz
Merge remote-tracking branch 'upstream/pull/149'
* upstream/pull/149 tests: create tests for new screenshot functions with callbacks ilmControl: Extend screenshot API with callback support Reviewed-by: Eugen Friedrich <efriedrich@de.adit-jv.com> Reviewed-by: Harsha M M <harsha.manjulamallikarjun@in.bosch.com> Tested-by: Doan Ngoc Au <au.doanngoc@vn.bosch.com>
Diffstat (limited to 'ivi-layermanagement-api/test/ilm_control_notification_test.cpp')
-rw-r--r--ivi-layermanagement-api/test/ilm_control_notification_test.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/ivi-layermanagement-api/test/ilm_control_notification_test.cpp b/ivi-layermanagement-api/test/ilm_control_notification_test.cpp
index 2638a03..b918e42 100644
--- a/ivi-layermanagement-api/test/ilm_control_notification_test.cpp
+++ b/ivi-layermanagement-api/test/ilm_control_notification_test.cpp
@@ -33,6 +33,12 @@ extern "C" {
#include "ilm_control.h"
}
+struct screenshot_data_t {
+ std::atomic<int32_t> fd;
+ std::atomic<uint32_t> error;
+ ilmErrorTypes result = ILM_SUCCESS;
+};
+
void add_nsecs(struct timespec *tv, long nsec)
{
assert(nsec < 1000000000);
@@ -230,6 +236,25 @@ public:
pthread_cond_signal( &waiterVariable );
}
+
+ static ilmErrorTypes ScreenshotDoneCallbackFunc(void *user_data, t_ilm_int fd, t_ilm_uint width, t_ilm_uint height, t_ilm_uint stride, t_ilm_uint format, t_ilm_uint timestamp)
+ {
+ PthreadMutexLock lock(notificationMutex);
+ screenshot_data_t *screenshotData = static_cast<screenshot_data_t*>(user_data);
+ screenshotData->fd.store(fd);
+ timesCalled++;
+ pthread_cond_signal( &waiterVariable );
+ return screenshotData->result;
+ }
+
+ static void ScreenshotErrorCallbackFunc(void *user_data, t_ilm_uint error, const char *message)
+ {
+ PthreadMutexLock lock(notificationMutex);
+ screenshot_data_t *screenshotData = static_cast<screenshot_data_t*>(user_data);
+ screenshotData->error.store(error);
+ timesCalled++;
+ pthread_cond_signal( &waiterVariable );
+ }
};
// Pointers where to put received values for current Test
@@ -726,3 +751,38 @@ TEST_F(NotificationTest, DefaultIsNotToReceiveNotificationsSurface)
// assert that we have not been notified
assertNoCallbackIsCalled();
}
+
+TEST_F(NotificationTest, getNotificationWhenScreenshotDone)
+{
+ /* Call ilm_takeAsyncScreenshot with right screen id
+ * The ilm_takeAsyncScreenshot should return ILM_SUCCESS
+ * Screenshot done callback should trigged
+ */
+ screenshot_data_t screenshotData;
+ screenshotData.fd.store(-1);
+ ASSERT_EQ(ILM_SUCCESS, ilm_takeAsyncScreenshot(0, ScreenshotDoneCallbackFunc, ScreenshotErrorCallbackFunc, &screenshotData));
+ assertCallbackcalled();
+ ASSERT_NE(screenshotData.fd.load(), -1);
+
+ /* Call ilm_takeAsyncSurfaceScreenshot with right surface id
+ * The ilm_takeAsyncSurfaceScreenshot should return ILM_SUCCESS
+ * Screenshot done callback should trigged
+ */
+ screenshotData.fd.store(-1);
+ ASSERT_EQ(ILM_SUCCESS, ilm_takeAsyncSurfaceScreenshot(surface, ScreenshotDoneCallbackFunc, ScreenshotErrorCallbackFunc, &screenshotData));
+ assertCallbackcalled();
+ ASSERT_NE(screenshotData.fd.load(), -1);
+}
+
+TEST_F(NotificationTest, getNotificationWhenScreenshotError)
+{
+ /* Call ilm_takeAsyncSurfaceScreenshot with wrong surface id
+ * The ilm_takeAsyncSurfaceScreenshot should return ILM_SUCCESS
+ * Screenshot error callback should trigged
+ */
+ screenshot_data_t screenshotData;
+ screenshotData.error.store(0);
+ ASSERT_EQ(ILM_SUCCESS, ilm_takeAsyncSurfaceScreenshot(surface + 1, ScreenshotDoneCallbackFunc, ScreenshotErrorCallbackFunc, &screenshotData));
+ assertCallbackcalled();
+ ASSERT_EQ(screenshotData.error.load(), 3); //IVI_SCREENSHOT_ERROR_NO_SURFACE is 3
+}