Skip to content

Commit

Permalink
bail out when kivy is missing a video provider (#267)
Browse files Browse the repository at this point in the history
* bail out when kivy is missing a video provider

* add small video integration test

* fix integration tests with current dev
  • Loading branch information
jabdoa2 committed May 19, 2017
1 parent 046dfb6 commit e356e4e
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 1 deletion.
5 changes: 5 additions & 0 deletions mpfmc/assets/video.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from kivy.core.video import Video
from kivy.core.video.video_null import VideoNull

from mpf.core.assets import Asset, AssetPool


Expand Down Expand Up @@ -107,6 +109,9 @@ def is_loaded(self):
self._video = Video(filename=self.file)
self._video.bind(on_load=self._check_duration)

if isinstance(self._video, VideoNull):
raise AssertionError("Kivy cannot load video {} because there is no provider.".format(self.file))

self._call_callbacks()

def _check_duration(self, instance):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ coils:
drain:
number:

playfields:
playfield:
default_source_device: bd_drain

ball_devices:
bd_drain:
eject_coil: drain
ball_switches: drain
tags: trough, drain, ball_add_live
tags: trough, drain
9 changes: 9 additions & 0 deletions mpfmc/integration/machine_files/video/config/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#config_version=4

displays:
default:
width: 400
height: 300

modes:
- mode1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#config_version=4

mode:
priority: 100
start_events: start_mode1
stop_events: stop_mode1
game_mode: false


slide_player:
mode_mode1_started:
mode1_slide1:
widgets:
- type: video
video: mpf_video_small_test2
- type: text
text: Video from Mode
y: bottom+20%
Binary file not shown.
27 changes: 27 additions & 0 deletions mpfmc/integration/test_Video.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import time

from mpfmc.tests.MpfIntegrationTestCase import MpfIntegrationTestCase


class TestVideo(MpfIntegrationTestCase):

def getMachinePath(self):
return 'integration/machine_files/video'

def getConfigFile(self):
return 'config.yaml'

def test_video_stops_on_slide_removal(self):
# start mode1, its slide with video should come up
self.post_event("start_mode1")
self.advance_time_and_run()

self.assertEqual(self.mc.targets['default'].current_slide.name, 'mode1_slide1')
video_widget = self.mc.targets['default'].current_slide.children[0].children[0]
self.assertEqual(video_widget.state, 'play')

# stop mode 1, should unload the slide
self.post_event("stop_mode1")
self.advance_time_and_run()
self.assertEqual(self.mc.targets['default'].current_slide.name, 'default_blank')
self.assertEqual(video_widget.state, 'stop')

0 comments on commit e356e4e

Please sign in to comment.