提交 a912f940 编写于 作者: 杜庆泉's avatar 杜庆泉

Merge branch 'dev' of gitcode.net:dcloud/hello-uts into dev

<template> <template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view> <view>
<button @click="testUtsSync">点击测试uts同步方法</button> <button @click="testUtsSync">点击测试uts同步方法</button>
<view>测试return: <view
>测试return:
{{ format(testUtsSyncResult) }} {{ format(testUtsSyncResult) }}
</view> </view>
<button @click="testUtsSyncWithCallback"> <button @click="testUtsSyncWithCallback">
点击测试uts带callback的同步方法 点击测试uts带callback的同步方法
</button> </button>
<view>测试return:{{ format(testUtsSyncWithCallbackResult.return) }}</view> <view
<view>测试success:{{ format(testUtsSyncWithCallbackResult.success) }}</view> >测试return:{{ format(testUtsSyncWithCallbackResult.return) }}</view
<view>测试complete:{{ format(testUtsSyncWithCallbackResult.complete) }}</view> >
<view
>测试success:{{ format(testUtsSyncWithCallbackResult.success) }}</view
>
<view
>测试complete:{{
format(testUtsSyncWithCallbackResult.complete)
}}</view
>
<!-- <button @click="testUtsAsync">点击测试uts异步方法</button> <!-- <button @click="testUtsAsync">点击测试uts异步方法</button>
<view>测试return:{{ format(testUtsAsyncResult.return) }}</view> <view>测试return:{{ format(testUtsAsyncResult.return) }}</view>
<view>测试success:{{ format(testUtsAsyncResult.success) }}</view> <view>测试success:{{ format(testUtsAsyncResult.success) }}</view>
<view>测试complete:{{ format(testUtsAsyncResult.complete) }}</view> --> <view>测试complete:{{ format(testUtsAsyncResult.complete) }}</view> -->
<button @click="testUtsClassConstructor">点击测试uts class构造函数</button> <button @click="testUtsClassConstructor">
<view>测试callback:{{ format(testUtsClassConstructorResult.callback) }}</view> 点击测试uts class构造函数
</button>
<view
>测试callback:{{
format(testUtsClassConstructorResult.callback)
}}</view
>
<button @click="testUtsClassStaticProp">点击测试uts class静态属性</button> <button @click="testUtsClassStaticProp">点击测试uts class静态属性</button>
<view>测试value:{{ format(testUtsClassStaticPropResult) }}</view> <view>测试value:{{ format(testUtsClassStaticPropResult) }}</view>
<button @click="testUtsClassStaticSyncWithCallback"> <button @click="testUtsClassStaticSyncWithCallback">
点击测试uts class静态方法 点击测试uts class静态方法
</button> </button>
<view>测试return:{{ format(testUtsClassStaticSyncWithCallbackResult.return) }}</view> <view
<view>测试success:{{ format(testUtsClassStaticSyncWithCallbackResult.success) }}</view> >测试return:{{
<view>测试complete:{{ format(testUtsClassStaticSyncWithCallbackResult.complete) }}</view> format(testUtsClassStaticSyncWithCallbackResult.return)
}}</view
>
<view
>测试success:{{
format(testUtsClassStaticSyncWithCallbackResult.success)
}}</view
>
<view
>测试complete:{{
format(testUtsClassStaticSyncWithCallbackResult.complete)
}}</view
>
<!-- <button @click="testUtsClassStaticAsync">点击测试uts class静态异步方法</button> <!-- <button @click="testUtsClassStaticAsync">点击测试uts class静态异步方法</button>
<view>测试return:{{ format(testUtsClassStaticAsyncResult.return) }}</view> <view>测试return:{{ format(testUtsClassStaticAsyncResult.return) }}</view>
<view>测试success:{{ format(testUtsClassStaticAsyncResult.success) }}</view> <view>测试success:{{ format(testUtsClassStaticAsyncResult.success) }}</view>
...@@ -33,9 +63,21 @@ ...@@ -33,9 +63,21 @@
<button @click="testUtsClassSyncWithCallback"> <button @click="testUtsClassSyncWithCallback">
点击测试uts class实例方法 点击测试uts class实例方法
</button> </button>
<view>测试return:{{ format(testUtsClassSyncWithCallbackResult.return) }}</view> <view
<view>测试success:{{ format(testUtsClassSyncWithCallbackResult.success) }}</view> >测试return:{{
<view>测试complete:{{ format(testUtsClassSyncWithCallbackResult.complete) }}</view> format(testUtsClassSyncWithCallbackResult.return)
}}</view
>
<view
>测试success:{{
format(testUtsClassSyncWithCallbackResult.success)
}}</view
>
<view
>测试complete:{{
format(testUtsClassSyncWithCallbackResult.complete)
}}</view
>
<!-- <button @click="testUtsClassAsync">点击测试uts class实例异步方法</button> <!-- <button @click="testUtsClassAsync">点击测试uts class实例异步方法</button>
<view>测试return:{{ format(testUtsClassAsyncResult.return) }}</view> <view>测试return:{{ format(testUtsClassAsyncResult.return) }}</view>
<view>测试success:{{ format(testUtsClassAsyncResult.success) }}</view> <view>测试success:{{ format(testUtsClassAsyncResult.success) }}</view>
...@@ -44,13 +86,20 @@ ...@@ -44,13 +86,20 @@
<view>测试prop:{{ format(testUtsClassInstanceResult.prop) }}</view> <view>测试prop:{{ format(testUtsClassInstanceResult.prop) }}</view>
<view>测试return:{{ format(testUtsClassInstanceResult.return) }}</view> <view>测试return:{{ format(testUtsClassInstanceResult.return) }}</view>
<view>测试success:{{ format(testUtsClassInstanceResult.success) }}</view> <view>测试success:{{ format(testUtsClassInstanceResult.success) }}</view>
<view>测试complete:{{ format(testUtsClassInstanceResult.complete) }}</view> <view
<view>测试callback:{{ format(testUtsClassInstanceResult.callback) }}</view> >测试complete:{{ format(testUtsClassInstanceResult.complete) }}</view
>
<view
>测试callback:{{ format(testUtsClassInstanceResult.callback) }}</view
>
<button @click="testAll">点击测试所有</button> <button @click="testAll">点击测试所有</button>
</view> </view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template> </template>
<script lang="ts"> <script lang="ts">
import { import {
MAX, MAX,
testSync, testSync,
testSyncWithCallback, testSyncWithCallback,
...@@ -59,26 +108,26 @@ ...@@ -59,26 +108,26 @@
request, request,
AsyncOptions, AsyncOptions,
TestOptions, TestOptions,
SyncOptions SyncOptions,
} from "../../uni_modules/uts-syntaxcase"; } from '../../uni_modules/uts-syntaxcase'
const TRUE = 'true' const TRUE = 'true'
const FALSE = 'false' const FALSE = 'false'
const NULL = 'null' const NULL = 'null'
let test: Test | null = null let test: Test | null = null
let id = 0 let id = 0
type TestResult = { type TestResult = {
return ?: string, return?: string
success ?: string, success?: string
fail ?: string, fail?: string
complete ?: string, complete?: string
callback?: string, callback?: string
prop?: string, prop?: string
} }
export default { export default {
data() { data() {
return { return {
// 'null' | 'true' | 'false' // 'null' | 'true' | 'false'
...@@ -96,7 +145,7 @@ ...@@ -96,7 +145,7 @@
complete: 'null', complete: 'null',
} as TestResult, } as TestResult,
testUtsClassConstructorResult: { testUtsClassConstructorResult: {
callback: 'null' callback: 'null',
} as TestResult, } as TestResult,
testUtsClassStaticPropResult: 'null', testUtsClassStaticPropResult: 'null',
testUtsClassStaticSyncWithCallbackResult: { testUtsClassStaticSyncWithCallbackResult: {
...@@ -130,64 +179,64 @@ ...@@ -130,64 +179,64 @@
success: 'null', success: 'null',
fail: 'null', fail: 'null',
complete: 'null', complete: 'null',
callback: 'null' callback: 'null',
} as TestResult } as TestResult,
} }
}, },
methods: { methods: {
format(v: string | null) : string { format(v: string | null): string {
return v === "null" || v == null ? "--" : v === 'true' ? "通过" : "未通过"; return v === 'null' || v == null ? '--' : v === 'true' ? '通过' : '未通过'
}, },
testAll() { testAll() {
this.testUtsSync(); this.testUtsSync()
this.testUtsSyncWithCallback(); this.testUtsSyncWithCallback()
// this.testUtsAsync(); // this.testUtsAsync();
this.testUtsClassConstructor(); this.testUtsClassConstructor()
this.testUtsClassStaticProp(); this.testUtsClassStaticProp()
this.testUtsClassStaticSyncWithCallback(); this.testUtsClassStaticSyncWithCallback()
// this.testUtsClassStaticAsync(); // this.testUtsClassStaticAsync();
this.testUtsClassProp(); this.testUtsClassProp()
this.testUtsClassSyncWithCallback(); this.testUtsClassSyncWithCallback()
// this.testUtsClassAsync(); // this.testUtsClassAsync();
this.testUtsClassInstance(); this.testUtsClassInstance()
}, },
testUtsSync() { testUtsSync() {
this.testUtsSyncResult = FALSE; this.testUtsSyncResult = FALSE
try { try {
console.log('testSync("dcloud").msg', testSync("dcloud").msg) console.log('testSync("dcloud").msg', testSync('dcloud').msg)
if (testSync("dcloud").msg == "hello dcloud") { if (testSync('dcloud').msg == 'hello dcloud') {
this.testUtsSyncResult = TRUE; this.testUtsSyncResult = TRUE
} }
} catch (e) { } catch (e) {
console.error("testUtsSync", e); console.error('testUtsSync', e)
} }
}, },
testUtsSyncWithCallback() { testUtsSyncWithCallback() {
try { try {
this.testUtsSyncWithCallbackResult.return = FALSE; this.testUtsSyncWithCallbackResult.return = FALSE
this.testUtsSyncWithCallbackResult.success = FALSE; this.testUtsSyncWithCallbackResult.success = FALSE
// testUtsSyncWithCallbackResult.fail = FALSE; // testUtsSyncWithCallbackResult.fail = FALSE;
this.testUtsSyncWithCallbackResult.complete = FALSE; this.testUtsSyncWithCallbackResult.complete = FALSE
if ( if (
testSyncWithCallback({ testSyncWithCallback({
type: "success", type: 'success',
success: (res) => { success: (res) => {
console.log("testSyncWithCallback.success.callback", res); console.log('testSyncWithCallback.success.callback', res)
this.testUtsSyncWithCallbackResult.success = TRUE; this.testUtsSyncWithCallbackResult.success = TRUE
}, },
fail: (res) => { fail: (res) => {
console.log("testSyncWithCallback.fail.callback", res); console.log('testSyncWithCallback.fail.callback', res)
// testUtsSyncWithCallbackResult.fail = TRUE; // testUtsSyncWithCallbackResult.fail = TRUE;
}, },
complete: (res) => { complete: (res) => {
console.log("testSyncWithCallback.complete.callback", res); console.log('testSyncWithCallback.complete.callback', res)
this.testUtsSyncWithCallbackResult.complete = TRUE; this.testUtsSyncWithCallbackResult.complete = TRUE
}, },
} as AsyncOptions).name === "testSyncWithCallback" } as AsyncOptions).name === 'testSyncWithCallback'
) { ) {
this.testUtsSyncWithCallbackResult.return = TRUE; this.testUtsSyncWithCallbackResult.return = TRUE
} }
} catch (e) { } } catch (e) {}
}, },
// TODO uvue 暂不支持 async await // TODO uvue 暂不支持 async await
// async testUtsAsync() { // async testUtsAsync() {
...@@ -223,7 +272,7 @@ ...@@ -223,7 +272,7 @@
callback: (res) => { callback: (res) => {
console.log(res) console.log(res)
this.testUtsClassConstructorResult.callback = TRUE this.testUtsClassConstructorResult.callback = TRUE
} },
} as TestOptions) } as TestOptions)
}, },
testUtsClassStaticProp() { testUtsClassStaticProp() {
...@@ -234,30 +283,30 @@ ...@@ -234,30 +283,30 @@
}, },
testUtsClassStaticSyncWithCallback() { testUtsClassStaticSyncWithCallback() {
try { try {
this.testUtsClassStaticSyncWithCallbackResult.return = FALSE; this.testUtsClassStaticSyncWithCallbackResult.return = FALSE
this.testUtsClassStaticSyncWithCallbackResult.success = FALSE; this.testUtsClassStaticSyncWithCallbackResult.success = FALSE
// testUtsClassStaticSyncWithCallbackResult.fail = FALSE; // testUtsClassStaticSyncWithCallbackResult.fail = FALSE;
this.testUtsClassStaticSyncWithCallbackResult.complete = FALSE; this.testUtsClassStaticSyncWithCallbackResult.complete = FALSE
if ( if (
Test.testClassStaticSyncWithCallback({ Test.testClassStaticSyncWithCallback({
type: "success", type: 'success',
success: (res) => { success: (res) => {
console.log("testStaticSyncWithCallback.success.callback", res); console.log('testStaticSyncWithCallback.success.callback', res)
this.testUtsClassStaticSyncWithCallbackResult.success = TRUE; this.testUtsClassStaticSyncWithCallbackResult.success = TRUE
}, },
fail: (res) => { fail: (res) => {
console.log("testStaticSyncWithCallback.fail.callback", res); console.log('testStaticSyncWithCallback.fail.callback', res)
// testUtsClassStaticSyncWithCallbackResult.fail = TRUE; // testUtsClassStaticSyncWithCallbackResult.fail = TRUE;
}, },
complete: (res) => { complete: (res) => {
console.log("testStaticSyncWithCallback.complete.callback", res); console.log('testStaticSyncWithCallback.complete.callback', res)
this.testUtsClassStaticSyncWithCallbackResult.complete = TRUE; this.testUtsClassStaticSyncWithCallbackResult.complete = TRUE
}, },
} as AsyncOptions).name === "testSyncWithCallback" } as AsyncOptions).name === 'testSyncWithCallback'
) { ) {
this.testUtsClassStaticSyncWithCallbackResult.return = TRUE; this.testUtsClassStaticSyncWithCallbackResult.return = TRUE
} }
} catch (e) { } } catch (e) {}
}, },
// async testUtsClassStaticAsync() { // async testUtsClassStaticAsync() {
...@@ -299,30 +348,30 @@ ...@@ -299,30 +348,30 @@
this.testUtsClassConstructor() this.testUtsClassConstructor()
} }
try { try {
this.testUtsClassSyncWithCallbackResult.return = FALSE; this.testUtsClassSyncWithCallbackResult.return = FALSE
this.testUtsClassSyncWithCallbackResult.success = FALSE; this.testUtsClassSyncWithCallbackResult.success = FALSE
// testUtsClassSyncWithCallbackResult.fail = FALSE; // testUtsClassSyncWithCallbackResult.fail = FALSE;
this.testUtsClassSyncWithCallbackResult.complete = FALSE; this.testUtsClassSyncWithCallbackResult.complete = FALSE
if ( if (
test!.testClassSyncWithCallback({ test!.testClassSyncWithCallback({
type: "success", type: 'success',
success: (res) => { success: (res) => {
console.log("testSyncWithCallback.success.callback", res); console.log('testSyncWithCallback.success.callback', res)
this.testUtsClassSyncWithCallbackResult.success = TRUE; this.testUtsClassSyncWithCallbackResult.success = TRUE
}, },
fail: (res) => { fail: (res) => {
console.log("testSyncWithCallback.fail.callback", res); console.log('testSyncWithCallback.fail.callback', res)
// testUtsClassSyncWithCallbackResult.fail = TRUE; // testUtsClassSyncWithCallbackResult.fail = TRUE;
}, },
complete: (res) => { complete: (res) => {
console.log("testSyncWithCallback.complete.callback", res); console.log('testSyncWithCallback.complete.callback', res)
this.testUtsClassSyncWithCallbackResult.complete = TRUE; this.testUtsClassSyncWithCallbackResult.complete = TRUE
}, },
} as AsyncOptions).name === "testSyncWithCallback" } as AsyncOptions).name === 'testSyncWithCallback'
) { ) {
this.testUtsClassSyncWithCallbackResult.return = TRUE; this.testUtsClassSyncWithCallbackResult.return = TRUE
} }
} catch (e) { } } catch (e) {}
}, },
// async testUtsClassAsync() { // async testUtsClassAsync() {
// if (test != null) { // if (test != null) {
...@@ -356,41 +405,41 @@ ...@@ -356,41 +405,41 @@
// } // }
// }, // },
testUtsClassInstance() { testUtsClassInstance() {
this.testUtsClassInstanceResult.prop = FALSE; this.testUtsClassInstanceResult.prop = FALSE
this.testUtsClassInstanceResult.return = FALSE; this.testUtsClassInstanceResult.return = FALSE
this.testUtsClassInstanceResult.success = FALSE; this.testUtsClassInstanceResult.success = FALSE
// testUtsClassAsyncResult.fail = FALSE; // testUtsClassAsyncResult.fail = FALSE;
this.testUtsClassInstanceResult.complete = FALSE; this.testUtsClassInstanceResult.complete = FALSE
this.testUtsClassInstanceResult.callback = FALSE; this.testUtsClassInstanceResult.callback = FALSE
const url = 'https://dcloud.io/' const url = 'https://dcloud.io/'
const task = request(url) const task = request(url)
if (task != null) { if (task != null) {
if (task.url === url && task.abort().url === url) { if (task.url === url && task.abort().url === url) {
this.testUtsClassInstanceResult.prop = TRUE; this.testUtsClassInstanceResult.prop = TRUE
} }
task.onCallback((res) => { task.onCallback((res) => {
if (res === 'onCallback') { if (res === 'onCallback') {
this.testUtsClassInstanceResult.callback = TRUE; this.testUtsClassInstanceResult.callback = TRUE
} }
}) })
const res = task.sync({ const res = task.sync({
success: (res) => { success: (res) => {
console.log("task.sync.success.callback", res); console.log('task.sync.success.callback', res)
this.testUtsClassInstanceResult.success = TRUE; this.testUtsClassInstanceResult.success = TRUE
}, },
fail: (res) => { fail: (res) => {
console.log("task.sync.fail.callback", res); console.log('task.sync.fail.callback', res)
}, },
complete: (res) => { complete: (res) => {
console.log("task.sync.complete.callback", res); console.log('task.sync.complete.callback', res)
this.testUtsClassInstanceResult.complete = TRUE; this.testUtsClassInstanceResult.complete = TRUE
}, },
} as SyncOptions) } as SyncOptions)
if (res === 'sync') { if (res === 'sync') {
this.testUtsClassInstanceResult.return = TRUE; this.testUtsClassInstanceResult.return = TRUE
}
}
}
} }
} }
},
},
}
</script> </script>
<template> <template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view> <view>
<view class="uni-padding-wrap uni-common-mt"> <view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text"> <view class="uni-hello-text"> 逐一点击执行,观察测试反馈 </view>
逐一点击执行,观察测试反馈
</view>
</view> </view>
<button @click="getAppContextClick">getAppContext</button> <button @click="getAppContextClick">getAppContext</button>
...@@ -25,24 +26,27 @@ ...@@ -25,24 +26,27 @@
</view> </view>
<view class="uni-padding-wrap uni-common-mt"> <view class="uni-padding-wrap uni-common-mt">
<view class="text-box" scroll-y="true"> <view class="text-box" scroll-y="true">
<text>{{text}}</text> <text>{{ text }}</text>
</view> </view>
</view> </view>
<button @click="gotoSystemPermissionActivityClick">手动申请权限测试</button> <button @click="gotoSystemPermissionActivityClick">
手动申请权限测试
</button>
<button @tap="testGoOtherActivity">跳转拍照界面</button> <button @tap="testGoOtherActivity">跳转拍照界面</button>
<button @tap="testUnRegLifecycle">取消注册周期函数</button> <button @tap="testUnRegLifecycle">取消注册周期函数</button>
<image :src="selectImage" v-if="selectImage"></image> <image :src="selectImage" v-if="selectImage"></image>
<view class="uni-padding-wrap uni-common-mt"> <view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text"> <view class="uni-hello-text"> 获取设备信息,观察是否符合预期 </view>
获取设备信息,观察是否符合预期
</view>
</view> </view>
<button @tap="getDeviceInfoClick">获取设备基础信息</button> <button @tap="getDeviceInfoClick">获取设备基础信息</button>
</view> </view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template> </template>
<script> <script>
import { import {
getAppContextTest, getAppContextTest,
getUniActivityTest, getUniActivityTest,
getAppTempPathTest, getAppTempPathTest,
...@@ -56,75 +60,75 @@ ...@@ -56,75 +60,75 @@
initAppLifecycle, initAppLifecycle,
gotoCameraTake, gotoCameraTake,
getDeviceInfoTest, getDeviceInfoTest,
privacyStateTest privacyStateTest,
} from '@/uni_modules/uts-platform-api' } from '@/uni_modules/uts-platform-api'
/** /**
* 测试在页面生命周期之外,使用api * 测试在页面生命周期之外,使用api
*/ */
export default { export default {
data() { data() {
return { return {
text: '', text: '',
selectImage:'' selectImage: '',
} }
}, },
onLoad:function(){ onLoad: function () {
let that = this; let that = this
initAppLifecycle(function(eventLog){ initAppLifecycle(function (eventLog) {
// 展示捕捉到的声明周期日志 // 展示捕捉到的声明周期日志
let nextLine = that.text + eventLog; let nextLine = that.text + eventLog
that.text = nextLine; that.text = nextLine
let nextLineFlag = that.text + '\n'; let nextLineFlag = that.text + '\n'
that.text = nextLineFlag that.text = nextLineFlag
}); })
}, },
methods: { methods: {
privacyStateClick(){ privacyStateClick() {
privacyStateTest(function(ret,desc){ privacyStateTest(function (ret, desc) {
if (ret) { if (ret) {
uni.showToast({ uni.showToast({
title: '测试通过' title: '测试通过',
}) })
} else { } else {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '失败:' + desc title: '失败:' + desc,
}) })
} }
}) })
}, },
getDeviceInfoClick(){ getDeviceInfoClick() {
this.text = getDeviceInfoTest() this.text = getDeviceInfoTest()
}, },
testGoOtherActivity(){ testGoOtherActivity() {
var that = this; var that = this
let ret = gotoCameraTake(function(file){ let ret = gotoCameraTake(function (file) {
// 展示捕捉到的声明周期日志 // 展示捕捉到的声明周期日志
console.log(file); console.log(file)
that.selectImage = "file://" + file; that.selectImage = 'file://' + file
}); })
if(!ret){ if (!ret) {
uni.showToast({ uni.showToast({
icon:'none', icon: 'none',
title:'测试失败' title: '测试失败',
}) })
} }
}, },
testUnRegLifecycle(){ testUnRegLifecycle() {
// 取消注册生命周期 // 取消注册生命周期
unRegLifecycle(); unRegLifecycle()
}, },
getAppContextClick() { getAppContextClick() {
if (getAppContextTest()) { if (getAppContextTest()) {
uni.showToast({ uni.showToast({
title: '测试通过' title: '测试通过',
}) })
} else { } else {
uni.showToast({ uni.showToast({
icon: 'error', icon: 'error',
title: '测试失败' title: '测试失败',
}) })
} }
}, },
...@@ -132,49 +136,49 @@ ...@@ -132,49 +136,49 @@
getUniActivityClick() { getUniActivityClick() {
if (getUniActivityTest()) { if (getUniActivityTest()) {
uni.showToast({ uni.showToast({
title: '测试通过' title: '测试通过',
}) })
} else { } else {
uni.showToast({ uni.showToast({
icon: 'error', icon: 'error',
title: '测试失败' title: '测试失败',
}) })
} }
}, },
pathTestClick() { pathTestClick() {
if (convert2AbsFullPathTest()) { if (convert2AbsFullPathTest()) {
uni.showToast({ uni.showToast({
title: '测试通过' title: '测试通过',
}) })
} else { } else {
uni.showToast({ uni.showToast({
icon: 'error', icon: 'error',
title: '测试失败' title: '测试失败',
}) })
} }
}, },
getAppTempPathClick() { getAppTempPathClick() {
if (getAppTempPathTest()) { if (getAppTempPathTest()) {
uni.showToast({ uni.showToast({
title: '测试通过' title: '测试通过',
}) })
} else { } else {
uni.showToast({ uni.showToast({
icon: 'error', icon: 'error',
title: '测试失败' title: '测试失败',
}) })
} }
}, },
dispatchAsyncClick() { dispatchAsyncClick() {
dispatchAsyncTest(function(ret,desc){ dispatchAsyncTest(function (ret, desc) {
if (ret) { if (ret) {
uni.showToast({ uni.showToast({
title: '测试通过' title: '测试通过',
}) })
} else { } else {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '失败:' + desc title: '失败:' + desc,
}) })
} }
}) })
...@@ -182,12 +186,12 @@ ...@@ -182,12 +186,12 @@
typeofClick() { typeofClick() {
if (typeofClickTest()) { if (typeofClickTest()) {
uni.showToast({ uni.showToast({
title: '测试通过' title: '测试通过',
}) })
} else { } else {
uni.showToast({ uni.showToast({
icon: 'error', icon: 'error',
title: '测试失败' title: '测试失败',
}) })
} }
}, },
...@@ -196,43 +200,41 @@ ...@@ -196,43 +200,41 @@
gotoSystemPermissionActivityTest() gotoSystemPermissionActivityTest()
}, },
arrayPermissionFlowClick() { arrayPermissionFlowClick() {
arrayPermissionFlowTest(function(ret,desc){ arrayPermissionFlowTest(function (ret, desc) {
if (ret) { if (ret) {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '测试通过' title: '测试通过',
}) })
} else { } else {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '失败:' + desc title: '失败:' + desc,
}) })
} }
}) })
}, },
singlePermissionFlowClick() { singlePermissionFlowClick() {
singlePermissionFlowTest(function(ret,desc){ singlePermissionFlowTest(function (ret, desc) {
if (ret) { if (ret) {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '测试通过' title: '测试通过',
}) })
} else { } else {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '失败:' + desc title: '失败:' + desc,
}) })
} }
}) })
} },
},
}
}
}
</script> </script>
<style> <style>
.testButton{ .testButton {
width:100% width: 100%;
} }
</style> </style>
<template> <template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view class="content"> <view class="content">
<page-head :title="title"></page-head> <page-head :title="title"></page-head>
<view v-for="(item,index) in resultArray" :key="index" class="result"> <view v-for="(item, index) in resultArray" :key="index" class="result">
<view>{{names[index]}}测试结果:</view> <view>{{ names[index] }}测试结果:</view>
<view> <view> 测试api:{{ item.passed.join(', ') }} </view>
测试api:{{item.passed.join(', ')}} <view>总共:{{ item.total }}</view>
</view> <view>通过:{{ item.passed.length }}</view>
<view>总共:{{item.total}}</view> <view>失败:{{ item.failed.length }}</view>
<view>通过:{{item.passed.length}}</view> <view v-for="(fail, i) in item.failed" :key="i">
<view>失败:{{item.failed.length}}</view> <text class="failed">{{ fail }}</text>
<view v-for="(fail,i) in item.failed" :key="i">
<text class="failed">{{fail}}</text>
</view> </view>
</view> </view>
</view> </view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template> </template>
<script lang="ts"> <script lang="ts">
import { import { runTests, Result } from '../../uni_modules/uts-tests'
runTests,
Result
} from '../../uni_modules/uts-tests'
export default { export default {
data() { data() {
return { return {
title: 'UTS基础语法', title: 'UTS基础语法',
resultArray: [] as Result[], resultArray: [] as Result[],
result: {} as UTSJSONObject, result: {} as UTSJSONObject,
names: [] as string[] names: [] as string[],
} }
}, },
onReady() { onReady() {
...@@ -41,26 +42,26 @@ ...@@ -41,26 +42,26 @@
this.names.push(name) this.names.push(name)
this.resultArray.push(res as Result) this.resultArray.push(res as Result)
}) })
} },
} },
} }
</script> </script>
<style> <style>
@import '@/common/uni-uvue.css'; @import '@/common/uni-uvue.css';
.content { .content {
min-height: 100%; min-height: 100%;
padding: 32rpx; padding: 32rpx;
} }
.passed { .passed {
color: green; color: green;
} }
.failed { .failed {
color: red; color: red;
} }
.result { .result {
margin-bottom: 20rpx; margin-bottom: 20rpx;
} }
</style> </style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册