@@ -14,6 +14,9 @@ import qualified Data.Text as T
14
14
15
15
import Potato.Flow
16
16
import Potato.Flow.TestStates
17
+ import Potato.Flow.GoatTester
18
+ import Potato.Flow.Controller.Manipulator.TestHelpers
19
+
17
20
18
21
testCanvas :: Int -> Int -> Int -> Int -> RenderedCanvasRegion
19
22
testCanvas x y w h = emptyRenderedCanvasRegion (LBox (V2 x y) (V2 w h))
@@ -33,8 +36,10 @@ potatoRenderWithSEltAndEmptyOwlTreeForTest selts rcr = potatoRenderWithOwlTree e
33
36
testsstyle :: SuperStyle
34
37
testsstyle = def { _superStyle_fill = FillStyle_Simple ' @' }
35
38
36
- spec :: Spec
37
- spec = do
39
+
40
+
41
+ spec1 :: Spec
42
+ spec1 = do
38
43
describe " Canvas" $ do
39
44
it " potato renders blank text" $ do
40
45
let
@@ -164,3 +169,79 @@ spec = do
164
169
canvas1 = _renderContext_renderedCanvasRegion rendercontext1
165
170
-- TODO test something
166
171
canvas1 `shouldBe` canvas1
172
+
173
+
174
+ emptyOwlStateWithSize :: (Int , Int ) -> OwlPFState
175
+ emptyOwlStateWithSize (x, y) = OwlPFState emptyOwlTree (SCanvas (LBox 0 (V2 x y)))
176
+
177
+ render_basic :: Spec
178
+ render_basic = hSpecGoatTesterWithOwlPFState (emptyOwlStateWithSize (20 ,20 )) $ do
179
+
180
+ setMarker " verify empty initial state"
181
+ verifyRenderNonEmptyCount 0
182
+
183
+ setMarker " draw a box"
184
+ drawCanvasBox (0 , 0 , 2 , 2 )
185
+ verifyRenderNonEmptyCount 4
186
+
187
+ setMarker " hide the box"
188
+ layerMouseDownUpRel LMO_Hide 0 0
189
+ verifyRenderNonEmptyCount 0
190
+
191
+ setMarker " unhide the box"
192
+ layerMouseDownUpRel LMO_Hide 0 0
193
+ verifyRenderNonEmptyCount 4
194
+
195
+ setMarker " delete the box"
196
+ pressBackspace
197
+ verifyRenderNonEmptyCount 0
198
+
199
+
200
+ render_hide_basic :: Spec
201
+ render_hide_basic = hSpecGoatTesterWithOwlPFState (emptyOwlStateWithSize (20 ,20 )) $ do
202
+
203
+ setMarker " verify empty initial state"
204
+ verifyRenderNonEmptyCount 0
205
+
206
+ setMarker " make a folder"
207
+ addFolder " hide me"
208
+
209
+ setMarker " draw a box"
210
+ drawCanvasBox (0 , 0 , 2 , 2 )
211
+ verifyRenderNonEmptyCount 4
212
+
213
+ setMarker " hide the folder"
214
+ layerMouseDownUpRel LMO_Hide 0 0
215
+ verifyRenderNonEmptyCount 0
216
+
217
+ setMarker " deselect evertyhing"
218
+ pressEscape
219
+ verifySelectionCount 0
220
+
221
+ setMarker " drag the box out of the folder"
222
+ layerMouseDownUpRel LMO_Normal 1 1
223
+ verifySelectionCount 1
224
+ layerMouseDownRel LMO_Normal 1 1
225
+ layerMouseDownUpRel (LMO_DropInFolder 0 ) 2 0
226
+ verifyRenderNonEmptyCount 4
227
+
228
+ setMarker " drag the box into the folder"
229
+ layerMouseDownRel LMO_Normal 1 0
230
+ layerMouseDownUpRel (LMO_DropInFolder 0 ) 1 1
231
+ verifyRenderNonEmptyCount 0
232
+
233
+
234
+
235
+
236
+ spec2 :: Spec
237
+ spec2 = do
238
+ describe " Render" $ do
239
+ describe " render_basic" $ render_basic
240
+ describe " render_hide_basic" $ render_hide_basic
241
+
242
+
243
+
244
+ spec :: Spec
245
+ spec = do
246
+ spec1
247
+ spec2
0 commit comments