summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy White <jwhite@codeweavers.com>2020-03-19 13:09:09 -0500
committerJeremy White <jwhite@codeweavers.com>2020-04-20 12:20:00 -0500
commit3825d6310455bf9dbaa92062000733bfc075f0ea (patch)
tree8d7a41b3aa6403014eec59b8b660a7b5b0a7690d
parent9e3ba91a788b612cdaadfa416dffb0e07c57d52d (diff)
Add a new test for tall screens; draw outside of scanline range.
This exposes a bug in the current code base. That is, we do not scan beyond the 32 scan lines currently given. That means if we have a screen taller than 1024 pixels, we will not scan every block fully, and so we can miss changes. This test exposes that issue, and currently fails.
-rw-r--r--src/tests/expected.grid.bottom.3840x2160.ppmbin0 -> 24883217 bytes
-rw-r--r--src/tests/tests.c12
-rw-r--r--src/tests/xcbtest.c42
-rw-r--r--src/tests/xcbtest.h1
4 files changed, 55 insertions, 0 deletions
diff --git a/src/tests/expected.grid.bottom.3840x2160.ppm b/src/tests/expected.grid.bottom.3840x2160.ppm
new file mode 100644
index 0000000..9b650ac
--- /dev/null
+++ b/src/tests/expected.grid.bottom.3840x2160.ppm
Binary files differ
diff --git a/src/tests/tests.c b/src/tests/tests.c
index 6c873f5..e9cb8f5 100644
--- a/src/tests/tests.c
+++ b/src/tests/tests.c
@@ -203,6 +203,7 @@ void test_tallscreen(xdummy_t *xdummy, gconstpointer user_data)
snprintf(buf, sizeof(buf), "xrandr --display :%s -s 3840x2160", xdummy->display);
system(buf);
+ /* Test basic drawing */
snprintf(buf, sizeof(buf), ":%s", xdummy->display);
if (xcbtest_draw_grid(buf)) {
g_warning("Could not draw the grid");
@@ -213,6 +214,17 @@ void test_tallscreen(xdummy_t *xdummy, gconstpointer user_data)
check_screenshot(&test, &server, xdummy, buf);
}
+ /* Test drawing to the very bottom of the screen */
+ snprintf(buf, sizeof(buf), ":%s", xdummy->display);
+ if (xcbtest_draw_at_bottom(buf)) {
+ g_warning("Could not draw at the bottom");
+ g_test_fail();
+ }
+ else {
+ snprintf(buf, sizeof(buf), "%s/expected.grid.bottom.3840x2160.ppm", PATH_TO_TEST_SRC);
+ check_screenshot(&test, &server, xdummy, buf);
+ }
+
test_common_stop(&test, &server);
}
diff --git a/src/tests/xcbtest.c b/src/tests/xcbtest.c
index c131248..6398ae1 100644
--- a/src/tests/xcbtest.c
+++ b/src/tests/xcbtest.c
@@ -124,3 +124,45 @@ int xcbtest_draw_grid(const char *display)
return 0;
}
+
+int xcbtest_draw_at_bottom(const char *display)
+{
+ uint32_t red_pixel;
+
+ xcb_connection_t *c;
+ xcb_screen_t *screen;
+ xcb_gcontext_t red_fg;
+
+ xcb_void_cookie_t cookie;
+
+ xcb_rectangle_t red_rectangle;
+
+ /* Open the connection to the X server */
+ c = xcb_connect(display, NULL);
+ if (xcb_connection_has_error(c))
+ return 1;
+
+ /* Get the first screen */
+ screen = xcb_setup_roots_iterator(xcb_get_setup(c)).data;
+
+ red_fg = xcb_generate_id(c);
+ lookup_color(c, screen, "red", &red_pixel);
+ cookie = xcb_create_gc_checked(c, red_fg, screen->root, XCB_GC_FOREGROUND, &red_pixel);
+ xcb_request_check(c, cookie);
+
+ red_rectangle.width = screen->width_in_pixels;
+ red_rectangle.height = 8;
+ red_rectangle.x = 0;
+ red_rectangle.y = screen->height_in_pixels - red_rectangle.height * 2;
+
+ /* We draw the rectangles */
+ cookie = xcb_poly_fill_rectangle_checked(c, screen->root, red_fg, 1, &red_rectangle);
+ xcb_request_check(c, cookie);
+
+ /* We flush the request */
+ xcb_flush(c);
+
+ xcb_disconnect(c);
+
+ return 0;
+}
diff --git a/src/tests/xcbtest.h b/src/tests/xcbtest.h
index aa78662..b820bc5 100644
--- a/src/tests/xcbtest.h
+++ b/src/tests/xcbtest.h
@@ -26,5 +26,6 @@
** Prototypes
**--------------------------------------------------------------------------*/
int xcbtest_draw_grid(const char *display);
+int xcbtest_draw_at_bottom(const char *display);
#endif