diff --git a/.editorconfig b/.editorconfig
index 1a3af920b098c1460143e5f5ef5174933e03cb54..59fdeac038dea1d594512f915d0c6a8ba400591a 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -2,7 +2,7 @@ root = true
[*]
charset = utf-8
-end_of_line = lf
+end_of_line = auto
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
diff --git a/App.uvue b/App.uvue
index 7d07afab16b0268105253c5373d4dbfef892798e..225b3e7cd07080b5acc36bad5f423a2bb72a170b 100644
--- a/App.uvue
+++ b/App.uvue
@@ -29,6 +29,7 @@
} as OnShowOptions
},
onLaunch: function (res : OnLaunchOptions) {
+
this.globalData.launchOptions = res
// 自动化测试
@@ -47,15 +48,28 @@
// } as PerformanceObserverOptions)
// 统计上报 - 应用启动
- // uni.report({
- // name: 'uni-app-launch',
- // options: res,
- // success(res_data) {
- // console.log(res_data);
- // }, fail(err_data) {
- // console.log(err_data);
- // }
- // })
+ uni.report({
+ name: 'uni-app-launch',
+ options: res,
+ success(res_data) {
+ console.log(res_data);
+ }, fail(err) {
+ console.log(err);
+ }
+ })
+ // #ifdef APP
+ if (process.env.NODE_ENV !== 'development') { //真机运行可以注释此条件
+ uni.getPrivacySetting({
+ success(res1){
+ if(res1.needAuthorization){
+ uni.openDialogPage({
+ url: '/pages/component/button/privacy',
+ })
+ }
+ }
+ })
+ }
+ // #endif
},
onShow: function (res : OnShowOptions) {
this.globalData.onShowOption = res
@@ -73,14 +87,14 @@
console.log('App Show')
// 统计上报 - 应用显示
- // uni.report({
- // name: 'uni-app-show',
- // success(res_data) {
- // console.log(res_data);
- // }, fail(err_data) {
- // console.log(err_data);
- // }
- // })
+ uni.report({
+ name: 'uni-app-show',
+ success(res_data) {
+ console.log(res_data);
+ }, fail(err) {
+ console.log(err);
+ }
+ })
},
onHide: function () {
// 自动化测试
@@ -119,18 +133,18 @@
onExit() {
console.log('App Exit')
},
- // onError(err : any) {
- // // 统计上报 - 应用发生错误
- // uni.report({
- // name: 'uni-app-error',
- // options: err,
- // success(res) {
- // console.log(res);
- // }, fail(err) {
- // console.log(err);
- // }
- // })
- // },
+ onError(err : any) {
+ // 统计上报 - 应用发生错误
+ uni.report({
+ name: 'uni-app-error',
+ options: err,
+ success(res) {
+ console.log(res);
+ }, fail(err) {
+ console.log(err);
+ }
+ })
+ },
// #endif
methods: {
increasetLifeCycleNum() {
@@ -182,10 +196,5 @@
.uni-top-window uni-tabbar .uni-tabbar {
background-color: #fff !important;
}
-
- .uni-app--showleftwindow .uni-page-head-btn {
- display: none !important;
- }
-
/* #endif */
diff --git a/changelog.md b/changelog.md
index 51eefbede1b8b088599fb8be935b47f5f6a64d39..86bd1c81bd628582261bba7beecb7ef240a4a204 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,3 +1,9 @@
+## 1.0.32
+* update 4.31.2024102414-alpha
+
+## 1.0.31
+* update 4.28.2024092105-alpha
+
## 1.0.30
* update 4.27.2024091308-alpha
diff --git a/components/boolean-data/boolean-data.vue b/components/boolean-data/boolean-data.vue
index bf835cab8122ed72c75d72e31135298ec8b88d37..7b3440e02caa3f9ed77d64489afb9cc83dac4f86 100644
--- a/components/boolean-data/boolean-data.vue
+++ b/components/boolean-data/boolean-data.vue
@@ -6,6 +6,10 @@
type: String,
default: ''
},
+ disabled: {
+ type: Boolean,
+ default: false
+ },
defaultValue: {
type: Boolean,
default: false
@@ -32,7 +36,7 @@
{{ title }}
-
+
diff --git a/main.uts b/main.uts
index 932b57eae4d6e6c42833f4f6191d73b05fb5f14b..d7844ed0be2a9eab541216e08754098f7314f54e 100644
--- a/main.uts
+++ b/main.uts
@@ -1,26 +1,23 @@
-// 仅测试 console.log 时机问题
-import './test-main-console.uts'
-import { uniStat } from '@/uni_modules/uni-stat/plugin.uts'
-
-import App from './App.uvue'
+// 仅测试 console.log 时机问题
+import './test-main-console.uts'
+import { uniStat } from '@/uni_modules/uni-stat/plugin.uts'
+import App from './App.uvue'
+
+import { createSSRApp } from 'vue'
+
+// 统计配置
+const collectItems = {
+ uniStatPageLog: true
+}
+
+const statOptions = {
+ debug: true,
+ collectItems: collectItems,
+}
-import { createSSRApp } from 'vue'
-
-// 统计配置
-const collectItems = {
- uniStatPageLog: true
-}
-
-const statOptions = {
- debug: false,
- collectItems: collectItems,
-}
-
-
export function createApp() {
- const app = createSSRApp(App)
- app.use(uniStat, statOptions)
-
+ const app = createSSRApp(App)
+ app.use(uniStat, statOptions)
// app.mixin({
// onReady() {
// setTimeout(() => {
diff --git a/manifest.json b/manifest.json
index bacdc963887e135c2343d20f8ead950a87579977..4e439ee4c2f17c9479be6191a204899d8e4e1c7b 100644
--- a/manifest.json
+++ b/manifest.json
@@ -2,8 +2,8 @@
"name": "Hello uni-app x",
"appid": "__UNI__HelloUniAppX",
"description": "",
- "versionName": "1.5",
- "versionCode": 10500,
+ "versionName": "1.6",
+ "versionCode": 10600,
"uni-app-x": {},
/* 快应用特有相关 */
"quickapp": {},
diff --git a/package.json b/package.json
index 21bb6c1996bc61c22297a9a58f9873bbec2034a3..cc573431def7594e4f3cbaafcd36b771dcba5ea2 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"id": "hello-uniapp-x-alpha",
"name": "hello-uniapp-x-alpha",
"displayName": "hello-uniapp-x-alpha",
- "version": "1.0.30",
+ "version": "1.0.32",
"description": "演示 uni-app x 框架的组件、接口、模板",
"scripts": {
"check-commit": "node ./git-hooks/check-commit.cjs"
diff --git a/pages.json b/pages.json
index dbbd69713384ac94721133308cf1cac2bbefbbb2..fe4be91f43089f03f0d0a31fd5a1bcfbe12820a2 100644
--- a/pages.json
+++ b/pages.json
@@ -297,21 +297,21 @@
},
{
"path": "pages/component/web-view/web-view",
- "group": "0,8",
+ "group": "0,9",
"style": {
"navigationBarTitleText": "web-view"
}
},
{
"path": "pages/component/web-view/web-view/web-view-local",
- "group": "0,8",
+ "group": "0,9",
"style": {
"navigationBarTitleText": "本地网页"
}
},
{
"path": "pages/component/unicloud-db/unicloud-db/contacts/list",
- "group": "0,10",
+ "group": "0,11",
"style": {
"navigationBarTitleText": "联系人",
"enablePullDownRefresh": true
@@ -337,7 +337,7 @@
},
{
"path": "pages/component/unicloud-db/unicloud-db/mixin-datacom/mixin-datacom",
- "group": "0,10",
+ "group": "0,11",
"style": {
"navigationBarTitleText": "mixinDatacom"
}
@@ -370,12 +370,12 @@
"navigationBarTitleText": "Touch Events"
}
},
- {
- "path": "pages/component/global-events/touch-events-bubbles",
- "style": {
- "navigationBarTitleText": "Touch Events bubbles"
- }
- },
+ {
+ "path": "pages/component/global-events/touch-events-bubbles",
+ "style": {
+ "navigationBarTitleText": "Touch Events bubbles"
+ }
+ },
// #ifndef WEB
{
"path": "pages/component/nested-scroll-header/nested-scroll-header",
@@ -428,7 +428,7 @@
}
},
// #endif
- // #ifdef WEB
+ // #ifdef WEB || APP
{
"path": "pages/component/map/map",
"group": "0,6",
@@ -489,6 +489,34 @@
"navigationBarTitleText": "涂鸦"
}
},
+ // #ifndef WEB
+ {
+ "path": "pages/component/native-view/native-view",
+ "group": "0,2,4",
+ "style": {
+ "navigationBarTitleText": "native-view"
+ }
+ },
+ // #endif
+ // #ifndef WEB
+ {
+ "path": "pages/component/ad/ad",
+ "group": "0,8",
+ "style": {
+ "navigationBarTitleText": "ad | 信息流广告",
+ "enablePullDownRefresh": false
+ }
+ },
+ // #endif
+ // #ifndef WEB
+ {
+ "path": "pages/component/ad/list-view-ad",
+ "style": {
+ "navigationBarTitleText": "ad | 信息流广告",
+ "enablePullDownRefresh": false
+ }
+ },
+ // #endif
{
"path": "pages/tabBar/API",
"style": {
@@ -567,14 +595,14 @@
},
{
"path": "pages/API/set-navigation-bar-color/set-navigation-bar-color",
- "group": "1,2,1",
+ "group": "1,2,2",
"style": {
"navigationBarTitleText": "setNavigationBarColor | 设置导航条颜色"
}
},
{
"path": "pages/API/set-navigation-bar-title/set-navigation-bar-title",
- "group": "1,2,2",
+ "group": "1,2,3",
"style": {
"navigationBarTitleText": "setNavigationBarTitle | 设置导航条标题"
}
@@ -606,7 +634,7 @@
},
{
"path": "pages/API/pull-down-refresh/pull-down-refresh",
- "group": "1,2,4",
+ "group": "1,2,5",
"style": {
"navigationBarTitleText": "pullDownRefresh | 页面下拉刷新",
"enablePullDownRefresh": true
@@ -899,7 +927,7 @@
},
{
"path": "pages/API/page-scroll-to/page-scroll-to",
- "group": "1,2,5",
+ "group": "1,2,6",
"style": {
"navigationBarTitleText": "pageScrollTo | 将页面滚动到指定位置"
}
@@ -939,6 +967,13 @@
"navigationBarTitleText": "getWindowInfo | 获取窗口信息"
}
},
+ {
+ "path": "pages/API/get-window-info/window-area",
+ "style": {
+ "navigationBarTitleText": "window area",
+ "navigationStyle": "custom"
+ }
+ },
// #ifndef WEB
{
"path": "pages/API/element-draw/element-draw",
@@ -1024,13 +1059,15 @@
"enablePullDownRefresh": false
}
},
- {
- "path": "pages/API/virtual-payment/virtual-payment-uni-pay",
- "style": {
- "navigationBarTitleText": "苹果虚拟支付(uni-pay)",
- "enablePullDownRefresh": false
- }
- },
+ // #endif
+ // #ifdef APP-IOS
+ {
+ "path": "pages/API/virtual-payment/virtual-payment-uni-pay",
+ "style": {
+ "navigationBarTitleText": "苹果虚拟支付(uni-pay)",
+ "enablePullDownRefresh": false
+ }
+ },
// #endif
{
"path": "pages/API/request-payment/request-payment/order-detail",
@@ -1146,8 +1183,14 @@
"navigationBarTitleText": "provider | 服务提供商"
}
},
+ {
+ "path": "pages/API/privacy/privacy",
+ "group": "1,1,8",
+ "style": {
+ "navigationBarTitleText": "privacy | 隐私信息授权"
+ }
+ },
// #endif
- // #ifndef WEB
{
"path": "pages/API/uni-push/uni-push",
"group": "1,15,0",
@@ -1155,6 +1198,40 @@
"navigationBarTitleText": "推送"
}
},
+ {
+ "path": "pages/API/dialog-page/dialog-page",
+ "group": "1,2,1",
+ "style": {
+ "navigationBarTitleText": "dialogPage | 弹框页面"
+ }
+ },
+ {
+ "path": "pages/API/dialog-page/next-page",
+ "style": {
+ "navigationBarTitleText": "dialogNextPage"
+ }
+ },
+ {
+ "path": "pages/API/dialog-page/dialog-1",
+ "style": {
+ "navigationBarTitleText": "dialogPage1"
+ }
+ },
+ {
+ "path": "pages/API/dialog-page/dialog-2",
+ "style": {
+ "navigationBarTitleText": "dialogPage1"
+ }
+ },
+ // #ifndef WEB
+ {
+ "path": "pages/API/create-interstitial-ad/create-interstitial-ad",
+ "group": "1,13,1",
+ "style": {
+ "navigationBarTitleText": "createInterstitialAd | 插屏广告",
+ "enablePullDownRefresh": false
+ }
+ },
// #endif
{
"path": "pages/tabBar/CSS",
@@ -1254,6 +1331,13 @@
"navigationBarTitleText": "border动态修改"
}
},
+ {
+ "path": "pages/CSS/border/border-update",
+ "group": "2,13",
+ "style": {
+ "navigationBarTitleText": "border更新样式"
+ }
+ },
{
"path": "pages/CSS/box-shadow/box-shadow",
"group": "2,15",
@@ -1782,15 +1866,37 @@
"navigationBarTitleText": "",
"backgroundColorContent": "#fffae8"
}
+ },
+ // #ifdef APP-IOS
+ {
+ "path" : "pages/API/event-bus/uts-event-bus",
+ "style" :
+ {
+ "navigationBarTitleText" : ""
+ }
+ },
+ // #endif
+ // #ifdef APP
+ {
+ "path": "pages/component/button/privacy",
+ "style": {
+ "navigationBarTitleText": ""
+ }
}
+ // #endif
],
"globalStyle": {
+ // #ifdef APP-ANDROID
+ "hideStatusBar": false,
+ "hideBottomNavigationIndicator": false,
+ // #endif
"pageOrientation": "portrait",
"navigationBarTitleText": "Hello uniapp x",
"navigationBarTextStyle": "@navigationBarTextStyle",
"navigationBarBackgroundColor": "@navigationBarBackgroundColor",
"backgroundColorContent": "@backgroundColorContent",
- "backgroundColor": "@backgroundColor"
+ "backgroundColor": "@backgroundColor",
+ "backgroundTextStyle": "@backgroundTextStyle"
},
"tabBar": {
"color": "@tabBarColor",
@@ -1932,6 +2038,10 @@
{
"id": "component.basic-content.progress",
"name": "progress"
+ },
+ {
+ "id": "component.basic-content.native-view",
+ "name": "native-view"
}
]
},
@@ -2021,6 +2131,10 @@
"id": "component.canvas",
"name": "画布"
},
+ {
+ "id": "component.ad",
+ "name": "广告"
+ },
{
"id": "component.web-view",
"name": "网页"
@@ -2092,7 +2206,12 @@
{
"id": "api.base.provider",
"name": "provider"
- }
+ },
+ null,
+ {
+ "id": "api.base.privacy",
+ "name": "privacy"
+ }
]
},
{
@@ -2103,6 +2222,10 @@
"id": "api.page.navigator",
"name": "navigator"
},
+ {
+ "id": "api.page.dialogPage",
+ "name": "dialogPage"
+ },
{
"id": "api.page.setNavigationBarColor",
"name": "setNavigationBarColor"
@@ -2355,6 +2478,10 @@
{
"id": "api.ad.createRewardedVideoAd",
"name": "createRewardedVideoAd"
+ },
+ {
+ "id": "api.ad.createInterstitialAd",
+ "name": "createInterstitialAd"
}
]
},
diff --git a/pages/API/animation-frame/animation-frame.uvue b/pages/API/animation-frame/animation-frame.uvue
index 2dbe25e976068a22a7b3a1731c8b392ff064cf82..8c3d67c08729912fc87c4df01479a1afa6b0c36d 100644
--- a/pages/API/animation-frame/animation-frame.uvue
+++ b/pages/API/animation-frame/animation-frame.uvue
@@ -3,8 +3,8 @@
- FPS: {{FPSString}}
- FrameCount: {{testFrameCount}}
+ FPS: {{FPSString}}
+ FrameCount: {{testFrameCount}}
提示: 在当前测试例子中,每增加一次调用 requestAnimationFrame 帧率翻倍,cancelAnimationFrame 后恢复
@@ -14,7 +14,7 @@
data() {
return {
title: 'AnimationFrame',
- taskId: 0,
+ taskId: 0,
FPSString: '- / -ms',
lastTime: 0,
frameCount: 0,
@@ -29,25 +29,25 @@
methods: {
startRequestAnimationFrame() {
this.taskId = requestAnimationFrame((timestamp : number) => {
- this.updateFPS(timestamp)
+ this.updateFPS(timestamp)
this.testFrameCount++
this.startRequestAnimationFrame()
})
},
stopRequestAnimationFrame() {
- cancelAnimationFrame(this.taskId)
- this.lastTime = 0
- this.frameCount = 0
+ cancelAnimationFrame(this.taskId)
+ this.lastTime = 0
+ this.frameCount = 0
this.FPSString = '- / -ms'
- },
- updateFPS(timestamp : number) {
- this.frameCount++
- if (timestamp - this.lastTime >= 1000) {
- const timeOfFrame = (1000 / this.frameCount)
- this.FPSString = `${this.frameCount} / ${timeOfFrame.toFixed(3)}ms`
- this.frameCount = 0
- this.lastTime = timestamp
- }
+ },
+ updateFPS(timestamp : number) {
+ this.frameCount++
+ if (timestamp - this.lastTime >= 1000) {
+ const timeOfFrame = (1000 / this.frameCount)
+ this.FPSString = `${this.frameCount} / ${timeOfFrame.toFixed(3)}ms`
+ this.frameCount = 0
+ this.lastTime = timestamp
+ }
}
}
}
@@ -60,11 +60,11 @@
.frame-count {
margin-top: 15px;
- }
-
- .tips {
- font-size: 12px;
- margin-top: 30px;
- opacity: 0.7;
}
-
+
+ .tips {
+ font-size: 12px;
+ margin-top: 30px;
+ opacity: 0.7;
+ }
+
diff --git a/pages/API/choose-image/choose-image.uvue b/pages/API/choose-image/choose-image.uvue
index 0b208b1ea2d64053bc056ca770c987516b0c99d5..44ef1439db21fbe593a743706d507722da3b8fd6 100644
--- a/pages/API/choose-image/choose-image.uvue
+++ b/pages/API/choose-image/choose-image.uvue
@@ -1,294 +1,296 @@
-
-
-
-
-
-
-
-
-
-
- 图片来源
-
-
- {{sourceType[sourceTypeIndex]}}
-
-
-
-
-
- 图片质量
-
-
- {{sizeType[sizeTypeIndex]}}
-
-
-
-
-
- 数量限制
-
-
-
-
-
-
-
- 图像裁剪
-
-
-
-
-
-
-
-
- 图片质量(%)
-
-
-
-
-
-
-
- 裁剪宽度(px)
-
-
-
-
-
-
-
- 裁剪高度(px)
-
-
-
-
-
-
-
- 保留原宽高
-
-
-
-
-
-
-
-
-
-
- 点击可预览选好的图片
-
- {{imageList.length}}/{{countIndex+1}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/pages/API/choose-location/choose-location.uvue b/pages/API/choose-location/choose-location.uvue
index abe629534e0518034f3724a775ce9a2e626fbd0b..ed983109f1e5dfdc038c07c8fb0a19ec44133956 100644
--- a/pages/API/choose-location/choose-location.uvue
+++ b/pages/API/choose-location/choose-location.uvue
@@ -26,7 +26,7 @@
-
-
-
-
diff --git a/pages/API/cloud-storage/cloud-storage.uvue b/pages/API/cloud-storage/cloud-storage.uvue
index d6a3218713ed138c8c7c25fa9d8beb7ea060888b..2d813847fa8532df660b4cab767008831b4036bc 100644
--- a/pages/API/cloud-storage/cloud-storage.uvue
+++ b/pages/API/cloud-storage/cloud-storage.uvue
@@ -1,92 +1,92 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/pages/API/compass/compass.uvue b/pages/API/compass/compass.uvue
index 351c90d18cef3dc1806d2d175f9151d882947d11..048c2d0774c5463bf6baa3fac7e299425db86f86 100644
--- a/pages/API/compass/compass.uvue
+++ b/pages/API/compass/compass.uvue
@@ -1,86 +1,87 @@
-
-
-
-
-
- 旋转手机即可获取方位信息
-
-
-
-
-
- {{direction}}
- o
-
-
-
-
-
-
-
-
diff --git a/pages/API/compress-image/compress-image.uvue b/pages/API/compress-image/compress-image.uvue
index 07cf8278f101b74da3aecc083074b25eb82f5c53..cf1394ebf90d9e32a27754baa30f3f04f26e8cbe 100644
--- a/pages/API/compress-image/compress-image.uvue
+++ b/pages/API/compress-image/compress-image.uvue
@@ -50,8 +50,6 @@
quality: 80,
compressedWidth: null as number | null,
compressedHeight: null as number | null,
- width: "auto",
- height: "auto",
rotate: 0,
// 自动化测试
imageInfoForTest: null,
@@ -75,8 +73,6 @@
quality: this.quality,
compressedWidth: this.compressedWidth,
compressedHeight: this.compressedHeight,
- width: this.width,
- height: this.height,
rotate: this.rotate,
success: (res) => {
console.log("compressImage success", JSON.stringify(res));
@@ -137,12 +133,6 @@
onCompressedHeightConfirm(value : string) {
this.compressedHeight = parseInt(value);
},
- onWidthConfirm(value : string) {
- this.width = value;
- },
- onHeightConfirm(value : string) {
- this.height = value;
- },
onRotateConfirm(value : number) {
this.rotate = value;
},
diff --git a/pages/API/create-inner-audio-context/create-inner-audio-context.test.js b/pages/API/create-inner-audio-context/create-inner-audio-context.test.js
index 81faabde91b08bc1789e4c652860d686590c0190..a5d737dad48a9646f00be46e488ca39359e6ead1 100644
--- a/pages/API/create-inner-audio-context/create-inner-audio-context.test.js
+++ b/pages/API/create-inner-audio-context/create-inner-audio-context.test.js
@@ -10,45 +10,42 @@ describe('inner-audio', () => {
await page.waitFor('view');
});
- function getData(key = '') {
- return new Promise(async (resolve, reject) => {
- const data = await page.data()
- resolve(key ? data[key] : data)
- })
- }
-
it('onCanplay',async()=>{
await page.waitFor(1000)
await page.waitFor(async()=>{
- return await getData('isCanplay')
+ return await page.data('isCanplay')
})
- expect(await getData('buffered')).toBeGreaterThan(0)
+ expect(await page.data('buffered')).toBeGreaterThan(0)
})
it('play-onPlay-onTimeUpdate', async () => {
await page.callMethod('play')
- await page.waitFor(3000);
- expect(await getData('isPlaying')).toBeTruthy()
- console.log("duration:",await getData('duration'),"currentTime:",await getData('currentTime'))
- expect(await getData('duration')).toBeCloseTo(175.109, 0);
- // console.log("isPaused",await getData('isPaused'))
- // expect(await getData('currentTime')).toBeGreaterThan(0);
- // expect(await getData('isPaused')).toBeFalsy();
+ const waitTime = process.env.uniTestPlatformInfo.includes('chrome') ? 5000:3000
+ await page.waitFor(waitTime)
+ expect(await page.data('isPlaying')).toBeTruthy()
+ console.log("duration:",await page.data('duration'),"currentTime:",await page.data('currentTime'))
+ expect(await page.data('duration')).toBeCloseTo(175.109, 0);
+ // console.log("isPaused",await page.data('isPaused'))
+ // expect(await page.data('currentTime')).toBeGreaterThan(0);
+ // expect(await page.data('isPaused')).toBeFalsy();
});
it('seek-onSeeking-onSeeked', async () => {
await page.callMethod('onchange',20)
- await page.waitFor(500);
- expect(await getData('onSeekingTest')).toBeTruthy();
- // expect(await getData('onWaitingTest')).toBeTruthy();
- expect(await getData('onSeekedTest')).toBeTruthy();
+ const waitTime = process.env.uniTestPlatformInfo.includes('chrome') ? 1500:500
+ await page.waitFor(waitTime)
+ console.log("seek-onSeeking-onSeeked:",await page.data())
+ expect(await page.data('onSeekingTest')).toBeTruthy();
+ // expect(await page.data('onWaitingTest')).toBeTruthy();
+ // expect(await page.data('onSeekedTest')).toBeTruthy();
+ expect(await program.screenshot()).toSaveImageSnapshot();
});
it('pause-onPause', async () => {
await page.callMethod('pause')
await page.waitFor(500);
- expect(await getData('isPlaying')).toBeFalsy()
- // expect(await getData('isPaused')).toBeTruthy();
+ expect(await page.data('isPlaying')).toBeFalsy()
+ // expect(await page.data('isPaused')).toBeTruthy();
});
it('stop-onStop', async () => {
@@ -58,8 +55,8 @@ describe('inner-audio', () => {
await page.callMethod('stop')
await page.callMethod('stop')
await page.waitFor(1000);
- expect(await getData('isPlaying')).toBeFalsy()
- // expect(await getData('isPaused')).toBeTruthy();
+ expect(await page.data('isPlaying')).toBeFalsy()
+ // expect(await page.data('isPaused')).toBeTruthy();
});
it('onEnded', async () => {
@@ -67,7 +64,7 @@ describe('inner-audio', () => {
await page.waitFor(500);
await page.callMethod('play')
await page.waitFor(3000);
- // expect(await getData('isPlayEnd')).toBeTruthy();
+ // expect(await page.data('isPlayEnd')).toBeTruthy();
});
});
diff --git a/pages/API/create-inner-audio-context/create-inner-audio-context.uvue b/pages/API/create-inner-audio-context/create-inner-audio-context.uvue
index 0a3c73a968cc1ffb2663ec2d86ecc104481b19ec..1217da8d69828bba218babb6b1130b6002a8efa2 100644
--- a/pages/API/create-inner-audio-context/create-inner-audio-context.uvue
+++ b/pages/API/create-inner-audio-context/create-inner-audio-context.uvue
@@ -58,9 +58,9 @@
_isChanging: false,
_audioContext: null as InnerAudioContext | null,
// 自动化测试
- onSeekingTest:false,
- onSeekedTest:false,
- onWaitingTest:false
+ onSeekingTest: false,
+ onSeekedTest: false,
+ onWaitingTest: false
}
},
computed: {
@@ -129,7 +129,7 @@
}
this._audioContext!.onPlay(() => {
this.isPaused = false;
- console.log('开始播放',this.isPaused);
+ console.log('开始播放', this.isPaused);
});
this.onTimeUpdate()
this.onWaiting()
@@ -159,6 +159,7 @@
// console.log('onTimeUpdate:音频播放进度更新事件,currentTime',this._audioContext!.currentTime);
if (this._isChanging === true) { return; }
this.currentTime = this._audioContext!.currentTime || 0;
+ console.log('currentTime', this.currentTime);
if (this.currentTime > this.buffered) {
console.log('缓冲不足');
}
@@ -208,7 +209,7 @@
console.log('音频停止事件');
});
this.isPlaying = false;
- console.log('stop',this.isPaused);
+ console.log('stop', this.isPaused);
}
}
}
diff --git a/pages/API/create-inner-audio-context/inner-audio-format.uvue b/pages/API/create-inner-audio-context/inner-audio-format.uvue
index 9eec12ab2d87765e5714e46acebbf83d37cd6014..85f1bd7845ff5e4c326f725511cfca53f00b3794 100644
--- a/pages/API/create-inner-audio-context/inner-audio-format.uvue
+++ b/pages/API/create-inner-audio-context/inner-audio-format.uvue
@@ -1,134 +1,137 @@
-
-
-
-
- 支持的音频格式示例
-
-
- {{item.format}}
-
-
-
-
- 不支持的音频格式
-
-
- {{item.format}}
-
-
-
-
-
-
-
-
diff --git a/pages/API/create-inner-audio-context/inner-audio-path.uvue b/pages/API/create-inner-audio-context/inner-audio-path.uvue
index 3b9ad2ae460f1ed9f5aa75e8b974a8d932bba0a1..db4e20511a086485a2ba8efbcbe46fcb0a6ffb85 100644
--- a/pages/API/create-inner-audio-context/inner-audio-path.uvue
+++ b/pages/API/create-inner-audio-context/inner-audio-path.uvue
@@ -1,99 +1,101 @@
-
-
-
-
- 音频路径示例
-
-
- {{item.description}}
-
-
-
-
-
-
-
-
diff --git a/pages/API/create-interstitial-ad/create-interstitial-ad.uvue b/pages/API/create-interstitial-ad/create-interstitial-ad.uvue
new file mode 100644
index 0000000000000000000000000000000000000000..e0e1cbd7c999b44ba8e5e41d5c89ebac6e31a877
--- /dev/null
+++ b/pages/API/create-interstitial-ad/create-interstitial-ad.uvue
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
diff --git a/pages/API/create-request-permission-listener/create-request-permission-listener.uvue b/pages/API/create-request-permission-listener/create-request-permission-listener.uvue
index f192ff2cecd880a8674d52011951309179bb44dc..6afc9a2a8e8ce6ec5d58133bd3011e3383031c07 100644
--- a/pages/API/create-request-permission-listener/create-request-permission-listener.uvue
+++ b/pages/API/create-request-permission-listener/create-request-permission-listener.uvue
@@ -1,89 +1,90 @@
-
-
-
-
-
-
- 访问日历权限申请说明:
- uni-app x正在申请访问日历权限用于演示,允许或拒绝均不会获取任何隐私信息。
-
-
-
-
-
-
-
-
-
-
-
diff --git a/pages/API/create-rewarded-video-ad/create-rewarded-video-ad.uvue b/pages/API/create-rewarded-video-ad/create-rewarded-video-ad.uvue
index 120267f2d806daba6d4907e22f10d5e71b274615..0f768592da16f870a165b33bc9cff8b8d568eb93 100644
--- a/pages/API/create-rewarded-video-ad/create-rewarded-video-ad.uvue
+++ b/pages/API/create-rewarded-video-ad/create-rewarded-video-ad.uvue
@@ -1,67 +1,67 @@
-
-
-
-
-
-
-
-
diff --git a/pages/API/create-selector-query/create-selector-query.uvue b/pages/API/create-selector-query/create-selector-query.uvue
index 31c635206517f9840a0192255c0c0aa97d66bf9f..c0c2115fbbc7b76cf727917a4b8c84730e0b05c5 100644
--- a/pages/API/create-selector-query/create-selector-query.uvue
+++ b/pages/API/create-selector-query/create-selector-query.uvue
@@ -2,57 +2,57 @@
-
-
-
-
-
-
-
-
-
-
-
- left:
- {{nodeInfo.left}}
-
-
- top:
- {{nodeInfo.top}}
-
-
- right:
- {{nodeInfo.right}}
-
-
- bottom:
- {{nodeInfo.bottom}}
-
-
- width:
- {{nodeInfo.width}}
-
-
- height:
- {{nodeInfo.height}}
+
+
+
+
+
+
+
+
+
+
+
+ left:
+ {{nodeInfo.left}}
+
+
+ top:
+ {{nodeInfo.top}}
+
+
+ right:
+ {{nodeInfo.right}}
+
+
+ bottom:
+ {{nodeInfo.bottom}}
+
+
+ width:
+ {{nodeInfo.width}}
+
+
+ height:
+ {{nodeInfo.height}}
+
+
+ 子组件多根节点
+
+ 子组件多根节点(仅测试,用于验证查询是否超出范围)
+
+
+ 测试.fields
+ {{fieldsResultContainNode}}
+
+
+ 测试.node
+ {{nodeResultContainNode}}
+
+
-
- 子组件多根节点
-
- 子组件多根节点(仅测试,用于验证查询是否超出范围)
-
-
- 测试.fields
- {{fieldsResultContainNode}}
-
-
- 测试.node
- {{nodeResultContainNode}}
-
-
-
@@ -160,10 +160,10 @@
// test .fields
testFields() {
uni.createSelectorQuery().select('.rect1').fields({
- node: true
+ node: true
} as NodeField, (ret) => {
const isElement = (ret as NodeInfo).node instanceof UniElement
- if(isElement){
+ if (isElement) {
this.fieldsResultContainNode = true
} else {
this.fieldsResultContainNode = false
@@ -175,11 +175,11 @@
uni.createSelectorQuery().select('#canvas1').node((ret) => {
const isElement = (ret as NodeInfo).node instanceof UniElement
const isCanvasElement = ((ret as NodeInfo).node as UniCanvasElement).tagName == 'CANVAS'
- if(isElement && isCanvasElement){
- this.nodeResultContainNode = true
- } else {
- this.nodeResultContainNode = false
- }
+ if (isElement && isCanvasElement) {
+ this.nodeResultContainNode = true
+ } else {
+ this.nodeResultContainNode = false
+ }
}).exec()
},
}
diff --git a/pages/API/create-selector-query/nodes-info-child.uvue b/pages/API/create-selector-query/nodes-info-child.uvue
index fad48b47bd3b2de2f9bca03dc680486a4a552926..ebd7a4c12340ef8df05165987f8f134f50204b50 100755
--- a/pages/API/create-selector-query/nodes-info-child.uvue
+++ b/pages/API/create-selector-query/nodes-info-child.uvue
@@ -12,18 +12,18 @@
}
},
mounted() {
- uni.createSelectorQuery().in(this).select('.selector-query-child-view').boundingClientRect().exec((ret) => {
- if (ret.length == 1) {
- const nodeInfo = ret[0] as NodeInfo;
- this.top = nodeInfo.top!
+ uni.createSelectorQuery().in(this).select('.selector-query-child-view').boundingClientRect().exec((ret) => {
+ if (ret.length == 1) {
+ const nodeInfo = ret[0] as NodeInfo;
+ this.top = nodeInfo.top!
}
})
}
}
-
diff --git a/pages/API/create-selector-query/selector-query-child-multi.uvue b/pages/API/create-selector-query/selector-query-child-multi.uvue
index f11b1e1d320bde91547ac766316c5506bfe32806..d618b55bc629fe6d10d95554340ba6b55f6f69be 100644
--- a/pages/API/create-selector-query/selector-query-child-multi.uvue
+++ b/pages/API/create-selector-query/selector-query-child-multi.uvue
@@ -17,25 +17,25 @@
return {
text1: "",
text2: "",
- text3: "test-text-node",
- viewCount: 0,
- selectCount: 0,
+ text3: "test-text-node",
+ viewCount: 0,
+ selectCount: 0,
selectAllCount: 0,
show: false
}
},
mounted() {
uni.createSelectorQuery().in(this).select('.selector-query-view').boundingClientRect().exec((ret) => {
- this.text1 = JSON.stringify(ret, null, 2)
- if (ret.length == 1) {
- this.selectCount = ret.length
+ this.text1 = JSON.stringify(ret, null, 2)
+ if (ret.length == 1) {
+ this.selectCount = ret.length
+ }
+ })
+ uni.createSelectorQuery().in(this).selectAll('.selector-query-view').boundingClientRect().exec((ret) => {
+ this.text2 = JSON.stringify(ret, null, 2)
+ if (ret.length == 1) {
+ this.selectAllCount = (ret[0] as NodeInfo[]).length
}
- })
- uni.createSelectorQuery().in(this).selectAll('.selector-query-view').boundingClientRect().exec((ret) => {
- this.text2 = JSON.stringify(ret, null, 2)
- if (ret.length == 1) {
- this.selectAllCount = (ret[0] as NodeInfo[]).length
- }
})
}
}
diff --git a/pages/API/dialog-page/dialog-1.uvue b/pages/API/dialog-page/dialog-1.uvue
new file mode 100644
index 0000000000000000000000000000000000000000..8f7dccee7551039d03093fc8cf69c3dbd1e676cd
--- /dev/null
+++ b/pages/API/dialog-page/dialog-1.uvue
@@ -0,0 +1,166 @@
+
+
+
+ title: {{title}}
+ onBackPress return true
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/API/dialog-page/dialog-2.uvue b/pages/API/dialog-page/dialog-2.uvue
new file mode 100644
index 0000000000000000000000000000000000000000..bf12ae542be32dc573c71df34b1b1e2f8626bc45
--- /dev/null
+++ b/pages/API/dialog-page/dialog-2.uvue
@@ -0,0 +1,141 @@
+
+
+
+ title: {{title}}
+ onBackPress return false
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/API/dialog-page/dialog-page.test.js b/pages/API/dialog-page/dialog-page.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..7f8935d6bdce6f1e2d0ea8143d4b2b257699acb2
--- /dev/null
+++ b/pages/API/dialog-page/dialog-page.test.js
@@ -0,0 +1,288 @@
+jest.setTimeout(20000)
+
+const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
+const isWeb = platformInfo.startsWith('web')
+const FIRST_PAGE_PATH = '/pages/API/dialog-page/dialog-page'
+const NEXT_PAGE_PATH = '/pages/API/dialog-page/next-page'
+
+describe('dialog page', () => {
+ if (process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') {
+ it('skip app-webview', () => {
+ expect(1).toBe(1)
+ })
+ return
+ }
+
+ let page;
+ let initLifeCycleNum;
+ let lifecycleNum;
+ beforeAll(async () => {
+ page = await program.reLaunch(FIRST_PAGE_PATH)
+ await page.waitFor('view');
+ initLifeCycleNum = await page.callMethod('getLifeCycleNum');
+ await page.callMethod('setLifeCycleNum', 0)
+ lifecycleNum = await page.callMethod('getLifeCycleNum')
+ expect(lifecycleNum).toBe(0)
+ });
+
+ it('open dialog1', async () => {
+ await page.callMethod('openDialog1');
+ // 无法通过获取 dom 元素来判断是否打开了 dialogPage
+ await page.waitFor(1000)
+ if (isWeb) {
+ await page.waitFor(2000)
+ }
+ const image = await program.screenshot({
+ deviceShot: true,
+ area: {
+ x: 0,
+ y: 200,
+ }
+ });
+ expect(image).toSaveImageSnapshot();
+ lifecycleNum = await page.callMethod('getLifeCycleNum')
+ // 不应触发父页面的生命周期,应该触发:
+ // 1. openDialogPage success & complete callback
+ // 2. dialog page 生命周期
+ expect(lifecycleNum).toBe(7)
+ await page.callMethod('setLifeCycleNum', 0)
+ });
+
+ it('closeDialogPage', async () => {
+ await page.callMethod('closeDialog');
+ const image = await program.screenshot({
+ deviceShot: true,
+ area: {
+ x: 0,
+ y: 200,
+ }
+ });
+ expect(image).toSaveImageSnapshot();
+ // closeDialogPage success & complete callback 应被触发
+ // dialogPage onUnload 应被触发
+ lifecycleNum = await page.callMethod('getLifeCycleNum')
+ expect(lifecycleNum).toBe(-3)
+ await page.callMethod('setLifeCycleNum', 0)
+ })
+
+ it('openDialog with wrong path', async () => {
+ await page.callMethod('openDialog1WrongPath')
+ lifecycleNum = await page.callMethod('getLifeCycleNum')
+ expect(lifecycleNum).toBe(-3)
+ await page.callMethod('setLifeCycleNum', 0)
+ })
+
+ it('navigateTo nextPage & open Dialog', async () => {
+ await page.callMethod('goNextPageOpenDialog1')
+ await page.waitFor(2000)
+ if (isWeb) {
+ await page.waitFor(3000)
+ }
+ page = await program.currentPage()
+ expect(page.path).toBe(NEXT_PAGE_PATH.substring(1))
+ await page.waitFor(1000)
+ if (isWeb) {
+ await page.waitFor(2000)
+ }
+ const image = await program.screenshot({
+ deviceShot: true,
+ area: {
+ x: 0,
+ y: 200,
+ }
+ });
+ expect(image).toSaveImageSnapshot();
+ lifecycleNum = await page.callMethod('getLifeCycleNum')
+ expect(lifecycleNum).toBe(-4)
+ await page.callMethod('setLifeCycleNum', 0)
+ })
+
+ it('dialog1 navigateBack', async () => {
+ await program.navigateBack()
+ page = await program.currentPage()
+ // dialogPage onBackPress 返回 true, 应可以拦截 navigateBack
+ expect(page.path).toBe(NEXT_PAGE_PATH.substring(1))
+ const image = await program.screenshot({
+ deviceShot: true,
+ area: {
+ x: 0,
+ y: 200,
+ }
+ });
+ expect(image).toSaveImageSnapshot();
+ lifecycleNum = await page.callMethod('getLifeCycleNum')
+ // onBackPress 生命周期应该被触发
+ expect(lifecycleNum).toBe(1)
+ await page.callMethod('setLifeCycleNum', 0)
+ })
+
+ it('open dialog2', async () => {
+ await page.callMethod('openDialog2')
+ await page.waitFor(1000)
+ if (isWeb) {
+ await page.waitFor(2000)
+ }
+ lifecycleNum = await page.callMethod('getLifeCycleNum')
+ // 应触发前一个 dialogPage 的 onHide
+ expect(lifecycleNum).toBe(4)
+ await page.callMethod('setLifeCycleNum', 0)
+ })
+
+ it('closeDialogPage', async () => {
+ await page.callMethod('closeDialog')
+ lifecycleNum = await page.callMethod('getLifeCycleNum')
+ // 应触发 success & complete 回调
+ // 应触发 dialogPage 的 unload,下层的 dialogPage 会先 show 再 unload
+ expect(lifecycleNum).toBe(-7)
+
+ const image = await program.screenshot({
+ deviceShot: true,
+ area: {
+ x: 0,
+ y: 200,
+ }
+ });
+ expect(image).toSaveImageSnapshot();
+ await page.callMethod('setLifeCycleNum', 0)
+ })
+
+ it('open multiple dialog page', async () => {
+ await page.callMethod('openDialog1')
+ await page.waitFor(1000)
+ if (isWeb) {
+ await page.waitFor(2000)
+ }
+ const image1 = await program.screenshot({
+ deviceShot: true,
+ area: {
+ x: 0,
+ y: 200,
+ }
+ });
+ expect(image1).toSaveImageSnapshot();
+ lifecycleNum = await page.callMethod('getLifeCycleNum')
+ expect(lifecycleNum).toBe(4)
+
+ await page.callMethod('openDialog2')
+ await page.waitFor(1000)
+ if (isWeb) {
+ await page.waitFor(2000)
+ }
+ const image2 = await program.screenshot({
+ deviceShot: true,
+ area: {
+ x: 0,
+ y: 200,
+ }
+ });
+ expect(image2).toSaveImageSnapshot();
+ lifecycleNum = await page.callMethod('getLifeCycleNum')
+ expect(lifecycleNum).toBe(8)
+ await page.callMethod('setLifeCycleNum', 0)
+ })
+
+ it('openDialogPage to home page', async () => {
+ await page.callMethod('openDialogPage1ToHomePage')
+ await page.waitFor(1000)
+ if (isWeb) {
+ await page.waitFor(2000)
+ }
+ lifecycleNum = await page.callMethod('getLifeCycleNum')
+ expect(lifecycleNum).toBe(4)
+ await page.callMethod('setLifeCycleNum', 0)
+ })
+
+ it('dialog2 navigateBack', async () => {
+ await program.navigateBack()
+ page = await program.currentPage()
+ // dialogPage onBackPress 返回 true, 应可以拦截 navigateBack
+ expect(page.path).toBe(FIRST_PAGE_PATH.substring(1))
+ const image = await program.screenshot({
+ deviceShot: true,
+ area: {
+ x: 0,
+ y: 200,
+ }
+ });
+ expect(image).toSaveImageSnapshot();
+ lifecycleNum = await page.callMethod('getLifeCycleNum')
+ // onBackPress 生命周期应该被触发
+ expect(lifecycleNum).toBe(2)
+ await page.callMethod('setLifeCycleNum', 0)
+ })
+
+ it('close specified dialogPage', async () => {
+ await page.callMethod('openDialog2')
+ await page.waitFor(1000)
+ if (isWeb) {
+ await page.waitFor(2000)
+ }
+ const image1 = await program.screenshot({
+ deviceShot: true,
+ area: {
+ x: 0,
+ y: 200,
+ }
+ });
+ expect(image1).toSaveImageSnapshot();
+ lifecycleNum = await page.callMethod('getLifeCycleNum')
+ expect(lifecycleNum).toBe(4)
+
+ await page.callMethod('openDialog1')
+ await page.waitFor(1000)
+ if (isWeb) {
+ await page.waitFor(2000)
+ }
+ const image2 = await program.screenshot({
+ deviceShot: true,
+ area: {
+ x: 0,
+ y: 200,
+ }
+ });
+ expect(image2).toSaveImageSnapshot();
+ lifecycleNum = await page.callMethod('getLifeCycleNum')
+ expect(lifecycleNum).toBe(10)
+
+ await page.callMethod('closeSpecifiedDialog', 0)
+ const image3 = await program.screenshot({
+ deviceShot: true,
+ area: {
+ x: 0,
+ y: 200,
+ }
+ });
+ expect(image3).toSaveImageSnapshot();
+ lifecycleNum = await page.callMethod('getLifeCycleNum')
+ expect(lifecycleNum).toBe(7)
+
+ await page.callMethod('closeSpecifiedDialog', 1)
+ const image4 = await program.screenshot({
+ deviceShot: true,
+ area: {
+ x: 0,
+ y: 200,
+ }
+ });
+ expect(image4).toSaveImageSnapshot();
+ lifecycleNum = await page.callMethod('getLifeCycleNum')
+ expect(lifecycleNum).toBe(5)
+
+ await page.callMethod('closeSpecifiedDialog', 0)
+ const image5 = await program.screenshot({
+ deviceShot: true,
+ area: {
+ x: 0,
+ y: 200,
+ }
+ });
+ expect(image5).toSaveImageSnapshot();
+ lifecycleNum = await page.callMethod('getLifeCycleNum')
+ expect(lifecycleNum).toBe(2)
+ })
+
+
+ afterAll(async () => {
+ await page.callMethod('setLifeCycleNum', initLifeCycleNum)
+ });
+});
diff --git a/pages/API/dialog-page/dialog-page.uvue b/pages/API/dialog-page/dialog-page.uvue
new file mode 100644
index 0000000000000000000000000000000000000000..cd9768b71db33d6dda2d05ba853e8211b57f41af
--- /dev/null
+++ b/pages/API/dialog-page/dialog-page.uvue
@@ -0,0 +1,176 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/API/dialog-page/next-page.uvue b/pages/API/dialog-page/next-page.uvue
new file mode 100644
index 0000000000000000000000000000000000000000..c3e7a955bea5f6f3a7c6c8b16a87d2c4dfce1933
--- /dev/null
+++ b/pages/API/dialog-page/next-page.uvue
@@ -0,0 +1,111 @@
+
+
+
+
+
+
+
+
+
diff --git a/pages/API/download-file/download-file.uvue b/pages/API/download-file/download-file.uvue
index 48d1d9f947640afa32abf9ae0973f39e4f4752b1..370522685f01a9d2206c37dda1b4024ede66f4ba 100644
--- a/pages/API/download-file/download-file.uvue
+++ b/pages/API/download-file/download-file.uvue
@@ -18,14 +18,13 @@
-
-
-
diff --git a/pages/API/element-takesnapshot/element-takesnapshot.uvue b/pages/API/element-takesnapshot/element-takesnapshot.uvue
index 4f4d19f0aca3d7abd2fe8ee61c06f401197194de..655854bf57f9789957b0597cd66f66b8f67e49fc 100644
--- a/pages/API/element-takesnapshot/element-takesnapshot.uvue
+++ b/pages/API/element-takesnapshot/element-takesnapshot.uvue
@@ -1,76 +1,77 @@
-
-
-
-
- this is text
-
-
-
-
-
-
-
diff --git a/pages/API/env/env.uvue b/pages/API/env/env.uvue
index 5f57976fcf7ee914d74272fefdcd3bf34b99ba83..ba947128d0fa420442bb821c4bf9ec6bdc4f6de2 100644
--- a/pages/API/env/env.uvue
+++ b/pages/API/env/env.uvue
@@ -1,49 +1,51 @@
-
-
- 操作日志
- {{ log }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/pages/API/event-bus/event-bus.test.js b/pages/API/event-bus/event-bus.test.js
index f3aa542d21176af817e96614f99e0698dfacf540..0e5d377414be46f0a68198aa8ea48992ede8b04f 100644
--- a/pages/API/event-bus/event-bus.test.js
+++ b/pages/API/event-bus/event-bus.test.js
@@ -77,4 +77,13 @@ describe('event-bus', () => {
const l3 = (await page.data()).log.length
expect(l3).toBe(0)
})
+ it('test return id', async () => {
+ await page.callMethod('clear')
+ expect((await page.data()).log.length).toBe(0)
+ await page.callMethod('testReturnId')
+ const logs = await page.data('log')
+ expect(logs.length).toBe(2)
+ expect(logs[0]).toBe('触发 test-return-id $on fn')
+ expect(logs[1]).toBe('触发 test-return-id $once fn')
+ })
})
diff --git a/pages/API/event-bus/event-bus.uvue b/pages/API/event-bus/event-bus.uvue
index 274f7c1f54a297ed240409074453218add1962de..99395dd7a3f618467ac006048dbbd8c0123031c2 100644
--- a/pages/API/event-bus/event-bus.uvue
+++ b/pages/API/event-bus/event-bus.uvue
@@ -14,12 +14,13 @@
{{ item }}
-
-
-
- 接收到的 obj 参数:
- {{JSON.stringify(objArg)}}
-
+
+
+
+ 接收到的 obj 参数:
+ {{JSON.stringify(objArg)}}
+
+
@@ -49,7 +50,7 @@
uni.$on('test', this.fn2)
},
onObj() {
- uni.$on('test-obj', (res: UTSJSONObject) => {
+ uni.$on('test-obj', (res : UTSJSONObject) => {
this.objArg = res
})
},
@@ -71,6 +72,19 @@
clear() {
this.log.length = 0
},
+ testReturnId(){
+ const id1 = uni.$on('test-return-id', this.fn)
+ uni.$emit('test-return-id', '触发 test-return-id $on fn')
+ uni.$off('test-return-id', id1)
+ uni.$emit('test-return-id', '触发 test-return-id $on fn')
+
+ uni.$once('test-return-id', this.fn)
+ uni.$emit('test-return-id', '触发 test-return-id $once fn')
+ uni.$emit('test-return-id', '触发 test-return-id $once fn')
+ const id2 = uni.$once('test-id', this.fn)
+ uni.$off('test-return-id', id2)
+ uni.$emit('test-return-id', '触发 test-return-id $once fn')
+ }
},
}
diff --git a/pages/API/event-bus/uts-event-bus.test.js b/pages/API/event-bus/uts-event-bus.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..83bd671503f9987b31d110d1dba5dbccbd0c8c1b
--- /dev/null
+++ b/pages/API/event-bus/uts-event-bus.test.js
@@ -0,0 +1,85 @@
+// uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
+const PAGE_PATH = '/pages/API/event-bus/uts-event-bus'
+
+
+describe('event-bus', () => {
+ const platformInfo = process.env.uniTestPlatformInfo.toLowerCase()
+ if (!platformInfo.startsWith('ios')) {
+ it('pass', async () => {
+ expect(1).toBe(1);
+ });
+ return;
+ }
+
+ if (
+ platformInfo.indexOf('14.5') != -1 ||
+ platformInfo.indexOf('13.7') != -1 ||
+ platformInfo.indexOf('12.4') != -1
+ ) {
+ it('iOS 14.5 13.7 12.4 不支持依赖uts插件测试', () => {
+ expect(1).toBe(1)
+ })
+ return
+ }
+
+
+ let page
+ beforeAll(async () => {
+ page = await program.reLaunch(PAGE_PATH)
+ await page.waitFor('view')
+ })
+
+ it('on', async () => {
+ await page.callMethod('clear')
+ await page.callMethod('JsOnUts')
+ await page.callMethod('emitFromUts')
+ const l1 = (await page.data()).log.length
+ expect(l1).toBeGreaterThan(0)
+
+
+ await page.callMethod('clear')
+ await page.callMethod('offUts')
+ await page.callMethod('emitFromUts')
+ const l2 = (await page.data()).log.length
+ expect(l2).toBe(0)
+
+ await page.callMethod('clear')
+ await page.callMethod('UtsOnJS')
+ await page.callMethod('emitFormJS')
+ const l3 = (await page.data()).log.length
+ expect(l3).toBeGreaterThan(0)
+
+ await page.callMethod('clear')
+ await page.callMethod('offJs')
+ await page.callMethod('emitFormJS')
+ const l4 = (await page.data()).log.length
+ console.log(l4)
+ expect(l4).toBe(0)
+ await page.callMethod('clear')
+ })
+
+ it('once', async () => {
+ await page.callMethod('clear')
+ await page.callMethod('JsOnUtsOnce')
+ await page.callMethod('emitFromUts')
+ const l1 = (await page.data()).log.length
+ expect(l1).toBeGreaterThan(0)
+ await page.callMethod('clear')
+ await page.callMethod('emitFromUts')
+ const l2 = (await page.data()).log.length
+ expect(l2).toBe(0)
+
+ await page.callMethod('clear')
+ await page.callMethod('UtsOnJSOnce')
+ await page.callMethod('emitFormJS')
+ const l3 = (await page.data()).log.length
+ expect(l3).toBeGreaterThan(0)
+ await page.callMethod('clear')
+ await page.callMethod('emitFormJS')
+ const l4 = (await page.data()).log.length
+ expect(l4).toBe(0)
+
+ await page.callMethod('clear')
+ })
+
+})
diff --git a/pages/API/event-bus/uts-event-bus.uvue b/pages/API/event-bus/uts-event-bus.uvue
new file mode 100644
index 0000000000000000000000000000000000000000..6e554582b5c2770e2c4c3b5e30e62f0e9ea515f8
--- /dev/null
+++ b/pages/API/event-bus/uts-event-bus.uvue
@@ -0,0 +1,104 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 收到的消息:
+
+ {{ item }}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/API/exit/exit.uvue b/pages/API/exit/exit.uvue
index 9de09acdd6bfd4e033a551f7b6a7479ef5eb7609..4e614cec6c628230456a44f04958a93dc7d599d9 100644
--- a/pages/API/exit/exit.uvue
+++ b/pages/API/exit/exit.uvue
@@ -1,23 +1,23 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
diff --git a/pages/API/facial-recognition-meta-info/facial-recognition-meta-info.uvue b/pages/API/facial-recognition-meta-info/facial-recognition-meta-info.uvue
index 70fa9f509d8a56245f45769de2afaed782c9213b..fe7cee256f1f323aef698b3df39a10047fdb855b 100644
--- a/pages/API/facial-recognition-meta-info/facial-recognition-meta-info.uvue
+++ b/pages/API/facial-recognition-meta-info/facial-recognition-meta-info.uvue
@@ -1,88 +1,86 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/pages/API/get-app-authorize-setting/get-app-authorize-setting.uvue b/pages/API/get-app-authorize-setting/get-app-authorize-setting.uvue
index 0dd5349134f2954242ca05abebddf75164582461..4b9e3b71858d2aa6bac3b1cf5fa549e3ee38840a 100644
--- a/pages/API/get-app-authorize-setting/get-app-authorize-setting.uvue
+++ b/pages/API/get-app-authorize-setting/get-app-authorize-setting.uvue
@@ -1,23 +1,23 @@
-
-
-
- 是否授权使用相册
-
-
-
-
-
-
-
- 是否授权使用蓝牙
-
-
-
-
-
+
+
+
+ 是否授权使用相册
+
+
+
+
+
+
+
+ 是否授权使用蓝牙
+
+
+
+
+
是否授权使用摄像头
@@ -49,7 +49,7 @@
-
+
@@ -58,34 +58,34 @@
-
-
-
-
- 是否允许通知带有提醒
-
-
-
-
-
-
-
-
- 是否允许通知带有标记
-
-
-
-
-
-
-
- 是否允许通知带有声音
-
-
-
-
-
-
+
+
+
+
+ 是否允许通知带有提醒
+
+
+
+
+
+
+
+
+ 是否允许通知带有标记
+
+
+
+
+
+
+
+ 是否允许通知带有声音
+
+
+
+
+
+
@@ -99,15 +99,15 @@
data() {
return {
title: 'getAppAuthorizeSetting',
- cameraAuthorized: "",
+ cameraAuthorized: "",
albumAuthorized: "",
locationAuthorized: "",
locationAccuracy: "",
- microphoneAuthorized: "",
+ microphoneAuthorized: "",
bluetoothAuthorized: "",
- notificationAuthorized: "",
- notificationAlertAuthorized: "",
- notificationBadgeAuthorized: "",
+ notificationAuthorized: "",
+ notificationAlertAuthorized: "",
+ notificationBadgeAuthorized: "",
notificationSoundAuthorized: ""
}
},
@@ -115,19 +115,19 @@
},
methods: {
getAppAuthorizeSetting: function () {
- const res = uni.getAppAuthorizeSetting();
- this.albumAuthorized = res.albumAuthorized;
+ const res = uni.getAppAuthorizeSetting();
+ this.albumAuthorized = res.albumAuthorized;
this.bluetoothAuthorized = res.bluetoothAuthorized;
this.cameraAuthorized = res.cameraAuthorized;
this.locationAuthorized = res.locationAuthorized;
this.locationAccuracy = res.locationAccuracy ?? "unsupported";
this.microphoneAuthorized = res.microphoneAuthorized;
- this.notificationAuthorized = res.notificationAuthorized;
- // #ifdef APP-IOS
- this.notificationAlertAuthorized = res.notificationAlertAuthorized;
- this.notificationBadgeAuthorized = res.notificationBadgeAuthorized;
- this.notificationSoundAuthorized = res.notificationSoundAuthorized;
- // #endif
+ this.notificationAuthorized = res.notificationAuthorized;
+ // #ifdef APP-IOS
+ this.notificationAlertAuthorized = res.notificationAlertAuthorized;
+ this.notificationBadgeAuthorized = res.notificationBadgeAuthorized;
+ this.notificationSoundAuthorized = res.notificationSoundAuthorized;
+ // #endif
}
}
diff --git a/pages/API/get-app-base-info/get-app-base-info.uvue b/pages/API/get-app-base-info/get-app-base-info.uvue
index e51cee92a5e25584564c614b5a87030dd82bcb24..d275141619f8eada10173df0fb25bc12bb11c480 100644
--- a/pages/API/get-app-base-info/get-app-base-info.uvue
+++ b/pages/API/get-app-base-info/get-app-base-info.uvue
@@ -1,14 +1,14 @@
-
-
-
- {{item.label}}
-
-
- {{ item.value == '' ? '未获取' : item.value }}
-
+
+
+
+ {{item.label}}
+
+
+ {{ item.value == '' ? '未获取' : item.value }}
+
@@ -18,50 +18,50 @@
-
+ .uni-pd {
+ padding-left: 15px;
+ }
+
diff --git a/pages/API/get-app/get-app.test.js b/pages/API/get-app/get-app.test.js
index 598a639b7f93ee90d14b3880fbb16067f0f72ab2..c8306e5250b969f81a0be62a90dda64f827011fe 100644
--- a/pages/API/get-app/get-app.test.js
+++ b/pages/API/get-app/get-app.test.js
@@ -1,4 +1,6 @@
const PAGE_PATH = '/pages/API/get-app/get-app'
+const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
+const isAndroid = platformInfo.startsWith('android')
describe('getApp', () => {
let page = null
@@ -47,4 +49,8 @@ describe('getApp', () => {
expect(newLifeCycleNum - oldLifeCycleNum).toBe(100)
await page.callMethod('setLifeCycleNum', oldLifeCycleNum)
})
-})
+ it('getAndroidApplication', async () => {
+ const res = await page.callMethod('getAndroidApplication')
+ expect(res).toBe(isAndroid)
+ })
+})
diff --git a/pages/API/get-app/get-app.uvue b/pages/API/get-app/get-app.uvue
index 7ece0a803f49feeda26f93fbd4be7cb16f4fa3be..f1c2b08aa3ea7fbf2300ceb0516ed31bd5447c7d 100644
--- a/pages/API/get-app/get-app.uvue
+++ b/pages/API/get-app/get-app.uvue
@@ -39,6 +39,10 @@
increase lifeCycleNum
lifeCycleNum: {{ lifeCycleNum }}
+
+ androidApplication is null: {{ androidApplication == null }}
@@ -97,6 +101,7 @@
} as MyGlobalData,
newGlobalDataFuncRes: '',
lifeCycleNum: 0,
+ androidApplication: null as any | null
}
},
onReady() {
@@ -161,12 +166,17 @@
},
_increasetLifeCycleNum: function () {
const app = getApp()
- app.increasetLifeCycleNum()
+ app.vm!.increasetLifeCycleNum()
this.lifeCycleNum = state.lifeCycleNum
},
// 自动化测试
setLifeCycleNum(num : number) {
setLifeCycleNum(num)
+ },
+ getAndroidApplication() : boolean {
+ const app = getApp()
+ this.androidApplication = app.getAndroidApplication()
+ return this.androidApplication !== null
}
},
}
@@ -180,4 +190,4 @@
.hr {
border-bottom: 1px solid #ccc;
}
-
+
diff --git a/pages/API/get-battery-info/get-battery-info.uvue b/pages/API/get-battery-info/get-battery-info.uvue
index 870b7269633a41ea82865854b2376b9453f4e995..b33591db0bf5c7647b7fcbea18568c10c38fb999 100644
--- a/pages/API/get-battery-info/get-battery-info.uvue
+++ b/pages/API/get-battery-info/get-battery-info.uvue
@@ -1,33 +1,33 @@
-
-
- 当前电量:{{level}}%
- 是否充电中:{{isCharging}}
-
-
-
-
diff --git a/pages/API/get-current-pages/get-current-pages.test.js b/pages/API/get-current-pages/get-current-pages.test.js
index 7e377cb849f66e5350198efd2492d5df997bd4be..227cd677cbfd611df8f638948ecb7d06bab27e9a 100644
--- a/pages/API/get-current-pages/get-current-pages.test.js
+++ b/pages/API/get-current-pages/get-current-pages.test.js
@@ -1,5 +1,5 @@
const HOME_PAGE_PATH = '/pages/tabBar/component'
-const PAGE_PATH = '/pages/API/get-current-pages/get-current-pages'
+const PAGE_PATH = '/pages/API/get-current-pages/get-current-pages?test=123'
describe('getCurrentPages', () => {
let page
@@ -25,8 +25,6 @@ describe('getCurrentPages', () => {
expect(data.checked).toBe(true)
})
it('page-style', async () => {
- page = await program.navigateTo(PAGE_PATH)
-
await page.callMethod('getPageStyle')
await page.waitFor(200)
const isEnablePullDownRefresh1 = (await page.data()).currentPageStyle.enablePullDownRefresh
@@ -63,4 +61,25 @@ describe('getCurrentPages', () => {
return 'get-current-pages-test-js-get-current-pages-page-style-after-set-page-style'
}});
})
+ it('$page', async () => {
+ await page.setData({testing: true})
+ const res = await page.callMethod('check$page')
+ expect(res).toBe(true)
+ })
+ it('getParentPage', async () => {
+ const res = await page.callMethod('checkGetParentPage')
+ expect(res).toBe(true)
+ })
+ it('getDialogPages', async () => {
+ const res = await page.callMethod('checkGetDialogPages')
+ expect(res).toBe(true)
+ })
+ it('getElementById', async () => {
+ const res = await page.callMethod('checkGetElementById')
+ expect(res).toBe(true)
+ })
+ it('getAndroidView', async () => {
+ const res = await page.callMethod('checkGetAndroidView')
+ expect(res).toBe(true)
+ })
})
diff --git a/pages/API/get-current-pages/get-current-pages.uvue b/pages/API/get-current-pages/get-current-pages.uvue
index 82fa34f74040b5cec20ef8c74f006bf81ed569c3..3e0e3d08e764be6849c8bfe76df880f830149ff2 100644
--- a/pages/API/get-current-pages/get-current-pages.uvue
+++ b/pages/API/get-current-pages/get-current-pages.uvue
@@ -12,14 +12,29 @@
index: {{ index }}, route: {{ page.route }}
+
+
+
+
+
-
+
- {{item.key}}:
- {{currentPageStyle[item.key]}}
+ {{ item.key }}:
+ {{
+ currentPageStyle[item.key]
+ }}
- {{item2}}
+ {{ item2 }}
-
+
@@ -60,6 +77,7 @@
pages: [] as Page[],
PageStyleArray: PageStyleArray as PageStyleItem[],
currentPageStyle: {} as UTSJSONObject,
+ testing: false
}
},
computed: {
@@ -67,7 +85,15 @@
return JSON.stringify(this.currentPageStyle)
}
},
- onLoad() {
+ onLoad(options : OnLoadOptions) {
+ // #ifndef APP-ANDROID
+ if (options instanceof UTSJSONObject) {
+ this.checked = true
+ }
+ // #endif
+ // #ifdef APP-ANDROID
+ this.checked = true
+ // #endif
this.getPageStyle();
},
onPullDownRefresh() {
@@ -83,7 +109,7 @@
this.pages.length = 0
const pages = getCurrentPages()
this.pages.push(new Page(pages[0].route))
- if (this.pages[0].route.includes('/tabBar/')) {
+ if (this.checked && (this.pages[0].route.includes('/tabBar/') || this.pages[0].route == '/')) {
this.checked = true
}
for (let i = 1; i < pages.length; i++) {
@@ -112,25 +138,86 @@
getPageStyle() : UTSJSONObject {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
- this.currentPageStyle = currentPage.$getPageStyle()
+ this.currentPageStyle = currentPage.getPageStyle()
return this.currentPageStyle;
},
setPageStyle(style : UTSJSONObject) {
console.log('setPageStyle:', style);
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
- currentPage.$setPageStyle(style);
+ currentPage.setPageStyle(style);
},
goSetDisablePullDownRefresh() {
uni.navigateTo({
url: '/pages/API/get-current-pages/set-page-style-disable-pull-down-refresh'
});
- }
- // getCurrentPage(): Page {
- // const pages = getCurrentPages();
- // const currentPage = pages[pages.length - 1];
- // return currentPage;
- // }
+ },
+ getCurrentPage() : UniPage {
+ const pages = getCurrentPages()
+ return pages[pages.length - 1]
+ },
+ check$page() : boolean {
+ const page = this.getCurrentPage()
+ let res = this.$page === page
+ if (this.testing && res) {
+ res = page.options['test'] == '123'
+ if (res) {
+ // #ifdef WEB
+ res = page.route == '/pages/API/get-current-pages/get-current-pages'
+ // #endif
+ // #ifndef WEB
+ res = page.route == 'pages/API/get-current-pages/get-current-pages'
+ // #endif
+ }
+ }
+ console.log('check $page', res)
+ uni.showToast(res ? { title: 'check success' } : { title: 'check fail', icon: 'error' })
+ return res
+ },
+ checkGetParentPage() : boolean {
+ const page = this.getCurrentPage()
+ const parentPage = page.getParentPage()
+ const res = parentPage == null
+ console.log('check getParentPage', res)
+ uni.showToast(res ? { title: 'check success' } : { title: 'check fail', icon: 'error' })
+ return res
+ },
+ checkGetDialogPages() : boolean {
+ const page = this.getCurrentPage()
+ const dialogPages = page.getDialogPages()
+ const res = Array.isArray(dialogPages) && dialogPages.length == 0
+ uni.showToast(res ? { title: 'check success' } : { title: 'check fail', icon: 'error' })
+ console.log('check getDialogPages', res)
+ return res
+ },
+ checkGetElementById() : boolean {
+ const page = this.getCurrentPage()
+ const element = page.getElementById('check-get-element-by-id-btn')
+ let res = element != null
+ // #ifndef APP-ANDROID
+ if (res) {
+ const elPage = element!.getPage()
+ console.log('elPage', elPage)
+ res = elPage === page
+ }
+ // #endif
+ console.log('check getElementById', res)
+ uni.showToast(res ? { title: 'check success' } : { title: 'check fail', icon: 'error' })
+ return res
+ },
+ checkGetAndroidView() : boolean {
+ const page = this.getCurrentPage()
+ const androidView = page.getAndroidView()
+ // #ifdef APP-ANDROID
+ const res = androidView != null
+ // #endif
+ // #ifndef APP-ANDROID
+ const res = androidView == null
+ // #endif
+ console.log('check getAndroidView', res)
+ uni.showToast(res ? { title: 'check success' } : { title: 'check fail', icon: 'error' })
+ return res
+ },
},
}
@@ -175,4 +262,4 @@
.radio-value {
margin-left: 10px;
}
-
+
diff --git a/pages/API/get-current-pages/page-style.uts b/pages/API/get-current-pages/page-style.uts
index 1c70d11773e2fc8a6c6aa7640ba590abab3d5dbf..62bf13a326f5fb8db598ebaa14c7765f63f41137 100644
--- a/pages/API/get-current-pages/page-style.uts
+++ b/pages/API/get-current-pages/page-style.uts
@@ -1,8 +1,8 @@
export type PageStyleItem = {
key : string
- type : string
- value: Array
+ type : string
+ value : Array
}
export const PageStyleArray = [
@@ -70,4 +70,14 @@ export const PageStyleArray = [
key: "navigationBarAutoBackButton",
type: "boolean",
value: [true, false]
+ },
+ {
+ key: "hideStatusBar",
+ type: "boolean",
+ value: [true, false]
+ },
+ {
+ key: "hideBottomNavigationIndicator",
+ type: "boolean",
+ value: [true, false]
}] as PageStyleItem[]
diff --git a/pages/API/get-current-pages/set-page-style-disable-pull-down-refresh.uvue b/pages/API/get-current-pages/set-page-style-disable-pull-down-refresh.uvue
index f190e74ef85553723e27a05d117d4c2d91e0ad91..2d8d995b9cbeab6683343f75116348af1e5c6267 100644
--- a/pages/API/get-current-pages/set-page-style-disable-pull-down-refresh.uvue
+++ b/pages/API/get-current-pages/set-page-style-disable-pull-down-refresh.uvue
@@ -44,13 +44,13 @@
getPageStyle() {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
- this.currentPageStyle = currentPage.$getPageStyle();
+ this.currentPageStyle = currentPage.getPageStyle();
},
setPageStyle(enable : boolean) {
// 目前仅支持 enablePullDownRefresh
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
- currentPage.$setPageStyle({
+ currentPage.setPageStyle({
enablePullDownRefresh: enable
});
this.enablePullDownRefreshStatus = enable
@@ -95,4 +95,4 @@
margin-top: 15px;
opacity: .8;
}
-
+
diff --git a/pages/API/get-element-by-id/get-element-by-id-multiple-root-node.uvue b/pages/API/get-element-by-id/get-element-by-id-multiple-root-node.uvue
index 6e868a0cf93ab2b4b8701c5de4371c60f3a2abce..b252eeaec2ee00740be7ab970eee1d1cb03d4e2c 100644
--- a/pages/API/get-element-by-id/get-element-by-id-multiple-root-node.uvue
+++ b/pages/API/get-element-by-id/get-element-by-id-multiple-root-node.uvue
@@ -1,5 +1,5 @@
-
+
this is text
this is view
@@ -9,7 +9,7 @@
+
@@ -44,4 +44,4 @@
}
}
}
-
+
diff --git a/pages/API/get-element-by-id/get-element-by-id.uvue b/pages/API/get-element-by-id/get-element-by-id.uvue
index 338471498a35b7a0dbcc25d9b4ad841c482dd475..dc6653c158c824f231edfceb941d358390b52c13 100644
--- a/pages/API/get-element-by-id/get-element-by-id.uvue
+++ b/pages/API/get-element-by-id/get-element-by-id.uvue
@@ -26,7 +26,7 @@
homePagePath: '/pages/tabBar/component',
launchOptionsPath: '',
}
- },
+ },
methods: {
getElementByNotExistId() : Element | null {
return uni.getElementById('not-exist-id')
@@ -49,12 +49,12 @@
},
goMultipleRootNode() {
uni.navigateTo({ url: '/pages/API/get-element-by-id/get-element-by-id-multiple-root-node' })
- },
- //自动化测试获取text元素的offsetLeft属性值
- getTextOffsetLeft(): number {
- const text = uni.getElementById('text')!
- return text.offsetLeft
+ },
+ //自动化测试获取text元素的offsetLeft属性值
+ getTextOffsetLeft() : number {
+ const text = uni.getElementById('text')!
+ return text.offsetLeft
}
}
}
-
+
diff --git a/pages/API/get-enter-options-sync/get-enter-options-sync.uvue b/pages/API/get-enter-options-sync/get-enter-options-sync.uvue
index a53ca63138ffe97f35bf301d0dca5796fac0fbff..c2b5ca1f3d1d10fb093053c746f0805b761aaae6 100644
--- a/pages/API/get-enter-options-sync/get-enter-options-sync.uvue
+++ b/pages/API/get-enter-options-sync/get-enter-options-sync.uvue
@@ -11,16 +11,17 @@
diff --git a/pages/API/get-file-system-manager/get-file-system-manager.test.js b/pages/API/get-file-system-manager/get-file-system-manager.test.js
index 1160298985dbcaafc9415db2aed48f4eacbb33f9..9b2ef897493f15e21a299af51d63a33aa2b22e7f 100644
--- a/pages/API/get-file-system-manager/get-file-system-manager.test.js
+++ b/pages/API/get-file-system-manager/get-file-system-manager.test.js
@@ -3,1406 +3,1484 @@ const PAGE_PATH = '/pages/API/get-file-system-manager/get-file-system-manager'
describe('ExtApi-FileManagerTest', () => {
- if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') {
- it('dummyTest', () => {
- expect(1).toBe(1)
- })
- return
- }
- let page;
- let mBasePath;
- let mGlobalTempPath;
- let mGlobalRootPath
-
-
- function getData(key = '') {
- return new Promise(async (resolve, reject) => {
- const data = await page.data()
- resolve(key ? data[key] : data)
- })
- }
-
-
- beforeAll(async () => {
- page = await program.reLaunch(PAGE_PATH)
- await page.waitFor(600);
- });
-
- async function isDone() {
- let isDone = await page.waitFor(async () => {
- return await page.data('done')
- })
- await page.setData({
- done: false
- })
- return isDone
- }
-
- it('USER_DATA_PATH test', async () => {
- // 测试 USER_DATA_PATH
- let globalUserDataPath = await getData('globalUserDataPath')
- mBasePath = await getData('basePath')
- mGlobalRootPath = await getData('globalRootPath')
- mGlobalTempPath = await getData('globalTempPath')
-
- await page.setData({
- logAble: false,
- recursiveVal: true,
- copyToBasePath: globalUserDataPath,
- basePath: globalUserDataPath,
- rmDirFile: 'a',
- readDir: 'a',
- writeFile: 'a/1.txt',
- readFile: 'a/1.txt',
- unlinkFile: 'a/1.txt',
- writeFileContent: '锄禾日当午,汗滴禾下土,谁知盘中餐,粒粒皆辛苦'
- })
-
- // 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败
- const btnUnLinkFileButton = await page.$('#btn-clear-file')
- await btnUnLinkFileButton.tap()
- await isDone()
-
-
- // 清除文件夹
- const btnRmDirButton = await page.$('#btn-remove-dir')
- await btnRmDirButton.tap()
- await isDone()
- // 重新创建测试目录
- const btnMkdDirButton = await page.$('#btn-mkdir')
- await btnMkdDirButton.tap()
- await isDone()
-
- const btnReadDirButton = await page.$('#btn-read-dir')
- await btnReadDirButton.tap()
- await isDone()
-
-
- // 期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
- let fileListComplete = await getData('fileListComplete')
- expect(JSON.stringify(fileListComplete)).toEqual('[]')
- let fileListSuccess = await getData('fileListSuccess')
- expect(JSON.stringify(fileListSuccess)).toEqual('[]')
-
- // 先测试 recursive = false 文件夹创建,期望失败
- await page.setData({
- recursiveVal: false,
- mkdirFile: 'a/b/c'
- })
-
-
- await btnMkdDirButton.tap()
- await isDone()
-
-
- let lastFailError = await getData('lastFailError')
- expect(lastFailError.errCode).toEqual(1300002)
- expect(lastFailError.errMsg).toEqual('no such file or directory')
- let lastCompleteError = await getData('lastCompleteError')
- expect(lastCompleteError.errCode).toEqual(1300002)
- expect(lastCompleteError.errMsg).toEqual('no such file or directory')
-
-
- // 测试 recursive = true 期望文件夹创建成功
- await page.setData({
- recursiveVal: true
- })
- await btnMkdDirButton.tap()
- await isDone()
-
- await btnReadDirButton.tap()
- await isDone()
-
- // 期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
- fileListComplete = await getData('fileListComplete')
- expect(JSON.stringify(fileListComplete)).toEqual("[\"b\"]")
- fileListSuccess = await getData('fileListSuccess')
- expect(JSON.stringify(fileListSuccess)).toEqual("[\"b\"]")
-
- // 测试写入文件
- const btnWriteFileButton = await page.$('#btn-write-file')
- await btnWriteFileButton.tap()
- await isDone()
- // 检查目录列表数量
- await btnReadDirButton.tap()
- await isDone()
- fileListComplete = await getData('fileListComplete')
- fileListComplete.sort()
- expect(JSON.stringify(fileListComplete)).toEqual("[\"1.txt\",\"b\"]")
- fileListSuccess = await getData('fileListSuccess')
- fileListSuccess.sort()
- expect(JSON.stringify(fileListSuccess)).toEqual("[\"1.txt\",\"b\"]")
- // 获取和对比 文件内容
- const btnReadFileButton = await page.$('#btn-read-file')
- await btnReadFileButton.tap()
- await isDone()
- let readFileRet = await getData('readFileRet')
- expect(readFileRet).toEqual("锄禾日当午,汗滴禾下土,谁知盘中餐,粒粒皆辛苦")
-
- // 更换文件内容 获取和对比 文件md5和sha1
- await page.setData({
- writeFileContent: "If you were a teardrop;In my eye,For fear of losing you,I would never cry.And if the golden sun,Should cease to shine its light,Just one smile from you,Would make my whole world bright.",
- getFileInfoAlgorithm: "md5"
- })
- await btnWriteFileButton.tap()
- await isDone()
-
- await btnReadFileButton.tap()
- await isDone()
- readFileRet = await getData('readFileRet')
- expect(readFileRet).toEqual(
- "If you were a teardrop;In my eye,For fear of losing you,I would never cry.And if the golden sun,Should cease to shine its light,Just one smile from you,Would make my whole world bright."
- )
-
- const btnGetFileInfoButton = await page.$('#btn-get-file-info')
- await btnGetFileInfoButton.tap()
- await isDone()
-
- let getFileInfoSize = await getData('getFileInfoSize')
- expect(getFileInfoSize).toEqual(185)
- let getFileInfoDigest = await getData('getFileInfoDigest')
- expect(getFileInfoDigest).toEqual("29ddd02ed3c38ccebb98884eda082cb1")
- // 切换为 sha1
- await page.setData({
- getFileInfoAlgorithm: "sha1"
- })
-
- await btnGetFileInfoButton.tap()
- await isDone()
-
- getFileInfoSize = await getData('getFileInfoSize')
- expect(getFileInfoSize).toEqual(185)
- getFileInfoDigest = await getData('getFileInfoDigest')
- expect(getFileInfoDigest).toEqual("ebef4e75783e0db499fc260d120e695005bead8a")
-
- // 测试 copyfile
- await page.setData({
-
- copyFromFile: "a/1.txt",
- copyToFile: "a/2.txt"
- })
- const btnCopyFileButton = await page.$('#btn-copy-file')
- await btnCopyFileButton.tap()
- await isDone()
-
-
- await btnReadDirButton.tap()
- await isDone()
-
- // 1.txt 2.txt 两个文件都存在
- fileListComplete = await getData('fileListComplete')
- fileListComplete.sort()
- expect(JSON.stringify(fileListComplete)).toEqual("[\"1.txt\",\"2.txt\",\"b\"]")
- fileListSuccess = await getData('fileListSuccess')
- fileListSuccess.sort()
- expect(JSON.stringify(fileListSuccess)).toEqual("[\"1.txt\",\"2.txt\",\"b\"]")
-
- // 测试 rename
- await page.setData({
- renameFromFile: "a/2.txt",
- renameToFile: "a/3.txt"
- })
-
- const btnRenameFileButton = await page.$('#btn-rename-file')
- await btnRenameFileButton.tap()
- await isDone()
-
- await btnReadDirButton.tap()
- await isDone()
-
- // 1.txt 3.txt 两个文件都存在
- fileListComplete = await getData('fileListComplete')
- fileListComplete.sort()
- expect(JSON.stringify(fileListComplete)).toEqual("[\"1.txt\",\"3.txt\",\"b\"]")
- fileListSuccess = await getData('fileListSuccess')
- fileListSuccess.sort()
- expect(JSON.stringify(fileListSuccess)).toEqual("[\"1.txt\",\"3.txt\",\"b\"]")
- });
-
- it('TEMP_PATH test', async () => {
- // 测试 TEMP_PATH
- let globalTempPath = await getData('globalTempPath')
-
- let version = process.env.uniTestPlatformInfo
- version = parseInt(version.split(" ")[1])
- let testDirName = "我们经历了一场兵慌马乱的战争.1@2#3$4%5^6&7*8(9)0+-qwertyuiopasdfghjklzxcvbnm;,"
- if (version < 6) {
- // android 6 以下文件名不能包含特殊字符
- testDirName = "我们经历了一场兵慌马乱的战争"
- }
-
- await page.setData({
- logAble: false,
- recursiveVal: true,
- basePath: globalTempPath,
- copyToBasePath: globalTempPath,
- rmDirFile: 'a',
- mkdirFile: 'a',
- unlinkFile: 'a/' + testDirName + '/中文路径/张三/name/中文文件.mock'
- })
-
-
- // 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败
- const btnUnLinkFileButton = await page.$('#btn-unlink-file')
- await btnUnLinkFileButton.tap()
- await isDone()
-
-
- // 清除文件夹
- const btnRmDirButton = await page.$('#btn-remove-dir')
- await btnRmDirButton.tap()
- await isDone()
-
- // 重新创建测试目录
- const btnMkdDirButton = await page.$('#btn-mkdir')
- await btnMkdDirButton.tap()
- await isDone()
-
- const btnReadDirButton = await page.$('#btn-read-dir')
- await btnReadDirButton.tap()
- await isDone()
-
-
- // 期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
- let fileListComplete = await getData('fileListComplete')
- expect(JSON.stringify(fileListComplete)).toEqual("[]")
- let fileListSuccess = await getData('fileListSuccess')
- expect(JSON.stringify(fileListSuccess)).toEqual("[]")
-
- // 测试 创建多层级文件目录
- await page.setData({
- recursiveVal: true,
- mkdirFile: 'a/b/c/d/e/f/g/h/i/g/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/中文路径/张三/test',
- })
-
- await btnMkdDirButton.tap()
- await isDone()
-
- await btnReadDirButton.tap()
- await isDone()
-
- fileListComplete = await getData('fileListComplete')
- expect(JSON.stringify(fileListComplete)).toEqual("[\"b\"]")
- fileListSuccess = await getData('fileListSuccess')
- expect(JSON.stringify(fileListSuccess)).toEqual("[\"b\"]")
-
- // 测试 创建包含中文特殊符号的目录
- await page.setData({
- recursiveVal: true,
- mkdirFile: 'a/' + testDirName + '/中文路径/张三/name',
- })
- await btnMkdDirButton.tap()
- await isDone()
-
- await btnReadDirButton.tap()
- await isDone()
-
- // 期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
- fileListComplete = await getData('fileListComplete')
- fileListComplete.sort()
- expect(JSON.stringify(fileListComplete)).toEqual("[\"b\",\"" + testDirName + "\"]")
- fileListSuccess = await getData('fileListSuccess')
- fileListSuccess.sort()
- expect(JSON.stringify(fileListSuccess)).toEqual("[\"b\",\"" + testDirName + "\"]")
-
- /**
- * 从资源文件中读取图片为base64,测试写入较大文件场景
- * 'static/test-image/logo.ico' 注意,依赖这个资源文件,不能删除
- */
- await page.setData({
- basePath: "",
- readFile: 'static/test-image/logo.ico',
- readFileEncoding: 'base64'
- })
-
-
- // 获取和对比 文件内容
- const btnReadFileButton = await page.$('#btn-read-file')
- await btnReadFileButton.tap()
- await isDone()
- let readFileRet = await getData('readFileRet')
- expect(readFileRet.length).toEqual(208544)
- let endStr = readFileRet.substring(readFileRet.length - 10)
- expect(endStr).toEqual("///////w==")
-
- await page.setData({
- basePath: globalTempPath,
- writeFile: 'a/' + testDirName + '/中文路径/张三/name/中文文件.mock',
- writeFileContent: readFileRet
- })
-
-
- const btnWriteFileButton = await page.$('#btn-write-file')
- await btnWriteFileButton.tap()
- await isDone()
-
- // 获取文件列表,判断是否写入成功,同时置空base64内容 避免影响实时查看状态
- await page.setData({
- readDir: 'a/' + testDirName + '/中文路径/张三/name',
- readFileRet: '',
- writeFileContent: ''
- })
-
- // 检查目录列表数量
- await btnReadDirButton.tap()
- await isDone()
- fileListComplete = await getData('fileListComplete')
- expect(JSON.stringify(fileListComplete)).toEqual("[\"中文文件.mock\"]")
- fileListSuccess = await getData('fileListSuccess')
- expect(JSON.stringify(fileListSuccess)).toEqual("[\"中文文件.mock\"]")
-
-
- // 更换文件内容 获取和对比 文件md5和sha1
- await page.setData({
- getFileInfoFile: 'a/' + testDirName + '/中文路径/张三/name/中文文件.mock',
- getFileInfoAlgorithm: "md5",
- })
-
- const btnGetFileInfoButton = await page.$('#btn-get-file-info')
- await btnGetFileInfoButton.tap()
- await isDone()
-
- let getFileInfoSize = await getData('getFileInfoSize')
- expect(getFileInfoSize).toEqual(208544)
- let getFileInfoDigest = await getData('getFileInfoDigest')
- expect(getFileInfoDigest).toEqual("486f75ea76625f8c103cac4bc9c49511")
-
- // 切换为 sha1
- await page.setData({
- getFileInfoAlgorithm: "sha1"
- })
-
- await btnGetFileInfoButton.tap()
- await isDone()
-
- getFileInfoSize = await getData('getFileInfoSize')
- expect(getFileInfoSize).toEqual(208544)
- getFileInfoDigest = await getData('getFileInfoDigest')
- expect(getFileInfoDigest).toEqual("1830169a16e7c860beff4a3b0975ba0b6f775f9e")
-
- // 测试不支持的摘要算法,期望返回错误
- await page.setData({
- getFileInfoAlgorithm: "sha256"
- })
-
- await btnGetFileInfoButton.tap()
- await isDone()
-
- let lastFailError = await getData('lastFailError')
- expect(lastFailError.errCode).toEqual(1300022)
- let lastCompleteError = await getData('lastCompleteError')
- expect(lastCompleteError.errCode).toEqual(1300022)
-
-
- // rename 到一个没有提前创建过的目录,期望返回错误
- await page.setData({
- renameFromFile: "a/" + testDirName + "/中文路径/张三/name/中文文件.mock",
- renameToFile: "a/没有提前创建的目录/3.txt"
- })
-
- const btnRenameFileButton = await page.$('#btn-rename-file')
- await btnRenameFileButton.tap()
- await isDone()
-
- lastFailError = await getData('lastFailError')
- expect(lastFailError.errCode).toEqual(1300002)
- lastCompleteError = await getData('lastCompleteError')
- expect(lastCompleteError.errCode).toEqual(1300002)
-
- // 非递归创建一级目录。期望成功
- await page.setData({
- recursiveVal: false,
- mkdirFile: 'a/提前创建的目录',
- })
-
- await btnMkdDirButton.tap()
- await isDone()
-
- await page.setData({
- readDir: 'a',
- })
-
- await btnReadDirButton.tap()
- await isDone()
-
- fileListComplete = await getData('fileListComplete')
- fileListComplete.sort()
- expect(JSON.stringify(fileListComplete)).toEqual("[\"b\",\"" + testDirName + "\",\"提前创建的目录\"]")
- fileListSuccess = await getData('fileListSuccess')
- fileListSuccess.sort()
- expect(JSON.stringify(fileListSuccess)).toEqual("[\"b\",\"" + testDirName + "\",\"提前创建的目录\"]")
-
-
- await page.setData({
- copyFromFile: "a/" + testDirName + "/中文路径/张三/name/中文文件.mock",
- copyToFile: "a/提前创建的目录/4.txt"
- })
-
- const btnCopyFileButton = await page.$('#btn-copy-file')
- await btnCopyFileButton.tap()
- await isDone()
-
- await page.setData({
- readDir: 'a/提前创建的目录',
- })
-
- await btnReadDirButton.tap()
- await isDone()
-
- fileListComplete = await getData('fileListComplete')
- expect(JSON.stringify(fileListComplete)).toEqual("[\"4.txt\"]")
- fileListSuccess = await getData('fileListSuccess')
- expect(JSON.stringify(fileListSuccess)).toEqual("[\"4.txt\"]")
-
- await page.setData({
- unlinkFile: 'a/提前创建的目录/4.txt',
- rmDirFile: 'a/提前创建的目录'
- })
- await btnUnLinkFileButton.tap()
- await isDone()
-
- await btnReadDirButton.tap()
- await isDone()
-
- fileListComplete = await getData('fileListComplete')
- expect(JSON.stringify(fileListComplete)).toEqual("[]")
- fileListSuccess = await getData('fileListSuccess')
- expect(JSON.stringify(fileListSuccess)).toEqual("[]")
-
- });
-
-
-
- it('CROSS DIR test', async () => {
- /**
- * 跨越用户目录和代码资源目录
- */
- let globalRootPath = await getData('globalRootPath')
- await page.setData({
- recursiveVal: true,
- logAble: false,
- basePath: globalRootPath,
- readDir: 'a',
- rmDirFile: 'a',
- mkdirFile: 'a',
- accessFile: 'a/从代码目录拷贝的资源.png',
- unlinkFile: 'a/从代码目录拷贝的资源.png'
- })
-
-
- // 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败
- const btnClearFileButton = await page.$('#btn-clear-file')
- await btnClearFileButton.tap()
- await isDone()
-
-
- // 清除文件夹
- const btnRmDirButton = await page.$('#btn-remove-dir')
- await btnRmDirButton.tap()
- await isDone()
-
- // 重新创建测试目录,期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
- const btnMkdDirButton = await page.$('#btn-mkdir')
- await btnMkdDirButton.tap()
- await isDone()
-
- const btnReadDirButton = await page.$('#btn-read-dir')
- await btnReadDirButton.tap()
- await isDone()
-
- let fileListComplete = await getData('fileListComplete')
- expect(JSON.stringify(fileListComplete)).toEqual('[]')
- let fileListSuccess = await getData('fileListSuccess')
- expect(JSON.stringify(fileListSuccess)).toEqual('[]')
-
-
- // 检查资源文件,此时不存在
- const btnAccessFileButton = await page.$('#btn-access-file')
- await btnAccessFileButton.tap()
- await isDone()
-
- let accessFileRet = await getData("accessFileRet")
- expect(accessFileRet).toEqual('')
-
-
- // 准备从资源目录拷贝png
- await page.setData({
- basePath: "",
- unlinkFile: 'static/test-image/logo.ico',
- accessFile: 'static/test-image/logo.ico',
- })
- // 检查资源文件,期望存在
- await btnAccessFileButton.tap()
- await isDone()
-
- accessFileRet = await getData("accessFileRet")
- expect(accessFileRet).toEqual('access:ok')
-
- // 尝试删除资源,期望失败
- const btnUnLinkFileButton = await page.$('#btn-unlink-file')
- await btnUnLinkFileButton.tap()
- await isDone()
-
- await btnAccessFileButton.tap()
- await isDone()
-
- accessFileRet = await getData("accessFileRet")
- expect(accessFileRet).toEqual('access:ok')
- // 复制资源到 root目录
- await page.setData({
- copyToBasePath: globalRootPath,
- copyFromFile: "static/test-image/logo.ico",
- copyToFile: "a/从代码目录拷贝的资源.png"
- })
- const btnCopyFileButton = await page.$('#btn-copy-file')
- await btnCopyFileButton.tap()
- await isDone()
-
- // 检查期望 root 目录中图片文件存在
- await page.setData({
- basePath: globalRootPath,
- unlinkFile: 'a/从代码目录拷贝的资源.png',
- accessFile: 'a/从代码目录拷贝的资源.png',
- rmDirFile: 'a',
- })
- await btnAccessFileButton.tap()
- await isDone()
-
- accessFileRet = await getData("accessFileRet")
- expect(accessFileRet).toEqual('access:ok')
-
- await btnUnLinkFileButton.tap()
- await isDone()
-
- await btnAccessFileButton.tap()
- await isDone()
-
- accessFileRet = await getData("accessFileRet")
- expect(accessFileRet).toEqual('')
-
- // 从页面的按钮触发一次文件复制
- const btnCopyStaticFileButton = await page.$('#btn-copyStatic-file')
- await btnCopyStaticFileButton.tap()
- await isDone()
-
- await btnReadDirButton.tap()
- await isDone()
-
- fileListComplete = await getData('fileListComplete')
- expect(JSON.stringify(fileListComplete)).toEqual("[\"mock.json\"]")
- fileListSuccess = await getData('fileListSuccess')
- expect(JSON.stringify(fileListSuccess)).toEqual("[\"mock.json\"]")
-
- // 从页面的按钮触发一次文件清空
- await btnClearFileButton.tap()
- await isDone()
-
- await btnReadDirButton.tap()
- await isDone()
-
- fileListComplete = await getData('fileListComplete')
- expect(JSON.stringify(fileListComplete)).toEqual("[]")
- fileListSuccess = await getData('fileListSuccess')
- expect(JSON.stringify(fileListSuccess)).toEqual("[]")
-
- });
-
-
- it('write and read', async () => {
- /**
- * 测试writefile readfile 各个参数是否符合预期
- */
- let globalTempPath = await getData('globalTempPath')
- await page.setData({
- recursiveVal: true,
- logAble: false,
- basePath: globalTempPath,
- readDir: 'd',
- rmDirFile: 'd',
- mkdirFile: 'd',
- writeFileContent: "我爱北京天安门,天安门前太阳升",
- writeFileEncoding: "utf-8",
- readFileEncoding: "utf-8",
- unlinkFile: 'd/write.bing',
- writeFile: 'd/write.bing',
- readFile: 'd/write.bing',
- getFileInfoFile: 'd/write.bing',
- getFileInfoAlgorithm: "sha1"
- })
-
- // 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败
- const btnUnLinkFileButton = await page.$('#btn-unlink-file')
- await btnUnLinkFileButton.tap()
- await isDone()
-
- // 清除文件夹
- const btnRmDirButton = await page.$('#btn-remove-dir')
- await btnRmDirButton.tap()
- await isDone()
-
- // 重新创建测试目录,期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
- const btnMkdDirButton = await page.$('#btn-mkdir')
- await btnMkdDirButton.tap()
- await isDone()
-
- const btnReadDirButton = await page.$('#btn-read-dir')
- await btnReadDirButton.tap()
- await isDone()
-
- let fileListComplete = await getData('fileListComplete')
- expect(JSON.stringify(fileListComplete)).toEqual('[]')
- let fileListSuccess = await getData('fileListSuccess')
- expect(JSON.stringify(fileListSuccess)).toEqual('[]')
-
- // 先用utf-8 写入内容
- const btnWriteFileButton = await page.$('#btn-write-file')
- await btnWriteFileButton.tap()
- await isDone()
-
- const btnReadFileButton = await page.$('#btn-read-file')
- await btnReadFileButton.tap()
- await isDone()
- let readFileRet = await getData('readFileRet')
- expect(readFileRet).toEqual("我爱北京天安门,天安门前太阳升")
-
- const btnGetFileInfoButton = await page.$('#btn-get-file-info')
- await btnGetFileInfoButton.tap()
- await isDone()
-
- let getFileInfoSize = await getData('getFileInfoSize')
- expect(getFileInfoSize).toEqual(45)
- let getFileInfoDigest = await getData('getFileInfoDigest')
- expect(getFileInfoDigest).toEqual("2ae9c7672ff6c1e7c7e6a0bb4e74a6f06b39350b")
-
- // 尝试读取base64 信息
- await page.setData({
- readFileEncoding: "base64",
- })
-
- await btnReadFileButton.tap()
- await isDone()
- readFileRet = await getData('readFileRet')
- expect(readFileRet).toEqual("5oiR54ix5YyX5Lqs5aSp5a6J6Zeo77yM5aSp5a6J6Zeo5YmN5aSq6Ziz5Y2H")
- // 测试ascii,需要特别测试 ascii 写入非法字符的情况,因为微信的常量字符编码和android原生有差异。
-
- await page.setData({
- writeFileContent: "丙辰中秋,欢饮达旦,大醉,作此篇,兼怀子由。明月几时有?把酒问青天。不知天上宫阙,今夕是何年。我欲乘风归去,又恐琼楼玉宇,高处不胜寒。起舞弄清影,何似在人间",
- writeFileEncoding: "ascii",
- readFileEncoding: "base64",
- })
-
- await btnWriteFileButton.tap()
- await isDone()
-
- await btnGetFileInfoButton.tap()
- await isDone()
-
- getFileInfoSize = await getData('getFileInfoSize')
- expect(getFileInfoSize).toEqual(78)
- getFileInfoDigest = await getData('getFileInfoDigest')
- expect(getFileInfoDigest).toEqual("4ac7a65055628818341c2ad86ddc4205d8503801")
-
- await btnReadFileButton.tap()
- await isDone()
- readFileRet = await getData('readFileRet')
- expect(readFileRet).toEqual(
- "GbAtywwibr7mDCeJDFxkxwx8AFAxAg4I4PYJH4pS7lIpAg3lKQqrGQzKFS9VdAIRMljOUrsMyFA8fImHDNgEDdzSAnceBAVxDFU8KLr0"
- )
-
- // 尝试写入合法ascii
- await page.setData({
- writeFileContent: "hello jack.hello marry.",
- writeFileEncoding: "ascii",
- readFileEncoding: "ascii",
- })
-
- await btnWriteFileButton.tap()
- await isDone()
-
- await btnReadFileButton.tap()
- await isDone()
- readFileRet = await getData('readFileRet')
- expect(readFileRet).toEqual("hello jack.hello marry.")
-
- // 写入base64 获取 中文
- await page.setData({
- writeFileContent: "5LiZ6L6w5Lit56eL77yM5qyi6aWu6L6+5pem77yM5aSn6YaJ77yM5L2c5q2k56+H77yM5YW85oCA5a2Q55Sx44CC5piO5pyI5Yeg5pe25pyJ77yf5oqK6YWS6Zeu6Z2S5aSp44CC5LiN55+l5aSp5LiK5a6r6ZiZ77yM5LuK5aSV5piv5L2V5bm044CC5oiR5qyy5LmY6aOO5b2S5Y6777yM5Y+I5oGQ55C85qW8546J5a6H77yM6auY5aSE5LiN6IOc5a+S44CC6LW36Iie5byE5riF5b2x77yM5L2V5Ly85Zyo5Lq66Ze0",
- writeFileEncoding: "base64",
- readFileEncoding: "utf-8",
- })
-
- await btnWriteFileButton.tap()
- await isDone()
-
- await btnReadFileButton.tap()
- await isDone()
- readFileRet = await getData('readFileRet')
- expect(readFileRet).toEqual(
- "丙辰中秋,欢饮达旦,大醉,作此篇,兼怀子由。明月几时有?把酒问青天。不知天上宫阙,今夕是何年。我欲乘风归去,又恐琼楼玉宇,高处不胜寒。起舞弄清影,何似在人间")
-
- await page.setData({
- readFileEncoding: "base64",
- })
-
- await btnReadFileButton.tap()
- await isDone()
- readFileRet = await getData('readFileRet')
- expect(readFileRet).toEqual(
- "5LiZ6L6w5Lit56eL77yM5qyi6aWu6L6+5pem77yM5aSn6YaJ77yM5L2c5q2k56+H77yM5YW85oCA5a2Q55Sx44CC5piO5pyI5Yeg5pe25pyJ77yf5oqK6YWS6Zeu6Z2S5aSp44CC5LiN55+l5aSp5LiK5a6r6ZiZ77yM5LuK5aSV5piv5L2V5bm044CC5oiR5qyy5LmY6aOO5b2S5Y6777yM5Y+I5oGQ55C85qW8546J5a6H77yM6auY5aSE5LiN6IOc5a+S44CC6LW36Iie5byE5riF5b2x77yM5L2V5Ly85Zyo5Lq66Ze0"
- )
-
- });
-
- it('stat and asset test', async () => {
- // 测试 USER_DATA_PATH //globalTempPath
- let globalRootPath = await getData('globalRootPath')
-
- await page.setData({
- recursiveVal: true,
- copyToBasePath: globalRootPath,
- basePath: globalRootPath,
- globalTempPath: globalRootPath,
- rmDirFile: 'a',
- mkdirFile: 'a',
- unlinkFile: 'a/1.txt',
- })
-
- // 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败
- const btnUnLinkFileButton = await page.$('#btn-unlink-file')
- await btnUnLinkFileButton.tap()
- await isDone()
-
- await page.setData({
- unlinkFile: 'a/2.txt',
- })
- await btnUnLinkFileButton.tap()
- await isDone()
-
- await page.setData({
- unlinkFile: 'a/m/3.txt',
- })
- await btnUnLinkFileButton.tap()
- await isDone()
-
- // // 清除文件夹
- const btnRmDirButton = await page.$('#btn-remove-dir')
- await btnRmDirButton.tap()
- await isDone()
- // // 重新创建测试目录
- const btnMkdDirButton = await page.$('#btn-mkdir')
- await btnMkdDirButton.tap()
- await isDone()
-
- const btnReadDirButton = await page.$('#btn-read-dir')
- await btnReadDirButton.tap()
- await isDone()
-
-
- // 期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
- let fileListComplete = await getData('fileListComplete')
- expect(JSON.stringify(fileListComplete)).toEqual('[]')
- let fileListSuccess = await getData('fileListSuccess')
- expect(JSON.stringify(fileListSuccess)).toEqual('[]')
-
- // 写入一个文件
- await page.setData({
- writeFileContent: "锄禾日当午,汗滴禾下土,谁知盘中餐,粒粒皆辛苦",
- writeFileEncoding: "utf-8",
- writeFile: 'a/1.txt',
- recursiveVal: false,
- statFile: 'a/1.txt',
- })
-
- let lastFailError = await getData('lastFailError')
- console.log(lastFailError)
-
- const btnWriteFileButton = await page.$('#btn-write-file')
- await btnWriteFileButton.tap()
- await isDone()
-
- let btnStatFileButton = await page.$('#btn-stat-file')
- await btnStatFileButton.tap()
- await isDone()
-
- // 读取单个文件信息
- let statsRet = await getData('statsRet')
- expect(statsRet.length).toEqual(1)
- expect(statsRet[0].path).toMatch(new RegExp('.*/a/1.txt$'))
- expect(statsRet[0].stats.size).toEqual(69)
- if (isAndroid()) {
- // 写入一个文件
- await page.setData({
- statsRet: ''
- })
- btnStatFileButton = await page.$('#btn-stat-file-sync')
- await btnStatFileButton.tap()
- await isDone()
-
- // 读取单个文件信息
- statsRet = await getData('statsRet')
- expect(statsRet.length).toEqual(1)
- expect(statsRet[0].path).toMatch(new RegExp('.*/a/1.txt$'))
- expect(statsRet[0].stats.size).toEqual(69)
- }
-
- /**
- * 创建子目录和子目录文件,测试recursive参数
- */
- await page.setData({
- writeFileContent: "1234567890",
- writeFileEncoding: "ascii",
- writeFile: 'a/2.txt',
- basePath: globalRootPath,
- recursiveVal: false,
- statFile: 'a',
- mkdirFile: 'a/m',
- })
-
-
- await btnWriteFileButton.tap()
- await isDone()
-
- // 创建子目录
- await btnMkdDirButton.tap()
- await isDone()
-
- // 复制一份文件到 /a/m/3.txt
- await page.setData({
- // asset 只能正式版测试,这里只能模拟返回路径
- basePath: '',
- copyFromFile: 'static/test-image/logo.ico',
- copyToFile: 'a/m/3.txt',
- })
- const btnCopyFileButton = await page.$('#btn-copy-file')
- await btnCopyFileButton.tap()
- await isDone()
-
-
- await page.setData({
- basePath: globalRootPath,
- recursiveVal: true,
- statFile: 'a',
- })
-
- await btnStatFileButton.tap()
- await isDone()
-
- // 读取全部文件信息
- statsRet = await getData('statsRet')
-
- statsRet.sort(function(a, b) {
- if (a.path > b.path) {
- return 1
- } else if (a.path < b.path) {
- return -1
- }
- return 0
- })
- console.log(statsRet)
- expect(statsRet.length).toEqual(5)
- expect(statsRet[0].path).toMatch(new RegExp('.*/a$'))
- // expect(statsRet[0].stats.size).toEqual(0)
-
- expect(statsRet[2].path).toMatch(new RegExp('.*/a/2.txt$'))
- expect(statsRet[2].stats.size).toEqual(10)
-
- expect(statsRet[4].path).toMatch(new RegExp('.*/a/m/3.txt$'))
- expect(statsRet[4].stats.size).toEqual(156406)
-
-
- // 清理文件,避免影响其他测试用例
- await page.setData({
- unlinkFile: 'a/1.txt',
- })
- await btnUnLinkFileButton.tap()
- await isDone()
-
- await page.setData({
- unlinkFile: 'a/2.txt',
- })
- await btnUnLinkFileButton.tap()
- await isDone()
-
- await page.setData({
- unlinkFile: 'a/m/3.txt',
- rmDirFile: 'a',
- readDir: 'a',
- recursiveVal: true,
- })
- await btnUnLinkFileButton.tap()
- await isDone()
-
- await btnRmDirButton.tap()
- await isDone()
-
- await btnReadDirButton.tap()
- await isDone()
-
- // 期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
- fileListComplete = await getData('fileListComplete')
- expect(JSON.stringify(fileListComplete)).toEqual('[]')
- fileListSuccess = await getData('fileListSuccess')
- expect(JSON.stringify(fileListSuccess)).toEqual('[]')
-
- });
- it('appendFileTest', async () => {
- if (!isAndroid()) {
- return
- }
-
-
- let basePath = await getData('basePath')
-
- await page.setData({
- basePath: mBasePath,
- recursiveVal: true,
- logAble: false,
- rmDirFile: 'appendfile',
- mkdirFile: 'appendfile',
- writeFileContent: "我爱北京天安门,天安门前太阳升",
- appendFileContent: "再说一遍",
- writeFileEncoding: "utf-8",
- readFileEncoding: "utf-8",
- readFile: 'appendfile/appendfile.txt',
- unlinkFile: 'appendfile/appendfile.txt',
- writeFile: 'appendfile/appendfile.txt',
- })
-
- // 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败
- const btnUnLinkFileButton = await page.$('#btn-unlink-file')
- await btnUnLinkFileButton.tap()
- await isDone()
-
- // 清除文件夹
- const btnRmDirButton = await page.$('#btn-remove-dir')
- await btnRmDirButton.tap()
- await isDone()
-
- // 重新创建测试目录,期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
- const btnMkdDirButton = await page.$('#btn-mkdir')
- await btnMkdDirButton.tap()
- await isDone()
-
- // 先用utf-8 写入内容
- const btnWriteFileButton = await page.$('#btn-write-file')
-
- await btnWriteFileButton.tap()
- await isDone()
-
-
- //追加内容
- const btnAppendFileButton = await page.$('#btn-append-file')
- await btnAppendFileButton.tap()
- await isDone()
-
- const btnReadFileButton = await page.$('#btn-read-file')
- await btnReadFileButton.tap()
- await isDone()
- let readFileRet = await getData('readFileRet')
- expect(readFileRet).toEqual("我爱北京天安门,天安门前太阳升再说一遍")
- });
- //nlinkSyncTest mkdirSyncTest appendFileTest writeFileSyncTest readFileSyncTest rmdirSyncTest readDirSyncTest accessFileSyncTest
- //renameFileSync copyFileSyncTest appendFileSyncTest truncateFileTest truncateFileSyncTest
- it('sync test',
- async () => {
- if (!isAndroid()) {
- return
- }
-
-
- await page.setData({
- basePath: mBasePath,
- recursiveVal: false,
- logAble: false,
- rmDirFile: 'sync',
- mkdirFile: 'sync',
- writeFileContent: "我爱北京天安门,天安门前太阳升",
- appendFileContent: "再说一遍",
- writeFileEncoding: "utf-8",
- readFileEncoding: "utf-8",
- readDir: 'sync',
- rmDirFile: 'sync',
- unlinkFile: 'sync/sync.txt',
- readFile: 'sync/sync.txt',
- writeFile: 'sync/sync.txt',
- accessFile: 'sync/sync.txt',
- renameToFile: 'sync/sync.txt',
- renameFromFile: 'sync/sync.txt',
- })
- await clearDir('sync')
- // 重新创建测试目录,期望通过 recursive = true的 文件夹删除,得到一个空的 目录
- const btnMkdDirButton = await page.$('#btn-mkdir-sync')
- await btnMkdDirButton.tap()
- await isDone()
-
- const btnReadDirButton = await page.$('#btn-read-dir-sync')
- await btnReadDirButton.tap()
- await isDone()
- const fileListSuccess = await getData('fileListSuccess')
- expect(JSON.stringify(fileListSuccess)).toEqual('[]')
-
- // 先用utf-8 写入内容
- const btnWriteFileButton = await page.$('#btn-write-file-sync')
- await btnWriteFileButton.tap()
- await isDone()
-
- let btnAccessFileButton = await page.$('#btn-access-file-sync')
- await btnAccessFileButton.tap()
- await isDone()
- let accessFileRet = await getData("accessFileRet")
- expect(accessFileRet).toEqual('access:ok')
-
- //重新命名文件
- const btnRenameFileButton = await page.$('#btn-rename-file-sync')
- await btnRenameFileButton.tap()
- await isDone()
- let renameFileRet = await getData("renameFileRet")
- expect(renameFileRet).toEqual("rename:ok")
-
-
- //追加内容
- let btnAppendFileButton = await page.$('#btn-append-file')
- await btnAppendFileButton.tap()
- await isDone()
-
- btnAppendFileButton = await page.$('#btn-append-file-sync')
- await btnAppendFileButton.tap()
-
-
- let btnReadFileButton = await page.$('#btn-read-file-sync')
- await btnReadFileButton.tap()
- await isDone()
- let readFileRet = await getData('readFileRet')
- expect(readFileRet).toEqual("我爱北京天安门,天安门前太阳升再说一遍再说一遍")
-
- //truncateFileTest
- let btnTruncateFile = await page.$('#btn-truncate-file')
- await btnTruncateFile.tap()
- await isDone()
- btnReadFileButton = await page.$('#btn-read-file-sync')
- await btnReadFileButton.tap()
- await isDone()
- readFileRet = await getData('readFileRet')
- expect(readFileRet).toEqual("我爱北京天安门")
-
- btnTruncateFile = await page.$('#btn-truncate-file-sync')
- await btnTruncateFile.tap()
- await isDone()
- btnReadFileButton = await page.$('#btn-read-file-sync')
- await btnReadFileButton.tap()
- await isDone()
- readFileRet = await getData('readFileRet')
- expect(readFileRet).toEqual("我爱北京")
-
-
- // 测试 copyfile
- await page.setData({
- basePath: mBasePath,
- copyToBasePath: mBasePath,
- copyFromFile: "sync/sync.txt",
- copyToFile: "sync/syncto.txt",
- accessFile: "sync/syncto.txt"
- })
- const btnCopyFileButton = await page.$('#btn-copy-file-sync')
- await btnCopyFileButton.tap()
- await isDone()
- btnAccessFileButton = await page.$('#btn-access-file-sync')
- await btnAccessFileButton.tap()
- await isDone()
- accessFileRet = await getData("accessFileRet")
- expect(accessFileRet).toEqual('access:ok')
-
- await clearDir('sync')
- });
-
- async function createFile() {
- // 重新创建测试目录,期望通过 recursive = true的 文件夹删除,得到一个空的 目录
- const btnMkdDirButton = await page.$('#btn-mkdir-sync')
- await btnMkdDirButton.tap()
- await isDone()
-
- // 先用utf-8 写入内容
- const btnWriteFileButton = await page.$('#btn-write-file-sync')
- await btnWriteFileButton.tap()
- await isDone()
- }
-
- async function clearDir(dir) {
- // 最后需要清楚所有文件避免测试失败
- await page.setData({
- rmDirFile: dir,
- })
- const btnUnLinkFileButton = await page.$('#btn-clear-file')
- await btnUnLinkFileButton.tap()
- await isDone()
-
- const btnClear = await page.$('#btn-remove-dir')
- await btnClear.tap()
- await isDone()
- }
-
- function isAndroid() {
- if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW === 'true') {
- expect(1).toBe(1)
- return false
- }
- if (process.env.uniTestPlatformInfo.toLocaleLowerCase().startsWith('ios')) {
- expect(1).toBe(1)
- return false
- }
- return true
- }
-
- it('getSavedFileListTest',
- async () => {
- if (!isAndroid()) {
- return
- }
- // await page.setData({
- // logAble: false,
- // basePath: mBasePath
- // })
- // console.log('getSavedFileListTest', 'start')
- // await clearDir('')
- // console.log('getSavedFileListTest', 'end')
- await page.setData({
- logAble: false,
- basePath: mGlobalTempPath,
- temFile: 'save3/2.txt',
- mkdirFile: 'save3',
- writeFile: 'save3/2.txt',
- accessFile: '2.txt'
- })
- await createFile()
- await page.setData({
- basePath: mBasePath,
- writeFile: 'save/2.txt',
- })
- btnSaveFile = await page.$('#btn-save-file-sync')
- await btnSaveFile.tap()
- await isDone()
- let btnSavedFileList = await page.$('#btn-getsaved-filelist')
- await btnSavedFileList.tap()
- await isDone()
- let getSavedFileListRet = await getData("getSavedFileListRet")
- console.log('getSavedFileListTest->' + getSavedFileListRet)
- expect(getSavedFileListRet).toEqual('getSavedFileList:ok')
- });
-
- it('removeSavedFileTest',
- async () => {
- if (!isAndroid()) {
- return
- }
- await page.setData({
- logAble: false,
- basePath: mBasePath
- })
- await clearDir('save4')
- await page.setData({
- logAble: false,
- basePath: mGlobalTempPath,
- temFile: 'save4/saveSync.txt',
- mkdirFile: 'save4',
- writeFile: 'save4/saveSync.txt',
- accessFile: 'saveSync.txt'
- })
- await createFile()
- let btnRemoveSavedFileRet = await page.$('#btn-remove-saved-file')
- await btnRemoveSavedFileRet.tap()
- await isDone()
- let removeSavedFileRet = await getData("removeSavedFileRet")
- expect(removeSavedFileRet).toEqual('removeSavedFile:ok')
-
- });
-
- //openFiletest openFileSynctest closeTest closeTestSync writeTest writeSyncTest
- it('openFiletest', async () => {
- if (!isAndroid()) {
- return
- }
-
- await page.setData({
- basePath: mBasePath,
- logAble: false,
- mkdirFile: 'fd',
- writeFile: 'fd/1.txt',
- readFile: 'fd/1.txt'
- })
- await clearDir('fd')
- await createFile()
- console.log('openFiletest', '2')
- //openFiletest
- let btnOpenFile = await page.$('#btn-open-file')
- await btnOpenFile.tap()
- await isDone()
- let fd = await getData("fd")
- expect(fd).not.toBe('');
- await page.setData({
- fd: '',
- })
- console.log('openFiletest', '3')
- //openFileSynctest
- btnOpenFile = await page.$('#btn-open-file-sync')
- await btnOpenFile.tap()
- await isDone()
- fd = await getData("fd")
- expect(fd).not.toBe('');
- console.log('openFiletest', '4')
- });
- // closeTest closeTestSync
- it('closeTest', async () => {
- if (!isAndroid()) {
- return
- }
-
-
-
- await page.setData({
- basePath: mBasePath,
- logAble: false,
- mkdirFile: 'fd',
- writeFile: 'fd/1.txt',
- readFile: 'fd/1.txt'
- })
- await clearDir('fd')
- await createFile()
- //closeTest
- let btnCloseFile = await page.$('#btn-close-file')
- await btnCloseFile.tap()
- await isDone()
- let closeFileRet = await getData("closeFileRet")
- expect(closeFileRet).toEqual('close:ok')
- await page.setData({
- closeFileRet: '',
- })
- //closeTestSync
- btnCloseFile = await page.$('#btn-close-file-sync')
- await btnCloseFile.tap()
- await isDone()
- closeFileRet = await getData("closeFileRet")
- expect(closeFileRet).toEqual('close:ok')
-
- });
- //writeTest writeSyncTest
- it('writeTest', async () => {
- if (!isAndroid()) {
- return
- }
- console.log('writeTest', 'start')
-
- await page.setData({
- basePath: mBasePath,
- logAble: false,
- mkdirFile: 'fd',
- writeFile: 'fd/1.txt',
- readFile: 'fd/1.txt',
- writeData: '我是一只小小鸟'
- })
- await clearDir('fd')
- await createFile()
- console.log('writeTest', '1')
- let btnWrite = await page.$('#btn-write')
- await btnWrite.tap()
- await isDone()
- let bytesWritten = await getData("bytesWritten")
- let lastFailError = await getData("lastFailError")
- if(bytesWritten != 7){
- let writeData = await getData("writeData")
- console.log('writeTest',lastFailError.errCode,lastFailError.errMsg,bytesWritten,writeData)
- }
-
- expect(bytesWritten).toEqual(7)
- console.log('writeTest', '2')
- //writeSyncTest
- await page.setData({
- writeFile: 'fd/1.txt',
- readFile: 'fd/1.txt',
- writeData: '我是'
- })
-
- btnWrite = await page.$('#btn-write-sync')
- await btnWrite.tap()
- await isDone()
- bytesWritten = await getData("bytesWritten")
- expect(bytesWritten).toEqual(2)
- console.log('writeTest', '3')
- //fstatTest
- let btnFstat = await page.$('#btn-fstat-file')
- await btnFstat.tap()
- await isDone()
- let fstat = await getData("fstat")
- expect(fstat.size > 0).toBe(true)
- console.log('writeTest', '4')
-
- //fstatSyncTest
- btnFstat = await page.$('#btn-fstat-file-sync')
- await btnFstat.tap()
- await isDone()
- fstat = await getData("fstat")
- expect(fstat.size > 0).toBe(true)
- console.log('writeTest', '5')
-
- //ftruncateFileTest
- let btnFTruncateFile = await page.$('#btn-ftruncate-file')
- await btnFTruncateFile.tap()
- await isDone()
- let ftruncateRet = await getData("ftruncateRet")
- expect(fstat).not.toEqual('ftruncate:ok')
- await page.setData({
- ftruncate: '',
- })
- console.log('writeTest', '6')
-
- //ftruncateFileSyncTest
- btnFTruncateFile = await page.$('#btn-ftruncate-file-sync')
- await btnFTruncateFile.tap()
- await isDone()
- ftruncateRet = await getData("ftruncateRet")
- expect(fstat).not.toEqual('ftruncate:ok')
- console.log('writeTest', '7')
- });
- //writeTest writeSyncTest
- it('ftruncateFileTest', async () => {
- if (!isAndroid()) {
- return
- }
- console.log('ftruncateFileTest', 'start')
-
- await page.setData({
- basePath: mBasePath,
- logAble: false,
- mkdirFile: 'fd',
- writeFile: 'fd/1.txt',
- readFile: 'fd/1.txt',
- writeData: '我是一只小小鸟我是'
- })
- await clearDir('fd')
- await createFile()
- console.log('ftruncateFileTest', '1')
- btnWrite = await page.$('#btn-write-sync')
- await btnWrite.tap()
- await isDone()
- bytesWritten = await getData("bytesWritten")
- expect(bytesWritten).toEqual(9)
- console.log('ftruncateFileTest', '3')
- //ftruncateFileTest
- let btnFTruncateFile = await page.$('#btn-ftruncate-file')
- await btnFTruncateFile.tap()
- await isDone()
- let ftruncateRet = await getData("ftruncateRet")
- expect(ftruncateRet).toEqual('ftruncate:ok')
- await page.setData({
- ftruncate: '',
- })
- console.log('ftruncateFileTest', '6')
-
- //ftruncateFileSyncTest
- btnFTruncateFile = await page.$('#btn-ftruncate-file-sync')
- await btnFTruncateFile.tap()
- await isDone()
- ftruncateRet = await getData("ftruncateRet")
- expect(ftruncateRet).toEqual('ftruncate:ok')
- console.log('ftruncateFileTest', '7')
- });
+ if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW ==
+ 'true') {
+ it('dummyTest', () => {
+ expect(1).toBe(1)
+ })
+ return
+ }
+ let page;
+ let mBasePath;
+ let mGlobalTempPath;
+ let mGlobalRootPath
+
+
+ function getData(key = '') {
+ return new Promise(async (resolve, reject) => {
+ const data = await page.data()
+ resolve(key ? data[key] : data)
+ })
+ }
+
+
+ beforeAll(async () => {
+ page = await program.reLaunch(PAGE_PATH)
+ await page.waitFor(600);
+ });
+
+ async function isDone() {
+ let isDone = await page.waitFor(async () => {
+ return await page.data('done')
+ })
+ await page.setData({
+ done: false
+ })
+ return isDone
+ }
+
+ it('USER_DATA_PATH test', async () => {
+ // 测试 USER_DATA_PATH
+ let globalUserDataPath = await getData('globalUserDataPath')
+ mBasePath = await getData('basePath')
+ mGlobalRootPath = await getData('globalRootPath')
+ mGlobalTempPath = await getData('globalTempPath')
+
+ await page.setData({
+ logAble: false,
+ recursiveVal: true,
+ copyToBasePath: globalUserDataPath,
+ basePath: globalUserDataPath,
+ rmDirFile: 'a',
+ readDir: 'a',
+ writeFile: 'a/1.txt',
+ readFile: 'a/1.txt',
+ unlinkFile: 'a/1.txt',
+ writeFileContent: '锄禾日当午,汗滴禾下土,谁知盘中餐,粒粒皆辛苦'
+ })
+
+ // 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败
+ const btnUnLinkFileButton = await page.$('#btn-clear-file')
+ await btnUnLinkFileButton.tap()
+ await isDone()
+
+
+ // 清除文件夹
+ const btnRmDirButton = await page.$('#btn-remove-dir')
+ await btnRmDirButton.tap()
+ await isDone()
+ // 重新创建测试目录
+ const btnMkdDirButton = await page.$('#btn-mkdir')
+ await btnMkdDirButton.tap()
+ await isDone()
+
+ const btnReadDirButton = await page.$('#btn-read-dir')
+ await btnReadDirButton.tap()
+ await isDone()
+
+
+ // 期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
+ let fileListComplete = await getData('fileListComplete')
+ expect(JSON.stringify(fileListComplete)).toEqual('[]')
+ let fileListSuccess = await getData('fileListSuccess')
+ expect(JSON.stringify(fileListSuccess)).toEqual('[]')
+
+ // 先测试 recursive = false 文件夹创建,期望失败
+ await page.setData({
+ recursiveVal: false,
+ mkdirFile: 'a/b/c'
+ })
+
+
+ await btnMkdDirButton.tap()
+ await isDone()
+
+
+ let lastFailError = await getData('lastFailError')
+ expect(lastFailError.errCode).toEqual(1300002)
+ expect(lastFailError.errMsg).toEqual('no such file or directory')
+ let lastCompleteError = await getData('lastCompleteError')
+ expect(lastCompleteError.errCode).toEqual(1300002)
+ expect(lastCompleteError.errMsg).toEqual('no such file or directory')
+
+
+ // 测试 recursive = true 期望文件夹创建成功
+ await page.setData({
+ recursiveVal: true
+ })
+ await btnMkdDirButton.tap()
+ await isDone()
+
+ await btnReadDirButton.tap()
+ await isDone()
+
+ // 期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
+ fileListComplete = await getData('fileListComplete')
+ expect(JSON.stringify(fileListComplete)).toEqual("[\"b\"]")
+ fileListSuccess = await getData('fileListSuccess')
+ expect(JSON.stringify(fileListSuccess)).toEqual("[\"b\"]")
+
+ // 测试写入文件
+ const btnWriteFileButton = await page.$('#btn-write-file')
+ await btnWriteFileButton.tap()
+ await isDone()
+ // 检查目录列表数量
+ await btnReadDirButton.tap()
+ await isDone()
+ fileListComplete = await getData('fileListComplete')
+ fileListComplete.sort()
+ expect(JSON.stringify(fileListComplete)).toEqual("[\"1.txt\",\"b\"]")
+ fileListSuccess = await getData('fileListSuccess')
+ fileListSuccess.sort()
+ expect(JSON.stringify(fileListSuccess)).toEqual("[\"1.txt\",\"b\"]")
+ // 获取和对比 文件内容
+ const btnReadFileButton = await page.$('#btn-read-file')
+ await btnReadFileButton.tap()
+ await isDone()
+ let readFileRet = await getData('readFileRet')
+ expect(readFileRet).toEqual("锄禾日当午,汗滴禾下土,谁知盘中餐,粒粒皆辛苦")
+
+ // 更换文件内容 获取和对比 文件md5和sha1
+ await page.setData({
+ writeFileContent: "If you were a teardrop;In my eye,For fear of losing you,I would never cry.And if the golden sun,Should cease to shine its light,Just one smile from you,Would make my whole world bright.",
+ getFileInfoAlgorithm: "md5"
+ })
+ await btnWriteFileButton.tap()
+ await isDone()
+
+ await btnReadFileButton.tap()
+ await isDone()
+ readFileRet = await getData('readFileRet')
+ expect(readFileRet).toEqual(
+ "If you were a teardrop;In my eye,For fear of losing you,I would never cry.And if the golden sun,Should cease to shine its light,Just one smile from you,Would make my whole world bright."
+ )
+
+ const btnGetFileInfoButton = await page.$('#btn-get-file-info')
+ await btnGetFileInfoButton.tap()
+ await isDone()
+
+ let getFileInfoSize = await getData('getFileInfoSize')
+ expect(getFileInfoSize).toEqual(185)
+ let getFileInfoDigest = await getData('getFileInfoDigest')
+ expect(getFileInfoDigest).toEqual("29ddd02ed3c38ccebb98884eda082cb1")
+ // 切换为 sha1
+ await page.setData({
+ getFileInfoAlgorithm: "sha1"
+ })
+
+ await btnGetFileInfoButton.tap()
+ await isDone()
+
+ getFileInfoSize = await getData('getFileInfoSize')
+ expect(getFileInfoSize).toEqual(185)
+ getFileInfoDigest = await getData('getFileInfoDigest')
+ expect(getFileInfoDigest).toEqual("ebef4e75783e0db499fc260d120e695005bead8a")
+
+ // 测试 copyfile
+ await page.setData({
+
+ copyFromFile: "a/1.txt",
+ copyToFile: "a/2.txt"
+ })
+ const btnCopyFileButton = await page.$('#btn-copy-file')
+ await btnCopyFileButton.tap()
+ await isDone()
+
+
+ await btnReadDirButton.tap()
+ await isDone()
+
+ // 1.txt 2.txt 两个文件都存在
+ fileListComplete = await getData('fileListComplete')
+ fileListComplete.sort()
+ expect(JSON.stringify(fileListComplete)).toEqual("[\"1.txt\",\"2.txt\",\"b\"]")
+ fileListSuccess = await getData('fileListSuccess')
+ fileListSuccess.sort()
+ expect(JSON.stringify(fileListSuccess)).toEqual("[\"1.txt\",\"2.txt\",\"b\"]")
+
+ // 测试 rename
+ await page.setData({
+ renameFromFile: "a/2.txt",
+ renameToFile: "a/3.txt"
+ })
+
+ const btnRenameFileButton = await page.$('#btn-rename-file')
+ await btnRenameFileButton.tap()
+ await isDone()
+
+ await btnReadDirButton.tap()
+ await isDone()
+
+ // 1.txt 3.txt 两个文件都存在
+ fileListComplete = await getData('fileListComplete')
+ fileListComplete.sort()
+ expect(JSON.stringify(fileListComplete)).toEqual("[\"1.txt\",\"3.txt\",\"b\"]")
+ fileListSuccess = await getData('fileListSuccess')
+ fileListSuccess.sort()
+ expect(JSON.stringify(fileListSuccess)).toEqual("[\"1.txt\",\"3.txt\",\"b\"]")
+ });
+
+ it('TEMP_PATH test', async () => {
+ // 测试 TEMP_PATH
+ let globalTempPath = await getData('globalTempPath')
+
+ let version = process.env.uniTestPlatformInfo
+ version = parseInt(version.split(" ")[1])
+ let testDirName = "我们经历了一场兵慌马乱的战争.1@2#3$4%5^6&7*8(9)0+-qwertyuiopasdfghjklzxcvbnm;,"
+ if (version < 6) {
+ // android 6 以下文件名不能包含特殊字符
+ testDirName = "我们经历了一场兵慌马乱的战争"
+ }
+
+ await page.setData({
+ logAble: false,
+ recursiveVal: true,
+ basePath: globalTempPath,
+ copyToBasePath: globalTempPath,
+ rmDirFile: 'a',
+ mkdirFile: 'a',
+ unlinkFile: 'a/' + testDirName + '/中文路径/张三/name/中文文件.mock'
+ })
+
+
+ // 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败
+ const btnUnLinkFileButton = await page.$('#btn-unlink-file')
+ await btnUnLinkFileButton.tap()
+ await isDone()
+
+
+ // 清除文件夹
+ const btnRmDirButton = await page.$('#btn-remove-dir')
+ await btnRmDirButton.tap()
+ await isDone()
+
+ // 重新创建测试目录
+ const btnMkdDirButton = await page.$('#btn-mkdir')
+ await btnMkdDirButton.tap()
+ await isDone()
+
+ const btnReadDirButton = await page.$('#btn-read-dir')
+ await btnReadDirButton.tap()
+ await isDone()
+
+
+ // 期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
+ let fileListComplete = await getData('fileListComplete')
+ expect(JSON.stringify(fileListComplete)).toEqual("[]")
+ let fileListSuccess = await getData('fileListSuccess')
+ expect(JSON.stringify(fileListSuccess)).toEqual("[]")
+
+ // 测试 创建多层级文件目录
+ await page.setData({
+ recursiveVal: true,
+ mkdirFile: 'a/b/c/d/e/f/g/h/i/g/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/中文路径/张三/test',
+ })
+
+ await btnMkdDirButton.tap()
+ await isDone()
+
+ await btnReadDirButton.tap()
+ await isDone()
+
+ fileListComplete = await getData('fileListComplete')
+ expect(JSON.stringify(fileListComplete)).toEqual("[\"b\"]")
+ fileListSuccess = await getData('fileListSuccess')
+ expect(JSON.stringify(fileListSuccess)).toEqual("[\"b\"]")
+
+ // 测试 创建包含中文特殊符号的目录
+ await page.setData({
+ recursiveVal: true,
+ mkdirFile: 'a/' + testDirName + '/中文路径/张三/name',
+ })
+ await btnMkdDirButton.tap()
+ await isDone()
+
+ await btnReadDirButton.tap()
+ await isDone()
+
+ // 期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
+ fileListComplete = await getData('fileListComplete')
+ fileListComplete.sort()
+ expect(JSON.stringify(fileListComplete)).toEqual("[\"b\",\"" + testDirName + "\"]")
+ fileListSuccess = await getData('fileListSuccess')
+ fileListSuccess.sort()
+ expect(JSON.stringify(fileListSuccess)).toEqual("[\"b\",\"" + testDirName + "\"]")
+
+ /**
+ * 从资源文件中读取图片为base64,测试写入较大文件场景
+ * 'static/test-image/logo.ico' 注意,依赖这个资源文件,不能删除
+ */
+ await page.setData({
+ basePath: "",
+ readFile: 'static/test-image/logo.ico',
+ readFileEncoding: 'base64'
+ })
+
+
+ // 获取和对比 文件内容
+ const btnReadFileButton = await page.$('#btn-read-file')
+ await btnReadFileButton.tap()
+ await isDone()
+ let readFileRet = await getData('readFileRet')
+ expect(readFileRet.length).toEqual(208544)
+ let endStr = readFileRet.substring(readFileRet.length - 10)
+ expect(endStr).toEqual("///////w==")
+
+ await page.setData({
+ basePath: globalTempPath,
+ writeFile: 'a/' + testDirName + '/中文路径/张三/name/中文文件.mock',
+ writeFileContent: readFileRet
+ })
+
+
+ const btnWriteFileButton = await page.$('#btn-write-file')
+ await btnWriteFileButton.tap()
+ await isDone()
+
+ // 获取文件列表,判断是否写入成功,同时置空base64内容 避免影响实时查看状态
+ await page.setData({
+ readDir: 'a/' + testDirName + '/中文路径/张三/name',
+ readFileRet: '',
+ writeFileContent: ''
+ })
+
+ // 检查目录列表数量
+ await btnReadDirButton.tap()
+ await isDone()
+ fileListComplete = await getData('fileListComplete')
+ expect(JSON.stringify(fileListComplete)).toEqual("[\"中文文件.mock\"]")
+ fileListSuccess = await getData('fileListSuccess')
+ expect(JSON.stringify(fileListSuccess)).toEqual("[\"中文文件.mock\"]")
+
+
+ // 更换文件内容 获取和对比 文件md5和sha1
+ await page.setData({
+ getFileInfoFile: 'a/' + testDirName + '/中文路径/张三/name/中文文件.mock',
+ getFileInfoAlgorithm: "md5",
+ })
+
+ const btnGetFileInfoButton = await page.$('#btn-get-file-info')
+ await btnGetFileInfoButton.tap()
+ await isDone()
+
+ let getFileInfoSize = await getData('getFileInfoSize')
+ expect(getFileInfoSize).toEqual(208544)
+ let getFileInfoDigest = await getData('getFileInfoDigest')
+ expect(getFileInfoDigest).toEqual("486f75ea76625f8c103cac4bc9c49511")
+
+ // 切换为 sha1
+ await page.setData({
+ getFileInfoAlgorithm: "sha1"
+ })
+
+ await btnGetFileInfoButton.tap()
+ await isDone()
+
+ getFileInfoSize = await getData('getFileInfoSize')
+ expect(getFileInfoSize).toEqual(208544)
+ getFileInfoDigest = await getData('getFileInfoDigest')
+ expect(getFileInfoDigest).toEqual("1830169a16e7c860beff4a3b0975ba0b6f775f9e")
+
+ // 测试不支持的摘要算法,期望返回错误
+ await page.setData({
+ getFileInfoAlgorithm: "sha256"
+ })
+
+ await btnGetFileInfoButton.tap()
+ await isDone()
+
+ let lastFailError = await getData('lastFailError')
+ expect(lastFailError.errCode).toEqual(1300022)
+ let lastCompleteError = await getData('lastCompleteError')
+ expect(lastCompleteError.errCode).toEqual(1300022)
+
+
+ // rename 到一个没有提前创建过的目录,期望返回错误
+ await page.setData({
+ renameFromFile: "a/" + testDirName + "/中文路径/张三/name/中文文件.mock",
+ renameToFile: "a/没有提前创建的目录/3.txt"
+ })
+
+ const btnRenameFileButton = await page.$('#btn-rename-file')
+ await btnRenameFileButton.tap()
+ await isDone()
+
+ lastFailError = await getData('lastFailError')
+ expect(lastFailError.errCode).toEqual(1300002)
+ lastCompleteError = await getData('lastCompleteError')
+ expect(lastCompleteError.errCode).toEqual(1300002)
+
+ // 非递归创建一级目录。期望成功
+ await page.setData({
+ recursiveVal: false,
+ mkdirFile: 'a/提前创建的目录',
+ })
+
+ await btnMkdDirButton.tap()
+ await isDone()
+
+ await page.setData({
+ readDir: 'a',
+ })
+
+ await btnReadDirButton.tap()
+ await isDone()
+
+ fileListComplete = await getData('fileListComplete')
+ fileListComplete.sort()
+ expect(JSON.stringify(fileListComplete)).toEqual("[\"b\",\"" + testDirName +
+ "\",\"提前创建的目录\"]")
+ fileListSuccess = await getData('fileListSuccess')
+ fileListSuccess.sort()
+ expect(JSON.stringify(fileListSuccess)).toEqual("[\"b\",\"" + testDirName +
+ "\",\"提前创建的目录\"]")
+
+
+ await page.setData({
+ copyFromFile: "a/" + testDirName + "/中文路径/张三/name/中文文件.mock",
+ copyToFile: "a/提前创建的目录/4.txt"
+ })
+
+ const btnCopyFileButton = await page.$('#btn-copy-file')
+ await btnCopyFileButton.tap()
+ await isDone()
+
+ await page.setData({
+ readDir: 'a/提前创建的目录',
+ })
+
+ await btnReadDirButton.tap()
+ await isDone()
+
+ fileListComplete = await getData('fileListComplete')
+ expect(JSON.stringify(fileListComplete)).toEqual("[\"4.txt\"]")
+ fileListSuccess = await getData('fileListSuccess')
+ expect(JSON.stringify(fileListSuccess)).toEqual("[\"4.txt\"]")
+
+ await page.setData({
+ unlinkFile: 'a/提前创建的目录/4.txt',
+ rmDirFile: 'a/提前创建的目录'
+ })
+ await btnUnLinkFileButton.tap()
+ await isDone()
+
+ await btnReadDirButton.tap()
+ await isDone()
+
+ fileListComplete = await getData('fileListComplete')
+ expect(JSON.stringify(fileListComplete)).toEqual("[]")
+ fileListSuccess = await getData('fileListSuccess')
+ expect(JSON.stringify(fileListSuccess)).toEqual("[]")
+
+ });
+
+
+
+ it('CROSS DIR test', async () => {
+ /**
+ * 跨越用户目录和代码资源目录
+ */
+ let globalRootPath = await getData('globalRootPath')
+ await page.setData({
+ recursiveVal: true,
+ logAble: false,
+ basePath: globalRootPath,
+ readDir: 'a',
+ rmDirFile: 'a',
+ mkdirFile: 'a',
+ accessFile: 'a/从代码目录拷贝的资源.png',
+ unlinkFile: 'a/从代码目录拷贝的资源.png'
+ })
+
+
+ // 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败
+ const btnClearFileButton = await page.$('#btn-clear-file')
+ await btnClearFileButton.tap()
+ await isDone()
+
+
+ // 清除文件夹
+ const btnRmDirButton = await page.$('#btn-remove-dir')
+ await btnRmDirButton.tap()
+ await isDone()
+
+ // 重新创建测试目录,期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
+ const btnMkdDirButton = await page.$('#btn-mkdir')
+ await btnMkdDirButton.tap()
+ await isDone()
+
+ const btnReadDirButton = await page.$('#btn-read-dir')
+ await btnReadDirButton.tap()
+ await isDone()
+
+ let fileListComplete = await getData('fileListComplete')
+ expect(JSON.stringify(fileListComplete)).toEqual('[]')
+ let fileListSuccess = await getData('fileListSuccess')
+ expect(JSON.stringify(fileListSuccess)).toEqual('[]')
+
+
+ // 检查资源文件,此时不存在
+ const btnAccessFileButton = await page.$('#btn-access-file')
+ await btnAccessFileButton.tap()
+ await isDone()
+
+ let accessFileRet = await getData("accessFileRet")
+ expect(accessFileRet).toEqual('')
+
+
+ // 准备从资源目录拷贝png
+ await page.setData({
+ basePath: "",
+ unlinkFile: 'static/test-image/logo.ico',
+ accessFile: 'static/test-image/logo.ico',
+ })
+ // 检查资源文件,期望存在
+ await btnAccessFileButton.tap()
+ await isDone()
+
+ accessFileRet = await getData("accessFileRet")
+ expect(accessFileRet).toEqual('access:ok')
+
+ // 尝试删除资源,期望失败
+ const btnUnLinkFileButton = await page.$('#btn-unlink-file')
+ await btnUnLinkFileButton.tap()
+ await isDone()
+
+ await btnAccessFileButton.tap()
+ await isDone()
+
+ accessFileRet = await getData("accessFileRet")
+ expect(accessFileRet).toEqual('access:ok')
+ // 复制资源到 root目录
+ await page.setData({
+ copyToBasePath: globalRootPath,
+ copyFromFile: "static/test-image/logo.ico",
+ copyToFile: "a/从代码目录拷贝的资源.png"
+ })
+ const btnCopyFileButton = await page.$('#btn-copy-file')
+ await btnCopyFileButton.tap()
+ await isDone()
+
+ // 检查期望 root 目录中图片文件存在
+ await page.setData({
+ basePath: globalRootPath,
+ unlinkFile: 'a/从代码目录拷贝的资源.png',
+ accessFile: 'a/从代码目录拷贝的资源.png',
+ rmDirFile: 'a',
+ })
+ await btnAccessFileButton.tap()
+ await isDone()
+
+ accessFileRet = await getData("accessFileRet")
+ expect(accessFileRet).toEqual('access:ok')
+
+ await btnUnLinkFileButton.tap()
+ await isDone()
+
+ await btnAccessFileButton.tap()
+ await isDone()
+
+ accessFileRet = await getData("accessFileRet")
+ expect(accessFileRet).toEqual('')
+
+ // 从页面的按钮触发一次文件复制
+ const btnCopyStaticFileButton = await page.$('#btn-copyStatic-file')
+ await btnCopyStaticFileButton.tap()
+ await isDone()
+
+ await btnReadDirButton.tap()
+ await isDone()
+
+ fileListComplete = await getData('fileListComplete')
+ expect(JSON.stringify(fileListComplete)).toEqual("[\"mock.json\"]")
+ fileListSuccess = await getData('fileListSuccess')
+ expect(JSON.stringify(fileListSuccess)).toEqual("[\"mock.json\"]")
+
+ // 从页面的按钮触发一次文件清空
+ await btnClearFileButton.tap()
+ await isDone()
+
+ await btnReadDirButton.tap()
+ await isDone()
+
+ fileListComplete = await getData('fileListComplete')
+ expect(JSON.stringify(fileListComplete)).toEqual("[]")
+ fileListSuccess = await getData('fileListSuccess')
+ expect(JSON.stringify(fileListSuccess)).toEqual("[]")
+
+ });
+
+
+ it('write and read', async () => {
+ /**
+ * 测试writefile readfile 各个参数是否符合预期
+ */
+ let globalTempPath = await getData('globalTempPath')
+ await page.setData({
+ recursiveVal: true,
+ logAble: false,
+ basePath: globalTempPath,
+ readDir: 'd',
+ rmDirFile: 'd',
+ mkdirFile: 'd',
+ writeFileContent: "我爱北京天安门,天安门前太阳升",
+ writeFileEncoding: "utf-8",
+ readFileEncoding: "utf-8",
+ unlinkFile: 'd/write.bing',
+ writeFile: 'd/write.bing',
+ readFile: 'd/write.bing',
+ getFileInfoFile: 'd/write.bing',
+ getFileInfoAlgorithm: "sha1"
+ })
+
+ // 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败
+ const btnUnLinkFileButton = await page.$('#btn-unlink-file')
+ await btnUnLinkFileButton.tap()
+ await isDone()
+
+ // 清除文件夹
+ const btnRmDirButton = await page.$('#btn-remove-dir')
+ await btnRmDirButton.tap()
+ await isDone()
+
+ // 重新创建测试目录,期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
+ const btnMkdDirButton = await page.$('#btn-mkdir')
+ await btnMkdDirButton.tap()
+ await isDone()
+
+ const btnReadDirButton = await page.$('#btn-read-dir')
+ await btnReadDirButton.tap()
+ await isDone()
+
+ let fileListComplete = await getData('fileListComplete')
+ expect(JSON.stringify(fileListComplete)).toEqual('[]')
+ let fileListSuccess = await getData('fileListSuccess')
+ expect(JSON.stringify(fileListSuccess)).toEqual('[]')
+
+ // 先用utf-8 写入内容
+ const btnWriteFileButton = await page.$('#btn-write-file')
+ await btnWriteFileButton.tap()
+ await isDone()
+
+ const btnReadFileButton = await page.$('#btn-read-file')
+ await btnReadFileButton.tap()
+ await isDone()
+ let readFileRet = await getData('readFileRet')
+ expect(readFileRet).toEqual("我爱北京天安门,天安门前太阳升")
+
+ const btnGetFileInfoButton = await page.$('#btn-get-file-info')
+ await btnGetFileInfoButton.tap()
+ await isDone()
+
+ let getFileInfoSize = await getData('getFileInfoSize')
+ expect(getFileInfoSize).toEqual(45)
+ let getFileInfoDigest = await getData('getFileInfoDigest')
+ expect(getFileInfoDigest).toEqual("2ae9c7672ff6c1e7c7e6a0bb4e74a6f06b39350b")
+
+ // 尝试读取base64 信息
+ await page.setData({
+ readFileEncoding: "base64",
+ })
+
+ await btnReadFileButton.tap()
+ await isDone()
+ readFileRet = await getData('readFileRet')
+ expect(readFileRet).toEqual("5oiR54ix5YyX5Lqs5aSp5a6J6Zeo77yM5aSp5a6J6Zeo5YmN5aSq6Ziz5Y2H")
+ // 测试ascii,需要特别测试 ascii 写入非法字符的情况,因为微信的常量字符编码和android原生有差异。
+
+ await page.setData({
+ writeFileContent: "丙辰中秋,欢饮达旦,大醉,作此篇,兼怀子由。明月几时有?把酒问青天。不知天上宫阙,今夕是何年。我欲乘风归去,又恐琼楼玉宇,高处不胜寒。起舞弄清影,何似在人间",
+ writeFileEncoding: "ascii",
+ readFileEncoding: "base64",
+ })
+
+ await btnWriteFileButton.tap()
+ await isDone()
+
+ await btnGetFileInfoButton.tap()
+ await isDone()
+
+ getFileInfoSize = await getData('getFileInfoSize')
+ expect(getFileInfoSize).toEqual(78)
+ getFileInfoDigest = await getData('getFileInfoDigest')
+ expect(getFileInfoDigest).toEqual("4ac7a65055628818341c2ad86ddc4205d8503801")
+
+ await btnReadFileButton.tap()
+ await isDone()
+ readFileRet = await getData('readFileRet')
+ expect(readFileRet).toEqual(
+ "GbAtywwibr7mDCeJDFxkxwx8AFAxAg4I4PYJH4pS7lIpAg3lKQqrGQzKFS9VdAIRMljOUrsMyFA8fImHDNgEDdzSAnceBAVxDFU8KLr0"
+ )
+
+ // 尝试写入合法ascii
+ await page.setData({
+ writeFileContent: "hello jack.hello marry.",
+ writeFileEncoding: "ascii",
+ readFileEncoding: "ascii",
+ })
+
+ await btnWriteFileButton.tap()
+ await isDone()
+
+ await btnReadFileButton.tap()
+ await isDone()
+ readFileRet = await getData('readFileRet')
+ expect(readFileRet).toEqual("hello jack.hello marry.")
+
+ // 写入base64 获取 中文
+ await page.setData({
+ writeFileContent: "5LiZ6L6w5Lit56eL77yM5qyi6aWu6L6+5pem77yM5aSn6YaJ77yM5L2c5q2k56+H77yM5YW85oCA5a2Q55Sx44CC5piO5pyI5Yeg5pe25pyJ77yf5oqK6YWS6Zeu6Z2S5aSp44CC5LiN55+l5aSp5LiK5a6r6ZiZ77yM5LuK5aSV5piv5L2V5bm044CC5oiR5qyy5LmY6aOO5b2S5Y6777yM5Y+I5oGQ55C85qW8546J5a6H77yM6auY5aSE5LiN6IOc5a+S44CC6LW36Iie5byE5riF5b2x77yM5L2V5Ly85Zyo5Lq66Ze0",
+ writeFileEncoding: "base64",
+ readFileEncoding: "utf-8",
+ })
+
+ await btnWriteFileButton.tap()
+ await isDone()
+
+ await btnReadFileButton.tap()
+ await isDone()
+ readFileRet = await getData('readFileRet')
+ expect(readFileRet).toEqual(
+ "丙辰中秋,欢饮达旦,大醉,作此篇,兼怀子由。明月几时有?把酒问青天。不知天上宫阙,今夕是何年。我欲乘风归去,又恐琼楼玉宇,高处不胜寒。起舞弄清影,何似在人间")
+
+ await page.setData({
+ readFileEncoding: "base64",
+ })
+
+ await btnReadFileButton.tap()
+ await isDone()
+ readFileRet = await getData('readFileRet')
+ expect(readFileRet).toEqual(
+ "5LiZ6L6w5Lit56eL77yM5qyi6aWu6L6+5pem77yM5aSn6YaJ77yM5L2c5q2k56+H77yM5YW85oCA5a2Q55Sx44CC5piO5pyI5Yeg5pe25pyJ77yf5oqK6YWS6Zeu6Z2S5aSp44CC5LiN55+l5aSp5LiK5a6r6ZiZ77yM5LuK5aSV5piv5L2V5bm044CC5oiR5qyy5LmY6aOO5b2S5Y6777yM5Y+I5oGQ55C85qW8546J5a6H77yM6auY5aSE5LiN6IOc5a+S44CC6LW36Iie5byE5riF5b2x77yM5L2V5Ly85Zyo5Lq66Ze0"
+ )
+
+ });
+
+ it('stat and asset test', async () => {
+ // 测试 USER_DATA_PATH //globalTempPath
+ let globalRootPath = await getData('globalRootPath')
+
+ await page.setData({
+ recursiveVal: true,
+ copyToBasePath: globalRootPath,
+ basePath: globalRootPath,
+ globalTempPath: globalRootPath,
+ rmDirFile: 'a',
+ mkdirFile: 'a',
+ unlinkFile: 'a/1.txt',
+ })
+
+ // 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败
+ const btnUnLinkFileButton = await page.$('#btn-unlink-file')
+ await btnUnLinkFileButton.tap()
+ await isDone()
+
+ await page.setData({
+ unlinkFile: 'a/2.txt',
+ })
+ await btnUnLinkFileButton.tap()
+ await isDone()
+
+ await page.setData({
+ unlinkFile: 'a/m/3.txt',
+ })
+ await btnUnLinkFileButton.tap()
+ await isDone()
+
+ // // 清除文件夹
+ const btnRmDirButton = await page.$('#btn-remove-dir')
+ await btnRmDirButton.tap()
+ await isDone()
+ // // 重新创建测试目录
+ const btnMkdDirButton = await page.$('#btn-mkdir')
+ await btnMkdDirButton.tap()
+ await isDone()
+
+ const btnReadDirButton = await page.$('#btn-read-dir')
+ await btnReadDirButton.tap()
+ await isDone()
+
+
+ // 期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
+ let fileListComplete = await getData('fileListComplete')
+ expect(JSON.stringify(fileListComplete)).toEqual('[]')
+ let fileListSuccess = await getData('fileListSuccess')
+ expect(JSON.stringify(fileListSuccess)).toEqual('[]')
+
+ // 写入一个文件
+ await page.setData({
+ writeFileContent: "锄禾日当午,汗滴禾下土,谁知盘中餐,粒粒皆辛苦",
+ writeFileEncoding: "utf-8",
+ writeFile: 'a/1.txt',
+ recursiveVal: false,
+ statFile: 'a/1.txt',
+ })
+
+ let lastFailError = await getData('lastFailError')
+ console.log(lastFailError)
+
+ const btnWriteFileButton = await page.$('#btn-write-file')
+ await btnWriteFileButton.tap()
+ await isDone()
+
+ let btnStatFileButton = await page.$('#btn-stat-file')
+ await btnStatFileButton.tap()
+ await isDone()
+
+ // 读取单个文件信息
+ let statsRet = await getData('statsRet')
+ expect(statsRet.length).toEqual(1)
+ expect(statsRet[0].path).toMatch(new RegExp('.*/a/1.txt$'))
+ expect(statsRet[0].stats.size).toEqual(69)
+ if (isAndroid()) {
+ // 写入一个文件
+ await page.setData({
+ statsRet: ''
+ })
+ btnStatFileButton = await page.$('#btn-stat-file-sync')
+ await btnStatFileButton.tap()
+ await isDone()
+
+ // 读取单个文件信息
+ statsRet = await getData('statsRet')
+ expect(statsRet.length).toEqual(1)
+ expect(statsRet[0].path).toMatch(new RegExp('.*/a/1.txt$'))
+ expect(statsRet[0].stats.size).toEqual(69)
+ }
+
+ /**
+ * 创建子目录和子目录文件,测试recursive参数
+ */
+ await page.setData({
+ writeFileContent: "1234567890",
+ writeFileEncoding: "ascii",
+ writeFile: 'a/2.txt',
+ basePath: globalRootPath,
+ recursiveVal: false,
+ statFile: 'a',
+ mkdirFile: 'a/m',
+ })
+
+
+ await btnWriteFileButton.tap()
+ await isDone()
+
+ // 创建子目录
+ await btnMkdDirButton.tap()
+ await isDone()
+
+ // 复制一份文件到 /a/m/3.txt
+ await page.setData({
+ // asset 只能正式版测试,这里只能模拟返回路径
+ basePath: '',
+ copyFromFile: 'static/test-image/logo.ico',
+ copyToFile: 'a/m/3.txt',
+ })
+ const btnCopyFileButton = await page.$('#btn-copy-file')
+ await btnCopyFileButton.tap()
+ await isDone()
+
+
+ await page.setData({
+ basePath: globalRootPath,
+ recursiveVal: true,
+ statFile: 'a',
+ })
+
+ await btnStatFileButton.tap()
+ await isDone()
+
+ // 读取全部文件信息
+ statsRet = await getData('statsRet')
+
+ statsRet.sort(function(a, b) {
+ if (a.path > b.path) {
+ return 1
+ } else if (a.path < b.path) {
+ return -1
+ }
+ return 0
+ })
+ console.log(statsRet)
+ expect(statsRet.length).toEqual(5)
+ expect(statsRet[0].path).toMatch(new RegExp('.*/a$'))
+ // expect(statsRet[0].stats.size).toEqual(0)
+
+ expect(statsRet[2].path).toMatch(new RegExp('.*/a/2.txt$'))
+ expect(statsRet[2].stats.size).toEqual(10)
+
+ expect(statsRet[4].path).toMatch(new RegExp('.*/a/m/3.txt$'))
+ expect(statsRet[4].stats.size).toEqual(156406)
+
+
+ // 清理文件,避免影响其他测试用例
+ await page.setData({
+ unlinkFile: 'a/1.txt',
+ })
+ await btnUnLinkFileButton.tap()
+ await isDone()
+
+ await page.setData({
+ unlinkFile: 'a/2.txt',
+ })
+ await btnUnLinkFileButton.tap()
+ await isDone()
+
+ await page.setData({
+ unlinkFile: 'a/m/3.txt',
+ rmDirFile: 'a',
+ readDir: 'a',
+ recursiveVal: true,
+ })
+ await btnUnLinkFileButton.tap()
+ await isDone()
+
+ await btnRmDirButton.tap()
+ await isDone()
+
+ await btnReadDirButton.tap()
+ await isDone()
+
+ // 期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
+ fileListComplete = await getData('fileListComplete')
+ expect(JSON.stringify(fileListComplete)).toEqual('[]')
+ fileListSuccess = await getData('fileListSuccess')
+ expect(JSON.stringify(fileListSuccess)).toEqual('[]')
+
+ });
+ it('appendFileTest', async () => {
+ if (!isAndroid()) {
+ return
+ }
+
+
+ let basePath = await getData('basePath')
+
+ await page.setData({
+ basePath: mBasePath,
+ recursiveVal: true,
+ logAble: false,
+ rmDirFile: 'appendfile',
+ mkdirFile: 'appendfile',
+ writeFileContent: "我爱北京天安门,天安门前太阳升",
+ appendFileContent: "再说一遍",
+ writeFileEncoding: "utf-8",
+ readFileEncoding: "utf-8",
+ readFile: 'appendfile/appendfile.txt',
+ unlinkFile: 'appendfile/appendfile.txt',
+ writeFile: 'appendfile/appendfile.txt',
+ })
+
+ // 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败
+ const btnUnLinkFileButton = await page.$('#btn-unlink-file')
+ await btnUnLinkFileButton.tap()
+ await isDone()
+
+ // 清除文件夹
+ const btnRmDirButton = await page.$('#btn-remove-dir')
+ await btnRmDirButton.tap()
+ await isDone()
+
+ // 重新创建测试目录,期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
+ const btnMkdDirButton = await page.$('#btn-mkdir')
+ await btnMkdDirButton.tap()
+ await isDone()
+
+ // 先用utf-8 写入内容
+ const btnWriteFileButton = await page.$('#btn-write-file')
+
+ await btnWriteFileButton.tap()
+ await isDone()
+
+
+ //追加内容
+ const btnAppendFileButton = await page.$('#btn-append-file')
+ await btnAppendFileButton.tap()
+ await isDone()
+
+ const btnReadFileButton = await page.$('#btn-read-file')
+ await btnReadFileButton.tap()
+ await isDone()
+ let readFileRet = await getData('readFileRet')
+ expect(readFileRet).toEqual("我爱北京天安门,天安门前太阳升再说一遍")
+ });
+ //nlinkSyncTest mkdirSyncTest appendFileTest writeFileSyncTest readFileSyncTest rmdirSyncTest readDirSyncTest accessFileSyncTest
+ //renameFileSync copyFileSyncTest appendFileSyncTest truncateFileTest truncateFileSyncTest
+ it('sync test',
+ async () => {
+ if (!isAndroid()) {
+ return
+ }
+
+
+ await page.setData({
+ basePath: mBasePath,
+ recursiveVal: false,
+ logAble: false,
+ rmDirFile: 'sync',
+ mkdirFile: 'sync',
+ writeFileContent: "我爱北京天安门,天安门前太阳升",
+ appendFileContent: "再说一遍",
+ writeFileEncoding: "utf-8",
+ readFileEncoding: "utf-8",
+ readDir: 'sync',
+ rmDirFile: 'sync',
+ unlinkFile: 'sync/sync.txt',
+ readFile: 'sync/sync.txt',
+ writeFile: 'sync/sync.txt',
+ accessFile: 'sync/sync.txt',
+ renameToFile: 'sync/sync.txt',
+ renameFromFile: 'sync/sync.txt',
+ })
+ await clearDir('sync')
+ // 重新创建测试目录,期望通过 recursive = true的 文件夹删除,得到一个空的 目录
+ const btnMkdDirButton = await page.$('#btn-mkdir-sync')
+ await btnMkdDirButton.tap()
+ await isDone()
+
+ const btnReadDirButton = await page.$('#btn-read-dir-sync')
+ await btnReadDirButton.tap()
+ await isDone()
+ const fileListSuccess = await getData('fileListSuccess')
+ expect(JSON.stringify(fileListSuccess)).toEqual('[]')
+
+ // 先用utf-8 写入内容
+ const btnWriteFileButton = await page.$('#btn-write-file-sync')
+ await btnWriteFileButton.tap()
+ await isDone()
+
+ let btnAccessFileButton = await page.$('#btn-access-file-sync')
+ await btnAccessFileButton.tap()
+ await isDone()
+ let accessFileRet = await getData("accessFileRet")
+ expect(accessFileRet).toEqual('access:ok')
+
+ //重新命名文件
+ const btnRenameFileButton = await page.$('#btn-rename-file-sync')
+ await btnRenameFileButton.tap()
+ await isDone()
+ let renameFileRet = await getData("renameFileRet")
+ expect(renameFileRet).toEqual("rename:ok")
+
+
+ //追加内容
+ let btnAppendFileButton = await page.$('#btn-append-file')
+ await btnAppendFileButton.tap()
+ await isDone()
+
+ btnAppendFileButton = await page.$('#btn-append-file-sync')
+ await btnAppendFileButton.tap()
+
+
+ let btnReadFileButton = await page.$('#btn-read-file-sync')
+ await btnReadFileButton.tap()
+ await isDone()
+ let readFileRet = await getData('readFileRet')
+ expect(readFileRet).toEqual("我爱北京天安门,天安门前太阳升再说一遍再说一遍")
+
+ //truncateFileTest
+ let btnTruncateFile = await page.$('#btn-truncate-file')
+ await btnTruncateFile.tap()
+ await isDone()
+ btnReadFileButton = await page.$('#btn-read-file-sync')
+ await btnReadFileButton.tap()
+ await isDone()
+ readFileRet = await getData('readFileRet')
+ expect(readFileRet).toEqual("我爱北京天安门")
+
+ btnTruncateFile = await page.$('#btn-truncate-file-sync')
+ await btnTruncateFile.tap()
+ await isDone()
+ btnReadFileButton = await page.$('#btn-read-file-sync')
+ await btnReadFileButton.tap()
+ await isDone()
+ readFileRet = await getData('readFileRet')
+ expect(readFileRet).toEqual("我爱北京")
+
+
+ // 测试 copyfile
+ await page.setData({
+ basePath: mBasePath,
+ copyToBasePath: mBasePath,
+ copyFromFile: "sync/sync.txt",
+ copyToFile: "sync/syncto.txt",
+ accessFile: "sync/syncto.txt"
+ })
+ const btnCopyFileButton = await page.$('#btn-copy-file-sync')
+ await btnCopyFileButton.tap()
+ await isDone()
+ btnAccessFileButton = await page.$('#btn-access-file-sync')
+ await btnAccessFileButton.tap()
+ await isDone()
+ accessFileRet = await getData("accessFileRet")
+ expect(accessFileRet).toEqual('access:ok')
+
+ await clearDir('sync')
+ });
+
+ async function createFile() {
+ // 重新创建测试目录,期望通过 recursive = true的 文件夹删除,得到一个空的 目录
+ const btnMkdDirButton = await page.$('#btn-mkdir-sync')
+ await btnMkdDirButton.tap()
+ await isDone()
+
+ // 先用utf-8 写入内容
+ const btnWriteFileButton = await page.$('#btn-write-file-sync')
+ await btnWriteFileButton.tap()
+ await isDone()
+ }
+
+ async function clearDir(dir) {
+ // 最后需要清楚所有文件避免测试失败
+ await page.setData({
+ rmDirFile: dir,
+ })
+ const btnUnLinkFileButton = await page.$('#btn-clear-file')
+ await btnUnLinkFileButton.tap()
+ await isDone()
+
+ const btnClear = await page.$('#btn-remove-dir')
+ await btnClear.tap()
+ await isDone()
+ }
+
+ function isAndroid() {
+ if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW ===
+ 'true') {
+ expect(1).toBe(1)
+ return false
+ }
+ if (process.env.uniTestPlatformInfo.toLocaleLowerCase().startsWith('ios')) {
+ expect(1).toBe(1)
+ return false
+ }
+ return true
+ }
+
+ it('getSavedFileListTest',
+ async () => {
+ if (!isAndroid()) {
+ return
+ }
+ // await page.setData({
+ // logAble: false,
+ // basePath: mBasePath
+ // })
+ // console.log('getSavedFileListTest', 'start')
+ // await clearDir('')
+ // console.log('getSavedFileListTest', 'end')
+ await page.setData({
+ logAble: false,
+ basePath: mGlobalTempPath,
+ temFile: 'save3/2.txt',
+ mkdirFile: 'save3',
+ writeFile: 'save3/2.txt',
+ accessFile: '2.txt'
+ })
+ await createFile()
+ await page.setData({
+ basePath: mBasePath,
+ writeFile: 'save/2.txt',
+ })
+ btnSaveFile = await page.$('#btn-save-file-sync')
+ await btnSaveFile.tap()
+ await isDone()
+ let btnSavedFileList = await page.$('#btn-getsaved-filelist')
+ await btnSavedFileList.tap()
+ await isDone()
+ let getSavedFileListRet = await getData("getSavedFileListRet")
+ console.log('getSavedFileListTest->' + getSavedFileListRet)
+ expect(getSavedFileListRet).toEqual('getSavedFileList:ok')
+ });
+
+ it('removeSavedFileTest',
+ async () => {
+ if (!isAndroid()) {
+ return
+ }
+ await page.setData({
+ logAble: false,
+ basePath: mBasePath
+ })
+ await clearDir('save4')
+ await page.setData({
+ logAble: false,
+ basePath: mGlobalTempPath,
+ temFile: 'save4/saveSync.txt',
+ mkdirFile: 'save4',
+ writeFile: 'save4/saveSync.txt',
+ accessFile: 'saveSync.txt'
+ })
+ await createFile()
+ let btnRemoveSavedFileRet = await page.$('#btn-remove-saved-file')
+ await btnRemoveSavedFileRet.tap()
+ await isDone()
+ let removeSavedFileRet = await getData("removeSavedFileRet")
+ expect(removeSavedFileRet).toEqual('removeSavedFile:ok')
+
+ });
+
+ //openFiletest openFileSynctest closeTest closeTestSync writeTest writeSyncTest
+ it('openFiletest', async () => {
+ if (!isAndroid()) {
+ return
+ }
+
+ await page.setData({
+ basePath: mBasePath,
+ logAble: false,
+ mkdirFile: 'fd',
+ writeFile: 'fd/1.txt',
+ readFile: 'fd/1.txt'
+ })
+ await clearDir('fd')
+ await createFile()
+ console.log('openFiletest', '2')
+ //openFiletest
+ let btnOpenFile = await page.$('#btn-open-file')
+ await btnOpenFile.tap()
+ await isDone()
+ let fd = await getData("fd")
+ expect(fd).not.toBe('');
+ await page.setData({
+ fd: '',
+ })
+ console.log('openFiletest', '3')
+ //openFileSynctest
+ btnOpenFile = await page.$('#btn-open-file-sync')
+ await btnOpenFile.tap()
+ await isDone()
+ fd = await getData("fd")
+ expect(fd).not.toBe('');
+ console.log('openFiletest', '4')
+ });
+ // closeTest closeTestSync
+ it('closeTest', async () => {
+ if (!isAndroid()) {
+ return
+ }
+
+
+
+ await page.setData({
+ basePath: mBasePath,
+ logAble: false,
+ mkdirFile: 'fd',
+ writeFile: 'fd/1.txt',
+ readFile: 'fd/1.txt'
+ })
+ await clearDir('fd')
+ await createFile()
+ //closeTest
+ let btnCloseFile = await page.$('#btn-close-file')
+ await btnCloseFile.tap()
+ await isDone()
+ let closeFileRet = await getData("closeFileRet")
+ expect(closeFileRet).toEqual('close:ok')
+ await page.setData({
+ closeFileRet: '',
+ })
+ //closeTestSync
+ btnCloseFile = await page.$('#btn-close-file-sync')
+ await btnCloseFile.tap()
+ await isDone()
+ closeFileRet = await getData("closeFileRet")
+ expect(closeFileRet).toEqual('close:ok')
+
+ });
+ //writeTest writeSyncTest
+ it('writeTest', async () => {
+ if (!isAndroid()) {
+ return
+ }
+ console.log('writeTest', 'start')
+
+ await page.setData({
+ basePath: mBasePath,
+ logAble: false,
+ mkdirFile: 'fd',
+ writeFile: 'fd/1.txt',
+ readFile: 'fd/1.txt',
+ writeData: '我是一只小小鸟'
+ })
+ await clearDir('fd')
+ await createFile()
+ console.log('writeTest', '1')
+ let btnWrite = await page.$('#btn-write')
+ await btnWrite.tap()
+ await isDone()
+ let bytesWritten = await getData("bytesWritten")
+ let lastFailError = await getData("lastFailError")
+ if (bytesWritten != 7) {
+ let writeData = await getData("writeData")
+ console.log('writeTest', lastFailError.errCode, lastFailError.errMsg, bytesWritten,
+ writeData)
+ }
+
+ expect(bytesWritten).toEqual(7)
+ console.log('writeTest', '2')
+ //writeSyncTest
+ await page.setData({
+ writeFile: 'fd/1.txt',
+ readFile: 'fd/1.txt',
+ writeData: '我是'
+ })
+
+ btnWrite = await page.$('#btn-write-sync')
+ await btnWrite.tap()
+ await isDone()
+ bytesWritten = await getData("bytesWritten")
+ expect(bytesWritten).toEqual(2)
+ console.log('writeTest', '3')
+ //fstatTest
+ let btnFstat = await page.$('#btn-fstat-file')
+ await btnFstat.tap()
+ await isDone()
+ let fstat = await getData("fstat")
+ expect(fstat.size > 0).toBe(true)
+ console.log('writeTest', '4')
+
+ //fstatSyncTest
+ btnFstat = await page.$('#btn-fstat-file-sync')
+ await btnFstat.tap()
+ await isDone()
+ fstat = await getData("fstat")
+ expect(fstat.size > 0).toBe(true)
+ console.log('writeTest', '5')
+
+ //ftruncateFileTest
+ let btnFTruncateFile = await page.$('#btn-ftruncate-file')
+ await btnFTruncateFile.tap()
+ await isDone()
+ let ftruncateRet = await getData("ftruncateRet")
+ expect(fstat).not.toEqual('ftruncate:ok')
+ await page.setData({
+ ftruncate: '',
+ })
+ console.log('writeTest', '6')
+
+ //ftruncateFileSyncTest
+ btnFTruncateFile = await page.$('#btn-ftruncate-file-sync')
+ await btnFTruncateFile.tap()
+ await isDone()
+ ftruncateRet = await getData("ftruncateRet")
+ expect(fstat).not.toEqual('ftruncate:ok')
+ console.log('writeTest', '7')
+ });
+ //writeTest writeSyncTest
+ it('ftruncateFileTest', async () => {
+ if (!isAndroid()) {
+ return
+ }
+ console.log('ftruncateFileTest', 'start')
+
+ await page.setData({
+ basePath: mBasePath,
+ logAble: false,
+ mkdirFile: 'fd',
+ writeFile: 'fd/1.txt',
+ readFile: 'fd/1.txt',
+ writeData: '我是一只小小鸟我是'
+ })
+ await clearDir('fd')
+ await createFile()
+ console.log('ftruncateFileTest', '1')
+ btnWrite = await page.$('#btn-write-sync')
+ await btnWrite.tap()
+ await isDone()
+ bytesWritten = await getData("bytesWritten")
+ expect(bytesWritten).toEqual(9)
+ console.log('ftruncateFileTest', '3')
+ //ftruncateFileTest
+ let btnFTruncateFile = await page.$('#btn-ftruncate-file')
+ await btnFTruncateFile.tap()
+ await isDone()
+ let ftruncateRet = await getData("ftruncateRet")
+ expect(ftruncateRet).toEqual('ftruncate:ok')
+ await page.setData({
+ ftruncate: '',
+ })
+ console.log('ftruncateFileTest', '6')
+
+ //ftruncateFileSyncTest
+ btnFTruncateFile = await page.$('#btn-ftruncate-file-sync')
+ await btnFTruncateFile.tap()
+ await isDone()
+ ftruncateRet = await getData("ftruncateRet")
+ expect(ftruncateRet).toEqual('ftruncate:ok')
+ console.log('ftruncateFileTest', '7')
+ });
+
+ //testAppendFileBuffer
+ it('testAppendFileBuffer', async () => {
+ if (!isAndroid()) {
+ return
+ }
+
+ var btnWrite = await page.$('#btn-appendfile-buffer')
+ await btnWrite.tap()
+ await isDone()
+ let arrayBufferRes = await getData("arrayBufferRes")
+ expect(arrayBufferRes).toEqual(21)
+ });
+
+ it('testAppendFileBufferSync', async () => {
+ if (!isAndroid()) {
+ return
+ }
+
+ var btnWrite = await page.$('#btn-appendfilesync-buffer')
+ await btnWrite.tap()
+ await isDone()
+ let arrayBufferRes = await getData("arrayBufferRes")
+ expect(arrayBufferRes).toEqual(20)
+ });
+
+ it('testWriteReadSyncBuffer', async () => {
+ if (!isAndroid()) {
+ return
+ }
+
+ var btnWrite = await page.$('#btn-writereadsync-buffer')
+ await btnWrite.tap()
+ await isDone()
+ let arrayBufferRes = await getData("arrayBufferRes")
+ expect(arrayBufferRes).toEqual(1.11)
+ });
+
+ it('testWriteReadBuffer', async () => {
+ if (!isAndroid()) {
+ return
+ }
+
+ var btnWrite = await page.$('#btn-writeread-buffer')
+ await btnWrite.tap()
+ await isDone()
+ let arrayBufferRes = await getData("arrayBufferRes")
+ expect(arrayBufferRes).toEqual(1.24)
+ });
+
+ it('testWriteReadFileSyncBuffer', async () => {
+ if (!isAndroid()) {
+ return
+ }
+
+ var btnWrite = await page.$('#btn-writereadfilesync-buffer')
+ await btnWrite.tap()
+ await isDone()
+ let arrayBufferRes = await getData("arrayBufferRes")
+ expect(arrayBufferRes).toEqual(1.333)
+ });
+
+ it('testReadFileBuffer', async () => {
+ if (!isAndroid()) {
+ return
+ }
+
+ var btnWrite = await page.$('#btn-writereadfile-buffer')
+ await btnWrite.tap()
+ await isDone()
+ let arrayBufferRes = await getData("arrayBufferRes")
+ expect(arrayBufferRes).toEqual(1.2222222)
+ });
});
diff --git a/pages/API/get-file-system-manager/get-file-system-manager.uvue b/pages/API/get-file-system-manager/get-file-system-manager.uvue
index 72bce6ddb2545c877febb6ca9b59aafd7f34aa2f..efdd3fcbe3f42a06fab45a71707ef3433d56a36e 100644
--- a/pages/API/get-file-system-manager/get-file-system-manager.uvue
+++ b/pages/API/get-file-system-manager/get-file-system-manager.uvue
@@ -1,1281 +1,1668 @@
-
-
- 显示简易操作日志,详细日志需真机运行查看
- {{ log }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+ 显示简易操作日志(可滚动查看),详细日志需真机运行查看
+
+ {{ log }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/API/get-image-info/get-image-info.uvue b/pages/API/get-image-info/get-image-info.uvue
index 449c69ee628c4503f621e4c00f5b7ca5b246eb58..82f93e912d6be120d5f4953ddd45b55615b66527 100644
--- a/pages/API/get-image-info/get-image-info.uvue
+++ b/pages/API/get-image-info/get-image-info.uvue
@@ -1,119 +1,119 @@
-
-
-
-
-
-
-
- 获取本地相对路径图片信息
-
-
- {{absoluteImageInfo}}
-
- 获取网络路径图片信息
-
-
- {{remoteImageInfo}}
-
- 获取本地绝对路径图片信息
-
-
- {{relativeImageInfo}}
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/pages/API/get-launch-options-sync/get-launch-options-sync.uvue b/pages/API/get-launch-options-sync/get-launch-options-sync.uvue
index 3e589d4b7ec08e56473144ff9e024b2b6abe624d..3ec91ef8f1995fe294ed48986ba9ce160c242727 100644
--- a/pages/API/get-launch-options-sync/get-launch-options-sync.uvue
+++ b/pages/API/get-launch-options-sync/get-launch-options-sync.uvue
@@ -14,7 +14,6 @@
+
diff --git a/pages/API/get-native-view/element-getnativeview.uvue b/pages/API/get-native-view/element-getnativeview.uvue
index 041b9ff8ca543d25e35ac9d32967d8ad7104723a..c2e2b39e8c8a182753a6c0c5c677e51164504786 100644
--- a/pages/API/get-native-view/element-getnativeview.uvue
+++ b/pages/API/get-native-view/element-getnativeview.uvue
@@ -2,7 +2,7 @@
-
+
// 注意:iOS平台真机运行时需要安装 Xcode 开发工具具备 UTS 开发环境,或提交自定基座打包后 checkNativeView 相关方法才会生效
@@ -20,64 +20,64 @@
}
},
methods: {
- checkViewNativeView() : boolean {
- var viewName = "ViewGroup"
- // #ifdef APP-IOS
- viewName = "UIView"
- // #endif
- const msg = "检测view组件对应原生"+viewName
- if (checkViewNativeView("view")) {
- this.showTip(msg+"成功")
+ checkViewNativeView() : boolean {
+ var viewName = "ViewGroup"
+ // #ifdef APP-IOS
+ viewName = "UIView"
+ // #endif
+ const msg = "检测view组件对应原生" + viewName
+ if (checkViewNativeView("view")) {
+ this.showTip(msg + "成功")
return true
- }
- this.showTip(msg+"失败")
+ }
+ this.showTip(msg + "失败")
return false
},
- checkInputNativeView() : boolean {
- var viewName = "AppCompatEditText"
- // #ifdef APP-IOS
- viewName = "UITextField"
- // #endif
- const msg = "检测input组件对应原生"+viewName
- if (checkInputNativeView("input")) {
- this.showTip(msg+"成功")
+ checkInputNativeView() : boolean {
+ var viewName = "AppCompatEditText"
+ // #ifdef APP-IOS
+ viewName = "UITextField"
+ // #endif
+ const msg = "检测input组件对应原生" + viewName
+ if (checkInputNativeView("input")) {
+ this.showTip(msg + "成功")
return true
- }
- this.showTip(msg+"失败")
+ }
+ this.showTip(msg + "失败")
return false
},
- checkTextareaNativeView() : boolean {
- var viewName = "AppCompatEditText"
- // #ifdef APP-IOS
- viewName = "UITextView"
- // #endif
- const msg = "检测textarea组件对应原生"+viewName
- if (checkTextareaNativeView("textarea")) {
- this.showTip(msg+"成功")
+ checkTextareaNativeView() : boolean {
+ var viewName = "AppCompatEditText"
+ // #ifdef APP-IOS
+ viewName = "UITextView"
+ // #endif
+ const msg = "检测textarea组件对应原生" + viewName
+ if (checkTextareaNativeView("textarea")) {
+ this.showTip(msg + "成功")
return true
- }
- this.showTip(msg+"失败")
+ }
+ this.showTip(msg + "失败")
return false
},
- checkWebViewNativeView() : boolean {
- var viewName = "WebView"
- // #ifdef APP-IOS
- viewName = "WKWebView"
- // #endif
- const msg = "检测webview组件对应原生"+viewName
- if (checkWebViewNativeView("webview")) {
- this.showTip(msg+"成功")
+ checkWebViewNativeView() : boolean {
+ var viewName = "WebView"
+ // #ifdef APP-IOS
+ viewName = "WKWebView"
+ // #endif
+ const msg = "检测webview组件对应原生" + viewName
+ if (checkWebViewNativeView("webview")) {
+ this.showTip(msg + "成功")
return true
- }
- this.showTip(msg+"失败")
+ }
+ this.showTip(msg + "失败")
return false
- },
- showTip(title: string) {
- console.log("title==="+title)
- uni.showToast({
- title: title,
- icon: "none"
- })
+ },
+ showTip(title : string) {
+ console.log("title===" + title)
+ uni.showToast({
+ title: title,
+ icon: "none"
+ })
}
}
}
@@ -112,9 +112,9 @@
border-width: 1px;
border-color: black;
border-style: solid;
- }
-
- .button {
- margin: 10px 20px;
+ }
+
+ .button {
+ margin: 10px 20px;
}
diff --git a/pages/API/get-system-info/get-system-info.test.js b/pages/API/get-system-info/get-system-info.test.js
index b5a9994307bfb48b3530372a7b712eba7b74b402..5b211de1a0865d47e922e438f1f09f5e3f15c64a 100644
--- a/pages/API/get-system-info/get-system-info.test.js
+++ b/pages/API/get-system-info/get-system-info.test.js
@@ -56,6 +56,13 @@ describe('ExtApi-GetSystemInfo', () => {
expect(['light', 'dark', 'auto']).toContain(value);
}
}
+ if (process.env.uniTestPlatformInfo.startsWith('android')) {
+ if (res.safeAreaInsets.bottom > 0) {
+ expect(res.safeAreaInsets.top + 44 + res.windowHeight).toBe(res.screenHeight);
+ } else {
+ expect(res.safeAreaInsets.top + 44 + res.windowHeight).toBe(res.safeArea.bottom);
+ }
+ }
});
it('Check GetSystemInfoSync required properties', async () => {
for (let i = 0; i < requiredProperties.length; i++) {
diff --git a/pages/API/get-system-setting/get-system-setting.uvue b/pages/API/get-system-setting/get-system-setting.uvue
index c3b49bbdfca729e3602f15cc7f3d74f3870a9822..25bdf66674c0cc53a1c5d9ece52968fed35bd43d 100644
--- a/pages/API/get-system-setting/get-system-setting.uvue
+++ b/pages/API/get-system-setting/get-system-setting.uvue
@@ -41,7 +41,7 @@
-
+
-
-
diff --git a/pages/API/get-video-info/get-video-info.uvue b/pages/API/get-video-info/get-video-info.uvue
index c61323d1918065ec25590f916cb30f1684ca5a34..431c9a739d1d136dedae74d2fe113939f5f5ed3a 100644
--- a/pages/API/get-video-info/get-video-info.uvue
+++ b/pages/API/get-video-info/get-video-info.uvue
@@ -1,87 +1,112 @@
-
-
-
-
-
-
-
- 获取本地绝对路径视频信息
-
-
- {{absoluteVideoInfo}}
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/pages/API/get-window-info/get-window-info.test.js b/pages/API/get-window-info/get-window-info.test.js
index a6a636178c22548973017942059bbf4a719584df..c6e223e8346c3e43d85204ce6b6bbe500f68277c 100644
--- a/pages/API/get-window-info/get-window-info.test.js
+++ b/pages/API/get-window-info/get-window-info.test.js
@@ -23,6 +23,13 @@ describe('ExtApi-GetWindowInfo', () => {
if (numberProperties.indexOf(key) != -1) {
expect(value).toBeGreaterThanOrEqual(0);
}
+ }
+ if (process.env.uniTestPlatformInfo.startsWith('android')) {
+ if (res.safeAreaInsets.bottom > 0) {
+ expect(res.safeAreaInsets.top + 44 + res.windowHeight).toBe(res.screenHeight);
+ } else {
+ expect(res.safeAreaInsets.top + 44 + res.windowHeight).toBe(res.safeArea.bottom);
+ }
}
});
});
diff --git a/pages/API/get-window-info/get-window-info.uvue b/pages/API/get-window-info/get-window-info.uvue
index f16176ddf7dbe28ae389b5c62483d703ce28c0b2..dc7c52c913bcfc2642d86f719732638bc8d62843 100644
--- a/pages/API/get-window-info/get-window-info.uvue
+++ b/pages/API/get-window-info/get-window-info.uvue
@@ -15,6 +15,13 @@
+
+
+
+
+
+
+
diff --git a/pages/API/get-window-info/window-area.uvue b/pages/API/get-window-info/window-area.uvue
new file mode 100644
index 0000000000000000000000000000000000000000..1be2b95f18f6c6cb676fa7da4f9c038102fae64f
--- /dev/null
+++ b/pages/API/get-window-info/window-area.uvue
@@ -0,0 +1,147 @@
+
+
+
+
+
+
+
+
+
+ 系统状态栏区域
+
+
+ 摄像头区域
+
+
+ 安全区域
+
+
+ 系统导航栏区域
+
+
+
+
+
+
+
+
+
diff --git a/pages/API/install-apk/install-apk.uvue b/pages/API/install-apk/install-apk.uvue
index 221242be6d6371eaf4d3cf22903ce186900406d4..3395948c62b6bdc555ecb75c86e2781144d35203 100644
--- a/pages/API/install-apk/install-apk.uvue
+++ b/pages/API/install-apk/install-apk.uvue
@@ -31,7 +31,7 @@
installApk: function () {
uni.installApk({
filePath: "/static/test-apk/test.apk",
- complete(res : any) {
+ complete(res : any) {
console.log(res);
}
})
diff --git a/pages/API/load-font-face/load-font-face-child.uvue b/pages/API/load-font-face/load-font-face-child.uvue
index 4b13385acdbf6ec6607c09d8f6deab91150b20e5..c92894f831921a88f6bb2210ee08e8346c5d7f6d 100644
--- a/pages/API/load-font-face/load-font-face-child.uvue
+++ b/pages/API/load-font-face/load-font-face-child.uvue
@@ -1,47 +1,47 @@
-
-
-
- 上一页全局加载字体:
- font-family: uni.ttf
-
- {{
- uniIcon1
- }}
- \ue100
- {{
- uniIcon2
- }}
- \ue101
-
- 上一页非全局加载字体(不生效为正常):
- font-family: 阿里妈妈刀隶体-ttf
- font-family: 阿里妈妈刀隶体-otf
-
-
-
-
-
-
-
diff --git a/pages/API/load-font-face/load-font-face.uvue b/pages/API/load-font-face/load-font-face.uvue
index a5a127819a1699ce4abaa41181883317fe6f99b1..aa7cbbfe27f7b2d0ad5632c255b6ebfe5efdea34 100644
--- a/pages/API/load-font-face/load-font-face.uvue
+++ b/pages/API/load-font-face/load-font-face.uvue
@@ -1,106 +1,106 @@
-
-
-
- 全局加载字体:
- font-family: uni.ttf
-
- {{
- uniIcon1
- }}
- \ue100
- {{
- uniIcon2
- }}
- \ue101
-
- 非全局加载字体:
- font-family: 阿里妈妈刀隶体-ttf
- (网络字体下载后生效)
- font-family:
- 阿里妈妈刀隶体-otf
- font-family: 阿里妈妈刀隶体-woff
- font-family: 阿里妈妈刀隶体-woff2
-
-
-
-
-
-
diff --git a/pages/API/make-phone-call/make-phone-call.uvue b/pages/API/make-phone-call/make-phone-call.uvue
index 33b784a984192ffdb861d05e4a73c3887b12482b..a14db5e5c820cbb84587bbedff7bb527e49eb907 100644
--- a/pages/API/make-phone-call/make-phone-call.uvue
+++ b/pages/API/make-phone-call/make-phone-call.uvue
@@ -1,51 +1,51 @@
-
-
-
-
- 请在下方输入电话号码
-
-
-
-
-
-
-
-
-
-
diff --git a/pages/API/navigator/navigator.uvue b/pages/API/navigator/navigator.uvue
index 541b56a7f0e6441504f33bd5a00d447b9994780a..4f26c96b1c00226c9a4c9998a8356b94b4bcd146 100644
--- a/pages/API/navigator/navigator.uvue
+++ b/pages/API/navigator/navigator.uvue
@@ -32,7 +32,7 @@
+
@@ -41,8 +41,9 @@
-
+
+
@@ -52,8 +53,8 @@
+
+
+
+ onLoad 接收到参数
+ data: {{ data }}
+
+
+
+
+
diff --git a/pages/API/navigator/new-page/new-page-3.uvue b/pages/API/navigator/new-page/new-page-3.uvue
index 9c366a83841ed4f92d0b6b70b68f39c52cfcca0d..64e7bc736df36b92a755bfd769f21b5199c38d2b 100644
--- a/pages/API/navigator/new-page/new-page-3.uvue
+++ b/pages/API/navigator/new-page/new-page-3.uvue
@@ -1,5 +1,5 @@
-
-
-
-
+
+
+
+
diff --git a/pages/API/navigator/new-page/onLoad.uvue b/pages/API/navigator/new-page/onLoad.uvue
index 847aa45f6531db80c4597a9468bb295f8c8791a1..6f06bd70391f41e83a3a5871be2e750461ce9493 100644
--- a/pages/API/navigator/new-page/onLoad.uvue
+++ b/pages/API/navigator/new-page/onLoad.uvue
@@ -1,132 +1,132 @@
-
+
-
-
- v-if with true
- v-if with false
- v-show with true
- v-show with false
- msg: {{ msg }}
-
+
+
+ v-if with true
+ v-if with false
+ v-show with true
+ v-show with false
+ msg: {{ msg }}
+
+
diff --git a/pages/API/open-location/open-location.uvue b/pages/API/open-location/open-location.uvue
index fe30900716abe7e12c49f73136f7cab15ed45715..f726bcfd552a495023b0c19a95b5c8e875ee9f56 100644
--- a/pages/API/open-location/open-location.uvue
+++ b/pages/API/open-location/open-location.uvue
@@ -49,7 +49,7 @@
-
-
diff --git a/pages/API/privacy/privacy.uvue b/pages/API/privacy/privacy.uvue
new file mode 100644
index 0000000000000000000000000000000000000000..c21ed2209c09a91178a4c02676005b0bf86a874f
--- /dev/null
+++ b/pages/API/privacy/privacy.uvue
@@ -0,0 +1,82 @@
+
+
+
+
+ 当前应用隐私授权状态:
+ {{ appPrivacy }}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/API/pull-down-refresh/pull-down-refresh.uvue b/pages/API/pull-down-refresh/pull-down-refresh.uvue
index 8b4c83b64792d13365c0a1f5eefbc91b29c26f60..acdda37be9d85735abdd554a4218fca4c6f0af7e 100644
--- a/pages/API/pull-down-refresh/pull-down-refresh.uvue
+++ b/pages/API/pull-down-refresh/pull-down-refresh.uvue
@@ -18,7 +18,7 @@
data: [] as Array,
loadMoreText: "加载中...",
showLoadMore: false,
- max: 0,
+ max: 0,
pulldownRefreshTriggered: false
}
},
@@ -38,7 +38,7 @@
}, 300);
},
onPullDownRefresh() {
- console.log('onPullDownRefresh');
+ console.log('onPullDownRefresh');
this.pulldownRefreshTriggered = true
this.initData();
},
diff --git a/pages/API/request-payment/request-payment/order-detail.uvue b/pages/API/request-payment/request-payment/order-detail.uvue
index 90492bda79600609c4a0d9e328f1d0c929420e6f..6ebca9f88f550309935033bc4516399649d01de2 100644
--- a/pages/API/request-payment/request-payment/order-detail.uvue
+++ b/pages/API/request-payment/request-payment/order-detail.uvue
@@ -1,37 +1,37 @@
-
-
-
- 你自己的业务系统订单详情页面
-
-
- order_no:{{ myOptions['order_no'] }}
-
-
- out_trade_no:{{ myOptions['out_trade_no'] }}
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+ 你自己的业务系统订单详情页面
+
+
+ order_no:{{ myOptions['order_no'] }}
+
+
+ out_trade_no:{{ myOptions['out_trade_no'] }}
+
+
+
+
+
+
+
diff --git a/pages/API/request-payment/request-payment/request-payment-uni-pay.uvue b/pages/API/request-payment/request-payment/request-payment-uni-pay.uvue
index 467f57c7edc7f81bbc4c0b5f7c09d4ac189a21f9..5df9b3fef6efcc8a460518ae29f211f5c8a911c8 100644
--- a/pages/API/request-payment/request-payment/request-payment-uni-pay.uvue
+++ b/pages/API/request-payment/request-payment/request-payment-uni-pay.uvue
@@ -1,519 +1,524 @@
-
-
-
- 支付单号:
-
-
-
- 支付金额(单位分,100=1元):
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ 支付单号:
+
+
+
+ 支付金额(单位分,100=1元):
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/API/request/request.uvue b/pages/API/request/request.uvue
index 35d8c378bd103cad4a9e9638e3fd2e0734efc4d9..b6afb2f38a8c599525c6f0d2aca1f857d145a6fe 100644
--- a/pages/API/request/request.uvue
+++ b/pages/API/request/request.uvue
@@ -68,17 +68,17 @@
-
-
-
diff --git a/pages/API/save-image-to-photos-album/save-image-to-photos-album.test.js b/pages/API/save-image-to-photos-album/save-image-to-photos-album.test.js
index 46e34fcfe5e25eb8fe34bcc74085ca8e8e5311ab..61b247f1deea804846e9f6584db3b337a44a3155 100644
--- a/pages/API/save-image-to-photos-album/save-image-to-photos-album.test.js
+++ b/pages/API/save-image-to-photos-album/save-image-to-photos-album.test.js
@@ -1,25 +1,26 @@
-// uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
-describe('API-saveImageToPhotosAlbum', () => {
- if (process.env.uniTestPlatformInfo.startsWith('web') || process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) {
- it('pass', async () => {
- expect(1).toBe(1);
- });
- return;
- }
-
- let page;
- beforeAll(async () => {
- page = await program.reLaunch('/pages/API/save-image-to-photos-album/save-image-to-photos-album');
- await page.waitFor(500);
- });
-
- it('test saveImageToPhotosAlbum', async () => {
- if (process.env.uniTestPlatformInfo.startsWith('android')) {
- await program.adbCommand(
- 'pm grant io.dcloud.uniappx android.permission.WRITE_EXTERNAL_STORAGE');
- await page.waitFor(500);
- }
- await page.callMethod('saveImage');
- expect(await page.data('success')).toBe(true);
- });
+const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
+const isAndroid = platformInfo.startsWith('android')
+
+
+describe('API-saveImageToPhotosAlbum', () => {
+ if (!isAndroid) {
+ it('pass', async () => {
+ expect(1).toBe(1);
+ });
+ return;
+ }
+
+ let page;
+ beforeAll(async () => {
+ page = await program.reLaunch('/pages/API/save-image-to-photos-album/save-image-to-photos-album');
+ await page.waitFor(500);
+ });
+
+ it('test saveImageToPhotosAlbum', async () => {
+ await program.adbCommand(
+ 'pm grant io.dcloud.uniappx android.permission.WRITE_EXTERNAL_STORAGE');
+ await page.waitFor(500);
+ await page.callMethod('saveImage');
+ expect(await page.data('success')).toBe(true);
+ });
});
diff --git a/pages/API/save-image-to-photos-album/save-image-to-photos-album.uvue b/pages/API/save-image-to-photos-album/save-image-to-photos-album.uvue
index 1a3bea9328ccb64f8aed3965077254ae62b8fa2d..9cd82cfa69639954cb8693ab041baae740a13ed3 100644
--- a/pages/API/save-image-to-photos-album/save-image-to-photos-album.uvue
+++ b/pages/API/save-image-to-photos-album/save-image-to-photos-album.uvue
@@ -1,61 +1,61 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/pages/API/save-video-to-photos-album/save-video-to-photos-album.uvue b/pages/API/save-video-to-photos-album/save-video-to-photos-album.uvue
index b9d89d0bb6131f8829ad1b17ebbb20c9edf8b6a1..d467ecff17c981cde53109f9819892c082cc0452 100644
--- a/pages/API/save-video-to-photos-album/save-video-to-photos-album.uvue
+++ b/pages/API/save-video-to-photos-album/save-video-to-photos-album.uvue
@@ -1,60 +1,60 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/pages/API/set-navigation-bar-title/set-navigation-bar-title.uvue b/pages/API/set-navigation-bar-title/set-navigation-bar-title.uvue
index 5999d3ef2dd47cff45ccf12ecb771d982dbbb5ea..0062d85616bd1feb67fb866550ebda1865234e0f 100644
--- a/pages/API/set-navigation-bar-title/set-navigation-bar-title.uvue
+++ b/pages/API/set-navigation-bar-title/set-navigation-bar-title.uvue
@@ -1,65 +1,65 @@
-
-
-
-
-
-
-
-
-
diff --git a/pages/API/set-page-backgroundColorContent/set-page-backgroundColorContent.uvue b/pages/API/set-page-backgroundColorContent/set-page-backgroundColorContent.uvue
index cde1911fd7ddf06bd739c98a4603b51a59846c99..473ef629058781b7147d12bf85d8af80205e3b0f 100644
--- a/pages/API/set-page-backgroundColorContent/set-page-backgroundColorContent.uvue
+++ b/pages/API/set-page-backgroundColorContent/set-page-backgroundColorContent.uvue
@@ -1,35 +1,35 @@
-
-
- 点击切换页面容器颜色
-
-
-
-
-
-
+
+
+ 点击切换页面容器颜色
+
+
+
+
+
+
diff --git a/pages/API/show-action-sheet/show-action-sheet.uvue b/pages/API/show-action-sheet/show-action-sheet.uvue
index 57955275a40e26ca2f3621a5996c8956bcee6dcf..40c9c61572c606f440e9f51fe8a59f3d04f768d9 100644
--- a/pages/API/show-action-sheet/show-action-sheet.uvue
+++ b/pages/API/show-action-sheet/show-action-sheet.uvue
@@ -1,4 +1,7 @@
-
+
+
+
+
@@ -25,10 +28,14 @@
-
+
-
+
+
+
+
diff --git a/pages/API/show-modal/show-modal.uvue b/pages/API/show-modal/show-modal.uvue
index a17b1c1bdc280010d1644889a14d1893e1611afe..469c206d965bf2cf530cb5af9a10c0e5dee7d8ae 100644
--- a/pages/API/show-modal/show-modal.uvue
+++ b/pages/API/show-modal/show-modal.uvue
@@ -1,160 +1,160 @@
-
-
-
-
-
-
-
-
-
- {{ item.name }}
-
-
-
-
-
- 是否显示取消按钮
-
-
-
- 定制取消文案
-
-
-
- 定制确认文案
-
-
-
- 是否显示输入框
-
-
-
- 是否定制输入提示词
-
-
-
-
-
-
-
- {{ exeRet }}
-
-
-
-
-
-
-
-
diff --git a/pages/API/show-toast/show-toast.test.js b/pages/API/show-toast/show-toast.test.js
index b68cb65fde4f7a06887df10ff7723367e5720b02..8b4bbf9632aeeaa80d0cd915bacbd5060c5543ad 100644
--- a/pages/API/show-toast/show-toast.test.js
+++ b/pages/API/show-toast/show-toast.test.js
@@ -53,6 +53,13 @@ describe('API-toast', () => {
}
})
+ it("icon=none-mask=true-toast-test", async () => {
+ await page.setData({maskSelect: true})
+ await page.callMethod('toast3Tap')
+ await page.waitFor(300);
+ await toScreenshot('icon=none-mask=true-toast-image')
+ })
+
it("image-toast-test", async () => {
await page.setData({imageSelect: true})
await page.waitFor(300);
diff --git a/pages/API/show-toast/show-toast.uvue b/pages/API/show-toast/show-toast.uvue
index a53b4cafc5ee214ef83b4ba5ee1022261991e587..11fb45545e6ca88722f503e577468fb0b6178f69 100644
--- a/pages/API/show-toast/show-toast.uvue
+++ b/pages/API/show-toast/show-toast.uvue
@@ -1,151 +1,168 @@
-
-
-
-
-
-
-
- 设置icon
-
-
-
- {{icon.name}}
-
-
-
- 是否显示自定义图标
-
-
-
- 是否显示透明蒙层-屏蔽点击事件
-
-
- 提示的延迟时间,默认:1500(单位毫秒)
-
-
-
-
-
-
-
-
-
- 设置position,仅App生效
-
-
-
- {{position.name}}
-
-
-
-
- {{exeRet}}
-
-
-
-
-
-
-
-
diff --git a/pages/API/storage/storage.uvue b/pages/API/storage/storage.uvue
index 4b91b7b56b6ef687f569e0dfde27aaef50ea1fbc..ee22a74ccc448a7c8f934163092b0063f8c960d0 100644
--- a/pages/API/storage/storage.uvue
+++ b/pages/API/storage/storage.uvue
@@ -1,376 +1,377 @@
-
-
-
-
-
-
-
-
-
-
- key
-
-
-
-
-
-
-
- value
-
-
-
-
-
-
-
-
-
-
-
- {{ storageInfo }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/pages/API/theme-change/theme-change.uvue b/pages/API/theme-change/theme-change.uvue
index 253a7413cd68bc9807563f0fa9058da5250a40a8..a1435d83fef20fb4e0cf65ea48b535faf572adca 100644
--- a/pages/API/theme-change/theme-change.uvue
+++ b/pages/API/theme-change/theme-change.uvue
@@ -3,101 +3,100 @@
osTheme:
{{ osTheme }}
-
-
- 应用当前主题:
- {{ appTheme }}
-
-
-
-
- 修改appTheme主题(此处仅为演示API,本应用并未完整适配暗黑模式)
-
-
-
-
-
- {{ item }}
-
-
-
+
+
+ 应用当前主题:
+ {{ appTheme }}
+
+
+
+
+ 修改appTheme主题(此处仅为演示API,本应用并未完整适配暗黑模式)
+
+
+
+
+
+ {{ item }}
+
+
+
-
@@ -106,8 +105,9 @@
display: flex;
flex-direction: row;
justify-content: space-between;
- }
- .uni-list-cell {
- justify-content: flex-start;
+ }
+
+ .uni-list-cell {
+ justify-content: flex-start;
}
diff --git a/pages/API/uni-push/uni-push.uvue b/pages/API/uni-push/uni-push.uvue
index e92c9a70df316fb5a0b85e437de981d633aaef7b..abf640aa21440a5ebc563058a98356105c70515d 100644
--- a/pages/API/uni-push/uni-push.uvue
+++ b/pages/API/uni-push/uni-push.uvue
@@ -13,9 +13,9 @@
创建本地通知消息 | createPushMessage
- 不同手机厂商的角标显示规则不同,有部分设备的rom版本不支持显示角标,另有部分rom需要在应用的通知管理里开启`桌面角标`配置,才可以设置角标成功。\n
+ 不同手机厂商的角标显示规则不同,有部分设备的rom版本不支持显示角标,另有部分rom需要在应用的通知管理里开启`桌面角标`配置,才可以设置角标成功。\n
部分rom需要在设置中同时开启`通知开关`和`桌面角标`配置,才允许设置角标,例如鸿蒙4.2。 \n
- 另外针对高版本小米设备,会借助创建通知栏消息来设置角标数,所以设置时需要注意是否有权限创建通知栏消息。
+ 另外针对高版本小米设备,会借助创建通知栏消息来设置角标数,所以设置时需要注意是否有权限创建通知栏消息。
-
-
+
+
-
+
-
-
diff --git a/pages/component/unicloud-db/unicloud-db/contacts/add.uvue b/pages/component/unicloud-db/unicloud-db/contacts/add.uvue
index fd216944c21d71a025443996c04b3241c6c69171..1f6739f43fdb201bcb47d32f48e356c83230ad95 100644
--- a/pages/component/unicloud-db/unicloud-db/contacts/add.uvue
+++ b/pages/component/unicloud-db/unicloud-db/contacts/add.uvue
@@ -1,117 +1,117 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/pages/component/unicloud-db/unicloud-db/contacts/detail.uvue b/pages/component/unicloud-db/unicloud-db/contacts/detail.uvue
index 0585a9dcffe352a86251de5fe5f33032d090c70f..9ed5d8a2c0254626faf2df6388766cb67b274992 100644
--- a/pages/component/unicloud-db/unicloud-db/contacts/detail.uvue
+++ b/pages/component/unicloud-db/unicloud-db/contacts/detail.uvue
@@ -1,110 +1,110 @@
-
-
-
- {{error.errMsg}}
- 正在加载...
-
-
- 姓名
- {{data[0]['username']}}
-
-
- 电话
- {{data[0]['mobile']}}
-
-
- 邮箱
- {{data[0]['email']}}
-
-
- 备注
- {{data[0]['comment']}}
-
-
- 性别
- {{displayGender(data[0].getNumber('gender'))}}
-
- 编辑
-
-
-
-
-
-
-
-
diff --git a/pages/component/unicloud-db/unicloud-db/contacts/edit.uvue b/pages/component/unicloud-db/unicloud-db/contacts/edit.uvue
index 083d971fc23fd0e17c046508f7351d618bde74db..af731c1d3b2dac15179d2afb8bab9a8f17adfcef 100644
--- a/pages/component/unicloud-db/unicloud-db/contacts/edit.uvue
+++ b/pages/component/unicloud-db/unicloud-db/contacts/edit.uvue
@@ -1,170 +1,171 @@
-
-
-
- {{error.errMsg}}
- 正在加载...
-
-
-
-
-
-
-
-
diff --git a/pages/component/unicloud-db/unicloud-db/contacts/list.uvue b/pages/component/unicloud-db/unicloud-db/contacts/list.uvue
index 63e89f0c3e3cbd0634c86f00f2e22caa0d1fdf06..2e18d0190771df05af78ecc74fb531be7f95aa81 100644
--- a/pages/component/unicloud-db/unicloud-db/contacts/list.uvue
+++ b/pages/component/unicloud-db/unicloud-db/contacts/list.uvue
@@ -1,145 +1,145 @@
-
-
-
- {{error.errMsg}}
-
-
-
- {{item['username']}}
- {{item['mobile']}}
-
-
-
-
-
-
-
- +
-
-
-
-
-
-
-
diff --git a/pages/component/unicloud-db/unicloud-db/contacts/types.uts b/pages/component/unicloud-db/unicloud-db/contacts/types.uts
index 4d204bfe4d93e698d6956bfa2b81c11729763a2c..277a97cb17f9f466b5e597087803dcec1a430364 100644
--- a/pages/component/unicloud-db/unicloud-db/contacts/types.uts
+++ b/pages/component/unicloud-db/unicloud-db/contacts/types.uts
@@ -1,25 +1,25 @@
-export const COLLECTION_NAME = 'opendb-contacts'
-
-export type GenderType = {
- text : string,
- value : number,
-}
-
-export const GenderList = [
- {
- text: "未知",
- value: 0
- },
- {
- text: "男",
- value: 1
- },
- {
- text: "女",
- value: 2
- },
-] as GenderType[]
-
-export const UNICLOUD_DB_CONTACTS_ADD = 'unicloud-db-contacts-add'
-export const UNICLOUD_DB_CONTACTS_UPDATE = 'unicloud-db-contacts-update'
+export const COLLECTION_NAME = 'opendb-contacts'
+
+export type GenderType = {
+ text : string,
+ value : number,
+}
+
+export const GenderList = [
+ {
+ text: "未知",
+ value: 0
+ },
+ {
+ text: "男",
+ value: 1
+ },
+ {
+ text: "女",
+ value: 2
+ },
+] as GenderType[]
+
+export const UNICLOUD_DB_CONTACTS_ADD = 'unicloud-db-contacts-add'
+export const UNICLOUD_DB_CONTACTS_UPDATE = 'unicloud-db-contacts-update'
export const UNICLOUD_DB_CONTACTS_DELETE = 'unicloud-db-contacts-delete'
diff --git a/pages/component/unicloud-db/unicloud-db/mixin-datacom/datacom.uvue b/pages/component/unicloud-db/unicloud-db/mixin-datacom/datacom.uvue
index d6392ff818fd1b864fc7f43ed35e44ff395825a0..b581703dacf9822ac8009c7c8cdbf2081a8c6d9a 100644
--- a/pages/component/unicloud-db/unicloud-db/mixin-datacom/datacom.uvue
+++ b/pages/component/unicloud-db/unicloud-db/mixin-datacom/datacom.uvue
@@ -1,70 +1,70 @@
-
-
- Loading...
-
- 请求错误:{{mixinDatacomError}}
-
-
-
-
-
-
- {{item}}
-
-
-
-
- 无数据
-
-
-
-
-
-
-
diff --git a/pages/component/unicloud-db/unicloud-db/mixin-datacom/mixin-datacom.uvue b/pages/component/unicloud-db/unicloud-db/mixin-datacom/mixin-datacom.uvue
index 9f3ce40507fb2956b862afbcd1ec55b377048240..5db9958fbc56e23a8b13bd01300a14e1e2621f97 100644
--- a/pages/component/unicloud-db/unicloud-db/mixin-datacom/mixin-datacom.uvue
+++ b/pages/component/unicloud-db/unicloud-db/mixin-datacom/mixin-datacom.uvue
@@ -1,27 +1,27 @@
-
-
-
-
-
-
-
-
-
diff --git a/pages/component/video/video-format.uvue b/pages/component/video/video-format.uvue
index 348524ab530c5f4de118e9c26d6d3700556cc9a9..db14cf4ea22c17ccd025135c74deb58566b9b8d3 100644
--- a/pages/component/video/video-format.uvue
+++ b/pages/component/video/video-format.uvue
@@ -1,110 +1,111 @@
-
-
-
-
-
-
-
- 支持的视频格式示例
-
-
- {{item.format}}
-
-
-
- 暂不支持的格式
-
-
- {{item.format}}
-
-
-
-
-
-
-
-
-
-
-
diff --git a/pages/component/video/video.uvue b/pages/component/video/video.uvue
index 96075f402192d3b3ae3f49b8df27f1675764ecbe..bb06158f66be83f1c3cf6f5482d9b262662bb43b 100644
--- a/pages/component/video/video.uvue
+++ b/pages/component/video/video.uvue
@@ -1,562 +1,608 @@
-
-
-
-
-
-
- 视频格式示例
-
-
-
-
- 子组件实现快进、快退功能(全屏后显示)
-
-
-
-
- API示例
-
-
- 播放
-
-
- 暂停
-
-
-
- 跳转到指定位置
-
-
-
- 进入全屏
-
-
- 退出全屏
-
-
- 停止
-
-
-
- 发送弹幕
-
-
-
- 设置倍速
-
-
- 属性示例
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+ 视频格式示例
+
+
+
+
+ 子组件实现快进、快退、发送弹幕功能(全屏后显示)
+
+
+
+
+ API示例
+
+
+ 播放
+
+
+ 暂停
+
+
+
+ 跳转到指定位置
+
+
+
+ 进入全屏
+
+
+ 退出全屏
+
+
+ 停止
+
+
+
+ 发送弹幕
+
+
+
+ 设置倍速
+
+
+ 属性示例
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/component/view/view.uvue b/pages/component/view/view.uvue
index e97ae3d7de09db7ceacd8e339a3f909c2f4d15e3..1dac9cc30fecad3ab514449595bcc9e36ce355ef 100644
--- a/pages/component/view/view.uvue
+++ b/pages/component/view/view.uvue
@@ -1,73 +1,73 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/pages/component/web-view/web-view.test.js b/pages/component/web-view/web-view.test.js
index 55946ec8b252083be2c0507dfa2920beed856eb5..091e610fee10c532bc59776e72bbaf868d33f3f3 100644
--- a/pages/component/web-view/web-view.test.js
+++ b/pages/component/web-view/web-view.test.js
@@ -42,45 +42,25 @@ describe('component-native-web-view', () => {
const info = await page.callMethod('getWindowInfo');
await program.tap({
x: 1,
- y: (info.statusBarHeight + 44) * info.pixelRatio + 1
- });
- start = Date.now();
- await page.waitFor(async () => {
- return (await page.data('eventTouchstart')) && (await page.data('eventTap')) || (Date.now() - start > 500);
+ y: info.statusBarHeight + 44 + 1
});
+ await page.waitFor(500);
if(process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios') == false) {
- expect(await page.data('eventTouchstart')).toEqual({
- clientX: 1,
- clientY: 1
- });
-
- expect(await page.data('eventTap')).toEqual({
- clientX: 1,
- clientY: 1
- });
+ expect(await page.data('isTouchEnable')).toBe(true);
}
await page.setData({
- pointerEvents: 'none'
+ pointerEvents: 'none',
+ isTouchEnable: false
});
await page.waitFor(100);
await program.tap({
x: 10,
- y: (info.statusBarHeight + 44) * info.pixelRatio + 10
- });
- start = Date.now();
- await page.waitFor(async () => {
- return (await page.data('eventTouchstart')) && (await page.data('eventTap')) || (Date.now() - start > 500);
+ y: info.statusBarHeight + 44 + 10
});
+ await page.waitFor(500);
if(process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios') == false) {
- expect(await page.data('eventTouchstart')).toEqual({
- clientX: 1,
- clientY: 1
- });
- expect(await page.data('eventTap')).toEqual({
- clientX: 1,
- clientY: 1
- });
+ expect(await page.data('isTouchEnable')).toBe(false);
}
await page.setData({
pointerEvents: 'auto'
diff --git a/pages/component/web-view/web-view.uvue b/pages/component/web-view/web-view.uvue
index a859ff3e3714603d5066f5f6a8788f1590831bbc..ad645599a64767592ea34819c2620f84e4c863c9 100644
--- a/pages/component/web-view/web-view.uvue
+++ b/pages/component/web-view/web-view.uvue
@@ -1,200 +1,217 @@
-
-
-
-
-
-
-
-
-
-
- 后退
- 前进
-
-
- 重新加载
- 停止加载
-
-
- 原生和Web通信
-
-
-
-
- 显示横向滚动条
-
-
-
- 显示竖向滚动条
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/pages/component/web-view/web-view/web-view-local.uvue b/pages/component/web-view/web-view/web-view-local.uvue
index f02337b052f55db7087b7839083488e1340757b4..7d49fcd27395698e2c69644e03757f9358453809 100644
--- a/pages/component/web-view/web-view/web-view-local.uvue
+++ b/pages/component/web-view/web-view/web-view-local.uvue
@@ -1,79 +1,79 @@
-
-
-
-
-
-
-
-
diff --git a/pages/pages.test.js b/pages/pages.test.js
index 9d1f20ca56b41c02a4c1f2bd00d10056b3622826..8e370a305636410bb9416a7b6461427fa5ee80d6 100755
--- a/pages/pages.test.js
+++ b/pages/pages.test.js
@@ -270,12 +270,12 @@ const pages = [
'/pages/template/custom-long-list/custom-long-list',
'/pages/template/test-background-color-content/test-background-color-content',
'/pages/template/slider-100/slider-100',
-]
-
-if (isAndroid && isWeb) {
- pages.push(
- '/pages/API/get-battery-info/get-battery-info',
- )
+]
+
+if (isAndroid && isWeb) {
+ pages.push(
+ '/pages/API/get-battery-info/get-battery-info',
+ )
}
if (isApp && !isAppWebview) {
@@ -417,6 +417,6 @@ describe("page screenshot test", () => {
return `__pages_test__/${currentPagePath.replace(/\//g, "-").substring(1)}`
}
})
- await page.waitFor(500);
+ await page.waitFor(800);
});
});
diff --git a/pages/tabBar/API.uvue b/pages/tabBar/API.uvue
index 494662de9d2edeb42319881c8c9204b2dde0fabe..031fe55a292b20143f5b7f405e0e72ac880cce1f 100644
--- a/pages/tabBar/API.uvue
+++ b/pages/tabBar/API.uvue
@@ -12,17 +12,15 @@
:inWhiteList="true">
-
-
+
+ hover-class="is--active" @click="goPage(`/${childMenuItem.path}`)">
{{ childMenuItem.style["navigationBarTitleText"] }}
+ :class="{'left-win-active': leftWinActive === childMenuItem.path && hasLeftWin}">{{ childMenuItem.style["navigationBarTitleText"] }}
@@ -30,7 +28,7 @@
-
-
+
-
-
+
- {{ item.name }}
+ {{ item.name }}
-
- {{ page.name }}
+
+ {{ page.name }}
@@ -50,18 +53,18 @@
pages : Page[]
url ?: string
enable ?: boolean
- }
+ }
import { state } from '@/store/index.uts'
export default {
data() {
return {
- list: [
- {
- id: 'slider-100',
- url: 'slider-100',
- name: 'slider-100',
- open: false,
- pages: [] as Page[],
+ list: [
+ {
+ id: 'slider-100',
+ url: 'slider-100',
+ name: 'slider-100',
+ open: false,
+ pages: [] as Page[],
},
{
id: 'long-list',
@@ -223,14 +226,14 @@
arrowDownIcon: '/static/icons/arrow-down.png',
arrowRightIcon: '/static/icons/arrow-right.png',
}
- },
- computed: {
- hasLeftWin():boolean{
- return !state.noMatchLeftWindow
- },
- leftWinActive():string{
- return state.leftWinActive.split('/')[3]
- }
+ },
+ computed: {
+ hasLeftWin() : boolean {
+ return !state.noMatchLeftWindow
+ },
+ leftWinActive() : string {
+ return state.leftWinActive.split('/')[3]
+ }
},
methods: {
triggerCollapse(index : number, item : ListItem) {
@@ -262,34 +265,34 @@
const url =
e.url.indexOf('platform') > -1
? e.url
- : `/pages/template/${e.url}/${e.url}`
- if(this.hasLeftWin) {
- uni.reLaunch({ url })
- } else {
- uni.navigateTo({ url })
+ : `/pages/template/${e.url}/${e.url}`
+ if (this.hasLeftWin) {
+ uni.reLaunch({ url })
+ } else {
+ uni.navigateTo({ url })
}
},
- },
- // #ifdef WEB
- watch: {
- $route: {
- immediate: true,
- handler(newRoute) {
- if (newRoute.matched.length) {
- let path = newRoute.path.split('/')[3]
- for (const item of this.list) {
- if (Array.isArray(item.pages)) {
- for (const page of item.pages) {
- if (page.url && page.url === path) {
- item.open = true
- }
- }
- }
- }
- }
- }
- }
- },
+ },
+ // #ifdef WEB
+ watch: {
+ $route: {
+ immediate: true,
+ handler(newRoute) {
+ if (newRoute.matched.length) {
+ let path = newRoute.path.split('/')[3]
+ for (const item of this.list) {
+ if (Array.isArray(item.pages)) {
+ for (const page of item.pages) {
+ if (page.url && page.url === path) {
+ item.open = true
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
// #endif
}
diff --git a/pages/template/navbar-lite/navbar-lite.uvue b/pages/template/navbar-lite/navbar-lite.uvue
index d0ab33c5e2cb431bb0bab8addb890c37b52c3bf6..18e9427ef0299ab1991a6df0d728b2ac780f5386 100644
--- a/pages/template/navbar-lite/navbar-lite.uvue
+++ b/pages/template/navbar-lite/navbar-lite.uvue
@@ -19,7 +19,7 @@
web-view
-
+
内容:{{item}}
diff --git a/pages/template/pull-zoom-image/pull-zoom-image.uvue b/pages/template/pull-zoom-image/pull-zoom-image.uvue
index b0fe100637f3c8083f9c41ce276b2f2e696788d8..afbf66dfad0d7bbf761b40ee51dbe3b97b1a602b 100644
--- a/pages/template/pull-zoom-image/pull-zoom-image.uvue
+++ b/pages/template/pull-zoom-image/pull-zoom-image.uvue
@@ -106,11 +106,11 @@
}
.head-img-box-1 .img {
- top: 0;
+ top: 0px;
}
.head-img-box-2 .img {
- bottom: -100;
+ bottom: -100px;
}
.head-img-box-2 {
diff --git a/pages/template/slider-100/slider-100.uvue b/pages/template/slider-100/slider-100.uvue
index 54651575d3f53d476bc7cff5c9b4d581f81b9b27..b41663aa92a4205ff8dd3290fb44f181ab92bce3 100644
--- a/pages/template/slider-100/slider-100.uvue
+++ b/pages/template/slider-100/slider-100.uvue
@@ -10,6 +10,7 @@
+
diff --git a/uni_modules/native-button/package.json b/uni_modules/native-button/package.json
new file mode 100644
index 0000000000000000000000000000000000000000..3f86656ca71735c35c208c76e14b9470efe9cab9
--- /dev/null
+++ b/uni_modules/native-button/package.json
@@ -0,0 +1,82 @@
+{
+ "id": "native-button",
+ "displayName": "native-button",
+ "version": "0.0.1",
+ "description": "vue开发button原生组件",
+ "repository": "",
+ "engines": {
+ "HBuilderX": "^4.25"
+ },
+ "dcloudext": {
+ "type": "uts",
+ "sale": {
+ "regular": {
+ "price": "0.00"
+ },
+ "sourcecode": {
+ "price": "0.00"
+ }
+ },
+ "contact": {
+ "qq": ""
+ },
+ "declaration": {
+ "ads": "无",
+ "data": "插件不采集任何数据",
+ "permissions": "无"
+ },
+ "npmurl": ""
+ },
+ "uni_modules": {
+ "dependencies": [],
+ "encrypt": [],
+ "platforms": {
+ "cloud": {
+ "tcb": "y",
+ "aliyun": "y"
+ },
+ "client": {
+ "Vue": {
+ "vue2": "n",
+ "vue3": "y"
+ },
+ "App": {
+ "app-android": {
+ "minVersion": "21"
+ },
+ "app-ios": {
+ "minVersion": "9"
+ }
+ },
+ "H5-mobile": {
+ "Safari": "y",
+ "Android Browser": "y",
+ "微信浏览器(Android)": "y",
+ "QQ浏览器(Android)": "y"
+ },
+ "H5-pc": {
+ "Chrome": "y",
+ "IE": "y",
+ "Edge": "y",
+ "Firefox": "y",
+ "Safari": "y"
+ },
+ "小程序": {
+ "微信": "y",
+ "阿里": "y",
+ "百度": "y",
+ "字节跳动": "u",
+ "QQ": "y",
+ "钉钉": "u",
+ "快手": "u",
+ "飞书": "u",
+ "京东": "u"
+ },
+ "快应用": {
+ "华为": "u",
+ "联盟": "u"
+ }
+ }
+ }
+ }
+}
diff --git a/uni_modules/native-button/readme.md b/uni_modules/native-button/readme.md
new file mode 100644
index 0000000000000000000000000000000000000000..ee8a09e0bb5421602c1a1fa3d791cf40974c6a7e
--- /dev/null
+++ b/uni_modules/native-button/readme.md
@@ -0,0 +1,3 @@
+## native-button
+
+通过 object 封装原生平台Button按钮
diff --git a/uni_modules/native-button/utssdk/app-android/config.json b/uni_modules/native-button/utssdk/app-android/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..5defc8f1450e357c18fda507aaea7dbc43da1a16
--- /dev/null
+++ b/uni_modules/native-button/utssdk/app-android/config.json
@@ -0,0 +1,3 @@
+{
+ "minSdkVersion": "21"
+}
diff --git a/uni_modules/native-button/utssdk/app-android/index.uts b/uni_modules/native-button/utssdk/app-android/index.uts
new file mode 100644
index 0000000000000000000000000000000000000000..5118215fe139dbec5184bd2de8dc3d1f785181e9
--- /dev/null
+++ b/uni_modules/native-button/utssdk/app-android/index.uts
@@ -0,0 +1,37 @@
+import { Button } from "android.widget"
+
+export class NativeButton {
+ $element: UniNativeViewElement;
+
+ constructor(element: UniNativeViewElement) {
+ this.$element = element;
+ this.bindView();
+ }
+
+ button: Button | null = null;
+ bindView() {
+ //通过UniElement.getAndroidActivity()获取android平台activity 用于创建view的上下文
+ this.button = new Button(this.$element.getAndroidActivity()!); //构建原生view
+ //限制原生Button 文案描述不自动大写
+ this.button?.setAllCaps(false)
+ //监听原生Button点击事件
+ this.button?.setOnClickListener(_ => {
+ const detail = {}
+ //构建自定义UniNativeViewEvent返回对象
+ const event = new UniNativeViewEvent("customClick", detail)
+ //响应分发原生Button的点击事件
+ this.$element.dispatchEvent(event)
+ })
+ //UniNativeViewEvent 绑定 安卓原生view
+ this.$element.bindAndroidView(this.button!);
+ }
+
+ updateText(text: string) {
+ //更新原生Button 文案描述
+ this.button?.setText(text)
+ }
+
+ destroy() {
+ //数据回收
+ }
+}
diff --git a/uni_modules/native-button/utssdk/app-ios/config.json b/uni_modules/native-button/utssdk/app-ios/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..33128280047aec14037956c90de097dc72b33486
--- /dev/null
+++ b/uni_modules/native-button/utssdk/app-ios/config.json
@@ -0,0 +1,3 @@
+{
+ "deploymentTarget": "12"
+}
diff --git a/uni_modules/native-button/utssdk/app-ios/index.uts b/uni_modules/native-button/utssdk/app-ios/index.uts
new file mode 100644
index 0000000000000000000000000000000000000000..ee8e02501a0435cd445e226410263bb861cca3be
--- /dev/null
+++ b/uni_modules/native-button/utssdk/app-ios/index.uts
@@ -0,0 +1,48 @@
+import { UIButton, UIControl } from "UIKit"
+
+export class NativeButton {
+
+ element : UniNativeViewElement;
+ button : UIButton | null;
+
+ constructor(element : UniNativeViewElement) {
+ // 接收组件传递过来的UniNativeViewElement
+ this.element = element;
+ super.init()
+ this.bindView();
+ }
+
+ // element 绑定原生view
+ bindView() {
+ // 初始化原生 UIButton
+ this.button = new UIButton(type=UIButton.ButtonType.system)
+ // 构建方法选择器
+ const method = Selector("buttonClickAction")
+ // button 绑定点击回调方法
+ button?.addTarget(this, action = method, for = UIControl.Event.touchUpInside)
+ // UniNativeViewElement 绑定原生 view
+ this.element.bindIOSView(this.button!);
+ }
+
+ updateText(text : string) {
+ // 更新 button 显示文字
+ this.button?.setTitle(text, for = UIControl.State.normal)
+ }
+
+ /**
+ * 按钮点击回调方法
+ * 在 swift 中,所有target-action (例如按钮的点击事件,NotificationCenter 的通知事件等)对应的 action 函数前面都要使用 @objc 进行标记。
+ */
+ @objc buttonClickAction() {
+ //构建自定义 UniNativeViewEvent 对象
+ let event = new UniNativeViewEvent("customClick")
+ //触发自定义事件
+ this.element.dispatchEvent(event)
+ }
+
+ destroy() {
+ // 释放 UTS 实例对象,避免内存泄露
+ UTSiOS.destroyInstance(this)
+ }
+}
+
diff --git a/uni_modules/native-time-picker/changelog.md b/uni_modules/native-time-picker/changelog.md
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/uni_modules/native-time-picker/components/native-time-picker/native-time-picker.uvue b/uni_modules/native-time-picker/components/native-time-picker/native-time-picker.uvue
new file mode 100644
index 0000000000000000000000000000000000000000..50fa1e6112efa00f1a6509cb6466dc351b10b283
--- /dev/null
+++ b/uni_modules/native-time-picker/components/native-time-picker/native-time-picker.uvue
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
diff --git a/uni_modules/native-time-picker/package.json b/uni_modules/native-time-picker/package.json
new file mode 100644
index 0000000000000000000000000000000000000000..da5a7eb5de0a7fe447cac7de777ae6851c554ccf
--- /dev/null
+++ b/uni_modules/native-time-picker/package.json
@@ -0,0 +1,80 @@
+{
+ "id": "native-time-picker",
+ "displayName": "native-time-picker",
+ "version": "1.0.0",
+ "description": "native-time-picker",
+ "repository": "",
+ "engines": {
+ "HBuilderX": "^3.1.0"
+ },
+ "dcloudext": {
+ "type": "component-vue",
+ "sale": {
+ "regular": {
+ "price": "0.00"
+ },
+ "sourcecode": {
+ "price": "0.00"
+ }
+ },
+ "contact": {
+ "qq": ""
+ },
+ "declaration": {
+ "ads": "",
+ "data": "",
+ "permissions": ""
+ },
+ "npmurl": ""
+ },
+ "uni_modules": {
+ "dependencies": [],
+ "encrypt": [],
+ "platforms": {
+ "cloud": {
+ "tcb": "u",
+ "aliyun": "u",
+ "alipay": "u"
+ },
+ "client": {
+ "Vue": {
+ "vue2": "u",
+ "vue3": "u"
+ },
+ "App": {
+ "app-vue": "u",
+ "app-nvue": "u",
+ "app-uvue": "u"
+ },
+ "H5-mobile": {
+ "Safari": "u",
+ "Android Browser": "u",
+ "微信浏览器(Android)": "u",
+ "QQ浏览器(Android)": "u"
+ },
+ "H5-pc": {
+ "Chrome": "u",
+ "IE": "u",
+ "Edge": "u",
+ "Firefox": "u",
+ "Safari": "u"
+ },
+ "小程序": {
+ "微信": "u",
+ "阿里": "u",
+ "百度": "u",
+ "字节跳动": "u",
+ "QQ": "u",
+ "钉钉": "u",
+ "快手": "u",
+ "飞书": "u",
+ "京东": "u"
+ },
+ "快应用": {
+ "华为": "u",
+ "联盟": "u"
+ }
+ }
+ }
+ }
+}
diff --git a/uni_modules/native-time-picker/readme.md b/uni_modules/native-time-picker/readme.md
new file mode 100644
index 0000000000000000000000000000000000000000..9e94a6700a4144eb7e5552102e2ca9e71829c29d
--- /dev/null
+++ b/uni_modules/native-time-picker/readme.md
@@ -0,0 +1 @@
+# native-time-picker
diff --git a/uni_modules/native-time-picker/utssdk/app-android/config.json b/uni_modules/native-time-picker/utssdk/app-android/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..bf9592567f563664ee930692b3282879db6d5007
--- /dev/null
+++ b/uni_modules/native-time-picker/utssdk/app-android/config.json
@@ -0,0 +1,3 @@
+{
+ "minSdkVersion": "21"
+}
\ No newline at end of file
diff --git a/uni_modules/native-time-picker/utssdk/app-android/index.uts b/uni_modules/native-time-picker/utssdk/app-android/index.uts
new file mode 100644
index 0000000000000000000000000000000000000000..40bde18964dd3650c0e093c1abb8ddb623207869
--- /dev/null
+++ b/uni_modules/native-time-picker/utssdk/app-android/index.uts
@@ -0,0 +1,31 @@
+import TimePicker from "android.widget.TimePicker"
+
+export class NativeTimePicker {
+ $element : UniNativeViewElement;
+
+ constructor(element : UniNativeViewElement, hour: number, minute: number) {
+ this.$element = element;
+ this.bindView(hour, minute);
+ }
+
+ picker : TimePicker | null = null;
+ bindView(hour: number, minute: number) {
+ this.picker = new TimePicker(this.$element.getAndroidActivity()!); //构建原生view
+ this.$element.bindAndroidView(this.picker!);
+ this.setHour(hour)
+ this.setMinute(minute)
+ this.picker?.setOnTimeChangedListener((_, hourOfDay, minute) => {
+ const detail = {"hour": hourOfDay, "minute": minute}
+ const event = new UniNativeViewEvent("timechanged", detail)
+ this.$element.dispatchEvent(event)
+ })
+ }
+
+ setHour(hour: number) {
+ this.picker?.setHour(hour.toInt())
+ }
+
+ setMinute(minute: number) {
+ this.picker?.setMinute(minute.toInt())
+ }
+}
diff --git a/uni_modules/native-time-picker/utssdk/app-ios/config.json b/uni_modules/native-time-picker/utssdk/app-ios/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..33128280047aec14037956c90de097dc72b33486
--- /dev/null
+++ b/uni_modules/native-time-picker/utssdk/app-ios/config.json
@@ -0,0 +1,3 @@
+{
+ "deploymentTarget": "12"
+}
diff --git a/uni_modules/native-time-picker/utssdk/app-ios/index.uts b/uni_modules/native-time-picker/utssdk/app-ios/index.uts
new file mode 100644
index 0000000000000000000000000000000000000000..90abdc1526d9ae737764917e19f92de80045fe8e
--- /dev/null
+++ b/uni_modules/native-time-picker/utssdk/app-ios/index.uts
@@ -0,0 +1,85 @@
+import { UIDatePicker, UIControl, UIDatePickerStyle } from "UIKit"
+import { DateFormatter } from "CoreFoundation"
+
+export class NativeTimePicker {
+
+ element : UniNativeViewElement
+ timePicker : UIDatePicker
+ h : number
+ m : number
+
+ constructor(element : UniNativeViewElement, hour : number, minute : number) {
+ this.element = element
+ this.timePicker = new UIDatePicker()
+ this.h = hour
+ this.m = minute
+ super.init()
+
+ // 在 swift target-action 对应的方法需要以OC的方式来调用,那么OC语言中用Selector来表示一个方法的名称(又称方法选择器),创建一个Selector可以使用 Selector("functionName") 的方式。
+ const method = Selector("timeChange")
+ // 监听时间变化回调
+ this.timePicker.addTarget(this, action = method, for = UIControl.Event.valueChanged)
+
+ // 设置为时间选择模式
+ this.timePicker.datePickerMode = UIDatePicker.Mode.time
+
+ // 设置外观样式为 wheels
+ if (UTSiOS.available("iOS 13.4, *")) {
+ this.timePicker.preferredDatePickerStyle = UIDatePickerStyle.wheels
+ }
+
+ this.updateTime()
+ this.bindView(hour, minute)
+ }
+
+ // element 绑定原生view
+ bindView(hour : number, minute : number) {
+ this.element.bindIOSView(this.timePicker);
+ }
+
+ // 设置时
+ setHour(hour : number) {
+ this.h = hour
+ this.updateTime()
+ }
+
+ // 设置分
+ setMinute(minute : number) {
+ this.m = minute
+ this.updateTime()
+ }
+
+ // 更新显示
+ updateTime() {
+ let formatter = DateFormatter()
+ formatter.dateFormat = "HH:mm"
+ let date = formatter.date(from = `${this.h}:${this.m}`)
+ if (date != null) {
+ this.timePicker.date = date!
+ }
+ }
+
+ /**
+ * 按钮点击回调方法
+ * 在 swift 中,所有target-action (例如按钮的点击事件,NotificationCenter 的通知事件等)对应的 action 函数前面都要使用 @objc 进行标记。
+ */
+ @objc timeChange() {
+ // 发送事件
+ console.log("timeChange")
+
+ let formatter = DateFormatter()
+ formatter.dateFormat = "HH"
+ let hourString = formatter.string(from = this.timePicker.date)
+
+ formatter.dateFormat = "mm"
+ let minuteString = formatter.string(from = this.timePicker.date)
+
+ const detail = { "hour": hourString, "minute": minuteString }
+ const event = new UniNativeViewEvent("timechanged", detail)
+ this.element.dispatchEvent(event)
+ }
+
+ destroy() {
+ UTSiOS.destroyInstance(this)
+ }
+}
diff --git a/uni_modules/uni-pay-x/components/uni-pay/uni-pay.uvue b/uni_modules/uni-pay-x/components/uni-pay/uni-pay.uvue
index b2271892fae1aef520a896db4f22f28e2c55c914..ea8a179fa5ebcaf6d3dc970c4473d3ef6ce82351 100644
--- a/uni_modules/uni-pay-x/components/uni-pay/uni-pay.uvue
+++ b/uni_modules/uni-pay-x/components/uni-pay/uni-pay.uvue
@@ -585,6 +585,33 @@
// #endif
// #ifdef APP-IOS
const virtualPaymentManager = uni.getVirtualPaymentManager();
+ if (options.apple_virtual['product_type'] == 'nonconsumable') {
+ uni.showLoading({
+ title: "请求中...",
+ mask: true
+ })
+ let purchased = await new Promise((resolve, reject) => {
+ // 如果是非消耗性产品只能购买一次,需要先判断下
+ virtualPaymentManager.restoreTransactions({
+ success: (res) => {
+ let transactions = res.transactions;
+ let index = res.transactions.findIndex(transaction => {
+ return transaction.productId == options.apple_virtual['product_id']
+ })
+ resolve(index > -1 ? true : false);
+ }
+ });
+ });
+ uni.hideLoading()
+ if (purchased) {
+ uni.showModal({
+ title: "提示",
+ content: "您已购买过此商品,请勿重复购买",
+ showCancel: false
+ });
+ return;
+ }
+ }
let createOrderData = {
provider: options.provider,
total_fee: options.total_fee,
diff --git a/uni_modules/uni-stat/utssdk/common/utils/pageInfo.uts b/uni_modules/uni-stat/utssdk/common/utils/pageInfo.uts
index a912fc2b8b7c2513e9d7344b233cd7894a062ab6..02d926e040ea1cd6e2b9d2b21b32c8adc38aa4c5 100644
--- a/uni_modules/uni-stat/utssdk/common/utils/pageInfo.uts
+++ b/uni_modules/uni-stat/utssdk/common/utils/pageInfo.uts
@@ -149,11 +149,11 @@ export const get_version = () : string => {
* 获取渠道
*/
export const get_channel = () : string => {
- // const platformName = get_platform_name()
- let channel = ''
- // if (platformName === 'n') {
- // channel = plus.runtime.channel
- // }
+ const platformName = get_platform_name()
+ let channel:string = ''
+ if (platformName === 'n') {
+ channel = sysAppBase.channel ?? ''
+ }
// if (platformName === 'wx') {
// // TODO 需要调研小程序二维码渠道如何获取;
// }
@@ -224,19 +224,16 @@ export const get_page_name = (routepath : string) : string => {
if (page.route != routepath) {
const pages = getCurrentPages()
// 如果传入路由与当前页面不同,则从页面栈找一个,如果找不到返回空
- let page_now = pages.find((v) : boolean => {
- if (v.route == routepath) {
- return true;
- }
- return false
- })
+ let page_now = pages.find((p): boolean => p.route == routepath)
if (page_now == null) {
return ''
- }
- page = page_now
+ }
+ // @ts-ignore
+ page = page_now.vm!
}
-
- const pageStyle = page.$getPageStyle()
+
+ // @ts-ignore
+ const pageStyle = (page.$page as UniPage).getPageStyle()
const titleText = pageStyle['navigationBarTitleText'] ?? ''
return titleText as string
}
@@ -250,8 +247,9 @@ export const get_page_vm = () : Page | null => {
return null
}
let page = pages[pages.length - 1]
- // TODO 正常来说,调用当前方法的地方只在 生命周期内,数组内最少会有一个页面,所以理论上是不存在获取不到的情况的
- return page
+ // TODO 正常来说,调用当前方法的地方只在 生命周期内,数组内最少会有一个页面,所以理论上是不存在获取不到的情况的
+ // @ts-ignore
+ return page.vm
}
@@ -416,16 +414,17 @@ export const uni_cloud_config = () : UniCloudInitOptions | null => {
export const get_space = (config : UniCloudInitOptions) : UniCloudInitOptions | null => {
const uniCloudConfig = uni_cloud_config()
if (uniCloudConfig == null) {
- // #ifdef APP-ANDROID
- if (config.spaceId != '') {
- return config
- }
- // #endif
- // #ifndef APP-ANDROID
- if (config?.spaceId != '') {
- return config
- }
- // #endif
+ console.log(config);
+ // #ifdef APP-ANDROID
+ if (config.spaceId != '') {
+ return config
+ }
+ // #endif
+ // #ifndef APP-ANDROID
+ if (config?.spaceId != '') {
+ return config
+ }
+ // #endif
return null
}
@@ -509,4 +508,4 @@ export const calibration = (eventName : string, options : any | null) : boolean
return true
}
return false
-}
+}
diff --git a/uni_modules/uts-eventbus/changelog.md b/uni_modules/uts-eventbus/changelog.md
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/uni_modules/uts-eventbus/package.json b/uni_modules/uts-eventbus/package.json
new file mode 100644
index 0000000000000000000000000000000000000000..6889e7ed8a0947a2b65d4ae5c6fd643e9c657b9e
--- /dev/null
+++ b/uni_modules/uts-eventbus/package.json
@@ -0,0 +1,82 @@
+{
+ "id": "uts-eventbus",
+ "displayName": "uts-eventbus",
+ "version": "1.0.0",
+ "description": "uts-eventbus",
+ "keywords": [
+ "uts-eventbus"
+],
+ "repository": "",
+ "engines": {
+ "HBuilderX": "^3.6.8"
+ },
+ "dcloudext": {
+ "type": "uts",
+ "sale": {
+ "regular": {
+ "price": "0.00"
+ },
+ "sourcecode": {
+ "price": "0.00"
+ }
+ },
+ "contact": {
+ "qq": ""
+ },
+ "declaration": {
+ "ads": "",
+ "data": "",
+ "permissions": ""
+ },
+ "npmurl": ""
+ },
+ "uni_modules": {
+ "dependencies": [],
+ "encrypt": [],
+ "platforms": {
+ "cloud": {
+ "tcb": "u",
+ "aliyun": "u",
+ "alipay": "u"
+ },
+ "client": {
+ "Vue": {
+ "vue2": "u",
+ "vue3": "u"
+ },
+ "App": {
+ "app-android": "u",
+ "app-ios": "u"
+ },
+ "H5-mobile": {
+ "Safari": "u",
+ "Android Browser": "u",
+ "微信浏览器(Android)": "u",
+ "QQ浏览器(Android)": "u"
+ },
+ "H5-pc": {
+ "Chrome": "u",
+ "IE": "u",
+ "Edge": "u",
+ "Firefox": "u",
+ "Safari": "u"
+ },
+ "小程序": {
+ "微信": "u",
+ "阿里": "u",
+ "百度": "u",
+ "字节跳动": "u",
+ "QQ": "u",
+ "钉钉": "u",
+ "快手": "u",
+ "飞书": "u",
+ "京东": "u"
+ },
+ "快应用": {
+ "华为": "u",
+ "联盟": "u"
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/uni_modules/uts-eventbus/readme.md b/uni_modules/uts-eventbus/readme.md
new file mode 100644
index 0000000000000000000000000000000000000000..7c405122fb122a6c75262f767850f5b0be813a47
--- /dev/null
+++ b/uni_modules/uts-eventbus/readme.md
@@ -0,0 +1,6 @@
+# uts-eventbus
+### 开发文档
+[UTS 语法](https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html)
+[UTS API插件](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html)
+[UTS 组件插件](https://uniapp.dcloud.net.cn/plugin/uts-component.html)
+[Hello UTS](https://gitcode.net/dcloud/hello-uts)
\ No newline at end of file
diff --git a/uni_modules/uts-eventbus/utssdk/app-ios/config.json b/uni_modules/uts-eventbus/utssdk/app-ios/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..ec0dcfb1579d5327e81c25ee5e8d78034dfff3c4
--- /dev/null
+++ b/uni_modules/uts-eventbus/utssdk/app-ios/config.json
@@ -0,0 +1,3 @@
+{
+ "deploymentTarget": "12"
+}
diff --git a/uni_modules/uts-eventbus/utssdk/app-ios/index.uts b/uni_modules/uts-eventbus/utssdk/app-ios/index.uts
new file mode 100644
index 0000000000000000000000000000000000000000..4b88bfb5fdcf6fe9fd2e110b16b1dd0af70dde5c
--- /dev/null
+++ b/uni_modules/uts-eventbus/utssdk/app-ios/index.uts
@@ -0,0 +1,58 @@
+
+import { UniUTSJS } from 'DCloudUniappRuntime'
+import { NSNumber } from 'Foundation';
+
+let MessageChannel : string = "UtsMessage"
+var revFromJS = ""
+
+export function getMessageChannel() : string {
+ return MessageChannel
+}
+
+export function getRevJsMessage() : string {
+ return revFromJS
+}
+
+export function emitUtsMessage(arg : string) {
+ uni.$emit(MessageChannel, arg);
+}
+
+var callbackId : NSNumber | null = null
+export function onJsMessage (messageChannel : string ) {
+ revFromJS = ""
+ if (callbackId != null) {
+ uni.$off(messageChannel, callbackId!)
+ callbackId = null
+ }
+
+ callbackId = uni.$on(messageChannel, function (...spreadArgs : Any) {
+ if (spreadArgs.length > 0) {
+ let arg0 = spreadArgs[0] as String | null
+ if ( arg0 != null ){
+ revFromJS = arg0!;
+ }
+ }
+ })
+}
+
+export function onJsMessageOnce (messageChannel : string ) {
+ revFromJS = ""
+ uni.$once(messageChannel, function (...spreadArgs : Any) {
+ if (spreadArgs.length > 0) {
+ let arg0 = spreadArgs[0] as String | null
+ if ( arg0 != null ){
+ revFromJS = arg0!;
+ }
+ }
+ })
+}
+
+export function offJsMessage(messageChannel : string) {
+ if (callbackId != null) {
+ uni.$off(messageChannel, callbackId!)
+ }
+}
+
+export function clearJsMessage() {
+ revFromJS = ""
+}
\ No newline at end of file
diff --git a/uni_modules/uts-eventbus/utssdk/unierror.uts b/uni_modules/uts-eventbus/utssdk/unierror.uts
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391