[PATCH weston v2 3/6] test: Add clock_settime()
Derek Foreman
derekf at osg.samsung.com
Mon Dec 22 14:09:58 PST 2014
Add a way to set the presentation clock to an arbitrary value, but only
when in test mode.
Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
---
protocol/wayland-test.xml | 9 +++++++++
src/compositor.c | 23 +++++++++++++++++++++++
src/compositor.h | 4 ++++
tests/weston-test.c | 13 +++++++++++++
4 files changed, 49 insertions(+)
diff --git a/protocol/wayland-test.xml b/protocol/wayland-test.xml
index 292abe9..70016ce 100644
--- a/protocol/wayland-test.xml
+++ b/protocol/wayland-test.xml
@@ -68,5 +68,14 @@
Once test mode is enabled it remains active for the life of the
compositor.
</description>
+ <request name="clock_settime">
+ <description summary="set the presentation clock time">
+ Sets the presentation clock time.
+
+ Requires compositor test mode to be active.
+ </description>
+ <arg name="sec" type="string" summary="whole part in seconds"/>
+ <arg name="nsec" type="string" summary="fractional part in seconds"/>
+ </request>
</interface>
</protocol>
diff --git a/src/compositor.c b/src/compositor.c
index d645391..6dd0be8 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -4242,6 +4242,29 @@ weston_compositor_presentation_clock_gettime(
return clock_gettime(compositor->presentation_clock, ts);
}
+/** Set the presentation clock time when in test mode.
+ *
+ * \param compositor The compositor object
+ * \param ts timespec to set the presentation clock to
+ *
+ * Fails when not in test mode. Sets the presentation clock
+ * time to the input timespec when in test mode.
+ *
+ * Returns 0 for success or -1 for failure.
+ */
+WL_EXPORT int
+weston_compositor_presentation_clock_settime(
+ struct weston_compositor *compositor,
+ const struct timespec *ts)
+{
+ if (!compositor->test_mode) {
+ weston_log("warning: attempt to control presentation clock outside of test mode\n");
+ return -1;
+ }
+ compositor->test_time = *ts;
+ return 0;
+}
+
WL_EXPORT int
weston_compositor_set_presentation_clock(struct weston_compositor *compositor,
clockid_t clk_id)
diff --git a/src/compositor.h b/src/compositor.h
index 1fcd067..49c1908 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -1281,6 +1281,10 @@ int
weston_compositor_presentation_clock_gettime(
const struct weston_compositor *compositor,
struct timespec *ts);
+int
+weston_compositor_presentation_clock_settime(
+ struct weston_compositor *compositor,
+ const struct timespec *ts);
void
weston_compositor_shutdown(struct weston_compositor *ec);
void
diff --git a/tests/weston-test.c b/tests/weston-test.c
index 0a213b2..cb53d71 100644
--- a/tests/weston-test.c
+++ b/tests/weston-test.c
@@ -243,6 +243,18 @@ enable_test_mode(struct wl_client *client, struct wl_resource *resource)
weston_compositor_test_mode_enable(test->compositor);
}
+static void
+set_time(struct wl_client *client, struct wl_resource *resource,
+ const char *sec, const char *nsec)
+{
+ struct weston_test *test = wl_resource_get_user_data(resource);
+ struct timespec ts;
+
+ ts.tv_sec = atoll(sec);
+ ts.tv_nsec = atoll(nsec);
+ weston_compositor_presentation_clock_settime(test->compositor, &ts);
+}
+
static const struct wl_test_interface test_implementation = {
move_surface,
move_pointer,
@@ -251,6 +263,7 @@ static const struct wl_test_interface test_implementation = {
send_key,
get_n_buffers,
enable_test_mode,
+ set_time,
};
static void
--
2.1.3
More information about the wayland-devel
mailing list