| skipped 69 lines |
70 | 70 | | wantErr: true, |
71 | 71 | | }, |
72 | 72 | | { |
73 | | - | desc: "fails on negative height", |
| 73 | + | desc: "fails on negative threshold", |
74 | 74 | | opts: []Option{ |
75 | | - | Height(-1), |
| 75 | + | Threshold(-1, linestyle.Light), |
76 | 76 | | }, |
77 | 77 | | canvas: image.Rect(0, 0, 10, 3), |
78 | 78 | | want: func(size image.Point) *faketerm.Terminal { |
| skipped 758 lines |
837 | 837 | | testdraw.MustText(c, "(lo…", image.Point{5, 1}, |
838 | 838 | | draw.TextCellOpts(cell.FgColor(cell.ColorDefault)), |
839 | 839 | | ) |
| 840 | + | testcanvas.MustApply(c, ft) |
| 841 | + | return ft |
| 842 | + | }, |
| 843 | + | }, |
| 844 | + | { |
| 845 | + | desc: "threshold with border percentage", |
| 846 | + | opts: []Option{ |
| 847 | + | Char('o'), |
| 848 | + | Threshold(20, linestyle.Double), |
| 849 | + | }, |
| 850 | + | percent: &percentCall{p: 35}, |
| 851 | + | canvas: image.Rect(0, 0, 10, 3), |
| 852 | + | want: func(size image.Point) *faketerm.Terminal { |
| 853 | + | ft := faketerm.MustNew(size) |
| 854 | + | c := testcanvas.MustNew(ft.Area()) |
| 855 | + | |
| 856 | + | testdraw.MustRectangle(c, image.Rect(0, 0, 3, 3), |
| 857 | + | draw.RectChar('o'), |
| 858 | + | draw.RectCellOpts(cell.BgColor(cell.ColorGreen)), |
| 859 | + | ) |
| 860 | + | testdraw.MustText(c, "35%", image.Point{3, 1}) |
| 861 | + | testdraw.MustHVLines(c, []draw.HVLine{{ |
| 862 | + | Start: image.Point{X: 2, Y: 0}, |
| 863 | + | End: image.Point{X: 2, Y: 2}, |
| 864 | + | }}, draw.HVLineStyle(linestyle.Double)) |
| 865 | + | testcanvas.MustApply(c, ft) |
| 866 | + | return ft |
| 867 | + | }, |
| 868 | + | }, |
| 869 | + | { |
| 870 | + | desc: "threshold without border absolute", |
| 871 | + | opts: []Option{ |
| 872 | + | Char('o'), |
| 873 | + | Threshold(3, linestyle.Light, cell.BgColor(cell.ColorRed)), |
| 874 | + | Border(linestyle.None), |
| 875 | + | HideTextProgress(), |
| 876 | + | }, |
| 877 | + | absolute: &absoluteCall{done: 4, total: 10}, |
| 878 | + | canvas: image.Rect(0, 0, 10, 3), |
| 879 | + | want: func(size image.Point) *faketerm.Terminal { |
| 880 | + | ft := faketerm.MustNew(size) |
| 881 | + | c := testcanvas.MustNew(ft.Area()) |
| 882 | + | |
| 883 | + | testdraw.MustRectangle(c, image.Rect(0, 0, 3, 3), |
| 884 | + | draw.RectChar('o'), |
| 885 | + | draw.RectCellOpts(cell.BgColor(cell.ColorGreen)), |
| 886 | + | ) |
| 887 | + | testdraw.MustHVLines(c, []draw.HVLine{{ |
| 888 | + | Start: image.Point{X: 3, Y: 0}, |
| 889 | + | End: image.Point{X: 3, Y: 2}, |
| 890 | + | }}, draw.HVLineStyle(linestyle.Light), |
| 891 | + | draw.HVLineCellOpts(cell.BgColor(cell.ColorRed))) |
| 892 | + | testcanvas.MustApply(c, ft) |
| 893 | + | return ft |
| 894 | + | }, |
| 895 | + | }, |
| 896 | + | { |
| 897 | + | desc: "threshold outside of bounds (>=max)", |
| 898 | + | opts: []Option{ |
| 899 | + | Char('o'), |
| 900 | + | HideTextProgress(), |
| 901 | + | Threshold(100, linestyle.Light), // ignored |
| 902 | + | }, |
| 903 | + | percent: &percentCall{p: 35}, |
| 904 | + | canvas: image.Rect(0, 0, 10, 3), |
| 905 | + | want: func(size image.Point) *faketerm.Terminal { |
| 906 | + | ft := faketerm.MustNew(size) |
| 907 | + | c := testcanvas.MustNew(ft.Area()) |
| 908 | + | |
| 909 | + | testdraw.MustRectangle(c, image.Rect(0, 0, 3, 3), |
| 910 | + | draw.RectChar('o'), |
| 911 | + | draw.RectCellOpts(cell.BgColor(cell.ColorGreen)), |
| 912 | + | ) |
| 913 | + | testcanvas.MustApply(c, ft) |
| 914 | + | return ft |
| 915 | + | }, |
| 916 | + | }, |
| 917 | + | { |
| 918 | + | desc: "progress below threshold", |
| 919 | + | opts: []Option{ |
| 920 | + | Char('o'), |
| 921 | + | Threshold(5, linestyle.Light, cell.BgColor(cell.ColorRed)), |
| 922 | + | HideTextProgress(), |
| 923 | + | }, |
| 924 | + | absolute: &absoluteCall{done: 4, total: 10}, |
| 925 | + | canvas: image.Rect(0, 0, 10, 3), |
| 926 | + | want: func(size image.Point) *faketerm.Terminal { |
| 927 | + | ft := faketerm.MustNew(size) |
| 928 | + | c := testcanvas.MustNew(ft.Area()) |
| 929 | + | |
| 930 | + | testdraw.MustRectangle(c, image.Rect(0, 0, 4, 3), |
| 931 | + | draw.RectChar('o'), |
| 932 | + | draw.RectCellOpts(cell.BgColor(cell.ColorGreen)), |
| 933 | + | ) |
| 934 | + | testdraw.MustHVLines(c, []draw.HVLine{{ |
| 935 | + | Start: image.Point{X: 5, Y: 0}, |
| 936 | + | End: image.Point{X: 5, Y: 2}, |
| 937 | + | }}, draw.HVLineStyle(linestyle.Light), |
| 938 | + | draw.HVLineCellOpts(cell.BgColor(cell.ColorRed))) |
| 939 | + | testcanvas.MustApply(c, ft) |
| 940 | + | return ft |
| 941 | + | }, |
| 942 | + | }, |
| 943 | + | { |
| 944 | + | desc: "progress exactly at threshold", |
| 945 | + | opts: []Option{ |
| 946 | + | Char('o'), |
| 947 | + | Threshold(5, linestyle.Light, cell.BgColor(cell.ColorRed)), |
| 948 | + | HideTextProgress(), |
| 949 | + | }, |
| 950 | + | absolute: &absoluteCall{done: 5, total: 10}, |
| 951 | + | canvas: image.Rect(0, 0, 10, 3), |
| 952 | + | want: func(size image.Point) *faketerm.Terminal { |
| 953 | + | ft := faketerm.MustNew(size) |
| 954 | + | c := testcanvas.MustNew(ft.Area()) |
| 955 | + | |
| 956 | + | testdraw.MustRectangle(c, image.Rect(0, 0, 5, 3), |
| 957 | + | draw.RectChar('o'), |
| 958 | + | draw.RectCellOpts(cell.BgColor(cell.ColorGreen)), |
| 959 | + | ) |
| 960 | + | testdraw.MustHVLines(c, []draw.HVLine{{ |
| 961 | + | Start: image.Point{X: 5, Y: 0}, |
| 962 | + | End: image.Point{X: 5, Y: 2}, |
| 963 | + | }}, draw.HVLineStyle(linestyle.Light), |
| 964 | + | draw.HVLineCellOpts(cell.BgColor(cell.ColorRed))) |
| 965 | + | testcanvas.MustApply(c, ft) |
| 966 | + | return ft |
| 967 | + | }, |
| 968 | + | }, |
| 969 | + | { |
| 970 | + | desc: "progress after threshold", |
| 971 | + | opts: []Option{ |
| 972 | + | Char('o'), |
| 973 | + | Threshold(5, linestyle.Light, cell.BgColor(cell.ColorRed)), |
| 974 | + | HideTextProgress(), |
| 975 | + | }, |
| 976 | + | absolute: &absoluteCall{done: 6, total: 10}, |
| 977 | + | canvas: image.Rect(0, 0, 10, 3), |
| 978 | + | want: func(size image.Point) *faketerm.Terminal { |
| 979 | + | ft := faketerm.MustNew(size) |
| 980 | + | c := testcanvas.MustNew(ft.Area()) |
| 981 | + | |
| 982 | + | testdraw.MustRectangle(c, image.Rect(0, 0, 6, 3), |
| 983 | + | draw.RectChar('o'), |
| 984 | + | draw.RectCellOpts(cell.BgColor(cell.ColorGreen)), |
| 985 | + | ) |
| 986 | + | testdraw.MustHVLines(c, []draw.HVLine{{ |
| 987 | + | Start: image.Point{X: 5, Y: 0}, |
| 988 | + | End: image.Point{X: 5, Y: 2}, |
| 989 | + | }}, draw.HVLineStyle(linestyle.Light), |
| 990 | + | draw.HVLineCellOpts(cell.BgColor(cell.ColorRed))) |
840 | 991 | | testcanvas.MustApply(c, ft) |
841 | 992 | | return ft |
842 | 993 | | }, |
| skipped 161 lines |