tests: add scale and transform compositor options
authorPekka Paalanen <pekka.paalanen@collabora.com>
Wed, 22 Jan 2020 09:53:12 +0000 (11:53 +0200)
committerPekka Paalanen <pekka.paalanen@collabora.com>
Thu, 27 Feb 2020 14:08:42 +0000 (16:08 +0200)
With these, a test can initialize the headless-backend with non-default scale
and transform which allows testing output scales and transforms.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
tests/weston-test-fixture-compositor.c
tests/weston-test-fixture-compositor.h

index 0c8004b4c050deb9946c461d4db448069e0abb8a..da0fa26a93f629255b9e36dc5530e46205146fdd 100644 (file)
@@ -107,6 +107,8 @@ compositor_setup_defaults_(struct compositor_setup *setup,
                .xwayland = false,
                .width = 320,
                .height = 240,
+               .scale = 1,
+               .transform = WL_OUTPUT_TRANSFORM_NORMAL,
                .config_file = NULL,
                .extra_module = NULL,
                .logging_scopes = NULL,
@@ -163,6 +165,24 @@ shell_to_str(enum shell_type t)
        return names[t];
 }
 
+static const char *
+transform_to_str(enum wl_output_transform t)
+{
+       static const char * const names[] = {
+               [WL_OUTPUT_TRANSFORM_NORMAL] = "normal",
+               [WL_OUTPUT_TRANSFORM_90] = "rotate-90",
+               [WL_OUTPUT_TRANSFORM_180] = "rotate-180",
+               [WL_OUTPUT_TRANSFORM_270] = "rotate-270",
+               [WL_OUTPUT_TRANSFORM_FLIPPED] = "flipped",
+               [WL_OUTPUT_TRANSFORM_FLIPPED_90] = "flipped-rotate-90",
+               [WL_OUTPUT_TRANSFORM_FLIPPED_180] = "flipped-rotate-180",
+               [WL_OUTPUT_TRANSFORM_FLIPPED_270] = "flipped-rotate-270",
+       };
+
+       assert(t < ARRAY_LENGTH(names) && names[t]);
+       return names[t];
+}
+
 /** Execute compositor
  *
  * Manufactures the compositor command line and calls wet_main().
@@ -259,6 +279,17 @@ execute_compositor(const struct compositor_setup *setup,
        asprintf(&tmp, "--height=%d", setup->height);
        prog_args_take(&args, tmp);
 
+       if (setup->scale != 1) {
+               asprintf(&tmp, "--scale=%d", setup->scale);
+               prog_args_take(&args, tmp);
+       }
+
+       if (setup->transform != WL_OUTPUT_TRANSFORM_NORMAL) {
+               asprintf(&tmp, "--transform=%s",
+                        transform_to_str(setup->transform));
+               prog_args_take(&args, tmp);
+       }
+
        if (setup->config_file) {
                asprintf(&tmp, "--config=%s", setup->config_file);
                prog_args_take(&args, tmp);
index 6e8d680e2c3d42f0a35ce1de9003ddffe25ad9d4..fd8d0e5c6324f4d369d7940759764b4fcfba3613 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef WESTON_TEST_FIXTURE_COMPOSITOR_H
 #define WESTON_TEST_FIXTURE_COMPOSITOR_H
 
+#include <wayland-client-protocol.h>
 #include <libweston/libweston.h>
 
 #include "weston-testsuite-data.h"
@@ -82,6 +83,10 @@ struct compositor_setup {
        unsigned width;
        /** Default output height. */
        unsigned height;
+       /** Default output scale. */
+       int scale;
+       /** Default output transform, one of WL_OUTPUT_TRANSFORM_*. */
+       enum wl_output_transform transform;
        /** The absolute path to \c weston.ini to use,
         * or NULL for \c --no-config . */
        const char *config_file;
@@ -109,6 +114,8 @@ compositor_setup_defaults_(struct compositor_setup *setup,
  * - xwayland: no
  * - width: 320
  * - height: 240
+ * - scale: 1
+ * - transform: WL_OUTPUT_TRANSFORM_NORMAL
  * - config_file: none
  * - extra_module: none
  * - logging_scopes: compositor defaults