2011-09-30 15:26:14 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Run a test with the WebRTC Chromium build.
|
|
|
|
# Should work on any machine with a camera.
|
|
|
|
#
|
2012-03-15 10:40:23 +01:00
|
|
|
# Pass the argument --xvfb-and-screenshots to run in a xvfb environment and
|
|
|
|
# capture screenshots from inside the virtual environment. If you don't what
|
|
|
|
# that is, never mind and run this script without arguments.
|
|
|
|
#
|
2012-03-23 15:59:56 +01:00
|
|
|
# Pass the argument --chrome-binary <binary> to provide a custom chrome binary.
|
|
|
|
#
|
2011-09-30 15:26:14 +02:00
|
|
|
# Method:
|
2012-03-23 15:59:56 +01:00
|
|
|
# - Start peerconnection_server.
|
2012-03-15 10:40:23 +01:00
|
|
|
# - Start serving webrtc_test.html off a local web server.
|
|
|
|
# - Start 2 browser tabs.
|
|
|
|
# - Tab 1 connects to the server.
|
|
|
|
# - Tab 2 connects to the server and calls tab 1.
|
|
|
|
# - Both tabs will capture the webcam you have on the system and start
|
|
|
|
# sending to each other.
|
2011-09-30 15:26:14 +02:00
|
|
|
#
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2011-10-14 15:56:26 +02:00
|
|
|
if [ ! -x run_sanity_check ]; then
|
|
|
|
echo "Error: This script must run from its own directory"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2012-03-15 10:40:23 +01:00
|
|
|
# Tweakable parameters:
|
|
|
|
URLBASE=localhost:3000
|
|
|
|
CALLEE="$URLBASE/webrtc_test.html?name=test1&autoconnect=yes"
|
|
|
|
CALLER="$URLBASE/webrtc_test.html?name=test2&autocall=test1"
|
|
|
|
FLAGS="--enable-media-stream"
|
2012-03-23 15:59:56 +01:00
|
|
|
CHROME_BINARY=google-chrome
|
|
|
|
|
|
|
|
# Parse parameters:
|
|
|
|
while (( "$#" )); do
|
|
|
|
if [ "$1" == "--xvfb-and-screenshots" ]; then
|
|
|
|
RUN_WITH_XVFB_AND_SCREENSHOTS=1
|
|
|
|
fi
|
|
|
|
if [ "$1" == "--chrome-binary" ]; then
|
|
|
|
shift
|
|
|
|
CHROME_BINARY=$1
|
|
|
|
fi
|
|
|
|
shift
|
|
|
|
done
|
2012-03-15 10:40:23 +01:00
|
|
|
|
|
|
|
run_chrome_for_user() {
|
|
|
|
# Run the binary straight up and proceed with cleanup when the user closes
|
|
|
|
# the browser.
|
|
|
|
${CHROME_BINARY} $CALLEE $CALLER $FLAGS --user-data-dir=temp/user1
|
|
|
|
}
|
|
|
|
|
|
|
|
run_chrome_in_xvfb_with_screenshots() {
|
|
|
|
# Run chrome in a virtual window environment and capture screenshots.
|
|
|
|
# It will run for 30 seconds and then exit.
|
|
|
|
Xvfb :17 -screen 0 1024x768x24 &
|
2012-03-23 15:59:56 +01:00
|
|
|
XVFB=$!
|
2012-03-15 10:40:23 +01:00
|
|
|
DISPLAY=:17 ${CHROME_BINARY} $CALLEE $CALLER $FLAGS --user-data-dir=temp/user1 &
|
|
|
|
CHROME=$!
|
|
|
|
|
|
|
|
sleep 2
|
|
|
|
|
|
|
|
for (( i = 0; i < 6; i++ )) do
|
|
|
|
FILENAME="IMAGE${i}.png"
|
|
|
|
DISPLAY=:17 import -window root $FILENAME
|
|
|
|
sleep 5
|
|
|
|
done
|
|
|
|
kill $CHROME || echo "No Chrome process."
|
2012-03-23 15:59:56 +01:00
|
|
|
kill $XVFB || echo "No XVFB process."
|
2012-03-15 10:40:23 +01:00
|
|
|
}
|
|
|
|
|
2011-09-30 15:26:14 +02:00
|
|
|
PROJECT_ROOT=../..
|
|
|
|
|
2011-10-14 15:56:26 +02:00
|
|
|
if which lighttpd; then
|
|
|
|
LOCAL_WEB_SERVER_BINARY=$(which lighttpd)
|
|
|
|
else
|
2011-09-30 15:26:14 +02:00
|
|
|
echo "Error: You must install lighttpd first (sudo apt-get install lighttpd)"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2012-03-15 10:40:23 +01:00
|
|
|
SERVER_BINARY=${PROJECT_ROOT}/../../peerconnection/trunk/out/Debug/peerconnection_server
|
2011-09-30 15:26:14 +02:00
|
|
|
if [ ! -e "$SERVER_BINARY" ]; then
|
|
|
|
echo "Error: You must build peerconnection_server first."
|
2012-03-15 10:40:23 +01:00
|
|
|
echo "I expected to find a binary at $SERVER_BINARY but found none."
|
2011-09-30 15:26:14 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Launch the web server and make it serve the local www/html directory
|
|
|
|
${LOCAL_WEB_SERVER_BINARY} -D -f lighttpd.conf &
|
|
|
|
LOCAL_WEB_SERVER=$!
|
|
|
|
|
|
|
|
${SERVER_BINARY} &
|
|
|
|
SERVER=$!
|
|
|
|
echo "Started server as $SERVER"
|
|
|
|
|
2012-03-15 10:40:23 +01:00
|
|
|
# Launch a browser with two tabs:
|
2012-03-23 15:59:56 +01:00
|
|
|
if [ -z "$RUN_WITH_XVFB_AND_SCREENSHOTS" ]; then
|
2012-03-15 10:40:23 +01:00
|
|
|
run_chrome_for_user
|
2012-03-23 15:59:56 +01:00
|
|
|
else
|
|
|
|
run_chrome_in_xvfb_with_screenshots
|
2012-03-15 10:40:23 +01:00
|
|
|
fi
|
2011-09-30 15:26:14 +02:00
|
|
|
|
|
|
|
echo "Test finished, cleaning up"
|
|
|
|
|
2012-03-15 10:40:23 +01:00
|
|
|
kill $SERVER || echo "No peerconnection_server"
|
2011-10-14 15:56:26 +02:00
|
|
|
kill $LOCAL_WEB_SERVER || echo "No local web server"
|