bool dump_all_images = true;
/* Create the client */
- printf("Creating client for test\n");
+ testlog("Creating client for test\n");
client = create_client_and_test_surface(100, 100, 100, 100);
assert(client);
surface = client->surface->wl_surface;
wl_surface_commit(surface);
/* Take a snapshot. Result will be in screenshot->wl_buffer. */
- printf("Taking a screenshot\n");
+ testlog("Taking a screenshot\n");
screenshot = capture_screenshot_of_output(client);
assert(screenshot);
/* Load good reference image */
fname = screenshot_reference_filename("internal-screenshot-good", 0);
- printf("Loading good reference image %s\n", fname);
+ testlog("Loading good reference image %s\n", fname);
reference_good = load_image_from_png(fname);
assert(reference_good);
/* Load bad reference image */
fname = screenshot_reference_filename("internal-screenshot-bad", 0);
- printf("Loading bad reference image %s\n", fname);
+ testlog("Loading bad reference image %s\n", fname);
reference_bad = load_image_from_png(fname);
assert(reference_bad);
* We expect this to fail since we use a bad reference image
*/
match = check_images_match(screenshot->image, reference_bad, NULL);
- printf("Screenshot %s reference image\n", match? "equal to" : "different from");
+ testlog("Screenshot %s reference image\n", match? "equal to" : "different from");
assert(!match);
pixman_image_unref(reference_bad);
clip.y = 100;
clip.width = 100;
clip.height = 100;
- printf("Clip: %d,%d %d x %d\n", clip.x, clip.y, clip.width, clip.height);
+ testlog("Clip: %d,%d %d x %d\n", clip.x, clip.y, clip.width, clip.height);
match = check_images_match(screenshot->image, reference_good, &clip);
- printf("Screenshot %s reference image in clipped area\n", match? "matches" : "doesn't match");
+ testlog("Screenshot %s reference image in clipped area\n", match? "matches" : "doesn't match");
if (!match) {
diffimg = visualize_image_difference(screenshot->image, reference_good, &clip);
fname = screenshot_output_filename("internal-screenshot-error", 0);
buffer_destroy(screenshot);
- printf("Test complete\n");
+ testlog("Test complete\n");
assert(match);
}
vp = create_viewport(client);
- fprintf(stderr, "wp_viewport.set_source x=%d, y=%d, w=%d, h=%d\n",
+ testlog("wp_viewport.set_source x=%d, y=%d, w=%d, h=%d\n",
args->x, args->y, args->w, args->h);
set_source(vp, args->x, args->y, args->w, args->h);
vp = create_viewport(client);
- fprintf(stderr, "wp_viewport.set_destination w=%d, h=%d\n",
- args->w, args->h);
+ testlog("wp_viewport.set_destination w=%d, h=%d\n", args->w, args->h);
wp_viewport_set_destination(vp, args->w, args->h);
expect_protocol_error(client, &wp_viewport_interface,
vp = create_viewport(client);
- fprintf(stderr, "non-integer size w=%f, h=%f\n",
+ testlog("non-integer size w=%f, h=%f\n",
wl_fixed_to_double(args->w), wl_fixed_to_double(args->h));
wp_viewport_set_source(vp, 5, 6, args->w, args->h);
wp_viewport_set_destination(vp, -1, -1);
surf = client->surface->wl_surface;
vp = create_viewport(client);
- fprintf(stderr, "surface %dx%d\n",
+ testlog("surface %dx%d\n",
get_surface_width(client->surface,
args->buffer_scale, args->buffer_transform),
get_surface_height(client->surface,
args->buffer_scale, args->buffer_transform));
- fprintf(stderr, "source x=%f, y=%f, w=%f, h=%f; "
+ testlog("source x=%f, y=%f, w=%f, h=%f; "
"buffer scale=%d, transform=%d\n",
wl_fixed_to_double(args->x), wl_fixed_to_double(args->y),
wl_fixed_to_double(args->w), wl_fixed_to_double(args->h),
pointer->x = wl_fixed_to_int(x);
pointer->y = wl_fixed_to_int(y);
- fprintf(stderr, "test-client: got pointer enter %d %d, surface %p\n",
+ testlog("test-client: got pointer enter %d %d, surface %p\n",
pointer->x, pointer->y, pointer->focus);
}
pointer->focus = NULL;
- fprintf(stderr, "test-client: got pointer leave, surface %p\n",
+ testlog("test-client: got pointer leave, surface %p\n",
wl_surface ? wl_surface_get_user_data(wl_surface) : NULL);
}
pointer->motion_time_timespec = pointer->input_timestamp;
pointer->input_timestamp = (struct timespec) { 0 };
- fprintf(stderr, "test-client: got pointer motion %d %d\n",
+ testlog("test-client: got pointer motion %d %d\n",
pointer->x, pointer->y);
}
pointer->button_time_timespec = pointer->input_timestamp;
pointer->input_timestamp = (struct timespec) { 0 };
- fprintf(stderr, "test-client: got pointer button %u %u\n",
- button, state);
+ testlog("test-client: got pointer button %u %u\n", button, state);
}
static void
pointer->axis_time_timespec = pointer->input_timestamp;
pointer->input_timestamp = (struct timespec) { 0 };
- fprintf(stderr, "test-client: got pointer axis %u %f\n",
+ testlog("test-client: got pointer axis %u %f\n",
axis, wl_fixed_to_double(value));
}
static void
pointer_handle_frame(void *data, struct wl_pointer *wl_pointer)
{
- fprintf(stderr, "test-client: got pointer frame\n");
+ testlog("test-client: got pointer frame\n");
}
static void
pointer_handle_axis_source(void *data, struct wl_pointer *wl_pointer,
uint32_t source)
{
- fprintf(stderr, "test-client: got pointer axis source %u\n", source);
+ testlog("test-client: got pointer axis source %u\n", source);
}
static void
pointer->axis_stop_time_timespec = pointer->input_timestamp;
pointer->input_timestamp = (struct timespec) { 0 };
- fprintf(stderr, "test-client: got pointer axis stop %u\n", axis);
+ testlog("test-client: got pointer axis stop %u\n", axis);
}
static void
pointer_handle_axis_discrete(void *data, struct wl_pointer *wl_pointer,
uint32_t axis, int32_t value)
{
- fprintf(stderr, "test-client: got pointer axis discrete %u %d\n",
- axis, value);
+ testlog("test-client: got pointer axis discrete %u %d\n", axis, value);
}
static const struct wl_pointer_listener pointer_listener = {
{
close(fd);
- fprintf(stderr, "test-client: got keyboard keymap\n");
+ testlog("test-client: got keyboard keymap\n");
}
static void
else
keyboard->focus = NULL;
- fprintf(stderr, "test-client: got keyboard enter, surface %p\n",
+ testlog("test-client: got keyboard enter, surface %p\n",
keyboard->focus);
}
keyboard->focus = NULL;
- fprintf(stderr, "test-client: got keyboard leave, surface %p\n",
+ testlog("test-client: got keyboard leave, surface %p\n",
wl_surface ? wl_surface_get_user_data(wl_surface) : NULL);
}
keyboard->key_time_timespec = keyboard->input_timestamp;
keyboard->input_timestamp = (struct timespec) { 0 };
- fprintf(stderr, "test-client: got keyboard key %u %u\n", key, state);
+ testlog("test-client: got keyboard key %u %u\n", key, state);
}
static void
keyboard->mods_locked = mods_locked;
keyboard->group = group;
- fprintf(stderr, "test-client: got keyboard modifiers %u %u %u %u\n",
+ testlog("test-client: got keyboard modifiers %u %u %u %u\n",
mods_depressed, mods_latched, mods_locked, group);
}
keyboard->repeat_info.rate = rate;
keyboard->repeat_info.delay = delay;
- fprintf(stderr, "test-client: got keyboard repeat_info %d %d\n",
- rate, delay);
+ testlog("test-client: got keyboard repeat_info %d %d\n", rate, delay);
}
static const struct wl_keyboard_listener keyboard_listener = {
touch->down_time_timespec = touch->input_timestamp;
touch->input_timestamp = (struct timespec) { 0 };
- fprintf(stderr, "test-client: got touch down %d %d, surf: %p, id: %d\n",
+ testlog("test-client: got touch down %d %d, surf: %p, id: %d\n",
touch->down_x, touch->down_y, surface, id);
}
touch->up_time_timespec = touch->input_timestamp;
touch->input_timestamp = (struct timespec) { 0 };
- fprintf(stderr, "test-client: got touch up, id: %d\n", id);
+ testlog("test-client: got touch up, id: %d\n", id);
}
static void
touch->motion_time_timespec = touch->input_timestamp;
touch->input_timestamp = (struct timespec) { 0 };
- fprintf(stderr, "test-client: got touch motion, %d %d, id: %d\n",
+ testlog("test-client: got touch motion, %d %d, id: %d\n",
touch->x, touch->y, id);
}
++touch->frame_no;
- fprintf(stderr, "test-client: got touch frame (%d)\n", touch->frame_no);
+ testlog("test-client: got touch frame (%d)\n", touch->frame_no);
}
static void
++touch->cancel_no;
- fprintf(stderr, "test-client: got touch cancel (%d)\n", touch->cancel_no);
+ testlog("test-client: got touch cancel (%d)\n", touch->cancel_no);
}
static const struct wl_touch_listener touch_listener = {
surface->output = wl_output_get_user_data(output);
- fprintf(stderr, "test-client: got surface enter output %p\n",
- surface->output);
+ testlog("test-client: got surface enter output %p\n", surface->output);
}
static void
surface->output = NULL;
- fprintf(stderr, "test-client: got surface leave output %p\n",
+ testlog("test-client: got surface leave output %p\n",
wl_output_get_user_data(output));
}
test->pointer_x = wl_fixed_to_int(x);
test->pointer_y = wl_fixed_to_int(y);
- fprintf(stderr, "test-client: got global pointer %d %d\n",
+ testlog("test-client: got global pointer %d %d\n",
test->pointer_x, test->pointer_y);
}
{
struct test *test = data;
- printf("Screenshot has been captured\n");
+ testlog("Screenshot has been captured\n");
test->buffer_copy_done = 1;
}
if (input->seat_name && strcmp(input->seat_name, "test-seat") == 0)
input_update_devices(input);
- fprintf(stderr, "test-client: got seat %p capabilities: %x\n",
- input, caps);
+ testlog("test-client: got seat %p capabilities: %x\n", input, caps);
}
static void
input->client->input = input;
}
- fprintf(stderr, "test-client: got seat %p name: \'%s\'\n",
- input, name);
+ testlog("test-client: got seat %p name: \'%s\'\n", input, name);
}
static const struct wl_seat_listener seat_listener = {
/* check error */
if (errcode != code) {
- fprintf(stderr, "Should get error code %d but got %d\n",
- code, errcode);
+ testlog("Should get error code %d but got %d\n", code, errcode);
failed = 1;
}
assert(interface);
if (strcmp(intf->name, interface->name) != 0) {
- fprintf(stderr, "Should get interface '%s' but got '%s'\n",
+ testlog("Should get interface '%s' but got '%s'\n",
intf->name, interface->name);
failed = 1;
}
if (failed) {
- fprintf(stderr, "Expected other protocol error\n");
+ testlog("Expected other protocol error\n");
abort();
}
/* all OK */
- fprintf(stderr, "Got expected protocol error on '%s' (object id: %d) "
- "with code %d\n", interface->name, id, errcode);
+ testlog("Got expected protocol error on '%s' (object id: %d) "
+ "with code %d\n", interface->name, id, errcode);
}
static void
status = cairo_surface_write_to_png(cairo_surface, fname);
if (status != CAIRO_STATUS_SUCCESS) {
- fprintf(stderr, "Failed to save image '%s': %s\n", fname,
+ testlog("Failed to save image '%s': %s\n", fname,
cairo_status_to_string(status));
return false;
cairo_surface_flush(reference_cairo_surface);
status = cairo_surface_status(reference_cairo_surface);
if (status != CAIRO_STATUS_SUCCESS) {
- printf("Could not open %s: %s\n", fname, cairo_status_to_string(status));
+ testlog("Could not open %s: %s\n", fname,
+ cairo_status_to_string(status));
cairo_surface_destroy(reference_cairo_surface);
return NULL;
}