missionpinball / mpf-mc

The Mission Pinball Framework Media Controller. Controls graphics, sounds, DMDs, and LCD displays in MPF.
http://missionpinball.org
MIT License
21 stars 42 forks source link

widget_player "action:remove" fails from mode context with virtual DMD #256

Open unRARed opened 7 years ago

unRARed commented 7 years ago

The widgets are added to the virtual DMD as expected on the mode_attract_started event but not removed on mode_attract_stopped. The following integration test passes against my widget_player config globally, but fails when moving the config into the context of a specific mode. I could be missing something obvious, but this seems to relate to #144. This is a pretty specific case as we're using both the virtual DMD and named widgets.

Attract Mode Config

#config_version=4
widget_player:
  mode_attract_started:
    title:
      action: add
      target: dmd
      widget_settings:
        anchor_y: top
        y: top-4%
    credit:
      action: add
      target: dmd
      widget_settings:
        anchor_y: top
        y: top-50%
    company:
      action: add
      target: dmd
      widget_settings:
        anchor_y: top
        y: top-74%
    background:
      action: add
  mode_attract_stopped:
    title:
      action: remove
    credit:
      action: remove
    company:
      action: remove

Integration test:

def test_attract_mode(self):
    # verify widget is on the DMD
    current_widgets = self.get_dmd_text_widgets()
    self.assertIn('Pinball Plaid', [x.text for x in current_widgets])
    # stop the mode and verify the widget has been removed
    self.hit_and_release_switch("s_start") # triggers the attract mode stop event
    self.advance_time_and_run()
    current_widgets = self.get_dmd_text_widgets()
    self.assertNotIn('Pinball Plaid', [x.text for x in current_widgets]) # << FAILS

def get_dmd_text_widgets(self):
    current_widgets = []
    virtual_dmd = self.mc.displays['dmd'].\
        children[0].children[0]
    for widget in virtual_dmd.children:
        if hasattr(widget, 'text'): current_widgets.append(widget)
    return current_widgets

Error:

AssertionError: 'Pinball Plaid' unexpectedly found in ['Ball: 1', '', '', '', '00', 'P1:', 'Player: 1', '0,000,000', 'Zaccaria “Combat”', 'Pinball Plaid', 'Reimagined by:']

screenshot

unRARed commented 7 years ago

To be clear, I'm running upstream/dev HEAD for both mpf and mpf-mc.