-
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
get_current_speaker
if there is no speaker (#2071)
Handle calls when there is no speaker.
- Loading branch information
Showing
4 changed files
with
70 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"@path": "res://addons/dialogic/Resources/character.gd", | ||
"@subpath": NodePath(""), | ||
"_translation_id": "", | ||
"color": Color(1, 1, 1, 1), | ||
"custom_info": { | ||
"sound_mood_default": "", | ||
"sound_moods": {}, | ||
"style": "" | ||
}, | ||
"default_portrait": "", | ||
"description": "", | ||
"display_name": "unit_test_character", | ||
"mirror": false, | ||
"nicknames": [""], | ||
"offset": Vector2(0, 0), | ||
"portraits": {}, | ||
"scale": 1.0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters