提交 c22d0401 编写于 作者: W wan201809

Merge remote-tracking branch 'origin/dev' into alpha

...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
}, },
changeRepeat: function() { changeRepeat: function() {
// this.$refs["animView"].updateRepeatConfig("RESTART"); (this.$refs["animView"] as UtsAnimationViewElement).setRepeatMode("RESTART");
}, },
lottieClickTest: function() { lottieClickTest: function() {
console.log("lottieClickTest"); console.log("lottieClickTest");
......
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-btn-v uni-common-mt">
<button @tap="callKotlinMethodGetInfoTest">调用kotlin方法</button>
<button @tap="callJavaMethodGetInfoTest">调用java方法(需自定义基座)</button>
</view>
</view>
</template>
<script>
import { callKotlinMethodGetInfo, callJavaMethodGetInfo} from "../../uni_modules/uts-syntaxcase";
export default {
data() {
return {
title: 'UTS混编示例',
}
},
methods: {
callKotlinMethodGetInfoTest: function () {
let phoneInfo = callKotlinMethodGetInfo();
uni.showToast({
title:phoneInfo
})
},
callJavaMethodGetInfoTest: function () {
let javaInfo = callJavaMethodGetInfo();
uni.showToast({
title:javaInfo
})
},
}
}
</script>
<style>
</style>
\ No newline at end of file
...@@ -93,6 +93,14 @@ ...@@ -93,6 +93,14 @@
url: "SyntaxCase/consoleTest" url: "SyntaxCase/consoleTest"
}] as Page[] }] as Page[]
}, },
{
name: "组件开发示例",
open: false,
pages: [{
name: "Hello UTS Component",
url: "component/helloView"
}]
},
{ {
name: "平台代码示例", name: "平台代码示例",
open: false, open: false,
......
...@@ -119,7 +119,8 @@ ...@@ -119,7 +119,8 @@
},{ },{
name: "实例测试示例", name: "实例测试示例",
url: "SyntaxCase/instanceTest" url: "SyntaxCase/instanceTest"
}] }
]
}, },
{ {
name: "日志打印", name: "日志打印",
......
<template> <template>
<view> <div>
暂时不支持 todo <button @tap="doSth">调用组件的方法</button>
</view> <uts-hello-view ref="helloView" buttonText="点击按钮内容" style="width:375px;height: 375px;background-color: aqua;"></uts-hello-view>
<uts-hello-container>
<text>文本组件</text>
<image src="../../static/logo.png" mode="aspectFit"></image>
</uts-hello-container>
</div>
</template> </template>
<script> <script>
export default {
data() {
return {
}
},
methods: {
// 调用组件内的方法
doSth() {
// uvue 页面调用方法
(this.$refs["helloView"] as UtsHelloViewElement).doSth("param doSomething");
}
}
}
</script> </script>
<style> <style>
......
...@@ -128,7 +128,7 @@ ...@@ -128,7 +128,7 @@
// 组件内可以调用 UTSAndroid 内置方法 // 组件内可以调用 UTSAndroid 内置方法
console.log("UTSAndroid.devicePX2px(1080) : ",UTSAndroid.devicePX2px(1080)) console.log("UTSAndroid.devicePX2px(1080) : ",UTSAndroid.devicePX2px(1080))
console.log("UTSAndroid.rpx2px(1080) : ",UTSAndroid.rpx2px(1080)) console.log("UTSAndroid.rpx2px(1080) : ",UTSAndroid.rpx2px(1080))
console.log("UTSAndroid.appJSBundleUrl() : ",UTSAndroid.appJSBundleUrl()) // console.log("UTSAndroid.appJSBundleUrl() : ",UTSAndroid.appJSBundleUrl())
}, },
/** /**
* 原生View布局完成 * 原生View布局完成
......
...@@ -203,7 +203,7 @@ export function gotoCameraTake(imageDone : (event : string) => void) : boolean { ...@@ -203,7 +203,7 @@ export function gotoCameraTake(imageDone : (event : string) => void) : boolean {
} }
}, function (_ : boolean, _ : string[]) { }, function (_ : boolean, _ : string[]) {
//callback(false,"用户拒绝了部分权限") //callback(false,"用户拒绝了部分权限")
}) },true)
return true; return true;
...@@ -336,7 +336,7 @@ export function arrayPermissionFlowTest(callback : (ret : boolean, desc : string ...@@ -336,7 +336,7 @@ export function arrayPermissionFlowTest(callback : (ret : boolean, desc : string
*/ */
let permissionNeed = ["android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.ACCESS_FINE_LOCATION", "android.permission.READ_PHONE_STATE"] let permissionNeed = ["android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.ACCESS_FINE_LOCATION", "android.permission.READ_PHONE_STATE"]
if (UTSAndroid.getSystemPermissionDenied(UTSAndroid.getUniActivity()!, permissionNeed).isEmpty()) { if (UTSAndroid.getSystemPermissionDenied(UTSAndroid.getUniActivity()!, permissionNeed).length == 0) {
callback(false, "已具备请求权限") callback(false, "已具备请求权限")
return; return;
} }
...@@ -345,7 +345,7 @@ export function arrayPermissionFlowTest(callback : (ret : boolean, desc : string ...@@ -345,7 +345,7 @@ export function arrayPermissionFlowTest(callback : (ret : boolean, desc : string
if (allRight) { if (allRight) {
// 交给目前的location 引擎,真实执行 // 交给目前的location 引擎,真实执行
// 测试权限api 返回值 // 测试权限api 返回值
if (!UTSAndroid.getSystemPermissionDenied(UTSAndroid.getUniActivity()!, permissionNeed).isEmpty()) { if (UTSAndroid.getSystemPermissionDenied(UTSAndroid.getUniActivity()!, permissionNeed).length > 0) {
// 预期当前基座具备了读写日历的权限 // 预期当前基座具备了读写日历的权限
callback(false, "权限请求完成,getSystemPermissionDenied 失败") callback(false, "权限请求完成,getSystemPermissionDenied 失败")
return; return;
...@@ -483,7 +483,7 @@ export function singlePermissionFlowTest(callback : (ret : boolean, desc : strin ...@@ -483,7 +483,7 @@ export function singlePermissionFlowTest(callback : (ret : boolean, desc : strin
} }
let permissionNeed = ["android.permission.READ_PHONE_STATE"] let permissionNeed = ["android.permission.READ_PHONE_STATE"]
if (UTSAndroid.getSystemPermissionDenied(UTSAndroid.getUniActivity()!, permissionNeed).isEmpty()) { if (UTSAndroid.getSystemPermissionDenied(UTSAndroid.getUniActivity()!, permissionNeed).length == 0) {
callback(false, "已具备权限") callback(false, "已具备权限")
return; return;
} }
...@@ -491,7 +491,7 @@ export function singlePermissionFlowTest(callback : (ret : boolean, desc : strin ...@@ -491,7 +491,7 @@ export function singlePermissionFlowTest(callback : (ret : boolean, desc : strin
UTSAndroid.requestSystemPermission(UTSAndroid.getUniActivity()!, permissionNeed, function (allRight : boolean, _ : string[]) { UTSAndroid.requestSystemPermission(UTSAndroid.getUniActivity()!, permissionNeed, function (allRight : boolean, _ : string[]) {
if (allRight) { if (allRight) {
// 测试权限api 返回值 // 测试权限api 返回值
if (!UTSAndroid.getSystemPermissionDenied(UTSAndroid.getUniActivity()!, permissionNeed).isEmpty()) { if (UTSAndroid.getSystemPermissionDenied(UTSAndroid.getUniActivity()!, permissionNeed).length > 0) {
callback(false, "权限请求完成,getSystemPermissionDenied 失败") callback(false, "权限请求完成,getSystemPermissionDenied 失败")
return; return;
} }
......
...@@ -25,11 +25,66 @@ export function testDate() : Result { ...@@ -25,11 +25,66 @@ export function testDate() : Result {
}) })
test('new Date', () => { test('new Date', () => {
let date1 = new Date('1992-02-02'); let date1 = new Date('1992-02-02');
console.log("1111",date1.getTime())
expect(date1.getTime()).toEqual(696988800000); expect(date1.getTime()).toEqual(696988800000);
let date2 = new Date('1992-2-02');
console.log("2222",date2.getTime()) // #ifdef APP-ANDROID
// expect(date2.getTime()).toEqual(696960000000); /**
* iso 8601 相关
*/
let isoCaseArr = [
"2012",
"2012-07",
"1997-07-16",
"1997-07-16T02:20:20",
"1995-12-17T03:24:00.888Z",
"2022-11-19T00:00:00.666+04:00",
"1997-07-16T19:20+01:00",
"1997-07-16T19:20:30+01:00",
"1997-07-16T19:20:30.45+01:00",
"1994-11-05T08:15:30-05:00"
];
let timeStr = ""
for(let i = 0; i < isoCaseArr.length; i++){
let perDate = new Date(isoCaseArr[i])
timeStr += perDate.getTime()
}
expect(timeStr).toEqual("132537600000013411008000008690112000008689908200008191706408881668801600666869077200000869077230000869077230450784041330000");
timeStr = ""
let rfcCaseArr = [
"Dec 25, 1995",
"17 Dec 1995 03:24:00 GMT",
"December 17, 1995 03:24:00",
"December 17, 95 03:24:00",
"December 17, 95 03:24",
"December 17, 95 03:24:00 GMT+11:00",
"December 17, 1995, 03:24:00 GMT+11:00",
];
for(let i = 0; i < rfcCaseArr.length; i++){
let perDate = new Date(rfcCaseArr[i])
timeStr += perDate.getTime()
}
expect(timeStr).toEqual("819820800000819170640000819141840000819141840000819141840000819131040000819131040000");
timeStr = ""
let otherCaseArr = [
"2024-5-01",
"2024-05-01 22:00",
"2024/05/01 22:00:00",
"2024/05/01 22:00",
"2024/5/1 22:00:00",
"2024/5/1 22:00",
"2024/5/1"
];
for(let i = 0; i < otherCaseArr.length; i++){
let perDate = new Date(otherCaseArr[i])
timeStr += perDate.getTime()
}
expect(timeStr).toEqual("1714492800000171457200000017145720000001714572000000171457200000017145720000001714492800000");
// #endif
}) })
test('valueOf', () => { test('valueOf', () => {
......
import { describe, test, expect, Result } from './tests.uts'
export function testNativeCode(): Result {
return describe("mix-native-code-work", () => {
test('getStrFromNativeCode', () => {
// #ifdef APP-ANDROID
expect(NativeCode.getNativeStr()).toEqual("android-code");
// #endif
})
})
}
...@@ -22,13 +22,21 @@ export function testUTSJSONObject() : Result { ...@@ -22,13 +22,21 @@ export function testUTSJSONObject() : Result {
expect(returnedTarget.toMap().size).toEqual(3); expect(returnedTarget.toMap().size).toEqual(3);
type A = { type A = {
username:"张三", username:string
age:12 age:number
} }
type C = { type C = {
work:0.001 work:number
} }
let b = UTSJSONObject.assign(new A("张三",12),{b:2},new C(0.002))
let b = UTSJSONObject.assign( {
username:"张三",
age:12
} as A,
{b:2},
{
work:0.002
} as C)
expect(b['age']).toEqual(12); expect(b['age']).toEqual(12);
expect(b['username']).toEqual("张三"); expect(b['username']).toEqual("张三");
expect(b['b']).toEqual(2); expect(b['b']).toEqual(2);
......
package uts.sdk.modules.utsTests
import android.os.Build
import io.dcloud.uts.UTSAndroid
object NativeCode {
fun getNativeStr():String{
return "android-code"
}
}
\ No newline at end of file
...@@ -18,6 +18,7 @@ import { testGlobal } from './Global.uts' ...@@ -18,6 +18,7 @@ import { testGlobal } from './Global.uts'
import { testType } from './Type.uts' import { testType } from './Type.uts'
export { Result } from './tests.uts' export { Result } from './tests.uts'
import { testArrayBuffer } from './ArrayBuffer.uts' import { testArrayBuffer } from './ArrayBuffer.uts'
import { testNativeCode } from './NativeCode.uts'
// Promise、Proxy、Reflect、Weakmap、WeakSet 不支持 // Promise、Proxy、Reflect、Weakmap、WeakSet 不支持
...@@ -41,6 +42,7 @@ export function runTests() : UTSJSONObject { ...@@ -41,6 +42,7 @@ export function runTests() : UTSJSONObject {
const consoleRes = testConsole(); const consoleRes = testConsole();
const UTSJSONObjectRes = testUTSJSONObject(); const UTSJSONObjectRes = testUTSJSONObject();
const ArrayBufferRes = testArrayBuffer(); const ArrayBufferRes = testArrayBuffer();
const NativeCodeRes = testNativeCode();
return { return {
Array: ArrayRes, Array: ArrayRes,
Date: DateRes, Date: DateRes,
...@@ -60,6 +62,7 @@ export function runTests() : UTSJSONObject { ...@@ -60,6 +62,7 @@ export function runTests() : UTSJSONObject {
Type: TypeRes, Type: TypeRes,
console:consoleRes, console:consoleRes,
UTSJSONObject:UTSJSONObjectRes, UTSJSONObject:UTSJSONObjectRes,
ArrayBuffer:ArrayBufferRes ArrayBuffer:ArrayBufferRes,
NativeCode:NativeCodeRes
} }
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册