Leandro Ribeiro | b1c529e | 2020-05-06 11:21:54 -0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2020 Collabora, Ltd. |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining |
| 5 | * a copy of this software and associated documentation files (the |
| 6 | * "Software"), to deal in the Software without restriction, including |
| 7 | * without limitation the rights to use, copy, modify, merge, publish, |
| 8 | * distribute, sublicense, and/or sell copies of the Software, and to |
| 9 | * permit persons to whom the Software is furnished to do so, subject to |
| 10 | * the following conditions: |
| 11 | * |
| 12 | * The above copyright notice and this permission notice (including the |
| 13 | * next paragraph) shall be included in all copies or substantial |
| 14 | * portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 20 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 21 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 22 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 23 | * SOFTWARE. |
| 24 | */ |
| 25 | |
| 26 | #include "config.h" |
| 27 | |
| 28 | #include "weston-test-client-helper.h" |
| 29 | #include "weston-test-fixture-compositor.h" |
| 30 | |
| 31 | static enum test_result_code |
| 32 | fixture_setup(struct weston_test_harness *harness) |
| 33 | { |
| 34 | struct compositor_setup setup; |
| 35 | |
| 36 | compositor_setup_defaults(&setup); |
| 37 | setup.shell = SHELL_TEST_DESKTOP; |
| 38 | setup.backend = WESTON_BACKEND_DRM; |
| 39 | setup.renderer = RENDERER_PIXMAN; |
| 40 | |
| 41 | return weston_test_harness_execute_as_client(harness, &setup); |
| 42 | } |
| 43 | DECLARE_FIXTURE_SETUP(fixture_setup); |
| 44 | |
| 45 | TEST(drm_smoke) { |
Leandro Ribeiro | b1c529e | 2020-05-06 11:21:54 -0300 | [diff] [blame] | 46 | struct client *client; |
| 47 | struct buffer *buffer; |
| 48 | struct wl_surface *surface; |
| 49 | pixman_color_t red; |
| 50 | int i, frame; |
| 51 | |
| 52 | color_rgb888(&red, 255, 0, 0); |
| 53 | |
| 54 | client = create_client_and_test_surface(0, 0, 200, 200); |
| 55 | assert(client); |
| 56 | |
| 57 | surface = client->surface->wl_surface; |
| 58 | buffer = create_shm_buffer_a8r8g8b8(client, 200, 200); |
| 59 | |
| 60 | fill_image_with_color(buffer->image, &red); |
| 61 | |
| 62 | for (i = 0; i < 5; i++) { |
| 63 | wl_surface_attach(surface, buffer->proxy, 0, 0); |
| 64 | wl_surface_damage(surface, 0, 0, 200, 200); |
| 65 | frame_callback_set(surface, &frame); |
| 66 | wl_surface_commit(surface); |
| 67 | frame_callback_wait(client, &frame); |
| 68 | } |
| 69 | |
Leandro Ribeiro | b985c6b | 2021-06-18 17:14:28 -0300 | [diff] [blame] | 70 | buffer_destroy(buffer); |
Leandro Ribeiro | b1c529e | 2020-05-06 11:21:54 -0300 | [diff] [blame] | 71 | client_destroy(client); |
| 72 | } |
Pekka Paalanen | 0f7da61 | 2020-12-04 16:12:33 +0200 | [diff] [blame] | 73 | |
| 74 | TEST(drm_screenshot_no_damage) { |
| 75 | struct client *client; |
| 76 | int i; |
| 77 | bool ret; |
| 78 | |
| 79 | client = create_client_and_test_surface(0, 0, 200, 200); |
| 80 | assert(client); |
| 81 | |
| 82 | /* |
| 83 | * DRM-backend has an optimization to not even call the renderer if |
| 84 | * there is no damage to be repainted on the primary plane occupied by |
| 85 | * renderer's buffer. However, renderer must be called for a screenshot |
| 86 | * to complete. |
| 87 | * |
| 88 | * Therefore, if there is no damage, it is possible that screenshots |
| 89 | * might get stuck. This test makes sure they run regardless. |
| 90 | */ |
| 91 | for (i = 0; i < 5; i++) { |
| 92 | ret = verify_screen_content(client, "drm_screenshot_no_damage", |
| 93 | 0, NULL, i); |
| 94 | assert(ret); |
| 95 | } |
| 96 | |
| 97 | client_destroy(client); |
| 98 | } |