Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
8e06b571
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看板
提交
8e06b571
编写于
4月 30, 2024
作者:
dcloud_wdl
浏览文件
操作
浏览文件
下载
差异文件
[转正] git merge origin/alpha
上级
207468c5
109f5d58
变更
28
隐藏空白更改
内联
并排
Showing
28 changed file
with
578 addition
and
96 deletion
+578
-96
changelog.md
changelog.md
+6
-6
manifest.json
manifest.json
+1
-0
package.json
package.json
+4
-4
pages/SDKIntegration/SDKIntegration.uvue
pages/SDKIntegration/SDKIntegration.uvue
+3
-4
pages/SyntaxCase/consoleTest.uvue
pages/SyntaxCase/consoleTest.uvue
+3
-6
pages/SyntaxCase/consoleTest.vue
pages/SyntaxCase/consoleTest.vue
+5
-1
pages/SyntaxCase/utsAndroid.uvue
pages/SyntaxCase/utsAndroid.uvue
+4
-0
pages/SyntaxCase/utsiOS.uvue
pages/SyntaxCase/utsiOS.uvue
+163
-0
pages/index/basicTest.test.js
pages/index/basicTest.test.js
+34
-25
pages/index/basicTest.uvue
pages/index/basicTest.uvue
+23
-8
uni_modules/uts-api-test/utssdk/app-android/index.uts
uni_modules/uts-api-test/utssdk/app-android/index.uts
+44
-1
uni_modules/uts-ios-tests/changelog.md
uni_modules/uts-ios-tests/changelog.md
+0
-0
uni_modules/uts-ios-tests/package.json
uni_modules/uts-ios-tests/package.json
+82
-0
uni_modules/uts-ios-tests/readme.md
uni_modules/uts-ios-tests/readme.md
+6
-0
uni_modules/uts-ios-tests/utssdk/app-js/index.uts
uni_modules/uts-ios-tests/utssdk/app-js/index.uts
+9
-0
uni_modules/uts-ios-tests/utssdk/interface.uts
uni_modules/uts-ios-tests/utssdk/interface.uts
+3
-0
uni_modules/uts-nativepage/utssdk/app-android/AndroidManifest.xml
...les/uts-nativepage/utssdk/app-android/AndroidManifest.xml
+13
-0
uni_modules/uts-nativepage/utssdk/app-android/CustomAccessibilityService.uts
...ivepage/utssdk/app-android/CustomAccessibilityService.uts
+31
-0
uni_modules/uts-nativepage/utssdk/app-android/index.uts
uni_modules/uts-nativepage/utssdk/app-android/index.uts
+23
-1
uni_modules/uts-nativepage/utssdk/app-android/res/layout/demo_activity.xml
...ativepage/utssdk/app-android/res/layout/demo_activity.xml
+1
-0
uni_modules/uts-nativepage/utssdk/app-android/res/values/strings.xml
.../uts-nativepage/utssdk/app-android/res/values/strings.xml
+1
-0
uni_modules/uts-nativepage/utssdk/app-android/res/xml/custom_accessibility_service_config.xml
...p-android/res/xml/custom_accessibility_service_config.xml
+10
-0
uni_modules/uts-tests/utssdk/Date.uts
uni_modules/uts-tests/utssdk/Date.uts
+21
-2
uni_modules/uts-tests/utssdk/ForLoop.uts
uni_modules/uts-tests/utssdk/ForLoop.uts
+9
-9
uni_modules/uts-tests/utssdk/Math.uts
uni_modules/uts-tests/utssdk/Math.uts
+1
-1
uni_modules/uts-tests/utssdk/RegExp.uts
uni_modules/uts-tests/utssdk/RegExp.uts
+11
-0
uni_modules/uts-tests/utssdk/String.uts
uni_modules/uts-tests/utssdk/String.uts
+41
-21
uni_modules/uts-tests/utssdk/Type.uts
uni_modules/uts-tests/utssdk/Type.uts
+26
-7
未找到文件。
changelog.md
浏览文件 @
8e06b571
## 1.
1.4
## 1.
0.11
*
update 4.
08.2024040123
*
update 4.
14.2024042905-alpha
## 1.
1.3
## 1.
0.10
*
update 4.
07.2024032720
*
update 4.
13.2024042321-alpha
## 1.
1.2
## 1.
0.9
*
update 4.
06.2024032513
*
update 4.
12.2024041009-alpha
## 1.0.8
## 1.0.8
*
update 4.06.2024032403-alpha
*
update 4.06.2024032403-alpha
...
...
manifest.json
浏览文件 @
8e06b571
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
"versionName"
:
"1.0.9"
,
"versionName"
:
"1.0.9"
,
"versionCode"
:
"109"
,
"versionCode"
:
"109"
,
"transformPx"
:
false
,
"transformPx"
:
false
,
"uni-app-x"
:
{},
/*
5
+App特有相关
*/
/*
5
+App特有相关
*/
"app-plus"
:
{
"app-plus"
:
{
"usingComponents"
:
true
,
"usingComponents"
:
true
,
...
...
package.json
浏览文件 @
8e06b571
{
{
"id"
:
"hello-uts"
,
"id"
:
"hello-uts
-alpha
"
,
"name"
:
"hello-uts"
,
"name"
:
"hello-uts
-alpha
"
,
"displayName"
:
"hello-uts"
,
"displayName"
:
"hello-uts
-alpha
"
,
"version"
:
"1.
1.4
"
,
"version"
:
"1.
0.11
"
,
"description"
:
"UTS插件示例项目"
,
"description"
:
"UTS插件示例项目"
,
"repository"
:
"https://gitcode.net/dcloud/hello-uts"
,
"repository"
:
"https://gitcode.net/dcloud/hello-uts"
,
"keywords"
:
[
"keywords"
:
[
...
...
pages/SDKIntegration/SDKIntegration.uvue
浏览文件 @
8e06b571
<template>
<template>
<view class="uni-container">
<view class="uni-container">
<page-head :title="title"></page-head>
<page-head :title="title"></page-head>
<view class="uni-panel" v-for="(item, index) in list" :key="index">
<view class="uni-panel" v-for="(item, index) in list" :key="index">
<view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="goDetailPage(item)"
<view class="uni-panel-h" :class="item.open
== true
? 'uni-panel-h-on' : ''" @click="goDetailPage(item)"
hover-class="uni-navigate-item-active">
hover-class="uni-navigate-item-active">
<text class="uni-panel-text">{{item.name}}</text>
<text class="uni-panel-text">{{item.name}}</text>
<image :src="arrowRightIcon" class="uni-icon"></image>
<image :src="arrowRightIcon" class="uni-icon"></image>
...
@@ -22,7 +21,7 @@
...
@@ -22,7 +21,7 @@
type ListItem = {
type ListItem = {
name : string,
name : string,
open : boolean,
open
?
: boolean,
function ?: string,
function ?: string,
url ?: string
url ?: string
}
}
...
@@ -34,7 +33,7 @@
...
@@ -34,7 +33,7 @@
list: [{
list: [{
name: "腾讯定位sdk集成示例",
name: "腾讯定位sdk集成示例",
function: "gotoTencentLocation"
function: "gotoTencentLocation"
,
},
},
{
{
name: "Toast示例",
name: "Toast示例",
...
...
pages/SyntaxCase/consoleTest.uvue
浏览文件 @
8e06b571
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
<script>
<script>
import { getLog,logObjectTest,logClassTest,logFunctionTest,logFileTest,logDateTest } from '../../uni_modules/uts-api-test'
import { getLog,logObjectTest,logClassTest,logFunctionTest,logFileTest,logDateTest
,logUTSJSONObjectTest
} from '../../uni_modules/uts-api-test'
export default {
export default {
...
@@ -29,8 +29,7 @@
...
@@ -29,8 +29,7 @@
this.testRet = "测试失败"
this.testRet = "测试失败"
return;
return;
}
}
if(getLog(2023) != '{"subType":"number","type":"number","value":"2023"}'){
if(getLog(2023) != '{"type":"number","value":"2023"}'){
this.testRet = "测试失败"
this.testRet = "测试失败"
return;
return;
}
}
...
@@ -39,13 +38,11 @@
...
@@ -39,13 +38,11 @@
// this.testRet = "测试失败"
// this.testRet = "测试失败"
// return;
// return;
// }
// }
if(getLog(2023.002 as number) != '{"subType":"number","type":"number","value":"2023.002"}'){
if(getLog(2023.002) != '{"type":"number","value":"2023.002"}'){
this.testRet = "测试失败"
this.testRet = "测试失败"
return;
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"}]}}'){
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 = "测试失败"
this.testRet = "测试失败"
return;
return;
...
...
pages/SyntaxCase/consoleTest.vue
浏览文件 @
8e06b571
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
<
script
>
<
script
>
import
{
getLog
,
logObjectTest
,
logClassTest
,
logFunctionTest
,
logFileTest
,
logDateTest
}
from
'
../../uni_modules/uts-api-test
'
import
{
getLog
,
logObjectTest
,
logClassTest
,
logFunctionTest
,
logFileTest
,
logDateTest
,
frequentlyObjectTest
}
from
'
../../uni_modules/uts-api-test
'
export
default
{
export
default
{
...
@@ -69,6 +69,10 @@
...
@@ -69,6 +69,10 @@
return
;
return
;
}
}
if
(
!
frequentlyObjectTest
()){
this
.
testRet
=
"
测试失败
"
return
;
}
this
.
testRet
=
"
测试完成
"
this
.
testRet
=
"
测试完成
"
}
}
...
...
pages/SyntaxCase/utsAndroid.uvue
浏览文件 @
8e06b571
<template>
<template>
<!-- #ifdef APP-ANDROID -->
<!-- #ifdef APP -->
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<scroll-view style="flex: 1">
<!-- #endif -->
<!-- #endif -->
...
@@ -45,9 +46,11 @@
...
@@ -45,9 +46,11 @@
<!-- #ifdef APP -->
<!-- #ifdef APP -->
</scroll-view>
</scroll-view>
<!-- #endif -->
<!-- #endif -->
<!-- #endif -->
</template>
</template>
<script>
<script>
<!-- #ifdef APP-ANDROID -->
import {
import {
getAppContextTest,
getAppContextTest,
getUniActivityTest,
getUniActivityTest,
...
@@ -257,6 +260,7 @@ export default {
...
@@ -257,6 +260,7 @@ export default {
},
},
},
},
}
}
<!-- #endif -->
</script>
</script>
<style>
<style>
...
...
pages/SyntaxCase/utsiOS.uvue
浏览文件 @
8e06b571
<template>
<template>
<!-- #ifdef APP-IOS -->
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<button @click="testCurrentVC">获取当前UIViewController</button>
<view class="result" :style="resultStyle(currentVCResult.passed)"> 测试结果 -- {{formatResult(currentVCResult.passed)}}</view>
<button @click="testKeyWindow">获取当前app的keyWindow</button>
<view class="result" :style="resultStyle(keyWindowResult.passed)"> 测试结果 -- {{formatResult(keyWindowResult.passed)}}</view>
<button @click="testColorConvert">将字符串色值转换为UIColor</button>
<view class="result">
<p v-for="item in colorConvertResult" :style="resultStyle(item.passed)"> {{item.key}}: {{item.value}} -- {{formatResult(item.passed)}}</p>
</view>
<button @click="testResourcePath">资源路径转换</button>
<view class="result" :style="resultStyle(resourcePathResult.passed)"> {{resourcePathResult.key}}: {{resourcePathResult.value}} -- {{formatResult(resourcePathResult.passed)}}</view>
<button @click="testDeviceInfo">获取设备信息</button>
<view class="result">
<p v-for="item in deviceInfoResult" :style="resultStyle(item.passed)"> {{item.key}}: {{item.value}} -- {{formatResult(item.passed)}}</p>
</view>
<button @click="testAppInfo">获取App信息相关api</button>
<view class="result">
<p v-for="item in appInfoResult" :style="resultStyle(item.passed)"> {{item.key}}: {{item.value}} -- {{formatResult(item.passed)}}</p>
</view>
<button @click="testSystemSetting">获取系统设置</button>
<view class="result" :style="resultStyle(systemSettingResult.passed)"> {{systemSettingResult.key}}: {{systemSettingResult.value}} -- {{formatResult(systemSettingResult.passed)}}</view>
<button @click="testTypeof">typeof</button>
<view class="result">
<p v-for="item in typeofResult" :style="resultStyle(item.passed)"> {{item.key}}: {{item.value}} -- {{formatResult(item.passed)}}</p>
</view>
<button @click="testDataConvert">数据转换</button>
<view class="result">
<p v-for="item in dataConvertResult" :style="resultStyle(item.passed)"> {{item.key}}: {{item.value}} -- {{formatResult(item.passed)}}</p>
</view>
<button @click="testAll">test all</button>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
<!-- #endif -->
</template>
</template>
<script>
<script>
<!-- #ifdef APP-IOS -->
import {
getCurrentVCTest,
getKeyWindowTest,
colorWithStringTest,
getResourcePathTest,
getDeviceInfoTest,
getAppInfoTest,
getSystemSettingTest,
tepeofTest,
dataConvertTest,
} from "@/uni_modules/uts-platform-api"
export default {
data() {
return {
title: "UTSiOS test",
currentVCResult: {},
keyWindowResult: {},
colorConvertResult: [],
resourcePathResult: {},
deviceInfoResult: [],
appInfoResult: [],
systemSettingResult: {},
typeofResult: [],
dataConvertResult: []
}
},
methods: {
formatResult(res) {
if (res == null) {
return "";
}
return res ? "测试通过": "测试失败"
},
resultStyle(res) {
if (res == null) {
return {
color: "#333333"
}
}
let color = res ? "#00ff00" : "#ff0000";
return {
color: color
}
},
testCurrentVC() {
this.currentVCResult = getCurrentVCTest();
},
testKeyWindow() {
this.keyWindowResult = getKeyWindowTest();
},
testColorConvert() {
let array = colorWithStringTest();
this.colorConvertResult = array.map((value) => {
return JSON.parse(value)
})
},
testResourcePath() {
this.resourcePathResult = getResourcePathTest("/static/logo.png");
},
testDeviceInfo() {
let array = getDeviceInfoTest();
this.deviceInfoResult = array.map((value) => {
return JSON.parse(value)
})
},
testAppInfo() {
let array = getAppInfoTest();
this.appInfoResult = array.map((value) => {
return JSON.parse(value)
})
},
testSystemSetting() {
this.systemSettingResult = getSystemSettingTest();
},
testTypeof() {
let array = tepeofTest();
this.typeofResult = array.map((value) => {
return JSON.parse(value)
})
},
testDataConvert() {
let array = dataConvertTest();
this.dataConvertResult = array.map((value) => {
return JSON.parse(value)
})
},
testAll() {
this.testCurrentVC();
this.testKeyWindow();
this.testColorConvert();
this.testResourcePath();
this.testDeviceInfo();
this.testAppInfo();
this.testSystemSetting();
this.testTypeof();
this.testDataConvert();
}
}
}
<!-- #endif -->
</script>
</script>
<style>
<style>
.result {
text-align: left;
padding-left: 20px;
padding-right: 20px;
max-width: 100%;
overflow: auto;
overflow-wrap: normal;
}
</style>
</style>
\ No newline at end of file
pages/index/basicTest.test.js
浏览文件 @
8e06b571
...
@@ -3,35 +3,44 @@ const ERR_RE = /expected:<(.*)> but was:<(.*)>/
...
@@ -3,35 +3,44 @@ const ERR_RE = /expected:<(.*)> but was:<(.*)>/
let
result
;
let
result
;
beforeAll
(
async
()
=>
{
beforeAll
(
async
()
=>
{
await
program
.
reLaunch
(
'
/pages/index/basicTest
'
)
await
program
.
reLaunch
(
'
/pages/index/basicTest
'
)
page
=
await
program
.
currentPage
()
page
=
await
program
.
currentPage
()
await
page
.
waitFor
(
3000
);
await
page
.
waitFor
(
3000
);
const
data
=
await
page
.
data
();
const
data
=
await
page
.
data
();
result
=
data
[
'
result
'
]
result
=
data
[
'
result
'
]
})
})
function
getApiFailed
(
describe
,
api
)
{
function
getApiFailed
(
describe
,
api
)
{
const
failed
=
result
[
describe
]?.
failed
?.
find
(
item
=>
{
const
failed
=
result
[
describe
]?.
failed
?.
find
(
item
=>
{
return
item
.
split
(
'
:
'
)[
0
]
===
api
return
item
.
split
(
'
:
'
)[
0
]
===
api
})
})
return
failed
return
failed
}
}
describes
.
forEach
(
d
=>
{
describes
.
forEach
(
d
=>
{
d
?.
describe
&&
describe
(
d
.
describe
,
()
=>
{
d
?.
describe
&&
describe
(
d
.
describe
,
()
=>
{
d
?.
tests
&&
d
.
tests
.
forEach
(
api
=>
{
d
?.
tests
&&
d
.
tests
.
forEach
(
api
=>
{
it
(
api
,
()
=>
{
it
(
api
,
()
=>
{
const
failed
=
getApiFailed
(
d
.
describe
,
api
)
const
failed
=
getApiFailed
(
d
.
describe
,
api
)
if
(
failed
)
{
if
(
failed
)
{
const
parts
=
failed
.
split
(
'
\n
'
)
const
parts
=
failed
.
split
(
'
\n
'
)
const
matches
=
parts
[
1
].
match
(
ERR_RE
)
const
matches
=
parts
[
1
].
match
(
ERR_RE
)
if
(
matches
?.
length
)
{
if
(
matches
?.
length
)
{
expect
(
matches
[
2
]).
toEqual
(
matches
[
1
])
expect
(
matches
[
2
]).
toEqual
(
matches
[
1
])
}
else
{
}
else
{
expect
(
parts
[
1
]).
toEqual
(
''
)
expect
(
parts
[
1
]).
toEqual
(
''
)
}
}
}
}
})
})
})
})
})
})
})
})
if
(
process
.
env
.
UNI_PROJECT_TYPE
===
'
2.0
'
&&
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
().
startsWith
(
'
ios
'
))
{
describe
(
'
testTypeFromAppJs
'
,
()
=>
{
it
(
"
jest_testTypeFromAppJs
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
'
jest_testTypeFromAppJs
'
)
expect
(
res
).
toEqual
(
true
)
})
})
}
\ No newline at end of file
pages/index/basicTest.uvue
浏览文件 @
8e06b571
...
@@ -20,7 +20,10 @@
...
@@ -20,7 +20,10 @@
<!-- #endif -->
<!-- #endif -->
</template>
</template>
<script lang="ts">
<script lang="ts">
import { runTests, Result } from '../../uni_modules/uts-tests'
import { runTests, Result } from '../../uni_modules/uts-tests'
// #ifdef APP-IOS
import { testTypeFromAppJs, Options } from '@/uni_modules/uts-ios-tests'
// #endif
export default {
export default {
data() {
data() {
return {
return {
...
@@ -35,13 +38,25 @@ export default {
...
@@ -35,13 +38,25 @@ export default {
},
},
methods: {
methods: {
test() {
test() {
this.result = runTests()
this.result = runTests()
const resultMap = this.result.toMap()
// const resultMap = this.result.toMap()
resultMap.forEach((res, name) => {
// resultMap.forEach((res, name) => {
this.names.push(name)
// this.names.push(name)
this.resultArray.push(res as Result)
// this.resultArray.push(res as Result)
})
// })
},
const resultMap = this.result
for (const key in resultMap) {
this.names.push(key)
this.resultArray.push(resultMap[key] as Result)
}
},
// #ifdef APP-IOS
jest_testTypeFromAppJs() {
return testTypeFromAppJs({
num: 1
} as Options)
}
// #endif
},
},
}
}
</script>
</script>
...
...
uni_modules/uts-api-test/utssdk/app-android/index.uts
浏览文件 @
8e06b571
...
@@ -17,7 +17,7 @@ export const getLog : GetLog = function (param : Any|null) : string {
...
@@ -17,7 +17,7 @@ export const getLog : GetLog = function (param : Any|null) : string {
let jsonLog = allLog
let jsonLog = allLog
jsonLog = jsonLog.replace("---BEGIN:CONSOLE---", "")
jsonLog = jsonLog.replace("---BEGIN:CONSOLE---", "")
jsonLog = jsonLog.replace("---END:CONSOLE---", "")
jsonLog = jsonLog.replace("---END:CONSOLE---", "")
let jsonArrayObj = JSON.parse<
UTS
Array<UTSJSONObject>>(jsonLog)
let jsonArrayObj = JSON.parse<Array<UTSJSONObject>>(jsonLog)
return jsonArrayObj![0].toJSONString()
return jsonArrayObj![0].toJSONString()
}
}
...
@@ -36,6 +36,28 @@ class C {
...
@@ -36,6 +36,28 @@ class C {
}
}
}
}
/**
* 高频对象测试,主要是系统组件对象
*/
export function frequentlyObjectTest():boolean{
let typeLogRet = getLog(UTSAndroid.getUniActivity())
console.log(typeLogRet)
let typeLogObj = JSON.parseObject(typeLogRet)!
// let typeLogObjPos = typeLogObj.getJSON("__$originalPosition")!
// if("ParamOptions" != typeLogObjPos['name']){
// return false
// }
// /**
// * 编译出来的位置信息可能有差异,排除单独验证后,排除掉这个字段
// */
// typeLogObj.set("__$originalPosition","")
// console.log(typeLogObj.toJSONString())
return true
}
export function logObjectTest():string{
export function logObjectTest():string{
let ret : ParamOptions = {
let ret : ParamOptions = {
title: "logObjectTest",
title: "logObjectTest",
...
@@ -72,6 +94,27 @@ export function logDateTest():string{
...
@@ -72,6 +94,27 @@ export function logDateTest():string{
return getLog(new Date('1998-08-08'))
return getLog(new Date('1998-08-08'))
}
}
export function logUTSJSONObjectTest():string{
let classLogRet = getLog({a:1})
let classLogObj = JSON.parseObject(classLogRet)!
let classLogObjPos = classLogObj.getJSON("__$originalPosition")
if(classLogObjPos == null){
return ""
}
if("UTSJSONObject" != classLogObjPos['name']){
return ""
}
classLogObj.set("__$originalPosition","")
return classLogObj.toJSONString()
}
export function logClassTest():string{
export function logClassTest():string{
let c = new C()
let c = new C()
c.name="ccc"
c.name="ccc"
...
...
uni_modules/uts-ios-tests/changelog.md
0 → 100644
浏览文件 @
8e06b571
uni_modules/uts-ios-tests/package.json
0 → 100644
浏览文件 @
8e06b571
{
"id"
:
"uts-ios-tests"
,
"displayName"
:
"uts-ios-tests"
,
"version"
:
"1.0.0"
,
"description"
:
"uts-ios-tests"
,
"keywords"
:
[
"uts-ios-tests"
],
"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-ios-tests/readme.md
0 → 100644
浏览文件 @
8e06b571
# uts-ios-tests
### 开发文档
[
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-ios-tests/utssdk/app-js/index.uts
0 → 100644
浏览文件 @
8e06b571
import { Options } from '../interface.uts';
export function testTypeFromAppJs(options : Options) {
return options instanceof Options
}
export {
Options
}
\ No newline at end of file
uni_modules/uts-ios-tests/utssdk/interface.uts
0 → 100644
浏览文件 @
8e06b571
export type Options = {
num: number
}
\ No newline at end of file
uni_modules/uts-nativepage/utssdk/app-android/AndroidManifest.xml
浏览文件 @
8e06b571
...
@@ -5,6 +5,19 @@
...
@@ -5,6 +5,19 @@
<uses-permission
android:name=
"android.permission.FOREGROUND_SERVICE"
/>
<uses-permission
android:name=
"android.permission.FOREGROUND_SERVICE"
/>
<application>
<application>
<service
android:name=
"uts.sdk.modules.utsNativepage.CustomAccessibilityService"
android:enabled=
"true"
android:exported=
"true"
android:permission=
"android.permission.BIND_ACCESSIBILITY_SERVICE"
>
<intent-filter>
<action
android:name=
"android.accessibilityservice.AccessibilityService"
/>
</intent-filter>
<meta-data
android:name=
"android.accessibilityservice"
android:resource=
"@xml/custom_accessibility_service_config"
/>
</service>
<service
android:name=
"uts.sdk.modules.utsNativepage.ForeService"
/>
<service
android:name=
"uts.sdk.modules.utsNativepage.ForeService"
/>
<activity
android:name=
"uts.sdk.modules.utsNativepage.DemoActivity"
></activity>
<activity
android:name=
"uts.sdk.modules.utsNativepage.DemoActivity"
></activity>
<!--桌面widget组件注册-->
<!--桌面widget组件注册-->
...
...
uni_modules/uts-nativepage/utssdk/app-android/CustomAccessibilityService.uts
0 → 100644
浏览文件 @
8e06b571
import AccessibilityService from 'android.accessibilityservice.AccessibilityService'
import AccessibilityEvent from 'android.view.accessibility.AccessibilityEvent'
export class CustomAccessibilityService extends AccessibilityService {
constructor (){
super();
}
override onInterrupt():void {
console.log("onInterrupt");
}
override onAccessibilityEvent(event:AccessibilityEvent ):void {
if(event == null){
return ;
}
console.log("packagename",event!.getPackageName())
if("io.dcloud.uniappx" == event!.getPackageName()){
console.log("辅助服务消息:uniappx 基座打开")
}else if("io.dcloud.HBuilder" == event!.getPackageName()){
console.log("辅助服务消息:HBuilder 基座被打开")
}
}
}
uni_modules/uts-nativepage/utssdk/app-android/index.uts
浏览文件 @
8e06b571
...
@@ -29,7 +29,7 @@ export {DoAppWidget} from "./DoAppWidget.uts"
...
@@ -29,7 +29,7 @@ export {DoAppWidget} from "./DoAppWidget.uts"
import Application from 'android.app.Application';
import Application from 'android.app.Application';
import File from 'java.io.File';
import File from 'java.io.File';
import Uri from 'android.net.Uri';
import Uri from 'android.net.Uri';
export * from './CustomAccessibilityService.uts'
export class AppHookProxy implements UTSAndroidHookProxy {
export class AppHookProxy implements UTSAndroidHookProxy {
override onCreate(application: Application) {
override onCreate(application: Application) {
...
@@ -200,6 +200,25 @@ class RootActivityStartListener extends OnClickListener{
...
@@ -200,6 +200,25 @@ class RootActivityStartListener extends OnClickListener{
}
}
}
}
class RootPageStartListener extends OnClickListener{
host:Activity
constructor(activity:Activity){
super()
this.host = activity
}
override onClick(v?: View):void{
let packageName = UTSAndroid.getAppContext()!.getPackageName()
console.log("packageName",packageName)
console.log("host",this.host)
let intent = host.getPackageManager().getLaunchIntentForPackage(packageName)
intent?.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
host.startActivity(intent)
}
}
/**
/**
* 自定义异步线程
* 自定义异步线程
*/
*/
...
@@ -281,6 +300,9 @@ class DemoActivity extends Activity{
...
@@ -281,6 +300,9 @@ class DemoActivity extends Activity{
let btn_start_root_activity = this.findViewById<Button>(R.id.btn_start_root_activity);
let btn_start_root_activity = this.findViewById<Button>(R.id.btn_start_root_activity);
btn_start_root_activity.setOnClickListener(new RootActivityStartListener(this));
btn_start_root_activity.setOnClickListener(new RootActivityStartListener(this));
let btn_start_root_page = this.findViewById<Button>(R.id.btn_start_root_page);
btn_start_root_page.setOnClickListener(new RootPageStartListener(this));
let recyclerView = this.findViewById<RecyclerView>(R.id.recycler_view)
let recyclerView = this.findViewById<RecyclerView>(R.id.recycler_view)
let layoutManager = new LinearLayoutManager(this);
let layoutManager = new LinearLayoutManager(this);
...
...
uni_modules/uts-nativepage/utssdk/app-android/res/layout/demo_activity.xml
浏览文件 @
8e06b571
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"开启异步任务"
android:id=
"@+id/btn_start_thread"
/>
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"开启异步任务"
android:id=
"@+id/btn_start_thread"
/>
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"关闭当前activity"
android:id=
"@+id/btn_finish_activity"
/>
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"关闭当前activity"
android:id=
"@+id/btn_finish_activity"
/>
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"打开应用根目录activity"
android:id=
"@+id/btn_start_root_activity"
/>
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"打开应用根目录activity"
android:id=
"@+id/btn_start_root_activity"
/>
<Button
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"打开应用首页"
android:id=
"@+id/btn_start_root_page"
/>
<androidx.recyclerview.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
...
...
uni_modules/uts-nativepage/utssdk/app-android/res/values/strings.xml
浏览文件 @
8e06b571
...
@@ -12,4 +12,5 @@
...
@@ -12,4 +12,5 @@
<string
name=
"dcloud_ad_notification_delete_download"
>
Delete
</string>
<string
name=
"dcloud_ad_notification_delete_download"
>
Delete
</string>
<string
name=
"dcloud_ad_tag_ads"
>
Ads
</string>
<string
name=
"dcloud_ad_tag_ads"
>
Ads
</string>
<string
name=
"app_widget_description"
>
This is an app widget description
</string>
<string
name=
"app_widget_description"
>
This is an app widget description
</string>
<string
name=
"demo_service_name"
>
uniappx 测试辅助服务
</string>
</resources>
</resources>
\ No newline at end of file
uni_modules/uts-nativepage/utssdk/app-android/res/xml/custom_accessibility_service_config.xml
0 → 100644
浏览文件 @
8e06b571
<?xml version="1.0" encoding="utf-8"?>
<accessibility-service
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:description=
"@string/demo_service_name"
android:accessibilityEventTypes=
"typeNotificationStateChanged|typeWindowStateChanged"
android:packageNames=
"io.dcloud.uniappx,io.dcloud.HBuilder"
android:accessibilityFeedbackType=
"feedbackGeneric"
android:notificationTimeout=
"100"
android:accessibilityFlags=
"flagDefault"
android:canRetrieveWindowContent=
"true"
/>
\ No newline at end of file
uni_modules/uts-tests/utssdk/Date.uts
浏览文件 @
8e06b571
...
@@ -16,7 +16,7 @@ export function testDate() : Result {
...
@@ -16,7 +16,7 @@ export function testDate() : Result {
expect(date1.getTime()).toEqual(696988800000);
expect(date1.getTime()).toEqual(696988800000);
let date2 = new Date('1992-2-02');
let date2 = new Date('1992-2-02');
console.log("2222",date2.getTime())
console.log("2222",date2.getTime())
expect(date2.getTime()).toEqual(696960000000);
//
expect(date2.getTime()).toEqual(696960000000);
})
})
test('valueOf', () => {
test('valueOf', () => {
...
@@ -44,7 +44,26 @@ export function testDate() : Result {
...
@@ -44,7 +44,26 @@ export function testDate() : Result {
// expect(date1.toTimeString()).toEqual("08:00:00 GMT+0800");
// expect(date1.toTimeString()).toEqual("08:00:00 GMT+0800");
// expect(date2.toTimeString()).toEqual("03:24:00 GMT+0800");
// expect(date2.toTimeString()).toEqual("03:24:00 GMT+0800");
// // #endif
// // #endif
})
})
test('toXString', () => {
// #ifdef APP-ANDROID
const event = new Date('1995-12-17T03:24:00');
expect(event.toString()).toEqual("Sun Dec 17 1995 03:24:00 GMT+0800");
expect(event.toTimeString()).toEqual("03:24:00 GMT+0800");
expect(event.toISOString()).toEqual("1995-12-16T19:24:00.000Z");
expect(event.toJSON()).toEqual("1995-12-16T19:24:00.000Z");
expect(event.toDateString()).toEqual("Sun Dec 17 1995");
const event2 = new Date('2014-01-09 22:00:00');
expect(event2.toString()).toEqual("Thu Jan 09 2014 22:00:00 GMT+0800");
expect(event2.toTimeString()).toEqual("22:00:00 GMT+0800");
expect(event2.toISOString()).toEqual("2014-01-09T14:00:00.000Z");
expect(event2.toJSON()).toEqual("2014-01-09T14:00:00.000Z");
expect(event2.toDateString()).toEqual("Thu Jan 09 2014");
// #endif
})
test('getDate', () => {
test('getDate', () => {
const birthday = new Date('August 19, 1975 23:15:30');
const birthday = new Date('August 19, 1975 23:15:30');
...
...
uni_modules/uts-tests/utssdk/ForLoop.uts
浏览文件 @
8e06b571
...
@@ -288,15 +288,15 @@ export function testForLoop(): Result {
...
@@ -288,15 +288,15 @@ export function testForLoop(): Result {
}
}
result5.push(str + ' (End of Outer)')
result5.push(str + ' (End of Outer)')
}
}
expect(result5).toEqual([
//
expect(result5).toEqual([
'1: ODD - 1',
//
'1: ODD - 1',
'1: ODD - 1 (Inner Continue) - 3',
//
'1: ODD - 1 (Inner Continue) - 3',
'1: ODD - 1 (Inner Continue) - 3 (End of Outer)',
//
'1: ODD - 1 (Inner Continue) - 3 (End of Outer)',
'2: EVEN - 1',
//
'2: EVEN - 1',
'2: EVEN - 1 (Inner Continue) - 3',
//
'2: EVEN - 1 (Inner Continue) - 3',
'2: EVEN - 1 (Inner Continue) - 3 (End of Outer)',
//
'2: EVEN - 1 (Inner Continue) - 3 (End of Outer)',
'3: ODD (Loop Break)'
//
'3: ODD (Loop Break)'
])
//
])
})
})
})
})
}
}
uni_modules/uts-tests/utssdk/Math.uts
浏览文件 @
8e06b571
...
@@ -223,7 +223,7 @@ export function testMath(): Result {
...
@@ -223,7 +223,7 @@ export function testMath(): Result {
test('tan', () => {
test('tan', () => {
// 解决精度问题
// 解决精度问题
expect(Math.tan(0)).toEqual(0.0);
expect(Math.tan(0)).toEqual(0.0);
expect(Math.tan(1)).toEqual(1.5574077246549023);
//
expect(Math.tan(1)).toEqual(1.5574077246549023);
})
})
test('tanh', () => {
test('tanh', () => {
expect(Math.tanh(-1)).toEqual(-0.7615941559557649);
expect(Math.tanh(-1)).toEqual(-0.7615941559557649);
...
...
uni_modules/uts-tests/utssdk/RegExp.uts
浏览文件 @
8e06b571
...
@@ -231,6 +231,17 @@ export function testRegExp(): Result {
...
@@ -231,6 +231,17 @@ export function testRegExp(): Result {
const pattern10 = /(?<!@)\w+/;
const pattern10 = /(?<!@)\w+/;
const result10 = pattern10.exec('Username: john')!;
const result10 = pattern10.exec('Username: john')!;
expect(result10[0]).toEqual('Username');
expect(result10[0]).toEqual('Username');
const CHUNK_REGEXP =
/^(\S*)?\s*(\d*\.?\d+(?:ms|s)?)?\s*(\S*)?\s*(\d*\.?\d+(?:ms|s)?)?$/
const match2 = CHUNK_REGEXP.exec('none')
expect(match2![0]).toEqual("none");
expect(match2![1]).toEqual("none");
// expect(JSON.stringify(match2![2])).toEqual("null");
// expect(JSON.stringify(match2![3])).toEqual("null");
// expect(JSON.stringify(match2![4])).toEqual("null");
})
})
})
})
}
}
uni_modules/uts-tests/utssdk/String.uts
浏览文件 @
8e06b571
...
@@ -112,27 +112,39 @@ export function testString(): Result {
...
@@ -112,27 +112,39 @@ export function testString(): Result {
expect("".indexOf("test")).toEqual(-1);
expect("".indexOf("test")).toEqual(-1);
})
})
// test('match', () => {
test('match', () => {
// const str = 'The quick brown fox jumps over the lazy dog. It barked.';
const str = 'The quick brown fox jumps over the lazy dog. It barked.';
// const result = str.match(new RegExp('[A-Z]', 'g'));
const result = str.match(new RegExp('[A-Z]', 'g'));
// expect(result).toEqual(["T", "I"]);
// expect(result!.length).toEqual(2);
expect(result![0]).toEqual("T");
// const str1 = 'For more information, see Chapter 3.4.5.1';
expect(result![1]).toEqual("I");
// const result1 = str1.match(/see (chapter \d+(\.\d)*)/i);
// expect(result1[0]).toEqual("see Chapter 3.4.5.1");
const result2 = str.match(new RegExp('[A-Z]'));
// expect(result1[1]).toEqual("Chapter 3.4.5.1");
// expect(result2!.length).toEqual(1);
// expect(result1[2]).toEqual(".1");
expect(result2![0]).toEqual("T");
// expect(result1.index).toEqual(22);
// expect(result1.input).toEqual(str1);
const gradientString = 'linear-gradient(to right, rgb(255, 0, 0), #00FF00, hsl(120, 100%, 50%))';
const pattern = /rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)|#([a-fA-F0-9]{2}){3}|hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)/g;
// const str2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
const result3 = gradientString.match(pattern);
// const result2 = str2.match(/[A-E]/gi);
// expect(result3!.length).toEqual(3);
// expect(result2).toEqual(['A', 'B', 'C', 'D', 'E', 'a', 'b', 'c', 'd', 'e']);
// expect(result3![0]).toEqual("rgb(255, 0, 0)");
// expect(result3![2]).toEqual("hsl(120, 100%, 50%)");
// const str3 = 'Nothing will come of nothing.';
// const result3 = str3.match();
const pattern2 = /rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)|#([a-fA-F0-9]{2}){3}|hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)/;
// expect(result3).toEqual([""]);
const result4 = gradientString.match(pattern2);
// })
// expect(result4!.length).toEqual(8);
// expect(result4![0]).toEqual("rgb(255, 0, 0)");
// expect(result4![1]).toEqual("255");
// expect(result4![2]).toEqual("0");
const url = '';
const urlRegex = /^(\w+):\/\/([^\/?#]+)([^?#]*)(\?[^#]*)?(#.*)?$/;
const match = url.match(urlRegex);
// expect(JSON.stringify(match)).toEqual("null");
})
test('padEnd', () => {
test('padEnd', () => {
const str1 = 'Breaded Mushrooms';
const str1 = 'Breaded Mushrooms';
expect(str1.padEnd(25, '.')).toEqual("Breaded Mushrooms........");
expect(str1.padEnd(25, '.')).toEqual("Breaded Mushrooms........");
...
@@ -176,6 +188,14 @@ export function testString(): Result {
...
@@ -176,6 +188,14 @@ export function testString(): Result {
expect(string).toEqual(str);
expect(string).toEqual(str);
return p.join(' - ');
return p.join(' - ');
}
}
// const REGEX_FORMAT = /[YMDHhms]o|\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|SSS/g
// const formatStr = 'This is a [sample] text with [another] capture group.'
// const nextStr = formatStr.replace(REGEX_FORMAT, (match:string, p1: string|null, offset: number, string: string):string =>{
// console.log('123', p1, match)
// return p1 ?? match ?? ''
// })
// expect(nextStr).toEqual('This is a sample text with another capture group.');
// var newString = str.replace(/([^\d]*)(\d*)([^\w]*)/, replacer);
// var newString = str.replace(/([^\d]*)(\d*)([^\w]*)/, replacer);
// expect(newString).toEqual("abc - 12345 - #$*%");
// expect(newString).toEqual("abc - 12345 - #$*%");
// const str1 = 'hello, world';
// const str1 = 'hello, world';
...
...
uni_modules/uts-tests/utssdk/Type.uts
浏览文件 @
8e06b571
...
@@ -4,24 +4,24 @@ export function testType() : Result {
...
@@ -4,24 +4,24 @@ export function testType() : Result {
return describe("Type", () => {
return describe("Type", () => {
test("Object literal to type instance", () => {
test("Object literal to type instance", () => {
type Person = {
type Person = {
age: number
age
: number
}
}
const a: Person = {
const a
: Person = {
age: 1
age: 1
}
}
const b = {
const b = {
age: 2
age: 2
} as Person
} as Person
expect(a instanceof Person).toEqual(true);
expect(a instanceof Person).toEqual(true);
expect(b instanceof Person).toEqual(true);
expect(b instanceof Person).toEqual(true);
})
})
test("Type with any[]", () => {
test("Type with any[]", () => {
type Person = {
type Person = {
age: number,
age
: number,
friends: any[]
friends
: any[]
}
}
const a: Person = {
const a
: Person = {
age: 1,
age: 1,
friends: ['b']
friends: ['b']
}
}
...
@@ -29,9 +29,28 @@ export function testType() : Result {
...
@@ -29,9 +29,28 @@ export function testType() : Result {
age: 2,
age: 2,
friends: ['a']
friends: ['a']
} as Person
} as Person
expect(a instanceof Person).toEqual(true);
expect(a instanceof Person).toEqual(true);
expect(b instanceof Person).toEqual(true);
expect(b instanceof Person).toEqual(true);
})
})
test("destructure default value should override null", () => {
type Options = {
name : string
age ?: number
gender ?: number
}
const options = {
name: 'Tom'
} as Options
const {
name = 'testName',
age = 20,
gender
} = options;
expect(name).toEqual('Tom');
expect(age).toEqual(20);
expect(gender).toEqual(null);
})
})
})
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录