@@ -307,6 +307,11 @@ paddingXY x y =
311+ List.filter Tuple.first ls
312+ |> List.map Tuple.second
310widthHelper maybeMin maybeMax len =
315widthHelper maybeMin maybeMax len =
312 addMin l =
317 addMin l =
@@ -465,12 +470,31 @@ widthHelper maybeMin maybeMax len =
465 totalChildren + horizontalPadding
470 totalChildren + horizontalPadding
467 expectedLines =
472 expectedLines =
473+ if boxChildrenHeight > 20 then
474+ ceiling (boxChildrenHeight / 20)
468− ceiling (totalCalculatedWidth / context.self.bbox.width)
477+ ceiling (totalCalculatedWidth / context.self.bbox.width)
470− [ Testable.rounded "text wrapping, checking height"
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.
471− { expected = toFloat (expectedLines * 22)
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.
472− , found = context.self.bbox.height
496+ context.self.bbox.height < (20 * 2)
@@ -504,23 +528,21 @@ widthHelper maybeMin maybeMax len =
505 horizontalPadding =
529 horizontalPadding =
506 context.self.bbox.padding.left + context.self.bbox.padding.right
530 context.self.bbox.padding.left + context.self.bbox.padding.right
512− |> List.map childWidth
513− , text = List.map .width context.self.textMetrics
533+ [ ( (context.parentLayout /= Testable.InParagraph)
534+ && (context.parentLayout /= Testable.InTextCol)
516− [ Testable.rounded "equals children"
535+ , Testable.rounded "equals children"
517− { expected = totalChildren + horizontalPadding
536+ { expected = totalChildren + horizontalPadding
518− , found = context.self.bbox.width
537+ , found = context.self.bbox.width
540+ , ( context.parentLayout /= Testable.AtRoot
520− , Testable.lessThanOrEqual "not larger than parent"
541+ , Testable.lessThanOrEqual "not larger than parent"
521− context.self.bbox.width
542+ context.self.bbox.width
522− context.parent.bbox.width
543+ context.parent.bbox.width
525 Testable.Row rowAttrs _ ->
547 Testable.Row rowAttrs _ ->
526 -- width of row is the sum of all children widths
548 -- width of row is the sum of all children widths
@@ -544,14 +566,19 @@ widthHelper maybeMin maybeMax len =
544 totalSpacing =
566 totalSpacing =
545 toFloat spacingAmount * (toFloat (List.length context.children) - 1)
567 toFloat spacingAmount * (toFloat (List.length context.children) - 1)
547− [ expectRoundedEquality
571+ , expectRoundedEquality
548− { expected = totalChildren + horizontalPadding + totalSpacing
572+ { expected = totalChildren + horizontalPadding + totalSpacing
549− , found = context.self.bbox.width
573+ , found = context.self.bbox.width
576+ , ( context.parentLayout /= Testable.AtRoot
551− , Testable.lessThanOrEqual "not larger than parent"
577+ , Testable.lessThanOrEqual "not larger than parent"
552− context.self.bbox.width
578+ context.self.bbox.width
553− context.parent.bbox.width
579+ context.parent.bbox.width
556 Testable.Column _ _ ->
583 Testable.Column _ _ ->
557 -- The width of the column is the width of the widest child.
584 -- The width of the column is the width of the widest child.
@@ -575,14 +602,19 @@ widthHelper maybeMin maybeMax len =
575 |> List.map childWidth
602 |> List.map childWidth
576 |> List.append textChildren
603 |> List.append textChildren
578− [ expectRoundedEquality
607+ , expectRoundedEquality
579− { expected = Maybe.withDefault 0 (List.maximum allChildren)
608+ { expected = Maybe.withDefault 0 (List.maximum allChildren)
580− , found = context.self.bbox.width
609+ , found = context.self.bbox.width
612+ , ( context.parentLayout /= Testable.AtRoot
582− , Testable.lessThanOrEqual "not larger than parent"
613+ , Testable.lessThanOrEqual "not larger than parent"
583− context.self.bbox.width
614+ context.self.bbox.width
584− context.parent.bbox.width
615+ context.parent.bbox.width
587 Testable.TextColumn _ _ ->
619 Testable.TextColumn _ _ ->
588 -- The width of the column is the width of the widest child.
620 -- The width of the column is the width of the widest child.
@@ -606,14 +638,19 @@ widthHelper maybeMin maybeMax len =
606 |> List.map childWidth
638 |> List.map childWidth
607 |> List.append textChildren
639 |> List.append textChildren
609− [ expectRoundedEquality
643+ , expectRoundedEquality
610− { expected = Maybe.withDefault 0 (List.maximum allChildren)
644+ { expected = Maybe.withDefault 0 (List.maximum allChildren)
611− , found = context.self.bbox.width
645+ , found = context.self.bbox.width
648+ , ( context.parentLayout /= Testable.AtRoot
613− , Testable.lessThanOrEqual "not larger than parent"
649+ , Testable.lessThanOrEqual "not larger than parent"
614− context.self.bbox.width
650+ context.self.bbox.width
615− context.parent.bbox.width
651+ context.parent.bbox.width
618 Testable.Paragraph _ _ ->
655 Testable.Paragraph _ _ ->
619 -- This should be the size it's text,
656 -- This should be the size it's text,
@@ -631,14 +668,19 @@ widthHelper maybeMin maybeMax len =
631 horizontalPadding =
668 horizontalPadding =
632 context.self.bbox.padding.left + context.self.bbox.padding.right
669 context.self.bbox.padding.left + context.self.bbox.padding.right
634− [ expectRoundedEquality
673+ , expectRoundedEquality
635− { expected = totalChildren + horizontalPadding
674+ { expected = totalChildren + horizontalPadding
636− , found = context.self.bbox.width
675+ , found = context.self.bbox.width
678+ , ( context.parentLayout /= Testable.AtRoot
638− , Testable.lessThanOrEqual "not larger than parent"
679+ , Testable.lessThanOrEqual "not larger than parent"
639− context.self.bbox.width
680+ context.self.bbox.width
640− context.parent.bbox.width
681+ context.parent.bbox.width
643 Testable.Text _ ->
685 Testable.Text _ ->
@@ -792,20 +834,17 @@ heightHelper maybeMin maybeMax len =
792 childHeight child =
834 childHeight child =
793 child.bbox.height
835 child.bbox.height
795− [ if List.isEmpty context.children then
837+ if List.isEmpty context.children then
796 -- context.self.textMetrics
838 -- context.self.textMetrics
797 -- |> List.map Testable.textHeight
839 -- |> List.map Testable.textHeight
798 -- |> List.sum
840 -- |> List.sum
799 -- TODO: apparently the font metrics we have are for the literal characters rendered
841 -- TODO: apparently the font metrics we have are for the literal characters rendered
800 -- not for the font itself.
842 -- not for the font itself.
801− -- so for now, we are stubbing this in as 20, which is the default font size + line height.
843+ [ Testable.todo "calculate height from actual text metrics"
802− Testable.rounded "expected multiple of 20"
844+ ]
803− { expected = context.self.bbox.height
804− , found = toFloat (List.length context.self.textMetrics * 20)
808− expectRoundedEquality
847+ [ expectRoundedEquality
809 { expected =
848 { expected =
810 context.children
849 context.children
811 |> List.map childHeight
850 |> List.map childHeight
@@ -813,28 +852,26 @@ heightHelper maybeMin maybeMax len =
813 |> (\h -> h + context.self.bbox.padding.top + context.self.bbox.padding.bottom)
852 |> (\h -> h + context.self.bbox.padding.top + context.self.bbox.padding.bottom)
814 , found = context.self.bbox.height
853 , found = context.self.bbox.height
816− , Testable.lessThanOrEqual "not larger than parent"
855+ , Testable.lessThanOrEqual "not larger than parent"
817− context.self.bbox.height
856+ context.self.bbox.height
818− context.parent.bbox.height
857+ context.parent.bbox.height
821 Testable.Row _ _ ->
860 Testable.Row _ _ ->
823 childHeight child =
862 childHeight child =
824 child.bbox.height
863 child.bbox.height
826− [ if List.isEmpty context.children then
865+ if List.isEmpty context.children then
827 -- context.self.textMetrics
866 -- context.self.textMetrics
828 -- |> List.map Testable.textHeight
867 -- |> List.map Testable.textHeight
829 -- |> List.sum
868 -- |> List.sum
830 -- TODO: apparently the font metrics we have are for the literal characters rendered
869 -- TODO: apparently the font metrics we have are for the literal characters rendered
831 -- not for the font itself.
870 -- not for the font itself.
832− -- so for now, we are stubbing this in as 20, which is the default font size.
871+ [ Testable.todo "calculate height from actual text metrics" ]
833− Testable.true "expected multiple of 20"
834− ((round context.self.bbox.height |> modBy 20) == 0)
837− expectRoundedEquality
874+ [ expectRoundedEquality
838 { expected =
875 { expected =
839 context.children
876 context.children
840 |> List.map childHeight
877 |> List.map childHeight
@@ -843,10 +880,10 @@ heightHelper maybeMin maybeMax len =
843 |> (\h -> h + context.self.bbox.padding.top + context.self.bbox.padding.bottom)
880 |> (\h -> h + context.self.bbox.padding.top + context.self.bbox.padding.bottom)
844 , found = context.self.bbox.height
881 , found = context.self.bbox.height
846− , Testable.lessThanOrEqual "not larger than parent"
883+ , Testable.lessThanOrEqual "not larger than parent"
847− context.self.bbox.height
884+ context.self.bbox.height
848− context.parent.bbox.height
885+ context.parent.bbox.height
851 Testable.Column colAttrs _ ->
888 Testable.Column colAttrs _ ->
@@ -878,16 +915,10 @@ heightHelper maybeMin maybeMax len =
880 Testable.TextColumn _ _ ->
917 Testable.TextColumn _ _ ->
881− [ Testable.lessThanOrEqual "not larger than parent"
882− context.self.bbox.height
883− context.parent.bbox.height
886 Testable.Paragraph _ _ ->
920 Testable.Paragraph _ _ ->
887− [ Testable.lessThanOrEqual "not larger than parent"
888− context.self.bbox.height
889− context.parent.bbox.height
892 Testable.Text _ ->
923 Testable.Text _ ->