M1b: Brücke und Hülle #6
@@ -46,6 +46,33 @@ func test_a_saved_game_is_continued_on_the_next_start() -> void:
|
||||
TestFiles.remove_dir(directory)
|
||||
|
||||
|
||||
func test_closing_the_window_saves_the_game_and_records_the_session() -> void:
|
||||
var directory := TestFiles.temporary_dir("close")
|
||||
var main := _start_main(directory)
|
||||
await tree.process_frame
|
||||
main.notification(Node.NOTIFICATION_WM_CLOSE_REQUEST)
|
||||
var store := SaveStore.new(directory)
|
||||
check(store.has_save(), "the game was saved")
|
||||
check_eq(store.recordings().size(), 1, "the session was recorded")
|
||||
_stop_main(main)
|
||||
TestFiles.remove_dir(directory)
|
||||
|
||||
|
||||
func test_the_game_is_saved_automatically_every_two_minutes() -> void:
|
||||
var directory := TestFiles.temporary_dir("autosave")
|
||||
var main := _start_main(directory)
|
||||
var store := SaveStore.new(directory)
|
||||
check(not store.has_save(), "there is no save at the start")
|
||||
# No frames are awaited, so only these ticks run.
|
||||
while main.session.tick() < main.AUTOSAVE_TICKS - 1:
|
||||
main._run_tick()
|
||||
check(not store.has_save(), "still no save one tick before the interval ends")
|
||||
main._run_tick()
|
||||
check(store.has_save(), "saved when the interval ends")
|
||||
_stop_main(main)
|
||||
TestFiles.remove_dir(directory)
|
||||
|
||||
|
||||
func test_an_unusable_save_is_set_aside_and_a_new_world_starts() -> void:
|
||||
var directory := TestFiles.temporary_dir("broken")
|
||||
var store := SaveStore.new(directory)
|
||||
|
||||
Reference in New Issue
Block a user