-
-
Notifications
You must be signed in to change notification settings - Fork 775
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #663
- Loading branch information
Showing
5 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains 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,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 |
This file contains 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,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 |
This file contains 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,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 |