[PATCH weston 1/6] test: Add a compositor test-mode

Derek Foreman derekf at osg.samsung.com
Fri Dec 19 10:45:45 PST 2014


For now, the intention of test-mode is to have a way to allow a client
to control the presentation clock to allow capturing deterministic
screenshots during testing.

Once in test-mode you're trapped in test-mode forever.

Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
---
 protocol/wayland-test.xml |  4 +++-
 src/compositor.c          | 15 +++++++++++++++
 src/compositor.h          |  6 ++++++
 tests/weston-test.c       |  9 +++++++++
 4 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/protocol/wayland-test.xml b/protocol/wayland-test.xml
index 18b6625..7174907 100644
--- a/protocol/wayland-test.xml
+++ b/protocol/wayland-test.xml
@@ -26,7 +26,7 @@
     THIS SOFTWARE.
   </copyright>
 
-  <interface name="wl_test" version="1">
+  <interface name="wl_test" version="2">
     <request name="move_surface">
       <arg name="surface" type="object" interface="wl_surface"/>
       <arg name="x" type="int"/>
@@ -58,5 +58,7 @@
     <event name="n_egl_buffers">
       <arg name="n" type="uint"/>
     </event>
+    <!-- interface version 2 -->
+    <request name="enable_test_mode"/>
   </interface>
 </protocol>
diff --git a/src/compositor.c b/src/compositor.c
index b84658a..833cf51 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -4750,6 +4750,21 @@ weston_transform_to_string(uint32_t output_transform)
 	return "<illegal value>";
 }
 
+WL_EXPORT void
+weston_compositor_test_mode_enable(struct weston_compositor *compositor)
+{
+	weston_log("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
+	weston_log("Entering compositor test mode.\n");
+	weston_log("This should never be seen in normal operation.\n");
+	weston_log("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
+
+	/* set the test_mode flag first in case the callback follows
+	 * code paths that test it...
+	 */
+	compositor->test_mode = true;
+	if (compositor->enable_test_mode)
+		compositor->enable_test_mode(compositor);
+}
 
 int main(int argc, char *argv[])
 {
diff --git a/src/compositor.h b/src/compositor.h
index 3f7ed4a..2b99225 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -650,6 +650,7 @@ struct weston_compositor {
 	void (*destroy)(struct weston_compositor *ec);
 	void (*restore)(struct weston_compositor *ec);
 	int (*authenticate)(struct weston_compositor *c, uint32_t id);
+	void (*enable_test_mode)(struct weston_compositor *c);
 
 	struct weston_launcher *launcher;
 
@@ -668,6 +669,8 @@ struct weston_compositor {
 	clockid_t presentation_clock;
 
 	int exit_code;
+
+	bool test_mode;
 };
 
 struct weston_buffer {
@@ -1490,6 +1493,9 @@ weston_parse_transform(const char *transform, uint32_t *out);
 const char *
 weston_transform_to_string(uint32_t output_transform);
 
+void
+weston_compositor_test_mode_enable(struct weston_compositor *compositor);
+
 #ifdef  __cplusplus
 }
 #endif
diff --git a/tests/weston-test.c b/tests/weston-test.c
index 77eaa23..0a213b2 100644
--- a/tests/weston-test.c
+++ b/tests/weston-test.c
@@ -235,6 +235,14 @@ get_n_buffers(struct wl_client *client, struct wl_resource *resource)
 	wl_test_send_n_egl_buffers(resource, n_buffers);
 }
 
+static void
+enable_test_mode(struct wl_client *client, struct wl_resource *resource)
+{
+	struct weston_test *test = wl_resource_get_user_data(resource);
+
+	weston_compositor_test_mode_enable(test->compositor);
+}
+
 static const struct wl_test_interface test_implementation = {
 	move_surface,
 	move_pointer,
@@ -242,6 +250,7 @@ static const struct wl_test_interface test_implementation = {
 	activate_surface,
 	send_key,
 	get_n_buffers,
+	enable_test_mode,
 };
 
 static void
-- 
2.1.3



More information about the wayland-devel mailing list