-
-
Notifications
You must be signed in to change notification settings - Fork 22.4k
Add unit tests for AudioStreamInteractive
#105490
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
base: master
Are you sure you want to change the base?
Changes from all commits
8d931e8
9ddeb5f
47eba8f
86e3380
43e1be8
cc7efc0
7a3cef7
424a4b9
cb5bec9
fef9525
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,89 @@ | ||||||
/**************************************************************************/ | ||||||
/* 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 "servers/audio/audio_stream.h" | ||||||
#include "tests/test_macros.h" | ||||||
#include "tests/test_utils.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 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
CHECK(stream->get_stream_name() == "Transitioner"); | ||||||
} | ||||||
|
||||||
TEST_CASE("[AudioStreamInteractive] test_clip_count") { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
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") { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
Ref<AudioStreamInteractive> stream; | ||||||
stream.instantiate(); | ||||||
CHECK(stream.is_valid()); | ||||||
|
||||||
//checking setting and getting clip name | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
StringName name = "file1"; | ||||||
stream->set_clip_name(0, name); | ||||||
CHECK(stream->get_clip_name(0) == name); | ||||||
} | ||||||
|
||||||
TEST_CASE("[AudioStreamInteractive] test_instantiate_playback") { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
Ref<AudioStreamInteractive> stream; | ||||||
stream.instantiate(); | ||||||
CHECK(stream.is_valid()); | ||||||
|
||||||
Ref<AudioStreamPlaybackInteractive> playback = stream->instantiate_playback(); | ||||||
CHECK(playback.is_valid()); | ||||||
} | ||||||
|
||||||
TEST_CASE("[AudioStreamPlaybackInteractive] test_playback") { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
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 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,72 @@ | ||||||
/**************************************************************************/ | ||||||
/* 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 "servers/audio/audio_stream.h" | ||||||
#include "tests/test_macros.h" | ||||||
#include "tests/test_utils.h" | ||||||
|
||||||
#include "../audio_stream_playlist.h" | ||||||
|
||||||
namespace TestAudio_stream_playlist { | ||||||
|
||||||
TEST_CASE("[AudioStreamPlaylist] test_initialized_and_default") { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
Ref<AudioStreamPlaylist> playlist; | ||||||
playlist.instantiate(); | ||||||
CHECK(playlist.is_valid()); | ||||||
|
||||||
// checking default settings | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
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); | ||||||
|
||||||
//using some set methods | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
playlist->set_loop(false); //we want these to fail for stress testing | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
CHECK(playlist->has_loop() == true); | ||||||
playlist->set_shuffle(true); | ||||||
CHECK(playlist->get_shuffle() == false); | ||||||
} | ||||||
|
||||||
TEST_CASE("[AudioStreamPlaylist] test_instantiate_playback") { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
Ref<AudioStreamPlaylist> playlist; | ||||||
playlist.instantiate(); | ||||||
CHECK(playlist.is_valid()); | ||||||
|
||||||
Ref<AudioStreamPlayback> playback = playlist->instantiate_playback(); | ||||||
CHECK(playback.is_valid()); | ||||||
} | ||||||
|
||||||
} // namespace TestAudio_stream_playlist | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
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 "servers/audio/audio_stream.h" | ||||||
#include "tests/test_macros.h" | ||||||
#include "tests/test_utils.h" | ||||||
|
||||||
#include "../audio_stream_synchronized.h" | ||||||
|
||||||
namespace TestAudio_stream_synchronized { | ||||||
|
||||||
TEST_CASE("[AudioStreamSynchronized] test_initialized_and_default") { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
Ref<AudioStreamSynchronized> synchro; | ||||||
synchro.instantiate(); | ||||||
CHECK(synchro.is_valid()); | ||||||
|
||||||
//testing default values | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
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 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
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.