Commit 26939a27 authored by lyong's avatar lyong

feat:增加自动化测试

parent bad876fe
// globalThis.cslog = //console.log
// //console.log = function () {
console.log = function () {
// }
// console.trace = function () {
}
console.trace = function () {
// }
}
console.debug = function (text) {
var date = new Date()
text = `========= [${date}] ${text}`
......@@ -60,6 +60,8 @@ function onCreate(uri) {
console.log(times);
gc();
}
require("autoFactoryTest.js").autoFactoryTestTimer();
}
// function onKeyEvent(code) {
......
<html>
<div class="screen">
<div id="id_color"></div>
<image style="left:0;top:0;" id="id_testPng" :src="gifIconSrc">{{gifIconSrc}}</image>
<text class="page" style="color: #f11515; font-size: 88;">auto Test</text>
<text class="testReturn" id="id_ng" onpress="touchedScreen" onclick="touch1Button" style="top: 300;left:22 ;color: #F44236;background-color: #858282;">点击1</text>
<text class="testReturn" id="id_back" onpress="touchedScreen" onclick="touched2Button" style="top: 300;left:174;color: #000000;background-color: #858282;">点击2</text>
<text class="testReturn" id="id_yes" onpress="touchedScreen" onclick="touch3Button" style="top: 300;left:326;color: #000000;background-color: #FF9700;">点击3</text>
</div>
</html>
<script>
var router = require("@system.router");
var lvgl = require("@native.lvgl7");
var autoUtil = require("autoFactoryTestUtil.js");
var manual = require("autoFactoryTest.js");
var idTimeOut = null;
export default {
data: {
colorBash: [
{
"val": 0xffffff,//纯白
"text": "纯白:#ffffff"//纯白
},
{
"val": 0xff0000,//纯红
"text": "纯红:#ff0000",//纯红
},
{
"val": 0x00ff00,//纯绿
"text": "纯绿:#00ff00",//纯绿
},
{
"val": 0x0000ff,//纯蓝
"text": "纯蓝:#0000ff",//纯蓝
},
{
"val": 0x000000,//纯黑
"text": "纯黑:#000000",//纯黑
},
],
colorBashPng: [
{
"val": "./../../../../../mnt/app/quicknode/tests/re860_factory/images/factory/factoryGradientColor.png",
"text": "渐变:png1",
},
{
"val": "./../../../../../mnt/app/quicknode/tests/re860_factory/images/factory/factoryWhileToBlack.png",
"text": "渐变:png2",//纯黑
},
],
imgCnt: 0,
pngCnt: 0,
gifIconSrc: "",
},
onshwKeyBuntton: function () {
console.log("!!onshwKeyBuntton")
this.checkFlagBash(0)
},
exitLedTest: function () {
console.log("!!exitLedTest")
this.clearTimer();
},
/*************** struct ***************/
onInit: function () {
//this.$setImageForceUpdate(true);
},
onShow: function () {
//console.log(this.$uri + "===========onShow=============")
this.$hide("id_testPng")
this.imgCnt = 0
this.pngCnt = 0
this.checkFlagBash(this.imgCnt)
this.imgCnt++
this.gifIconSrc = " ";
this.$hide("id_testPng")
this.checkFlagBash(0)
this.$show("id_yes")
this.$show("id_ng")
this.$show("id_back")
autoUtil.initPage(this)
},
onHide: function () {
//console.log(this.$uri + "===========onHide=============")
this.clearTimer()
},
onQuit: function () {
//console.log(this.$uri + "===========onQuit=============")
this.clearTimer()
},
resetLcd: function () {
if (this.imgCnt >= this.colorBash.length &&
this.pngCnt >= this.colorBashPng.length) {
this.imgCnt = 0;
this.pngCnt = 0;
this.gifIconSrc = " ";
this.$hide("id_testPng")
}
},
/*************** timer ***************/
ledtimerSet: function () {
this.resetLcd();
this.clearTimer();
idTimeOut = this.$setInterval(this.normalTimerOut, 300, [], this);
// this.$setTimeout(this.LedTimerOut, 5000, [], this);
},
resetUI: function () {
this.gifIconSrc = " ";
this.$hide("id_testPng")
this.checkFlagBash(0)
this.$hide("id_yes")
this.$hide("id_ng")
this.$hide("id_back")
},
normalTimerOut: function () {
this.resetLcd();
this.touchedScreen();
},
clearTimer: function () {
if (idTimeOut != null) {
this.$clearInterval(idTimeOut);
idTimeOut = null;
}
},
/*************** connect ***************/
/*************** event ***************/
shortDelay: function () {
this.$setX("id_ng", 800);
this.$setY("id_ng", 340);
//console.log("=====show id_ng successful!")
this.$clearTimeout(this.shortDelayId);
},
touchedScreen: function () {
if (this.imgCnt < this.colorBash.length) {
this.checkFlagBash(this.imgCnt)
this.imgCnt++
} else {
if (this.pngCnt < this.colorBashPng.length) {
this.checkFlagBash2(this.pngCnt)
this.pngCnt++
if (this.pngCnt == this.colorBashPng.length) {
//console.log("=====show id_yes successful!")
}
}
}
},
/*************** gesture ***************/
onGestureEvent: function (dir, x, y) {
//console.log(dir + " " + x + " " + y);
},
/*************** work ***************/
checkFlagBash: function (val) {
var temp = this.colorBash[val].val
//console.log("tempType = " + typeof temp)
//console.log("tempValue = " + temp)
this.$setBackgroundColor("id_color", temp)
},
checkFlagBash2: function (val) {
var temp = this.colorBashPng[val].val
//console.log("tempValue = " + temp)
this.gifIconSrc = temp;
this.$show("id_testPng")
},
touch1Button: function (node, topNode, x, y) {
autoUtil.ciclkAutoFactory(1)
manual.manualKeyBz("TOUCH1")
},
touched2Button: function (node, topNode, x, y) {
autoUtil.ciclkAutoFactory(2)
manual.manualKeyBz("TOUCH2")
},
touch3Button: function (node, topNode, x, y) {
autoUtil.ciclkAutoFactory(3)
manual.manualKeyBz("TOUCH3")
},
}
</script>
<style>
.screen {
left: 0px;
top: 0px;
width: 1280;
height: 1280;
background-color: gray;
}
/*********************************/
#id_color {
width: 1280;
height: 1280;
background-color: black;
}
#reminderText {
top: 40;
width: 500;
height: 100;
border-radius: 10;
border-width: 2;
border-color: white;
text-align: left;
/* text-overflow: ellipsis; */
font-size: 60;
color: white;
background-color: transparent;
}
.class_msg {
top: 240;
width: 200;
height: 100;
border-radius: 10;
border-width: 2;
border-color: white;
text-align: center;
text-overflow: ellipsis;
font-size: 60;
color: red;
background-color: gainsboro;
}
#id_yes {
bottom: 20px;
left: 20px;
}
#id_ng {
bottom: 20px;
right: 20px;
}
#id_back {
bottom: 20px;
right: 20px;
}
.testReturn {
position: absolute;
width: 130;
height: 130;
text-align: center;
text-overflow: ellipsis;
font-size: 40;
}
.page {
position: absolute;
top: 0;
width: 480;
height: 200;
text-align: center;
text-overflow: ellipsis;
font-size: 66;
}
</style>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
var dlfcn = require("dlfcna.js");
console.log(dlfcn)
var funcs = [
["uart_init", "iss"],
["uart_close", "vi"],
["uart_send", "iisi"],
["uart_recv", "si"],
["uart_recv_hex", "si"],
["kill_tty_user", "is"],
["pwm_uart_init", "vv"],
["uart_set_canonical", "vi"],
["uart_set_raw", "vi"]
];
console.log("in uartUtil.js")
function register() {
console.log("will register uartUtil.so")
var isSuccess = dlfcn.register("@native.uartUtil", "/mnt/app/quicknode/tests/re860_factory/lib/factory/uartUtil.so", funcs);
if (isSuccess) {
console.log("load so successfully")
var uartUtil = require("@native.uartUtil");
return uartUtil
} else {
console.log("load so failed")
}
return undefined;
}
var uartUtil = register();
function uart_init(port, baud_str) {
// int uart_init(const char *port, const char *baud_str);
return uartUtil.uart_init(port, baud_str);
}
function uart_close(fd) {
// void uart_close(int fd);
uartUtil.uart_close(fd);
}
function uart_send(fd, data, len) {
// int uart_send(int fd, const void *data, size_t len);
return uartUtil.uart_send(fd, data, len);
}
function uart_recv(fd) {
// char *uart_recv(int fd)
return uartUtil.uart_recv(fd);
}
function uart_recv_hex(fd) {
console.log("!!uart_recv_hex:" + fd);
// char *uart_recv(int fd)
// console.log("uart_recv_hex:" + fd);
return uartUtil.uart_recv_hex(fd);
}
function kill_tty_user(port) {
console.log("!!kill_tty_user:" + port);
// const char *port = "/dev/ttyS0";
// int killed = kill_tty_user(port);
return uartUtil.kill_tty_user(port);
}
function pwm_uart_init() {
console.log("!!pwm_uart_init");
uartUtil.pwm_uart_init();
}
function uart_set_canonical(fd) {
console.log("!!!!!! Please use C code to modify rx_thread !!!!!");
return;
console.log("!!uart_set_canonical:" + fd);
// 串口设为 canonical 模式 //
uartUtil.uart_set_canonical(fd);
}
function uart_set_raw(fd) {
console.log("!!uart_set_raw:" + fd);
// 串口设为 raw 模式
uartUtil.uart_set_raw(fd);
}
module.exports = {
uart_init: uart_init,
uart_close: uart_close,
uart_send: uart_send,
uart_recv: uart_recv,
uart_recv_hex: uart_recv_hex,
kill_tty_user: kill_tty_user,
pwm_uart_init: pwm_uart_init,
uart_set_canonical: uart_set_canonical,
uart_set_raw: uart_set_raw
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment