Преглед на файлове

tests: Added video and audio tests

Closes #663
Rishabh Tewari преди 2 години
родител
ревизия
dcd2aa83d4
променени са 5 файла, в които са добавени 149 реда и са изтрити 0 реда
  1. BIN
      tests/movies/impulse.flac
  2. BIN
      tests/movies/small.mp4
  3. 58 0
      tests/movies/test_movie_audio.py
  4. 52 0
      tests/movies/test_movie_texture.py
  5. 39 0
      tests/movies/test_movie_video.py

BIN
tests/movies/impulse.flac


BIN
tests/movies/small.mp4


+ 58 - 0
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

+ 52 - 0
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
+
+
[email protected](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

+ 39 - 0
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
+
+
[email protected](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