Ejemplo n.º 1
0
  def test_initial_factor_clamped_to_valid_value_range(self):
    too_large_multiplier = util._MAX_TIME_MULTIPLIER + 1.
    too_small_multiplier = util._MIN_TIME_MULTIPLIER - 1.

    factor = util.TimeMultiplier(initial_time_multiplier=too_large_multiplier)
    self.assertEqual(util._MAX_TIME_MULTIPLIER, factor.get())

    factor = util.TimeMultiplier(initial_time_multiplier=too_small_multiplier)
    self.assertEqual(util._MIN_TIME_MULTIPLIER, factor.get())
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
 def custom_initial_factor(self):
     initial_value = 5.0
     factor = util.TimeMultiplier(initial_time_multiplier=initial_value)
     self.assertEqual(initial_value, factor.get())
Ejemplo n.º 4
0
 def setUp(self):
     self.factor = util.TimeMultiplier(initial_time_multiplier=1.0)
Ejemplo n.º 5
0
 def setUp(self):
     super(TimeMultiplierTests, self).setUp()
     self.factor = util.TimeMultiplier(initial_time_multiplier=1.0)