session-limits: Add mct_session_limits_is_enabled() API

This is a high-level API to indicate whether parental controls are
‘enabled’ for the given user. It’s a mirror of
`mct_app_filter_is_enabled()`, and exposes the existing
`time_limit_enabled_out` argument of
`mct_session_limits_check_time_remaining()` more conveniently.

Includes tests.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
Philip Withnall 2020-03-20 15:06:34 +00:00
parent f106319fdd
commit 04705c079a
3 changed files with 30 additions and 0 deletions

View file

@ -518,6 +518,7 @@ test_session_limits_bus_get (BusFixture *fixture,
/* Check the session limits properties. */
g_assert_cmpuint (mct_session_limits_get_user_id (session_limits), ==, fixture->valid_uid);
g_assert_true (mct_session_limits_is_enabled (session_limits));
g_assert_false (mct_session_limits_check_time_remaining (session_limits, usec (0),
&time_remaining_secs, &time_limit_enabled));
g_assert_true (time_limit_enabled);
@ -580,6 +581,7 @@ test_session_limits_bus_get_none (BusFixture *fixture,
/* Check the session limits properties. */
g_assert_cmpuint (mct_session_limits_get_user_id (session_limits), ==, fixture->valid_uid);
g_assert_false (mct_session_limits_is_enabled (session_limits));
g_assert_true (mct_session_limits_check_time_remaining (session_limits, usec (0),
&time_remaining_secs, &time_limit_enabled));
g_assert_false (time_limit_enabled);