bowser/tests
Benedikt Willi 8c2d360515 This commit introduces several enhancements to the browser rendering engine. Key changes include the ability to handle link clicks, improved link detection, and enhanced color parsing for proper rendering of styled links. The following modifications are included:
- **Link Detection and Navigation**: Added functionality to detect if a mouse click falls within a link area. If a link is clicked, the browser now navigates to the corresponding URL while logging the action. This also includes handling relative URLs based on the current page context.

- **Line Layout Enhancements**: The `LayoutLine` class now includes optional attributes for color and href, allowing links to maintain their designated colors in the rendered output.

- **Color Parsing**: Implemented a new `_parse_color` method in the `RenderPipeline` class to convert various color formats (hex and named colors) to Skia-compatible values. This ensures that default link colors are correctly applied and that extremely light colors are rendered as black for visibility.

- **Rendering Links**: During the rendering process, links in the text layout are now rendered with their specified colors, and an underline is drawn under links to indicate interactivity.

- **Document Layout Updates**: The document parsing system has been updated to extract link information correctly while preserving text hierarchy.

- **Tests**: A comprehensive suite of tests has been added, including tests for link parsing, layout characteristics, styling application, and default color handling for links.
2026-01-13 13:06:20 +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 This commit introduces several enhancements to the browser rendering engine. Key changes include the ability to handle link clicks, improved link detection, and enhanced color parsing for proper rendering of styled links. The following modifications are included: 2026-01-13 13:06:20 +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 This commit introduces several enhancements to the browser rendering engine. Key changes include the ability to handle link clicks, improved link detection, and enhanced color parsing for proper rendering of styled links. The following modifications are included: 2026-01-13 13:06:20 +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 This commit introduces several enhancements to the browser rendering engine. Key changes include the ability to handle link clicks, improved link detection, and enhanced color parsing for proper rendering of styled links. The following modifications are included: 2026-01-13 13:06:20 +01:00
test_layout.py Implement CSS parsing, selector matching, and style resolution 2026-01-12 11:41:18 +01:00
test_links.py This commit introduces several enhancements to the browser rendering engine. Key changes include the ability to handle link clicks, improved link detection, and enhanced color parsing for proper rendering of styled links. The following modifications are included: 2026-01-13 13:06:20 +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 This commit introduces several enhancements to the browser rendering engine. Key changes include the ability to handle link clicks, improved link detection, and enhanced color parsing for proper rendering of styled links. The following modifications are included: 2026-01-13 13:06:20 +01:00
test_tasks.py This commit introduces several enhancements to the browser rendering engine. Key changes include the ability to handle link clicks, improved link detection, and enhanced color parsing for proper rendering of styled links. The following modifications are included: 2026-01-13 13:06:20 +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