diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/wallp.bats | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/wallp.bats b/tests/wallp.bats index 56f3d54..8a092d4 100644 --- a/tests/wallp.bats +++ b/tests/wallp.bats @@ -286,3 +286,52 @@ EOF run require_bins [ "$status" -eq 0 ] } + +@test "parse_conf reads optional PHONE_V and expands tilde" { + conf="$HOME/c.conf" + printf '%s\n' 'PHONE_V=~/sync/phone.png' 'PHONE_SIZE=1440x3120' > "$conf" + parse_conf "$conf" + [ "$CONF_PHONE_V" = "$HOME/sync/phone.png" ] + [ "$CONF_PHONE_SIZE" = "1440x3120" ] +} + +@test "sync_phone copies the vertical wallpaper to PHONE_V" { + printf 'img' > "$HOME/v.png" + mkdir -p "$HOME/.config/wallp" + printf '%s\n' "$HOME/v.png" > "$HOME/.config/wallp/wall_v" + CONF_PHONE_V="$HOME/sync/phone.png" + sync_phone + cmp -s "$HOME/v.png" "$HOME/sync/phone.png" +} + +@test "sync_phone skips a source it already copied" { + printf 'img' > "$HOME/v.png" + mkdir -p "$HOME/.config/wallp" + printf '%s\n' "$HOME/v.png" > "$HOME/.config/wallp/wall_v" + CONF_PHONE_V="$HOME/sync/phone.png" + sync_phone + touch -d '2000-01-01' "$HOME/sync/phone.png" + sync_phone + [ "$(stat -c %Y "$HOME/sync/phone.png")" = "$(date -d 2000-01-01 +%s)" ] +} + +@test "sync_phone crops to PHONE_SIZE, centred" { + magick -size 400x100 xc:red -fill blue -draw 'rectangle 180,0 219,99' "$HOME/v.png" + mkdir -p "$HOME/.config/wallp" + printf '%s\n' "$HOME/v.png" > "$HOME/.config/wallp/wall_v" + CONF_PHONE_V="$HOME/sync/phone.png" + CONF_PHONE_SIZE="20x50" + sync_phone + [ "$(magick identify -format '%wx%h' "$HOME/sync/phone.png")" = "20x50" ] + [ "$(magick "$HOME/sync/phone.png" -format '%[hex:p{10,25}]' info:)" = "0000FF" ] +} + +@test "sync_phone does nothing when PHONE_V is unset" { + printf 'img' > "$HOME/v.png" + mkdir -p "$HOME/.config/wallp" + printf '%s\n' "$HOME/v.png" > "$HOME/.config/wallp/wall_v" + CONF_PHONE_V="" + run sync_phone + [ "$status" -eq 0 ] + [ ! -e "$HOME/sync" ] +} |
