test_movie_audio.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. from panda3d.core import MovieAudioCursor
  2. from panda3d.core import MovieAudio
  3. from panda3d.core import Filename
  4. from panda3d.core import PandaSystem
  5. from panda3d.core import MovieTexture
  6. from panda3d.core import MovieVideo
  7. import pytest
  8. import os
  9. def test_audio_rate(): #tests for audio rate
  10. movie_path = os.path.join(os.path.dirname(__file__), "impulse.flac")
  11. movie_path = Filename.from_os_specific(movie_path) # enables Platform independent testing
  12. reference_file = MovieAudio.get(movie_path)
  13. movie_file = reference_file.open()
  14. assert movie_file.audio_rate() == 48000
  15. def test_audio_length(): #test for testing audio length
  16. movie_path = os.path.join(os.path.dirname(__file__), "impulse.flac")
  17. movie_path = Filename.from_os_specific(movie_path)
  18. reference_file = MovieAudio.get(movie_path)
  19. movie_file = reference_file.open()
  20. assert movie_file.length() == 2
  21. def test_can_seek(): #test for seeking
  22. movie_path = os.path.join(os.path.dirname(__file__), "impulse.flac")
  23. movie_path = Filename.from_os_specific(movie_path)
  24. reference_file = MovieAudio.get(movie_path)
  25. movie_file = reference_file.open()
  26. assert movie_file.can_seek() is True
  27. def test_can_seek_fast(): #test for seeking fast
  28. movie_path = os.path.join(os.path.dirname(__file__), "impulse.flac")
  29. movie_path = Filename.from_os_specific(movie_path)
  30. reference_file = MovieAudio.get(movie_path)
  31. movie_file = reference_file.open()
  32. assert movie_file.can_seek_fast() is True
  33. def test_audio_channel(): #tests for number of audio channels
  34. movie_path = os.path.join(os.path.dirname(__file__), "impulse.flac")
  35. movie_path = Filename.from_os_specific(movie_path)
  36. reference_file = MovieAudio.get(movie_path)
  37. movie_file = reference_file.open()
  38. assert movie_file.audio_channels() == 1
  39. def test_cursor(): #opening the file returns a cursor
  40. movie_path = os.path.join(os.path.dirname(__file__), "impulse.flac")
  41. movie_path = Filename.from_os_specific(movie_path)
  42. reference_file = MovieAudio.get(movie_path)
  43. file_name_return = reference_file.get_filename()
  44. assert reference_file.open() is not None #checks the cursor
  45. assert file_name_return == movie_path #checks the return name of the file