1package app
2
3import (
4 "testing"
5
6 "github.com/stretchr/testify/assert"
7
8 "github.com/bnema/nefercap/internal/adapters/cli"
9 "github.com/bnema/nefercap/internal/adapters/config"
10 "github.com/bnema/nefercap/internal/ports"
11)
12
13// Only selectors that can take a screenshot freeze the screen; rec records the
14// live screen, and selector.freeze = off keeps every selector live.
15func TestFreezes(t *testing.T) {
16 on, off := config.Settings{Freeze: true}, config.Settings{}
17 for _, tc := range []struct {
18 command cli.Command
19 settings config.Settings
20 want bool
21 }{
22 {cli.Shot, on, true},
23 {cli.AllInOne, on, true},
24 {cli.Rec, on, false},
25 {cli.Shot, off, false},
26 {cli.AllInOne, off, false},
27 } {
28 assert.Equal(t, tc.want, freezes(cli.Options{Command: tc.command}, tc.settings), "%s freeze=%v", tc.command, tc.settings.Freeze)
29 }
30}
31
32// Outputs too large for a backdrop are not frozen, so their screenshot is
33// live like their selector.
34func TestFrozenOutputs(t *testing.T) {
35 outputs := []ports.Output{{ID: 7, Width: 3840, Height: 2160}, {ID: 8, Width: 5120, Height: 2160}, {ID: 9, Width: 1080, Height: 1920}, {ID: 10}, {ID: 11, Width: 7680, Height: 4320}}
36 assert.Equal(t, []uint32{7, 8, 9}, frozenOutputs(outputs))
37}