From 8a64e4134e7ad333cb3c352784f0068151a97e67 Mon Sep 17 00:00:00 2001 From: Caio Freitas de Oliveira Date: Wed, 12 Oct 2022 19:27:55 -0300 Subject: [PATCH] add special case for X11 tests --- src/gradient.cc | 4 +++- tests/test-gradient.cc | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/gradient.cc b/src/gradient.cc index 6a785bb9..77d9a09e 100644 --- a/src/gradient.cc +++ b/src/gradient.cc @@ -81,7 +81,9 @@ void gradient_factory::setup_masks() { void gradient_factory::setup_colour_depth() { #ifdef BUILD_X11 - if (out_to_x.get(*state)) { + if (state == nullptr) { // testing purposes + colour_depth = 24; + } else if (out_to_x.get(*state)) { colour_depth = DisplayPlanes(display, screen); } else #endif /* BUILD_X11 */ diff --git a/tests/test-gradient.cc b/tests/test-gradient.cc index dcb4b0d6..7ae820e0 100644 --- a/tests/test-gradient.cc +++ b/tests/test-gradient.cc @@ -32,7 +32,8 @@ #include const int width = 4; -#ifdef BUILD_GUI // 24-bit color depth +#ifdef BUILD_X11 // 24-bit color depth +#include const long colour = 0x996633; // brown const long expected_hue = 256; const long expected_value = 0x99; // max(0x99, 0x66, 0x33) @@ -57,7 +58,9 @@ const long expected_blue = 0x06; const long full_scale = conky::gradient_factory::SCALE360; TEST_CASE("gradient_factory::convert_from_rgb returns correct value") { +#ifdef BUILD_X11 state = nullptr; +#endif SECTION("rgb_gradient_factory") { auto factory = new conky::rgb_gradient_factory(width, colour, colour); long result[3]; @@ -135,7 +138,7 @@ TEST_CASE( * Due to lack of precision, the HSV and HCL functions are not reversible * if color depth is less than 24-bit */ -#ifdef BUILD_GUI +#ifdef BUILD_X11 SECTION("hsv_gradient_factory") { long tmp[3]; auto factory = new conky::hsv_gradient_factory(width, colour, colour);