""" Tests for engine.frame module. """ import time from engine.frame import FrameTimer, calculate_scroll_step class TestFrameTimer: """Tests for FrameTimer class.""" def test_init_default(self): """FrameTimer initializes with default values.""" timer = FrameTimer() assert timer.target_frame_dt == 0.05 assert timer.fps >= 0 def test_init_custom(self): """FrameTimer accepts custom frame duration.""" timer = FrameTimer(target_frame_dt=0.1) assert timer.target_frame_dt == 0.1 def test_fps_calculation(self): """FrameTimer calculates FPS correctly.""" timer = FrameTimer() timer._frame_count = 10 timer._start_time = time.monotonic() - 1.0 assert timer.fps >= 9.0 def test_reset(self): """FrameTimer.reset() clears frame count.""" timer = FrameTimer() timer._frame_count = 100 timer.reset() assert timer._frame_count == 0 class TestCalculateScrollStep: """Tests for calculate_scroll_step function.""" def test_basic_calculation(self): """calculate_scroll_step returns positive value.""" result = calculate_scroll_step(5.0, 24) assert result > 0 def test_with_padding(self): """calculate_scroll_step respects padding parameter.""" without_padding = calculate_scroll_step(5.0, 24, padding=0) with_padding = calculate_scroll_step(5.0, 24, padding=15) assert with_padding < without_padding def test_larger_view_slower_scroll(self): """Larger view height results in slower scroll steps.""" small = calculate_scroll_step(5.0, 10) large = calculate_scroll_step(5.0, 50) assert large < small def test_longer_duration_slower_scroll(self): """Longer scroll duration results in slower scroll steps.""" fast = calculate_scroll_step(2.0, 24) slow = calculate_scroll_step(10.0, 24) assert slow > fast