Skip to content

Commit 2adc7ef

Browse files
add UTs
1 parent 8c56502 commit 2adc7ef

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

TODO.txt

+5-3
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,11 @@ DONE-support label and text area
244244
IGNORE-refactor ShapeDef please...
245245
DONE-connect fully and deprecate BoxLabel/TextHandler
246246
-you can still keep BoxHandler for now as it does multi-select for you
247-
-make ellipse drawer
248-
-add UTs
249-
-make basic shape renderer that just fills all intersecting lines with fill character or whatever
247+
DONE-make poopy ellipse drawer
248+
DONE-add UTs
249+
-add text area to ellipse, maybe add text label?
250+
-make generic shape drawer
251+
-add shape selection menu
250252

251253
:: shape tool spec
252254
-can we generalize box and boxtext handlers to support any shape

test/Potato/Flow/Controller/Manipulator/ShapeSpec.hs

+31
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,33 @@ import Potato.Flow
1616
import Potato.Flow.Controller.Manipulator.TestHelpers
1717

1818

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+
1937
drawShape :: (Int, Int, Int, Int) -> GoatTester ()
2038
drawShape (x, y, sx, sy) = do
2139
count <- getOwlCount
2240
setTool Tool_Shape
2341
tool <- getTool
2442
verifyEqual "tool is shape" tool Tool_Shape
43+
44+
-- TODO set shape, it's hardcoded right now
45+
2546
canvasMouseDown (x, y)
2647
canvasMouseDown (x+sx, y+sy)
2748
verifyOwlCount (count+1)
@@ -49,8 +70,18 @@ basic_cancel = hSpecGoatTesterWithOwlPFState emptyOwlPFState $ do
4970
pressEscape
5071
verifyOwlCount count
5172

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+
5282
spec :: Spec
5383
spec = do
5484
describe "Shape" $ do
5585
describe "basic" $ basic_test
5686
describe "basic_cancel" $ basic_cancel
87+
describe "modifyEllipse_test" $ modifyEllipse_test

0 commit comments

Comments
 (0)