ssm: Remove delayed action GCancellable integration
Unfortunately, the implementation was not thread safe and was not sticking to the thread local main context. In addition to this, it is not entirely clear to me how this API should behave. The current approach is to simply cancel the transition with the state machine halting in its current state. Instead, it could also make sense for cancellation to cause the state machine to return a G_IO_ERROR_CANCELLED. As such, simply remove the feature for now. If anyone actually has a good use-case then we can add it again.
This commit is contained in:
parent
94e86875ae
commit
d683b271d4
11 changed files with 57 additions and 243 deletions
|
@ -760,7 +760,7 @@ calibrate_run_state (FpiSsm *ssm, FpDevice *dev)
|
||||||
if (self->calib_status == 0x00 &&
|
if (self->calib_status == 0x00 &&
|
||||||
self->last_read[0] == 0x01)
|
self->last_read[0] == 0x01)
|
||||||
self->calib_status = 0x01;
|
self->calib_status = 0x01;
|
||||||
fpi_ssm_next_state_delayed (ssm, 50, NULL);
|
fpi_ssm_next_state_delayed (ssm, 50);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -353,7 +353,7 @@ m_loop_state (FpiSsm *ssm, FpDevice *_dev)
|
||||||
{
|
{
|
||||||
case M_WAIT_PRINT:
|
case M_WAIT_PRINT:
|
||||||
/* Wait fingerprint scanning */
|
/* Wait fingerprint scanning */
|
||||||
fpi_ssm_next_state_delayed (ssm, NB1010_TRANSITION_DELAY, NULL);
|
fpi_ssm_next_state_delayed (ssm, NB1010_TRANSITION_DELAY);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case M_REQUEST_PRINT:
|
case M_REQUEST_PRINT:
|
||||||
|
|
|
@ -865,7 +865,7 @@ rebootpwr_run_state (FpiSsm *ssm, FpDevice *_dev)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fpi_ssm_jump_to_state_delayed (ssm, 10, REBOOTPWR_GET_HWSTAT, NULL);
|
fpi_ssm_jump_to_state_delayed (ssm, 10, REBOOTPWR_GET_HWSTAT);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -947,11 +947,11 @@ powerup_run_state (FpiSsm *ssm, FpDevice *_dev)
|
||||||
}
|
}
|
||||||
else if (!self->profile->auth_cr)
|
else if (!self->profile->auth_cr)
|
||||||
{
|
{
|
||||||
fpi_ssm_jump_to_state_delayed (ssm, POWERUP_SET_HWSTAT, 10, NULL);
|
fpi_ssm_jump_to_state_delayed (ssm, POWERUP_SET_HWSTAT, 10);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fpi_ssm_next_state_delayed (ssm, 10, NULL);
|
fpi_ssm_next_state_delayed (ssm, 10);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -613,7 +613,7 @@ activate_ssm (FpiSsm *ssm, FpDevice *dev)
|
||||||
clear_data (self);
|
clear_data (self);
|
||||||
|
|
||||||
/* Wait for probable vdev->active changing */
|
/* Wait for probable vdev->active changing */
|
||||||
fpi_ssm_next_state_delayed (ssm, VFS_SSM_TIMEOUT, NULL);
|
fpi_ssm_next_state_delayed (ssm, VFS_SSM_TIMEOUT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SSM_NEXT_RECEIVE:
|
case SSM_NEXT_RECEIVE:
|
||||||
|
@ -632,8 +632,7 @@ activate_ssm (FpiSsm *ssm, FpDevice *dev)
|
||||||
|
|
||||||
case SSM_WAIT_ANOTHER_SCAN:
|
case SSM_WAIT_ANOTHER_SCAN:
|
||||||
/* Orange light is on now */
|
/* Orange light is on now */
|
||||||
fpi_ssm_jump_to_state_delayed (ssm, SSM_TURN_ON, VFS_SSM_ORANGE_TIMEOUT,
|
fpi_ssm_jump_to_state_delayed (ssm, SSM_TURN_ON, VFS_SSM_ORANGE_TIMEOUT);
|
||||||
NULL);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -785,7 +785,7 @@ m_loop_state (FpiSsm *ssm, FpDevice *_dev)
|
||||||
|
|
||||||
case M_LOOP_0_SLEEP:
|
case M_LOOP_0_SLEEP:
|
||||||
/* Wait fingerprint scanning */
|
/* Wait fingerprint scanning */
|
||||||
fpi_ssm_next_state_delayed (ssm, 50, NULL);
|
fpi_ssm_next_state_delayed (ssm, 50);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case M_LOOP_0_GET_STATE:
|
case M_LOOP_0_GET_STATE:
|
||||||
|
@ -828,7 +828,7 @@ m_loop_state (FpiSsm *ssm, FpDevice *_dev)
|
||||||
img_extract (ssm, dev);
|
img_extract (ssm, dev);
|
||||||
|
|
||||||
/* Wait handling image */
|
/* Wait handling image */
|
||||||
fpi_ssm_next_state_delayed (ssm, 10, NULL);
|
fpi_ssm_next_state_delayed (ssm, 10);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case M_LOOP_0_CHECK_ACTION:
|
case M_LOOP_0_CHECK_ACTION:
|
||||||
|
@ -851,7 +851,7 @@ m_loop_state (FpiSsm *ssm, FpDevice *_dev)
|
||||||
if (vfs_finger_state (self) == VFS_FINGER_PRESENT)
|
if (vfs_finger_state (self) == VFS_FINGER_PRESENT)
|
||||||
{
|
{
|
||||||
fpi_image_device_report_finger_status (dev, TRUE);
|
fpi_image_device_report_finger_status (dev, TRUE);
|
||||||
fpi_ssm_next_state_delayed (ssm, 250, NULL);
|
fpi_ssm_next_state_delayed (ssm, 250);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -881,7 +881,7 @@ m_loop_state (FpiSsm *ssm, FpDevice *_dev)
|
||||||
|
|
||||||
case M_LOOP_1_SLEEP:
|
case M_LOOP_1_SLEEP:
|
||||||
/* Wait fingerprint scanning */
|
/* Wait fingerprint scanning */
|
||||||
fpi_ssm_next_state_delayed (ssm, 10, NULL);
|
fpi_ssm_next_state_delayed (ssm, 10);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case M_LOOP_2_ABORT_PRINT:
|
case M_LOOP_2_ABORT_PRINT:
|
||||||
|
@ -917,7 +917,7 @@ m_loop_state (FpiSsm *ssm, FpDevice *_dev)
|
||||||
{
|
{
|
||||||
/* Wait aborting */
|
/* Wait aborting */
|
||||||
self->counter++;
|
self->counter++;
|
||||||
fpi_ssm_next_state_delayed (ssm, 100, NULL);
|
fpi_ssm_next_state_delayed (ssm, 100);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1055,7 +1055,7 @@ m_init_state (FpiSsm *ssm, FpDevice *_dev)
|
||||||
{
|
{
|
||||||
/* Wait aborting */
|
/* Wait aborting */
|
||||||
self->counter++;
|
self->counter++;
|
||||||
fpi_ssm_next_state_delayed (ssm, 100, NULL);
|
fpi_ssm_next_state_delayed (ssm, 100);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1084,7 +1084,7 @@ m_init_state (FpiSsm *ssm, FpDevice *_dev)
|
||||||
{
|
{
|
||||||
/* Wait removing finger */
|
/* Wait removing finger */
|
||||||
self->counter++;
|
self->counter++;
|
||||||
fpi_ssm_next_state_delayed (ssm, 250, NULL);
|
fpi_ssm_next_state_delayed (ssm, 250);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -97,7 +97,7 @@ m_loop_state (FpiSsm *ssm, FpDevice *_dev)
|
||||||
|
|
||||||
case M_WAIT_PRINT:
|
case M_WAIT_PRINT:
|
||||||
/* Wait fingerprint scanning */
|
/* Wait fingerprint scanning */
|
||||||
fpi_ssm_next_state_delayed (ssm, 200, NULL);
|
fpi_ssm_next_state_delayed (ssm, 200);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case M_CHECK_PRINT:
|
case M_CHECK_PRINT:
|
||||||
|
@ -115,7 +115,7 @@ m_loop_state (FpiSsm *ssm, FpDevice *_dev)
|
||||||
|
|
||||||
case M_READ_PRINT_WAIT:
|
case M_READ_PRINT_WAIT:
|
||||||
/* Wait fingerprint scanning */
|
/* Wait fingerprint scanning */
|
||||||
fpi_ssm_next_state_delayed (ssm, 200, NULL);
|
fpi_ssm_next_state_delayed (ssm, 200);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case M_READ_PRINT_POLL:
|
case M_READ_PRINT_POLL:
|
||||||
|
|
|
@ -706,7 +706,7 @@ activate_loop (FpiSsm *ssm, FpDevice *_dev)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DEV_ACTIVATE_DATA_COMPLETE:
|
case DEV_ACTIVATE_DATA_COMPLETE:
|
||||||
fpi_ssm_next_state_delayed (ssm, 1, NULL);
|
fpi_ssm_next_state_delayed (ssm, 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DEV_ACTIVATE_PREPARE_NEXT_CAPTURE:
|
case DEV_ACTIVATE_PREPARE_NEXT_CAPTURE:
|
||||||
|
|
|
@ -487,7 +487,7 @@ deactivate_run_state (FpiSsm *ssm, FpDevice *_dev)
|
||||||
switch (fpi_ssm_get_cur_state (ssm))
|
switch (fpi_ssm_get_cur_state (ssm))
|
||||||
{
|
{
|
||||||
case DEACTIVATE_ENTER:
|
case DEACTIVATE_ENTER:
|
||||||
fpi_ssm_next_state_delayed (ssm, 10, NULL);
|
fpi_ssm_next_state_delayed (ssm, 10);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DEACTIVATE_DISABLE_SENSOR:
|
case DEACTIVATE_DISABLE_SENSOR:
|
||||||
|
|
|
@ -82,8 +82,6 @@ struct _FpiSsm
|
||||||
int cur_state;
|
int cur_state;
|
||||||
gboolean completed;
|
gboolean completed;
|
||||||
GSource *timeout;
|
GSource *timeout;
|
||||||
GCancellable *cancellable;
|
|
||||||
gulong cancellable_id;
|
|
||||||
GError *error;
|
GError *error;
|
||||||
FpiSsmCompletedCallback callback;
|
FpiSsmCompletedCallback callback;
|
||||||
FpiSsmHandlerCallback handler;
|
FpiSsmHandlerCallback handler;
|
||||||
|
@ -201,59 +199,13 @@ fpi_ssm_clear_delayed_action (FpiSsm *machine)
|
||||||
{
|
{
|
||||||
g_return_if_fail (machine);
|
g_return_if_fail (machine);
|
||||||
|
|
||||||
if (machine->cancellable_id)
|
|
||||||
{
|
|
||||||
g_cancellable_disconnect (machine->cancellable, machine->cancellable_id);
|
|
||||||
machine->cancellable_id = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_clear_object (&machine->cancellable);
|
|
||||||
g_clear_pointer (&machine->timeout, g_source_destroy);
|
g_clear_pointer (&machine->timeout, g_source_destroy);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct _CancelledActionIdleData
|
|
||||||
{
|
|
||||||
gulong cancellable_id;
|
|
||||||
GCancellable *cancellable;
|
|
||||||
} CancelledActionIdleData;
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
on_delayed_action_cancelled_idle (gpointer user_data)
|
|
||||||
{
|
|
||||||
CancelledActionIdleData *data = user_data;
|
|
||||||
|
|
||||||
g_cancellable_disconnect (data->cancellable, data->cancellable_id);
|
|
||||||
g_object_unref (data->cancellable);
|
|
||||||
g_free (data);
|
|
||||||
|
|
||||||
return G_SOURCE_REMOVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
on_delayed_action_cancelled (GCancellable *cancellable,
|
|
||||||
FpiSsm *machine)
|
|
||||||
{
|
|
||||||
CancelledActionIdleData *data;
|
|
||||||
|
|
||||||
fp_dbg ("[%s] %s cancelled delayed state change",
|
|
||||||
fp_device_get_driver (machine->dev), machine->name);
|
|
||||||
|
|
||||||
g_clear_pointer (&machine->timeout, g_source_destroy);
|
|
||||||
|
|
||||||
data = g_new0 (CancelledActionIdleData, 1);
|
|
||||||
data->cancellable = g_steal_pointer (&machine->cancellable);
|
|
||||||
data->cancellable_id = machine->cancellable_id;
|
|
||||||
machine->cancellable_id = 0;
|
|
||||||
|
|
||||||
g_idle_add_full (G_PRIORITY_HIGH_IDLE, on_delayed_action_cancelled_idle,
|
|
||||||
data, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fpi_ssm_set_delayed_action_timeout (FpiSsm *machine,
|
fpi_ssm_set_delayed_action_timeout (FpiSsm *machine,
|
||||||
int delay,
|
int delay,
|
||||||
FpTimeoutFunc callback,
|
FpTimeoutFunc callback,
|
||||||
GCancellable *cancellable,
|
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GDestroyNotify destroy_func)
|
GDestroyNotify destroy_func)
|
||||||
{
|
{
|
||||||
|
@ -264,16 +216,6 @@ fpi_ssm_set_delayed_action_timeout (FpiSsm *machine,
|
||||||
|
|
||||||
fpi_ssm_clear_delayed_action (machine);
|
fpi_ssm_clear_delayed_action (machine);
|
||||||
|
|
||||||
if (cancellable != NULL)
|
|
||||||
{
|
|
||||||
g_set_object (&machine->cancellable, cancellable);
|
|
||||||
|
|
||||||
machine->cancellable_id =
|
|
||||||
g_cancellable_connect (machine->cancellable,
|
|
||||||
G_CALLBACK (on_delayed_action_cancelled),
|
|
||||||
machine, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
machine->timeout = fpi_device_add_timeout (machine->dev, delay, callback,
|
machine->timeout = fpi_device_add_timeout (machine->dev, delay, callback,
|
||||||
user_data, destroy_func);
|
user_data, destroy_func);
|
||||||
}
|
}
|
||||||
|
@ -439,24 +381,21 @@ on_device_timeout_complete (FpDevice *dev,
|
||||||
* fpi_ssm_mark_completed_delayed:
|
* fpi_ssm_mark_completed_delayed:
|
||||||
* @machine: an #FpiSsm state machine
|
* @machine: an #FpiSsm state machine
|
||||||
* @delay: the milliseconds to wait before switching to the next state
|
* @delay: the milliseconds to wait before switching to the next state
|
||||||
* @cancellable: (nullable): a #GCancellable to cancel the delayed operation
|
|
||||||
*
|
*
|
||||||
* Mark a ssm as completed successfully with a delay of @delay ms.
|
* Mark a ssm as completed successfully with a delay of @delay ms.
|
||||||
* The callback set when creating the state machine with fpi_ssm_new () will be
|
* The callback set when creating the state machine with fpi_ssm_new () will be
|
||||||
* called when the timeout is over.
|
* called when the timeout is over.
|
||||||
* The request can be cancelled passing a #GCancellable as @cancellable.
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
fpi_ssm_mark_completed_delayed (FpiSsm *machine,
|
fpi_ssm_mark_completed_delayed (FpiSsm *machine,
|
||||||
int delay,
|
int delay)
|
||||||
GCancellable *cancellable)
|
|
||||||
{
|
{
|
||||||
g_autofree char *source_name = NULL;
|
g_autofree char *source_name = NULL;
|
||||||
|
|
||||||
g_return_if_fail (machine != NULL);
|
g_return_if_fail (machine != NULL);
|
||||||
|
|
||||||
fpi_ssm_set_delayed_action_timeout (machine, delay,
|
fpi_ssm_set_delayed_action_timeout (machine, delay,
|
||||||
on_device_timeout_complete, cancellable,
|
on_device_timeout_complete,
|
||||||
machine, NULL);
|
machine, NULL);
|
||||||
|
|
||||||
source_name = g_strdup_printf ("[%s] ssm %s complete %d",
|
source_name = g_strdup_printf ("[%s] ssm %s complete %d",
|
||||||
|
@ -551,25 +490,21 @@ on_device_timeout_next_state (FpDevice *dev,
|
||||||
* fpi_ssm_next_state_delayed:
|
* fpi_ssm_next_state_delayed:
|
||||||
* @machine: an #FpiSsm state machine
|
* @machine: an #FpiSsm state machine
|
||||||
* @delay: the milliseconds to wait before switching to the next state
|
* @delay: the milliseconds to wait before switching to the next state
|
||||||
* @cancellable: (nullable): a #GCancellable to cancel the delayed operation
|
|
||||||
*
|
*
|
||||||
* Iterate to next state of a state machine with a delay of @delay ms. If the
|
* Iterate to next state of a state machine with a delay of @delay ms. If the
|
||||||
* current state is the last state, then the state machine will be marked as
|
* current state is the last state, then the state machine will be marked as
|
||||||
* completed, as if calling fpi_ssm_mark_completed().
|
* completed, as if calling fpi_ssm_mark_completed().
|
||||||
* Passing a valid #GCancellable will cause the action to be cancelled when
|
|
||||||
* @cancellable is.
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
fpi_ssm_next_state_delayed (FpiSsm *machine,
|
fpi_ssm_next_state_delayed (FpiSsm *machine,
|
||||||
int delay,
|
int delay)
|
||||||
GCancellable *cancellable)
|
|
||||||
{
|
{
|
||||||
g_autofree char *source_name = NULL;
|
g_autofree char *source_name = NULL;
|
||||||
|
|
||||||
g_return_if_fail (machine != NULL);
|
g_return_if_fail (machine != NULL);
|
||||||
|
|
||||||
fpi_ssm_set_delayed_action_timeout (machine, delay,
|
fpi_ssm_set_delayed_action_timeout (machine, delay,
|
||||||
on_device_timeout_next_state, cancellable,
|
on_device_timeout_next_state,
|
||||||
machine, NULL);
|
machine, NULL);
|
||||||
|
|
||||||
source_name = g_strdup_printf ("[%s] ssm %s jump to next state %d",
|
source_name = g_strdup_printf ("[%s] ssm %s jump to next state %d",
|
||||||
|
@ -626,18 +561,14 @@ on_device_timeout_jump_to_state (FpDevice *dev,
|
||||||
* @machine: an #FpiSsm state machine
|
* @machine: an #FpiSsm state machine
|
||||||
* @state: the state to jump to
|
* @state: the state to jump to
|
||||||
* @delay: the milliseconds to wait before switching to @state state
|
* @delay: the milliseconds to wait before switching to @state state
|
||||||
* @cancellable: (nullable): a #GCancellable to cancel the delayed operation
|
|
||||||
*
|
*
|
||||||
* Jump to the @state state with a delay of @delay milliseconds, bypassing
|
* Jump to the @state state with a delay of @delay milliseconds, bypassing
|
||||||
* intermediary states.
|
* intermediary states.
|
||||||
* Passing a valid #GCancellable will cause the action to be cancelled when
|
|
||||||
* @cancellable is.
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
fpi_ssm_jump_to_state_delayed (FpiSsm *machine,
|
fpi_ssm_jump_to_state_delayed (FpiSsm *machine,
|
||||||
int state,
|
int state,
|
||||||
int delay,
|
int delay)
|
||||||
GCancellable *cancellable)
|
|
||||||
{
|
{
|
||||||
FpiSsmJumpToStateDelayedData *data;
|
FpiSsmJumpToStateDelayedData *data;
|
||||||
g_autofree char *source_name = NULL;
|
g_autofree char *source_name = NULL;
|
||||||
|
@ -651,7 +582,7 @@ fpi_ssm_jump_to_state_delayed (FpiSsm *machine,
|
||||||
|
|
||||||
fpi_ssm_set_delayed_action_timeout (machine, delay,
|
fpi_ssm_set_delayed_action_timeout (machine, delay,
|
||||||
on_device_timeout_jump_to_state,
|
on_device_timeout_jump_to_state,
|
||||||
cancellable, data, g_free);
|
data, g_free);
|
||||||
|
|
||||||
source_name = g_strdup_printf ("[%s] ssm %s jump to state %d",
|
source_name = g_strdup_printf ("[%s] ssm %s jump to state %d",
|
||||||
fp_device_get_device_id (machine->dev),
|
fp_device_get_device_id (machine->dev),
|
||||||
|
|
|
@ -76,18 +76,15 @@ void fpi_ssm_start_subsm (FpiSsm *parent,
|
||||||
void fpi_ssm_next_state (FpiSsm *machine);
|
void fpi_ssm_next_state (FpiSsm *machine);
|
||||||
void fpi_ssm_jump_to_state (FpiSsm *machine,
|
void fpi_ssm_jump_to_state (FpiSsm *machine,
|
||||||
int state);
|
int state);
|
||||||
void fpi_ssm_next_state_delayed (FpiSsm *machine,
|
void fpi_ssm_next_state_delayed (FpiSsm *machine,
|
||||||
int delay,
|
int delay);
|
||||||
GCancellable *cancellable);
|
void fpi_ssm_jump_to_state_delayed (FpiSsm *machine,
|
||||||
void fpi_ssm_jump_to_state_delayed (FpiSsm *machine,
|
int state,
|
||||||
int state,
|
int delay);
|
||||||
int delay,
|
|
||||||
GCancellable *cancellable);
|
|
||||||
void fpi_ssm_cancel_delayed_state_change (FpiSsm *machine);
|
void fpi_ssm_cancel_delayed_state_change (FpiSsm *machine);
|
||||||
void fpi_ssm_mark_completed (FpiSsm *machine);
|
void fpi_ssm_mark_completed (FpiSsm *machine);
|
||||||
void fpi_ssm_mark_completed_delayed (FpiSsm *machine,
|
void fpi_ssm_mark_completed_delayed (FpiSsm *machine,
|
||||||
int delay,
|
int delay);
|
||||||
GCancellable *cancellable);
|
|
||||||
void fpi_ssm_mark_failed (FpiSsm *machine,
|
void fpi_ssm_mark_failed (FpiSsm *machine,
|
||||||
GError *error);
|
GError *error);
|
||||||
void fpi_ssm_set_data (FpiSsm *machine,
|
void fpi_ssm_set_data (FpiSsm *machine,
|
||||||
|
|
|
@ -158,14 +158,6 @@ test_ssm_cancel_delayed_action_delayed (gpointer data)
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
test_ssm_cancel_cancellable_delayed (gpointer data)
|
|
||||||
{
|
|
||||||
g_cancellable_cancel (G_CANCELLABLE (data));
|
|
||||||
|
|
||||||
return G_SOURCE_REMOVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Tests */
|
/* Tests */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -339,7 +331,7 @@ test_ssm_next_with_delayed (void)
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
||||||
|
|
||||||
fpi_ssm_next_state_delayed (ssm, 10, NULL);
|
fpi_ssm_next_state_delayed (ssm, 10);
|
||||||
|
|
||||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*BUG:*timeout*");
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*BUG:*timeout*");
|
||||||
fpi_ssm_next_state (ssm);
|
fpi_ssm_next_state (ssm);
|
||||||
|
@ -447,7 +439,7 @@ test_ssm_jump_to_state_with_delayed (void)
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
||||||
|
|
||||||
fpi_ssm_jump_to_state_delayed (ssm, FPI_TEST_SSM_STATE_2, 10, NULL);
|
fpi_ssm_jump_to_state_delayed (ssm, FPI_TEST_SSM_STATE_2, 10);
|
||||||
|
|
||||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*BUG:*timeout*");
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*BUG:*timeout*");
|
||||||
fpi_ssm_jump_to_state (ssm, FPI_TEST_SSM_STATE_2);
|
fpi_ssm_jump_to_state (ssm, FPI_TEST_SSM_STATE_2);
|
||||||
|
@ -564,7 +556,7 @@ test_ssm_mark_completed_with_delayed (void)
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
||||||
|
|
||||||
data->expected_last_state = FPI_TEST_SSM_STATE_0;
|
data->expected_last_state = FPI_TEST_SSM_STATE_0;
|
||||||
fpi_ssm_mark_completed_delayed (ssm, 10, NULL);
|
fpi_ssm_mark_completed_delayed (ssm, 10);
|
||||||
|
|
||||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*BUG:*timeout*");
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*BUG:*timeout*");
|
||||||
fpi_ssm_mark_completed (g_steal_pointer (&ssm));
|
fpi_ssm_mark_completed (g_steal_pointer (&ssm));
|
||||||
|
@ -626,7 +618,7 @@ test_ssm_mark_failed_with_delayed (void)
|
||||||
fpi_ssm_start (ssm, test_ssm_completed_callback);
|
fpi_ssm_start (ssm, test_ssm_completed_callback);
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
||||||
|
|
||||||
fpi_ssm_mark_completed_delayed (ssm, 10, NULL);
|
fpi_ssm_mark_completed_delayed (ssm, 10);
|
||||||
|
|
||||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*BUG:*timeout*");
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*BUG:*timeout*");
|
||||||
data->expected_last_state = FPI_TEST_SSM_STATE_0;
|
data->expected_last_state = FPI_TEST_SSM_STATE_0;
|
||||||
|
@ -657,7 +649,7 @@ test_ssm_delayed_next (void)
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
||||||
|
|
||||||
fpi_ssm_next_state_delayed (ssm, 10, NULL);
|
fpi_ssm_next_state_delayed (ssm, 10);
|
||||||
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_0);
|
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_0);
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
||||||
|
@ -685,7 +677,7 @@ test_ssm_delayed_next_cancel (void)
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
||||||
|
|
||||||
fpi_ssm_next_state_delayed (ssm, 10, NULL);
|
fpi_ssm_next_state_delayed (ssm, 10);
|
||||||
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_0);
|
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_0);
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
||||||
|
@ -704,40 +696,6 @@ test_ssm_delayed_next_cancel (void)
|
||||||
g_assert_no_error (data->error);
|
g_assert_no_error (data->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
test_ssm_delayed_next_cancellable (void)
|
|
||||||
{
|
|
||||||
g_autoptr(FpiSsm) ssm = ssm_test_new ();
|
|
||||||
g_autoptr(GCancellable) cancellable = g_cancellable_new ();
|
|
||||||
FpiSsmTestData *data = fpi_ssm_get_data (ssm);
|
|
||||||
|
|
||||||
fpi_ssm_start (ssm, test_ssm_completed_callback);
|
|
||||||
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_0);
|
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
|
||||||
|
|
||||||
fpi_ssm_next_state_delayed (ssm, 10, cancellable);
|
|
||||||
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_0);
|
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
|
||||||
|
|
||||||
g_idle_add_full (G_PRIORITY_HIGH, test_ssm_cancel_cancellable_delayed, cancellable, NULL);
|
|
||||||
|
|
||||||
while (!g_cancellable_is_cancelled (cancellable))
|
|
||||||
g_main_context_iteration (NULL, TRUE);
|
|
||||||
|
|
||||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*BUG:*timeout*");
|
|
||||||
fpi_ssm_cancel_delayed_state_change (ssm);
|
|
||||||
g_test_assert_expected_messages ();
|
|
||||||
|
|
||||||
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_0);
|
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
|
||||||
|
|
||||||
g_assert_false (data->completed);
|
|
||||||
g_assert_no_error (data->error);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_ssm_delayed_next_not_started (void)
|
test_ssm_delayed_next_not_started (void)
|
||||||
{
|
{
|
||||||
|
@ -745,7 +703,7 @@ test_ssm_delayed_next_not_started (void)
|
||||||
FpiSsmTestData *data = fpi_ssm_get_data (ssm);
|
FpiSsmTestData *data = fpi_ssm_get_data (ssm);
|
||||||
|
|
||||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*BUG:*completed*");
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*BUG:*completed*");
|
||||||
fpi_ssm_next_state_delayed (ssm, 10, NULL);
|
fpi_ssm_next_state_delayed (ssm, 10);
|
||||||
g_test_assert_expected_messages ();
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
g_assert_cmpint (data->handler_state, ==, -1);
|
g_assert_cmpint (data->handler_state, ==, -1);
|
||||||
|
@ -776,7 +734,7 @@ test_ssm_delayed_next_complete (void)
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
||||||
|
|
||||||
fpi_ssm_next_state_delayed (ssm, 10, NULL);
|
fpi_ssm_next_state_delayed (ssm, 10);
|
||||||
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_0);
|
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_0);
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
||||||
|
@ -788,7 +746,7 @@ test_ssm_delayed_next_complete (void)
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_1);
|
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_1);
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 2);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 2);
|
||||||
|
|
||||||
fpi_ssm_next_state_delayed (ssm, 10, NULL);
|
fpi_ssm_next_state_delayed (ssm, 10);
|
||||||
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_1);
|
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_1);
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_1);
|
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_1);
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 2);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 2);
|
||||||
|
@ -800,7 +758,7 @@ test_ssm_delayed_next_complete (void)
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_2);
|
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_2);
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 3);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 3);
|
||||||
|
|
||||||
fpi_ssm_next_state_delayed (ssm, 10, NULL);
|
fpi_ssm_next_state_delayed (ssm, 10);
|
||||||
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_2);
|
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_2);
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_2);
|
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_2);
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 3);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 3);
|
||||||
|
@ -812,7 +770,7 @@ test_ssm_delayed_next_complete (void)
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_3);
|
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_3);
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 4);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 4);
|
||||||
|
|
||||||
fpi_ssm_next_state_delayed (ssm, 10, NULL);
|
fpi_ssm_next_state_delayed (ssm, 10);
|
||||||
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_3);
|
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_3);
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_3);
|
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_3);
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 4);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 4);
|
||||||
|
@ -838,7 +796,7 @@ test_ssm_delayed_jump_to_state (void)
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
||||||
|
|
||||||
fpi_ssm_jump_to_state_delayed (ssm, FPI_TEST_SSM_STATE_2, 10, NULL);
|
fpi_ssm_jump_to_state_delayed (ssm, FPI_TEST_SSM_STATE_2, 10);
|
||||||
|
|
||||||
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_0);
|
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_0);
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
||||||
|
@ -851,7 +809,7 @@ test_ssm_delayed_jump_to_state (void)
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_2);
|
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_2);
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 2);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 2);
|
||||||
|
|
||||||
fpi_ssm_jump_to_state_delayed (ssm, FPI_TEST_SSM_STATE_1, 10, NULL);
|
fpi_ssm_jump_to_state_delayed (ssm, FPI_TEST_SSM_STATE_1, 10);
|
||||||
|
|
||||||
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_2);
|
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_2);
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_2);
|
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_2);
|
||||||
|
@ -880,7 +838,7 @@ test_ssm_delayed_jump_to_state_cancel (void)
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
||||||
|
|
||||||
fpi_ssm_jump_to_state_delayed (ssm, FPI_TEST_SSM_STATE_2, 10, NULL);
|
fpi_ssm_jump_to_state_delayed (ssm, FPI_TEST_SSM_STATE_2, 10);
|
||||||
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_0);
|
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_0);
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
||||||
|
@ -899,40 +857,6 @@ test_ssm_delayed_jump_to_state_cancel (void)
|
||||||
g_assert_no_error (data->error);
|
g_assert_no_error (data->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
test_ssm_delayed_jump_to_state_cancellable (void)
|
|
||||||
{
|
|
||||||
g_autoptr(FpiSsm) ssm = ssm_test_new ();
|
|
||||||
g_autoptr(GCancellable) cancellable = g_cancellable_new ();
|
|
||||||
FpiSsmTestData *data = fpi_ssm_get_data (ssm);
|
|
||||||
|
|
||||||
fpi_ssm_start (ssm, test_ssm_completed_callback);
|
|
||||||
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_0);
|
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
|
||||||
|
|
||||||
fpi_ssm_jump_to_state_delayed (ssm, FPI_TEST_SSM_STATE_2, 10, cancellable);
|
|
||||||
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_0);
|
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
|
||||||
|
|
||||||
g_idle_add_full (G_PRIORITY_HIGH, test_ssm_cancel_cancellable_delayed, cancellable, NULL);
|
|
||||||
|
|
||||||
while (!g_cancellable_is_cancelled (cancellable))
|
|
||||||
g_main_context_iteration (NULL, TRUE);
|
|
||||||
|
|
||||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*BUG:*timeout*");
|
|
||||||
fpi_ssm_cancel_delayed_state_change (ssm);
|
|
||||||
g_test_assert_expected_messages ();
|
|
||||||
|
|
||||||
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_0);
|
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
|
||||||
|
|
||||||
g_assert_false (data->completed);
|
|
||||||
g_assert_no_error (data->error);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_ssm_delayed_jump_to_state_not_started (void)
|
test_ssm_delayed_jump_to_state_not_started (void)
|
||||||
{
|
{
|
||||||
|
@ -940,7 +864,7 @@ test_ssm_delayed_jump_to_state_not_started (void)
|
||||||
FpiSsmTestData *data = fpi_ssm_get_data (ssm);
|
FpiSsmTestData *data = fpi_ssm_get_data (ssm);
|
||||||
|
|
||||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*BUG:*completed*");
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*BUG:*completed*");
|
||||||
fpi_ssm_jump_to_state_delayed (ssm, FPI_TEST_SSM_STATE_2, 10, NULL);
|
fpi_ssm_jump_to_state_delayed (ssm, FPI_TEST_SSM_STATE_2, 10);
|
||||||
g_test_assert_expected_messages ();
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
g_assert_cmpint (data->handler_state, ==, -1);
|
g_assert_cmpint (data->handler_state, ==, -1);
|
||||||
|
@ -970,7 +894,7 @@ test_ssm_delayed_jump_to_state_last (void)
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
||||||
|
|
||||||
fpi_ssm_jump_to_state_delayed (ssm, FPI_TEST_SSM_STATE_3, 10, NULL);
|
fpi_ssm_jump_to_state_delayed (ssm, FPI_TEST_SSM_STATE_3, 10);
|
||||||
|
|
||||||
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_0);
|
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_0);
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
||||||
|
@ -999,7 +923,7 @@ test_ssm_delayed_jump_to_state_wrong (void)
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
||||||
|
|
||||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*BUG:*nr_states*");
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*BUG:*nr_states*");
|
||||||
fpi_ssm_jump_to_state_delayed (ssm, FPI_TEST_SSM_STATE_NUM + 10, 10, NULL);
|
fpi_ssm_jump_to_state_delayed (ssm, FPI_TEST_SSM_STATE_NUM + 10, 10);
|
||||||
g_test_assert_expected_messages ();
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_0);
|
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_0);
|
||||||
|
@ -1016,7 +940,7 @@ test_ssm_delayed_jump_to_state_wrong (void)
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 2);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 2);
|
||||||
|
|
||||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*BUG:*state*");
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*BUG:*state*");
|
||||||
fpi_ssm_jump_to_state_delayed (ssm, FPI_TEST_SSM_STATE_0 - 10, 10, NULL);
|
fpi_ssm_jump_to_state_delayed (ssm, FPI_TEST_SSM_STATE_0 - 10, 10);
|
||||||
g_test_assert_expected_messages ();
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_NUM + 10);
|
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_NUM + 10);
|
||||||
|
@ -1046,7 +970,7 @@ test_ssm_delayed_mark_completed (void)
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
||||||
|
|
||||||
data->expected_last_state = FPI_TEST_SSM_STATE_0;
|
data->expected_last_state = FPI_TEST_SSM_STATE_0;
|
||||||
fpi_ssm_mark_completed_delayed (g_steal_pointer (&ssm), 10, NULL);
|
fpi_ssm_mark_completed_delayed (g_steal_pointer (&ssm), 10);
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
||||||
|
|
||||||
while (g_slist_length (data->handlers_chain) == 1)
|
while (g_slist_length (data->handlers_chain) == 1)
|
||||||
|
@ -1066,7 +990,7 @@ test_ssm_delayed_mark_completed_not_started (void)
|
||||||
g_autoptr(FpiSsmTestData) data = fpi_ssm_test_data_ref (fpi_ssm_get_data (ssm));
|
g_autoptr(FpiSsmTestData) data = fpi_ssm_test_data_ref (fpi_ssm_get_data (ssm));
|
||||||
|
|
||||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*BUG:*completed*");
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*BUG:*completed*");
|
||||||
fpi_ssm_mark_completed_delayed (ssm, 10, NULL);
|
fpi_ssm_mark_completed_delayed (ssm, 10);
|
||||||
g_test_assert_expected_messages ();
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
g_timeout_add (100, G_SOURCE_FUNC (fpi_ssm_test_nullify_pointer), &ssm);
|
g_timeout_add (100, G_SOURCE_FUNC (fpi_ssm_test_nullify_pointer), &ssm);
|
||||||
|
@ -1093,7 +1017,7 @@ test_ssm_delayed_mark_completed_cancel (void)
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
||||||
|
|
||||||
fpi_ssm_mark_completed_delayed (ssm, 10, NULL);
|
fpi_ssm_mark_completed_delayed (ssm, 10);
|
||||||
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_0);
|
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_0);
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
||||||
|
@ -1113,40 +1037,6 @@ test_ssm_delayed_mark_completed_cancel (void)
|
||||||
g_assert_false (data->ssm_destroyed);
|
g_assert_false (data->ssm_destroyed);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
test_ssm_delayed_mark_completed_cancellable (void)
|
|
||||||
{
|
|
||||||
g_autoptr(FpiSsm) ssm = ssm_test_new ();
|
|
||||||
g_autoptr(GCancellable) cancellable = g_cancellable_new ();
|
|
||||||
FpiSsmTestData *data = fpi_ssm_get_data (ssm);
|
|
||||||
|
|
||||||
fpi_ssm_start (ssm, test_ssm_completed_callback);
|
|
||||||
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_0);
|
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
|
||||||
|
|
||||||
fpi_ssm_mark_completed_delayed (ssm, 10, cancellable);
|
|
||||||
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_0);
|
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
|
||||||
|
|
||||||
g_idle_add_full (G_PRIORITY_HIGH, test_ssm_cancel_cancellable_delayed, cancellable, NULL);
|
|
||||||
|
|
||||||
while (!g_cancellable_is_cancelled (cancellable))
|
|
||||||
g_main_context_iteration (NULL, TRUE);
|
|
||||||
|
|
||||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*BUG:*timeout*");
|
|
||||||
fpi_ssm_cancel_delayed_state_change (ssm);
|
|
||||||
g_test_assert_expected_messages ();
|
|
||||||
|
|
||||||
g_assert_cmpint (data->handler_state, ==, FPI_TEST_SSM_STATE_0);
|
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
|
||||||
|
|
||||||
g_assert_false (data->completed);
|
|
||||||
g_assert_no_error (data->error);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_ssm_delayed_cancel_error (void)
|
test_ssm_delayed_cancel_error (void)
|
||||||
{
|
{
|
||||||
|
@ -1320,7 +1210,7 @@ test_ssm_subssm_start_with_delayed (void)
|
||||||
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
g_assert_cmpint (fpi_ssm_get_cur_state (ssm), ==, FPI_TEST_SSM_STATE_0);
|
||||||
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
g_assert_cmpuint (g_slist_length (data->handlers_chain), ==, 1);
|
||||||
|
|
||||||
fpi_ssm_next_state_delayed (ssm, 10, NULL);
|
fpi_ssm_next_state_delayed (ssm, 10);
|
||||||
|
|
||||||
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*BUG:*timeout*");
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*BUG:*timeout*");
|
||||||
fpi_ssm_start_subsm (ssm, subssm);
|
fpi_ssm_start_subsm (ssm, subssm);
|
||||||
|
@ -1457,18 +1347,15 @@ main (int argc, char *argv[])
|
||||||
g_test_add_func ("/ssm/mark_failed/with_delayed", test_ssm_mark_failed_with_delayed);
|
g_test_add_func ("/ssm/mark_failed/with_delayed", test_ssm_mark_failed_with_delayed);
|
||||||
g_test_add_func ("/ssm/delayed/next", test_ssm_delayed_next);
|
g_test_add_func ("/ssm/delayed/next", test_ssm_delayed_next);
|
||||||
g_test_add_func ("/ssm/delayed/next/cancel", test_ssm_delayed_next_cancel);
|
g_test_add_func ("/ssm/delayed/next/cancel", test_ssm_delayed_next_cancel);
|
||||||
g_test_add_func ("/ssm/delayed/next/cancellable", test_ssm_delayed_next_cancellable);
|
|
||||||
g_test_add_func ("/ssm/delayed/next/not_started", test_ssm_delayed_next_not_started);
|
g_test_add_func ("/ssm/delayed/next/not_started", test_ssm_delayed_next_not_started);
|
||||||
g_test_add_func ("/ssm/delayed/next/complete", test_ssm_delayed_next_complete);
|
g_test_add_func ("/ssm/delayed/next/complete", test_ssm_delayed_next_complete);
|
||||||
g_test_add_func ("/ssm/delayed/jump_to_state", test_ssm_delayed_jump_to_state);
|
g_test_add_func ("/ssm/delayed/jump_to_state", test_ssm_delayed_jump_to_state);
|
||||||
g_test_add_func ("/ssm/delayed/jump_to_state/cancel", test_ssm_delayed_jump_to_state_cancel);
|
g_test_add_func ("/ssm/delayed/jump_to_state/cancel", test_ssm_delayed_jump_to_state_cancel);
|
||||||
g_test_add_func ("/ssm/delayed/jump_to_state/cancellable", test_ssm_delayed_jump_to_state_cancellable);
|
|
||||||
g_test_add_func ("/ssm/delayed/jump_to_state/not_started", test_ssm_delayed_jump_to_state_not_started);
|
g_test_add_func ("/ssm/delayed/jump_to_state/not_started", test_ssm_delayed_jump_to_state_not_started);
|
||||||
g_test_add_func ("/ssm/delayed/jump_to_state/last", test_ssm_delayed_jump_to_state_last);
|
g_test_add_func ("/ssm/delayed/jump_to_state/last", test_ssm_delayed_jump_to_state_last);
|
||||||
g_test_add_func ("/ssm/delayed/jump_to_state/wrong", test_ssm_delayed_jump_to_state_wrong);
|
g_test_add_func ("/ssm/delayed/jump_to_state/wrong", test_ssm_delayed_jump_to_state_wrong);
|
||||||
g_test_add_func ("/ssm/delayed/mark_completed", test_ssm_delayed_mark_completed);
|
g_test_add_func ("/ssm/delayed/mark_completed", test_ssm_delayed_mark_completed);
|
||||||
g_test_add_func ("/ssm/delayed/mark_completed/cancel", test_ssm_delayed_mark_completed_cancel);
|
g_test_add_func ("/ssm/delayed/mark_completed/cancel", test_ssm_delayed_mark_completed_cancel);
|
||||||
g_test_add_func ("/ssm/delayed/mark_completed/cancellable", test_ssm_delayed_mark_completed_cancellable);
|
|
||||||
g_test_add_func ("/ssm/delayed/mark_completed/not_started", test_ssm_delayed_mark_completed_not_started);
|
g_test_add_func ("/ssm/delayed/mark_completed/not_started", test_ssm_delayed_mark_completed_not_started);
|
||||||
g_test_add_func ("/ssm/delayed/cancel/error", test_ssm_delayed_cancel_error);
|
g_test_add_func ("/ssm/delayed/cancel/error", test_ssm_delayed_cancel_error);
|
||||||
g_test_add_func ("/ssm/subssm/start", test_ssm_subssm_start);
|
g_test_add_func ("/ssm/subssm/start", test_ssm_subssm_start);
|
||||||
|
|
Loading…
Reference in a new issue