aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMarshall Greenblatt <magreenblatt@gmail.com>2019-06-29 21:27:36 -0400
committerMarshall Greenblatt <magreenblatt@gmail.com>2019-07-01 11:36:54 -0400
commitd0f5129e0d0680810f2657078696f9fb85e3185f (patch)
treec3b3f387c4ac70a83cd572461c74be454c1ccbf9 /tools
parent6b140efeef4e566b6a68025b1dcea9b2da6e6e57 (diff)
downloadjcef-d0f5129e0d0680810f2657078696f9fb85e3185f.tar.gz
Add initial JUnit test support (see issue #339).
Unit tests can be run from the command line using the run_tests.[bat|sh] script. Currently supported on Windows and Linux only. Known issues: - Linux: TestFrame hangs due to the onBeforeClose event not being delivered.
Diffstat (limited to 'tools')
-rw-r--r--tools/compile.bat4
-rwxr-xr-xtools/compile.sh4
-rwxr-xr-xtools/run.sh5
-rw-r--r--tools/run_tests.bat62
-rwxr-xr-xtools/run_tests.sh35
5 files changed, 103 insertions, 7 deletions
diff --git a/tools/compile.bat b/tools/compile.bat
index 4ed396b..a3371e1 100644
--- a/tools/compile.bat
+++ b/tools/compile.bat
@@ -14,10 +14,10 @@ goto end
)
set OUT_PATH=".\out\%1"
-set CLS_PATH=".\third_party\jogamp\jar\*;.\java"
+set CLS_PATH=".\third_party\jogamp\jar\*;.\third_party\junit\*;.\java"
if not exist %OUT_PATH% mkdir %OUT_PATH%
-javac -Xdiags:verbose -cp %CLS_PATH% -d %OUT_PATH% java/tests/detailed/*.java java/tests/simple/*.java java/org/cef/*.java java/org/cef/browser/*.java java/org/cef/callback/*.java java/org/cef/handler/*.java java/org/cef/misc/*.java java/org/cef/network/*.java
+javac -Xdiags:verbose -cp %CLS_PATH% -d %OUT_PATH% java/tests/detailed/*.java java/tests/junittests/*.java java/tests/simple/*.java java/org/cef/*.java java/org/cef/browser/*.java java/org/cef/callback/*.java java/org/cef/handler/*.java java/org/cef/misc/*.java java/org/cef/network/*.java
:: Copy resource files.
xcopy /sfy .\java\tests\detailed\handler\*.html %OUT_PATH%\tests\detailed\handler\
diff --git a/tools/compile.sh b/tools/compile.sh
index 7ef730b..97b861a 100755
--- a/tools/compile.sh
+++ b/tools/compile.sh
@@ -9,13 +9,13 @@ if [ -z "$1" ]; then
echo "ERROR: Please specify a target platform: linux32 or linux64"
else
export OUT_PATH="./out/$1"
- export CLS_PATH="./third_party/jogamp/jar/*:./java"
+ export CLS_PATH="./third_party/jogamp/jar/*:./third_party/junit/*:./java"
if [ ! -d "$OUT_PATH" ]; then
mkdir -p "$OUT_PATH"
fi
- javac -Xdiags:verbose -cp $CLS_PATH -d $OUT_PATH java/tests/detailed/*.java java/tests/simple/*.java java/org/cef/*.java java/org/cef/browser/*.java java/org/cef/callback/*.java java/org/cef/handler/*.java java/org/cef/misc/*.java java/org/cef/network/*.java
+ javac -Xdiags:verbose -cp $CLS_PATH -d $OUT_PATH java/tests/detailed/*.java java/tests/junittests/*.java java/tests/simple/*.java java/org/cef/*.java java/org/cef/browser/*.java java/org/cef/callback/*.java java/org/cef/handler/*.java java/org/cef/misc/*.java java/org/cef/network/*.java
# Copy resource files.
cp -f ./java/tests/detailed/handler/*.html $OUT_PATH/tests/detailed/handler
diff --git a/tools/run.sh b/tools/run.sh
index 1a58940..083922e 100755
--- a/tools/run.sh
+++ b/tools/run.sh
@@ -13,7 +13,7 @@ else
elif [ -z "$3" ]; then
echo "ERROR: Please specify a run type: detailed or simple"
else
- export OUT_PATH="./out"
+ export OUT_PATH="./out/$1"
export LIB_PATH=$(readlink -f "./jcef_build/native/$2")
if [ ! -d "$LIB_PATH" ]; then
@@ -21,7 +21,7 @@ else
exit 1
fi
- export CLS_PATH="./third_party/jogamp/jar/*:$OUT_PATH/$1"
+ export CLS_PATH="./third_party/jogamp/jar/*:$OUT_PATH"
export RUN_TYPE="$3"
# Necessary for jcef_helper to find libcef.so.
@@ -37,4 +37,3 @@ else
fi
cd tools
-
diff --git a/tools/run_tests.bat b/tools/run_tests.bat
new file mode 100644
index 0000000..461bbef
--- /dev/null
+++ b/tools/run_tests.bat
@@ -0,0 +1,62 @@
+@echo off
+:: Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
+:: reserved. Use of this source code is governed by a BSD-style license
+:: that can be found in the LICENSE file.
+
+set RC=
+setlocal
+cd ..
+
+if "%1" == "" (
+echo ERROR: Please specify a target platform: win32 or win64
+set ERRORLEVEL=1
+goto end
+)
+
+if "%2" == "" (
+echo ERROR: Please specify a build type: Debug or Release
+set ERRORLEVEL=1
+goto end
+)
+
+if "%JAVA_HOME%" == "" (
+echo ERROR: Please set the JAVA_HOME environment variable
+set ERRORLEVEL=1
+goto end
+)
+
+set OUT_PATH=.\out\%~1
+
+set LIB_PATH=.\jcef_build\native\%~2
+if not exist %LIB_PATH% (
+echo ERROR: Native build output path does not exist
+goto end
+)
+
+set CLS_PATH=.\third_party\jogamp\jar\*;%OUT_PATH%
+
+:: Remove the first two params (%1 and %2) and pass the rest to java.
+set RESTVAR=
+shift
+shift
+:loop1
+if "%1"=="" goto after_loop
+set RESTVAR=%RESTVAR% %1
+shift
+goto loop1
+:after_loop
+
+:: JUnit can fail to load JVM DLLs if you don't explicitly set the PATH.
+set PATH="%JAVA_HOME%\bin"
+
+java -Djava.library.path=%LIB_PATH% -jar .\third_party\junit\junit-platform-console-standalone-1.4.2.jar -cp %OUT_PATH% --disable-ansi-colors --select-package tests.junittests %RESTVAR%
+
+:end
+endlocal & set RC=%ERRORLEVEL%
+goto omega
+
+:returncode
+exit /B %RC%
+
+:omega
+call :returncode %RC%
diff --git a/tools/run_tests.sh b/tools/run_tests.sh
new file mode 100755
index 0000000..54f5eba
--- /dev/null
+++ b/tools/run_tests.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+# Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
+# reserved. Use of this source code is governed by a BSD-style license
+# that can be found in the LICENSE file.
+
+cd ..
+
+if [ -z "$1" ]; then
+ echo "ERROR: Please specify a target platform: linux32 or linux64"
+else
+ if [ -z "$2" ]; then
+ echo "ERROR: Please specify a build type: Debug or Release"
+ else
+ export OUT_PATH="./out/$1"
+
+ export LIB_PATH=$(readlink -f "./jcef_build/native/$2")
+ if [ ! -d "$LIB_PATH" ]; then
+ echo "ERROR: Native build output path does not exist"
+ exit 1
+ fi
+
+ export CLS_PATH="./third_party/jogamp/jar/*:$OUT_PATH"
+
+ # Necessary for jcef_helper to find libcef.so.
+ export LD_LIBRARY_PATH=$LIB_PATH
+
+ # Remove the first two params ($1 and $2) and pass the rest to java.
+ shift
+ shift
+
+ LD_PRELOAD=$LIB_PATH/libcef.so java -Djava.library.path=$LIB_PATH -jar ./third_party/junit/junit-platform-console-standalone-*.jar -cp $OUT_PATH --select-package tests.junittests "$@"
+ fi
+fi
+
+cd tools