From a2a8e8dd046678816c3797cb894b20abfe84e360 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sat, 21 Dec 2024 13:19:48 +0530 Subject: Fix issue with pointer coordinates + Add mouse press/release actions --- specs/Specs/AppStateUpdateSpec.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'specs/Specs') diff --git a/specs/Specs/AppStateUpdateSpec.hs b/specs/Specs/AppStateUpdateSpec.hs index 3f8ca47..fd79c95 100644 --- a/specs/Specs/AppStateUpdateSpec.hs +++ b/specs/Specs/AppStateUpdateSpec.hs @@ -2,7 +2,7 @@ module Specs.AppStateUpdateSpec where import Chelleport (initialState, update) import Chelleport.Types -import Chelleport.Utils (uniq) +import Chelleport.Utils (intToCInt, uniq) import Control.Monad (join) import Mock import qualified SDL @@ -90,6 +90,8 @@ test = do context "with action MoveMousePosition" $ do let currentState = defaultState + let rows = intToCInt $ length $ stateGrid currentState + let columns = intToCInt $ length $ head $ stateGrid currentState -- TODO: Test with inline mocked values it "moves mouse pointer to center of cell of given coordinates" $ do @@ -98,7 +100,10 @@ test = do -- [ CallPressMouseButton LeftClick `returns` (1, 2), -- CallHideWindow `returns` () -- ] - mock `shouldHaveCalled` CallMoveMousePosition 25 25 + mock + `shouldHaveCalled` CallMoveMousePosition + (mockWindowOffsetX + mockWindowWidth `div` columns `div` 2) + (mockWindowOffsetY + mockWindowHeight `div` rows `div` 2) it "does not continue or update state" $ do (result, _) <- runWithMocks $ update currentState $ MoveMousePosition (0, 0) -- cgit v1.3.1