1module Testable.Element exposing
15 , expectRoundedEquality
48{-| This module should mirror the top level `Element` api, with one important distinction.
50The resulting `Element msg` structure can either be rendered to Html or transformed into a test suite that can be run.
52In order to run the test:
55 - gather information from the browser
67layout : List (Testable.Attr msg) -> Testable.Element Testable.Runner.Msg -> Testable.Runner.TestableProgram
69 Testable.Runner.program
70 [ ( "Tests Run", elem )
74text : String -> Testable.Element msg
79el : List (Testable.Attr msg) -> Testable.Element msg -> Testable.Element msg
81 Testable.El (implicitWidthHeightShrink attrs)
84row : List (Testable.Attr msg) -> List (Testable.Element msg) -> Testable.Element msg
86 Testable.Row (implicitWidthHeightShrink attrs)
89column : List (Testable.Attr msg) -> List (Testable.Element msg) -> Testable.Element msg
91 Testable.Column (implicitWidthHeightShrink attrs)
94none : Testable.Element msg
99paragraph : List (Testable.Attr msg) -> List (Testable.Element msg) -> Testable.Element msg
103 implicitTest (widthHelper Nothing Nothing (Fill 1))
104 :: implicitTest (heightHelper Nothing Nothing Shrink)
107 Testable.Paragraph (skipOverridden withImplicits)
110textColumn : List (Testable.Attr msg) -> List (Testable.Element msg) -> Testable.Element msg
114 implicitTest (widthHelper (Just 500) (Just 750) (Fill 1))
115 :: implicitTest (heightHelper Nothing Nothing Shrink)
118 Testable.TextColumn (skipOverridden withImplicits)
122 List (Testable.Attr msg)
125 , label : Testable.Element msg
127 -> Testable.Element msg
129 -- TODO: this is not actually a link element!!
130 Testable.El (implicitWidthHeightShrink attrs) details.label
133{-| Old labeling mechanism that i removed to hastily
140 Testable.Attr (Element.moveUp x)
144 Testable.Attr (Element.moveDown x)
148 Testable.Attr (Element.moveRight x)
152 Testable.Attr (Element.moveLeft x)
194fillPortion : Int -> Length
199transparent : Bool -> Testable.Attr msg
208 , attr = Element.transparent on
215 |> Dict.get "opacity"
216 |> Maybe.withDefault "notfound"
225 [ Testable.equal value selfTransparency ]
230isVisible : Testable.Attr msg
233 { label = "is-visible"
237 [ Testable.equal context.self.isVisible True ]
242alpha : Float -> Testable.Attr msg
245 { label = "alpha-" ++ String.fromFloat a
246 , attr = Element.alpha a
253 |> Dict.get "opacity"
254 |> Maybe.withDefault "notfound"
256 [ Testable.equal (String.fromFloat a) selfTransparency ]
261padding : Int -> Testable.Attr msg
264 { label = "padding " ++ String.fromInt pad
265 , attr = Element.padding pad
269 [ Testable.true ("Padding " ++ String.fromInt pad ++ " is present")
271 [ floor found.self.bbox.padding.left
272 , floor found.self.bbox.padding.right
273 , floor found.self.bbox.padding.top
274 , floor found.self.bbox.padding.bottom
282paddingXY : Int -> Int -> Testable.Attr msg
285 { label = "paddingXY " ++ String.fromInt x ++ ", " ++ String.fromInt y
286 , attr = Element.paddingXY x y
290 [ Testable.true ("PaddingXY (" ++ String.fromInt x ++ ", " ++ String.fromInt y ++ ") is present")
292 [ floor found.self.bbox.padding.left
293 , floor found.self.bbox.padding.right
296 [ floor found.self.bbox.padding.top
297 , floor found.self.bbox.padding.bottom
304widthHelper maybeMin maybeMax len =
312 l |> Element.minimum minPx
320 l |> Element.maximum maxPx
328 " min:" ++ String.fromInt i
336 " max:" ++ String.fromInt i
338 minMaxTest actualWidth =
339 case ( maybeMin, maybeMax ) of
340 ( Nothing, Nothing ) ->
343 ( Just lower, Nothing ) ->
346 ( Just lower, Just higher ) ->
347 lower <= actualWidth && actualWidth <= higher
349 ( Nothing, Just higher ) ->
350 actualWidth <= higher
354 widthHelper (Just m) maybeMax newLen
357 widthHelper maybeMin (Just m) newLen
360 -- Pixel values should ignore min and max?
362 { label = "width " ++ String.fromInt val ++ "px" ++ minLabel ++ maxLabel
363 , id = Testable.IsWidth
372 [ expectRoundedEquality
373 { expected = toFloat val
374 , found = found.self.bbox.width
376 , Testable.true "min/max is upheld" (minMaxTest (floor found.self.bbox.width))
384 "width fill" ++ minLabel ++ maxLabel
387 "width fill-" ++ String.fromInt portion ++ minLabel ++ maxLabel
388 , id = Testable.IsWidth
391 (Element.fillPortion portion
397 if List.member context.parentLayout [ Testable.IsNearby Testable.OnRight, Testable.IsNearby Testable.OnLeft ] then
398 [ Testable.true "width fill doesn't apply to onright/onleft elements" True ]
402 parentAvailableWidth =
403 context.parent.bbox.width - (context.self.bbox.padding.left + context.self.bbox.padding.right)
406 [ case context.parentLayout of
407 Testable.IsNearby _ ->
408 [ Testable.true "Nearby Element has fill width"
409 ((floor context.parent.bbox.width == floor context.self.bbox.width)
410 || minMaxTest (floor context.self.bbox.width)
415 [ Testable.true "Element within column has fill width"
416 ((floor parentAvailableWidth == floor context.self.bbox.width)
417 || minMaxTest (floor context.self.bbox.width)
422 [ Testable.true "Element within element has fill width" <|
423 (floor parentAvailableWidth == floor context.self.bbox.width)
424 || minMaxTest (floor context.self.bbox.width)
430 parentAvailableWidth / toFloat (List.length context.siblings + 1)
432 [ Testable.true "element has fill width" <|
433 (floor spacePerPortion == floor context.self.bbox.width)
434 || minMaxTest (floor context.self.bbox.width)
436 , [ Testable.lessThanOrEqual "not larger than parent"
437 context.self.bbox.width
438 context.parent.bbox.width
440 , case context.selfElement of
441 Testable.Paragraph _ _ ->
442 -- A paragraph with width fill
443 -- we want to test for correct text wrapping here.
451 |> List.map childWidth
452 |> List.append (List.map .width context.self.textMetrics)
456 context.self.bbox.padding.left + context.self.bbox.padding.right
458 totalCalculatedWidth =
459 totalChildren + horizontalPadding
462 ceiling (totalCalculatedWidth / context.self.bbox.width)
464 [ Testable.rounded "text wrapping, checking height"
465 { expected = toFloat (expectedLines * 22)
466 , found = context.self.bbox.height
477 { label = "width shrink" ++ minLabel ++ maxLabel
484 , id = Testable.IsWidth
487 case context.selfElement of
495 |> List.map childWidth
496 |> List.append (List.map .width context.self.textMetrics)
500 context.self.bbox.padding.left + context.self.bbox.padding.right
506 |> List.map childWidth
507 , text = List.map .width context.self.textMetrics
510 [ Testable.rounded "equals children"
511 { expected = totalChildren + horizontalPadding
512 , found = context.self.bbox.width
514 , Testable.lessThanOrEqual "not larger than parent"
515 context.self.bbox.width
516 context.parent.bbox.width
519 Testable.Row rowAttrs _ ->
520 -- width of row is the sum of all children widths
521 -- both text elements and others.
528 |> List.map childWidth
529 |> List.append (List.map .width context.self.textMetrics)
533 context.self.bbox.padding.left + context.self.bbox.padding.right
536 Testable.getSpacingFromAttributes rowAttrs
539 toFloat spacingAmount * (toFloat (List.length context.children) - 1)
541 [ expectRoundedEquality
542 { expected = totalChildren + horizontalPadding + totalSpacing
543 , found = context.self.bbox.width
545 , Testable.lessThanOrEqual "not larger than parent"
546 context.self.bbox.width
547 context.parent.bbox.width
550 Testable.Column _ _ ->
551 -- The width of the column is the width of the widest child.
555 + context.self.bbox.padding.left
556 + context.self.bbox.padding.right
562 + context.self.bbox.padding.left
563 + context.self.bbox.padding.right
565 context.self.textMetrics
569 |> List.map childWidth
570 |> List.append textChildren
572 [ expectRoundedEquality
573 { expected = Maybe.withDefault 0 (List.maximum allChildren)
574 , found = context.self.bbox.width
576 , Testable.lessThanOrEqual "not larger than parent"
577 context.self.bbox.width
578 context.parent.bbox.width
581 Testable.TextColumn _ _ ->
582 -- The width of the column is the width of the widest child.
586 + context.self.bbox.padding.left
587 + context.self.bbox.padding.right
593 + context.self.bbox.padding.left
594 + context.self.bbox.padding.right
596 context.self.textMetrics
600 |> List.map childWidth
601 |> List.append textChildren
603 [ expectRoundedEquality
604 { expected = Maybe.withDefault 0 (List.maximum allChildren)
605 , found = context.self.bbox.width
607 , Testable.lessThanOrEqual "not larger than parent"
608 context.self.bbox.width
609 context.parent.bbox.width
612 Testable.Paragraph _ _ ->
613 -- This should be the size it's text,
614 -- unless it takes up all available space, in which case it should wrap.
621 |> List.map childWidth
622 |> List.append (List.map .width context.self.textMetrics)
626 context.self.bbox.padding.left + context.self.bbox.padding.right
628 [ expectRoundedEquality
629 { expected = totalChildren + horizontalPadding
630 , found = context.self.bbox.width
632 , Testable.lessThanOrEqual "not larger than parent"
633 context.self.bbox.width
634 context.parent.bbox.width
645heightHelper maybeMin maybeMax len =
653 l |> Element.minimum minPx
661 l |> Element.maximum maxPx
669 " min:" ++ String.fromInt i
677 " max:" ++ String.fromInt i
679 minMaxTest actualheight =
680 case ( maybeMin, maybeMax ) of
681 ( Nothing, Nothing ) ->
684 ( Just lower, Nothing ) ->
685 lower <= actualheight
687 ( Just lower, Just higher ) ->
688 lower <= actualheight && actualheight <= higher
690 ( Nothing, Just higher ) ->
691 actualheight <= higher
695 heightHelper (Just m) maybeMax newLen
698 heightHelper maybeMin (Just m) newLen
701 -- Pixel values should ignore min and max?
703 { label = "height " ++ String.fromInt val ++ "px" ++ minLabel ++ maxLabel
710 , id = Testable.IsHeight
713 [ expectRoundedEquality
714 { expected = toFloat val
715 , found = found.self.bbox.height
717 , Testable.true "min/max holds true"
718 (minMaxTest (floor found.self.bbox.height))
724 { label = "height fill-" ++ String.fromInt portion ++ minLabel ++ maxLabel
727 (Element.fillPortion portion
731 , id = Testable.IsHeight
734 [ if List.member context.parentLayout [ Testable.IsNearby Testable.Above, Testable.IsNearby Testable.Below ] then
735 Testable.true "height fill doesn't apply to above/below elements" True
739 parentAvailableHeight =
740 context.parent.bbox.height - (context.self.bbox.padding.top + context.self.bbox.padding.bottom)
742 case context.parentLayout of
743 Testable.IsNearby _ ->
744 Testable.true "Nearby Element has fill height"
745 ((floor context.parent.bbox.height == floor context.self.bbox.height)
746 || minMaxTest (floor context.self.bbox.height)
750 Testable.true "Element within column has fill height"
751 ((floor parentAvailableHeight == floor context.self.bbox.height)
752 || minMaxTest (floor context.self.bbox.height)
756 Testable.true "Element within el has fill height" <|
757 (floor parentAvailableHeight == floor context.self.bbox.height)
758 || minMaxTest (floor context.self.bbox.height)
763 parentAvailableHeight / toFloat (List.length context.siblings + 1)
765 Testable.true "el has fill height" <|
766 (floor spacePerPortion == floor context.self.bbox.height)
767 || minMaxTest (floor context.self.bbox.height)
773 { label = "height shrink" ++ minLabel ++ maxLabel
780 , id = Testable.IsHeight
783 case context.selfElement of
789 [ if List.isEmpty context.children then
790 -- context.self.textMetrics
791 -- |> List.map Testable.textHeight
793 -- TODO: apparently the font metrics we have are for the literal characters rendered
794 -- not for the font itself.
795 -- so for now, we are stubbing this in as 20, which is the default font size + line height.
796 Testable.rounded "expected multiple of 20"
797 { expected = context.self.bbox.height
798 , found = toFloat (List.length context.self.textMetrics * 20)
802 expectRoundedEquality
805 |> List.map childHeight
807 |> (\h -> h + context.self.bbox.padding.top + context.self.bbox.padding.bottom)
808 , found = context.self.bbox.height
810 , Testable.lessThanOrEqual "not larger than parent"
811 context.self.bbox.height
812 context.parent.bbox.height
820 [ if List.isEmpty context.children then
821 -- context.self.textMetrics
822 -- |> List.map Testable.textHeight
824 -- TODO: apparently the font metrics we have are for the literal characters rendered
825 -- not for the font itself.
826 -- so for now, we are stubbing this in as 20, which is the default font size.
827 Testable.true "expected multiple of 20"
828 ((round context.self.bbox.height |> modBy 20) == 0)
831 expectRoundedEquality
834 |> List.map childHeight
836 |> Maybe.withDefault 0
837 |> (\h -> h + context.self.bbox.padding.top + context.self.bbox.padding.bottom)
838 , found = context.self.bbox.height
840 , Testable.lessThanOrEqual "not larger than parent"
841 context.self.bbox.height
842 context.parent.bbox.height
845 Testable.Column colAttrs _ ->
852 |> List.map childHeight
853 |> List.append (List.map Testable.textHeight context.self.textMetrics)
857 context.self.bbox.padding.top + context.self.bbox.padding.bottom
860 Testable.getSpacingFromAttributes colAttrs
863 toFloat spacingAmount * (toFloat (List.length context.children) - 1)
865 [ expectRoundedEquality
866 { expected = totalChildren + verticalPadding + totalSpacing
867 , found = context.self.bbox.height
869 , Testable.lessThanOrEqual "not larger than parent"
870 context.self.bbox.height
871 context.parent.bbox.height
874 Testable.TextColumn _ _ ->
875 [ Testable.lessThanOrEqual "not larger than parent"
876 context.self.bbox.height
877 context.parent.bbox.height
880 Testable.Paragraph _ _ ->
881 [ Testable.lessThanOrEqual "not larger than parent"
882 context.self.bbox.height
883 context.parent.bbox.height
894width : Length -> Testable.Attr msg
896 widthHelper Nothing Nothing len
899height : Length -> Testable.Attr msg
901 heightHelper Nothing Nothing len
904spacing : Int -> Testable.Attr msg
907 [ Testable.Spacing space
908 , Testable.LabeledTest
909 { label = "spacing: " ++ String.fromInt space
910 , attr = Element.spacing space
915 findDistance child total =
922 - otherChild.bbox.right
927 - otherChild.bbox.bottom
929 [ if horizontal > 0 then
934 , if vertical > 0 then
945 List.foldl findDistance [] found.children
950 if not (x >= space) then
960 ("All children are at least "
961 ++ String.fromInt space
963 ++ Debug.toString allAreSpaced
972{-| alignLeft needs to account for
975 - elements to the left
978in order to calculate the expected result.
980Also need parent rendering context if this is to work with wrapped rows in the future.
985alignLeft : Testable.Attr msg
988 { label = "alignLeft"
989 , attr = Element.alignLeft
993 [ if List.member found.parentLayout [ Testable.IsNearby Testable.OnLeft, Testable.IsNearby Testable.OnRight ] then
994 Testable.true "alignLeft doesn't apply to elements that are onLeft or onRight" True
997 List.member found.parentLayout
998 [ Testable.IsNearby Testable.InFront
999 , Testable.IsNearby Testable.Behind
1000 , Testable.IsNearby Testable.Above
1001 , Testable.IsNearby Testable.Below
1004 expectRoundedEquality
1005 { found = found.self.bbox.left
1006 , expected = found.parent.bbox.left
1009 else if List.length found.siblings == 0 then
1010 expectRoundedEquality
1011 { found = found.self.bbox.left
1012 , expected = found.parent.bbox.left + found.parent.bbox.padding.left
1016 case found.parentLayout of
1020 List.filter (\x -> x.bbox.right < found.self.bbox.left) found.siblings
1023 toFloat (List.length siblingsOnLeft * found.parentSpacing)
1027 |> List.map (.width << .bbox)
1030 expectRoundedEquality
1031 { found = found.self.bbox.left
1032 , expected = found.parent.bbox.left + (found.parent.bbox.padding.left + widthsOnLeft + spacings)
1036 expectRoundedEquality
1037 { found = found.self.bbox.left
1038 , expected = found.parent.bbox.left + found.parent.bbox.padding.left
1045centerX : Testable.Attr msg
1047 Testable.LabeledTest
1049 , attr = Element.centerX
1050 , id = Testable.NoId
1056 found.self.bbox.left + (found.self.bbox.width / 2)
1058 parentCenter : Float
1060 found.parent.bbox.left + (found.parent.bbox.width / 2)
1062 if List.member found.parentLayout [ Testable.IsNearby Testable.OnRight, Testable.IsNearby Testable.OnLeft ] then
1063 [ Testable.true "centerX doesn't apply to elements that are onLeft or onRight" True ]
1065 else if List.length found.siblings == 0 then
1066 [ expectRoundedEquality
1067 { found = selfCenter
1068 , expected = parentCenter
1073 case found.parentLayout of
1077 List.filter (\x -> x.bbox.right < found.self.bbox.left) found.siblings
1080 List.filter (\x -> x.bbox.left > found.self.bbox.right) found.siblings
1082 widthsOnLeft : Float
1085 |> List.map (.width << .bbox)
1087 |> (\x -> x + (toFloat (List.length siblingsOnLeft) * toFloat found.parentSpacing))
1091 |> List.map (.width << .bbox)
1093 |> (\x -> x + (toFloat (List.length siblingsOnRight) * toFloat found.parentSpacing))
1095 expectedCenter : Float
1097 found.parent.bbox.left
1099 + ((found.parent.bbox.width - (widthsOnRight + widthsOnLeft))
1103 [ expectRoundedEquality
1104 { found = selfCenter
1105 , expected = expectedCenter
1110 [ expectRoundedEquality
1111 { found = selfCenter
1112 , expected = parentCenter
1119alignRight : Testable.Attr msg
1121 Testable.LabeledTest
1122 { label = "alignRight"
1123 , attr = Element.alignRight
1124 , id = Testable.NoId
1127 if List.member found.parentLayout [ Testable.IsNearby Testable.OnLeft, Testable.IsNearby Testable.OnRight ] then
1128 [ Testable.true "alignRight doesn't apply to elements that are onLeft or onRight" True ]
1131 List.member found.parentLayout
1132 [ Testable.IsNearby Testable.InFront
1133 , Testable.IsNearby Testable.Behind
1134 , Testable.IsNearby Testable.Above
1135 , Testable.IsNearby Testable.Below
1138 [ expectRoundedEquality
1139 { found = found.self.bbox.right
1140 , expected = found.parent.bbox.right
1144 else if List.length found.siblings == 0 then
1145 [ expectRoundedEquality
1146 { found = found.self.bbox.right
1147 , expected = found.parent.bbox.right + found.parent.bbox.padding.right
1152 case found.parentLayout of
1156 List.filter (\x -> x.bbox.left > found.self.bbox.right) found.siblings
1159 toFloat (List.length siblingsOnRight * found.parentSpacing)
1163 |> List.map (.width << .bbox)
1166 [ expectRoundedEquality
1167 { found = found.self.bbox.right
1168 , expected = found.parent.bbox.right - (found.parent.bbox.padding.right + widthsOnRight + spacings)
1173 [ expectRoundedEquality
1174 { found = found.self.bbox.right
1175 , expected = found.parent.bbox.right + found.parent.bbox.padding.right
1182alignTop : Testable.Attr msg
1184 Testable.LabeledTest
1185 { label = "alignTop"
1186 , attr = Element.alignTop
1187 , id = Testable.NoId
1190 if List.member found.parentLayout [ Testable.IsNearby Testable.Above, Testable.IsNearby Testable.Below ] then
1191 [ Testable.true "alignTop doesn't apply to elements that are above or below" True ]
1194 List.member found.parentLayout
1195 [ Testable.IsNearby Testable.InFront
1196 , Testable.IsNearby Testable.Behind
1197 , Testable.IsNearby Testable.OnRight
1198 , Testable.IsNearby Testable.OnLeft
1201 [ expectRoundedEquality
1202 { found = found.self.bbox.top
1203 , expected = found.parent.bbox.top
1207 else if List.length found.siblings == 0 then
1208 [ expectRoundedEquality
1209 { found = found.self.bbox.top
1210 , expected = found.parent.bbox.top + found.parent.bbox.padding.top
1215 case found.parentLayout of
1216 Testable.InColumn ->
1219 List.filter (\x -> x.bbox.bottom < found.self.bbox.top) found.siblings
1222 toFloat (List.length siblingsAbove * found.parentSpacing)
1226 |> List.map (.height << .bbox)
1229 [ expectRoundedEquality
1230 { found = found.self.bbox.top
1231 , expected = found.parent.bbox.top + (found.parent.bbox.padding.top + heightsAbove + spacings)
1236 [ expectRoundedEquality
1237 { found = found.self.bbox.top
1238 , expected = found.parent.bbox.top
1245alignBottom : Testable.Attr msg
1247 Testable.LabeledTest
1248 { label = "alignBottom"
1249 , attr = Element.alignBottom
1250 , id = Testable.NoId
1253 if List.member found.parentLayout [ Testable.IsNearby Testable.Above, Testable.IsNearby Testable.Below ] then
1254 [ Testable.true "alignBottom doesn't apply to elements that are above or below" True ]
1257 List.member found.parentLayout
1258 [ Testable.IsNearby Testable.InFront
1259 , Testable.IsNearby Testable.Behind
1260 , Testable.IsNearby Testable.OnRight
1261 , Testable.IsNearby Testable.OnLeft
1264 [ expectRoundedEquality
1265 { found = found.self.bbox.bottom
1266 , expected = found.parent.bbox.bottom
1270 else if List.length found.siblings == 0 then
1271 [ expectRoundedEquality
1272 { found = found.self.bbox.bottom
1273 , expected = found.parent.bbox.bottom + found.parent.bbox.padding.bottom
1278 case found.parentLayout of
1279 Testable.InColumn ->
1282 List.filter (\x -> x.bbox.top > found.self.bbox.bottom) found.siblings
1285 toFloat (List.length siblingsBelow * found.parentSpacing)
1289 |> List.map (.height << .bbox)
1292 [ expectRoundedEquality
1293 { found = found.self.bbox.bottom
1294 , expected = found.parent.bbox.bottom - (found.parent.bbox.padding.bottom + heightsBelow + spacings)
1299 [ expectRoundedEquality
1300 { found = found.self.bbox.bottom
1301 , expected = found.parent.bbox.bottom + found.parent.bbox.padding.bottom
1307expectRoundedEquality : { expected : Float, found : Float } -> Testable.LayoutExpectation
1308expectRoundedEquality { expected, found } =
1310 ("expected " ++ floatToString expected ++ ", found " ++ floatToString found)
1311 (abs (expected - found) < 1)
1314floatToString : Float -> String
1316 String.fromFloat (toFloat (round (x * 100)) / 100)
1320centerY : Testable.Attr msg
1322 Testable.LabeledTest
1324 , attr = Element.centerY
1325 , id = Testable.NoId
1330 found.self.bbox.top + (found.self.bbox.height / 2)
1333 found.parent.bbox.top + (found.parent.bbox.height / 2)
1335 if List.member found.parentLayout [ Testable.IsNearby Testable.Above, Testable.IsNearby Testable.Below ] then
1336 [ Testable.true "centerY doesn't apply to elements that are above or below" True ]
1338 else if List.length found.siblings == 0 then
1339 [ expectRoundedEquality
1340 { found = selfCenter
1341 , expected = parentCenter
1346 case found.parentLayout of
1347 Testable.InColumn ->
1350 List.filter (\x -> x.bbox.bottom < found.self.bbox.top) found.siblings
1353 List.filter (\x -> x.bbox.top > found.self.bbox.bottom) found.siblings
1355 heightsAbove : Float
1358 |> List.map (.height << .bbox)
1360 |> (\x -> x + (toFloat (List.length siblingsOnTop) * toFloat found.parentSpacing))
1364 |> List.map (.height << .bbox)
1366 |> (\x -> x + (toFloat (List.length siblingsBelow) * toFloat found.parentSpacing))
1368 expectedCenter : Float
1370 found.parent.bbox.top
1372 + ((found.parent.bbox.height - (heightsBelow + heightsAbove))
1376 [ expectRoundedEquality
1377 { found = selfCenter
1378 , expected = expectedCenter
1383 [ expectRoundedEquality
1384 { found = selfCenter
1385 , expected = parentCenter
1392above : Testable.Element msg -> Testable.Attr msg
1395 { location = Testable.Above
1400 [ expectRoundedEquality
1401 { found = found.self.bbox.bottom
1402 , expected = found.parent.bbox.top
1409below : Testable.Element msg -> Testable.Attr msg
1412 { location = Testable.Below
1417 [ expectRoundedEquality
1418 { found = found.self.bbox.top
1419 , expected = found.parent.bbox.bottom
1426onRight : Testable.Element msg -> Testable.Attr msg
1429 { location = Testable.OnRight
1434 [ expectRoundedEquality
1435 { found = found.self.bbox.left
1436 , expected = found.parent.bbox.right
1443onLeft : Testable.Element msg -> Testable.Attr msg
1446 { location = Testable.OnLeft
1451 [ expectRoundedEquality
1452 { found = found.self.bbox.right
1453 , expected = found.parent.bbox.left
1460 vs (round x) (round y) || vs (floor x) (floor y)
1464inFront : Testable.Element msg -> Testable.Attr msg
1467 { location = Testable.InFront
1472 [ withinHelper found ]
1479 if found.self.bbox.width > found.parent.bbox.width then
1480 [ compare found.self.bbox.right (<=) found.parent.bbox.right
1481 || compare found.self.bbox.left (>=) found.parent.bbox.left
1485 [ compare found.self.bbox.right (<=) found.parent.bbox.right
1486 , compare found.self.bbox.left (>=) found.parent.bbox.left
1490 if found.self.bbox.width > found.parent.bbox.width then
1491 [ compare found.self.bbox.top (>=) found.parent.bbox.top
1492 || compare found.self.bbox.bottom (<=) found.parent.bbox.bottom
1496 [ compare found.self.bbox.top (>=) found.parent.bbox.top
1497 , compare found.self.bbox.bottom (<=) found.parent.bbox.bottom
1500 Testable.true "within the confines of the parent"
1501 (List.all ((==) True)
1511behindContent : Testable.Element msg -> Testable.Attr msg
1512behindContent element =
1514 { location = Testable.Behind
1516 , label = "behindContent"
1519 [ withinHelper found ]
1524{- Implicit width/height calcualtions -}
1527implicitWidthHeightShrink attrs =
1530 implicitTest (widthHelper Nothing Nothing Shrink)
1531 :: implicitTest (heightHelper Nothing Nothing Shrink)
1534 skipOverridden withImplicits
1539 Testable.LabeledTest details ->
1542 Testable.AttrTest details ->
1551 (\attr ( found, caught ) ->
1561 , hasHeight = found.hasHeight
1565 Testable.IsHeight ->
1567 , { hasWidth = found.hasWidth
1580 ( { hasWidth = False
1590{-| This is taking a normal test and rmoving its ability to attach a real `Element` attribute.
1594 Testable.LabeledTest details ->
1596 { test = details.test
1597 , 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