added buggy crouching
This commit is contained in:
76
addons/dialogic-main/Tests/Unit/glossary_resource_test.gd
Normal file
76
addons/dialogic-main/Tests/Unit/glossary_resource_test.gd
Normal file
@@ -0,0 +1,76 @@
|
||||
## This test suite tests the DialogicGlossary class.
|
||||
extends GdUnitTestSuite
|
||||
|
||||
|
||||
const NAME_ENTRY := "Example Name"
|
||||
const EXAMPLE_TITLE := "Example Title"
|
||||
const ALTERNATIVE_ENTRIES := ["A", "BE", "VERY LONG ENTRY"]
|
||||
|
||||
const SAMPLE_ENTRY := {
|
||||
DialogicGlossary.TITLE_PROPERTY: EXAMPLE_TITLE,
|
||||
DialogicGlossary.NAME_PROPERTY: NAME_ENTRY,
|
||||
DialogicGlossary.ALTERNATIVE_PROPERTY: ALTERNATIVE_ENTRIES
|
||||
}
|
||||
|
||||
|
||||
## We test to add a glossary entry and whether the resulting states of the
|
||||
## glossary indicate that the entry was added correctly.
|
||||
func test_add_entry() -> void:
|
||||
var glossary: DialogicGlossary = DialogicGlossary.new()
|
||||
|
||||
assert(glossary.try_add_entry(SAMPLE_ENTRY), "Unable to add entry.")
|
||||
|
||||
const NAME_COUNTER := 1
|
||||
var total_entry_count := ALTERNATIVE_ENTRIES.size() + NAME_COUNTER
|
||||
|
||||
assert(glossary.entries.size() == total_entry_count, "Glossary should have 1 entry")
|
||||
assert(not glossary.get_entry(NAME_ENTRY).is_empty(), "Entry index cannot be found via entry name.")
|
||||
|
||||
for alternative: String in ALTERNATIVE_ENTRIES:
|
||||
var assert_error_message := "Entry index cannot be found via alternative name: " + alternative
|
||||
assert(not glossary.get_entry(alternative).is_empty(), assert_error_message)
|
||||
|
||||
|
||||
## We test whether an entry's key can be replaced and if the resulting action
|
||||
## invalidates the old entry key when accessing the glossary.
|
||||
func test_replace_entries() -> void:
|
||||
var glossary: DialogicGlossary = DialogicGlossary.new()
|
||||
|
||||
assert(glossary.try_add_entry(SAMPLE_ENTRY), "Unable to add entry.")
|
||||
|
||||
const NEW_NAME := "NEW NAME"
|
||||
|
||||
glossary.replace_entry_key(NAME_ENTRY, NEW_NAME)
|
||||
|
||||
var entry := glossary.get_entry(NEW_NAME)
|
||||
var error := "Entry expected to be non-empty, was empty."
|
||||
assert(not entry.is_empty(), error)
|
||||
|
||||
var old_entry := glossary.get_entry(NAME_ENTRY)
|
||||
error = "Entry expected to be empty, was an instance."
|
||||
assert(old_entry.is_empty(), error)
|
||||
|
||||
|
||||
## We test whether adding and deleting entries work.
|
||||
func test_remove_entry() -> void:
|
||||
var glossary: DialogicGlossary = DialogicGlossary.new()
|
||||
|
||||
assert(glossary.try_add_entry(SAMPLE_ENTRY), "Unable to add entry.")
|
||||
|
||||
const NAME_COUNTER := 1
|
||||
var total_entry_count := ALTERNATIVE_ENTRIES.size() + NAME_COUNTER
|
||||
|
||||
assert(glossary.entries.size() == total_entry_count, "Glossary should have " + str(total_entry_count) + " entries.")
|
||||
|
||||
var remove_result: bool = glossary.remove_entry(NAME_ENTRY)
|
||||
|
||||
assert(remove_result, "Removal of entry failed.")
|
||||
assert(glossary.get_entry(NAME_ENTRY).is_empty(), "Entry should not exist.")
|
||||
assert(glossary.entries.size() == 0, "Glossary should have 0 entries but has " + str(glossary.entries.size()) + " entries.")
|
||||
|
||||
|
||||
func test_add_duplicates() -> void:
|
||||
var glossary: DialogicGlossary = DialogicGlossary.new()
|
||||
|
||||
assert(glossary.try_add_entry(SAMPLE_ENTRY), "Unable to add entry.")
|
||||
assert(not glossary.try_add_entry(SAMPLE_ENTRY), "Entry should not have been added.")
|
@@ -0,0 +1,40 @@
|
||||
extends GdUnitTestSuite
|
||||
|
||||
## Check if transition animations can be accessed with "in", "out, "in out"
|
||||
## as space-delimited prefix.
|
||||
func test_fade_in_animation_paths() -> void:
|
||||
const TYPE := "PortraitAnimation"
|
||||
var fade_in_1: String = DialogicResourceUtil.guess_special_resource(TYPE, "fade in").get('path', "")
|
||||
var fade_in_2: String = DialogicResourceUtil.guess_special_resource(TYPE, "fade cross").get('path', "")
|
||||
var fade_in_3: String = DialogicResourceUtil.guess_special_resource(TYPE, "fade out").get('path', "")
|
||||
|
||||
var is_any_fade_in_empty := fade_in_1.is_empty() or fade_in_2.is_empty() or fade_in_3.is_empty()
|
||||
assert(is_any_fade_in_empty == false, "Fade In/Out animations are empty.")
|
||||
|
||||
var are_all_fade_in_equal := fade_in_1 == fade_in_2 and fade_in_2 == fade_in_3
|
||||
assert(are_all_fade_in_equal == true, "Fade In/Out animations returned different paths.")
|
||||
|
||||
|
||||
## Test if invalid animation paths will return empty strings.
|
||||
func test_invalid_animation_path() -> void:
|
||||
const TYPE := "PortraitAnimation"
|
||||
var invalid_animation_1: String = DialogicResourceUtil.guess_special_resource(TYPE, "fade i").get('path', "")
|
||||
assert(invalid_animation_1.is_empty() == true, "Invalid animation 1's path is not empty.")
|
||||
|
||||
|
||||
var invalid_animation_2: String = DialogicResourceUtil.guess_special_resource(TYPE, "fade").get('path', "")
|
||||
assert(invalid_animation_2.is_empty() == true, "Invalid animation 2's path is not empty.")
|
||||
|
||||
|
||||
## Test if invalid types will return empty strings.
|
||||
func test_invalid_type_path() -> void:
|
||||
const INVALID_TYPE := "Portait Animation"
|
||||
var invalid_animation: String = DialogicResourceUtil.guess_special_resource(INVALID_TYPE, "fade in").get('path', "")
|
||||
assert(invalid_animation.is_empty() == true, "Invalid animation 1's path is not empty.")
|
||||
|
||||
const VALID_TYPE := "PortraitAnimation"
|
||||
var valid_animation_path: String = DialogicResourceUtil.guess_special_resource(VALID_TYPE, "fade in").get('path', "")
|
||||
assert(valid_animation_path.is_empty() == false, "Valids animation's path is empty.")
|
||||
|
||||
assert(not invalid_animation == valid_animation_path, "Valid and invalid animation paths are equal.")
|
||||
|
51
addons/dialogic-main/Tests/Unit/subsystem_history_test.gd
Normal file
51
addons/dialogic-main/Tests/Unit/subsystem_history_test.gd
Normal file
@@ -0,0 +1,51 @@
|
||||
extends GdUnitTestSuite
|
||||
|
||||
var history := Dialogic.History
|
||||
|
||||
const EXAMPLE_SEEN_HISTORY: Dictionary = {
|
||||
"res://Dialogic/Timelines/start.dtl1": 1,
|
||||
"res://Dialogic/Timelines/start.dtl2": 2,
|
||||
"res://Dialogic/Timelines/start.dtl3": 3,
|
||||
"res://Dialogic/Timelines/start.dtl4": 4,
|
||||
"res://Dialogic/Timelines/start.dtl5": 5,
|
||||
"res://Dialogic/Timelines/start.dtl7": 7
|
||||
}
|
||||
|
||||
func test_save_load_visited() -> void:
|
||||
assert(history.visited_event_history_content == {}, "Seen events should have be empty.")
|
||||
history.load_visited_history()
|
||||
assert(history.visited_event_history_content == {}, "Seen events should have be empty after empty load.")
|
||||
|
||||
history.visited_event_history_content = EXAMPLE_SEEN_HISTORY
|
||||
assert(history.visited_event_history_content == EXAMPLE_SEEN_HISTORY, "Seen events should have be identical to test data.")
|
||||
|
||||
history.save_visited_history()
|
||||
var global_data_seen_events: Dictionary = history.get_saved_visited_history()
|
||||
|
||||
assert(global_data_seen_events == EXAMPLE_SEEN_HISTORY, "Global data does not have example data.")
|
||||
|
||||
history.load_visited_history()
|
||||
assert(history.visited_event_history_content == EXAMPLE_SEEN_HISTORY, "Seen events should have be identical to test data after load.")
|
||||
|
||||
|
||||
func test_deletion_save_visited() -> void:
|
||||
history.visited_event_history_content = EXAMPLE_SEEN_HISTORY
|
||||
assert(history.visited_event_history_content == EXAMPLE_SEEN_HISTORY, "Seen events should have be identical to test data.")
|
||||
|
||||
history.save_visited_history()
|
||||
var global_data_seen_events: Dictionary = history.get_saved_visited_history()
|
||||
assert(global_data_seen_events == EXAMPLE_SEEN_HISTORY, "Global data does not have example data.")
|
||||
|
||||
history.reset_visited_history(false)
|
||||
var global_data_seen_events_after_reset: Dictionary = history.get_saved_visited_history()
|
||||
assert(history.visited_event_history_content == EXAMPLE_SEEN_HISTORY, "Seen events are gone after global data only reset.")
|
||||
assert(global_data_seen_events_after_reset == {}, "Global data should be empty after reset.")
|
||||
|
||||
history.load_visited_history()
|
||||
assert(history.visited_event_history_content == {}, "Seen events should have be empty after empty load.")
|
||||
|
||||
history.visited_event_history_content = EXAMPLE_SEEN_HISTORY
|
||||
history.reset_visited_history(true)
|
||||
var global_data_seen_events_after_full_reset: Dictionary = history.get_saved_visited_history()
|
||||
assert(global_data_seen_events_after_full_reset == {}, "Seen events in global data should have be empty after full data reset.")
|
||||
assert(history.visited_event_history_content == {}, "Seen events in history should have be empty after full data reset.")
|
27
addons/dialogic-main/Tests/Unit/subsystem_text_test.gd
Normal file
27
addons/dialogic-main/Tests/Unit/subsystem_text_test.gd
Normal file
@@ -0,0 +1,27 @@
|
||||
extends GdUnitTestSuite
|
||||
|
||||
const VALID_SPEAKER_PATH := "res://Tests/Resources/unit_test_character.dch"
|
||||
|
||||
## We ensure that missing a speaker will return null.
|
||||
func test_missing_current_speaker() -> void:
|
||||
var null_speaker := DialogicUtil.autoload().Text.get_current_speaker()
|
||||
|
||||
assert(null_speaker == null, "Current speaker is not null.")
|
||||
|
||||
|
||||
## We ensure invalid speaker paths return the correct value.
|
||||
func test_set_invalid_current_speaker() -> void:
|
||||
DialogicUtil.autoload().current_state_info["speaker"] = "Invalid Speaker Path"
|
||||
var current_speaker := DialogicUtil.autoload().Text.get_current_speaker()
|
||||
|
||||
assert(current_speaker == null, "Invalid speaker must be invalid, but is valid.")
|
||||
|
||||
|
||||
## We ensure valid speaker paths return a valid [class DialogicCharacter] and
|
||||
## the path is set correctly.
|
||||
func test_set_valid_current_speaker() -> void:
|
||||
DialogicUtil.autoload().current_state_info["speaker"] = VALID_SPEAKER_PATH
|
||||
var current_speaker := DialogicUtil.autoload().Text.get_current_speaker()
|
||||
|
||||
assert(not current_speaker == null, "Valid speaker must be valid, but is invalid.")
|
||||
assert(current_speaker.get_path() == VALID_SPEAKER_PATH, "Valid speaker path is not set correctly.")
|
19
addons/dialogic-main/Tests/Unit/test_auto_advance.gd
Normal file
19
addons/dialogic-main/Tests/Unit/test_auto_advance.gd
Normal file
@@ -0,0 +1,19 @@
|
||||
extends GdUnitTestSuite
|
||||
|
||||
## Ensure Auto-Advance is enabled properly using the user input flag.
|
||||
func test_enable_auto_advance() -> void:
|
||||
Dialogic.Inputs.auto_advance.enabled_until_user_input = true
|
||||
var is_enabled: bool = Dialogic.Inputs.auto_advance.is_enabled()
|
||||
|
||||
assert(is_enabled == true, "Auto-Advance is not enabled.")
|
||||
|
||||
|
||||
## This test was created to ensure a bug was fixed:
|
||||
## When the user enabled the Auto-Advance until user input,
|
||||
## the Auto-Advance would still run after the user input.
|
||||
func test_disable_auto_advance() -> void:
|
||||
Dialogic.Inputs.auto_advance.enabled_until_user_input = true
|
||||
Dialogic.Inputs.handle_input()
|
||||
|
||||
var is_enabled: bool = Dialogic.Inputs.auto_advance.is_enabled()
|
||||
assert(is_enabled == false, "Auto-Advance is still running after input")
|
9
addons/dialogic-main/Tests/Unit/test_example.gd
Normal file
9
addons/dialogic-main/Tests/Unit/test_example.gd
Normal file
@@ -0,0 +1,9 @@
|
||||
class_name GdUnitExampleTest
|
||||
extends GdUnitTestSuite
|
||||
|
||||
func test_example() -> void:
|
||||
const EXAMPLE_STRING := "Dialogic!"
|
||||
|
||||
assert_str(EXAMPLE_STRING)\
|
||||
.has_length(EXAMPLE_STRING.length())\
|
||||
.starts_with("Dia")
|
Reference in New Issue
Block a user