bowser/tests
Benedikt Willi 762dd22e31 Implement image loading and rendering support in Bowser browser
This commit introduces support for loading and rendering images in the Bowser web browser, enhancing the rendering engine to handle various image sources. Key changes include:

- Updated README.md to reflect the new milestone status and added features for image support.
- Added `ImageLayout` class to manage image layout and loading.
- Implemented synchronous and asynchronous image loading in `src/network/images.py`, including caching mechanisms.
- Expanded the DOM parsing capabilities in `DocumentLayout` to handle `<img>` tags and manage their layout directives.
- Created a new `DrawImage` command in the rendering pipeline, which handles the drawing of both loaded images and placeholders for unloaded images.
- Introduced a task queue for managing asynchronous image loads, ensuring UI remains responsive during image fetching.
- Added unit tests for image loading, layout management, and the async task queue to ensure robust functionality and prevent regressions.
2026-01-12 17:36:14 +01:00
..
__init__.py Initial bowser project scaffold 2026-01-09 12:20:46 +01:00
conftest.py Add comprehensive test suite with pytest 2026-01-09 13:37:21 +01:00
README.md Add comprehensive test suite with pytest 2026-01-09 13:37:21 +01:00
test_browser.py Enhance font handling and layout rendering by supporting font-family in layout lines, improving CSS rule parsing for multi-selectors, and updating start page styles to include emoji support. 2026-01-12 16:05:14 +01:00
test_cookies.py Refactor test files to remove unnecessary imports and improve readability 2026-01-12 10:22:34 +01:00
test_css.py Implement CSS parsing, selector matching, and style resolution 2026-01-12 11:41:18 +01:00
test_dom_graph.py Refactor test files to remove unnecessary imports and improve readability 2026-01-12 10:22:34 +01:00
test_dom_graph_page.py Refactor test files to remove unnecessary imports and improve readability 2026-01-12 10:22:34 +01:00
test_frame.py Implement CSS parsing, selector matching, and style resolution 2026-01-12 11:41:18 +01:00
test_html_parsing.py Implement CSS parsing, selector matching, and style resolution 2026-01-12 11:41:18 +01:00
test_http.py Refactor test files to remove unnecessary imports and improve readability 2026-01-12 10:22:34 +01:00
test_images.py Implement image loading and rendering support in Bowser browser 2026-01-12 17:36:14 +01:00
test_layout.py Implement CSS parsing, selector matching, and style resolution 2026-01-12 11:41:18 +01:00
test_parser.py Refactor test files to remove unnecessary imports and improve readability 2026-01-12 10:22:34 +01:00
test_render.py Refactor test files to remove unnecessary imports and improve readability 2026-01-12 10:22:34 +01:00
test_styling_integration.py Implement CSS parsing, selector matching, and style resolution 2026-01-12 11:41:18 +01:00
test_tasks.py Implement image loading and rendering support in Bowser browser 2026-01-12 17:36:14 +01:00
test_templates.py Refactor test files to remove unnecessary imports and improve readability 2026-01-12 10:22:34 +01:00
test_url.py Refactor test files to remove unnecessary imports and improve readability 2026-01-12 10:22:34 +01:00
test_url_normalization.py Refactor test files to remove unnecessary imports and improve readability 2026-01-12 10:22:34 +01:00

Bowser Test Suite

This directory contains the test suite for the Bowser browser.

Running Tests

Run all tests:

uv run pytest

Run with verbose output:

uv run pytest -v

Run specific test file:

uv run pytest tests/test_browser.py

Run with coverage:

uv run pytest --cov=src --cov-report=html

View coverage report:

open htmlcov/index.html

Test Organization

  • test_url.py - URL parsing and resolution
  • test_parser.py - HTML/CSS parsing
  • test_browser.py - Browser and tab management
  • test_cookies.py - Cookie jar functionality
  • test_layout.py - Layout engine components
  • test_render.py - Rendering primitives
  • conftest.py - Shared fixtures and configuration

Writing Tests

Tests use pytest. Example:

def test_feature():
    # Arrange
    obj = MyClass()
    
    # Act
    result = obj.method()
    
    # Assert
    assert result == expected

Use mocks for GTK components:

@patch('src.browser.browser.Gtk')
def test_with_gtk(mock_gtk):
    browser = Browser()
    # test code