■ ■ ■ ■ ■ ■
widgets/gauge/gauge_test.go
| skipped 840 lines |
841 | 841 | | return ft |
842 | 842 | | }, |
843 | 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 (negative)", |
| 898 | + | opts: []Option{ |
| 899 | + | Char('o'), |
| 900 | + | HideTextProgress(), |
| 901 | + | Threshold(-1, 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: "threshold outside of bounds (>=max)", |
| 919 | + | opts: []Option{ |
| 920 | + | Char('o'), |
| 921 | + | HideTextProgress(), |
| 922 | + | Threshold(100, linestyle.Light), // ignored |
| 923 | + | }, |
| 924 | + | percent: &percentCall{p: 35}, |
| 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, 3, 3), |
| 931 | + | draw.RectChar('o'), |
| 932 | + | draw.RectCellOpts(cell.BgColor(cell.ColorGreen)), |
| 933 | + | ) |
| 934 | + | testcanvas.MustApply(c, ft) |
| 935 | + | return ft |
| 936 | + | }, |
| 937 | + | }, |
844 | 938 | | } |
845 | 939 | | |
846 | 940 | | for _, tc := range tests { |
| skipped 157 lines |