mirror of
https://github.com/Hopiu/bowser.git
synced 2026-03-16 19:10:24 +00:00
- **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. |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| conftest.py | ||
| README.md | ||
| test_browser.py | ||
| test_cookies.py | ||
| test_css.py | ||
| test_dom_graph.py | ||
| test_dom_graph_page.py | ||
| test_frame.py | ||
| test_html_parsing.py | ||
| test_http.py | ||
| test_images.py | ||
| test_layout.py | ||
| test_links.py | ||
| test_parser.py | ||
| test_render.py | ||
| test_styling_integration.py | ||
| test_tasks.py | ||
| test_templates.py | ||
| test_url.py | ||
| test_url_normalization.py | ||
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 resolutiontest_parser.py- HTML/CSS parsingtest_browser.py- Browser and tab managementtest_cookies.py- Cookie jar functionalitytest_layout.py- Layout engine componentstest_render.py- Rendering primitivesconftest.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