From fa9c178f092ac1f9082573e72e106cc0d7b9217d Mon Sep 17 00:00:00 2001 From: Robert Theis Date: Wed, 17 May 2017 19:59:07 -0700 Subject: [PATCH] Improve data path used for testing. Closes #208. --- preparetests.cmd | 29 ++++++++++--------- preparetests.sh | 15 +++++----- .../android/test/TessBaseAPITest.java | 6 ++-- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/preparetests.cmd b/preparetests.cmd index f0305b0e5..3a95ce200 100644 --- a/preparetests.cmd +++ b/preparetests.cmd @@ -1,20 +1,21 @@ +for /f %%i in ('adb shell echo $EXTERNAL_STORAGE') do set DIR=%%i + git clone https://github.com/tesseract-ocr/tessdata.git -adb shell rm /sdcard/testAddPageToDocument.pdf -adb shell rm /sdcard/testCreate.pdf +adb shell rm %DIR%/testAddPageToDocument.pdf +adb shell rm %DIR%/testCreate.pdf adb uninstall com.googlecode.tesseract.android.test -adb shell mkdir /sdcard/tesseract -adb shell mkdir /sdcard/tesseract/tessdata +adb shell mkdir %DIR%/tessdata -adb push -p tessdata/eng.cube.bigrams /sdcard/tesseract/tessdata -adb push -p tessdata/eng.cube.fold /sdcard/tesseract/tessdata -adb push -p tessdata/eng.cube.lm /sdcard/tesseract/tessdata -adb push -p tessdata/eng.cube.nn /sdcard/tesseract/tessdata -adb push -p tessdata/eng.cube.params /sdcard/tesseract/tessdata -adb push -p tessdata/eng.cube.size /sdcard/tesseract/tessdata -adb push -p tessdata/eng.cube.word-freq /sdcard/tesseract/tessdata -adb push -p tessdata/eng.tesseract_cube.nn /sdcard/tesseract/tessdata -adb push -p tessdata/eng.traineddata /sdcard/tesseract/tessdata -adb push -p tess-two/jni/com_googlecode_tesseract_android/src/tessdata/pdf.ttf /sdcard/tesseract/tessdata +adb push -p tessdata/eng.cube.bigrams %DIR%/tessdata +adb push -p tessdata/eng.cube.fold %DIR%/tessdata +adb push -p tessdata/eng.cube.lm %DIR%/tessdata +adb push -p tessdata/eng.cube.nn %DIR%/tessdata +adb push -p tessdata/eng.cube.params %DIR%/tessdata +adb push -p tessdata/eng.cube.size %DIR%/tessdata +adb push -p tessdata/eng.cube.word-freq %DIR%/tessdata +adb push -p tessdata/eng.tesseract_cube.nn %DIR%/tessdata +adb push -p tessdata/eng.traineddata %DIR%/tessdata +adb push -p tess-two/jni/com_googlecode_tesseract_android/src/tessdata/pdf.ttf %DIR%/tessdata diff --git a/preparetests.sh b/preparetests.sh index b8f3b4cf1..7abd1f3e7 100755 --- a/preparetests.sh +++ b/preparetests.sh @@ -1,17 +1,18 @@ #!/bin/sh +DIR="`adb shell echo \\$EXTERNAL_STORAGE`" + git clone https://github.com/tesseract-ocr/tessdata.git -adb shell rm /sdcard/testAddPageToDocument.pdf -adb shell rm /sdcard/testCreate.pdf +adb shell rm $DIR/testAddPageToDocument.pdf +adb shell rm $DIR/testCreate.pdf adb uninstall com.googlecode.tesseract.android.test -adb shell mkdir /sdcard/tesseract -adb shell mkdir /sdcard/tesseract/tessdata +adb shell mkdir $DIR/tessdata for f in tessdata/eng.*; do - TRAINEDDATA_FILENAME="/sdcard/tesseract/tessdata/`basename $f`" + TRAINEDDATA_FILENAME="$DIR/tessdata/`basename $f`" if [ `adb shell "if [ -f $TRAINEDDATA_FILENAME ]; then echo 1; fi"` ]; then echo "$TRAINEDDATA_FILENAME already present on device" @@ -19,9 +20,9 @@ for f in tessdata/eng.*; do fi echo "Copying $f to device..."; - adb push -p $f /sdcard/tesseract/tessdata + adb push -p $f $DIR/tessdata done -adb push -p tess-two/jni/com_googlecode_tesseract_android/src/tessdata/pdf.ttf /sdcard/tesseract/tessdata +adb push -p tess-two/jni/com_googlecode_tesseract_android/src/tessdata/pdf.ttf $DIR/tessdata # adb shell am instrument -w com.googlecode.tesseract.android.test/android.test.InstrumentationTestRunner diff --git a/tess-two-test/src/com/googlecode/tesseract/android/test/TessBaseAPITest.java b/tess-two-test/src/com/googlecode/tesseract/android/test/TessBaseAPITest.java index 63f9ab8fe..2cc90742a 100644 --- a/tess-two-test/src/com/googlecode/tesseract/android/test/TessBaseAPITest.java +++ b/tess-two-test/src/com/googlecode/tesseract/android/test/TessBaseAPITest.java @@ -26,6 +26,7 @@ import android.graphics.Paint.Style; import android.graphics.Rect; import android.os.AsyncTask; +import android.os.Environment; import android.test.suitebuilder.annotation.SmallTest; import android.text.Html; import android.util.Pair; @@ -47,10 +48,9 @@ import java.util.concurrent.Semaphore; public class TessBaseAPITest extends TestCase { - @SuppressLint("SdCardPath") - static final String TESSBASE_PATH = "/sdcard/tesseract/"; + static final String TESSBASE_PATH = Environment.getExternalStorageDirectory().toString(); static final String DEFAULT_LANGUAGE = "eng"; - private static final String TESSDATA_PATH = TESSBASE_PATH + "tessdata/"; + private static final String TESSDATA_PATH = TESSBASE_PATH + "/tessdata/"; private static final String[] EXPECTED_CUBE_DATA_FILES_ENG = { "eng.cube.bigrams", "eng.cube.fold",