Skip to content

Commit

Permalink
test -m
Browse files Browse the repository at this point in the history
  • Loading branch information
matklad committed Mar 27, 2019
1 parent d702f60 commit e50ffa5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
6 changes: 5 additions & 1 deletion jumpapp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jumpapp() {
list_matching_windows "$classid" "${pids[@]}" | print_windows
elif [[ -n "$focusOrMinimize" ]] && [[ ${#windowids[@]} -eq "1" ]] \
&& [[ "$(get_active_windowid)" -eq "${windowids[0]}" ]]; then
xdotool getactivewindow windowminimize
minimize_active_window
elif (( ${#windowids[@]} )) && ! needs_passthrough "$@"; then
local window=$(get_subsequent_window "${windowids[@]}")
if [[ -n "$keep_workspace" ]]; then
Expand Down Expand Up @@ -398,6 +398,10 @@ center_cursor() {
xdotool mousemove -w "$1" $(wmctrl -lG | grep "$1" | awk '{ print $5/2 " " $6/2 }')
}

minimize_active_window() {
xdotool getactivewindow windowminimize
}

has_command() {
hash "$1" 2>/dev/null
}
Expand Down
25 changes: 25 additions & 0 deletions t/test_jumpapp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ setUp() {
activate_window_arg=
center_cursor_called=
center_cursor_arg=
minimize_active_window_called=
die_called=
exec_command_called=
focus_window_by_class_called=
Expand Down Expand Up @@ -364,6 +365,26 @@ it_prints_matching_windows_when_called_with_-L() {
[[ "$output" == *"678 somehost 123 -1 someapp: SomeApp Window #2"* ]] || fail 'Output does not list Window #2'
}

it_calls_minimize_active_window_when_called_with_-m_and_window_is_active() {
active_windowid=456
list_windows_output='456 somehost 123 -1 someapp
567 somehost 234 -1 anotherapp AnotherApp Window'
main -m someapp

assertNotNull 'minimize_active_window() called' "$minimize_active_window_called"
}

it_calls_activate_window_when_called_with_-m_but_the_window_is_not_active() {
active_windowid=567
list_windows_output='456 somehost 123 -1 someapp
567 somehost 234 -1 anotherapp AnotherApp Window'
main -m someapp

assertNull 'minimize_active_window() not called' "$minimize_active_window_called"
assertNotNull 'i() called' "$activate_window_called"
assertEquals 456 "$activate_window_arg"
}

##### Test Doubles #####

source ./jumpapp # load app now, so we can override it
Expand Down Expand Up @@ -420,6 +441,10 @@ center_cursor() {
center_cursor_arg=$1
}

minimize_active_window() {
minimize_active_window_called=1
}

has_command() {
return "$has_command_val"
}
Expand Down

0 comments on commit e50ffa5

Please sign in to comment.