-I$(includedir)/gtest \
-fpermissive \
-rdynamic \
- -DFAIL_ON_UNSUPPORTED \
- -w
+ -DFAIL_ON_UNSUPPORTED
# The flag -w is used, because there are many warnings in libtdm's sources.
# Warnings occur because we build project with g++.
# In C++ we need to use explicit types conversion.
class TDMInit : public ::testing::Test {
protected:
+ int master_fd = -42, tbm_fd = -42;
void SetUp(void)
{
setenv("TDM_DLOG", "1", 1);
}
void TearDown(void)
{
+ if (master_fd > -1) {
+ int temp_master_fd = tbm_drm_helper_get_master_fd();
+ EXPECT_EQ(temp_master_fd, -1) << "Fatal Error. Can't deinit tdm/tbm" << std::endl;
+ if (temp_master_fd > -1)
+ exit(1);
+ close(master_fd);
+ }
+ if (tbm_fd > -1) {
+ int temp_tbm_fd = tbm_drm_helper_get_fd();
+ EXPECT_EQ(temp_tbm_fd, -1) << "Fatal Error. Can't deinit tdm/tbm" << std::endl;
+ if (temp_tbm_fd > -1)
+ exit(1);
+ close(tbm_fd);
+ }
unsetenv("TDM_DLOG");
unsetenv("XDG_RUNTIME_DIR");
unsetenv("TBM_DLOG");
protected:
tdm_display *dpy = NULL;
tbm_bufmgr tbm_bufmgr = NULL;
+ int master_fd = -42, tbm_fd = -42;
void SetUp(void)
{
setenv("TDM_DLOG", "1", 1);
dpy = tdm_display_init(&error);
ASSERT_TRUE(error == TDM_ERROR_NONE);
ASSERT_FALSE(dpy == NULL);
+ master_fd = tbm_drm_helper_get_master_fd();
+ tbm_fd = tbm_drm_helper_get_fd();
}
void TearDown(void)
{
tbm_bufmgr_deinit(tbm_bufmgr);
tbm_bufmgr = NULL;
dpy = NULL;
+ if (master_fd > -1) {
+ int temp_master_fd = tbm_drm_helper_get_master_fd();
+ EXPECT_EQ(temp_master_fd, -1) << "Fatal Error. Can't deinit tdm/tbm" << std::endl;
+ if (temp_master_fd > -1)
+ exit(1);
+ close(master_fd);
+ }
+ if (tbm_fd > -1) {
+ int temp_tbm_fd = tbm_drm_helper_get_fd();
+ EXPECT_EQ(temp_tbm_fd, -1) << "Fatal Error. Can't deinit tdm/tbm" << std::endl;
+ if (temp_tbm_fd > -1)
+ exit(1);
+ close(tbm_fd);
+ }
unsetenv("TDM_DLOG");
unsetenv("XDG_RUNTIME_DIR");
unsetenv("TBM_DLOG");
tdm_display *dpy = tdm_display_init(&error);
ASSERT_TRUE(error == TDM_ERROR_NONE);
ASSERT_FALSE(dpy == NULL);
+ master_fd = tbm_drm_helper_get_master_fd();
+ tbm_fd = tbm_drm_helper_get_fd();
tdm_display_deinit(dpy);
dpy = NULL;
- ASSERT_TRUE(tbm_drm_helper_get_master_fd() == -1);
- ASSERT_TRUE(tbm_drm_helper_get_fd() == -1);
}
+TEST_F(TDMInit, DisplayInitDeinitSuccessfulWithTBM)
+{
+ tbm_bufmgr tbm_bufmgr = NULL;
+ tbm_bufmgr = tbm_bufmgr_init(-1);
+ ASSERT_FALSE(tbm_bufmgr == NULL);
+ tdm_error error = TDM_ERROR_NONE;
+ tdm_display *dpy = tdm_display_init(&error);
+ EXPECT_TRUE(error == TDM_ERROR_NONE);
+ EXPECT_FALSE(dpy == NULL);
+ master_fd = tbm_drm_helper_get_master_fd();
+ tbm_fd = tbm_drm_helper_get_fd();
+ if (dpy != NULL && error == TDM_ERROR_NONE)
+ tdm_display_deinit(dpy);
+ dpy = NULL;
+ tbm_bufmgr_deinit(tbm_bufmgr);
+ tbm_bufmgr = NULL;
+}
+
+
TEST_F(TDMInit, DisplayInitFewTimesSuccessfulWithTBM)
{
tdm_error error = TDM_ERROR_NONE;
tbm_bufmgr tbm_bufmgr = NULL;
tbm_bufmgr = tbm_bufmgr_init(-1);
ASSERT_FALSE(tbm_bufmgr == NULL);
- for (int i = 0; i < 20; i++) {
+ dpy[0] = tdm_display_init(&error);
+ EXPECT_TRUE(error == TDM_ERROR_NONE);
+ EXPECT_FALSE(dpy[0] == NULL);
+ master_fd = tbm_drm_helper_get_master_fd();
+ tbm_fd = tbm_drm_helper_get_fd();
+ for (int i = 1; i < 20; i++) {
dpy[i] = tdm_display_init(&error);
EXPECT_TRUE(error == TDM_ERROR_NONE);
EXPECT_FALSE(dpy[i] == NULL);
}
for (int i = 19; i > 0; i--) {
tdm_display_deinit(dpy[i]);
- EXPECT_FALSE(tbm_drm_helper_get_master_fd() == -1);
- EXPECT_FALSE(tbm_drm_helper_get_fd() == -1);
+ if (master_fd > -1) {
+ int temp_master_fd = tbm_drm_helper_get_master_fd();
+ EXPECT_NE(temp_master_fd, -1);
+ if (temp_master_fd > -1)
+ close(temp_master_fd);
+ }
+ if (tbm_fd > -1) {
+ int temp_tbm_fd = tbm_drm_helper_get_fd();
+ EXPECT_NE(temp_tbm_fd, -1);
+ if (temp_tbm_fd > -1)
+ close(temp_tbm_fd);
+ }
}
tdm_display_deinit(dpy[0]);
tbm_bufmgr_deinit(tbm_bufmgr);
tbm_bufmgr = NULL;
- ASSERT_TRUE(tbm_drm_helper_get_master_fd() == -1);
- ASSERT_TRUE(tbm_drm_helper_get_fd() == -1);
-}
-
-TEST_F(TDMInit, DisplayInitDeinitSuccessfulWithTBM)
-{
- tbm_bufmgr tbm_bufmgr = NULL;
- tbm_bufmgr = tbm_bufmgr_init(-1);
- ASSERT_FALSE(tbm_bufmgr == NULL);
- tdm_error error = TDM_ERROR_NONE;
- tdm_display *dpy = tdm_display_init(&error);
- ASSERT_TRUE(error == TDM_ERROR_NONE);
- ASSERT_FALSE(dpy == NULL);
- tdm_display_deinit(dpy);
- dpy = NULL;
- tbm_bufmgr_deinit(tbm_bufmgr);
- tbm_bufmgr = NULL;
- ASSERT_TRUE(tbm_drm_helper_get_master_fd() == -1);
- ASSERT_TRUE(tbm_drm_helper_get_fd() == -1);
}
TEST_F(TDMInit, DisplayInitDeinitSuccessfulNullErrorWithTBM)
tbm_bufmgr tbm_bufmgr = NULL;
tbm_bufmgr = tbm_bufmgr_init(-1);
ASSERT_FALSE(tbm_bufmgr == NULL);
- tdm_error error = TDM_ERROR_NONE;
tdm_display *dpy = tdm_display_init(NULL);
- ASSERT_TRUE(error == TDM_ERROR_NONE);
- ASSERT_FALSE(dpy == NULL);
- tdm_display_deinit(dpy);
+ EXPECT_FALSE(dpy == NULL);
+ master_fd = tbm_drm_helper_get_master_fd();
+ tbm_fd = tbm_drm_helper_get_fd();
+ if (dpy != NULL)
+ tdm_display_deinit(dpy);
dpy = NULL;
tbm_bufmgr_deinit(tbm_bufmgr);
tbm_bufmgr = NULL;
- ASSERT_TRUE(tbm_drm_helper_get_master_fd() == -1);
- ASSERT_TRUE(tbm_drm_helper_get_fd() == -1);
}
TEST_F(TDMInit, DisplayInitDeinitSuccessfulFewTimesWithTBM)
ASSERT_FALSE(tbm_bufmgr == NULL);
tdm_error error = TDM_ERROR_NONE;
tdm_display *dpy = tdm_display_init(&error);
- ASSERT_TRUE(error == TDM_ERROR_NONE);
- ASSERT_FALSE(dpy == NULL);
- tdm_display_deinit(dpy);
+ EXPECT_TRUE(error == TDM_ERROR_NONE);
+ EXPECT_FALSE(dpy == NULL);
+ master_fd = tbm_drm_helper_get_master_fd();
+ tbm_fd = tbm_drm_helper_get_fd();
+ if (dpy != NULL)
+ tdm_display_deinit(dpy);
dpy = NULL;
tbm_bufmgr_deinit(tbm_bufmgr);
tbm_bufmgr = NULL;
+ if (master_fd > -1) {
+ int temp_master_fd = tbm_drm_helper_get_master_fd();
+ EXPECT_EQ(temp_master_fd, -1) << "Fatal Error. Can't deinit tdm/tbm" << std::endl;
+ if (temp_master_fd > -1)
+ exit(1);
+ close(master_fd);
+ master_fd = -1;
+ }
+ if (tbm_fd > -1) {
+ int temp_tbm_fd = tbm_drm_helper_get_fd();
+ EXPECT_EQ(temp_tbm_fd, -1) << "Fatal Error. Can't deinit tdm/tbm" << std::endl;
+ if (temp_tbm_fd > -1)
+ exit(1);
+ close(tbm_fd);
+ tbm_fd = -1;
+ }
}
- ASSERT_TRUE(tbm_drm_helper_get_master_fd() == -1);
- ASSERT_TRUE(tbm_drm_helper_get_fd() == -1);
}
-TEST_F(TDMInit, DisplayDeinitSuccessfulNullDpy)
+TEST_F(TDMInit, DisplayDeinitSuccessfulNullDpyWithoutTBM)
{
tdm_error error = TDM_ERROR_NONE;
tdm_display *dpy = tdm_display_init(&error);
ASSERT_TRUE(error == TDM_ERROR_NONE);
ASSERT_FALSE(dpy == NULL);
+ master_fd = tbm_drm_helper_get_master_fd();
+ tbm_fd = tbm_drm_helper_get_fd();
tdm_display_deinit(NULL);
tdm_display_deinit(dpy);
dpy = NULL;
- ASSERT_TRUE(tbm_drm_helper_get_master_fd() == -1);
- ASSERT_TRUE(tbm_drm_helper_get_fd() == -1);
}
-TEST_F(TDMInit, DisplayDeinitDeathWrongDpy)
+TEST_F(TDMInit, DisplayDeinitFailWrongDpyBadAddress)
{
tdm_error error = TDM_ERROR_NONE;
tdm_display *dpy = tdm_display_init(&error);
ASSERT_TRUE(error == TDM_ERROR_NONE);
ASSERT_FALSE(dpy == NULL);
- EXPECT_EXIT({tdm_display *wrong_dpy = 0xBEAF;
+ master_fd = tbm_drm_helper_get_master_fd();
+ tbm_fd = tbm_drm_helper_get_fd();
+ EXPECT_EXIT({tdm_display *wrong_dpy = (tdm_display *) 0xBEAF;
tdm_display_deinit(wrong_dpy);
exit(0); }, ::testing::ExitedWithCode(0), "");
tdm_display_deinit(dpy);
dpy = NULL;
- ASSERT_TRUE(tbm_drm_helper_get_master_fd() == -1);
- ASSERT_TRUE(tbm_drm_helper_get_fd() == -1);
+}
+
+TEST_F(TDMInit, DisplayDeinitFailWrongDpyStackAddress)
+{
+ tdm_error error = TDM_ERROR_NONE;
+ tdm_display *dpy = tdm_display_init(&error);
+ ASSERT_TRUE(error == TDM_ERROR_NONE);
+ ASSERT_FALSE(dpy == NULL);
+ master_fd = tbm_drm_helper_get_master_fd();
+ tbm_fd = tbm_drm_helper_get_fd();
+ EXPECT_EXIT({tdm_display *wrong_dpy = &error;
+ tdm_display_deinit(wrong_dpy);
+ exit(0); }, ::testing::ExitedWithCode(0), "");
+ tdm_display_deinit(dpy);
+ dpy = NULL;
+}
+
+TEST_F(TDMInit, DisplayDeinitFailWrongDpyHeapAddress)
+{
+ tdm_error error = TDM_ERROR_NONE;
+ tdm_display *dpy = tdm_display_init(&error);
+ ASSERT_TRUE(error == TDM_ERROR_NONE);
+ ASSERT_FALSE(dpy == NULL);
+ master_fd = tbm_drm_helper_get_master_fd();
+ tbm_fd = tbm_drm_helper_get_fd();
+ EXPECT_EXIT({tdm_display *wrong_dpy = (tdm_display *) ((unsigned long) sbrk(0) - sizeof(unsigned long));
+ tdm_display_deinit(wrong_dpy);
+ exit(0); }, ::testing::ExitedWithCode(0), "");
+ tdm_display_deinit(dpy);
+ dpy = NULL;
+}
+
+TEST_F(TDMInit, DISABLED_DisplayDeinitFailRepeatWithSameDpy)
+{
+ EXPECT_EXIT({tdm_error error = TDM_ERROR_NONE;
+ tdm_display *dpy = tdm_display_init(&error);
+ if (error != TDM_ERROR_NONE) exit(1);
+ tdm_display_deinit(dpy);
+ if (tbm_drm_helper_get_master_fd() != -1) exit(1);
+ if (tbm_drm_helper_get_fd() != -1) exit(1);
+ tdm_display_deinit(dpy);
+ tdm_display *dpy2 = malloc(2048);
+ *((unsigned int *)dpy2) = 673282346;
+ tdm_display_deinit(dpy2);
+ tdm_display_deinit(dpy);
+ tdm_display_deinit(dpy2);
+ exit(0); }, ::testing::ExitedWithCode(0), "");
}
TEST_F(TDMDefault, DisplayUpdateSuccessful)
TEST_F(TDMDefault, DisplayUpdateFailWrongDpy)
{
- ASSERT_EXIT({tdm_display *wrong_dpy = 0xBEAF;
+ ASSERT_EXIT({tdm_display *wrong_dpy = (tdm_display *)0xBEAF;
tdm_display_update(wrong_dpy);
exit(0);}, ::testing::ExitedWithCode(0), "");
}
TEST_F(TDMDefault, DisplayGetFDFailWrongDpy)
{
- ASSERT_EXIT({tdm_display *wrong_dpy = 0xBEAF; int fd = -42;
+ ASSERT_EXIT({tdm_display *wrong_dpy = (tdm_display *) 0xBEAF; int fd = -42;
tdm_display_get_fd(wrong_dpy, &fd);
exit(0);}, ::testing::ExitedWithCode(0), "");
}
TEST_F(TDMDefault, DisplayGetCapabilitiesSuccessful)
{
- tdm_display_capability capabilities = -42;
+ tdm_display_capability capabilities = (tdm_display_capability) -42;
ASSERT_TRUE(tdm_display_get_capabilities(dpy, &capabilities) == TDM_ERROR_NONE);
ASSERT_FALSE(capabilities == -1);
}
TEST_F(TDMDefault, DisplayGetPPCapabilitiesSuccessful)
{
- tdm_pp_capability capabilities = -42;
+ tdm_pp_capability capabilities = (tdm_pp_capability) -42;
tdm_error error = TDM_ERROR_NONE;
error = tdm_display_get_pp_capabilities(dpy, &capabilities);
ASSERT_TRUE(error == TDM_ERROR_NONE || error == TDM_ERROR_NO_CAPABILITY);
TEST_F(TDMDefault, DisplayGetCaptureCapabilitiesSuccessful)
{
- tdm_capture_capability capabilities = -42;
+ tdm_capture_capability capabilities = (tdm_capture_capability) -42;
tdm_error error = TDM_ERROR_NONE;
error = tdm_display_get_capture_capabilities(dpy, &capabilities);
ASSERT_TRUE(error == TDM_ERROR_NONE || error == TDM_ERROR_NO_CAPABILITY);
{
int max_count = -42;
ASSERT_TRUE(TDM_ERROR_NONE == tdm_display_get_max_layer_count(dpy, &max_count));
- ASSERT_FALSE(-42 == max_count);
+ ASSERT_NE(max_count, -42);
}
TEST_F(TDMDefault, DisplayGetMaxLayerCountFailNullAll)
class TDMCapture : public ::testing::Test {
protected:
tdm_display *dpy = NULL;
- tdm_capture_capability capture_capabilities = -42;
+ tdm_capture_capability capture_capabilities = (tdm_capture_capability) -42;
bool has_capture = false;
tbm_bufmgr tbm_bufmgr = NULL;
void SetUp(void)
protected:
tdm_display *dpy = NULL;
tbm_bufmgr tbm_bufmgr = NULL;
- int output_count = -42;
- int layer_count = -42;
+ int master_fd = -42, tbm_fd = -42, layer_count = 0;
+ tdm_layer ** tdm_layer_array = NULL;
bool has_layers = false;
void SetUp(void)
{
dpy = tdm_display_init(&error);
ASSERT_TRUE(error == TDM_ERROR_NONE);
ASSERT_FALSE(dpy == NULL);
- error = tdm_display_get_output_count(dpy, &output_count);
- error = tdm_display_get_max_layer_count(dpy, &layer_count);
+ master_fd = tbm_drm_helper_get_master_fd();
+ tbm_fd = tbm_drm_helper_get_fd();
+ int output_count = 0;
+ if (tdm_display_get_output_count(dpy, &output_count) == TDM_ERROR_NONE) {
+ for (int i = 0; i < output_count; i++) {
+ tdm_output * output = tdm_display_get_output(dpy, i, &error);
+ if (TDM_ERROR_NONE != error || NULL == output)
+ continue;
+ tdm_output_conn_status status = TDM_OUTPUT_CONN_STATUS_DISCONNECTED;
+ if (TDM_ERROR_NONE != tdm_output_get_conn_status(output, &status))
+ continue;
+ if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED)
+ continue;
+ int temp_layer_count = 0;
+ if (TDM_ERROR_NONE != tdm_output_get_layer_count(output, &temp_layer_count))
+ continue;
+ if (0 == temp_layer_count)
+ continue;
+ tdm_layer_array = (tdm_layer **) realloc(tdm_layer_array,
+ (layer_count + temp_layer_count)*sizeof(tdm_layer *));
+ ASSERT_FALSE(NULL == tdm_layer_array);
+ for (int k = layer_count; k < (layer_count + temp_layer_count); k++) {
+ tdm_layer_array[k] = tdm_output_get_layer(output, k, &error);
+ ASSERT_TRUE(TDM_ERROR_NONE == error);
+ ASSERT_FALSE(NULL == tdm_layer_array[k]);
+ }
+ layer_count+=temp_layer_count;
+ }
+ }
+
#ifdef FAIL_ON_UNSUPPORTED
- ASSERT_GT(output_count, 0);
ASSERT_GT(layer_count, 0);
#endif
if (layer_count > 0)
dpy = NULL;
tbm_bufmgr_deinit(tbm_bufmgr);
tbm_bufmgr = NULL;
+ if (tdm_layer_array)
+ free(tdm_layer_array);
+ if (master_fd > -1) {
+ int temp_master_fd = tbm_drm_helper_get_master_fd();
+ EXPECT_EQ(temp_master_fd, -1) << "Fatal Error. Can't deinit tdm/tbm" << std::endl;
+ if (temp_master_fd > -1)
+ exit(1);
+ close(master_fd);
+ }
+ if (tbm_fd > -1) {
+ int temp_tbm_fd = tbm_drm_helper_get_fd();
+ EXPECT_EQ(temp_tbm_fd, -1) << "Fatal Error. Can't deinit tdm/tbm" << std::endl;
+ if (temp_tbm_fd > -1)
+ exit(1);
+ close(tbm_fd);
+ }
unsetenv("TDM_DLOG");
unsetenv("XDG_RUNTIME_DIR");
unsetenv("TBM_DLOG");
}
};
-TEST_F(TDMLayer, OutputGetLayerSuccessful)
+TEST_F(TDMLayer, LayerGetCapabilitiesSuccessful)
{
SKIP_FLAG(has_layers);
- for (int i = 0; i < output_count; i++) {
- tdm_error error_output = TDM_ERROR_NONE;
- tdm_output * output = NULL;
- output = tdm_display_get_output(dpy, i, &error_output);
- ASSERT_FALSE(NULL == output);
- ASSERT_TRUE(TDM_ERROR_NONE == error_output);
- for (int k = 0; k < layer_count; k++) {
- tdm_error error_layer = TDM_ERROR_NONE;
- ASSERT_FALSE(NULL == tdm_output_get_layer(output, k, &error_layer));
- ASSERT_TRUE(TDM_ERROR_NONE == error_layer);
- }
+ for (int i = 0; i < layer_count; i++) {
+ tdm_layer_capability capabilities = (tdm_layer_capability) -42;
+ ASSERT_TRUE(TDM_ERROR_NONE == tdm_layer_get_capabilities(tdm_layer_array[i], &capabilities));
+ ASSERT_NE(capabilities, -42);
}
}
class TDMOutput : public ::testing::Test {
protected:
tdm_display *dpy = NULL;
- int output_count = -42;
+ int output_count = -42, master_fd = -42, tbm_fd = -42;
bool has_output = false;
tbm_bufmgr tbm_bufmgr = NULL;
static unsigned int handle_call;
dpy = tdm_display_init(&error);
ASSERT_TRUE(error == TDM_ERROR_NONE);
ASSERT_FALSE(dpy == NULL);
+ master_fd = tbm_drm_helper_get_master_fd();
+ tbm_fd = tbm_drm_helper_get_fd();
error = tdm_display_get_output_count(dpy, &output_count);
#ifdef FAIL_ON_UNSUPPORTED
ASSERT_GT(output_count, 0);
dpy = NULL;
tbm_bufmgr_deinit(tbm_bufmgr);
tbm_bufmgr = NULL;
+ if (master_fd > -1) {
+ int temp_master_fd = tbm_drm_helper_get_master_fd();
+ EXPECT_EQ(temp_master_fd, -1) << "Fatal Error. Can't deinit tdm/tbm" << std::endl;
+ if (temp_master_fd > -1)
+ exit(1);
+ close(master_fd);
+ }
+ if (tbm_fd > -1) {
+ int temp_tbm_fd = tbm_drm_helper_get_fd();
+ EXPECT_EQ(temp_tbm_fd, -1) << "Fatal Error. Can't deinit tdm/tbm" << std::endl;
+ if (temp_tbm_fd > -1)
+ exit(1);
+ close(tbm_fd);
+ }
unsetenv("TDM_DLOG");
unsetenv("XDG_RUNTIME_DIR");
unsetenv("TBM_DLOG");
SKIP_FLAG(has_output);
for (int i = 0; i < output_count; i++) {
tdm_error error = TDM_ERROR_NONE;
- tdm_output_capability capabilities = -42;
+ tdm_output_capability capabilities = (tdm_output_capability) -42;
tdm_output * output = tdm_display_get_output(dpy, i, &error);
ASSERT_FALSE(NULL == output);
ASSERT_TRUE(TDM_ERROR_NONE == error);
SKIP_FLAG(has_output);
for (int i = 0; i < output_count; i++) {
tdm_error error = TDM_ERROR_NONE;
- tdm_output_conn_status status = -42;
+ tdm_output_conn_status status = (tdm_output_conn_status) -42;
tdm_output * output = tdm_display_get_output(dpy, i, &error);
ASSERT_FALSE(NULL == output);
ASSERT_TRUE(TDM_ERROR_NONE == error);
SKIP_FLAG(has_output);
for (int i = 0; i < output_count; i++) {
tdm_error error = TDM_ERROR_NONE;
+ tdm_output_conn_status status;
tdm_output * output = tdm_display_get_output(dpy, i, &error);
ASSERT_FALSE(NULL == output);
ASSERT_TRUE(TDM_ERROR_NONE == error);
+ ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_conn_status(output, &status));
+ if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED)
+ continue;
ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON));
ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_STANDBY));
ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_SUSPEND));
tdm_output * output = tdm_display_get_output(dpy, i, &error);
ASSERT_FALSE(NULL == output);
ASSERT_TRUE(TDM_ERROR_NONE == error);
+ tdm_output_conn_status status;
+ ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_conn_status(output, &status));
+ if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED)
+ continue;
ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_add_change_handler(output,
tdm_output_change_handler_test_func,
- -101));
+ (void *) -101));
ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON));
ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF));
ASSERT_GT(handle_call, 0);
tdm_output * output = tdm_display_get_output(dpy, i, &error);
ASSERT_FALSE(NULL == output);
ASSERT_TRUE(TDM_ERROR_NONE == error);
+ tdm_output_conn_status status;
+ ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_conn_status(output, &status));
+ if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED)
+ continue;
for (int k = 0; k < 20; k++) {
ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_add_change_handler(output,
tdm_output_change_handler_test_func,
- (-101-k)));
+ (void *) (-101-k)));
}
ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON));
ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF));
TEST_F(TDMOutput, OutputAddChangeHandlerFailAllNull)
{
SKIP_FLAG(has_output);
- ASSERT_FALSE(TDM_ERROR_NONE ==tdm_output_add_change_handler(NULL, NULL, NULL));
+ ASSERT_FALSE(TDM_ERROR_NONE == tdm_output_add_change_handler(NULL, NULL, NULL));
}
TEST_F(TDMOutput, OutputAddChangeHandlerFailOnlyOutput)
TEST_F(TDMOutput, OutputAddChangeHandlerFailWrongOutput)
{
SKIP_FLAG(has_output);
- ASSERT_EXIT({tdm_output *output = 0xBEAF;
+ ASSERT_EXIT({tdm_output *output = (tdm_output *) 0xBEAF;
tdm_output_add_change_handler(output,
tdm_output_change_handler_test_func,
- -101);
+ (void *) -101);
exit(0);}, ::testing::ExitedWithCode(0), "");
}
TEST_F(TDMOutput, OutputRemoveChangeHandlerSuccessful)
{
+ SKIP_FLAG(has_output);
for (int i = 0; i < output_count; i++) {
tdm_error error = TDM_ERROR_NONE;
tdm_output * output = tdm_display_get_output(dpy, i, &error);
ASSERT_FALSE(NULL == output);
ASSERT_TRUE(TDM_ERROR_NONE == error);
+ tdm_output_conn_status status;
+ ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_conn_status(output, &status));
+ if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED)
+ continue;
ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_add_change_handler(output,
tdm_output_change_handler_test_func,
- -101));
+ (void *) -101));
ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON));
ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF));
ASSERT_GT(handle_call, 0);
handle_call = 0;
- tdm_output_remove_change_handler(output, tdm_output_change_handler_test_func, -101);
+ tdm_output_remove_change_handler(output, tdm_output_change_handler_test_func, (void *) -101);
ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON));
ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF));
ASSERT_EQ(handle_call, 0);
TEST_F(TDMOutput, OutputRemoveChangeHandlerSuccessfulFewFuncs)
{
+ SKIP_FLAG(has_output);
for (int i = 0; i < output_count; i++) {
tdm_error error = TDM_ERROR_NONE;
tdm_output * output = tdm_display_get_output(dpy, i, &error);
ASSERT_FALSE(NULL == output);
ASSERT_TRUE(TDM_ERROR_NONE == error);
+ tdm_output_conn_status status;
+ ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_conn_status(output, &status));
+ if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED)
+ continue;
for (int k = 0; k < 20; k++) {
ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_add_change_handler(output,
tdm_output_change_handler_test_func,
- (-101-k)));
+ (void *) (-101-k)));
}
ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON));
ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF));
ASSERT_GT(handle_call, 20);
handle_call = 0;
for (int k = 0; k < 20; k++) {
- tdm_output_remove_change_handler(output, tdm_output_change_handler_test_func, (-101-k));
+ tdm_output_remove_change_handler(output, tdm_output_change_handler_test_func, (void *) (-101-k));
}
ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_ON));
ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_set_dpms(output, TDM_OUTPUT_DPMS_OFF));
ASSERT_EQ(handle_call, 0);
}
}
+
+TEST_F(TDMOutput, OutputRemoveChangeHandlerFailAllNull)
+{
+ SKIP_FLAG(has_output);
+ ASSERT_EXIT({tdm_output_remove_change_handler(NULL, NULL, NULL);
+ exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMOutput, OutputRemoveChangeHandlerFailOnlyOutput)
+{
+ SKIP_FLAG(has_output);
+ ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
+ tdm_error error = TDM_ERROR_NONE;
+ tdm_output * output = tdm_display_get_output(dpy, i, &error);
+ if (NULL == output) exit(1);
+ if (TDM_ERROR_NONE != error) exit(1);
+ tdm_output_remove_change_handler(output, NULL, NULL);
+ } exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMOutput, OutputRemoveChangeHandlerFailWrongOutput)
+{
+ SKIP_FLAG(has_output);
+ ASSERT_EXIT({tdm_output *output = (tdm_output *) 0xBEAF;
+ tdm_output_remove_change_handler(output,
+ tdm_output_change_handler_test_func,
+ (void *) -101);
+ exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMOutput, OutputGetOutputTypeSuccessful)
+{
+ SKIP_FLAG(has_output);
+ for (int i = 0; i < output_count; i++) {
+ tdm_error error = TDM_ERROR_NONE;
+ tdm_output_type type = (tdm_output_type) -42;
+ tdm_output * output = tdm_display_get_output(dpy, i, &error);
+ ASSERT_FALSE(NULL == output);
+ ASSERT_TRUE(TDM_ERROR_NONE == error);
+ ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_output_type(output, &type));
+ ASSERT_NE(type, -42);
+ }
+}
+
+TEST_F(TDMOutput, OutputGetOutputTypeFailNullAll)
+{
+ SKIP_FLAG(has_output);
+ ASSERT_EXIT({if (tdm_output_get_output_type(NULL, NULL) == TDM_ERROR_NONE) exit(1);
+ exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMOutput, OutputGetOutputTypeFailOnlyOutput)
+{
+ SKIP_FLAG(has_output);
+ ASSERT_EXIT({for (int i = 0; i < output_count; i++) {
+ tdm_error error = TDM_ERROR_NONE;
+ tdm_output * output = tdm_display_get_output(dpy, i, &error);
+ if (NULL == output) exit(1);
+ if (TDM_ERROR_NONE != error) exit(1);
+ if (tdm_output_get_output_type(output, NULL) == TDM_ERROR_NONE) exit(1);
+ }
+ exit(0);}, ::testing::ExitedWithCode(0), "");
+}
+
+TEST_F(TDMOutput, OutputGetLayerCountSuccessful)
+{
+ SKIP_FLAG(has_output);
+ for (int i = 0; i < output_count; i++) {
+ tdm_error error = TDM_ERROR_NONE;
+ int count = -42;
+ tdm_output * output = tdm_display_get_output(dpy, i, &error);
+ ASSERT_FALSE(NULL == output);
+ ASSERT_TRUE(TDM_ERROR_NONE == error);
+ ASSERT_TRUE(TDM_ERROR_NONE == tdm_output_get_layer_count(output, &count));
+ ASSERT_NE(count, -42);
+ }
+}
class TDMPP : public testing::Test {
protected:
tdm_display *dpy = NULL;
- tdm_pp_capability pp_capabilities = -42;
+ tdm_pp_capability pp_capabilities = (tdm_pp_capability) -42;
bool has_pp = false;
void SetUp(void)
{