Move terminal bell tests from unit -> integration

The bell tests rely on timers and yields, so are too slow to run as part
of the unit test suite.
This commit is contained in:
Leroy Hopson 2022-08-21 18:22:41 +12:00
parent 41525959e1
commit 344c04f9d8
No known key found for this signature in database
GPG key ID: D2747312A6DB51AA
2 changed files with 30 additions and 32 deletions

View file

@ -2,6 +2,36 @@ extends "res://addons/gut/test.gd"
const Terminal := preload("res://addons/godot_xterm/terminal.gd") const Terminal := preload("res://addons/godot_xterm/terminal.gd")
var terminal: Terminal
func before_each():
terminal = Terminal.new()
terminal.rect_size = Vector2(400, 200)
add_child_autofree(terminal)
func test_bell() -> void:
terminal.bell_cooldown = 0
terminal.write(char(7))
terminal.write(char(0x07))
terminal.write("\a")
terminal.write("\u0007")
terminal.write("'Ask not for whom the \a tolls; it tolls for thee' - John Donne")
yield(yield_to(terminal, "bell", 5), YIELD)
assert_signal_emit_count(terminal, "bell", 5)
func test_bell_cooldown() -> void:
watch_signals(terminal)
terminal.bell_cooldown = 0.5
terminal.write("\a")
terminal.write("\a")
yield(yield_for(1), YIELD)
terminal.write("\a")
yield(yield_to(terminal, "bell", 5), YIELD)
assert_signal_emit_count(terminal, "bell", 2)
func test_writing_random_data_to_terminal_does_not_crash_application(): func test_writing_random_data_to_terminal_does_not_crash_application():
add_child_autofree(preload("res://test/scenes/write_random.tscn").instance()) add_child_autofree(preload("res://test/scenes/write_random.tscn").instance())

View file

@ -1,37 +1,5 @@
extends "res://addons/gut/test.gd" extends "res://addons/gut/test.gd"
const Terminal := preload("res://addons/godot_xterm/terminal.gd")
var term: Terminal
func before_each():
term = Terminal.new()
term.rect_size = Vector2(400, 200)
add_child_autofree(term)
func test_bell() -> void:
term.bell_cooldown = 0
term.write(char(7))
term.write(char(0x07))
term.write("\a")
term.write("\u0007")
term.write("'Ask not for whom the \a tolls; it tolls for thee' - John Donne")
yield(yield_to(term, "bell", 5), YIELD)
assert_signal_emit_count(term, "bell", 5)
func test_bell_cooldown() -> void:
watch_signals(term)
term.bell_cooldown = 0.5
term.write("\a")
term.write("\a")
yield(yield_for(1), YIELD)
term.write("\a")
yield(yield_to(term, "bell", 5), YIELD)
assert_signal_emit_count(term, "bell", 2)
class TestMultipleInputs: class TestMultipleInputs:
# Tests for when Terminal is around other input nodes and arrow keys or TAB # Tests for when Terminal is around other input nodes and arrow keys or TAB