diff --git a/src/test/kotlin/controllers/AutomatonTest.kt b/src/test/kotlin/controllers/AutomatonTest.kt index 07ab0e6..83eaea1 100644 --- a/src/test/kotlin/controllers/AutomatonTest.kt +++ b/src/test/kotlin/controllers/AutomatonTest.kt @@ -1,9 +1,12 @@ package controllers -import org.mockito.Mockito.* +import org.mockito.Mockito.mock +import org.mockito.Mockito.`when` +import params.MouseWiggleParams import java.awt.Point import java.awt.event.InputEvent import kotlin.test.Test +import kotlin.test.assertTrue class AutomatonTest { @@ -18,9 +21,26 @@ class AutomatonTest { */ @Test fun `Automaton extends DesktopController`() { + val automaton = mock(Automaton::class.java) - verify(automaton).getAlmostPoint(Point(100, 100)) - // Asserts Automaton extends DesktopController + + + // Given + val basePoint = Point(10, 10) + val wiggleParams = MouseWiggleParams(xWiggle = 5, yWiggle = 5) + + + // When + `when`(automaton.getAlmostPoint(basePoint, wiggleParams)).thenReturn(Point(12, 8)) + + val result = automaton.getAlmostPoint(basePoint, wiggleParams) + + // Then + assertTrue(result.x >= basePoint.x - wiggleParams.xWiggle) + assertTrue(result.x <= basePoint.x + wiggleParams.xWiggle) + + assertTrue(result.y >= basePoint.y - wiggleParams.yWiggle) + assertTrue(result.y <= basePoint.y + wiggleParams.yWiggle) } /** diff --git a/src/test/kotlin/controllers/OrchestratorTest.kt b/src/test/kotlin/controllers/OrchestratorTest.kt deleted file mode 100644 index 4138457..0000000 --- a/src/test/kotlin/controllers/OrchestratorTest.kt +++ /dev/null @@ -1,36 +0,0 @@ -package controllers - -import org.mockito.Mockito.* -import org.mockito.ArgumentMatchers.* -import java.awt.Point -import kotlin.test.Test - -class OrchestratorTest { - - /** - * Tests scrollOutToHeight() calls expected methods on Automaton. - * - * Creates mock Orchestrator and Automaton instances. - * Mocks the orchestrator's automaton to return the mock Automaton. - * Calls scrollOutToHeight() on the orchestrator mock. - * Verifies sleep(), doLoop(), scrollIn(), and scrollOut() are called on - * the Automaton mock with expected arguments. - * This validates scrollOutToHeight() correctly delegates to Automaton. - */ - @Test - fun `scrollOutToHeight calls doLoop and scroll methods`() { - val orchestrator = mock(Orchestrator::class.java) - val automaton = mock(Automaton::class.java) - - `when`(orchestrator.automaton).thenReturn(automaton) - - orchestrator.scrollOutToHeight(10) - - verify(automaton).sleep(anyLong()) - verify(orchestrator).doLoop(anyInt(), anyInt(), any()) - verify(automaton, times(2)).scrollIn(anyLong(), anyLong()) - verify(automaton, times(10)).scrollOut(anyLong(), anyLong()) - } - - -}