rendered paste bodyvoid
ldtp_gui_wait_till_gui_exist (LDTPClientContext* cctxt, LDTPErrorCode* err)
{
int time_wait = ldtp_gui_timeout;
time_t start, cur;
LDTPGuiHandle *accessible = NULL;
/*
Copied from LTFX source code
*/
start = cur = time (NULL);
if (cctxt->req->component) {
time_wait = atoi (cctxt->req->component);
if (!time_wait && !ldtp_gui_timeout)
time_wait = 30;
} else if (!ldtp_gui_timeout) {
time_wait = 30; // Max wait for 30 seconds
}
while ((difftime (cur, start) < time_wait) && (accessible == NULL)) {
ldtp_nsleep (0, 30000);
cur = time (NULL);
accessible = ldtp_gui_get_gui_handle (cctxt, err);
}
if (accessible == NULL)
*err = LDTP_ERROR_GUI_NOT_EXIST;
else {
Accessible_unref (accessible->handle);
g_free (accessible);
*err = LDTP_ERROR_SUCCESS;
}
}
void
ldtp_gui_wait_till_gui_not_exist (LDTPClientContext* cctxt, LDTPErrorCode* err)
{
int time_wait = ldtp_gui_timeout;
time_t start, cur;
LDTPGuiHandle *accessible = NULL;
/*
Copied from LTFX source code
*/
start = cur = time (NULL);
if (cctxt->req->component) {
time_wait = atoi (cctxt->req->component);
if (!time_wait && !ldtp_gui_timeout)
time_wait = 30;
} else if (!ldtp_gui_timeout) {
time_wait = 30; // Max wait for 30 seconds
}
accessible = ldtp_gui_get_gui_handle (cctxt, err);
while ((difftime (cur, start) < time_wait) && (accessible != NULL)) {
ldtp_nsleep (0, 30000);
cur = time (NULL);
if (accessible) {
Accessible_unref (accessible->handle);
g_free (accessible);
accessible = NULL;
}
accessible = ldtp_gui_get_gui_handle (cctxt, err);
}
if (accessible == NULL)
*err = LDTP_ERROR_SUCCESS;
else {
Accessible_unref (accessible->handle);
g_free (accessible);
*err = LDTP_ERROR_GUI_EXIST;
}
}