demo / network-computer
Public
Copy of github.com/askrobots/network-computer (MIT): a desk you reach from anything. The original lives on GitHub.
GitStable demo
README: say this is a copy and where the original is
cde82c2
13 hours, 39 minutes ago
History
display_test.go · 1.2 KB · 39 lines
| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/askrobots/network-computer/internal/proto" |
| 7 | ) |
| 8 | |
| 9 | func TestNormalize(t *testing.T) { |
| 10 | cases := []struct { |
| 11 | in proto.InputEvent |
| 12 | want displayReq |
| 13 | }{ |
| 14 | {proto.InputEvent{W: 1920, H: 1080, S: 1.5}, displayReq{1920, 1080, 1.5}}, |
| 15 | {proto.InputEvent{W: 1600, H: 900, S: 1.5}, displayReq{1600, 900, 1.5}}, // 900 stays 900 |
| 16 | {proto.InputEvent{W: 1917, H: 1083, S: 1.26}, displayReq{1912, 1082, 1.25}}, // width /8, height even, 5% steps |
| 17 | {proto.InputEvent{W: 9000, H: 9000, S: 9}, displayReq{2560, 1600, 3}}, // clamped |
| 18 | {proto.InputEvent{W: 10, H: 10, S: 0}, displayReq{640, 360, 1}}, // floor + default scale |
| 19 | } |
| 20 | for _, c := range cases { |
| 21 | if got := normalize(c.in); got != c.want { |
| 22 | t.Errorf("normalize(%+v) = %+v, want %+v", c.in, got, c.want) |
| 23 | } |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | func TestBitrateFor(t *testing.T) { |
| 28 | cases := map[[2]int]string{ |
| 29 | {1280, 720}: "4000k", // the base |
| 30 | {1920, 1080}: "9000k", // 2.25x the pixels |
| 31 | {2560, 1600}: "16000k", // capped |
| 32 | {640, 360}: "1500k", // floored |
| 33 | } |
| 34 | for wh, want := range cases { |
| 35 | if got := bitrateFor("4M", wh[0], wh[1]); got != want { |
| 36 | t.Errorf("bitrateFor(4M, %dx%d) = %s, want %s", wh[0], wh[1], got, want) |
| 37 | } |
| 38 | } |
| 39 | } |