46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
"""Unit tests for font sizing UI helpers."""
|
|
|
|
from types import SimpleNamespace
|
|
import importlib
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture
|
|
def font_helpers_module():
|
|
"""Import the font helper utilities."""
|
|
return importlib.import_module("src.ui.font_helpers")
|
|
|
|
|
|
def test_font_size_ui_state_manual_when_fitting_disabled(monkeypatch, font_helpers_module):
|
|
"""Manual font size should remain enabled when fitting is off."""
|
|
monkeypatch.setattr(font_helpers_module, "has_text_fitting", lambda: True)
|
|
props = SimpleNamespace(enable_text_fitting=False, text_fitting_mode="FIT_CONTAIN")
|
|
|
|
enabled, message = font_helpers_module.font_size_ui_state(props)
|
|
|
|
assert enabled is True
|
|
assert message == ""
|
|
|
|
|
|
def test_font_size_ui_state_auto_when_fitting_enabled(monkeypatch, font_helpers_module):
|
|
"""Font size control shows auto-sizing message when fitting is active."""
|
|
monkeypatch.setattr(font_helpers_module, "has_text_fitting", lambda: True)
|
|
props = SimpleNamespace(enable_text_fitting=True, text_fitting_mode="FIT_WIDTH")
|
|
|
|
enabled, message = font_helpers_module.font_size_ui_state(props)
|
|
|
|
assert enabled is False
|
|
assert "Fit Width" in message
|
|
|
|
|
|
def test_font_size_ui_state_without_text_fitting_feature(monkeypatch, font_helpers_module):
|
|
"""Without text fitting support, manual font sizing stays enabled."""
|
|
monkeypatch.setattr(font_helpers_module, "has_text_fitting", lambda: False)
|
|
props = SimpleNamespace(enable_text_fitting=True, text_fitting_mode="FIT_WIDTH")
|
|
|
|
enabled, message = font_helpers_module.font_size_ui_state(props)
|
|
|
|
assert enabled is True
|
|
assert message == ""
|