add test for accellog

pull/821/head
Gordon Williams 2021-09-23 13:02:24 +01:00
parent 0109a8114b
commit 16fe84704b
7 changed files with 32 additions and 18 deletions

View File

@ -105,7 +105,6 @@ function startRecord(force) {
showMenu();
}}
]);
layout.update();
layout.render();
// now start writing

Binary file not shown.

View File

@ -1,5 +1,4 @@
#!/bin/bash
cd `dirname $0`
cd ../tests
ls *.js | xargs ../bin/runtest.sh
cd `dirname $0`/..
ls tests/*.js | xargs -I{} bin/runtest.sh {}

View File

@ -2,35 +2,38 @@
# Requires Linux x64 (for ./espruino)
# Also imagemagick for display
cd `dirname $0`
cd `dirname $0`/..
if [ "$#" -ne 1 ]; then
echo "USAGE:"
echo " bin/runtest.sh testxyz.js"
echo " bin/runtest.sh tests/testxyz.js"
exit 1
fi
# temporary test files
TESTJS=tmp.js
TESTBMP=tmp.bmp
TESTJS=bin/tmp.js
TESTBMP=bin/tmp.bmp
# actual source files
SRCDIR=../tests/
SRCDIR=tests
SRCJS=$1
SRCBMP=`basename $SRCJS .js`.bmp
SRCBMP=$SRCDIR/`basename $SRCJS .js`.bmp
echo "TEST $SRCJS ($SRCBMP)"
cat ../../../modules/Layout.js > $TESTJS
cat ../../modules/Layout.js > $TESTJS
echo 'Bangle = {};BTN1=0;process.env = process.env;process.env.HWVERSION=2;' >> $TESTJS
echo 'g = Graphics.createArrayBuffer(176,176,4);' >> $TESTJS
cat $SRCDIR/$SRCJS >> $TESTJS || exit 1
cat $SRCJS >> $TESTJS || exit 1
echo 'layout.render()' >> $TESTJS
echo 'layout.debug()' >> $TESTJS
#echo 'layout.debug()' >> $TESTJS
echo 'require("fs").writeFileSync("'$TESTBMP'",g.asBMP())' >> $TESTJS
./espruino $TESTJS || exit 1
if ! cmp $TESTBMP $SRCDIR/$SRCBMP >/dev/null 2>&1
bin/espruino $TESTJS || exit 1
if ! cmp $TESTBMP $SRCBMP >/dev/null 2>&1
then
echo Files differ
convert "+append" $TESTBMP $SRCDIR/$SRCBMP ../testresult.bmp
display ../testresult.bmp
echo =============================================
echo $TESTBMP $SRCBMP differ
echo ==============================================
convert "+append" $TESTBMP $SRCBMP testresult.bmp
display testresult.bmp
exit 1
else
echo Files are the same

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -0,0 +1,13 @@
// Based on accellog usage
var layout = new Layout({ type: "v", c: [
{type:"txt", font:"6x8", label:"Samples", pad:2},
{type:"txt", id:"samples", font:"6x8:2", label:" - ", pad:5},
{type:"txt", font:"6x8", label:"Time", pad:2},
{type:"txt", id:"time", font:"6x8:2", label:" - ", pad:5},
{type:"txt", font:"6x8:2", label:"RECORDING", bgCol:"#f00", pad:5, fillx:1},
]
},[ // Buttons...
{label:"STOP", cb:()=>{}}
]);
layout.samples.label = "123";
layout.time.label = "123s";

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB