Add tests for sms module + update Bessere Tests
Good that I decided to introduce unit tests to CORE because I found multiple issues in the Scene Manager which I was now able to fix. See52c6d029d9
,25c4667a05
and32b82c8f5b
.
This commit is contained in:
parent
2e3c5bf53d
commit
c64f40d0bf
4 changed files with 233 additions and 1 deletions
2
dist/submodules/besseretests
vendored
2
dist/submodules/besseretests
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 82cf251ecee89f3f2a575b1b322c1df48ea42aaf
|
||||
Subproject commit a58bfb23dc389ec60e3f45fbb0433e107755c4ea
|
5
tests/test_resources/scene.gd
Normal file
5
tests/test_resources/scene.gd
Normal file
|
@ -0,0 +1,5 @@
|
|||
extends Control
|
||||
|
||||
@onready var suite: BessereTestsTest = get_node_or_null("/root/suite_sms")
|
||||
|
||||
func _ready() -> void: suite.callback = "_ready"
|
12
tests/test_resources/scene.tscn
Normal file
12
tests/test_resources/scene.tscn
Normal file
|
@ -0,0 +1,12 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://cyixk2ixllyp5"]
|
||||
|
||||
[ext_resource type="Script" path="res://tests/test_resources/scene.gd" id="1_k6cu8"]
|
||||
|
||||
[node name="Scene" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_k6cu8")
|
215
tests/unit/sms.gd
Normal file
215
tests/unit/sms.gd
Normal file
|
@ -0,0 +1,215 @@
|
|||
extends 'res://tests/unitbase.gd'
|
||||
|
||||
var test_scene: Node = load("res://tests/test_resources/scene.tscn").instantiate()
|
||||
var test_scene_duplicate: Node
|
||||
|
||||
func after_each() -> void:
|
||||
if test_scene_duplicate != null: test_scene_duplicate.queue_free()
|
||||
await super()
|
||||
|
||||
func after_all() -> void: test_scene.queue_free()
|
||||
|
||||
func test_agr_debug() -> void:
|
||||
await load_framework()
|
||||
|
||||
test_scene_duplicate = test_scene.duplicate()
|
||||
core.sms.add_scene("test_scene", test_scene_duplicate, CoreTypes.SceneType.DEBUG)
|
||||
await wait_process_time()
|
||||
if callback != "_ready":
|
||||
rerror("Scene was not added")
|
||||
return
|
||||
if core.sms.get_scene("test_scene") == null:
|
||||
rerror("Got null from 'get_scene' method")
|
||||
return
|
||||
elif core.sms.get_scene("test_scene") != test_scene_duplicate:
|
||||
rerror("Got invalid node from 'get_scene' method")
|
||||
return
|
||||
core.sms.remove_scene("test_scene")
|
||||
|
||||
rok()
|
||||
|
||||
func test_agr_cutscene() -> void:
|
||||
await load_framework()
|
||||
|
||||
test_scene_duplicate = test_scene.duplicate()
|
||||
core.sms.add_scene("test_scene", test_scene_duplicate, CoreTypes.SceneType.CUTSCENE)
|
||||
await wait_process_time()
|
||||
if callback != "_ready":
|
||||
rerror("Scene was not added")
|
||||
return
|
||||
if core.sms.get_scene("test_scene") == null:
|
||||
rerror("Got null from 'get_scene' method")
|
||||
return
|
||||
elif core.sms.get_scene("test_scene") != test_scene_duplicate:
|
||||
rerror("Got invalid node from 'get_scene' method")
|
||||
return
|
||||
core.sms.remove_scene("test_scene")
|
||||
|
||||
rok()
|
||||
|
||||
func test_agr_menu() -> void:
|
||||
await load_framework()
|
||||
|
||||
test_scene_duplicate = test_scene.duplicate()
|
||||
core.sms.add_scene("test_scene", test_scene_duplicate, CoreTypes.SceneType.MENU)
|
||||
await wait_process_time()
|
||||
if callback != "_ready":
|
||||
rerror("Scene was not added")
|
||||
return
|
||||
if core.sms.get_scene("test_scene") == null:
|
||||
rerror("Got null from 'get_scene' method")
|
||||
return
|
||||
elif core.sms.get_scene("test_scene") != test_scene_duplicate:
|
||||
rerror("Got invalid node from 'get_scene' method")
|
||||
return
|
||||
core.sms.remove_scene("test_scene")
|
||||
|
||||
rok()
|
||||
|
||||
func test_agr_main() -> void:
|
||||
await load_framework()
|
||||
|
||||
test_scene_duplicate = test_scene.duplicate()
|
||||
core.sms.add_scene("test_scene", test_scene_duplicate, CoreTypes.SceneType.MAIN)
|
||||
await wait_process_time()
|
||||
if callback != "_ready":
|
||||
rerror("Scene was not added")
|
||||
return
|
||||
if core.sms.get_scene("test_scene") == null:
|
||||
rerror("Got null from 'get_scene' method")
|
||||
return
|
||||
elif core.sms.get_scene("test_scene") != test_scene_duplicate:
|
||||
rerror("Got invalid node from 'get_scene' method")
|
||||
return
|
||||
core.sms.remove_scene("test_scene")
|
||||
|
||||
rok()
|
||||
|
||||
func test_agr_background() -> void:
|
||||
await load_framework()
|
||||
|
||||
test_scene_duplicate = test_scene.duplicate()
|
||||
core.sms.add_scene("test_scene", test_scene_duplicate, CoreTypes.SceneType.BACKGROUND)
|
||||
await wait_process_time()
|
||||
if callback != "_ready":
|
||||
rerror("Scene was not added")
|
||||
return
|
||||
if core.sms.get_scene("test_scene") == null:
|
||||
rerror("Got null from 'get_scene' method")
|
||||
return
|
||||
elif core.sms.get_scene("test_scene") != test_scene_duplicate:
|
||||
rerror("Got invalid node from 'get_scene' method")
|
||||
return
|
||||
core.sms.remove_scene("test_scene")
|
||||
|
||||
rok()
|
||||
|
||||
func test_sc_debug() -> void:
|
||||
await load_framework()
|
||||
|
||||
if core.sms.get_scene_collection(CoreTypes.SceneType.DEBUG) == core.sms.scenes_debug: rok()
|
||||
else: rerror("Got invalid node from 'get_scene_collection' method")
|
||||
|
||||
func test_sc_cutscene() -> void:
|
||||
await load_framework()
|
||||
|
||||
if core.sms.get_scene_collection(CoreTypes.SceneType.CUTSCENE) == core.sms.scenes_cutscene: rok()
|
||||
else: rerror("Got invalid node from 'get_scene_collection' method")
|
||||
|
||||
func test_sc_menu() -> void:
|
||||
await load_framework()
|
||||
|
||||
if core.sms.get_scene_collection(CoreTypes.SceneType.MENU) == core.sms.scenes_menu: rok()
|
||||
else: rerror("Got invalid node from 'get_scene_collection' method")
|
||||
|
||||
func test_sc_main() -> void:
|
||||
await load_framework()
|
||||
|
||||
if core.sms.get_scene_collection(CoreTypes.SceneType.MAIN) == core.sms.scenes_main: rok()
|
||||
else: rerror("Got invalid node from 'get_scene_collection' method")
|
||||
|
||||
func test_sc_background() -> void:
|
||||
await load_framework()
|
||||
|
||||
if core.sms.get_scene_collection(CoreTypes.SceneType.BACKGROUND) == core.sms.scenes_background: rok()
|
||||
else: rerror("Got invalid node from 'get_scene_collection' method")
|
||||
|
||||
func test_sclistcount_debug() -> void:
|
||||
await load_framework()
|
||||
|
||||
test_scene_duplicate = test_scene.duplicate()
|
||||
core.sms.add_scene("test_scene", test_scene_duplicate, CoreTypes.SceneType.DEBUG)
|
||||
await wait_process_time()
|
||||
if callback != "_ready":
|
||||
rerror("Scene was not added")
|
||||
return
|
||||
|
||||
var test_sclist: Array[Node] = core.sms.get_scene_collection_list(CoreTypes.SceneType.DEBUG)
|
||||
if test_sclist.size() != 1: rerror("Method 'get_scene_collection_list' did not return '1' (returned '" + str(test_sclist.size()) + "')")
|
||||
elif test_sclist[0] != test_scene_duplicate: rerror("Method 'get_scene_collection_list' returned an invalid node (in Array[Node])")
|
||||
elif core.sms.get_scene_collection_count(CoreTypes.SceneType.DEBUG) != 1: rerror("Method 'get_scene_collection_count' did not return '1' (returned '" + str(core.sms.get_scene_collection_count(CoreTypes.SceneType.DEBUG)) + "'")
|
||||
else: rok()
|
||||
|
||||
func test_sclistcount_cutscene() -> void:
|
||||
await load_framework()
|
||||
|
||||
test_scene_duplicate = test_scene.duplicate()
|
||||
core.sms.add_scene("test_scene", test_scene_duplicate, CoreTypes.SceneType.CUTSCENE)
|
||||
await wait_process_time()
|
||||
if callback != "_ready":
|
||||
rerror("Scene was not added")
|
||||
return
|
||||
|
||||
var test_sclist: Array[Node] = core.sms.get_scene_collection_list(CoreTypes.SceneType.CUTSCENE)
|
||||
if test_sclist.size() != 1: rerror("Method 'get_scene_collection_list' did not return '1' (returned '" + str(test_sclist.size()) + "')")
|
||||
elif test_sclist[0] != test_scene_duplicate: rerror("Method 'get_scene_collection_list' returned an invalid node (in Array[Node])")
|
||||
elif core.sms.get_scene_collection_count(CoreTypes.SceneType.CUTSCENE) != 1: rerror("Method 'get_scene_collection_count' did not return '1' (returned '" + str(core.sms.get_scene_collection_count(CoreTypes.SceneType.CUTSCENE)) + "'")
|
||||
else: rok()
|
||||
|
||||
func test_sclistcount_menu() -> void:
|
||||
await load_framework()
|
||||
|
||||
test_scene_duplicate = test_scene.duplicate()
|
||||
core.sms.add_scene("test_scene", test_scene_duplicate, CoreTypes.SceneType.MENU)
|
||||
await wait_process_time()
|
||||
if callback != "_ready":
|
||||
rerror("Scene was not added")
|
||||
return
|
||||
|
||||
var test_sclist: Array[Node] = core.sms.get_scene_collection_list(CoreTypes.SceneType.MENU)
|
||||
if test_sclist.size() != 1: rerror("Method 'get_scene_collection_list' did not return '1' (returned '" + str(test_sclist.size()) + "')")
|
||||
elif test_sclist[0] != test_scene_duplicate: rerror("Method 'get_scene_collection_list' returned an invalid node (in Array[Node])")
|
||||
elif core.sms.get_scene_collection_count(CoreTypes.SceneType.MENU) != 1: rerror("Method 'get_scene_collection_count' did not return '1' (returned '" + str(core.sms.get_scene_collection_count(CoreTypes.SceneType.MENU)) + "'")
|
||||
else: rok()
|
||||
|
||||
func test_sclistcount_main() -> void:
|
||||
await load_framework()
|
||||
|
||||
test_scene_duplicate = test_scene.duplicate()
|
||||
core.sms.add_scene("test_scene", test_scene_duplicate, CoreTypes.SceneType.MAIN)
|
||||
await wait_process_time()
|
||||
if callback != "_ready":
|
||||
rerror("Scene was not added")
|
||||
return
|
||||
|
||||
var test_sclist: Array[Node] = core.sms.get_scene_collection_list(CoreTypes.SceneType.MAIN)
|
||||
if test_sclist.size() != 1: rerror("Method 'get_scene_collection_list' did not return '1' (returned '" + str(test_sclist.size()) + "')")
|
||||
elif test_sclist[0] != test_scene_duplicate: rerror("Method 'get_scene_collection_list' returned an invalid node (in Array[Node])")
|
||||
elif core.sms.get_scene_collection_count(CoreTypes.SceneType.MAIN) != 1: rerror("Method 'get_scene_collection_count' did not return '1' (returned '" + str(core.sms.get_scene_collection_count(CoreTypes.SceneType.MAIN)) + "'")
|
||||
else: rok()
|
||||
|
||||
func test_sclistcount_background() -> void:
|
||||
await load_framework()
|
||||
|
||||
test_scene_duplicate = test_scene.duplicate()
|
||||
core.sms.add_scene("test_scene", test_scene_duplicate, CoreTypes.SceneType.BACKGROUND)
|
||||
await wait_process_time()
|
||||
if callback != "_ready":
|
||||
rerror("Scene was not added")
|
||||
return
|
||||
|
||||
var test_sclist: Array[Node] = core.sms.get_scene_collection_list(CoreTypes.SceneType.BACKGROUND)
|
||||
if test_sclist.size() != 1: rerror("Method 'get_scene_collection_list' did not return '1' (returned '" + str(test_sclist.size()) + "')")
|
||||
elif test_sclist[0] != test_scene_duplicate: rerror("Method 'get_scene_collection_list' returned an invalid node (in Array[Node])")
|
||||
elif core.sms.get_scene_collection_count(CoreTypes.SceneType.BACKGROUND) != 1: rerror("Method 'get_scene_collection_count' did not return '1' (returned '" + str(core.sms.get_scene_collection_count(CoreTypes.SceneType.BACKGROUND)) + "'")
|
||||
else: rok()
|
Loading…
Reference in a new issue