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
310widthHelper maybeMin maybeMax len =
318 l |> Element.minimum minPx
326 l |> Element.maximum maxPx
334 " min:" ++ String.fromInt i
342 " max:" ++ String.fromInt i
344 minMaxTest actualWidth =
345 case ( maybeMin, maybeMax ) of
346 ( Nothing, Nothing ) ->
349 ( Just lower, Nothing ) ->
352 ( Just lower, Just higher ) ->
353 lower <= actualWidth && actualWidth <= higher
355 ( Nothing, Just higher ) ->
356 actualWidth <= higher
360 widthHelper (Just m) maybeMax newLen
363 widthHelper maybeMin (Just m) newLen
366 -- Pixel values should ignore min and max?
368 { label = "width " ++ String.fromInt val ++ "px" ++ minLabel ++ maxLabel
369 , id = Testable.IsWidth
378 [ expectRoundedEquality
379 { expected = toFloat val
380 , found = found.self.bbox.width
382 , Testable.true "min/max is upheld" (minMaxTest (floor found.self.bbox.width))
390 "width fill" ++ minLabel ++ maxLabel
393 "width fill-" ++ String.fromInt portion ++ minLabel ++ maxLabel
394 , id = Testable.IsWidth
397 (Element.fillPortion portion
403 if List.member context.parentLayout [ Testable.IsNearby Testable.OnRight, Testable.IsNearby Testable.OnLeft ] then
404 [ Testable.true "width fill doesn't apply to onright/onleft elements" True ]
408 parentAvailableWidth =
409 context.parent.bbox.width - (context.self.bbox.padding.left + context.self.bbox.padding.right)
412 [ case context.parentLayout of
413 Testable.IsNearby _ ->
414 [ Testable.true "Nearby Element has fill width"
415 ((floor context.parent.bbox.width == floor context.self.bbox.width)
416 || minMaxTest (floor context.self.bbox.width)
421 [ Testable.true "Element within column has fill width"
422 ((floor parentAvailableWidth == floor context.self.bbox.width)
423 || minMaxTest (floor context.self.bbox.width)
428 [ Testable.true "Element within element has fill width" <|
429 (floor parentAvailableWidth == floor context.self.bbox.width)
430 || minMaxTest (floor context.self.bbox.width)
436 parentAvailableWidth / toFloat (List.length context.siblings + 1)
438 [ Testable.true "element has fill width" <|
439 (floor spacePerPortion == floor context.self.bbox.width)
440 || minMaxTest (floor context.self.bbox.width)
442 , [ Testable.lessThanOrEqual "not larger than parent"
443 context.self.bbox.width
444 context.parent.bbox.width
446 , case context.selfElement of
447 Testable.Paragraph _ _ ->
448 -- A paragraph with width fill
449 -- we want to test for correct text wrapping here.
457 |> List.map childWidth
458 |> List.append (List.map .width context.self.textMetrics)
462 context.self.bbox.padding.left + context.self.bbox.padding.right
464 totalCalculatedWidth =
465 totalChildren + horizontalPadding
468 ceiling (totalCalculatedWidth / context.self.bbox.width)
470 [ Testable.rounded "text wrapping, checking height"
471 { expected = toFloat (expectedLines * 22)
472 , found = context.self.bbox.height
483 { label = "width shrink" ++ minLabel ++ maxLabel
490 , id = Testable.IsWidth
493 case context.selfElement of
501 |> List.map childWidth
502 |> List.append (List.map .width context.self.textMetrics)
506 context.self.bbox.padding.left + context.self.bbox.padding.right
512 |> List.map childWidth
513 , text = List.map .width context.self.textMetrics
516 [ Testable.rounded "equals children"
517 { expected = totalChildren + horizontalPadding
518 , found = context.self.bbox.width
520 , Testable.lessThanOrEqual "not larger than parent"
521 context.self.bbox.width
522 context.parent.bbox.width
525 Testable.Row rowAttrs _ ->
526 -- width of row is the sum of all children widths
527 -- both text elements and others.
534 |> List.map childWidth
535 |> List.append (List.map .width context.self.textMetrics)
539 context.self.bbox.padding.left + context.self.bbox.padding.right
542 Testable.getSpacingFromAttributes rowAttrs
545 toFloat spacingAmount * (toFloat (List.length context.children) - 1)
547 [ expectRoundedEquality
548 { expected = totalChildren + horizontalPadding + totalSpacing
549 , found = context.self.bbox.width
551 , Testable.lessThanOrEqual "not larger than parent"
552 context.self.bbox.width
553 context.parent.bbox.width
556 Testable.Column _ _ ->
557 -- The width of the column is the width of the widest child.
561 + context.self.bbox.padding.left
562 + context.self.bbox.padding.right
568 + context.self.bbox.padding.left
569 + context.self.bbox.padding.right
571 context.self.textMetrics
575 |> List.map childWidth
576 |> List.append textChildren
578 [ expectRoundedEquality
579 { expected = Maybe.withDefault 0 (List.maximum allChildren)
580 , found = context.self.bbox.width
582 , Testable.lessThanOrEqual "not larger than parent"
583 context.self.bbox.width
584 context.parent.bbox.width
587 Testable.TextColumn _ _ ->
588 -- The width of the column is the width of the widest child.
592 + context.self.bbox.padding.left
593 + context.self.bbox.padding.right
599 + context.self.bbox.padding.left
600 + context.self.bbox.padding.right
602 context.self.textMetrics
606 |> List.map childWidth
607 |> List.append textChildren
609 [ expectRoundedEquality
610 { expected = Maybe.withDefault 0 (List.maximum allChildren)
611 , found = context.self.bbox.width
613 , Testable.lessThanOrEqual "not larger than parent"
614 context.self.bbox.width
615 context.parent.bbox.width
618 Testable.Paragraph _ _ ->
619 -- This should be the size it's text,
620 -- unless it takes up all available space, in which case it should wrap.
627 |> List.map childWidth
628 |> List.append (List.map .width context.self.textMetrics)
632 context.self.bbox.padding.left + context.self.bbox.padding.right
634 [ expectRoundedEquality
635 { expected = totalChildren + horizontalPadding
636 , found = context.self.bbox.width
638 , Testable.lessThanOrEqual "not larger than parent"
639 context.self.bbox.width
640 context.parent.bbox.width
651heightHelper maybeMin maybeMax len =
659 l |> Element.minimum minPx
667 l |> Element.maximum maxPx
675 " min:" ++ String.fromInt i
683 " max:" ++ String.fromInt i
685 minMaxTest actualheight =
686 case ( maybeMin, maybeMax ) of
687 ( Nothing, Nothing ) ->
690 ( Just lower, Nothing ) ->
691 lower <= actualheight
693 ( Just lower, Just higher ) ->
694 lower <= actualheight && actualheight <= higher
696 ( Nothing, Just higher ) ->
697 actualheight <= higher
701 heightHelper (Just m) maybeMax newLen
704 heightHelper maybeMin (Just m) newLen
707 -- Pixel values should ignore min and max?
709 { label = "height " ++ String.fromInt val ++ "px" ++ minLabel ++ maxLabel
716 , id = Testable.IsHeight
719 [ expectRoundedEquality
720 { expected = toFloat val
721 , found = found.self.bbox.height
723 , Testable.true "min/max holds true"
724 (minMaxTest (floor found.self.bbox.height))
730 { label = "height fill-" ++ String.fromInt portion ++ minLabel ++ maxLabel
733 (Element.fillPortion portion
737 , id = Testable.IsHeight
740 [ if List.member context.parentLayout [ Testable.IsNearby Testable.Above, Testable.IsNearby Testable.Below ] then
741 Testable.true "height fill doesn't apply to above/below elements" True
745 parentAvailableHeight =
746 context.parent.bbox.height - (context.self.bbox.padding.top + context.self.bbox.padding.bottom)
748 case context.parentLayout of
749 Testable.IsNearby _ ->
750 Testable.true "Nearby Element has fill height"
751 ((floor context.parent.bbox.height == floor context.self.bbox.height)
752 || minMaxTest (floor context.self.bbox.height)
756 Testable.true "Element within column has fill height"
757 ((floor parentAvailableHeight == floor context.self.bbox.height)
758 || minMaxTest (floor context.self.bbox.height)
762 Testable.true "Element within el has fill height" <|
763 (floor parentAvailableHeight == floor context.self.bbox.height)
764 || minMaxTest (floor context.self.bbox.height)
769 parentAvailableHeight / toFloat (List.length context.siblings + 1)
771 Testable.true "el has fill height" <|
772 (floor spacePerPortion == floor context.self.bbox.height)
773 || minMaxTest (floor context.self.bbox.height)
779 { label = "height shrink" ++ minLabel ++ maxLabel
786 , id = Testable.IsHeight
789 case context.selfElement of
795 [ if List.isEmpty context.children then
796 -- context.self.textMetrics
797 -- |> List.map Testable.textHeight
799 -- TODO: apparently the font metrics we have are for the literal characters rendered
800 -- not for the font itself.
801 -- so for now, we are stubbing this in as 20, which is the default font size + line height.
802 Testable.rounded "expected multiple of 20"
803 { expected = context.self.bbox.height
804 , found = toFloat (List.length context.self.textMetrics * 20)
808 expectRoundedEquality
811 |> List.map childHeight
813 |> (\h -> h + context.self.bbox.padding.top + context.self.bbox.padding.bottom)
814 , found = context.self.bbox.height
816 , Testable.lessThanOrEqual "not larger than parent"
817 context.self.bbox.height
818 context.parent.bbox.height
826 [ if List.isEmpty context.children then
827 -- context.self.textMetrics
828 -- |> List.map Testable.textHeight
830 -- TODO: apparently the font metrics we have are for the literal characters rendered
831 -- not for the font itself.
832 -- so for now, we are stubbing this in as 20, which is the default font size.
833 Testable.true "expected multiple of 20"
834 ((round context.self.bbox.height |> modBy 20) == 0)
837 expectRoundedEquality
840 |> List.map childHeight
842 |> Maybe.withDefault 0
843 |> (\h -> h + context.self.bbox.padding.top + context.self.bbox.padding.bottom)
844 , found = context.self.bbox.height
846 , Testable.lessThanOrEqual "not larger than parent"
847 context.self.bbox.height
848 context.parent.bbox.height
851 Testable.Column colAttrs _ ->
858 |> List.map childHeight
859 |> List.append (List.map Testable.textHeight context.self.textMetrics)
863 context.self.bbox.padding.top + context.self.bbox.padding.bottom
866 Testable.getSpacingFromAttributes colAttrs
869 toFloat spacingAmount * (toFloat (List.length context.children) - 1)
871 [ expectRoundedEquality
872 { expected = totalChildren + verticalPadding + totalSpacing
873 , found = context.self.bbox.height
875 , Testable.lessThanOrEqual "not larger than parent"
876 context.self.bbox.height
877 context.parent.bbox.height
880 Testable.TextColumn _ _ ->
881 [ Testable.lessThanOrEqual "not larger than parent"
882 context.self.bbox.height
883 context.parent.bbox.height
886 Testable.Paragraph _ _ ->
887 [ Testable.lessThanOrEqual "not larger than parent"
888 context.self.bbox.height
889 context.parent.bbox.height
900width : Length -> Testable.Attr msg
902 widthHelper Nothing Nothing len
905height : Length -> Testable.Attr msg
907 heightHelper Nothing Nothing len
910spacing : Int -> Testable.Attr msg
913 [ Testable.Spacing space
914 , Testable.LabeledTest
915 { label = "spacing: " ++ String.fromInt space
916 , attr = Element.spacing space
921 findDistance child total =
928 - otherChild.bbox.right
933 - otherChild.bbox.bottom
935 [ if horizontal > 0 then
940 , if vertical > 0 then
951 List.foldl findDistance [] found.children
956 if not (x >= space) then
966 ("All children are at least "
967 ++ String.fromInt space
969 ++ Debug.toString allAreSpaced
978{-| alignLeft needs to account for
981 - elements to the left
984in order to calculate the expected result.
986Also need parent rendering context if this is to work with wrapped rows in the future.
991alignLeft : Testable.Attr msg
994 { label = "alignLeft"
995 , attr = Element.alignLeft
999 [ if List.member found.parentLayout [ Testable.IsNearby Testable.OnLeft, Testable.IsNearby Testable.OnRight ] then
1000 Testable.true "alignLeft doesn't apply to elements that are onLeft or onRight" True
1003 List.member found.parentLayout
1004 [ Testable.IsNearby Testable.InFront
1005 , Testable.IsNearby Testable.Behind
1006 , Testable.IsNearby Testable.Above
1007 , Testable.IsNearby Testable.Below
1010 expectRoundedEquality
1011 { found = found.self.bbox.left
1012 , expected = found.parent.bbox.left
1015 else if List.length found.siblings == 0 then
1016 expectRoundedEquality
1017 { found = found.self.bbox.left
1018 , expected = found.parent.bbox.left + found.parent.bbox.padding.left
1022 case found.parentLayout of
1026 List.filter (\x -> x.bbox.right < found.self.bbox.left) found.siblings
1029 toFloat (List.length siblingsOnLeft * found.parentSpacing)
1033 |> List.map (.width << .bbox)
1036 expectRoundedEquality
1037 { found = found.self.bbox.left
1038 , expected = found.parent.bbox.left + (found.parent.bbox.padding.left + widthsOnLeft + spacings)
1042 expectRoundedEquality
1043 { found = found.self.bbox.left
1044 , expected = found.parent.bbox.left + found.parent.bbox.padding.left
1051centerX : Testable.Attr msg
1053 Testable.LabeledTest
1055 , attr = Element.centerX
1056 , id = Testable.NoId
1062 found.self.bbox.left + (found.self.bbox.width / 2)
1064 parentCenter : Float
1066 found.parent.bbox.left + (found.parent.bbox.width / 2)
1068 if List.member found.parentLayout [ Testable.IsNearby Testable.OnRight, Testable.IsNearby Testable.OnLeft ] then
1069 [ Testable.true "centerX doesn't apply to elements that are onLeft or onRight" True ]
1071 else if List.length found.siblings == 0 then
1072 [ expectRoundedEquality
1073 { found = selfCenter
1074 , expected = parentCenter
1079 case found.parentLayout of
1083 List.filter (\x -> x.bbox.right < found.self.bbox.left) found.siblings
1086 List.filter (\x -> x.bbox.left > found.self.bbox.right) found.siblings
1088 widthsOnLeft : Float
1091 |> List.map (.width << .bbox)
1093 |> (\x -> x + (toFloat (List.length siblingsOnLeft) * toFloat found.parentSpacing))
1097 |> List.map (.width << .bbox)
1099 |> (\x -> x + (toFloat (List.length siblingsOnRight) * toFloat found.parentSpacing))
1101 expectedCenter : Float
1103 found.parent.bbox.left
1105 + ((found.parent.bbox.width - (widthsOnRight + widthsOnLeft))
1109 [ expectRoundedEquality
1110 { found = selfCenter
1111 , expected = expectedCenter
1116 [ expectRoundedEquality
1117 { found = selfCenter
1118 , expected = parentCenter
1125alignRight : Testable.Attr msg
1127 Testable.LabeledTest
1128 { label = "alignRight"
1129 , attr = Element.alignRight
1130 , id = Testable.NoId
1133 if List.member found.parentLayout [ Testable.IsNearby Testable.OnLeft, Testable.IsNearby Testable.OnRight ] then
1134 [ Testable.true "alignRight doesn't apply to elements that are onLeft or onRight" True ]
1137 List.member found.parentLayout
1138 [ Testable.IsNearby Testable.InFront
1139 , Testable.IsNearby Testable.Behind
1140 , Testable.IsNearby Testable.Above
1141 , Testable.IsNearby Testable.Below
1144 [ expectRoundedEquality
1145 { found = found.self.bbox.right
1146 , expected = found.parent.bbox.right
1150 else if List.length found.siblings == 0 then
1151 [ expectRoundedEquality
1152 { found = found.self.bbox.right
1153 , expected = found.parent.bbox.right + found.parent.bbox.padding.right
1158 case found.parentLayout of
1162 List.filter (\x -> x.bbox.left > found.self.bbox.right) found.siblings
1165 toFloat (List.length siblingsOnRight * found.parentSpacing)
1169 |> List.map (.width << .bbox)
1172 [ expectRoundedEquality
1173 { found = found.self.bbox.right
1174 , expected = found.parent.bbox.right - (found.parent.bbox.padding.right + widthsOnRight + spacings)
1179 [ expectRoundedEquality
1180 { found = found.self.bbox.right
1181 , expected = found.parent.bbox.right + found.parent.bbox.padding.right
1188alignTop : Testable.Attr msg
1190 Testable.LabeledTest
1191 { label = "alignTop"
1192 , attr = Element.alignTop
1193 , id = Testable.NoId
1196 if List.member found.parentLayout [ Testable.IsNearby Testable.Above, Testable.IsNearby Testable.Below ] then
1197 [ Testable.true "alignTop doesn't apply to elements that are above or below" True ]
1200 List.member found.parentLayout
1201 [ Testable.IsNearby Testable.InFront
1202 , Testable.IsNearby Testable.Behind
1203 , Testable.IsNearby Testable.OnRight
1204 , Testable.IsNearby Testable.OnLeft
1207 [ expectRoundedEquality
1208 { found = found.self.bbox.top
1209 , expected = found.parent.bbox.top
1213 else if List.length found.siblings == 0 then
1214 [ expectRoundedEquality
1215 { found = found.self.bbox.top
1216 , expected = found.parent.bbox.top + found.parent.bbox.padding.top
1221 case found.parentLayout of
1222 Testable.InColumn ->
1225 List.filter (\x -> x.bbox.bottom < found.self.bbox.top) found.siblings
1228 toFloat (List.length siblingsAbove * found.parentSpacing)
1232 |> List.map (.height << .bbox)
1235 [ expectRoundedEquality
1236 { found = found.self.bbox.top
1237 , expected = found.parent.bbox.top + (found.parent.bbox.padding.top + heightsAbove + spacings)
1242 [ expectRoundedEquality
1243 { found = found.self.bbox.top
1244 , expected = found.parent.bbox.top
1251alignBottom : Testable.Attr msg
1253 Testable.LabeledTest
1254 { label = "alignBottom"
1255 , attr = Element.alignBottom
1256 , id = Testable.NoId
1259 if List.member found.parentLayout [ Testable.IsNearby Testable.Above, Testable.IsNearby Testable.Below ] then
1260 [ Testable.true "alignBottom doesn't apply to elements that are above or below" True ]
1263 List.member found.parentLayout
1264 [ Testable.IsNearby Testable.InFront
1265 , Testable.IsNearby Testable.Behind
1266 , Testable.IsNearby Testable.OnRight
1267 , Testable.IsNearby Testable.OnLeft
1270 [ expectRoundedEquality
1271 { found = found.self.bbox.bottom
1272 , expected = found.parent.bbox.bottom
1276 else if List.length found.siblings == 0 then
1277 [ expectRoundedEquality
1278 { found = found.self.bbox.bottom
1279 , expected = found.parent.bbox.bottom + found.parent.bbox.padding.bottom
1284 case found.parentLayout of
1285 Testable.InColumn ->
1288 List.filter (\x -> x.bbox.top > found.self.bbox.bottom) found.siblings
1291 toFloat (List.length siblingsBelow * found.parentSpacing)
1295 |> List.map (.height << .bbox)
1298 [ expectRoundedEquality
1299 { found = found.self.bbox.bottom
1300 , expected = found.parent.bbox.bottom - (found.parent.bbox.padding.bottom + heightsBelow + spacings)
1305 [ expectRoundedEquality
1306 { found = found.self.bbox.bottom
1307 , expected = found.parent.bbox.bottom + found.parent.bbox.padding.bottom
1313expectRoundedEquality : { expected : Float, found : Float } -> Testable.LayoutExpectation
1314expectRoundedEquality { expected, found } =
1316 ("expected " ++ floatToString expected ++ ", found " ++ floatToString found)
1317 (abs (expected - found) < 1)
1320floatToString : Float -> String
1322 String.fromFloat (toFloat (round (x * 100)) / 100)
1326centerY : Testable.Attr msg
1328 Testable.LabeledTest
1330 , attr = Element.centerY
1331 , id = Testable.NoId
1336 found.self.bbox.top + (found.self.bbox.height / 2)
1339 found.parent.bbox.top + (found.parent.bbox.height / 2)
1341 if List.member found.parentLayout [ Testable.IsNearby Testable.Above, Testable.IsNearby Testable.Below ] then
1342 [ Testable.true "centerY doesn't apply to elements that are above or below" True ]
1344 else if List.length found.siblings == 0 then
1345 [ expectRoundedEquality
1346 { found = selfCenter
1347 , expected = parentCenter
1352 case found.parentLayout of
1353 Testable.InColumn ->
1356 List.filter (\x -> x.bbox.bottom < found.self.bbox.top) found.siblings
1359 List.filter (\x -> x.bbox.top > found.self.bbox.bottom) found.siblings
1361 heightsAbove : Float
1364 |> List.map (.height << .bbox)
1366 |> (\x -> x + (toFloat (List.length siblingsOnTop) * toFloat found.parentSpacing))
1370 |> List.map (.height << .bbox)
1372 |> (\x -> x + (toFloat (List.length siblingsBelow) * toFloat found.parentSpacing))
1374 expectedCenter : Float
1376 found.parent.bbox.top
1378 + ((found.parent.bbox.height - (heightsBelow + heightsAbove))
1382 [ expectRoundedEquality
1383 { found = selfCenter
1384 , expected = expectedCenter
1389 [ expectRoundedEquality
1390 { found = selfCenter
1391 , expected = parentCenter
1398above : Testable.Element msg -> Testable.Attr msg
1401 { location = Testable.Above
1406 [ expectRoundedEquality
1407 { found = found.self.bbox.bottom
1408 , expected = found.parent.bbox.top
1415below : Testable.Element msg -> Testable.Attr msg
1418 { location = Testable.Below
1423 [ expectRoundedEquality
1424 { found = found.self.bbox.top
1425 , expected = found.parent.bbox.bottom
1432onRight : Testable.Element msg -> Testable.Attr msg
1435 { location = Testable.OnRight
1440 [ expectRoundedEquality
1441 { found = found.self.bbox.left
1442 , expected = found.parent.bbox.right
1449onLeft : Testable.Element msg -> Testable.Attr msg
1452 { location = Testable.OnLeft
1457 [ expectRoundedEquality
1458 { found = found.self.bbox.right
1459 , expected = found.parent.bbox.left
1466 vs (round x) (round y) || vs (floor x) (floor y)
1470inFront : Testable.Element msg -> Testable.Attr msg
1473 { location = Testable.InFront
1478 [ withinHelper found ]
1485 if found.self.bbox.width > found.parent.bbox.width then
1486 [ compare found.self.bbox.right (<=) found.parent.bbox.right
1487 || compare found.self.bbox.left (>=) found.parent.bbox.left
1491 [ compare found.self.bbox.right (<=) found.parent.bbox.right
1492 , compare found.self.bbox.left (>=) found.parent.bbox.left
1496 if found.self.bbox.width > found.parent.bbox.width then
1497 [ compare found.self.bbox.top (>=) found.parent.bbox.top
1498 || compare found.self.bbox.bottom (<=) found.parent.bbox.bottom
1502 [ compare found.self.bbox.top (>=) found.parent.bbox.top
1503 , compare found.self.bbox.bottom (<=) found.parent.bbox.bottom
1506 Testable.true "within the confines of the parent"
1507 (List.all ((==) True)
1517behindContent : Testable.Element msg -> Testable.Attr msg
1518behindContent element =
1520 { location = Testable.Behind
1522 , label = "behindContent"
1525 [ withinHelper found ]
1530{- Implicit width/height calcualtions -}
1533implicitWidthHeightShrink attrs =
1536 implicitTest (widthHelper Nothing Nothing Shrink)
1537 :: implicitTest (heightHelper Nothing Nothing Shrink)
1540 skipOverridden withImplicits
1545 Testable.LabeledTest details ->
1548 Testable.AttrTest details ->
1557 (\attr ( found, caught ) ->
1567 , hasHeight = found.hasHeight
1571 Testable.IsHeight ->
1573 , { hasWidth = found.hasWidth
1586 ( { hasWidth = False
1596{-| This is taking a normal test and rmoving its ability to attach a real `Element` attribute.
1600 Testable.LabeledTest details ->
1602 { test = details.test
1603 , 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