Skip to content

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions modules/interactive_music/tests/test_audio_stream_interactive.h
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") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TEST_CASE("[AudioStreamInteractive] test_is_initialized_and_default") {
TEST_CASE("[AudioStreamInteractive] Defaults") {

Ref<AudioStreamInteractive> stream;
stream.instantiate();
CHECK(stream.is_valid());

//checking default values
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//checking default values
// Checking default values.

CHECK(stream->get_stream_name() == "Transitioner");
}

TEST_CASE("[AudioStreamInteractive] test_clip_count") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TEST_CASE("[AudioStreamInteractive] test_clip_count") {
TEST_CASE("[AudioStreamInteractive] 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") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TEST_CASE("[AudioStreamInteractive] test_clip_name") {
TEST_CASE("[AudioStreamInteractive] Clip name") {

Ref<AudioStreamInteractive> stream;
stream.instantiate();
CHECK(stream.is_valid());

//checking setting and getting clip name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//checking setting and getting clip name
// 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") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TEST_CASE("[AudioStreamInteractive] test_instantiate_playback") {
TEST_CASE("[AudioStreamInteractive] 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") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TEST_CASE("[AudioStreamPlaybackInteractive] test_playback") {
TEST_CASE("[AudioStreamPlaybackInteractive] 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} // namespace TestAudio_stream_interactive
} // namespace TestAudioStreamInteractive

72 changes: 72 additions & 0 deletions modules/interactive_music/tests/test_audio_stream_playlist.h
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") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TEST_CASE("[AudioStreamPlaylist] test_initialized_and_default") {
TEST_CASE("[AudioStreamPlaylist] Defaults") {

Ref<AudioStreamPlaylist> playlist;
playlist.instantiate();
CHECK(playlist.is_valid());

// checking default settings
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// checking default settings
// 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);

//using some set methods
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//using some set methods
// Using some set methods.

playlist->set_loop(false); //we want these to fail for stress testing
Copy link
Member

Choose a reason for hiding this comment

The 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
playlist->set_loop(false); // we want these to fail for stress testing.

CHECK(playlist->has_loop() == true);
playlist->set_shuffle(true);
CHECK(playlist->get_shuffle() == false);
}

TEST_CASE("[AudioStreamPlaylist] test_instantiate_playback") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TEST_CASE("[AudioStreamPlaylist] test_instantiate_playback") {
TEST_CASE("[AudioStreamPlaylist] 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} // namespace TestAudio_stream_playlist
} // namespace TestAudioStreamPlaylist

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") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TEST_CASE("[AudioStreamSynchronized] test_initialized_and_default") {
TEST_CASE("[AudioStreamSynchronized] Defaults") {

Ref<AudioStreamSynchronized> synchro;
synchro.instantiate();
CHECK(synchro.is_valid());

//testing default values
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//testing default values
// Checking 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} // namespace TestAudio_stream_synchronized
} // namespace TestAudioStreamSynchronized

Loading