diff --git a/tests/api/controllers/robot_window_html/robot_window_html.c b/tests/api/controllers/robot_window_html/robot_window_html.c index 8c041f29152..6e046afab13 100644 --- a/tests/api/controllers/robot_window_html/robot_window_html.c +++ b/tests/api/controllers/robot_window_html/robot_window_html.c @@ -7,15 +7,13 @@ #define TIME_STEP 32 int main(int argc, char **argv) { - bool configured = false, received = false; ts_setup(argv[0]); - while (!configured) { // receive message sent by the robot window. + const char *configure_message; + for (;;) { // receive message sent by the robot window. wb_robot_step(TIME_STEP); - const char *configure_message; - while ((configure_message = wb_robot_wwi_receive_text())) { + if ((configure_message = wb_robot_wwi_receive_text())) { if (strcmp(configure_message, "configure") == 0) { - configured = true; wb_robot_wwi_send_text("test wwi functions from robot_window_html controller."); break; } else @@ -25,14 +23,13 @@ int main(int argc, char **argv) { printf("CONFIGURED!!!!\n"); - while (!received) { // receive message sent by Webots. + const char *test_message; + for (;;) { // receive message sent by Webots. wb_robot_step(TIME_STEP); - const char *test_message; - while ((test_message = wb_robot_wwi_receive_text())) { - if (strcmp(test_message, "Answer: test wwi functions from robot_window_html controller.") == 0) { - received = true; + if ((test_message = wb_robot_wwi_receive_text())) { + if (strcmp(test_message, "Answer: test wwi functions from robot_window_html controller.") == 0) break; - } else + else ts_send_error_and_exit("Wrong test message received from the HTML robot-window: %s", test_message); } }