Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
2fae914a
H
Hello UTS
项目概览
DCloud
/
Hello UTS
通知
1595
Star
27
Fork
9
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
2
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
Hello UTS
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
2
Issue
2
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
2fae914a
编写于
2月 22, 2024
作者:
杜庆泉
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加console.log 自动化测试代码
上级
0cfffe72
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
327 addition
and
122 deletion
+327
-122
pages/SyntaxCase/consoleTest.uvue
pages/SyntaxCase/consoleTest.uvue
+67
-30
pages/SyntaxCase/consoleTest.vue
pages/SyntaxCase/consoleTest.vue
+61
-45
uni_modules/uts-advance/utssdk/app-android/index.uts
uni_modules/uts-advance/utssdk/app-android/index.uts
+0
-47
uni_modules/uts-api-test/changelog.md
uni_modules/uts-api-test/changelog.md
+0
-0
uni_modules/uts-api-test/package.json
uni_modules/uts-api-test/package.json
+82
-0
uni_modules/uts-api-test/readme.md
uni_modules/uts-api-test/readme.md
+6
-0
uni_modules/uts-api-test/utssdk/app-android/config.json
uni_modules/uts-api-test/utssdk/app-android/config.json
+3
-0
uni_modules/uts-api-test/utssdk/app-android/index.uts
uni_modules/uts-api-test/utssdk/app-android/index.uts
+95
-0
uni_modules/uts-api-test/utssdk/interface.uts
uni_modules/uts-api-test/utssdk/interface.uts
+3
-0
uni_modules/uts-api-test/utssdk/unierror.uts
uni_modules/uts-api-test/utssdk/unierror.uts
+10
-0
未找到文件。
pages/SyntaxCase/consoleTest.uvue
浏览文件 @
2fae914a
<template>
<button @click="logStr">打印字符串</button>
<button @click="logFloat">打印浮点数</button>
<button @click="logInt">打印整数</button>
<button @click="logObject">打印对象</button>
<button @click="logFunction">打印函数</button>
<div>
<button @click="doLogTest">打印测试</button>
<text>{{testRet}}</text>
</div>
</template>
<script>
import {
logStrTest,
logIntTest,
logFloatTest,
logObjectTest,
logFunctionTest
} from '@/uni_modules/uts-advance'
import { getLog,logObjectTest,logClassTest,logFunctionTest,logFileTest,logDateTest } from '../../uni_modules/uts-api-test'
export default {
data() {
return {}
return {
testRet:''
}
},
methods: {
logStr() {
logStrTest()
},
logFloat() {
logFloatTest()
},
logInt() {
logIntTest()
},
logObject() {
logObjectTest()
},
logFunction() {
logFunctionTest()
},
doLogTest() {
if(getLog("") != '{"type":"string","value":""}'){
this.testRet = "测试失败"
return;
}
if(getLog("字符串打印测试") != '{"type":"string","value":"字符串打印测试"}'){
this.testRet = "测试失败"
return;
}
if(getLog(2023) != '{"type":"number","value":"2023"}'){
this.testRet = "测试失败"
return;
}
// console.log(getLog(2023.0))
// if(getLog(2023.0) != '{"type":"number","value":"2023"}'){
// this.testRet = "测试失败"
// return;
// }
if(getLog(2023.002) != '{"type":"number","value":"2023.002"}'){
this.testRet = "测试失败"
return;
}
if(logObjectTest() != '{"className":"uts.sdk.modules.utsApiTest.ParamOptions","subType":"object","__$originalPosition":"","type":"object","value":{"methods":[],"properties":[{"name":"array","subType":"array","className":"io.dcloud.uts.UTSArray","type":"object","value":{"properties":[{"name":0,"type":"string","value":"1"},{"name":1,"type":"string","value":"2"},{"name":2,"type":"string","value":"3"}]}},{"name":"title","type":"string","value":"logObjectTest"}]}}'){
this.testRet = "测试失败"
return;
}
if(logFunctionTest() != '{"parameter":[],"type":"function"}'){
this.testRet = "测试失败"
return;
}
if(logClassTest() != '{"className":"uts.sdk.modules.utsApiTest.C","subType":"object","__$originalPosition":"","type":"object","value":{"methods":[],"properties":[{"name":"name","type":"string","value":"ccc"},{"parameter":["string"],"name":"sayBye","type":"function"}]}}'){
this.testRet = "测试失败"
return;
}
/**
* uvue 和 vue 因为 java 版本不同,所以这里的打印格式可能存在差异
*/
if(logFileTest() != '{"className":"java.io.File","subType":"object","type":"object","value":{"methods":[],"properties":[]}}'){
this.testRet = "测试失败"
return;
}
if(logDateTest() != '{"className":"io.dcloud.uts.Date","subType":"date","type":"object","value":"Sat Aug 08 1998 08:00:00 GMT+0800"}'){
this.testRet = "测试失败"
return;
}
this.testRet = "测试完成"
}
}
}
...
...
pages/SyntaxCase/consoleTest.vue
浏览文件 @
2fae914a
<
template
>
<div>
<button
@
click=
"logStr"
>
打印字符串
</button>
<button
@
click=
"logFloat"
>
打印浮点数
</button>
<button
@
click=
"logInt"
>
打印整数
</button>
<button
@
click=
"logObject"
>
打印对象
</button>
<button
@
click=
"logFunction"
>
打印函数
</button>
<button
@
click=
"logFile"
>
打印文件
</button>
<button
@
click=
"logDate"
>
打印日期
</button>
<button
@
click=
"logDateCombine"
>
组合打印日期
</button>
<button
@
click=
"doLogTest"
>
打印测试
</button>
<text>
{{
testRet
}}
</text>
</div>
</
template
>
<
script
>
import
{
logStrTest
,
logIntTest
,
logFloatTest
,
logObjectTest
,
logFunctionTest
,
logDateTest
,
logFileTest
,
logDateCombineTest
}
from
'
@/uni_modules/uts-advance
'
import
{
getLog
,
logObjectTest
,
logClassTest
,
logFunctionTest
,
logFileTest
,
logDateTest
}
from
'
../../uni_modules/uts-api-test
'
export
default
{
data
()
{
return
{}
return
{
testRet
:
''
}
},
methods
:
{
logStr
()
{
logStrTest
()
},
logFloat
()
{
logFloatTest
()
},
logInt
()
{
logIntTest
()
},
logObject
()
{
logObjectTest
()
},
logFunction
()
{
logFunctionTest
()
},
logFile
()
{
logFileTest
()
},
logDate
()
{
logDateTest
()
},
logDateCombine
()
{
logDateCombineTest
()
},
doLogTest
()
{
if
(
getLog
(
""
)
!=
'
{"type":"string","value":""}
'
){
this
.
testRet
=
"
测试失败
"
return
;
}
if
(
getLog
(
"
字符串打印测试
"
)
!=
'
{"type":"string","value":"字符串打印测试"}
'
){
this
.
testRet
=
"
测试失败
"
return
;
}
if
(
getLog
(
2023
)
!=
'
{"type":"number","value":"2023"}
'
){
this
.
testRet
=
"
测试失败
"
return
;
}
if
(
getLog
(
2023.0
)
!=
'
{"type":"number","value":"2023"}
'
){
this
.
testRet
=
"
测试失败
"
return
;
}
if
(
getLog
(
2023.002
)
!=
'
{"type":"number","value":"2023.002"}
'
){
this
.
testRet
=
"
测试失败
"
return
;
}
if
(
logObjectTest
()
!=
'
{"className":"uts.sdk.modules.utsApiTest.ParamOptions","subType":"object","__$originalPosition":"","type":"object","value":{"methods":[],"properties":[{"name":"array","subType":"array","className":"io.dcloud.uts.UTSArray","type":"object","value":{"properties":[{"name":0,"type":"string","value":"1"},{"name":1,"type":"string","value":"2"},{"name":2,"type":"string","value":"3"}]}},{"name":"title","type":"string","value":"logObjectTest"}]}}
'
){
this
.
testRet
=
"
测试失败
"
return
;
}
if
(
logFunctionTest
()
!=
'
{"parameter":[],"type":"function"}
'
){
this
.
testRet
=
"
测试失败
"
return
;
}
if
(
logClassTest
()
!=
'
{"className":"uts.sdk.modules.utsApiTest.C","subType":"object","__$originalPosition":"","type":"object","value":{"methods":[],"properties":[{"name":"name","type":"string","value":"ccc"},{"parameter":["string"],"name":"sayBye","type":"function"}]}}
'
){
this
.
testRet
=
"
测试失败
"
return
;
}
if
(
logFileTest
()
!=
'
{"className":"java.io.File","subType":"object","type":"object","value":{"methods":[],"properties":[{"name":"filePath","type":"null","value":"null"},{"name":"path","type":"string","value":"/sdcard/temp/1.txt"},{"name":"prefixLength","subType":"number","type":"Int","value":"1"},{"name":"status","type":"null","value":"null"}]}}
'
){
this
.
testRet
=
"
测试失败
"
return
;
}
if
(
logDateTest
()
!=
'
{"className":"io.dcloud.uts.Date","subType":"date","type":"object","value":"Sat Aug 08 1998 08:00:00 GMT+0800"}
'
){
this
.
testRet
=
"
测试失败
"
return
;
}
this
.
testRet
=
"
测试完成
"
}
}
}
...
...
uni_modules/uts-advance/utssdk/app-android/index.uts
浏览文件 @
2fae914a
...
...
@@ -433,53 +433,6 @@ export function callbackParam(callback : ParamCallback) {
}
callback(ret)
}
/**
* 打印测试方法
*/
export function logStrTest() {
console.log("logStrTest 字符串打印测试")
}
export function logFloatTest() {
console.log(3.1415926)
}
export function logIntTest() {
console.log(2023)
console.log(2023.0)
console.log(2023.002)
}
export function logObjectTest(){
let ret : ParamOptions = {
title: "logObjectTest",
array: ['1', '2', '3']
}
console.log(ret)
}
export function logFunctionTest(){
let testFun = function(){
console.log("testFun")
}
console.log(testFun)
}
export function logFileTest(){
console.log(new File("/sdcard/temp/1.txt"))
}
export function logDateTest(){
console.log(new Date())
}
export function logDateCombineTest(){
console.log("现在的日期是",new Date()," 以上是日期信息")
}
/**
...
...
uni_modules/uts-api-test/changelog.md
0 → 100644
浏览文件 @
2fae914a
uni_modules/uts-api-test/package.json
0 → 100644
浏览文件 @
2fae914a
{
"id"
:
"uts-test"
,
"displayName"
:
"uts-test"
,
"version"
:
"1.0.0"
,
"description"
:
"uts-test"
,
"keywords"
:
[
"uts-test"
],
"repository"
:
""
,
"engines"
:
{
"HBuilderX"
:
"^3.6.8"
},
"dcloudext"
:
{
"type"
:
"uts"
,
"sale"
:
{
"regular"
:
{
"price"
:
"0.00"
},
"sourcecode"
:
{
"price"
:
"0.00"
}
},
"contact"
:
{
"qq"
:
""
},
"declaration"
:
{
"ads"
:
""
,
"data"
:
""
,
"permissions"
:
""
},
"npmurl"
:
""
},
"uni_modules"
:
{
"dependencies"
:
[],
"encrypt"
:
[],
"platforms"
:
{
"cloud"
:
{
"tcb"
:
"u"
,
"aliyun"
:
"u"
,
"alipay"
:
"u"
},
"client"
:
{
"Vue"
:
{
"vue2"
:
"u"
,
"vue3"
:
"u"
},
"App"
:
{
"app-android"
:
"u"
,
"app-ios"
:
"u"
},
"H5-mobile"
:
{
"Safari"
:
"u"
,
"Android Browser"
:
"u"
,
"微信浏览器(Android)"
:
"u"
,
"QQ浏览器(Android)"
:
"u"
},
"H5-pc"
:
{
"Chrome"
:
"u"
,
"IE"
:
"u"
,
"Edge"
:
"u"
,
"Firefox"
:
"u"
,
"Safari"
:
"u"
},
"小程序"
:
{
"微信"
:
"u"
,
"阿里"
:
"u"
,
"百度"
:
"u"
,
"字节跳动"
:
"u"
,
"QQ"
:
"u"
,
"钉钉"
:
"u"
,
"快手"
:
"u"
,
"飞书"
:
"u"
,
"京东"
:
"u"
},
"快应用"
:
{
"华为"
:
"u"
,
"联盟"
:
"u"
}
}
}
}
}
\ No newline at end of file
uni_modules/uts-api-test/readme.md
0 → 100644
浏览文件 @
2fae914a
# uts-test
### 开发文档
[
UTS 语法
](
https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html
)
[
UTS API插件
](
https://uniapp.dcloud.net.cn/plugin/uts-plugin.html
)
[
UTS 组件插件
](
https://uniapp.dcloud.net.cn/plugin/uts-component.html
)
[
Hello UTS
](
https://gitcode.net/dcloud/hello-uts
)
\ No newline at end of file
uni_modules/uts-api-test/utssdk/app-android/config.json
0 → 100644
浏览文件 @
2fae914a
{
"minSdkVersion"
:
"21"
}
\ No newline at end of file
uni_modules/uts-api-test/utssdk/app-android/index.uts
0 → 100644
浏览文件 @
2fae914a
/* 引入 interface.uts 文件中定义的变量 */
import { GetLog } from '../interface.uts';
import File from 'java.io.File';
export const getLog : GetLog = function (param : Any|null) : string {
let allLog = console.getLogV2(param);
/**
* 移除掉干扰因素,仅返回打印对象本身的序列化结果
*/
if(!allLog.startsWith("---BEGIN:CONSOLE---")){
return ""
}
if(!allLog.endsWith("---END:CONSOLE---")){
return ""
}
let jsonLog = allLog
jsonLog = jsonLog.replace("---BEGIN:CONSOLE---", "")
jsonLog = jsonLog.replace("---END:CONSOLE---", "")
let jsonArrayObj = JSON.parse<UTSArray<UTSJSONObject>>(jsonLog)
return jsonArrayObj![0].toJSONString()
}
type ParamOptions = {
title : string,
array : Array<string>
}
class C {
name:string = "default"
sayBye = function(word:string){
console.log("sayBye",word)
}
sayHello(word:string){
console.log("sayHello",word)
}
}
export function logObjectTest():string{
let ret : ParamOptions = {
title: "logObjectTest",
array: ['1', '2', '3']
}
let typeLogRet = getLog(ret)
let typeLogObj = JSON.parseObject(typeLogRet)!
let typeLogObjPos = typeLogObj.getJSON("__$originalPosition")!
if("ParamOptions" != typeLogObjPos['name']){
return ""
}
/**
* 编译出来的位置信息可能有差异,排除单独验证后,排除掉这个字段
*/
typeLogObj.set("__$originalPosition","")
return typeLogObj.toJSONString()
}
export function logFunctionTest():string{
let testFun = function(){
console.log("testFun")
}
return getLog(testFun)
}
export function logFileTest():string{
return getLog(new File("/sdcard/temp/1.txt"))
}
export function logDateTest():string{
return getLog(new Date('1998-08-08'))
}
export function logClassTest():string{
let c = new C()
c.name="ccc"
let classLogRet = getLog(c)
let classLogObj = JSON.parseObject(classLogRet)!
let classLogObjPos = classLogObj.getJSON("__$originalPosition")!
if("C" != classLogObjPos['name']){
return ""
}
/**
* 编译出来的位置信息可能有差异,排除单独验证后,排除掉这个字段
*/
classLogObj.set("__$originalPosition","")
return classLogObj.toJSONString()
}
uni_modules/uts-api-test/utssdk/interface.uts
0 → 100644
浏览文件 @
2fae914a
/* 同步函数定义 */
export type GetLog = (logObject : Any|null) => string
\ No newline at end of file
uni_modules/uts-api-test/utssdk/unierror.uts
0 → 100644
浏览文件 @
2fae914a
/* 此规范为 uni 规范,可以按照自己的需要选择是否实现 */
/**
* 错误主题
* 注意:错误主题一般为插件名称,每个组件不同,需要使用时请更改。
* [可选实现]
*/
export const UniErrorSubject = 'uts-test';
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录