summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'Tests')
-rw-r--r--Tests/Game/test_CommandInputArea.gd (renamed from Tests/Game/test_Input.gd)23
-rw-r--r--Tests/Game/test_Game.gd50
-rw-r--r--Tests/Terminal/test_OutputArea.gd (renamed from Tests/Game/test_Output.gd)6
-rw-r--r--Tests/Terminal/test_OutputBlock.gd (renamed from Tests/Game/test_OutputBlock.gd)4
-rw-r--r--Tests/Terminal/test_StatusArea.gd (renamed from Tests/Game/test_StatusLine.gd)4
-rw-r--r--Tests/ui_helpers.gd3
6 files changed, 71 insertions, 19 deletions
diff --git a/Tests/Game/test_Input.gd b/Tests/Game/test_CommandInputArea.gd
index fca14e5..c233ec4 100644
--- a/Tests/Game/test_Input.gd
+++ b/Tests/Game/test_CommandInputArea.gd
@@ -1,7 +1,7 @@
extends GutTest
-const Scene = preload('res://Scenes/Game/Input.tscn')
-const GameInput = preload('res://Scripts/Game/Input.cs')
+const Scene = preload('res://Scenes/Game/CommandInputArea.tscn')
+const GameInput = preload('res://Scripts/Game/CommandInputArea.cs')
var _instance: GameInput = null
var _sender = InputSender.new(Input)
@@ -26,6 +26,9 @@ func after_each():
_sender.release_all()
_sender.clear()
+func before_all():
+ _sender.set_auto_flush_input(true)
+
func after_all():
assert_no_new_orphans()
@@ -43,44 +46,44 @@ func test_TextInput_has_focus_when_scene_is_instantiated():
func test_CommandSubmitted_signal_is_not_emitted_when_enter_is_pressed_without_text_in_TextInput():
watch_signals(_instance)
- yield(UiHelpers.press_key(_sender, KEY_ENTER), 'idle')
+ UiHelpers.press_key(_sender, KEY_ENTER)
assert_signal_not_emitted(_instance, _command_submitted)
func test_UknownInputSumbmitted_signal_is_not_emitted_when_enter_is_pressed_without_text_in_TextInput():
watch_signals(_instance)
- yield(UiHelpers.press_key(_sender, KEY_ENTER), 'idle')
+ UiHelpers.press_key(_sender, KEY_ENTER)
assert_signal_not_emitted(_instance, _unknown_input_submitted)
func test_CommandSubmitted_signal_is_emitted_when_enter_is_pressed_with_a_valid_command_in_TextInput():
watch_signals(_instance)
_set_input_text(_valid_input)
- yield(UiHelpers.press_key(_sender, KEY_ENTER), 'idle')
+ UiHelpers.press_key(_sender, KEY_ENTER)
assert_signal_emitted(_instance, _command_submitted)
func test_UnknownInputSubmitted_signal_is_not_emitted_when_enter_is_pressed_with_an_invalid_command_in_TextInput():
watch_signals(_instance)
_set_input_text(_valid_input)
- yield(UiHelpers.press_key(_sender, KEY_ENTER), 'idle')
+ UiHelpers.press_key(_sender, KEY_ENTER)
assert_signal_not_emitted(_instance, _unknown_input_submitted)
func test_CommandSubmitted_signal_is_not_emitted_when_enter_is_pressed_with_an_invalid_command_in_TextInput():
watch_signals(_instance)
_set_input_text(_invalid_input)
- yield(UiHelpers.press_key(_sender, KEY_ENTER), 'idle')
+ UiHelpers.press_key(_sender, KEY_ENTER)
assert_signal_not_emitted(_instance, _command_submitted)
func test_UnknownInputSubmitted_signal_is_emitted_when_enter_is_pressed_with_a_valid_command_in_TextInput():
watch_signals(_instance)
_set_input_text(_invalid_input)
- yield(UiHelpers.press_key(_sender, KEY_ENTER), 'idle')
+ UiHelpers.press_key(_sender, KEY_ENTER)
assert_signal_emitted(_instance, _unknown_input_submitted)
func test_TextInput_is_empty_after_submitting_a_valid_command():
_set_input_text(_valid_input)
- yield(UiHelpers.press_key(_sender, KEY_ENTER), 'idle')
+ UiHelpers.press_key(_sender, KEY_ENTER)
assert_true(_get_input_node().text.empty())
func test_TextInput_is_empty_after_submitting_an_invalid_command():
_set_input_text(_invalid_input)
- yield(UiHelpers.press_key(_sender, KEY_ENTER), 'idle')
+ UiHelpers.press_key(_sender, KEY_ENTER)
assert_true(_get_input_node().text.empty())
diff --git a/Tests/Game/test_Game.gd b/Tests/Game/test_Game.gd
new file mode 100644
index 0000000..427d28c
--- /dev/null
+++ b/Tests/Game/test_Game.gd
@@ -0,0 +1,50 @@
+extends GutTest
+
+const Scene = preload('res://Scenes/Game/Game.tscn')
+const Game = preload('res://Scripts/Game/Game.cs')
+
+const InputArea = preload('res://Scripts/Game/CommandInputArea.cs')
+const OutputArea = preload('res://Scripts/Terminal/OutputArea.cs')
+
+var _instance: Game = null
+var _sender = InputSender.new(Input)
+
+func _get_output_area() -> OutputArea:
+ return _instance.get_node('%OutputArea') as OutputArea
+
+func _get_input_area() -> InputArea:
+ return _instance.get_node('%InputArea') as InputArea
+
+func before_each():
+ _instance = add_child_autofree(Scene.instance())
+
+func after_each():
+ _sender.release_all()
+ _sender.clear()
+
+func before_all():
+ _sender.set_auto_flush_input(true)
+
+func after_all():
+ assert_no_new_orphans()
+
+func test_can_instantiate():
+ assert_not_null(_instance)
+
+func test_has_OutputArea():
+ assert_not_null(_get_output_area())
+
+func test_OutputArea_is_empty_after_instantiation():
+ assert_true(_get_output_area().TextBlocks.empty())
+
+func test_has_InputArea():
+ assert_not_null(_get_input_area())
+
+func test_InputArea_has_focus_after_instantiation():
+ assert_true(_get_input_area().HasFocus)
+
+func test_after_submitting_some_text_via_InputArea_OutputArea_is_not_empty():
+ var textInput = _get_input_area().get_node('%TextInput')
+ textInput.text = 'this is a test'
+ UiHelpers.press_key(_sender, KEY_ENTER)
+ assert_false(_get_output_area().TextBlocks.empty())
diff --git a/Tests/Game/test_Output.gd b/Tests/Terminal/test_OutputArea.gd
index f3793de..88beddb 100644
--- a/Tests/Game/test_Output.gd
+++ b/Tests/Terminal/test_OutputArea.gd
@@ -1,7 +1,7 @@
extends GutTest
-const Scene = preload('res://Scenes/Game/Output.tscn')
-const GameOutput = preload('res://Scripts/Game/Output.cs')
+const Scene = preload('res://Scenes/Terminal/OutputArea.tscn')
+const GameOutput = preload('res://Scripts/Terminal/OutputArea.cs')
var _instance: GameOutput = null
@@ -13,7 +13,7 @@ func after_each():
func before_each():
var scene = Scene.instance()
- scene.OutputBlockScene = load('res://Scenes/Game/OutputBlock.tscn')
+ scene.OutputBlockScene = preload('res://Scenes/Terminal/OutputBlock.tscn')
_instance = add_child_autofree(scene)
func after_all():
diff --git a/Tests/Game/test_OutputBlock.gd b/Tests/Terminal/test_OutputBlock.gd
index c7addfe..f586c55 100644
--- a/Tests/Game/test_OutputBlock.gd
+++ b/Tests/Terminal/test_OutputBlock.gd
@@ -1,7 +1,7 @@
extends GutTest
-const Scene = preload("res://Scenes/Game/OutputBlock.tscn")
-const OutputBlock = preload("res://Scripts/Game/OutputBlock.cs")
+const Scene = preload("res://Scenes/Terminal/OutputBlock.tscn")
+const OutputBlock = preload("res://Scripts/Terminal/OutputBlock.cs")
const _input_text_changed = 'InputTextChanged'
const _output_text_changed = 'OutputTextChanged'
diff --git a/Tests/Game/test_StatusLine.gd b/Tests/Terminal/test_StatusArea.gd
index b22f624..8277210 100644
--- a/Tests/Game/test_StatusLine.gd
+++ b/Tests/Terminal/test_StatusArea.gd
@@ -1,7 +1,7 @@
extends GutTest
-const Scene = preload("res://Scenes/Game/StatusLine.tscn")
-const StatusLine = preload("res://Scripts/Game/StatusLine.cs")
+const Scene = preload("res://Scenes/Terminal/StatusArea.tscn")
+const StatusLine = preload("res://Scripts/Terminal/StatusArea.cs")
var _instance: StatusLine = null
diff --git a/Tests/ui_helpers.gd b/Tests/ui_helpers.gd
index 858a639..96806b6 100644
--- a/Tests/ui_helpers.gd
+++ b/Tests/ui_helpers.gd
@@ -12,6 +12,5 @@ static func click_control(sender, control: Control):
static func press_key(sender, key):
sender.key_down(key) \
- .hold_for('1f') \
- .wait('1f')
+ .hold_for('1f')
return sender