Context Menu Testing Coverage
Context Menu Testing Coverage
#386 in iced-rs/iced_aw — merged 2025-12-29
Added test coverage for the ContextMenu widget
Changes
Widget Enhancements (src/widget/context_menu.rs)
- Added
force_open: Option<bool>field to control menu state for testing - Added
.open(bool)method to force menu open/closed state - Updated
operate()andoverlay()methods to respect forced state - Added unit tests for the new
open()method
Overlay Implementation (src/widget/overlay/context_menu.rs)
- Implemented
operate()method to support widget tree operations - Added unit tests covering overlay creation, positioning, and state management
Integration Tests (tests/context_menu_integration_tests.rs)
Added iced_test simulator-based integration tests covering:
- Widget discovery: Finding underlay/overlay elements when open/closed
- Interactions: Clicking buttons in underlay and overlay
- Complex layouts: Column/Row structures, nested elements
- Edge cases: Unicode text, emojis, long text, multiple instances
- State control: Forced open/closed states via
.open()method
Impact
Enables reliable automated testing of ContextMenu functionality without manual interaction.
# Unit tests
cargo test widget::context_menu
cargo test widget::overlay::context_menu
# Integration tests
cargo test --test context_menu_integration_tests
Last updated 2026-05-14
Links to this note
Credits
Merged pull requests, newest first.