コード例 #1
0
ファイル: util_test.py プロジェクト: wpumacay/dm_control
    def test_update_each_added_listener(self):
        listener = mock.MagicMock(spec=object)

        subject = util.ObservableFlag(True)

        subject += listener
        listener.assert_called_once_with(True)
コード例 #2
0
ファイル: util_test.py プロジェクト: wpumacay/dm_control
    def test_update_listeners_on_toggle(self):
        listeners = [mock.MagicMock(spec=object) for _ in range(10)]

        subject = util.ObservableFlag(True)
        subject += listeners

        for listener in listeners:
            listener.reset_mock()
        subject.toggle()
        for listener in listeners:
            listener.assert_called_once_with(False)
コード例 #3
0
    def __init__(self, title='Explorer', width=1024, height=768):
        """Instance initializer."""
        self._render_surface = None
        self._renderer = renderer.NullRenderer()
        self._viewport = renderer.Viewport(width, height)
        self._window = gui.RenderWindow(width, height, title)

        self._pause_subject = util.ObservableFlag(True)
        self._time_multiplier = util.TimeMultiplier(1.)
        self._frame_timer = util.Timer()
        self._viewer = viewer.Viewer(self._viewport, self._window.mouse,
                                     self._window.keyboard)
        self._viewer_layout = views.ViewportLayout()
        self._status = Status(self._time_multiplier, self._pause_subject,
                              self._frame_timer)

        self._runtime = None
        self._environment_loader = None
        self._environment = None
        self._policy = None
        self._deferred_reload_request = None

        status_view_toggle = self._build_view_toggle(
            views.ColumnTextView(self._status),
            views.PanelLocation.BOTTOM_LEFT)
        help_view_toggle = self._build_view_toggle(
            views.ColumnTextView(Help()), views.PanelLocation.TOP_RIGHT)
        status_view_toggle()

        self._input_map = user_input.InputMap(self._window.mouse,
                                              self._window.keyboard)
        self._input_map.bind(self._pause_subject.toggle, _PAUSE)
        self._input_map.bind(self._time_multiplier.increase, _SPEED_UP_TIME)
        self._input_map.bind(self._time_multiplier.decrease, _SLOW_DOWN_TIME)
        self._input_map.bind(self._advance_simulation, _ADVANCE_SIMULATION)
        self._input_map.bind(self._restart_runtime, _RESTART)
        self._input_map.bind(help_view_toggle, _HELP)
        self._input_map.bind(status_view_toggle, _STATUS)