mirror of
https://github.com/lihop/godot-xterm.git
synced 2025-05-23 11:15:32 +02:00
chore(test): update tests
Adds additional tests for the interface. Creates a new base test class GodotXtermTest that adds some additional assert methods. Tests inheriting from this should override the got_described_class() method. Add instance of the described class named 'subject' will be created and added to the scene tree before each test.
This commit is contained in:
parent
cb86cc95d7
commit
1a5f0f96da
5 changed files with 387 additions and 125 deletions
|
@ -1,21 +1,86 @@
|
|||
# SPDX-FileCopyrightText: 2024 Leroy Hopson <godot-xterm@leroy.nix.nz>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
class_name PTYTest extends "res://addons/gut/test.gd"
|
||||
|
||||
var pty: PTY
|
||||
class_name PTYTest extends GodotXtermTest
|
||||
|
||||
|
||||
func before_each():
|
||||
pty = PTY.new()
|
||||
add_child_autofree(pty)
|
||||
func get_described_class():
|
||||
return PTY
|
||||
|
||||
|
||||
class TestDefaults:
|
||||
class TestInterface:
|
||||
extends PTYTest
|
||||
|
||||
func test_default_env() -> void:
|
||||
assert_eq(pty.env, {"TERM": "xterm-256color", "COLORTERM": "truecolor"})
|
||||
## API V2.
|
||||
|
||||
func test_default_use_os_env() -> void:
|
||||
assert_eq(pty.use_os_env, true)
|
||||
# Properties.
|
||||
|
||||
# TODO: Implement cols property.
|
||||
func xtest_has_property_cols() -> void:
|
||||
assert_has_property_with_default_value("cols", 80)
|
||||
|
||||
func test_has_property_env() -> void:
|
||||
assert_has_property_with_default_value(
|
||||
"env", {"TERM": "xterm-256color", "COLORTERM": "truecolor"}
|
||||
)
|
||||
|
||||
# TODO: Implement rows property.
|
||||
func xtest_has_property_rows() -> void:
|
||||
assert_has_property_with_default_value("rows", 24)
|
||||
|
||||
# TODO: Implement terminal_path property.
|
||||
func xtest_has_property_terminal_path() -> void:
|
||||
assert_has_property("terminal_path")
|
||||
|
||||
func test_has_proprty_use_os_env() -> void:
|
||||
assert_has_property_with_default_value("use_os_env", true)
|
||||
|
||||
# Methods.
|
||||
|
||||
func test_has_method_fork():
|
||||
assert_has_method_with_return_type("fork", TYPE_INT)
|
||||
|
||||
func test_has_method_kill():
|
||||
assert_has_method_with_return_type("kill", TYPE_NIL)
|
||||
|
||||
func test_has_method_open():
|
||||
assert_has_method_with_return_type("open", TYPE_INT)
|
||||
|
||||
func test_has_method_resize():
|
||||
assert_has_method_with_return_type("resize", TYPE_NIL)
|
||||
|
||||
func test_has_method_resizev():
|
||||
assert_has_method_with_return_type("resizev", TYPE_NIL)
|
||||
|
||||
func test_has_method_write():
|
||||
assert_has_method_with_return_type("write", TYPE_NIL)
|
||||
|
||||
# Signals.
|
||||
|
||||
func test_has_signal_data_received() -> void:
|
||||
assert_has_signal(subject, "data_received")
|
||||
|
||||
func test_has_signal_exited() -> void:
|
||||
assert_has_signal(subject, "exited")
|
||||
|
||||
# Enums.
|
||||
|
||||
# Added SIGNAL_ prefix to name.
|
||||
func test_has_enum_signal():
|
||||
assert_eq(described_class.SIGNAL_SIGHUP, 1)
|
||||
assert_eq(described_class.SIGNAL_SIGINT, 2)
|
||||
assert_eq(described_class.SIGNAL_SIGQUIT, 3)
|
||||
assert_eq(described_class.SIGNAL_SIGILL, 4)
|
||||
assert_eq(described_class.SIGNAL_SIGTRAP, 5)
|
||||
assert_eq(described_class.SIGNAL_SIGABRT, 6)
|
||||
assert_eq(described_class.SIGNAL_SIGFPE, 8)
|
||||
assert_eq(described_class.SIGNAL_SIGKILL, 9)
|
||||
assert_eq(described_class.SIGNAL_SIGSEGV, 11)
|
||||
assert_eq(described_class.SIGNAL_SIGPIPE, 13)
|
||||
assert_eq(described_class.SIGNAL_SIGALRM, 14)
|
||||
assert_eq(described_class.SIGNAL_SIGTERM, 15)
|
||||
|
||||
## Other tests.
|
||||
|
||||
func test_has_no_visible_children():
|
||||
assert_eq(subject.get_child_count(), 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue