void timer_handler(AppContextRef ctx, AppTimerHandle handle, uint32_t cookie) { if(cookie == UPDATE_SCREEN_RATE_COOKIE) { if(window_manager_get_layers_to_process() != NOTHING_TO_UPDATE) { start_appropriate_update(); } start_timer((uint32_t)WAIT_ON_WINDOW_MS,UPDATE_SCREEN_RATE_COOKIE); } else if(cookie == WAIT_FOR_BUFFER_COOKIE) { send_buffer(); } else if(cookie == COLD_START_TIMER_COOKIE) { // only two layers not by a message window_manager_mark_layer_for_update(UPDATE_TIME | UPDATE_DATE); send_buffer(); // after startup communicate with phone start_timer((uint32_t)WAIT_ON_WINDOW_MS, UPDATE_SCREEN_RATE_COOKIE); } else if(cookie == SEND_TEXTER_MESSAGE_COOKIE) { send_request_for_texters(); } else if(cookie == SEND_MESSAGE_MESSAGE_COOKIE) { send_request_for_messages(); } else if(cookie == SEND_SMS_MESSAGE_COOKIE) { send_request_to_send_message(); } else if(cookie == RINGER_MAIN_COOKIE) { send_command_get_ringer_mode(); } else if(cookie == RINGER_GET_BUFFER_RETRY_COOKIE) { send_ringer_command(); } else if(cookie == SEND_APP_VERSION_COOKIE) { send_app_version(); } else if(cookie == SEND_COMMAND_RESPONSE_GAP_TIME_COOKIE) { if(get_state_machine() == AWAITING_RESPONSE) { resetStateMachine(); window_manager_set_state(WM_BAD); } } }
bool StateMachineRestartTest::runTest(NSFString& errorMessage) { startStateMachine(); // Test // state machine start up // initial state entering // null transition. // entry actions if (!testHarness.doesEventResultInState(NULL, &state1)) { errorMessage = "State Machine did not start properly."; stopStateMachine(); return false; } // Test // state machine event handling // triggered transitions // entry actions if (!testHarness.doesEventResultInState(&event1, &state2)) { errorMessage = "State Machine did not handle simple event triggered transition from state1 to state2"; stopStateMachine(); return false; } // Test // state machine event handling // triggered transitions // entry actions if (!testHarness.doesEventResultInState(&event2, &state3)) { errorMessage = "State Machine did not handle simple event triggered transition from state2 to state3"; stopStateMachine(); return false; } // Test // state machine event handling // triggered transitions // entry actions if (!testHarness.doesEventResultInState(&event1, &state2)) { errorMessage = "State Machine did not handle simple event triggered transition from state3 to state2"; stopStateMachine(); return false; } resetStateMachine(); // Test // state machine restart // initial state entering // null transition. // entry actions if (!testHarness.doesEventResultInState(NULL, &state1)) { errorMessage = "State Machine did not reset properly."; stopStateMachine(); return false; } // Test // state machine event handling // triggered transitions // entry actions if (!testHarness.doesEventResultInState(&event1, &state2)) { errorMessage = "State Machine did not handle simple event triggered transition from state1 to state2 after reset"; stopStateMachine(); return false; } stopStateMachine(); return true; }