Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
7f69bda0
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
7f69bda0
编写于
11月 01, 2023
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' into alpha
上级
ad182749
bc9327da
变更
45
显示空白变更内容
内联
并排
Showing
45 changed file
with
622 addition
and
550 deletion
+622
-550
pages.json
pages.json
+19
-12
pages/API/event-bus/event-bus.test.js
pages/API/event-bus/event-bus.test.js
+1
-1
pages/API/get-element-by-id/get-element-by-id-multiple-root-node.test.js
...lement-by-id/get-element-by-id-multiple-root-node.test.js
+1
-1
pages/API/get-element-by-id/get-element-by-id.test.js
pages/API/get-element-by-id/get-element-by-id.test.js
+1
-1
pages/API/get-launch-options-sync/get-launch-options-sync.test.js
...I/get-launch-options-sync/get-launch-options-sync.test.js
+1
-1
pages/API/install-apk/install-apk.uvue
pages/API/install-apk/install-apk.uvue
+47
-0
pages/API/load-font-face/load-font-face-child.test.js
pages/API/load-font-face/load-font-face-child.test.js
+0
-12
pages/API/load-font-face/load-font-face.test.js
pages/API/load-font-face/load-font-face.test.js
+16
-9
pages/API/navigator/navigator.test.js
pages/API/navigator/navigator.test.js
+0
-199
pages/API/navigator/new-page/new-page-2.test.js
pages/API/navigator/new-page/new-page-2.test.js
+0
-77
pages/API/navigator/new-page/new-page-2.uvue
pages/API/navigator/new-page/new-page-2.uvue
+0
-91
pages/API/navigator/new-page/onLoad.test.js
pages/API/navigator/new-page/onLoad.test.js
+15
-15
pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.test.js
...igation-bar-color/set-custom-navigation-bar-color.test.js
+4
-0
pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.uvue
...navigation-bar-color/set-custom-navigation-bar-color.uvue
+10
-4
pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js
...set-navigation-bar-color/set-navigation-bar-color.test.js
+14
-10
pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue
...PI/set-navigation-bar-color/set-navigation-bar-color.uvue
+10
-13
pages/API/set-navigation-bar-title/set-navigation-bar-title.test.js
...set-navigation-bar-title/set-navigation-bar-title.test.js
+26
-0
pages/API/set-navigation-bar-title/set-navigation-bar-title.uvue
...PI/set-navigation-bar-title/set-navigation-bar-title.uvue
+49
-0
pages/component/button/button.test.js
pages/component/button/button.test.js
+2
-7
pages/component/checkbox/checkbox.test.js
pages/component/checkbox/checkbox.test.js
+1
-4
pages/component/general-attribute/general-attribute.test.js
pages/component/general-attribute/general-attribute.test.js
+2
-2
pages/component/general-event/general-event.test.js
pages/component/general-event/general-event.test.js
+1
-1
pages/component/input/input.test.js
pages/component/input/input.test.js
+48
-48
pages/component/picker-view/picker-view.test.js
pages/component/picker-view/picker-view.test.js
+4
-6
pages/component/progress/progress.test.js
pages/component/progress/progress.test.js
+4
-9
pages/component/radio/radio.test.js
pages/component/radio/radio.test.js
+1
-4
pages/component/textarea/textarea.test.js
pages/component/textarea/textarea.test.js
+2
-2
pages/component/video/video.uvue
pages/component/video/video.uvue
+4
-2
pages/tabBar/API.uvue
pages/tabBar/API.uvue
+7
-4
pages/template/custom-tab-bar/custom-tab-bar-tab1.uvue
pages/template/custom-tab-bar/custom-tab-bar-tab1.uvue
+1
-1
pages/template/long-list/long-list-page.uvue
pages/template/long-list/long-list-page.uvue
+5
-1
pages/template/long-list/long-list.uvue
pages/template/long-list/long-list.uvue
+4
-2
pages/template/long-list2/long-list2.uvue
pages/template/long-list2/long-list2.uvue
+23
-9
pages/template/swiper-list/swiper-list.uvue
pages/template/swiper-list/swiper-list.uvue
+3
-1
pages/template/swiper-list2/swiper-list2.uvue
pages/template/swiper-list2/swiper-list2.uvue
+3
-1
readme.md
readme.md
+10
-0
static/test-apk/test.apk
static/test-apk/test.apk
+0
-0
uni_modules/uni-installApk/changelog.md
uni_modules/uni-installApk/changelog.md
+8
-0
uni_modules/uni-installApk/package.json
uni_modules/uni-installApk/package.json
+93
-0
uni_modules/uni-installApk/readme.md
uni_modules/uni-installApk/readme.md
+37
-0
uni_modules/uni-installApk/utssdk/app-android/AndroidManifest.xml
...les/uni-installApk/utssdk/app-android/AndroidManifest.xml
+5
-0
uni_modules/uni-installApk/utssdk/app-android/index.uts
uni_modules/uni-installApk/utssdk/app-android/index.uts
+39
-0
uni_modules/uni-installApk/utssdk/app-ios/index.uts
uni_modules/uni-installApk/utssdk/app-ios/index.uts
+0
-0
uni_modules/uni-installApk/utssdk/interface.uts
uni_modules/uni-installApk/utssdk/interface.uts
+76
-0
uni_modules/uni-installApk/utssdk/unierror.uts
uni_modules/uni-installApk/utssdk/unierror.uts
+25
-0
未找到文件。
pages.json
浏览文件 @
7f69bda0
...
...
@@ -263,6 +263,12 @@
"navigationBarTitleText"
:
"设置导航条颜色"
}
},
{
"path"
:
"pages/API/set-navigation-bar-title/set-navigation-bar-title"
,
"style"
:
{
"navigationBarTitleText"
:
"设置导航条标题"
}
},
{
"path"
:
"pages/API/set-navigation-bar-color/set-custom-navigation-bar-color"
,
"style"
:
{
...
...
@@ -276,13 +282,6 @@
"navigationBarTitleText"
:
"新页面-1"
}
},
{
"path"
:
"pages/API/navigator/new-page/new-page-2"
,
"style"
:
{
"navigationBarTitleText"
:
"新页面-2"
,
"enablePullDownRefresh"
:
true
}
},
{
"path"
:
"pages/API/navigator/new-page/new-page-3"
,
"style"
:
{
...
...
@@ -1040,6 +1039,14 @@
"navigationBarTitleText"
:
"transitionend事件"
,
"enablePullDownRefresh"
:
false
}
},
{
"path"
:
"pages/API/install-apk/install-apk"
,
"style"
:
{
"navigationBarTitleText"
:
"install-apk"
,
"enablePullDownRefresh"
:
false
}
}
],
...
...
pages/API/event-bus/event-bus.test.js
浏览文件 @
7f69bda0
...
...
@@ -4,7 +4,7 @@ describe('event-bus', () => {
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
await
page
.
waitFor
(
'
view
'
)
})
it
(
'
on
'
,
async
()
=>
{
...
...
pages/API/get-element-by-id/get-element-by-id-multiple-root-node.test.js
浏览文件 @
7f69bda0
...
...
@@ -5,7 +5,7 @@ let page;
describe
(
"
getElementByIdForMultipleRootNode
"
,
()
=>
{
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
);
await
page
.
waitFor
(
1000
);
await
page
.
waitFor
(
'
view
'
);
});
it
(
"
getElementByNotExistId
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
"
getElementByNotExistId
"
);
...
...
pages/API/get-element-by-id/get-element-by-id.test.js
浏览文件 @
7f69bda0
...
...
@@ -4,7 +4,7 @@ let page;
describe
(
"
getElementById
"
,
()
=>
{
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
);
await
page
.
waitFor
(
1000
);
await
page
.
waitFor
(
'
view
'
);
});
it
(
"
getElementByNotExistId
"
,
async
()
=>
{
const
res
=
await
page
.
callMethod
(
"
getElementByNotExistId
"
);
...
...
pages/API/get-launch-options-sync/get-launch-options-sync.test.js
浏览文件 @
7f69bda0
...
...
@@ -3,7 +3,7 @@ const PAGE_PATH = '/pages/API/get-launch-options-sync/get-launch-options-sync'
describe
(
'
getLaunchOptionsSync
'
,
()
=>
{
it
(
'
getLaunchOptionsSync
'
,
async
()
=>
{
const
page
=
await
program
.
navigateTo
(
PAGE_PATH
)
await
page
.
waitFor
(
1000
)
await
page
.
waitFor
(
'
view
'
)
await
page
.
callMethod
(
'
getLaunchOptionsSync
'
)
const
data
=
await
page
.
data
()
expect
(
data
.
checked
).
toBe
(
true
)
...
...
pages/API/install-apk/install-apk.uvue
0 → 100644
浏览文件 @
7f69bda0
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view>
<page-head :title="title"></page-head>
<view class="uni-common-mt">
<view class="uni-padding-wrap">
<view class="uni-btn-v">
<button type="primary" @tap="installApk">
installApk
</button>
</view>
</view>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
export default {
data() {
return {
title: 'installApk'
}
},
onUnload: function () {
},
methods: {
installApk: function () {
uni.installApk({
filePath: "/static/test-apk/test.apk",
complete(res : any) {
console.log(res);
}
})
},
}
}
</script>
<style>
.uni-pd {
padding-left: 30rpx;
}
</style>
pages/API/load-font-face/load-font-face-child.test.js
已删除
100644 → 0
浏览文件 @
ad182749
const
PAGE_PATH
=
'
/pages/API/load-font-face/load-font-face-child
'
describe
(
'
loadFontFace global
'
,
()
=>
{
beforeAll
(
async
()
=>
{
const
page
=
await
program
.
navigateTo
(
PAGE_PATH
)
await
page
.
waitFor
(
2000
)
})
it
(
'
screenshot
'
,
async
()
=>
{
const
image
=
await
program
.
screenshot
()
expect
(
image
).
toMatchImageSnapshot
()
})
})
pages/API/load-font-face/load-font-face.test.js
浏览文件 @
7f69bda0
const
PAGE_PATH
=
'
/pages/API/load-font-face/load-font-face
'
const
CHILD_PAGE_PATH
=
"
/pages/API/load-font-face/load-font-face-child
"
;
describe
(
'
loadFontFace
'
,
()
=>
{
describe
(
"
loadFontFace
"
,
()
=>
{
beforeAll
(
async
()
=>
{
const
page
=
await
program
.
navigateTo
(
PAGE_PATH
)
await
page
.
waitFor
(
4000
)
})
it
(
'
screenshot
'
,
async
()
=>
{
const
image
=
await
program
.
screenshot
()
expect
(
image
).
toMatchImageSnapshot
()
})
})
const
page
=
await
program
.
navigateTo
(
PAGE_PATH
);
await
page
.
waitFor
(
3000
);
});
it
(
"
parent screenshot
"
,
async
()
=>
{
const
image
=
await
program
.
screenshot
();
expect
(
image
).
toMatchImageSnapshot
();
});
it
(
"
child screenshot
"
,
async
()
=>
{
const
page
=
await
program
.
navigateTo
(
CHILD_PAGE_PATH
);
await
page
.
waitFor
(
"
view
"
);
const
image
=
await
program
.
screenshot
();
expect
(
image
).
toMatchImageSnapshot
();
});
});
pages/API/navigator/navigator.test.js
已删除
100644 → 0
浏览文件 @
ad182749
jest
.
setTimeout
(
80000
)
const
CURRENT_PAGE_PATH
=
'
/pages/API/navigator/navigator
'
const
CHILD1_PAGE_PATH
=
'
/pages/API/navigator/new-page/new-page-1
'
const
CHILD2_PAGE_PATH
=
'
/pages/API/navigator/new-page/new-page-2
'
describe
(
'
navigator
'
,
()
=>
{
let
page
let
lifeCycleNum
afterAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
CURRENT_PAGE_PATH
)
const
resetLifecycleNum
=
1100
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
resetLifecycleNum
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
resetLifecycleNum
)
})
it
(
'
reLaunch
'
,
async
()
=>
{
page
=
await
program
.
navigateTo
(
CURRENT_PAGE_PATH
)
await
page
.
waitFor
(
500
)
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
await
page
.
callMethod
(
'
reLaunch
'
)
await
page
.
waitFor
(
500
)
page
=
await
program
.
navigateTo
(
CURRENT_PAGE_PATH
)
await
page
.
waitFor
(
500
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
2
)
})
it
(
'
navigateTo
'
,
async
()
=>
{
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
await
page
.
callMethod
(
'
navigateTo
'
)
await
page
.
waitFor
(
500
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
2
)
page
=
await
program
.
navigateBack
()
await
page
.
waitFor
(
500
)
})
it
(
'
navigateTo error page
'
,
async
()
=>
{
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
await
page
.
callMethod
(
'
navigateToErrorPage
'
)
await
page
.
waitFor
(
500
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
2
)
})
it
(
'
navigateTo debounce
'
,
async
()
=>
{
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
await
page
.
callMethod
(
'
navigateToDebounce
'
)
await
page
.
waitFor
(
500
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
4
)
page
=
await
program
.
navigateBack
()
await
page
.
waitFor
(
500
)
})
it
(
'
navigateTo relative path
'
,
async
()
=>
{
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
await
page
.
callMethod
(
'
navigateToRelativePath1
'
)
page
=
await
program
.
navigateBack
()
await
page
.
waitFor
(
500
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
2
)
await
page
.
waitFor
(
500
)
})
it
(
'
navigateTo relative path ./
'
,
async
()
=>
{
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
await
page
.
callMethod
(
'
navigateToRelativePath2
'
)
page
=
await
program
.
navigateBack
()
await
page
.
waitFor
(
500
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
2
)
await
page
.
waitFor
(
500
)
})
it
(
'
navigateTo relative path ../
'
,
async
()
=>
{
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
await
page
.
callMethod
(
'
navigateToRelativePath3
'
)
page
=
await
program
.
navigateBack
()
await
page
.
waitFor
(
500
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
2
)
await
page
.
waitFor
(
500
)
})
it
(
'
navigateBack
'
,
async
()
=>
{
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
await
page
.
callMethod
(
'
navigateBack
'
)
await
page
.
waitFor
(
500
)
page
=
await
program
.
navigateTo
(
CURRENT_PAGE_PATH
)
await
page
.
waitFor
(
500
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
2
)
})
it
(
'
navigateBackWithDelta1
'
,
async
()
=>
{
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
await
page
.
callMethod
(
'
navigateBackWithDelta1
'
)
await
page
.
waitFor
(
1000
)
page
=
await
program
.
currentPage
()
expect
(
`/
${
page
.
path
}
`
).
toBe
(
CURRENT_PAGE_PATH
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
2
)
})
it
(
'
navigateBackWithDelta2
'
,
async
()
=>
{
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
await
program
.
navigateTo
(
CHILD2_PAGE_PATH
)
await
page
.
waitFor
(
500
)
page
=
await
program
.
navigateTo
(
CHILD1_PAGE_PATH
)
await
page
.
waitFor
(
500
)
await
page
.
callMethod
(
'
navigateBackWithDelta2
'
)
await
page
.
waitFor
(
500
)
page
=
await
program
.
currentPage
()
expect
(
`/
${
page
.
path
}
`
).
toBe
(
CURRENT_PAGE_PATH
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
10
)
})
it
(
'
navigateBackWithDelta100
'
,
async
()
=>
{
page
=
await
program
.
reLaunch
(
CURRENT_PAGE_PATH
)
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
await
page
.
callMethod
(
'
navigateBackWithDelta100
'
)
await
page
.
waitFor
(
1000
)
page
=
await
program
.
currentPage
()
expect
(
`/
${
page
.
path
}
`
).
toBe
(
CURRENT_PAGE_PATH
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
2
)
})
it
(
'
redirectTo
'
,
async
()
=>
{
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
await
page
.
callMethod
(
'
redirectTo
'
)
await
page
.
waitFor
(
500
)
page
=
await
program
.
redirectTo
(
CURRENT_PAGE_PATH
)
await
page
.
waitFor
(
500
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
2
)
})
it
(
'
switchTab
'
,
async
()
=>
{
page
=
await
program
.
reLaunch
(
CURRENT_PAGE_PATH
)
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
await
page
.
callMethod
(
'
switchTab
'
)
await
page
.
waitFor
(
500
)
page
=
await
program
.
navigateTo
(
CURRENT_PAGE_PATH
)
await
page
.
waitFor
(
500
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
2
)
})
it
(
'
20 times navigateTo
'
,
async
()
=>
{
const
originPageStack
=
await
program
.
pageStack
()
page
=
await
program
.
navigateTo
(
CHILD1_PAGE_PATH
)
expect
(
page
.
path
).
toBe
(
CHILD1_PAGE_PATH
.
substring
(
1
))
page
=
await
program
.
navigateTo
(
CHILD2_PAGE_PATH
)
expect
(
page
.
path
).
toBe
(
CHILD2_PAGE_PATH
.
substring
(
1
))
page
=
await
program
.
navigateTo
(
CHILD1_PAGE_PATH
)
expect
(
page
.
path
).
toBe
(
CHILD1_PAGE_PATH
.
substring
(
1
))
page
=
await
program
.
navigateTo
(
CHILD2_PAGE_PATH
)
expect
(
page
.
path
).
toBe
(
CHILD2_PAGE_PATH
.
substring
(
1
))
page
=
await
program
.
navigateTo
(
CHILD1_PAGE_PATH
)
expect
(
page
.
path
).
toBe
(
CHILD1_PAGE_PATH
.
substring
(
1
))
page
=
await
program
.
navigateTo
(
CHILD2_PAGE_PATH
)
expect
(
page
.
path
).
toBe
(
CHILD2_PAGE_PATH
.
substring
(
1
))
page
=
await
program
.
navigateTo
(
CHILD1_PAGE_PATH
)
expect
(
page
.
path
).
toBe
(
CHILD1_PAGE_PATH
.
substring
(
1
))
page
=
await
program
.
navigateTo
(
CHILD2_PAGE_PATH
)
expect
(
page
.
path
).
toBe
(
CHILD2_PAGE_PATH
.
substring
(
1
))
page
=
await
program
.
navigateTo
(
CHILD1_PAGE_PATH
)
expect
(
page
.
path
).
toBe
(
CHILD1_PAGE_PATH
.
substring
(
1
))
page
=
await
program
.
navigateTo
(
CHILD2_PAGE_PATH
)
expect
(
page
.
path
).
toBe
(
CHILD2_PAGE_PATH
.
substring
(
1
))
page
=
await
program
.
navigateTo
(
CHILD1_PAGE_PATH
)
expect
(
page
.
path
).
toBe
(
CHILD1_PAGE_PATH
.
substring
(
1
))
page
=
await
program
.
navigateTo
(
CHILD2_PAGE_PATH
)
expect
(
page
.
path
).
toBe
(
CHILD2_PAGE_PATH
.
substring
(
1
))
page
=
await
program
.
navigateTo
(
CHILD1_PAGE_PATH
)
expect
(
page
.
path
).
toBe
(
CHILD1_PAGE_PATH
.
substring
(
1
))
page
=
await
program
.
navigateTo
(
CHILD2_PAGE_PATH
)
expect
(
page
.
path
).
toBe
(
CHILD2_PAGE_PATH
.
substring
(
1
))
page
=
await
program
.
navigateTo
(
CHILD1_PAGE_PATH
)
expect
(
page
.
path
).
toBe
(
CHILD1_PAGE_PATH
.
substring
(
1
))
page
=
await
program
.
navigateTo
(
CHILD2_PAGE_PATH
)
expect
(
page
.
path
).
toBe
(
CHILD2_PAGE_PATH
.
substring
(
1
))
page
=
await
program
.
navigateTo
(
CHILD1_PAGE_PATH
)
expect
(
page
.
path
).
toBe
(
CHILD1_PAGE_PATH
.
substring
(
1
))
page
=
await
program
.
navigateTo
(
CHILD2_PAGE_PATH
)
expect
(
page
.
path
).
toBe
(
CHILD2_PAGE_PATH
.
substring
(
1
))
page
=
await
program
.
navigateTo
(
CHILD1_PAGE_PATH
)
expect
(
page
.
path
).
toBe
(
CHILD1_PAGE_PATH
.
substring
(
1
))
page
=
await
program
.
navigateTo
(
CHILD2_PAGE_PATH
)
expect
(
page
.
path
).
toBe
(
CHILD2_PAGE_PATH
.
substring
(
1
))
const
newPageStack
=
await
program
.
pageStack
()
expect
(
newPageStack
.
length
-
originPageStack
.
length
).
toBe
(
20
)
})
})
pages/API/navigator/new-page/new-page-2.test.js
已删除
100644 → 0
浏览文件 @
ad182749
jest
.
setTimeout
(
30000
)
const
PAGE_PATH
=
'
/pages/API/navigator/new-page/new-page-2
'
const
INTERMEDIATE_PAGE_PATH
=
'
/pages/API/navigator/navigator
'
let
page
let
lifeCycleNum
describe
(
'
app-lifecycle
'
,
()
=>
{
it
(
'
onLaunch onShow
'
,
async
()
=>
{
page
=
await
program
.
reLaunch
(
INTERMEDIATE_PAGE_PATH
)
await
page
.
waitFor
(
1000
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
1100
)
})
it
(
'
onLastPageBackPress
'
,
async
()
=>
{
page
=
await
program
.
navigateBack
()
await
page
.
waitFor
(
1000
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
100
)
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
0
)
})
})
describe
(
'
page-lifecycle
'
,
()
=>
{
it
(
'
onLoad onShow onReady
'
,
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
1000
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
120
)
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
})
it
(
'
onPullDownRefresh
'
,
async
()
=>
{
await
page
.
callMethod
(
'
pullDownRefresh
'
)
await
page
.
waitFor
(
1500
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
10
)
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
})
it
(
'
onPageScroll onReachBottom
'
,
async
()
=>
{
await
program
.
pageScrollTo
(
2000
)
const
data
=
await
page
.
data
()
expect
(
data
.
isScrolled
).
toBe
(
true
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
10
)
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
})
it
(
'
onHide
'
,
async
()
=>
{
page
=
await
program
.
navigateTo
(
INTERMEDIATE_PAGE_PATH
)
await
page
.
waitFor
(
1000
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
-
10
)
page
=
await
program
.
navigateBack
()
await
page
.
waitFor
(
1000
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
0
)
})
it
(
'
onUnload
'
,
async
()
=>
{
page
=
await
program
.
redirectTo
(
INTERMEDIATE_PAGE_PATH
)
await
page
.
waitFor
(
1000
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
-
100
)
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
})
it
(
'
onBackPress
'
,
async
()
=>
{
page
=
await
program
.
navigateTo
(
PAGE_PATH
)
await
page
.
waitFor
(
1000
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
120
)
page
=
await
program
.
navigateBack
()
await
page
.
waitFor
(
1000
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
10
)
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
})
})
pages/API/navigator/new-page/new-page-2.uvue
已删除
100644 → 0
浏览文件 @
ad182749
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view class="uni-padding-wrap container">
<page-head title="new-page-2" />
<button @click="scrollToBottom">scrollToBottom</button>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script lang="uts">
import { state, setLifeCycleNum } from '@/store/index.uts'
export default {
data() {
return {
isScrolled: false,
}
},
onLoad(_ : Map<string, string>) {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 100)
},
onShow() {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10)
},
onReady() {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10)
},
onPullDownRefresh() {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10)
},
onPageScroll(_) {
// 自动化测试
this.isScrolled = true
},
onReachBottom() {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10)
},
onBackPress(_ : OnBackPressOptions) : boolean | null {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 10)
return null
},
onHide() {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 10)
},
onUnload() {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 100)
},
methods: {
// 自动化测试
getLifeCycleNum() : number {
return state.lifeCycleNum
},
// 自动化测试
setLifeCycleNum(num : number) {
setLifeCycleNum(num)
},
pullDownRefresh() {
uni.startPullDownRefresh({
success() {
setTimeout(() => {
uni.stopPullDownRefresh()
}, 1000)
},
})
},
scrollToBottom() {
uni.pageScrollTo({
scrollTop: 2000
})
},
},
}
</script>
<style>
.container {
height: 1200px;
}
</style>
pages/API/navigator/new-page/onLoad.test.js
浏览文件 @
7f69bda0
...
...
@@ -7,50 +7,50 @@ let page;
describe
(
"
onLoad
"
,
()
=>
{
it
(
"
adjustData
"
,
async
()
=>
{
page
=
await
program
.
reLaunch
(
INTERMEDIATE_PAGE_PATH
);
await
page
.
waitFor
(
500
);
await
page
.
waitFor
(
'
view
'
);
await
page
.
callMethod
(
"
navigateToOnLoadWithType
"
,
"
adjustData
"
);
await
page
.
waitFor
(
10
00
);
await
page
.
waitFor
(
5
00
);
const
image
=
await
program
.
screenshot
();
expect
(
image
).
toMatchImageSnapshot
();
});
it
(
"
navigateTo
"
,
async
()
=>
{
page
=
await
program
.
reLaunch
(
INTERMEDIATE_PAGE_PATH
);
await
page
.
waitFor
(
500
);
await
page
.
waitFor
(
'
view
'
);
await
page
.
callMethod
(
"
navigateToOnLoadWithType
"
,
"
navigateTo
"
);
await
page
.
waitFor
(
10
00
);
await
page
.
waitFor
(
5
00
);
page
=
await
program
.
currentPage
();
expect
(
page
.
path
).
toBe
(
TARGET_PAGE_PATH
.
substring
(
1
));
});
it
(
"
navigateBack
"
,
async
()
=>
{
page
=
await
program
.
reLaunch
(
INTERMEDIATE_PAGE_PATH
);
await
page
.
waitFor
(
500
);
await
page
.
waitFor
(
'
view
'
);
await
page
.
callMethod
(
"
navigateToOnLoadWithType
"
,
"
navigateBack
"
);
await
page
.
waitFor
(
1000
);
page
=
await
program
.
currentPage
();
await
page
.
waitFor
(
'
view
'
);
expect
(
page
.
path
).
toBe
(
INTERMEDIATE_PAGE_PATH
.
substring
(
1
));
});
it
(
"
redirectTo
"
,
async
()
=>
{
page
=
await
program
.
reLaunch
(
INTERMEDIATE_PAGE_PATH
);
await
page
.
waitFor
(
500
);
await
page
.
waitFor
(
'
view
'
);
await
page
.
callMethod
(
"
navigateToOnLoadWithType
"
,
"
redirectTo
"
);
await
page
.
waitFor
(
10
00
);
await
page
.
waitFor
(
5
00
);
page
=
await
program
.
currentPage
();
expect
(
page
.
path
).
toBe
(
TARGET_PAGE_PATH
.
substring
(
1
));
});
it
(
"
reLaunch
"
,
async
()
=>
{
page
=
await
program
.
reLaunch
(
INTERMEDIATE_PAGE_PATH
);
await
page
.
waitFor
(
500
);
await
page
.
waitFor
(
'
view
'
);
await
page
.
callMethod
(
"
navigateToOnLoadWithType
"
,
"
reLaunch
"
);
await
page
.
waitFor
(
10
00
);
await
page
.
waitFor
(
5
00
);
page
=
await
program
.
currentPage
();
expect
(
page
.
path
).
toBe
(
TARGET_PAGE_PATH
.
substring
(
1
));
});
it
(
"
switchTab
"
,
async
()
=>
{
page
=
await
program
.
reLaunch
(
INTERMEDIATE_PAGE_PATH
);
await
page
.
waitFor
(
500
);
await
page
.
waitFor
(
'
view
'
);
await
page
.
callMethod
(
"
navigateToOnLoadWithType
"
,
"
switchTab
"
);
await
page
.
waitFor
(
1000
);
page
=
await
program
.
currentPage
();
await
page
.
waitFor
(
'
view
'
);
expect
(
page
.
path
).
toBe
(
"
pages/tabBar/component
"
);
});
// toast 出现在 INTERMEDIATE_PAGE_PATH 页面(非 onLoad 生命周期所在页面)
...
...
@@ -66,7 +66,7 @@ describe("onLoad", () => {
// 同 toast
// it("showLoading", async () => {
// page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
// await page.waitFor(
500
);
// await page.waitFor(
'view'
);
// await page.callMethod("navigateToOnLoadWithType", "showLoading");
// await page.waitFor(1000);
// const image = await program.screenshot();
...
...
@@ -75,7 +75,7 @@ describe("onLoad", () => {
// 同 toast
// it("showModal", async () => {
// page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
// await page.waitFor(
500
);
// await page.waitFor(
'view'
);
// await page.callMethod("navigateToOnLoadWithType", "showModal");
// await page.waitFor(1000);
// const image = await program.screenshot();
...
...
@@ -84,7 +84,7 @@ describe("onLoad", () => {
// 同 toast
// it("showActionSheet", async () => {
// page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
// await page.waitFor(
500
);
// await page.waitFor(
'view'
);
// await page.callMethod("navigateToOnLoadWithType", "showActionSheet");
// await page.waitFor(1000);
// const image = await program.screenshot();
...
...
pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.test.js
浏览文件 @
7f69bda0
...
...
@@ -24,6 +24,8 @@ describe("setCustomNavigationBarColor", () => {
area
:
{
x
:
880
,
y
:
0
,
width
:
100
,
height
:
60
},
});
expect
(
image
).
toMatchImageSnapshot
();
const
lifeCycleNum
=
await
page
.
callMethod
(
"
getLifeCycleNum
"
);
expect
(
lifeCycleNum
-
originLifeCycleNum
).
toBe
(
2
);
});
it
(
"
setNavigationBarColor1
"
,
async
()
=>
{
...
...
@@ -34,5 +36,7 @@ describe("setCustomNavigationBarColor", () => {
area
:
{
x
:
880
,
y
:
0
,
width
:
100
,
height
:
60
},
});
expect
(
image
).
toMatchImageSnapshot
();
const
lifeCycleNum
=
await
page
.
callMethod
(
"
getLifeCycleNum
"
);
expect
(
lifeCycleNum
-
originLifeCycleNum
).
toBe
(
4
);
});
});
pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.uvue
浏览文件 @
7f69bda0
...
...
@@ -50,12 +50,15 @@ export default {
success() {
this.navigationBarTextColor = '#fff'
console.log('setNavigationBarColor success')
this.setLifeCycleNum(state.lifeCycleNum + 1)
},
fail() {
console.log('setNavigationBarColor success')
console.log('setNavigationBarColor fail')
this.setLifeCycleNum(state.lifeCycleNum - 1)
},
complete() {
console.log('setNavigationBarColor success')
console.log('setNavigationBarColor complete')
this.setLifeCycleNum(state.lifeCycleNum + 1)
}
})
},
...
...
@@ -66,12 +69,15 @@ export default {
success() {
this.navigationBarTextColor = '#000'
console.log('setNavigationBarColor success')
this.setLifeCycleNum(state.lifeCycleNum + 1)
},
fail() {
console.log('setNavigationBarColor success')
console.log('setNavigationBarColor fail')
this.setLifeCycleNum(state.lifeCycleNum - 1)
},
complete() {
console.log('setNavigationBarColor success')
console.log('setNavigationBarColor complete')
this.setLifeCycleNum(state.lifeCycleNum + 1)
}
})
},
...
...
pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js
浏览文件 @
7f69bda0
...
...
@@ -16,14 +16,18 @@ describe('setNavigationBarColor', () => {
expect
(
lifeCycleNum
).
toBe
(
originLifeCycleNum
)
})
it
(
'
setNavigationBarColor1
'
,
async
()
=>
{
await
page
.
callMethod
(
'
setNavigationBarColor1
'
)
const
image
=
await
program
.
screenshot
()
expect
(
image
).
toMatchImageSnapshot
()
})
it
(
'
setNavigationBarColor2
'
,
async
()
=>
{
await
page
.
callMethod
(
'
setNavigationBarColor2
'
)
const
image
=
await
program
.
screenshot
()
expect
(
image
).
toMatchImageSnapshot
()
})
it
(
"
setNavigationBarColor1
"
,
async
()
=>
{
await
page
.
callMethod
(
"
setNavigationBarColor1
"
);
const
image
=
await
program
.
screenshot
();
expect
(
image
).
toMatchImageSnapshot
();
const
lifeCycleNum
=
await
page
.
callMethod
(
"
getLifeCycleNum
"
);
expect
(
lifeCycleNum
-
originLifeCycleNum
).
toBe
(
2
);
});
it
(
"
setNavigationBarColor2
"
,
async
()
=>
{
await
page
.
callMethod
(
"
setNavigationBarColor2
"
);
const
image
=
await
program
.
screenshot
();
expect
(
image
).
toMatchImageSnapshot
();
const
lifeCycleNum
=
await
page
.
callMethod
(
"
getLifeCycleNum
"
);
expect
(
lifeCycleNum
-
originLifeCycleNum
).
toBe
(
4
);
});
})
pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue
浏览文件 @
7f69bda0
...
...
@@ -26,12 +26,15 @@ export default {
backgroundColor: '#00ff00',
success() {
console.log('setNavigationBarColor success')
this.setLifeCycleNum(state.lifeCycleNum + 1)
},
fail() {
console.log('setNavigationBarColor success')
console.log('setNavigationBarColor fail')
this.setLifeCycleNum(state.lifeCycleNum - 1)
},
complete() {
console.log('setNavigationBarColor success')
console.log('setNavigationBarColor complete')
this.setLifeCycleNum(state.lifeCycleNum + 1)
}
})
},
...
...
@@ -41,12 +44,15 @@ export default {
backgroundColor: '#ff0000',
success() {
console.log('setNavigationBarColor success')
this.setLifeCycleNum(state.lifeCycleNum + 1)
},
fail() {
console.log('setNavigationBarColor success')
console.log('setNavigationBarColor fail')
this.setLifeCycleNum(state.lifeCycleNum - 1)
},
complete() {
console.log('setNavigationBarColor success')
console.log('setNavigationBarColor complete')
this.setLifeCycleNum(state.lifeCycleNum + 1)
}
})
},
...
...
@@ -66,12 +72,3 @@ export default {
},
}
</script>
<style>
.direction-row {
flex-direction: row;
}
.label {
width: 190px;
}
</style>
pages/API/set-navigation-bar-title/set-navigation-bar-title.test.js
0 → 100644
浏览文件 @
7f69bda0
const
CURRENT_PAGE_PATH
=
"
/pages/API/set-navigation-bar-title/set-navigation-bar-title
"
;
describe
(
"
setNavigationBarColor
"
,
()
=>
{
let
page
;
let
originLifeCycleNum
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
navigateTo
(
CURRENT_PAGE_PATH
);
await
page
.
waitFor
(
1000
);
originLifeCycleNum
=
await
page
.
callMethod
(
"
getLifeCycleNum
"
);
});
afterAll
(
async
()
=>
{
await
page
.
callMethod
(
"
setLifeCycleNum
"
,
originLifeCycleNum
);
const
lifeCycleNum
=
await
page
.
callMethod
(
"
getLifeCycleNum
"
);
expect
(
lifeCycleNum
).
toBe
(
originLifeCycleNum
);
});
it
(
"
setNavigationBarTitle
"
,
async
()
=>
{
await
page
.
callMethod
(
"
setNavigationBarTitle
"
);
const
image
=
await
program
.
screenshot
();
expect
(
image
).
toMatchImageSnapshot
();
const
lifeCycleNum
=
await
page
.
callMethod
(
"
getLifeCycleNum
"
);
expect
(
lifeCycleNum
-
originLifeCycleNum
).
toBe
(
2
);
});
});
pages/API/set-navigation-bar-title/set-navigation-bar-title.uvue
0 → 100644
浏览文件 @
7f69bda0
<template>
<view>
<page-head title="setNavigationBarTitle"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<button @tap="setNavigationBarTitle" class="uni-btn">
设置当前页面的标题为 {{ newTitle }}
</button>
</view>
</view>
</template>
<script lang="uts">
import { state, setLifeCycleNum } from '@/store/index.uts'
export default {
data(){
return {
newTitle: 'new title'
}
},
methods: {
setNavigationBarTitle() {
uni.setNavigationBarTitle({
title: this.newTitle,
success() {
console.log('setNavigationBarTitle success')
this.setLifeCycleNum(state.lifeCycleNum + 1)
},
fail() {
console.log('setNavigationBarTitle success')
this.setLifeCycleNum(state.lifeCycleNum - 1)
},
complete() {
console.log('setNavigationBarTitle complete')
this.setLifeCycleNum(state.lifeCycleNum + 1)
}
})
},
// 自动化测试
getLifeCycleNum(): number {
return state.lifeCycleNum
},
// 自动化测试
setLifeCycleNum(num: number) {
setLifeCycleNum(num)
}
},
}
</script>
pages/component/button/button.test.js
浏览文件 @
7f69bda0
...
...
@@ -4,7 +4,7 @@ describe('Button.uvue', () => {
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
await
page
.
waitFor
(
'
view
'
)
})
it
(
'
click
'
,
async
()
=>
{
// TODO 待测试框架支持text的dispatchEvent
...
...
@@ -41,12 +41,10 @@ describe('Button.uvue', () => {
await
page
.
setData
({
type_enum_current
:
1
,
})
await
page
.
waitFor
(
500
)
expect
(
await
btn
.
property
(
'
type
'
)).
toBe
(
'
primary
'
)
await
page
.
setData
({
type_enum_current
:
2
,
})
await
page
.
waitFor
(
500
)
expect
(
await
btn
.
property
(
'
type
'
)).
toBe
(
'
warn
'
)
})
it
(
'
size
'
,
async
()
=>
{
...
...
@@ -55,7 +53,6 @@ describe('Button.uvue', () => {
await
page
.
setData
({
size_enum_current
:
1
,
})
await
page
.
waitFor
(
500
)
expect
(
await
btn
.
property
(
'
size
'
)).
toBe
(
'
mini
'
)
})
it
(
'
plain
'
,
async
()
=>
{
...
...
@@ -64,7 +61,6 @@ describe('Button.uvue', () => {
await
page
.
setData
({
plain_boolean
:
true
,
})
await
page
.
waitFor
(
500
)
expect
(
await
btn
.
property
(
'
plain
'
)).
toBe
(
true
)
})
it
(
'
disabled
'
,
async
()
=>
{
...
...
@@ -73,7 +69,6 @@ describe('Button.uvue', () => {
await
page
.
setData
({
disabled_boolean
:
true
,
})
await
page
.
waitFor
(
500
)
expect
(
await
btn
.
property
(
'
disabled
'
)).
toBe
(
true
)
})
})
pages/component/checkbox/checkbox.test.js
浏览文件 @
7f69bda0
...
...
@@ -8,7 +8,7 @@ function getData(key = '') {
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/component/checkbox/checkbox
'
)
await
page
.
waitFor
(
1000
)
await
page
.
waitFor
(
'
view
'
)
})
describe
(
'
Checkbox.uvue
'
,
()
=>
{
...
...
@@ -46,7 +46,6 @@ describe('Checkbox.uvue', () => {
await
page
.
setData
({
checked
:
false
,
})
await
page
.
waitFor
(
500
)
expect
(
await
cb
.
property
(
'
checked
'
)).
toBe
(
false
)
})
it
(
'
color
'
,
async
()
=>
{
...
...
@@ -55,7 +54,6 @@ describe('Checkbox.uvue', () => {
await
page
.
setData
({
color
:
'
#63acfc
'
,
})
await
page
.
waitFor
(
500
)
expect
(
await
cb
.
property
(
'
color
'
)).
toBe
(
'
#63acfc
'
)
})
it
(
'
disabled
'
,
async
()
=>
{
...
...
@@ -64,7 +62,6 @@ describe('Checkbox.uvue', () => {
await
page
.
setData
({
disabled
:
false
,
})
await
page
.
waitFor
(
500
)
expect
(
await
cb
.
property
(
'
disabled
'
)).
toBe
(
false
)
})
})
pages/component/general-attribute/general-attribute.test.js
浏览文件 @
7f69bda0
...
...
@@ -5,7 +5,7 @@ describe('general attribute', () => {
beforeAll
(
async
()
=>
{
page
=
await
program
.
navigateTo
(
PAGE_PATH
)
await
page
.
waitFor
(
1000
)
await
page
.
waitFor
(
'
view
'
)
})
it
(
"
class & style
"
,
async
()
=>
{
const
image
=
await
program
.
screenshot
();
...
...
@@ -20,7 +20,7 @@ describe('general attribute', () => {
it
(
"
ref
"
,
async
()
=>
{
const
button
=
await
page
.
$
(
"
.btn-ref
"
);
await
button
.
tap
();
await
page
.
waitFor
(
10
00
);
await
page
.
waitFor
(
5
00
);
const
image
=
await
program
.
screenshot
();
expect
(
image
).
toMatchImageSnapshot
();
});
...
...
pages/component/general-event/general-event.test.js
浏览文件 @
7f69bda0
...
...
@@ -5,7 +5,7 @@ describe('event trigger sequence', () => {
let
el
beforeAll
(
async
()
=>
{
page
=
await
program
.
navigateTo
(
PAGE_PATH
)
await
page
.
waitFor
(
1000
)
await
page
.
waitFor
(
'
view
'
)
el
=
await
page
.
$
(
'
.target
'
)
})
...
...
pages/component/input/input.test.js
浏览文件 @
7f69bda0
...
...
@@ -73,54 +73,54 @@ describe('component-native-input', () => {
// })
// })
// 测试placeholder
it
(
"
placeholder
"
,
async
()
=>
{
const
placeholder1
=
await
page
.
$
(
'
.uni-input-placeholder1
'
);
expect
(
await
placeholder1
.
property
(
"
placeholder-style
"
)).
toMatchObject
({
"
color
"
:
"
red
"
})
expect
(
await
placeholder1
.
property
(
"
placeholder
"
)).
toEqual
(
"
占位符文字颜色为红色
"
)
await
page
.
setData
({
inputPlaceHolderStyle
:
"
color:#CC00CC
"
,
})
expect
(
await
placeholder1
.
property
(
"
placeholder-style
"
)).
toMatchObject
({
"
color
"
:
"
#CC00CC
"
})
//
it("placeholder", async () => {
//
const placeholder1 = await page.$('.uni-input-placeholder1');
//
expect(await placeholder1.property("placeholder-style")).toMatchObject({
//
"color": "red"
//
})
//
expect(await placeholder1.property("placeholder")).toEqual("占位符文字颜色为红色")
//
await page.setData({
//
inputPlaceHolderStyle: "color:#CC00CC",
//
})
//
expect(await placeholder1.property("placeholder-style")).toMatchObject({
//
"color": "#CC00CC"
//
})
await
page
.
setData
({
inputPlaceHolderStyle
:
"
color:#CC19CC;background-color:#00b1c0
"
,
})
expect
(
await
placeholder1
.
property
(
"
placeholder-style
"
)).
toMatchObject
({
"
color
"
:
"
#CC19CC
"
,
"
backgroundColor
"
:
"
#00b1c0
"
})
//
await page.setData({
//
inputPlaceHolderStyle: "color:#CC19CC;background-color:#00b1c0",
//
})
//
expect(await placeholder1.property("placeholder-style")).toMatchObject({
//
"color": "#CC19CC",
//
"backgroundColor": "#00b1c0"
//
})
await
page
.
setData
({
inputPlaceHolderStyle
:
"
color:#CC19CC;background-color:#00b1c0;text-align:center;font-size:44px;font-weight:900
"
,
})
expect
(
await
placeholder1
.
property
(
"
placeholder-style
"
)).
toEqual
({
"
backgroundColor
"
:
"
#00b1c0
"
,
"
color
"
:
"
#CC19CC
"
,
"
fontSize
"
:
"
44px
"
,
"
fontWeight
"
:
"
900
"
,
"
textAlign
"
:
"
center
"
})
//
await page.setData({
//
inputPlaceHolderStyle: "color:#CC19CC;background-color:#00b1c0;text-align:center;font-size:44px;font-weight:900",
//
})
//
expect(await placeholder1.property("placeholder-style")).toEqual({
//
"backgroundColor": "#00b1c0",
//
"color": "#CC19CC",
//
"fontSize": "44px",
//
"fontWeight": "900",
//
"textAlign": "center"
//
})
const
placeholder2
=
await
page
.
$
(
'
.uni-input-placeholder2
'
);
expect
(
await
placeholder2
.
property
(
"
placeholder-class
"
)).
toMatchObject
({
"
backgroundColor
"
:
"
#008000
"
})
await
page
.
setData
({
inputPlaceHolderClass
:
"
uni-input-placeholder-class-ts
"
,
})
expect
(
await
placeholder2
.
property
(
"
placeholder-class
"
)).
toMatchObject
({
"
backgroundColor
"
:
"
#FFA500
"
})
expect
(
await
placeholder2
.
property
(
"
placeholder
"
)).
toEqual
(
"
占位符背景色为绿色
"
)
})
//
const placeholder2 = await page.$('.uni-input-placeholder2');
//
expect(await placeholder2.property("placeholder-class")).toMatchObject({
//
"backgroundColor": "#008000"
//
})
//
await page.setData({
//
inputPlaceHolderClass: "uni-input-placeholder-class-ts",
//
})
//
expect(await placeholder2.property("placeholder-class")).toMatchObject({
//
"backgroundColor": "#FFA500"
//
})
//
expect(await placeholder2.property("placeholder")).toEqual("占位符背景色为绿色")
//
})
it
(
"
disable
"
,
async
()
=>
{
const
input
=
await
page
.
$
(
'
.uni-input-disable
'
);
expect
(
await
input
.
property
(
"
disabled
"
)).
toBe
(
true
)
expect
(
await
input
.
property
(
"
disabled
"
)).
toBe
(
"
true
"
)
})
it
(
"
confirm-type
"
,
async
()
=>
{
...
...
@@ -139,10 +139,10 @@ describe('component-native-input', () => {
// await page.waitFor(500)
// })
//
it("afterAllTestScreenshot", async () => {
//
const image = await program.screenshot({
//
fullPage: true
//
})
//
expect(image).toMatchImageSnapshot()
//
})
it
(
"
afterAllTestScreenshot
"
,
async
()
=>
{
const
image
=
await
program
.
screenshot
({
fullPage
:
true
})
expect
(
image
).
toMatchImageSnapshot
()
})
});
pages/component/picker-view/picker-view.test.js
浏览文件 @
7f69bda0
...
...
@@ -8,7 +8,7 @@ function getData(key = '') {
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/component/picker-view/picker-view
'
)
await
page
.
waitFor
(
1000
)
await
page
.
waitFor
(
'
view
'
)
})
describe
(
'
PickerView.uvue
'
,
()
=>
{
...
...
@@ -44,7 +44,6 @@ describe('PickerView.uvue', () => {
await
page
.
setData
({
maskTopStyle
:
'
background: #ffffff;
'
,
})
await
page
.
waitFor
(
500
)
expect
(
await
el
.
property
(
'
mask-top-style
'
)).
toBe
(
'
background: #ffffff;
'
)
})
it
(
'
mask-bottom-style
'
,
async
()
=>
{
...
...
@@ -52,7 +51,6 @@ describe('PickerView.uvue', () => {
await
page
.
setData
({
maskBottomStyle
:
'
background: #ffffff;
'
,
})
await
page
.
waitFor
(
500
)
expect
(
await
el
.
property
(
'
mask-bottom-style
'
)).
toBe
(
'
background: #ffffff;
'
)
})
})
pages/component/progress/progress.test.js
浏览文件 @
7f69bda0
...
...
@@ -8,7 +8,7 @@ function getData(key = '') {
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/component/progress/progress
'
)
await
page
.
waitFor
(
1000
)
await
page
.
waitFor
(
'
view
'
)
})
describe
(
'
Progress.uvue
'
,
()
=>
{
...
...
@@ -17,14 +17,14 @@ describe('Progress.uvue', () => {
const
p1
=
await
page
.
$
(
'
.p1
'
)
const
p2
=
await
page
.
$
(
'
.p2
'
)
const
p3
=
await
page
.
$
(
'
.p3
'
)
page
.
callMethod
(
'
setProgress
'
)
await
page
.
callMethod
(
'
setProgress
'
)
await
page
.
waitFor
(
1000
)
expect
(
await
p
.
property
(
'
percent
'
)).
toEqual
(
20
)
expect
(
await
p1
.
property
(
'
percent
'
)).
toEqual
(
40
)
expect
(
await
p2
.
property
(
'
percent
'
)).
toEqual
(
60
)
expect
(
await
p3
.
property
(
'
percent
'
)).
toEqual
(
80
)
expect
(
await
getData
(
'
curPercent
'
)).
toEqual
(
20
)
page
.
callMethod
(
'
clearProgress
'
)
await
page
.
callMethod
(
'
clearProgress
'
)
await
page
.
waitFor
(
1000
)
expect
(
await
p
.
property
(
'
percent
'
)).
toEqual
(
0
)
expect
(
await
p1
.
property
(
'
percent
'
)).
toEqual
(
0
)
...
...
@@ -42,7 +42,6 @@ describe('Progress.uvue', () => {
await
page
.
setData
({
showInfo
:
false
})
await
page
.
waitFor
(
500
)
expect
(
await
el
.
property
(
'
show-info
'
)).
toEqual
(
false
)
})
it
(
'
border-radius
'
,
async
()
=>
{
...
...
@@ -51,7 +50,6 @@ describe('Progress.uvue', () => {
await
page
.
setData
({
borderRadius
:
5
})
await
page
.
waitFor
(
500
)
expect
(
await
el
.
property
(
'
border-radius
'
)).
toEqual
(
5
)
})
it
(
'
font-size
'
,
async
()
=>
{
...
...
@@ -60,7 +58,6 @@ describe('Progress.uvue', () => {
await
page
.
setData
({
fontSize
:
18
})
await
page
.
waitFor
(
500
)
expect
(
await
el
.
property
(
'
font-size
'
)).
toEqual
(
18
)
})
it
(
'
stroke-width
'
,
async
()
=>
{
...
...
@@ -69,7 +66,6 @@ describe('Progress.uvue', () => {
await
page
.
setData
({
strokeWidth
:
6
})
await
page
.
waitFor
(
500
)
expect
(
await
el
.
property
(
'
stroke-width
'
)).
toEqual
(
6
)
})
it
(
'
backgroundColor
'
,
async
()
=>
{
...
...
@@ -78,7 +74,6 @@ describe('Progress.uvue', () => {
await
page
.
setData
({
backgroundColor
:
"
#007aff
"
})
await
page
.
waitFor
(
500
)
expect
(
await
el
.
property
(
'
background-color
'
)).
toEqual
(
'
#007aff
'
)
})
})
pages/component/radio/radio.test.js
浏览文件 @
7f69bda0
...
...
@@ -8,7 +8,7 @@ function getData(key = '') {
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/component/radio/radio
'
)
await
page
.
waitFor
(
1000
)
await
page
.
waitFor
(
'
view
'
)
})
describe
(
'
Radio.uvue
'
,
()
=>
{
...
...
@@ -44,7 +44,6 @@ describe('Radio.uvue', () => {
await
page
.
setData
({
checked
:
false
,
})
await
page
.
waitFor
(
500
)
expect
(
await
radio
.
property
(
'
checked
'
)).
toBe
(
false
)
})
it
(
'
color
'
,
async
()
=>
{
...
...
@@ -53,7 +52,6 @@ describe('Radio.uvue', () => {
await
page
.
setData
({
color
:
'
#63acfc
'
,
})
await
page
.
waitFor
(
500
)
expect
(
await
radio
.
property
(
'
color
'
)).
toBe
(
'
#63acfc
'
)
})
it
(
'
disabled
'
,
async
()
=>
{
...
...
@@ -62,7 +60,6 @@ describe('Radio.uvue', () => {
await
page
.
setData
({
disabled
:
false
,
})
await
page
.
waitFor
(
500
)
expect
(
await
radio
.
property
(
'
disabled
'
)).
toBe
(
false
)
})
})
pages/component/textarea/textarea.test.js
浏览文件 @
7f69bda0
...
...
@@ -12,12 +12,12 @@ describe('component-native-textarea', () => {
});
it
(
'
focus
'
,
async
()
=>
{
expect
(
await
textarea
.
property
(
"
focus
"
)).
toBe
(
false
)
expect
(
await
textarea
.
property
(
"
focus
"
)).
toBe
(
"
false
"
)
await
page
.
setData
({
focus_boolean
:
true
,
})
await
page
.
waitFor
(
500
)
expect
(
await
textarea
.
property
(
"
focus
"
)).
toBe
(
true
)
expect
(
await
textarea
.
property
(
"
focus
"
)).
toBe
(
"
true
"
)
});
/* it("auto-height", async () => {
await page.setData({
...
...
pages/component/video/video.uvue
浏览文件 @
7f69bda0
...
...
@@ -223,7 +223,8 @@
},
pause: function () {
console.log("pause");
this.videoContext?.pause();
(uni.getElementById("video") as UniVideoElement).pause(); //as写法测试。注意id不对时as会崩溃
// this.videoContext?.pause();
},
seek: function (pos : number) {
console.log("seek -> " + pos);
...
...
@@ -239,7 +240,8 @@
},
stop: function () {
console.log("stop");
this.videoContext?.stop();
uni.getElementById<UniVideoElement>("video")?.stop(); //泛型写法测试
// this.videoContext?.stop();
},
sendDanmu: function (danmu : Danmu) {
console.log("sendDanmu -> " + danmu);
...
...
pages/tabBar/API.uvue
浏览文件 @
7f69bda0
...
...
@@ -102,12 +102,11 @@
url: 'navigator',
api: ["navigateTo", "reLaunch", "navigateBack", "redirectTo", "switchTab"]
},
/*
{
name: '设置导航条标题',
url: 'set-navigation-bar-title',
enable: false,
}, */
},
{
name: '设置导航条颜色',
url: 'set-navigation-bar-color',
...
...
@@ -254,6 +253,10 @@
name: '电量',
url: 'get-battery-info',
},
{
name: '安装Apk',
url: 'install-apk'
}
/* {
name: "打电话",
url: "make-phone-call",
...
...
pages/template/custom-tab-bar/custom-tab-bar-tab1.uvue
浏览文件 @
7f69bda0
...
...
@@ -35,7 +35,7 @@
uni.$emit('tabchange', e.detail.scrollTop)
},
scrollTop(top : number) {
(this.$refs["listView"] as Element).s
etAttribute('scrollTop', top)
(this.$refs["listView"] as Element).s
crollTop = top
}
}
}
...
...
pages/template/long-list/long-list-page.uvue
浏览文件 @
7f69bda0
<template>
<list-view ref="listView" class="list" :rebound="false" :scroll-y="true" :custom-nested-scroll="true"
<list-view ref="listView"
:id=id
class="list" :rebound="false" :scroll-y="true" :custom-nested-scroll="true"
@scrolltolower="loadData(null)">
<list-item class="list-item" v-for="(item, _) in dataList" :key="item.plugin_id">
<view class="list-item-icon">
...
...
@@ -60,6 +60,10 @@
preload: {
type: Boolean,
default: false
},
id: {
type: String,
default: ''
}
},
data() {
...
...
pages/template/long-list/long-list.uvue
浏览文件 @
7f69bda0
...
...
@@ -206,7 +206,9 @@
// 滚动到水平中心位置
const scroll_x = x - this.$swiperWidth / 2
this.$tabScrollView?.setAttribute('scrollLeft', scroll_x)
if(this.$tabScrollView !== null){
this.$tabScrollView!.scrollLeft = scroll_x
}
},
initSwiperItemData(index : number) {
if (!this.swiperList[index].preload) {
...
...
pages/template/long-list2/long-list2.uvue
浏览文件 @
7f69bda0
<template>
<scroll-view ref="pageScrollView" class="page" :scroll-y="true" :rebound="false"
@startnestedscroll="onStartNestedScroll" @nestedprescroll="onNestedPreScroll">
@startnestedscroll="onStartNestedScroll" @nestedprescroll="onNestedPreScroll"
:nested-scroll-child="nestedScrollChildId"
>
<swiper ref="header" indicator-dots="true" circular="true">
<swiper-item v-for="i in 3" :item-id="i">
<image src="/static/shuijiao.jpg" style="height: 240px;"></image>
...
...
@@ -20,7 +22,7 @@
<swiper ref="swiper" class="swiper-view" :current="swiperIndex" @transition="onSwiperTransition"
@animationfinish="onSwiperAnimationfinish">
<swiper-item class="swiper-item" v-for="(item, index) in swiperList" :key="index">
<long-page ref="longPage" :type="item.type" :preload="item.preload"></long-page>
<long-page ref="longPage" :
id="item.id" :
type="item.type" :preload="item.preload"></long-page>
</swiper-item>
</swiper>
</view>
...
...
@@ -39,6 +41,7 @@
type SwiperViewItem = {
type : string,
name : string,
id: string,
preload : boolean,
}
...
...
@@ -64,19 +67,23 @@
{
type: 'UpdatedDate',
name: '最新上架',
id: "list-id-1",
preload: true
} as SwiperViewItem,
{
type: 'FreeHot',
name: '免费热榜'
name: '免费热榜',
id: "list-id-2"
} as SwiperViewItem,
{
type: 'PaymentHot',
name: '付费热榜'
name: '付费热榜',
id: "list-id-3"
} as SwiperViewItem,
{
type: 'HotList',
name: '热门总榜'
name: '热门总榜',
id: "list-id-4"
} as SwiperViewItem
] as SwiperViewItem[],
swiperIndex: -1,
...
...
@@ -86,7 +93,8 @@
$tabScrollView: null as null | Element,
$indicatorNode: null as null | Element,
$swiperWidth: 0,
$swiperTabsRect: [] as SwiperTabsItem[]
$swiperTabsRect: [] as SwiperTabsItem[],
nestedScrollChildId: ""
}
},
onReady() {
...
...
@@ -201,13 +209,19 @@
// 滚动到水平中心位置
const scroll_x = x - this.$swiperWidth / 2
this.$tabScrollView?.setAttribute('scrollLeft', scroll_x)
if(this.$tabScrollView !== null){
this.$tabScrollView!.scrollLeft = scroll_x
}
},
initSwiperItemData(index : number) {
if (!this.swiperList[index].preload) {
this.swiperList[index].preload = true;
(this.$refs["longPage"]! as ComponentPublicInstance[])[index].$callMethod('loadData', null)
}
//swiper页面切换需要重新赋值嵌套滚动子元素的id
if (this.swiperList[index].id != null) {
this.nestedScrollChildId = this.swiperList[index].id
}
}
}
}
...
...
pages/template/swiper-list/swiper-list.uvue
浏览文件 @
7f69bda0
...
...
@@ -164,7 +164,9 @@
// 滚动到水平中心位置
const scroll_x = x - this.$swiperWidth / 2
this.$tabScrollView?.setAttribute('scrollLeft', scroll_x)
if(this.$tabScrollView !== null){
this.$tabScrollView!.scrollLeft = scroll_x
}
}
}
}
...
...
pages/template/swiper-list2/swiper-list2.uvue
浏览文件 @
7f69bda0
...
...
@@ -122,7 +122,9 @@
// 滚动到水平中心位置
const target_x = lerpNumber(current_node.offsetLeft, move_to_node.offsetLeft, percentage)
const center_x = target_x + move_to_node.offsetWidth / 2 - this.$swiperWidth / 2
this.$tabScrollView?.setAttribute('scrollLeft', center_x)
if(this.$tabScrollView !== null){
this.$tabScrollView!.scrollLeft = center_x
}
}
}
}
...
...
readme.md
浏览文件 @
7f69bda0
...
...
@@ -2,4 +2,14 @@ hello uni-app x 是 uni-app x 项目的演示工程。
uni-app x
[
开发文档
](
https://uniapp.dcloud.net.cn/uni-app-x/
)
### 自动化测试
项目下的js文件为自动化测试的nodejs文件,uni-app x手机端没有js引擎,是纯原生的。
[
自动化测试详见
](
https://uniapp.dcloud.net.cn/worktile/auto/quick-start.html
)
#### 页面截图对比测试
测试用例文件路径:pages/pages.test.js
其中 pages 变量中保存了所有需要截图对比测试的页面地址,如果有新增示例页面需要截图对比测试将页面地址添加到此变量即可。
**注意**
-
添加到截图对比测试的页面列表,修改内容涉及到变更,需要在测试平台删除基准图
-
动态内容页面不适合截图对比测试,不要添加到截图对比测试的页面列表中
static/test-apk/test.apk
0 → 100644
浏览文件 @
7f69bda0
文件已添加
uni_modules/uni-installApk/changelog.md
0 → 100644
浏览文件 @
7f69bda0
## 1.0.3(2023-10-27)
遵循UniError规范
## 1.0.2(2023-10-27)
修改文档
## 1.0.1(2023-10-27)
支持js层调用
## 1.0.0(2023-10-26)
安装apk的插件
uni_modules/uni-installApk/package.json
0 → 100644
浏览文件 @
7f69bda0
{
"id"
:
"uni-installApk"
,
"displayName"
:
"uni-installApk"
,
"version"
:
"1.0.3"
,
"description"
:
"uni-installApk"
,
"keywords"
:
[
"uni-installApk"
],
"repository"
:
""
,
"engines"
:
{
"HBuilderX"
:
"^3.94"
},
"dcloudext"
:
{
"type"
:
"uts"
,
"sale"
:
{
"regular"
:
{
"price"
:
"0.00"
},
"sourcecode"
:
{
"price"
:
"0.00"
}
},
"contact"
:
{
"qq"
:
""
},
"declaration"
:
{
"ads"
:
"无"
,
"data"
:
"无"
,
"permissions"
:
"android.permission.REQUEST_INSTALL_PACKAGES"
},
"npmurl"
:
""
},
"uni_modules"
:
{
"dependencies"
:
[],
"uni-ext-api"
:
{
"uni"
:
{
"installApk"
:
{
"name"
:
"installApk"
,
"app"
:
{
"js"
:
true
,
"kotlin"
:
true
,
"swift"
:
false
}
}
}
},
"encrypt"
:
[],
"platforms"
:
{
"cloud"
:
{
"tcb"
:
"y"
,
"aliyun"
:
"y"
},
"client"
:
{
"Vue"
:
{
"vue2"
:
"y"
,
"vue3"
:
"y"
},
"App"
:
{
"app-android"
:
"y"
,
"app-ios"
:
"n"
},
"H5-mobile"
:
{
"Safari"
:
"n"
,
"Android Browser"
:
"n"
,
"微信浏览器(Android)"
:
"n"
,
"QQ浏览器(Android)"
:
"n"
},
"H5-pc"
:
{
"Chrome"
:
"n"
,
"IE"
:
"n"
,
"Edge"
:
"n"
,
"Firefox"
:
"n"
,
"Safari"
:
"n"
},
"小程序"
:
{
"微信"
:
"n"
,
"阿里"
:
"n"
,
"百度"
:
"n"
,
"字节跳动"
:
"n"
,
"QQ"
:
"n"
,
"钉钉"
:
"n"
,
"快手"
:
"n"
,
"飞书"
:
"n"
,
"京东"
:
"n"
},
"快应用"
:
{
"华为"
:
"n"
,
"联盟"
:
"n"
}
}
}
}
}
\ No newline at end of file
uni_modules/uni-installApk/readme.md
0 → 100644
浏览文件 @
7f69bda0
# uni-installApk
## 使用说明
Android平台安装Apk
**注意: 3.95以下需要自定义基座**
### uni.installApk(options : InstallApkOptions):void
安装apk
参数说明
```
type InstallApkOptions = {
/**
* apk文件地址
*/
filePath : string,
/**
* 接口调用成功的回调函数
* @defaultValue null
*/
success ?: (res : any) => void,
/**
* 接口调用失败的回调函数
* @defaultValue null
*/
fail ?: (err : any) => void,
/**
* 接口调用结束的回调函数(调用成功、失败都会执行)
* @defaultValue null
*/
complete ?: (res : any) => void,
}
```
\ No newline at end of file
uni_modules/uni-installApk/utssdk/app-android/AndroidManifest.xml
0 → 100644
浏览文件 @
7f69bda0
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
package=
"io.dcloud.uni.installApk"
>
<uses-permission
android:name=
"android.permission.REQUEST_INSTALL_PACKAGES"
/>
</manifest>
\ No newline at end of file
uni_modules/uni-installApk/utssdk/app-android/index.uts
0 → 100644
浏览文件 @
7f69bda0
import { InstallApkOptions, InstallApkSuccess } from "../interface.uts"
import { InstallApkFailImpl } from "../unierror.uts"
import Intent from 'android.content.Intent';
import Build from 'android.os.Build';
import File from 'java.io.File';
import FileProvider from 'androidx.core.content.FileProvider';
import Context from 'android.content.Context';
import Uri from 'android.net.Uri';
export function installApk(options : InstallApkOptions) : void {
const context = UTSAndroid.getAppContext() as Context
const filePath = UTSAndroid.convert2AbsFullPath(options.filePath)
const apkFile = new File(filePath)
if (!apkFile.exists() && !apkFile.isFile()) {
let error = new InstallApkFailImpl(1300002);
options.fail?.(error)
options.complete?.(error)
return
}
const intent = new Intent()
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent.setAction(Intent.ACTION_VIEW)
if (Build.VERSION.SDK_INT >= 24) {
const authority = context.getPackageName() + ".dc.fileprovider"
const apkUri = FileProvider.getUriForFile(context, authority, apkFile)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setDataAndType(apkUri, "application/vnd.android.package-archive");
} else {
intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
}
context.startActivity(intent)
const success : InstallApkSuccess = {
errMsg: "success"
}
options.success?.(success)
options.complete?.(success)
}
\ No newline at end of file
uni_modules/uni-installApk/utssdk/app-ios/index.uts
0 → 100644
浏览文件 @
7f69bda0
uni_modules/uni-installApk/utssdk/interface.uts
0 → 100644
浏览文件 @
7f69bda0
export interface Uni {
/**
* installApk()
* @description
* 安装apk
* @param {InstallApkOptions}
* @return {void}
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4",
* "uniVer": "3.94+",
* "unixVer": "3.94+"
* },
* "ios": {
* "osVer": "x",
* "uniVer": "x",
* "unixVer": "x"
* }
* }
* }
* @example
```typescript
uni.installApk({
filePath: "/xx/xx/xx.apk",
complete: (res: any) => {
console.log("complete => " + JSON.stringify(res));
}
});
```
*/
installApk(options : InstallApkOptions) : void
}
export type InstallApkSuccess = {
/**
* 安装成功消息
*/
errMsg : string
}
export type InstallApkComplete = any
export type InstallApkSuccessCallback = (res : InstallApkSuccess) => void
/**
* 错误码
* - 1300002 找不到文件
*/
export type InstallApkErrorCode = 1300002
/**
* 网络请求失败的错误回调参数
*/
export interface InstallApkFail extends IUniError {
errCode : InstallApkErrorCode
};
export type InstallApkFailCallback = (err : InstallApkFail) => void
export type InstallApkCompleteCallback = (res : InstallApkComplete) => void
export type InstallApkOptions = {
/**
* apk文件地址
*/
filePath : string,
/**
* 接口调用成功的回调函数
* @defaultValue null
*/
success ?: InstallApkSuccessCallback | null,
/**
* 接口调用失败的回调函数
* @defaultValue null
*/
fail ?: InstallApkFailCallback | null,
/**
* 接口调用结束的回调函数(调用成功、失败都会执行)
* @defaultValue null
*/
complete ?: InstallApkCompleteCallback | null
}
\ No newline at end of file
uni_modules/uni-installApk/utssdk/unierror.uts
0 → 100644
浏览文件 @
7f69bda0
import { InstallApkErrorCode, InstallApkFail } from "./interface.uts"
/**
* 错误主题
*/
export const UniErrorSubject = 'uni-installApk';
/**
* 错误码
* @UniError
*/
export const UniErrors : Map<InstallApkErrorCode, string> = new Map([
/**
* 找不到文件
*/
[1300002, 'No such file'],
]);
export class InstallApkFailImpl extends UniError implements InstallApkFail {
constructor(errCode : InstallApkErrorCode) {
super();
this.errSubject = UniErrorSubject;
this.errCode = errCode;
this.errMsg = UniErrors[errCode] ?? "";
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录