@@ -16,12 +16,33 @@ import Potato.Flow
16
16
import Potato.Flow.Controller.Manipulator.TestHelpers
17
17
18
18
19
+ fetchLatestEllipse :: OwlPFState -> Either Text SEllipse
20
+ fetchLatestEllipse pfs = do
21
+ sowl <- case maybeGetMostRecentlyCreatedOwl' pfs of
22
+ Nothing -> Left " failed, no 🦉s"
23
+ Just x -> Right x
24
+ case _owlItem_subItem (_superOwl_elt sowl) of
25
+ OwlSubItemEllipse x -> Right x
26
+ x -> Left $ " expected SEllipse got: " <> show x
27
+
28
+ verifyMostRecentlyCreatedEllipseHasSize :: (Int , Int ) -> GoatTester ()
29
+ verifyMostRecentlyCreatedEllipseHasSize (x, y) = verifyStateObjectHasProperty " verifyMostRecentlyCreatedEllipseHasSize" fetchLatestEllipse checkfn where
30
+ checkfn sellipse = r where
31
+ LBox _ (V2 x' y') = _sEllipse_box sellipse
32
+ r = if x == x' && y == y'
33
+ then Nothing
34
+ else Just $ " got size " <> show (x', y') <> " expected " <> show (x, y)
35
+
36
+
19
37
drawShape :: (Int , Int , Int , Int ) -> GoatTester ()
20
38
drawShape (x, y, sx, sy) = do
21
39
count <- getOwlCount
22
40
setTool Tool_Shape
23
41
tool <- getTool
24
42
verifyEqual " tool is shape" tool Tool_Shape
43
+
44
+ -- TODO set shape, it's hardcoded right now
45
+
25
46
canvasMouseDown (x, y)
26
47
canvasMouseDown (x+ sx, y+ sy)
27
48
verifyOwlCount (count+ 1 )
@@ -49,8 +70,18 @@ basic_cancel = hSpecGoatTesterWithOwlPFState emptyOwlPFState $ do
49
70
pressEscape
50
71
verifyOwlCount count
51
72
73
+ modifyEllipse_test :: Spec
74
+ modifyEllipse_test = hSpecGoatTesterWithOwlPFState emptyOwlPFState $ do
75
+ drawShape (1 , 1 , 100 , 100 )
76
+ verifyMostRecentlyCreatedEllipseHasSize (100 ,100 )
77
+ canvasMouseDown (0 , 0 )
78
+ canvasMouseDown (- 10 , - 10 )
79
+ canvasMouseUp (- 10 , - 10 )
80
+ verifyMostRecentlyCreatedEllipseHasSize (110 ,110 )
81
+
52
82
spec :: Spec
53
83
spec = do
54
84
describe " Shape" $ do
55
85
describe " basic" $ basic_test
56
86
describe " basic_cancel" $ basic_cancel
87
+ describe " modifyEllipse_test" $ modifyEllipse_test
0 commit comments