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

UTSAndroid.getJavaClass 示例添加

上级 6ef0ce1b
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<button @click="getAppContextClick">getAppContext</button> <button @click="getAppContextClick">getAppContext</button>
<button @click="getUniActivityClick">getUniActivity</button> <button @click="getUniActivityClick">getUniActivity</button>
<button @click="getJavaClassClick">getJavaClass</button>
<button @click="getAppTempPathClick">getAppTempPath</button> <button @click="getAppTempPathClick">getAppTempPath</button>
<button @click="typeofClick">typeof</button> <button @click="typeofClick">typeof</button>
<button @click="arrayPermissionFlowClick">组权限申请流程测试</button> <button @click="arrayPermissionFlowClick">组权限申请流程测试</button>
...@@ -50,6 +51,7 @@ ...@@ -50,6 +51,7 @@
import { import {
getAppContextTest, getAppContextTest,
getUniActivityTest, getUniActivityTest,
getJavaClassTest,
getAppTempPathTest, getAppTempPathTest,
typeofClickTest, typeofClickTest,
gotoSystemPermissionActivityTest, gotoSystemPermissionActivityTest,
...@@ -123,6 +125,18 @@ export default { ...@@ -123,6 +125,18 @@ export default {
// 取消注册生命周期 // 取消注册生命周期
unRegLifecycle() unRegLifecycle()
}, },
getJavaClassClick() {
if (getJavaClassTest()) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败'
})
}
},
getAppContextClick() { getAppContextClick() {
if (getAppContextTest()) { if (getAppContextTest()) {
uni.showToast({ uni.showToast({
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<button @click="getAppContextClick">getAppContext</button> <button @click="getAppContextClick">getAppContext</button>
<button @click="getUniActivityClick">getUniActivity</button> <button @click="getUniActivityClick">getUniActivity</button>
<button @click="getJavaClassClick">getJavaClass</button>
<button @click="getAppTempPathClick">getAppTempPath</button> <button @click="getAppTempPathClick">getAppTempPath</button>
<button @click="typeofClick">typeof</button> <button @click="typeofClick">typeof</button>
<button @click="arrayPermissionFlowClick">组权限申请流程测试</button> <button @click="arrayPermissionFlowClick">组权限申请流程测试</button>
...@@ -45,6 +46,7 @@ ...@@ -45,6 +46,7 @@
import { import {
getAppContextTest, getAppContextTest,
getUniActivityTest, getUniActivityTest,
getJavaClassTest,
getAppTempPathTest, getAppTempPathTest,
typeofClickTest, typeofClickTest,
gotoSystemPermissionActivityTest, gotoSystemPermissionActivityTest,
...@@ -114,6 +116,18 @@ ...@@ -114,6 +116,18 @@
// 取消注册生命周期 // 取消注册生命周期
unRegLifecycle(); unRegLifecycle();
}, },
getJavaClassClick() {
if (getJavaClassTest()) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败'
})
}
},
getAppContextClick() { getAppContextClick() {
if (getAppContextTest()) { if (getAppContextTest()) {
uni.showToast({ uni.showToast({
......
...@@ -23,6 +23,20 @@ export function getAppContextTest() : boolean { ...@@ -23,6 +23,20 @@ export function getAppContextTest() : boolean {
return true return true
} }
export function getJavaClassTest() : boolean {
let classObj1 = UTSAndroid.getJavaClass(UTSAndroid.getDispatcher())
if("io.dcloud.uts.task.UTSTaskDispatcher" == classObj1.name){
return true
}
let classObj2 = UTSAndroid.getJavaClass(UTSAndroid.getAppContext()!)
if("io.dcloud.uniapp.UniApplication" == classObj2.name){
return true
}
return false
}
/** /**
* UTSAndroid.getUniActivity 测试示例 * UTSAndroid.getUniActivity 测试示例
* https://uniapp.dcloud.net.cn/plugin/uts-for-android.html#_4-2-1-getuniactivity * https://uniapp.dcloud.net.cn/plugin/uts-for-android.html#_4-2-1-getuniactivity
......
...@@ -89,8 +89,14 @@ export function testNumber() : Result { ...@@ -89,8 +89,14 @@ export function testNumber() : Result {
expect((123456789987654).toString(16)).toEqual("7048861cc146"); expect((123456789987654).toString(16)).toEqual("7048861cc146");
expect((-0xff).toString(2)).toEqual("-11111111"); expect((-0xff).toString(2)).toEqual("-11111111");
const a = 1e38 const a = 1e38
expect(a.toString(16)).toEqual("4b3b4ca85a86c4000000000000000000");
expect(a.toString(2)).toEqual("1001011001110110100110010101000010110101000011011000100000000000000000000000000000000000000000000000000000000000000000000000000") expect(a.toString(16).substring(0,12)).toEqual("4b3b4ca85a86");
expect(a.toString(16).length).toEqual(32);
expect(a.toString(16).substring(23)).toEqual("000000000");
expect(a.toString(2).length).toEqual(127);
expect(a.toString(2).substring(0,32)).toEqual("10010110011101101001100101010000");
expect(a.toString(2).substring(100)).toEqual("000000000000000000000000000");
const b = 1e22 const b = 1e22
expect(b.toString(12)).toEqual("27373a86ba1a194a65054"); expect(b.toString(12)).toEqual("27373a86ba1a194a65054");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册