- Replace the Python/Docker setup with a Rust workspace and Tauri frontend - Add core crates for archive, audio, MIDI, plugin, and desktop UI layers - Refresh the app scaffolding, build config, and documentation
37 lines
1.4 KiB
Python
37 lines
1.4 KiB
Python
import unittest
|
|
from unittest.mock import MagicMock
|
|
from PyQt5.QtWidgets import QApplication
|
|
from Fbrowser import SampleMusicBrowser
|
|
|
|
class TestSampleMusicBrowser(unittest.TestCase):
|
|
def setUp(self):
|
|
self.app = QApplication([])
|
|
self.browser = SampleMusicBrowser()
|
|
|
|
def tearDown(self):
|
|
self.app.quit()
|
|
|
|
def test_player_error(self):
|
|
# Mock QMediaPlayer and set error code
|
|
self.browser.player.error = MagicMock(return_value=1)
|
|
self.browser.player.errorString = MagicMock(return_value="Test Error")
|
|
self.browser.player_error(1)
|
|
# Assert that the error message is printed
|
|
self.assertIn("An error occurred: Code:1 Test Error", self.browser.console_output)
|
|
|
|
def test_player_media_status_changed(self):
|
|
# Mock QMediaPlayer and set media status
|
|
self.browser.player_media_status_changed(2)
|
|
# Assert that the media status is printed
|
|
self.assertIn("Media Status: 2", self.browser.console_output)
|
|
|
|
def test_play_file(self):
|
|
# Mock QFileSystemModel and set file path
|
|
self.browser.list_model.filePath = MagicMock(return_value="/path/to/file.mp3")
|
|
# Call play_file method
|
|
self.browser.play_file(None)
|
|
# Assert that the player is playing the correct media
|
|
self.assertEqual(self.browser.playlist.media(0).canonicalUrl().toString(), "file:///path/to/file.mp3")
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main() |