Skip to content

Commit 5cf413b

Browse files
shai-almogclaude
andauthored
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 5cf413b

File tree

1 file changed

+550
-0
lines changed

1 file changed

+550
-0
lines changed

0 commit comments

Comments
 (0)