231 lines
9.3 KiB
GDScript
231 lines
9.3 KiB
GDScript
# CORE FRAMEWORK TEST FILE
|
|
# Copyright (c) 2024 The StarOpenSource Project & Contributors
|
|
# Licensed under the GNU Affero General Public License v3
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
# License, or (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
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()
|