-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for v3 get image only and get screenshot
- Loading branch information
1 parent
b35c804
commit 3f81829
Showing
7 changed files
with
110 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
proto="$PROTO_V3" | ||
method="$METHOD_GET_IMAGE_ONLY" | ||
|
||
. scripts/common/get_image.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
proto="$PROTO_V3" | ||
method="$METHOD_GET_SCREENSHOT" | ||
disp_num=1 | ||
disp="$(printf '%016x' $disp_num)" | ||
|
||
copy_image "$imgSample" | ||
|
||
. scripts/common/get_screenshot.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
|
||
. init.sh | ||
|
||
copy_image "$imgSample" | ||
|
||
responseDump=$(echo -n "${proto}${method}" | hex2bin | client_tool) | ||
|
||
protoAck="$PROTO_SUPPORTED" | ||
methodAck="$METHOD_OK" | ||
length=$(printf '%016x' "$((${#imgSample} / 2))") | ||
|
||
expected="${protoAck}${methodAck}${length}${imgSample}" | ||
|
||
if [ "$DETECTED_OS" = 'Linux' ]; then | ||
if [ "$responseDump" != "$expected" ]; then | ||
showStatus info 'Incorrect server response.' | ||
echo 'Expected:' "${expected::20} ..." | ||
echo 'Received:' "${responseDump::20} ..." | ||
exit 1 | ||
fi | ||
elif [ "$DETECTED_OS" = 'Windows' ]; then | ||
if [ "${responseDump::36}" != "${expected::36}" ]; then | ||
showStatus info 'Incorrect server response.' | ||
echo 'Expected:' "${expected::20} ..." | ||
echo 'Received:' "${responseDump::20} ..." | ||
exit 1 | ||
fi | ||
elif [ "$DETECTED_OS" = 'macOS' ]; then | ||
if [ "${responseDump::17}" != "${expected::17}" ]; then | ||
showStatus info 'Incorrect server response.' | ||
echo 'Expected:' "${expected::17} ..." | ||
echo 'Received:' "${responseDump::17} ..." | ||
exit 1 | ||
fi | ||
imgSize="$((0x${responseDump:4:16}))" | ||
if [ "$imgSize" -gt '512' ]; then | ||
showStatus info "Image is too large. size=${imgSize}." | ||
exit 1 | ||
fi | ||
if [ "${responseDump:20:16}" != "${expected:20:16}" ]; then | ||
showStatus info 'Incorrect server response.' | ||
echo 'Expected:' "${expected::17} ..." | ||
echo 'Received:' "${responseDump::17} ..." | ||
exit 1 | ||
fi | ||
else | ||
showStatus info "Unknown OS." | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
. init.sh | ||
|
||
responseDump=$(echo -n "${proto}${method}${disp}" | hex2bin | client_tool) | ||
|
||
protoAck="$PROTO_SUPPORTED" | ||
methodAck="$METHOD_OK" | ||
|
||
expected_proto_method_ack="${protoAck}${methodAck}" | ||
len_expected_header="${#expected_proto_method_ack}" | ||
|
||
if [ "${responseDump::len_expected_header}" != "$expected_proto_method_ack" ]; then | ||
showStatus info 'Incorrect protocol:method ack.' | ||
echo 'Expected:' "$expected_proto_method_ack" | ||
echo 'Received:' "${responseDump::len_expected_header}" | ||
exit 1 | ||
fi | ||
|
||
length="$((16#${responseDump:len_expected_header:16}))" | ||
|
||
if [ "$length" -le '512' ]; then | ||
showStatus info 'Invalid image length.' | ||
exit 1 | ||
fi | ||
|
||
len_expected_header="$((len_expected_header + 16))" | ||
|
||
expected_png_header="$(printf '\x89PNG\r\n\x1a\n' | bin2hex)" | ||
png_header="${responseDump:len_expected_header:${#expected_png_header}}" | ||
|
||
if [ "$png_header" != "$expected_png_header" ]; then | ||
showStatus info 'Invalid image header.' | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,5 @@ | ||
#!/bin/bash | ||
|
||
. init.sh | ||
|
||
imgSample="89504e470d0a1a0a0000000d4948445200000005000000050802000000020db1b20\ | ||
00000264944415408d755cb2112002010804070fcff973168f0681bb042b99501f5ac8bbf9ad6c\ | ||
dfc0f828c0e0522b1809c0000000049454e44ae426082" | ||
|
||
copy_image "$imgSample" | ||
|
||
method="$METHOD_GET_IMAGE" | ||
|
||
responseDump=$(echo -n "${proto}${method}" | hex2bin | client_tool) | ||
|
||
protoAck="$PROTO_SUPPORTED" | ||
methodAck="$METHOD_OK" | ||
length=$(printf '%016x' "$((${#imgSample} / 2))") | ||
|
||
expected="${protoAck}${methodAck}${length}${imgSample}" | ||
|
||
if [ "$DETECTED_OS" = 'Linux' ]; then | ||
if [ "$responseDump" != "$expected" ]; then | ||
showStatus info 'Incorrect server response.' | ||
echo 'Expected:' "${expected::20} ..." | ||
echo 'Received:' "${responseDump::20} ..." | ||
exit 1 | ||
fi | ||
elif [ "$DETECTED_OS" = 'Windows' ]; then | ||
if [ "${responseDump::36}" != "${expected::36}" ]; then | ||
showStatus info 'Incorrect server response.' | ||
echo 'Expected:' "${expected::20} ..." | ||
echo 'Received:' "${responseDump::20} ..." | ||
exit 1 | ||
fi | ||
elif [ "$DETECTED_OS" = 'macOS' ]; then | ||
if [ "${responseDump::17}" != "${expected::17}" ]; then | ||
showStatus info 'Incorrect server response.' | ||
echo 'Expected:' "${expected::17} ..." | ||
echo 'Received:' "${responseDump::17} ..." | ||
exit 1 | ||
fi | ||
imgSize="$((0x${responseDump:4:16}))" | ||
if [ "$imgSize" -gt '512' ]; then | ||
showStatus info "Image is too large. size=${imgSize}." | ||
exit 1 | ||
fi | ||
if [ "${responseDump:20:16}" != "${expected:20:16}" ]; then | ||
showStatus info 'Incorrect server response.' | ||
echo 'Expected:' "${expected::17} ..." | ||
echo 'Received:' "${responseDump::17} ..." | ||
exit 1 | ||
fi | ||
else | ||
showStatus info "Unknown OS." | ||
exit 1 | ||
fi | ||
. scripts/common/get_image.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,8 @@ | ||
#!/bin/bash | ||
|
||
. init.sh | ||
|
||
method="$METHOD_GET_IMAGE" | ||
disp='' # not used in method 5 | ||
|
||
clear_clipboard | ||
|
||
responseDump=$(echo -n "${proto}${method}" | hex2bin | client_tool) | ||
|
||
protoAck="$PROTO_SUPPORTED" | ||
methodAck="$METHOD_OK" | ||
|
||
expected_proto_method_ack="${protoAck}${methodAck}" | ||
len_expected_header="${#expected_proto_method_ack}" | ||
|
||
if [ "${responseDump::len_expected_header}" != "$expected_proto_method_ack" ]; then | ||
showStatus info 'Incorrect protocol:method ack.' | ||
echo 'Expected:' "$expected_proto_method_ack" | ||
echo 'Received:' "${responseDump::len_expected_header}" | ||
exit 1 | ||
fi | ||
|
||
length="$((16#${responseDump:len_expected_header:16}))" | ||
|
||
if [ "$length" -le '8' ]; then | ||
showStatus info 'Invalid image length.' | ||
exit 1 | ||
fi | ||
|
||
len_expected_header="$((len_expected_header + 16))" | ||
|
||
expected_png_header="$(printf '\x89PNG\r\n\x1a\n' | bin2hex)" | ||
png_header="${responseDump:len_expected_header:${#expected_png_header}}" | ||
|
||
if [ "$png_header" != "$expected_png_header" ]; then | ||
showStatus info 'Invalid image header.' | ||
exit 1 | ||
fi | ||
. scripts/common/get_screenshot.sh |