[PATCH weston 3/6] test: Add clock_settime()
Derek Foreman
derekf at osg.samsung.com
Fri Dec 19 10:45:47 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 | 4 ++++
src/compositor.c | 13 +++++++++++++
src/compositor.h | 4 ++++
tests/weston-test.c | 13 +++++++++++++
4 files changed, 34 insertions(+)
diff --git a/protocol/wayland-test.xml b/protocol/wayland-test.xml
index 7174907..7133555 100644
--- a/protocol/wayland-test.xml
+++ b/protocol/wayland-test.xml
@@ -60,5 +60,9 @@
</event>
<!-- interface version 2 -->
<request name="enable_test_mode"/>
+ <request name="clock_settime">
+ <arg name="sec" type="string"/>
+ <arg name="nsec" type="string"/>
+ </request>
</interface>
</protocol>
diff --git a/src/compositor.c b/src/compositor.c
index 6109eb5..61ba041 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -4233,6 +4233,19 @@ weston_compositor_presentation_clock_gettime(
}
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 924e354..17ce070 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -1281,6 +1281,10 @@ int
weston_compositor_presentation_clock_gettime(
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..ba37cdf 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
+settime(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,
+ settime,
};
static void
--
2.1.3
More information about the wayland-devel
mailing list