*
**************************************************************************/
+#include <limits.h>
#include "gtest/gtest.h"
#include "ut_common.h"
#include "stdint.h"
setenv("TDM_COMMIT_PER_VBLANK", "1", 1);
setenv("TDM_DLOG", "1", 1);
setenv("TDM_HWC", "1", 1);
- setenv("XDG_RUNTIME_DIR", ".", 1);
+ setenv("XDG_RUNTIME_DIR", "/run", 1);
setenv("TBM_DLOG", "1", 1);
setenv("TBM_DISPLAY_SERVER", "1", 1);
}
const tdm_output_mode *preferred_mode = NULL;
tdm_error error = TDM_ERROR_NONE;
int all_output_count = 0;
+ outputs = NULL;
SetEnv();
class TDMHwcWindow : public TDMOutputHwc {
protected:
tdm_hwc_window **hwc_wins;
+ tdm_hwc_window *video_hwc_win;
int hwc_count;
void SetUp(void)
{
hwc_count = 0;
+ video_hwc_win = NULL;
TDMOutputHwc::SetUp();
hwc_wins = (tdm_hwc_window **)calloc(output_count * HWC_WIN_NUM, sizeof(tdm_hwc_window *));
ASSERT_EQ(TDM_ERROR_NONE, error);
hwc_wins[hwc_count++] = hw;
}
+ if (!video_hwc_win) {
+ video_hwc_win = tdm_output_hwc_create_video_window(outputs[i], &error);
+ }
}
}
}
for (int i = 0; i < hwc_count; i++) {
tdm_output_hwc_destroy_window(outputs[0], hwc_wins[i]);
}
+
+ if (video_hwc_win)
+ tdm_output_hwc_destroy_window(outputs[0], video_hwc_win);
+
TDMOutputHwc::TearDown();
}
/* tdm_error tdm_output_hwc_set_client_target_buffer(tdm_output *output,
tbm_surface_h target_buffer, tdm_hwc_region damage,
tdm_hwc_window *composited_wnds, uint32_t num_wnds); */
-TEST_F(TDMOutputHwc, DISABLED_SetClientTargetBufferFailNullOutput)
+TEST_F(TDMOutputHwc, SetClientTargetBufferFailNullOutput)
{
tdm_hwc_region reg;
tbm_surface_h target_buff = CreateBufferForOutput(0);
ASSERT_NE(TDM_ERROR_NONE, error);
}
-TEST_F(TDMOutputHwcWithoutHwcCap, DISABLED_SetClientTargetBufferFailNoHwc)
+TEST_F(TDMOutputHwcWithoutHwcCap, SetClientTargetBufferFailNoHwc)
{
tdm_hwc_region damage;
}
}
-TEST_F(TDMOutputHwc, DISABLED_SetClientTargetBufferSuccessfulSetBuff)
+TEST_F(TDMOutputHwc, SetClientTargetBufferSuccessfulSetBuff)
{
tdm_hwc_region damage;
}
}
-TEST_F(TDMOutputHwc, DISABLED_SetClientTargetBufferSuccessfulResetBuff)
+TEST_F(TDMOutputHwc, SetClientTargetBufferSuccessfulResetBuff)
{
tdm_hwc_region damage = {.num_rects = 0, .rects = NULL};
for (int i = 0; i < hwc_count; i++) {
error = tdm_hwc_window_set_flags(hwc_wins[i], flag);
- ASSERT_EQ(TDM_ERROR_NONE, error);
+ ASSERT_TRUE(TDM_ERROR_NONE == error || TDM_ERROR_NOT_IMPLEMENTED == error);
}
}
for (int i = 0; i < hwc_count; i++) {
error = tdm_hwc_window_unset_flags(hwc_wins[i], flag);
- ASSERT_EQ(TDM_ERROR_NONE, error);
+ ASSERT_TRUE(TDM_ERROR_NONE == error || TDM_ERROR_NOT_IMPLEMENTED == error);
}
}
for (int i = 0; i < hwc_count; i++) {
/* hwc_window with TDM_COMPOSITION_CLIENT dosn't support tdm_hwc_window_video_get_capability()*/
- error = tdm_hwc_window_video_get_capability(hwc_wins[i], &video_capability);
+ error = tdm_hwc_window_video_get_capability(hwc_wins[i], &video_capability);
ASSERT_NE(TDM_ERROR_NONE, error);
- /*TODO:: check video capability for TDM_COMPOSITION_VIDEO*/
+ if (video_hwc_win != NULL) {
+ error = tdm_hwc_window_video_get_capability(video_hwc_win, &video_capability);
+ ASSERT_TRUE(TDM_ERROR_NONE == error || TDM_ERROR_NOT_IMPLEMENTED == error);
+ }
}
}
{
for (int i = 0; i < output_count; i++) {
if (IsHwcEnable(i)) {
+ /*
+ * This event can't be generated form user side.
+ * So just check a set and double set
+ */
+
/* test: first set*/
error = tdm_output_hwc_set_need_validate_handler(outputs[i], &need_validate_handler);
ASSERT_EQ(TDM_ERROR_NONE, error);
-
- error = tdm_backend_trigger_need_validate_event(outputs[i]);
- ASSERT_EQ(TDM_ERROR_NONE, error);
-
- error = tdm_display_handle_events(dpy);
- ASSERT_EQ(TDM_ERROR_NONE, error);
-
- ASSERT_EQ(1, need_validate_handler_is_called);
-
/* test: second isn't allowed*/
error = tdm_output_hwc_set_need_validate_handler(outputs[i], &need_validate_handler);
ASSERT_NE(TDM_ERROR_NONE, error);
}
}
+/* tdm_hwc_window * tdm_output_hwc_create_video_window(tdm_output *output, tdm_error *error); */
+TEST_F(TDMOutputHwc, CreateVideoWindowFailNull)
+{
+ ASSERT_EQ(NULL, tdm_output_hwc_create_video_window(NULL, &error));
+ ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_F(TDMOutputHwc, CreateVideoWindowSuccessful)
+{
+ for (int i = 0; i < output_count; i++) {
+ if (IsHwcEnable(i)) {
+ tdm_hwc_window * hw = tdm_output_hwc_create_video_window(outputs[i], &error);
+ if (error != TDM_ERROR_NOT_IMPLEMENTED) {
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+ ASSERT_NE(NULL, hw);
+ error = tdm_output_hwc_destroy_window(outputs[i], hw);
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+ }
+ } else {
+ ASSERT_EQ(NULL, tdm_output_hwc_create_video_window(outputs[i], &error));
+ ASSERT_NE(TDM_ERROR_NONE, error);
+ }
+ }
+}
+
+/* tdm_output_hwc_get_video_supported_formats() */
+TEST_F(TDMOutputHwc, GetVideoSupportedFormatsFailNull)
+{
+ tdm_error error;
+
+ error = tdm_output_hwc_get_video_supported_formats(NULL, NULL, NULL);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_F(TDMOutputHwc, GetVideoSupportedFormatsSuccessful)
+{
+ tdm_error error;
+ const tbm_format *formats;
+ int count;
+
+ for (int i = 0; i < output_count; i++) {
+ if (IsHwcEnable(i)) {
+ error = tdm_output_hwc_get_video_supported_formats(outputs[i], &formats, &count);
+ if (error != TDM_ERROR_NOT_IMPLEMENTED) {
+ ASSERT_EQ(TDM_ERROR_NONE, error);
+ if (count > 0)
+ ASSERT_NE(NULL, formats);
+ }
+ } else {
+ error = tdm_output_hwc_get_video_supported_formats(outputs[i], &formats, &count);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+ }
+ }
+}
+
+/* tdm_hwc_window_video_get_available_properties() */
+TEST_F(TDMHwcWindow, GetAvailablePropertiesFailNullWin)
+{
+ SKIP_FLAG(video_hwc_win != NULL);
+ const tdm_prop *props;
+ int count;
+
+ error = tdm_hwc_window_video_get_available_properties(NULL, &props, &count);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+
+ error = tdm_hwc_window_video_get_available_properties(video_hwc_win, NULL, &count);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+
+ error = tdm_hwc_window_video_get_available_properties(video_hwc_win, &props, NULL);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_F(TDMHwcWindow, GetAvailablePropertiesSuccess)
+{
+ SKIP_FLAG(video_hwc_win != NULL);
+
+ const tdm_prop *props;
+ int count;
+
+ error = tdm_hwc_window_video_get_available_properties(video_hwc_win, &props, &count);
+ ASSERT_TRUE(TDM_ERROR_NONE == error || TDM_ERROR_NOT_IMPLEMENTED == error);
+}
+
+/* tdm_hwc_window_video_get_property() */
+TEST_F(TDMHwcWindow, GetPropertyFailNull)
+{
+ SKIP_FLAG(video_hwc_win != NULL);
+
+ tdm_value value;
+ int id = 1;
+
+ error = tdm_hwc_window_video_get_property(NULL, id, &value);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+
+ error = tdm_hwc_window_video_get_property(video_hwc_win, id, NULL);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_F(TDMHwcWindow, GetPropertyFailWrongId)
+{
+ SKIP_FLAG(video_hwc_win != NULL);
+
+ tdm_value value;
+ int id = INT_MAX;
+
+ error = tdm_hwc_window_video_get_property(video_hwc_win, id, &value);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+/* tdm_hwc_window_video_set_property() */
+TEST_F(TDMHwcWindow, SetPropertyFailNull)
+{
+ SKIP_FLAG(video_hwc_win != NULL);
+ tdm_value value;
+ int id = 1;
+
+ error = tdm_hwc_window_video_set_property(NULL, id, value);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+}
+
+TEST_F(TDMHwcWindow, SetPropertyFailWrongId)
+{
+ SKIP_FLAG(video_hwc_win != NULL);
+
+ tdm_value value;
+ int id = INT_MAX;
+
+ error = tdm_hwc_window_video_set_property(video_hwc_win, id, value);
+ ASSERT_NE(TDM_ERROR_NONE, error);
+}
+