Godot 4 automatic changes

This commit is contained in:
Daniel Inkpen 2022-11-09 20:57:46 +00:00
parent 8b5caafbc7
commit cdbf3f2adc
75 changed files with 1034 additions and 952 deletions

View file

@ -7,7 +7,7 @@ var terminal: Terminal
func before_each():
terminal = Terminal.new()
terminal.rect_size = Vector2(400, 200)
terminal.size = Vector2(400, 200)
add_child_autofree(terminal)
@ -18,7 +18,7 @@ func test_bell() -> void:
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)
await yield_to(terminal, "bell", 5).YIELD
assert_signal_emit_count(terminal, "bell", 5)
@ -27,15 +27,15 @@ func test_bell_cooldown() -> void:
terminal.bell_cooldown = 0.5
terminal.write("\a")
terminal.write("\a")
yield(yield_for(1), YIELD)
await yield_for(1).YIELD
terminal.write("\a")
yield(yield_to(terminal, "bell", 5), YIELD)
await yield_to(terminal, "bell", 5).YIELD
assert_signal_emit_count(terminal, "bell", 2)
func test_writing_random_data_to_terminal_does_not_crash_application():
add_child_autofree(preload("res://test/scenes/write_random.tscn").instance())
yield(yield_frames(5, "Writing random data to terminal"), YIELD)
add_child_autofree(preload("res://test/scenes/write_random.tscn").instantiate())
await yield_frames(5, "Writing random data to terminal").YIELD
assert_true(true, "Expected no crash when writing random data to terminal.")
@ -71,16 +71,16 @@ class TestTheme:
func _get_pixelv(src: Vector2) -> Color:
var screen := get_tree().root.get_texture().get_data()
screen.lock()
false # screen.lock() # TODOConverter40, Image no longer requires locking, `false` helps to not break one line if/else, so it can freely be removed
screen.flip_y()
var pixel := screen.get_pixelv(src)
screen.unlock()
false # screen.unlock() # TODOConverter40, Image no longer requires locking, `false` helps to not break one line if/else, so it can freely be removed
return pixel
func _check_colors(theme: Theme):
var cell_size := Vector2(
int(terminal.rect_size.x / terminal.get_cols()),
int(terminal.rect_size.y / terminal.get_rows())
int(terminal.size.x / terminal.get_cols()),
int(terminal.size.y / terminal.get_rows())
)
var src := cell_size / 2
@ -96,61 +96,61 @@ class TestTheme:
src += Vector2(cell_size.x, 0)
func before_each():
terminal = autofree(TestScene.instance())
yield(yield_frames(1), YIELD)
terminal = autofree(TestScene.instantiate())
await yield_frames(1).YIELD
func test_terminal_display_colors_from_default_theme():
terminal.theme = null
add_child(terminal)
yield(yield_to(terminal, "theme_changed", 5), YIELD)
await yield_to(terminal, "theme_changed", 5).YIELD
_check_colors(default_theme)
func test_terminal_displays_colors_from_theme():
terminal.theme = alt_theme
add_child(terminal)
yield(yield_to(terminal, "theme_changed", 5), YIELD)
await yield_to(terminal, "theme_changed", 5).YIELD
_check_colors(alt_theme)
func test_visible_characters_still_displayed_after_resize_with_default_theme():
terminal.theme = null
add_child(terminal)
yield(yield_frames(1), YIELD)
await yield_frames(1).YIELD
OS.window_size += Vector2(1, 0)
yield(yield_to(terminal, "size_changed", 5), YIELD)
await yield_to(terminal, "size_changed", 5).YIELD
_check_colors(default_theme)
func test_visible_characters_still_displayed_after_resize_with_custom_theme():
# Issue 57: https://github.com/lihop/godot-xterm/issues/57
terminal.theme = alt_theme
add_child(terminal)
yield(yield_to(terminal, "theme_changed", 5), YIELD)
await yield_to(terminal, "theme_changed", 5).YIELD
OS.window_size += Vector2(1, 0)
yield(yield_to(terminal, "size_changed", 5), YIELD)
await yield_to(terminal, "size_changed", 5).YIELD
_check_colors(alt_theme)
func test_updates_colors_after_theme_set():
# Issue 58: https://github.com/lihop/godot-xterm/issues/58
terminal.theme = null
add_child(terminal)
yield(yield_frames(1), YIELD)
await yield_frames(1).YIELD
terminal.theme = alt_theme
yield(yield_to(terminal, "theme_changed", 50), YIELD)
await yield_to(terminal, "theme_changed", 50).YIELD
_check_colors(alt_theme)
func test_updates_colors_after_theme_unset():
# Issue 58: https://github.com/lihop/godot-xterm/issues/58
terminal.theme = alt_theme
add_child(terminal)
yield(yield_to(terminal, "theme_changed", 5), YIELD)
await yield_to(terminal, "theme_changed", 5).YIELD
terminal.theme = null
yield(yield_to(terminal, "theme_changed", 5), YIELD)
await yield_to(terminal, "theme_changed", 5).YIELD
_check_colors(default_theme)
func test_updates_colors_after_theme_changed():
# Issue 58: https://github.com/lihop/godot-xterm/issues/58
terminal.theme = alt_theme
add_child(terminal)
yield(yield_to(terminal, "theme_changed", 5), YIELD)
await yield_to(terminal, "theme_changed", 5).YIELD
terminal.theme = default_theme
yield(yield_to(terminal, "theme_changed", 5), YIELD)
await yield_to(terminal, "theme_changed", 5).YIELD
_check_colors(default_theme)