Added tests for WMIC
parent
601202e816
commit
7602b1da32
|
|
@ -72,15 +72,8 @@ battery_percentage(){
|
||||||
echo ${IOREG_OUTPUT:--1}
|
echo ${IOREG_OUTPUT:--1}
|
||||||
elif _command_exists WMIC;
|
elif _command_exists WMIC;
|
||||||
then
|
then
|
||||||
local WINPC=$(echo porcent=$(WMIC PATH Win32_Battery Get EstimatedChargeRemaining /Format:List) | grep -o '[0-9]*')
|
local WINPC=$(WMIC PATH Win32_Battery Get EstimatedChargeRemaining /Format:List | grep -o '[0-9]\+' | head -1)
|
||||||
case $WINPC in
|
echo ${WINPC:--1}
|
||||||
100*)
|
|
||||||
echo '100'
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo $WINPC
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
else
|
else
|
||||||
echo "no"
|
echo "no"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -272,3 +272,61 @@ function setup_ioreg {
|
||||||
run battery_percentage
|
run battery_percentage
|
||||||
assert_output "0"
|
assert_output "0"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#######################
|
||||||
|
#
|
||||||
|
# WMIC
|
||||||
|
#
|
||||||
|
|
||||||
|
function setup_WMIC {
|
||||||
|
percent="$1"
|
||||||
|
|
||||||
|
function WMIC {
|
||||||
|
printf "Charge: %s" "${percent}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@test 'plugins battery: battery-percentage with WMIC, 100%' {
|
||||||
|
setup_command_exists "WMIC"
|
||||||
|
|
||||||
|
setup_WMIC "100%"
|
||||||
|
|
||||||
|
run battery_percentage
|
||||||
|
assert_output "100"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test 'plugins battery: battery-percentage with WMIC, 98%' {
|
||||||
|
setup_command_exists "WMIC"
|
||||||
|
|
||||||
|
setup_WMIC "98%"
|
||||||
|
|
||||||
|
run battery_percentage
|
||||||
|
assert_output "98"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test 'plugins battery: battery-percentage with WMIC, 98.5%' {
|
||||||
|
setup_command_exists "WMIC"
|
||||||
|
|
||||||
|
setup_WMIC "98.5%"
|
||||||
|
|
||||||
|
run battery_percentage
|
||||||
|
assert_output "98"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test 'plugins battery: battery-percentage with WMIC, 4%' {
|
||||||
|
setup_command_exists "WMIC"
|
||||||
|
|
||||||
|
setup_WMIC "4%"
|
||||||
|
|
||||||
|
run battery_percentage
|
||||||
|
assert_output "4"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test 'plugins battery: battery-percentage with WMIC, no status' {
|
||||||
|
setup_command_exists "WMIC"
|
||||||
|
|
||||||
|
setup_WMIC ""
|
||||||
|
|
||||||
|
run battery_percentage
|
||||||
|
assert_output "-1"
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue