[mutter] tests/frame-clock: Test delayed schedule update
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] tests/frame-clock: Test delayed schedule update
- Date: Thu, 2 Jul 2020 20:49:57 +0000 (UTC)
commit 51ee41ee4305c97df15153681e11264b67e33711
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Sat Mar 21 21:46:14 2020 +0100
tests/frame-clock: Test delayed schedule update
Check that the frame clock doesn't dispatch any updates early until
there is any scheduling.
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
src/tests/clutter/conform/frame-clock.c | 83 +++++++++++++++++++++++++++++++++
1 file changed, 83 insertions(+)
---
diff --git a/src/tests/clutter/conform/frame-clock.c b/src/tests/clutter/conform/frame-clock.c
index 63927ce0b9..1921ed760c 100644
--- a/src/tests/clutter/conform/frame-clock.c
+++ b/src/tests/clutter/conform/frame-clock.c
@@ -229,7 +229,90 @@ frame_clock_immediate_present (void)
g_object_unref (frame_clock);
}
+static gboolean
+schedule_update_timeout (gpointer user_data)
+{
+ ClutterFrameClock *frame_clock = user_data;
+
+ clutter_frame_clock_schedule_update (frame_clock);
+
+ return G_SOURCE_REMOVE;
+}
+
+static ClutterFrameResult
+delayed_damage_frame_clock_frame (ClutterFrameClock *frame_clock,
+ int64_t frame_count,
+ gpointer user_data)
+{
+ FrameClockTest *test = user_data;
+ GMainLoop *main_loop = test->main_loop;
+
+ g_assert_cmpint (frame_count, ==, expected_frame_count);
+
+ expected_frame_count++;
+
+ if (test_frame_count == 0)
+ {
+ g_main_loop_quit (main_loop);
+ return CLUTTER_FRAME_RESULT_IDLE;
+ }
+ else
+ {
+ test->fake_hw_clock->has_pending_present = TRUE;
+ }
+
+ test_frame_count--;
+
+ g_timeout_add (100, schedule_update_timeout, frame_clock);
+
+ return CLUTTER_FRAME_RESULT_PENDING_PRESENTED;
+}
+
+static const ClutterFrameListenerIface delayed_damage_frame_listener_iface = {
+ .frame = delayed_damage_frame_clock_frame,
+};
+
+static void
+frame_clock_delayed_damage (void)
+{
+ FrameClockTest test;
+ ClutterFrameClock *frame_clock;
+ int64_t before_us;
+ int64_t after_us;
+ FakeHwClock *fake_hw_clock;
+ GSource *source;
+
+ test_frame_count = 2;
+ expected_frame_count = 0;
+
+ test.main_loop = g_main_loop_new (NULL, FALSE);
+ frame_clock = clutter_frame_clock_new (refresh_rate,
+ &delayed_damage_frame_listener_iface,
+ &test);
+
+ fake_hw_clock = fake_hw_clock_new (frame_clock, NULL, NULL);
+ source = &fake_hw_clock->source;
+ g_source_attach (source, NULL);
+
+ test.fake_hw_clock = fake_hw_clock;
+
+ before_us = g_get_monotonic_time ();
+
+ clutter_frame_clock_schedule_update (frame_clock);
+ g_main_loop_run (test.main_loop);
+
+ after_us = g_get_monotonic_time ();
+
+ g_assert_cmpint (after_us - before_us, >, 100000 + refresh_interval_us);
+
+ g_main_loop_unref (test.main_loop);
+ g_object_unref (frame_clock);
+ g_source_destroy (source);
+ g_source_unref (source);
+}
+
CLUTTER_TEST_SUITE (
CLUTTER_TEST_UNIT ("/frame-clock/schedule-update", frame_clock_schedule_update)
CLUTTER_TEST_UNIT ("/frame-clock/immediate-present", frame_clock_immediate_present)
+ CLUTTER_TEST_UNIT ("/frame-clock/delayed-damage", frame_clock_delayed_damage)
)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]