diff --git a/tests/movies/impulse.flac b/tests/movies/impulse.flac new file mode 100644 index 0000000000..01f1e3d142 Binary files /dev/null and b/tests/movies/impulse.flac differ diff --git a/tests/movies/small.mp4 b/tests/movies/small.mp4 new file mode 100644 index 0000000000..6a17395f67 Binary files /dev/null and b/tests/movies/small.mp4 differ diff --git a/tests/movies/test_movie_audio.py b/tests/movies/test_movie_audio.py new file mode 100644 index 0000000000..570ae69e2f --- /dev/null +++ b/tests/movies/test_movie_audio.py @@ -0,0 +1,58 @@ +from panda3d.core import MovieAudioCursor +from panda3d.core import MovieAudio +from panda3d.core import Filename +from panda3d.core import PandaSystem +from panda3d.core import MovieTexture +from panda3d.core import MovieVideo + +import pytest +import os + + +def test_audio_rate(): #tests for audio rate + movie_path = os.path.join(os.path.dirname(__file__), "impulse.flac") + movie_path = Filename.from_os_specific(movie_path) # enables Platform independent testing + reference_file = MovieAudio.get(movie_path) + movie_file = reference_file.open() + assert movie_file.audio_rate() == 48000 + + +def test_audio_length(): #test for testing audio length + movie_path = os.path.join(os.path.dirname(__file__), "impulse.flac") + movie_path = Filename.from_os_specific(movie_path) + reference_file = MovieAudio.get(movie_path) + movie_file = reference_file.open() + assert movie_file.length() == 2 + + +def test_can_seek(): #test for seeking + movie_path = os.path.join(os.path.dirname(__file__), "impulse.flac") + movie_path = Filename.from_os_specific(movie_path) + reference_file = MovieAudio.get(movie_path) + movie_file = reference_file.open() + assert movie_file.can_seek() is True + + +def test_can_seek_fast(): #test for seeking fast + movie_path = os.path.join(os.path.dirname(__file__), "impulse.flac") + movie_path = Filename.from_os_specific(movie_path) + reference_file = MovieAudio.get(movie_path) + movie_file = reference_file.open() + assert movie_file.can_seek_fast() is True + + +def test_audio_channel(): #tests for number of audio channels + movie_path = os.path.join(os.path.dirname(__file__), "impulse.flac") + movie_path = Filename.from_os_specific(movie_path) + reference_file = MovieAudio.get(movie_path) + movie_file = reference_file.open() + assert movie_file.audio_channels() == 1 + + +def test_cursor(): #opening the file returns a cursor + movie_path = os.path.join(os.path.dirname(__file__), "impulse.flac") + movie_path = Filename.from_os_specific(movie_path) + reference_file = MovieAudio.get(movie_path) + file_name_return = reference_file.get_filename() + assert reference_file.open() is not None #checks the cursor + assert file_name_return == movie_path #checks the return name of the file diff --git a/tests/movies/test_movie_texture.py b/tests/movies/test_movie_texture.py new file mode 100644 index 0000000000..25fc642e9e --- /dev/null +++ b/tests/movies/test_movie_texture.py @@ -0,0 +1,52 @@ +from panda3d.core import MovieVideo +from panda3d.core import MovieTexture +from panda3d.core import Filename +from panda3d.core import PandaSystem +from panda3d.core import MovieTexture + +import pytest +import os + + +def check_ffmpeg(): + # Make sure video plug-ins are loaded + MovieVideo.get("test.mp4") + + system = PandaSystem.get_global_ptr() + return 'FFmpeg' in system.systems #checks whether ffmpeg is loaded + + +@pytest.mark.skipif(not check_ffmpeg(), reason="skip when ffmpeg is not available") +class Test_Texture_Movie(): + def test_texture_loop_count(self): + movie_path = os.path.join(os.path.dirname(__file__), "small.mp4") + movie_path = Filename.from_os_specific(movie_path) # enables Platform independent testing + reference_file = MovieVideo.get(movie_path) + reference_texture = MovieTexture(reference_file) + assert reference_texture.get_loop_count() == 1 + + def test_video_is_playing(self): #This test checks isPlaying() and stop() functionality + movie_path = os.path.join(os.path.dirname(__file__), "small.mp4") + movie_path = Filename.from_os_specific(movie_path) # enables Platform independent testing + reference_file = MovieVideo.get(movie_path) + reference_texture = MovieTexture(reference_file) + reference_texture.play() + assert reference_texture.is_playing() is True + reference_texture.stop() + assert reference_texture.is_playing() is False + + def test_play_rate(self): + movie_path = os.path.join(os.path.dirname(__file__), "small.mp4") + movie_path = Filename.from_os_specific(movie_path) # enables Platform independent testing + reference_file = MovieVideo.get(movie_path) + reference_texture = MovieTexture(reference_file) + assert reference_texture.get_play_rate() == 1 + reference_texture.set_play_rate(2) + assert reference_texture.get_play_rate() == 2 + + def test_video_texture_length(self): + movie_path = os.path.join(os.path.dirname(__file__), "small.mp4") + movie_path = Filename.from_os_specific(movie_path) # enables Platform independent testing + reference_file = MovieVideo.get(movie_path) + reference_texture = MovieTexture(reference_file) + assert reference_texture.get_video_length() == 32.480 #got info from mkvinfo diff --git a/tests/movies/test_movie_video.py b/tests/movies/test_movie_video.py new file mode 100644 index 0000000000..412a1c6202 --- /dev/null +++ b/tests/movies/test_movie_video.py @@ -0,0 +1,39 @@ +from panda3d.core import MovieVideo +from panda3d.core import Filename +from panda3d.core import PandaSystem + +import pytest +import os + + +def check_ffmpeg(): + # Make sure video plug-ins are loaded + MovieVideo.get("test.mp4") + + system = PandaSystem.get_global_ptr() + return 'FFmpeg' in system.systems #checks whether ffmpeg is loaded + + +@pytest.mark.skipif(not check_ffmpeg(), reason="skip when ffmpeg is not available") +class Test_Video_Movie(): + def test_cursor_check(self): + movie_path = os.path.join(os.path.dirname(__file__), "small.mp4") + movie_path = Filename.from_os_specific(movie_path) + reference_file = MovieVideo.get(movie_path) + assert reference_file.get_filename() == movie_path + assert reference_file.open() is not None + + def test_video_length(self): + movie_path = os.path.join(os.path.dirname(__file__), "small.mp4") + movie_path = Filename.from_os_specific(movie_path) + reference_file = MovieVideo.get(movie_path) + cursor = reference_file.open() + assert cursor.length() == 32.4800 + + def test_video_size(self): + movie_path = os.path.join(os.path.dirname(__file__), "small.mp4") + movie_path = Filename.from_os_specific(movie_path) + reference_file = MovieVideo.get(movie_path) + cursor = reference_file.open() + assert cursor.size_x() == 640 #found the height and width using mkvinfo + assert cursor.size_y() == 360