1module Testable.Element exposing
15 , expectRoundedEquality
49{-| This module should mirror the top level `Element` api, with one important distinction.
51The resulting `Element msg` structure can either be rendered to Html or transformed into a test suite that can be run.
53In order to run the test:
56 - gather information from the browser
68{-| This is used when we want to run all tests in a test suite instead of one at a time.
70toProgram : Testable.Runner.Testable -> Testable.Runner.TestableProgram
72 Testable.Runner.program [ testable ]
75layout : List (Testable.Attr msg) -> Testable.Element Testable.Runner.Msg -> Testable.Runner.Testable
77 Testable.Runner.testable "Test" elem
80text : String -> Testable.Element msg
85el : List (Testable.Attr msg) -> Testable.Element msg -> Testable.Element msg
87 Testable.El (implicitWidthHeightShrink attrs)
90row : List (Testable.Attr msg) -> List (Testable.Element msg) -> Testable.Element msg
92 Testable.Row (implicitWidthHeightShrink attrs)
95column : List (Testable.Attr msg) -> List (Testable.Element msg) -> Testable.Element msg
97 Testable.Column (implicitWidthHeightShrink attrs)
100none : Testable.Element msg
105paragraph : List (Testable.Attr msg) -> List (Testable.Element msg) -> Testable.Element msg
109 implicitTest (widthHelper Nothing Nothing (Fill 1))
110 :: implicitTest (heightHelper Nothing Nothing Shrink)
113 Testable.Paragraph (skipOverridden withImplicits)
116textColumn : List (Testable.Attr msg) -> List (Testable.Element msg) -> Testable.Element msg
120 implicitTest (widthHelper (Just 500) (Just 750) (Fill 1))
121 :: implicitTest (heightHelper Nothing Nothing Shrink)
124 Testable.TextColumn (skipOverridden withImplicits)
128 List (Testable.Attr msg)
131 , label : Testable.Element msg
133 -> Testable.Element msg
135 -- TODO: this is not actually a link element!!
136 Testable.El (implicitWidthHeightShrink attrs) details.label
139{-| Old labeling mechanism that i removed to hastily
146 Testable.Attr (Element.moveUp x)
150 Testable.Attr (Element.moveDown x)
154 Testable.Attr (Element.moveRight x)
158 Testable.Attr (Element.moveLeft x)
200fillPortion : Int -> Length
205transparent : Bool -> Testable.Attr msg
214 , attr = Element.transparent on
221 |> Dict.get "opacity"
222 |> Maybe.withDefault "notfound"
231 [ Testable.equal value selfTransparency ]
236isVisible : Testable.Attr msg
239 { label = "is-visible"
243 [ Testable.equal context.self.isVisible True ]
248alpha : Float -> Testable.Attr msg
251 { label = "alpha-" ++ String.fromFloat a
252 , attr = Element.alpha a
259 |> Dict.get "opacity"
260 |> Maybe.withDefault "notfound"
262 [ Testable.equal (String.fromFloat a) selfTransparency ]
267padding : Int -> Testable.Attr msg
270 { label = "padding " ++ String.fromInt pad
271 , attr = Element.padding pad
275 [ Testable.true ("Padding " ++ String.fromInt pad ++ " is present")
277 [ floor found.self.bbox.padding.left
278 , floor found.self.bbox.padding.right
279 , floor found.self.bbox.padding.top
280 , floor found.self.bbox.padding.bottom
288paddingXY : Int -> Int -> Testable.Attr msg
291 { label = "paddingXY " ++ String.fromInt x ++ ", " ++ String.fromInt y
292 , attr = Element.paddingXY x y
296 [ Testable.true ("PaddingXY (" ++ String.fromInt x ++ ", " ++ String.fromInt y ++ ") is present")
298 [ floor found.self.bbox.padding.left
299 , floor found.self.bbox.padding.right
302 [ floor found.self.bbox.padding.top
303 , floor found.self.bbox.padding.bottom
311 List.filter Tuple.first ls
312 |> List.map Tuple.second
315widthHelper maybeMin maybeMax len =
323 l |> Element.minimum minPx
331 l |> Element.maximum maxPx
339 " min:" ++ String.fromInt i
347 " max:" ++ String.fromInt i
349 minMaxTest actualWidth =
350 case ( maybeMin, maybeMax ) of
351 ( Nothing, Nothing ) ->
354 ( Just lower, Nothing ) ->
357 ( Just lower, Just higher ) ->
358 lower <= actualWidth && actualWidth <= higher
360 ( Nothing, Just higher ) ->
361 actualWidth <= higher
365 widthHelper (Just m) maybeMax newLen
368 widthHelper maybeMin (Just m) newLen
371 -- Pixel values should ignore min and max?
373 { label = "width " ++ String.fromInt val ++ "px" ++ minLabel ++ maxLabel
374 , id = Testable.IsWidth
383 [ expectRoundedEquality
384 { expected = toFloat val
385 , found = found.self.bbox.width
387 , Testable.true "min/max is upheld" (minMaxTest (floor found.self.bbox.width))
395 "width fill" ++ minLabel ++ maxLabel
398 "width fill-" ++ String.fromInt portion ++ minLabel ++ maxLabel
399 , id = Testable.IsWidth
402 (Element.fillPortion portion
408 if List.member context.parentLayout [ Testable.IsNearby Testable.OnRight, Testable.IsNearby Testable.OnLeft ] then
409 [ Testable.true "width fill doesn't apply to onright/onleft elements" True ]
413 parentAvailableWidth =
414 context.parent.bbox.width - (context.self.bbox.padding.left + context.self.bbox.padding.right)
417 [ case context.parentLayout of
418 Testable.IsNearby _ ->
419 [ Testable.true "Nearby Element has fill width"
420 ((floor context.parent.bbox.width == floor context.self.bbox.width)
421 || minMaxTest (floor context.self.bbox.width)
426 [ Testable.true "Element within column has fill width"
427 ((floor parentAvailableWidth == floor context.self.bbox.width)
428 || minMaxTest (floor context.self.bbox.width)
433 [ Testable.true "Element within element has fill width" <|
434 (floor parentAvailableWidth == floor context.self.bbox.width)
435 || minMaxTest (floor context.self.bbox.width)
441 parentAvailableWidth / toFloat (List.length context.siblings + 1)
443 [ Testable.true "element has fill width" <|
444 (floor spacePerPortion == floor context.self.bbox.width)
445 || minMaxTest (floor context.self.bbox.width)
447 , [ Testable.lessThanOrEqual "not larger than parent"
448 context.self.bbox.width
449 context.parent.bbox.width
451 , case context.selfElement of
452 Testable.Paragraph _ _ ->
453 -- A paragraph with width fill
454 -- we want to test for correct text wrapping here.
462 |> List.map childWidth
463 |> List.append (List.map .width context.self.textMetrics)
467 context.self.bbox.padding.left + context.self.bbox.padding.right
469 totalCalculatedWidth =
470 totalChildren + horizontalPadding
473 if boxChildrenHeight > 20 then
474 ceiling (boxChildrenHeight / 20)
477 ceiling (totalCalculatedWidth / context.self.bbox.width)
487 [ Testable.true "text wrapping, checking height"
488 -- all we're doing here is testing if wrapping is occurring
489 -- not the exact height, which is a little tricky to calculate perfectly without more information.
490 (if expectedLines > 1 then
491 context.self.bbox.height >= (20 * 2)
494 -- then it's less than 2 ~ line heights
495 -- there's some weird variance here which makes it hard to be exact.
496 context.self.bbox.height < (20 * 2)
507 { label = "width shrink" ++ minLabel ++ maxLabel
514 , id = Testable.IsWidth
517 case context.selfElement of
525 |> List.map childWidth
526 |> List.append (List.map .width context.self.textMetrics)
530 context.self.bbox.padding.left + context.self.bbox.padding.right
533 [ ( (context.parentLayout /= Testable.InParagraph)
534 && (context.parentLayout /= Testable.InTextCol)
535 , Testable.rounded "equals children"
536 { expected = totalChildren + horizontalPadding
537 , found = context.self.bbox.width
540 , ( context.parentLayout /= Testable.AtRoot
541 , Testable.lessThanOrEqual "not larger than parent"
542 context.self.bbox.width
543 context.parent.bbox.width
547 Testable.Row rowAttrs _ ->
548 -- width of row is the sum of all children widths
549 -- both text elements and others.
556 |> List.map childWidth
557 |> List.append (List.map .width context.self.textMetrics)
561 context.self.bbox.padding.left + context.self.bbox.padding.right
564 Testable.getSpacingFromAttributes rowAttrs
567 toFloat spacingAmount * (toFloat (List.length context.children) - 1)
571 , expectRoundedEquality
572 { expected = totalChildren + horizontalPadding + totalSpacing
573 , found = context.self.bbox.width
576 , ( context.parentLayout /= Testable.AtRoot
577 , Testable.lessThanOrEqual "not larger than parent"
578 context.self.bbox.width
579 context.parent.bbox.width
583 Testable.Column _ _ ->
584 -- The width of the column is the width of the widest child.
588 + context.self.bbox.padding.left
589 + context.self.bbox.padding.right
595 + context.self.bbox.padding.left
596 + context.self.bbox.padding.right
598 context.self.textMetrics
602 |> List.map childWidth
603 |> List.append textChildren
607 , expectRoundedEquality
608 { expected = Maybe.withDefault 0 (List.maximum allChildren)
609 , found = context.self.bbox.width
612 , ( context.parentLayout /= Testable.AtRoot
613 , Testable.lessThanOrEqual "not larger than parent"
614 context.self.bbox.width
615 context.parent.bbox.width
619 Testable.TextColumn _ _ ->
620 -- The width of the column is the width of the widest child.
624 + context.self.bbox.padding.left
625 + context.self.bbox.padding.right
631 + context.self.bbox.padding.left
632 + context.self.bbox.padding.right
634 context.self.textMetrics
638 |> List.map childWidth
639 |> List.append textChildren
643 , expectRoundedEquality
644 { expected = Maybe.withDefault 0 (List.maximum allChildren)
645 , found = context.self.bbox.width
648 , ( context.parentLayout /= Testable.AtRoot
649 , Testable.lessThanOrEqual "not larger than parent"
650 context.self.bbox.width
651 context.parent.bbox.width
655 Testable.Paragraph _ _ ->
656 -- This should be the size it's text,
657 -- unless it takes up all available space, in which case it should wrap.
664 |> List.map childWidth
665 |> List.append (List.map .width context.self.textMetrics)
669 context.self.bbox.padding.left + context.self.bbox.padding.right
673 , expectRoundedEquality
674 { expected = totalChildren + horizontalPadding
675 , found = context.self.bbox.width
678 , ( context.parentLayout /= Testable.AtRoot
679 , Testable.lessThanOrEqual "not larger than parent"
680 context.self.bbox.width
681 context.parent.bbox.width
693heightHelper maybeMin maybeMax len =
701 l |> Element.minimum minPx
709 l |> Element.maximum maxPx
717 " min:" ++ String.fromInt i
725 " max:" ++ String.fromInt i
727 minMaxTest actualheight =
728 case ( maybeMin, maybeMax ) of
729 ( Nothing, Nothing ) ->
732 ( Just lower, Nothing ) ->
733 lower <= actualheight
735 ( Just lower, Just higher ) ->
736 lower <= actualheight && actualheight <= higher
738 ( Nothing, Just higher ) ->
739 actualheight <= higher
743 heightHelper (Just m) maybeMax newLen
746 heightHelper maybeMin (Just m) newLen
749 -- Pixel values should ignore min and max?
751 { label = "height " ++ String.fromInt val ++ "px" ++ minLabel ++ maxLabel
758 , id = Testable.IsHeight
761 [ expectRoundedEquality
762 { expected = toFloat val
763 , found = found.self.bbox.height
765 , Testable.true "min/max holds true"
766 (minMaxTest (floor found.self.bbox.height))
772 { label = "height fill-" ++ String.fromInt portion ++ minLabel ++ maxLabel
775 (Element.fillPortion portion
779 , id = Testable.IsHeight
782 [ if List.member context.parentLayout [ Testable.IsNearby Testable.Above, Testable.IsNearby Testable.Below ] then
783 Testable.true "height fill doesn't apply to above/below elements" True
787 parentAvailableHeight =
788 context.parent.bbox.height - (context.self.bbox.padding.top + context.self.bbox.padding.bottom)
790 case context.parentLayout of
791 Testable.IsNearby _ ->
792 Testable.true "Nearby Element has fill height"
793 ((floor context.parent.bbox.height == floor context.self.bbox.height)
794 || minMaxTest (floor context.self.bbox.height)
798 Testable.true "Element within column has fill height"
799 ((floor parentAvailableHeight == floor context.self.bbox.height)
800 || minMaxTest (floor context.self.bbox.height)
804 Testable.true "Element within el has fill height" <|
805 (floor parentAvailableHeight == floor context.self.bbox.height)
806 || minMaxTest (floor context.self.bbox.height)
811 parentAvailableHeight / toFloat (List.length context.siblings + 1)
813 Testable.true "el has fill height" <|
814 (floor spacePerPortion == floor context.self.bbox.height)
815 || minMaxTest (floor context.self.bbox.height)
821 { label = "height shrink" ++ minLabel ++ maxLabel
828 , id = Testable.IsHeight
831 case context.selfElement of
837 if List.isEmpty context.children then
838 -- context.self.textMetrics
839 -- |> List.map Testable.textHeight
841 -- TODO: apparently the font metrics we have are for the literal characters rendered
842 -- not for the font itself.
843 [ Testable.todo "calculate height from actual text metrics"
847 [ expectRoundedEquality
850 |> List.map childHeight
852 |> (\h -> h + context.self.bbox.padding.top + context.self.bbox.padding.bottom)
853 , found = context.self.bbox.height
855 , Testable.lessThanOrEqual "not larger than parent"
856 context.self.bbox.height
857 context.parent.bbox.height
865 if List.isEmpty context.children then
866 -- context.self.textMetrics
867 -- |> List.map Testable.textHeight
869 -- TODO: apparently the font metrics we have are for the literal characters rendered
870 -- not for the font itself.
871 [ Testable.todo "calculate height from actual text metrics" ]
874 [ expectRoundedEquality
877 |> List.map childHeight
879 |> Maybe.withDefault 0
880 |> (\h -> h + context.self.bbox.padding.top + context.self.bbox.padding.bottom)
881 , found = context.self.bbox.height
883 , Testable.lessThanOrEqual "not larger than parent"
884 context.self.bbox.height
885 context.parent.bbox.height
888 Testable.Column colAttrs _ ->
895 |> List.map childHeight
896 |> List.append (List.map Testable.textHeight context.self.textMetrics)
900 context.self.bbox.padding.top + context.self.bbox.padding.bottom
903 Testable.getSpacingFromAttributes colAttrs
906 toFloat spacingAmount * (toFloat (List.length context.children) - 1)
908 [ expectRoundedEquality
909 { expected = totalChildren + verticalPadding + totalSpacing
910 , found = context.self.bbox.height
912 , Testable.lessThanOrEqual "not larger than parent"
913 context.self.bbox.height
914 context.parent.bbox.height
917 Testable.TextColumn _ _ ->
920 Testable.Paragraph _ _ ->
931width : Length -> Testable.Attr msg
933 widthHelper Nothing Nothing len
936height : Length -> Testable.Attr msg
938 heightHelper Nothing Nothing len
941spacing : Int -> Testable.Attr msg
944 [ Testable.Spacing space
945 , Testable.LabeledTest
946 { label = "spacing: " ++ String.fromInt space
947 , attr = Element.spacing space
952 findDistance child total =
959 - otherChild.bbox.right
964 - otherChild.bbox.bottom
966 [ if horizontal > 0 then
971 , if vertical > 0 then
982 List.foldl findDistance [] found.children
987 if not (x >= space) then
997 ("All children are at least "
998 ++ String.fromInt space
1000 ++ Debug.toString allAreSpaced
1001 ++ " are not though"
1003 (allAreSpaced == [])
1009{-| alignLeft needs to account for
1012 - elements to the left
1015in order to calculate the expected result.
1017Also need parent rendering context if this is to work with wrapped rows in the future.
1022alignLeft : Testable.Attr msg
1024 Testable.LabeledTest
1025 { label = "alignLeft"
1026 , attr = Element.alignLeft
1027 , id = Testable.NoId
1030 [ if List.member found.parentLayout [ Testable.IsNearby Testable.OnLeft, Testable.IsNearby Testable.OnRight ] then
1031 Testable.true "alignLeft doesn't apply to elements that are onLeft or onRight" True
1034 List.member found.parentLayout
1035 [ Testable.IsNearby Testable.InFront
1036 , Testable.IsNearby Testable.Behind
1037 , Testable.IsNearby Testable.Above
1038 , Testable.IsNearby Testable.Below
1041 expectRoundedEquality
1042 { found = found.self.bbox.left
1043 , expected = found.parent.bbox.left
1046 else if List.length found.siblings == 0 then
1047 expectRoundedEquality
1048 { found = found.self.bbox.left
1049 , expected = found.parent.bbox.left + found.parent.bbox.padding.left
1053 case found.parentLayout of
1057 List.filter (\x -> x.bbox.right < found.self.bbox.left) found.siblings
1060 toFloat (List.length siblingsOnLeft * found.parentSpacing)
1064 |> List.map (.width << .bbox)
1067 expectRoundedEquality
1068 { found = found.self.bbox.left
1069 , expected = found.parent.bbox.left + (found.parent.bbox.padding.left + widthsOnLeft + spacings)
1073 expectRoundedEquality
1074 { found = found.self.bbox.left
1075 , expected = found.parent.bbox.left + found.parent.bbox.padding.left
1082centerX : Testable.Attr msg
1084 Testable.LabeledTest
1086 , attr = Element.centerX
1087 , id = Testable.NoId
1093 found.self.bbox.left + (found.self.bbox.width / 2)
1095 parentCenter : Float
1097 found.parent.bbox.left + (found.parent.bbox.width / 2)
1099 if List.member found.parentLayout [ Testable.IsNearby Testable.OnRight, Testable.IsNearby Testable.OnLeft ] then
1100 [ Testable.true "centerX doesn't apply to elements that are onLeft or onRight" True ]
1102 else if List.length found.siblings == 0 then
1103 [ expectRoundedEquality
1104 { found = selfCenter
1105 , expected = parentCenter
1110 case found.parentLayout of
1114 List.filter (\x -> x.bbox.right < found.self.bbox.left) found.siblings
1117 List.filter (\x -> x.bbox.left > found.self.bbox.right) found.siblings
1119 widthsOnLeft : Float
1122 |> List.map (.width << .bbox)
1124 |> (\x -> x + (toFloat (List.length siblingsOnLeft) * toFloat found.parentSpacing))
1128 |> List.map (.width << .bbox)
1130 |> (\x -> x + (toFloat (List.length siblingsOnRight) * toFloat found.parentSpacing))
1132 expectedCenter : Float
1134 found.parent.bbox.left
1136 + ((found.parent.bbox.width - (widthsOnRight + widthsOnLeft))
1140 [ expectRoundedEquality
1141 { found = selfCenter
1142 , expected = expectedCenter
1147 [ expectRoundedEquality
1148 { found = selfCenter
1149 , expected = parentCenter
1156alignRight : Testable.Attr msg
1158 Testable.LabeledTest
1159 { label = "alignRight"
1160 , attr = Element.alignRight
1161 , id = Testable.NoId
1164 if List.member found.parentLayout [ Testable.IsNearby Testable.OnLeft, Testable.IsNearby Testable.OnRight ] then
1165 [ Testable.true "alignRight doesn't apply to elements that are onLeft or onRight" True ]
1168 List.member found.parentLayout
1169 [ Testable.IsNearby Testable.InFront
1170 , Testable.IsNearby Testable.Behind
1171 , Testable.IsNearby Testable.Above
1172 , Testable.IsNearby Testable.Below
1175 [ expectRoundedEquality
1176 { found = found.self.bbox.right
1177 , expected = found.parent.bbox.right
1181 else if List.length found.siblings == 0 then
1182 [ expectRoundedEquality
1183 { found = found.self.bbox.right
1184 , expected = found.parent.bbox.right + found.parent.bbox.padding.right
1189 case found.parentLayout of
1193 List.filter (\x -> x.bbox.left > found.self.bbox.right) found.siblings
1196 toFloat (List.length siblingsOnRight * found.parentSpacing)
1200 |> List.map (.width << .bbox)
1203 [ expectRoundedEquality
1204 { found = found.self.bbox.right
1205 , expected = found.parent.bbox.right - (found.parent.bbox.padding.right + widthsOnRight + spacings)
1210 [ expectRoundedEquality
1211 { found = found.self.bbox.right
1212 , expected = found.parent.bbox.right + found.parent.bbox.padding.right
1219alignTop : Testable.Attr msg
1221 Testable.LabeledTest
1222 { label = "alignTop"
1223 , attr = Element.alignTop
1224 , id = Testable.NoId
1227 if List.member found.parentLayout [ Testable.IsNearby Testable.Above, Testable.IsNearby Testable.Below ] then
1228 [ Testable.true "alignTop doesn't apply to elements that are above or below" True ]
1231 List.member found.parentLayout
1232 [ Testable.IsNearby Testable.InFront
1233 , Testable.IsNearby Testable.Behind
1234 , Testable.IsNearby Testable.OnRight
1235 , Testable.IsNearby Testable.OnLeft
1238 [ expectRoundedEquality
1239 { found = found.self.bbox.top
1240 , expected = found.parent.bbox.top
1244 else if List.length found.siblings == 0 then
1245 [ expectRoundedEquality
1246 { found = found.self.bbox.top
1247 , expected = found.parent.bbox.top + found.parent.bbox.padding.top
1252 case found.parentLayout of
1253 Testable.InColumn ->
1256 List.filter (\x -> x.bbox.bottom < found.self.bbox.top) found.siblings
1259 toFloat (List.length siblingsAbove * found.parentSpacing)
1263 |> List.map (.height << .bbox)
1266 [ expectRoundedEquality
1267 { found = found.self.bbox.top
1268 , expected = found.parent.bbox.top + (found.parent.bbox.padding.top + heightsAbove + spacings)
1273 [ expectRoundedEquality
1274 { found = found.self.bbox.top
1275 , expected = found.parent.bbox.top
1282alignBottom : Testable.Attr msg
1284 Testable.LabeledTest
1285 { label = "alignBottom"
1286 , attr = Element.alignBottom
1287 , id = Testable.NoId
1290 if List.member found.parentLayout [ Testable.IsNearby Testable.Above, Testable.IsNearby Testable.Below ] then
1291 [ Testable.true "alignBottom doesn't apply to elements that are above or below" True ]
1294 List.member found.parentLayout
1295 [ Testable.IsNearby Testable.InFront
1296 , Testable.IsNearby Testable.Behind
1297 , Testable.IsNearby Testable.OnRight
1298 , Testable.IsNearby Testable.OnLeft
1301 [ expectRoundedEquality
1302 { found = found.self.bbox.bottom
1303 , expected = found.parent.bbox.bottom
1307 else if List.length found.siblings == 0 then
1308 [ expectRoundedEquality
1309 { found = found.self.bbox.bottom
1310 , expected = found.parent.bbox.bottom + found.parent.bbox.padding.bottom
1315 case found.parentLayout of
1316 Testable.InColumn ->
1319 List.filter (\x -> x.bbox.top > found.self.bbox.bottom) found.siblings
1322 toFloat (List.length siblingsBelow * found.parentSpacing)
1326 |> List.map (.height << .bbox)
1329 [ expectRoundedEquality
1330 { found = found.self.bbox.bottom
1331 , expected = found.parent.bbox.bottom - (found.parent.bbox.padding.bottom + heightsBelow + spacings)
1336 [ expectRoundedEquality
1337 { found = found.self.bbox.bottom
1338 , expected = found.parent.bbox.bottom + found.parent.bbox.padding.bottom
1344expectRoundedEquality : { expected : Float, found : Float } -> Testable.LayoutExpectation
1345expectRoundedEquality { expected, found } =
1347 ("expected " ++ floatToString expected ++ ", found " ++ floatToString found)
1348 (abs (expected - found) < 1)
1351floatToString : Float -> String
1353 String.fromFloat (toFloat (round (x * 100)) / 100)
1357centerY : Testable.Attr msg
1359 Testable.LabeledTest
1361 , attr = Element.centerY
1362 , id = Testable.NoId
1367 found.self.bbox.top + (found.self.bbox.height / 2)
1370 found.parent.bbox.top + (found.parent.bbox.height / 2)
1372 if List.member found.parentLayout [ Testable.IsNearby Testable.Above, Testable.IsNearby Testable.Below ] then
1373 [ Testable.true "centerY doesn't apply to elements that are above or below" True ]
1375 else if List.length found.siblings == 0 then
1376 [ expectRoundedEquality
1377 { found = selfCenter
1378 , expected = parentCenter
1383 case found.parentLayout of
1384 Testable.InColumn ->
1387 List.filter (\x -> x.bbox.bottom < found.self.bbox.top) found.siblings
1390 List.filter (\x -> x.bbox.top > found.self.bbox.bottom) found.siblings
1392 heightsAbove : Float
1395 |> List.map (.height << .bbox)
1397 |> (\x -> x + (toFloat (List.length siblingsOnTop) * toFloat found.parentSpacing))
1401 |> List.map (.height << .bbox)
1403 |> (\x -> x + (toFloat (List.length siblingsBelow) * toFloat found.parentSpacing))
1405 expectedCenter : Float
1407 found.parent.bbox.top
1409 + ((found.parent.bbox.height - (heightsBelow + heightsAbove))
1413 [ expectRoundedEquality
1414 { found = selfCenter
1415 , expected = expectedCenter
1420 [ expectRoundedEquality
1421 { found = selfCenter
1422 , expected = parentCenter
1429above : Testable.Element msg -> Testable.Attr msg
1432 { location = Testable.Above
1437 [ expectRoundedEquality
1438 { found = found.self.bbox.bottom
1439 , expected = found.parent.bbox.top
1446below : Testable.Element msg -> Testable.Attr msg
1449 { location = Testable.Below
1454 [ expectRoundedEquality
1455 { found = found.self.bbox.top
1456 , expected = found.parent.bbox.bottom
1463onRight : Testable.Element msg -> Testable.Attr msg
1466 { location = Testable.OnRight
1471 [ expectRoundedEquality
1472 { found = found.self.bbox.left
1473 , expected = found.parent.bbox.right
1480onLeft : Testable.Element msg -> Testable.Attr msg
1483 { location = Testable.OnLeft
1488 [ expectRoundedEquality
1489 { found = found.self.bbox.right
1490 , expected = found.parent.bbox.left
1497 vs (round x) (round y) || vs (floor x) (floor y)
1501inFront : Testable.Element msg -> Testable.Attr msg
1504 { location = Testable.InFront
1509 [ withinHelper found ]
1516 if found.self.bbox.width > found.parent.bbox.width then
1517 [ compare found.self.bbox.right (<=) found.parent.bbox.right
1518 || compare found.self.bbox.left (>=) found.parent.bbox.left
1522 [ compare found.self.bbox.right (<=) found.parent.bbox.right
1523 , compare found.self.bbox.left (>=) found.parent.bbox.left
1527 if found.self.bbox.width > found.parent.bbox.width then
1528 [ compare found.self.bbox.top (>=) found.parent.bbox.top
1529 || compare found.self.bbox.bottom (<=) found.parent.bbox.bottom
1533 [ compare found.self.bbox.top (>=) found.parent.bbox.top
1534 , compare found.self.bbox.bottom (<=) found.parent.bbox.bottom
1537 Testable.true "within the confines of the parent"
1538 (List.all ((==) True)
1548behindContent : Testable.Element msg -> Testable.Attr msg
1549behindContent element =
1551 { location = Testable.Behind
1553 , label = "behindContent"
1556 [ withinHelper found ]
1561{- Implicit width/height calcualtions -}
1564implicitWidthHeightShrink attrs =
1567 implicitTest (widthHelper Nothing Nothing Shrink)
1568 :: implicitTest (heightHelper Nothing Nothing Shrink)
1571 skipOverridden withImplicits
1576 Testable.LabeledTest details ->
1579 Testable.AttrTest details ->
1588 (\attr ( found, caught ) ->
1598 , hasHeight = found.hasHeight
1602 Testable.IsHeight ->
1604 , { hasWidth = found.hasWidth
1617 ( { hasWidth = False
1627{-| This is taking a normal test and rmoving its ability to attach a real `Element` attribute.
1631 Testable.LabeledTest details ->
1633 { test = details.test
1634 , label = "Implicit -> " ++ details.label
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list