-
Notifications
You must be signed in to change notification settings - Fork 430
Commit 5cf413b
Write focus behavior unit test for form (#4100)
* Add comprehensive focus behavior test class
This test class verifies focus behavior using the @formtest annotation to
initialize the EDT and fire events through the entire stack. The tests cover:
- Focus state management (focusable, hasFocus, setFocus)
- Focus listeners (gained and lost events)
- Focus traversal (next/previous/left/right/up/down)
- Focus with containers and nested components
- Focus interaction with component state (enabled, visible)
- Focus with pointer/touch events
- Tab index and traversable properties
- Focus persistence across style changes
- Multiple focus listeners
- Focus cycles and form transitions
The implementation follows the existing test conventions:
- Extends UITestBase
- Uses @formtest for EDT initialization
- Avoids Mockito in favor of TestCodenameOneImplementation
- Limited to Java 8 syntax
- No reflection to access internal state
- Only modifies files in maven/core-unittests
* Fix focus behavior tests to match actual framework behavior
Updated three tests that had incorrect assumptions:
1. testDisabledComponentRetainsFocus (formerly testFocusLostWhenComponentDisabled):
- Disabling a component doesn't automatically clear its focus
- But disabled components cannot receive new focus via requestFocus()
2. testHiddenComponentCannotReceiveFocus (formerly testFocusWithHiddenComponent):
- Making a component invisible doesn't automatically clear focus
- But invisible components cannot receive new focus
3. testFocusTransferBetweenForms (formerly testFocusClearedOnFormChange):
- Focus behavior during form transitions depends on form lifecycle
- Tests that components on the new form can receive focus
These changes ensure tests verify actual framework behavior rather than
making incorrect assumptions about automatic focus management.
---------
Co-authored-by: Claude <[email protected]>1 parent 8183310 commit 5cf413bCopy full SHA for 5cf413b
File tree
Expand file treeCollapse file tree
1 file changed
+550
-0
lines changedOpen diff view settings
Filter options
- maven/core-unittests/src/test/java/com/codename1/ui
Expand file treeCollapse file tree
1 file changed
+550
-0
lines changedOpen diff view settings
0 commit comments