-
-
Notifications
You must be signed in to change notification settings - Fork 22.4k
Add unit tests for AudioStreamInteractive #105457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
90 changes: 90 additions & 0 deletions
90
modules/interactive_music/tests/test_audio_stream_interactive.h
This file contains hidden or 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,90 @@ | ||
/**************************************************************************/ | ||
/* test_audio_stream_interactive.h */ | ||
/**************************************************************************/ | ||
/* This file is part of: */ | ||
/* GODOT ENGINE */ | ||
/* https://godotengine.org */ | ||
/**************************************************************************/ | ||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ | ||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ | ||
/* */ | ||
/* Permission is hereby granted, free of charge, to any person obtaining */ | ||
/* a copy of this software and associated documentation files (the */ | ||
/* "Software"), to deal in the Software without restriction, including */ | ||
/* without limitation the rights to use, copy, modify, merge, publish, */ | ||
/* distribute, sublicense, and/or sell copies of the Software, and to */ | ||
/* permit persons to whom the Software is furnished to do so, subject to */ | ||
/* the following conditions: */ | ||
/* */ | ||
/* The above copyright notice and this permission notice shall be */ | ||
/* included in all copies or substantial portions of the Software. */ | ||
/* */ | ||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ | ||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ | ||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ | ||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ | ||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ | ||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ | ||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ | ||
/**************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include "tests/test_macros.h" | ||
#include "tests/test_utils.h" | ||
#include "servers/audio/audio_stream.h" | ||
|
||
#include "../audio_stream_interactive.h" | ||
|
||
|
||
namespace TestAudio_stream_interactive { | ||
|
||
TEST_CASE("[AudioStreamInteractive] test_is_initialized_and_default") { | ||
Ref<AudioStreamInteractive> stream; | ||
stream.instantiate(); | ||
CHECK(stream.is_valid()); | ||
|
||
//checking default values | ||
CHECK(stream->get_stream_name() == "Transitioner"); | ||
} | ||
|
||
TEST_CASE("[AudioStreamInteractive] test_clip_count") { | ||
Ref<AudioStreamInteractive> stream; | ||
stream.instantiate(); | ||
CHECK(stream.is_valid()); | ||
CHECK(stream->get_initial_clip() == 0); | ||
|
||
CHECK(stream->get_clip_count() == 0); | ||
} | ||
|
||
TEST_CASE("[AudioStreamInteractive] test_clip_name") { | ||
Ref<AudioStreamInteractive> stream; | ||
stream.instantiate(); | ||
CHECK(stream.is_valid()); | ||
|
||
//checking setting and getting clip name | ||
StringName name = "file1"; | ||
stream->set_clip_name(0, name); | ||
CHECK(stream->get_clip_name(0) == name); | ||
} | ||
|
||
TEST_CASE("[AudioStreamInteractive] test_instantiate_playback") { | ||
Ref<AudioStreamInteractive> stream; | ||
stream.instantiate(); | ||
CHECK(stream.is_valid()); | ||
|
||
Ref<AudioStreamPlaybackInteractive> playback = stream->instantiate_playback(); | ||
CHECK(playback.is_valid()); | ||
} | ||
|
||
TEST_CASE("[AudioStreamPlaybackInteractive] test_playback"){ | ||
Ref<AudioStreamPlaybackInteractive> playback; | ||
playback.instantiate(); | ||
CHECK(playback.is_valid()); | ||
|
||
CHECK(playback->is_playing() == false); | ||
CHECK(playback->get_loop_count() == 0); | ||
CHECK(playback->get_playback_position() == 0.0); | ||
} | ||
|
||
} // namespace TestAudio_stream_interactive |
66 changes: 66 additions & 0 deletions
66
modules/interactive_music/tests/test_audio_stream_playlist.h
This file contains hidden or 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,66 @@ | ||
/**************************************************************************/ | ||
/* test_audio_stream_playlist.h */ | ||
/**************************************************************************/ | ||
/* This file is part of: */ | ||
/* GODOT ENGINE */ | ||
/* https://godotengine.org */ | ||
/**************************************************************************/ | ||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ | ||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ | ||
/* */ | ||
/* Permission is hereby granted, free of charge, to any person obtaining */ | ||
/* a copy of this software and associated documentation files (the */ | ||
/* "Software"), to deal in the Software without restriction, including */ | ||
/* without limitation the rights to use, copy, modify, merge, publish, */ | ||
/* distribute, sublicense, and/or sell copies of the Software, and to */ | ||
/* permit persons to whom the Software is furnished to do so, subject to */ | ||
/* the following conditions: */ | ||
/* */ | ||
/* The above copyright notice and this permission notice shall be */ | ||
/* included in all copies or substantial portions of the Software. */ | ||
/* */ | ||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ | ||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ | ||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ | ||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ | ||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ | ||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ | ||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ | ||
/**************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include "tests/test_macros.h" | ||
#include "tests/test_utils.h" | ||
#include "servers/audio/audio_stream.h" | ||
|
||
#include "../audio_stream_playlist.h" | ||
|
||
namespace TestAudio_stream_playlist { | ||
|
||
TEST_CASE("[AudioStreamPlaylist] test_initialized_and_default") { | ||
Ref<AudioStreamPlaylist> playlist; | ||
playlist.instantiate(); | ||
CHECK(playlist.is_valid()); | ||
|
||
// checking default settings | ||
CHECK(playlist->get_stream_name() == "Playlist"); | ||
CHECK(playlist->get_shuffle() == false); | ||
CHECK(playlist->get_fade_time() == float(0.3)); | ||
CHECK(playlist->has_loop() == true); | ||
CHECK(playlist->get_stream_count() == 0); | ||
CHECK(playlist->get_length() == 0.0); | ||
CHECK(playlist->is_meta_stream() == true); | ||
CHECK(playlist->get_bpm() == 0.0); | ||
} | ||
|
||
TEST_CASE("[AudioStreamPlaylist] test_instantiate_playback") { | ||
Ref<AudioStreamPlaylist> playlist; | ||
playlist.instantiate(); | ||
CHECK(playlist.is_valid()); | ||
|
||
Ref<AudioStreamPlayback> playback = playlist->instantiate_playback(); | ||
CHECK(playback.is_valid()); | ||
} | ||
|
||
} // namespace TestAudio_stream_playlist |
54 changes: 54 additions & 0 deletions
54
modules/interactive_music/tests/test_audio_stream_synchronized.h
This file contains hidden or 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,54 @@ | ||
/**************************************************************************/ | ||
/* test_audio_stream_synchronized.h */ | ||
/**************************************************************************/ | ||
/* This file is part of: */ | ||
/* GODOT ENGINE */ | ||
/* https://godotengine.org */ | ||
/**************************************************************************/ | ||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ | ||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ | ||
/* */ | ||
/* Permission is hereby granted, free of charge, to any person obtaining */ | ||
/* a copy of this software and associated documentation files (the */ | ||
/* "Software"), to deal in the Software without restriction, including */ | ||
/* without limitation the rights to use, copy, modify, merge, publish, */ | ||
/* distribute, sublicense, and/or sell copies of the Software, and to */ | ||
/* permit persons to whom the Software is furnished to do so, subject to */ | ||
/* the following conditions: */ | ||
/* */ | ||
/* The above copyright notice and this permission notice shall be */ | ||
/* included in all copies or substantial portions of the Software. */ | ||
/* */ | ||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ | ||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ | ||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ | ||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ | ||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ | ||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ | ||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ | ||
/**************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include "tests/test_macros.h" | ||
#include "tests/test_utils.h" | ||
#include "servers/audio/audio_stream.h" | ||
|
||
#include "../audio_stream_synchronized.h" | ||
|
||
namespace TestAudio_stream_synchronized { | ||
|
||
TEST_CASE("[AudioStreamSynchronized] test_initialized_and_default") { | ||
Ref<AudioStreamSynchronized> synchro; | ||
synchro.instantiate(); | ||
CHECK(synchro.is_valid()); | ||
|
||
//testing default values | ||
CHECK(synchro->get_stream_count() == 0); | ||
CHECK(synchro->get_beat_count() == 0); | ||
CHECK(synchro->get_bpm() == 0.0); | ||
CHECK(synchro->get_bar_beats() == 0); | ||
CHECK(synchro->get_stream_name() == "Synchronized"); | ||
} | ||
|
||
} // namespace TestAudio_stream_synchronized |
This file contains hidden or 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
88 changes: 88 additions & 0 deletions
88
tests/modules/interactive_music/test_audio_stream_interactive.h
This file contains hidden or 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,88 @@ | ||
/**************************************************************************/ | ||
/* test_audio_stream_interactive.h */ | ||
/**************************************************************************/ | ||
/* This file is part of: */ | ||
/* GODOT ENGINE */ | ||
/* https://godotengine.org */ | ||
/**************************************************************************/ | ||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ | ||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ | ||
/* */ | ||
/* Permission is hereby granted, free of charge, to any person obtaining */ | ||
/* a copy of this software and associated documentation files (the */ | ||
/* "Software"), to deal in the Software without restriction, including */ | ||
/* without limitation the rights to use, copy, modify, merge, publish, */ | ||
/* distribute, sublicense, and/or sell copies of the Software, and to */ | ||
/* permit persons to whom the Software is furnished to do so, subject to */ | ||
/* the following conditions: */ | ||
/* */ | ||
/* The above copyright notice and this permission notice shall be */ | ||
/* included in all copies or substantial portions of the Software. */ | ||
/* */ | ||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ | ||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ | ||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ | ||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ | ||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ | ||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ | ||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ | ||
/**************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include "tests/test_macros.h" | ||
#include "modules/interactive_music/audio_stream_interactive.h" | ||
#include "servers/audio/audio_stream.h" | ||
|
||
|
||
namespace TestAudio_stream_interactive { | ||
|
||
TEST_CASE("[AudioStreamInteractive] test_is_initialized_and_default") { | ||
Ref<AudioStreamInteractive> stream; | ||
stream.instantiate(); | ||
CHECK(stream.is_valid()); | ||
|
||
//checking default values | ||
CHECK(stream->get_stream_name() == "Transitioner"); | ||
} | ||
|
||
TEST_CASE("[AudioStreamInteractive] test_clip_count") { | ||
Ref<AudioStreamInteractive> stream; | ||
stream.instantiate(); | ||
CHECK(stream.is_valid()); | ||
CHECK(stream->get_initial_clip() == 0); | ||
|
||
CHECK(stream->get_clip_count() == 0); | ||
} | ||
|
||
TEST_CASE("[AudioStreamInteractive] test_clip_name") { | ||
Ref<AudioStreamInteractive> stream; | ||
stream.instantiate(); | ||
CHECK(stream.is_valid()); | ||
|
||
//checking setting and getting clip name | ||
StringName name = "file1"; | ||
stream->set_clip_name(0, name); | ||
CHECK(stream->get_clip_name(0) == name); | ||
} | ||
|
||
TEST_CASE("[AudioStreamInteractive] test_instantiate_playback") { | ||
Ref<AudioStreamInteractive> stream; | ||
stream.instantiate(); | ||
CHECK(stream.is_valid()); | ||
|
||
Ref<AudioStreamPlaybackInteractive> playback = stream->instantiate_playback(); | ||
CHECK(playback.is_valid()); | ||
} | ||
|
||
TEST_CASE("[AudioStreamPlaybackInteractive] test_playback"){ | ||
Ref<AudioStreamPlaybackInteractive> playback; | ||
playback.instantiate(); | ||
CHECK(playback.is_valid()); | ||
|
||
CHECK(playback->is_playing() == false); | ||
CHECK(playback->get_loop_count() == 0); | ||
CHECK(playback->get_playback_position() == 0.0); | ||
} | ||
|
||
} // namespace TestAudio_stream_interactive |
64 changes: 64 additions & 0 deletions
64
tests/modules/interactive_music/test_audio_stream_playlist.h
This file contains hidden or 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,64 @@ | ||
/**************************************************************************/ | ||
/* test_audio_stream_playlist.h */ | ||
/**************************************************************************/ | ||
/* This file is part of: */ | ||
/* GODOT ENGINE */ | ||
/* https://godotengine.org */ | ||
/**************************************************************************/ | ||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ | ||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ | ||
/* */ | ||
/* Permission is hereby granted, free of charge, to any person obtaining */ | ||
/* a copy of this software and associated documentation files (the */ | ||
/* "Software"), to deal in the Software without restriction, including */ | ||
/* without limitation the rights to use, copy, modify, merge, publish, */ | ||
/* distribute, sublicense, and/or sell copies of the Software, and to */ | ||
/* permit persons to whom the Software is furnished to do so, subject to */ | ||
/* the following conditions: */ | ||
/* */ | ||
/* The above copyright notice and this permission notice shall be */ | ||
/* included in all copies or substantial portions of the Software. */ | ||
/* */ | ||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ | ||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ | ||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ | ||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ | ||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ | ||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ | ||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ | ||
/**************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include "tests/test_macros.h" | ||
#include "modules/interactive_music/audio_stream_playlist.h" | ||
#include "servers/audio/audio_stream.h" | ||
|
||
namespace TestAudio_stream_playlist { | ||
|
||
TEST_CASE("[AudioStreamPlaylist] test_initialized_and_default") { | ||
Ref<AudioStreamPlaylist> playlist; | ||
playlist.instantiate(); | ||
CHECK(playlist.is_valid()); | ||
|
||
// checking default settings | ||
CHECK(playlist->get_stream_name() == "Playlist"); | ||
CHECK(playlist->get_shuffle() == false); | ||
CHECK(playlist->get_fade_time() == float(0.3)); | ||
CHECK(playlist->has_loop() == true); | ||
CHECK(playlist->get_stream_count() == 0); | ||
CHECK(playlist->get_length() == 0.0); | ||
CHECK(playlist->is_meta_stream() == true); | ||
CHECK(playlist->get_bpm() == 0.0); | ||
} | ||
|
||
TEST_CASE("[AudioStreamPlaylist] test_instantiate_playback") { | ||
Ref<AudioStreamPlaylist> playlist; | ||
playlist.instantiate(); | ||
CHECK(playlist.is_valid()); | ||
|
||
Ref<AudioStreamPlayback> playback = playlist->instantiate_playback(); | ||
CHECK(playback.is_valid()); | ||
} | ||
|
||
} // namespace TestAudio_stream_playlist |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be solved differently, this sounds like an issue either in your compilation setup or something related to your tests, this is not the way to fix it
I suspect that you tried to build from inside
test/
which is not correctBut regardless of this the fix should be a separate PR if it is needed, this PR shouldn't contain a buildystem fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, on the writing unit test site it said that the tests would fall under tests/ so I got confused, but I can fix that issue. Thank you for pointing me to a helpful file, and I see the formatting is a little different than those in the tests/ folder. Is the one for jsonrpc the expected unit tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean for formatting? And what file? Did you mean to reply to my other comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I meant to reply to your other comment apologies.