diff --git a/pages.json b/pages.json
index bb03a6ee858504741e9969cd5c9177dc82a41d88..100ee36523bd2b84b13ecc264adb06f88832fc5e 100644
--- a/pages.json
+++ b/pages.json
@@ -132,7 +132,7 @@
// #ifdef APP-ANDROID || APP-IOS || WEB
{
"path": "pages/component/sticky-section/sticky-section",
- "group": "0,1,7,1",
+ "group": "0,1,8,1",
"style": {
"navigationBarTitleText": "sticky-section | 吸顶布局容器"
}
@@ -141,7 +141,7 @@
// #ifdef APP-ANDROID || APP-IOS || WEB
{
"path": "pages/component/sticky-header/sticky-header",
- "group": "0,1,7,0",
+ "group": "0,1,8,0",
"style": {
"navigationBarTitleText": "sticky-header | 吸顶布局容器",
"enablePullDownRefresh": false
@@ -485,7 +485,7 @@
// #ifdef APP-ANDROID || APP-IOS
{
"path": "pages/component/nested-scroll-header/nested-scroll-header",
- "group": "0,1,8,0",
+ "group": "0,1,9,0",
"style": {
"navigationBarTitleText": "nested-scroll-header"
}
@@ -494,7 +494,7 @@
// #ifdef APP-ANDROID || APP-IOS
{
"path": "pages/component/nested-scroll-body/nested-scroll-body",
- "group": "0,1,8,1",
+ "group": "0,1,9,1",
"style": {
"navigationBarTitleText": "nested-scroll-body"
}
@@ -626,6 +626,15 @@
}
},
// #endif
+ // #ifdef APP-ANDROID || APP-IOS
+ {
+ "path": "pages/component/grid-view/grid-view",
+ "group": "0,1,7",
+ "style": {
+ "navigationBarTitleText": "grid-view | 表格容器"
+ }
+ },
+ // #endif
// #ifdef APP-ANDROID || APP-IOS || MP-WEIXIN
{
"path": "pages/component/ad/list-view-ad",
@@ -1299,7 +1308,7 @@
}
},
// #endif
- // #ifdef APP || WEB || MP-WEIXIN
+ // #ifdef APP-ANDROID || WEB || MP-WEIXIN
{
"path": "pages/API/create-inner-audio-context/create-inner-audio-context",
"group": "1,7,9",
@@ -1308,7 +1317,7 @@
}
},
// #endif
- // #ifdef APP || WEB || MP-WEIXIN
+ // #ifdef APP-ANDROID || WEB || MP-WEIXIN
{
"path": "pages/API/create-inner-audio-context/inner-audio-format",
"style": {
@@ -1316,7 +1325,7 @@
}
},
// #endif
- // #ifdef APP || WEB || MP-WEIXIN
+ // #ifdef APP-ANDROID || WEB || MP-WEIXIN
{
"path": "pages/API/create-inner-audio-context/inner-audio-path",
"style": {
@@ -1324,7 +1333,7 @@
}
},
// #endif
- // #ifdef APP || WEB || MP-WEIXIN
+ // #ifdef APP-ANDROID || WEB || MP-WEIXIN
{
"path": "pages/API/create-inner-audio-context/inner-audio-mult",
"style": {
@@ -1350,7 +1359,7 @@
}
},
// #endif
- // #ifdef APP-ANDROID || APP-IOS || MP-WEIXIN
+ // #ifdef APP-ANDROID || APP-IOS || WEB || MP-WEIXIN
{
"path": "pages/API/theme-change/theme-change",
"group": "1,4,7",
@@ -1468,7 +1477,7 @@
{
"path": "pages/API/dialog-page/dialog-2",
"style": {
- "navigationBarTitleText": "dialogPage1"
+ "navigationBarTitleText": "dialogPage2"
}
},
// #endif
@@ -2283,18 +2292,20 @@
}
},
// #endif
- // #ifdef MP
- {
- "path" : "pages/template/vant-button/vant-button",
- "style" :
- {
- "navigationBarTitleText": "微信自定义组件示例",
- "usingComponents": {
- "van-button": "/wxcomponents/vant/button/index"
- }
- }
- }
- // #endif
+ // #ifdef MP
+ {
+ "path": "pages/template/vant/vant",
+ "style": {
+ "navigationBarTitleText": "微信自定义组件示例",
+ "usingComponents": {
+ "vant-button": "/wxcomponents/vant/button/index",
+ "vant-icon": "/wxcomponents/vant/icon/index",
+ "vant-info": "/wxcomponents/vant/info/index",
+ "vant-loading": "/wxcomponents/vant/loading/index"
+ }
+ }
+ }
+ // #endif
],
"globalStyle": {
// #ifdef APP-ANDROID
@@ -2403,6 +2414,10 @@
"id": "component.view-container.list-view",
"name": "list-view"
},
+ {
+ "id": "component.view-container.grid-view",
+ "name": "grid-view"
+ },
{
"id": "component.view-container.sticky",
"name": "sticky",
@@ -3291,4 +3306,4 @@
]
}
]
-}
+}
\ No newline at end of file
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 42d1284393f68e762938f9ea7029fb9c613bf5c5..b7434452702564d144b04b62ccf40d41fba91b32 100644
--- a/pages/API/create-inner-audio-context/inner-audio-path.uvue
+++ b/pages/API/create-inner-audio-context/inner-audio-path.uvue
@@ -22,23 +22,23 @@
return {
title: 'audio-path',
playIndex: 0,
- isPlaying: false,
- nativePath:uni.env.CACHE_PATH+'uni-audio/test/test.mp3' as string,
- sdcardPath :'sdcard/uni-audio/test.mp3',
+ isPlaying: false,
+ nativePath: uni.env.CACHE_PATH + 'uni-audio/test/test.mp3' as string,
+ sdcardPath: 'sdcard/uni-audio/test.mp3',
_audioContext: null as InnerAudioContext | null,
supportPaths: [
{
description: '本地路径:/static方式',
src: '/static/test-audio/ForElise.mp3'
},
- {
+ {
description: '本地路径:../static/',
src: '../../../static/test-audio/ForElise.mp3'
- },
- {
- description: '本地路径:env方式',
- src: 'env'
- },
+ },
+ {
+ description: '本地路径:env方式',
+ src: 'env'
+ },
{
description: '网络路径',
src: 'https://web-ext-storage.dcloud.net.cn/uni-app-x/audio/ForElise.mp3'
@@ -55,37 +55,51 @@
}
},
onReady() {
- this._audioContext = uni.createInnerAudioContext();
- this._audioContext!.onPlay(() => {
- console.log('开始播放');
- });
- this._audioContext!.onEnded(() => {
- console.log('播放结束');
- this.isPlaying = false;
- });
- this._audioContext!.onError((err) => {
- this.isPlaying = false;
- console.log('err', err);
- });
-
- const fileManager = uni.getFileSystemManager()
- try {
- fileManager.rmdirSync(uni.env.CACHE_PATH+'uni-audio/test',true)
- } catch (e) {
- }
-
- try {
- fileManager.mkdirSync(uni.env.CACHE_PATH+'uni-audio/test',true)
- } catch (e) {
- }
- try{
- fileManager.copyFileSync(
- '/static/test-audio/ForElise.mp3',
- this.nativePath)
- } catch(e){
- }
- },
-
+ this._audioContext = uni.createInnerAudioContext();
+ this._audioContext!.onPlay(() => {
+ console.log('开始播放');
+ });
+ this._audioContext!.onEnded(() => {
+ console.log('播放结束');
+ this.isPlaying = false;
+ });
+ this._audioContext!.onError((err) => {
+ this.isPlaying = false;
+ console.log('err', err);
+ });
+
+ const fileManager = uni.getFileSystemManager()
+ fileManager.mkdir({
+ dirPath: uni.env.CACHE_PATH + 'uni-audio/test',
+ recursive: true,
+ success: (res) => {
+ fileManager.copyFile({
+ srcPath: '/static/test-audio/ForElise.mp3',
+ destPath: this.nativePath,
+ success: () => {
+ console.log("copy成功: ", res)
+ }
+ })
+ },
+ fail: (err) => {
+ console.log("创建路径失败: ", err.errMsg)
+ if (err.errMsg.includes("file already exists")) {
+ console.log("已经包含该路径")
+ fileManager.copyFile({
+ srcPath: '/static/test-audio/ForElise.mp3',
+ destPath: this.nativePath,
+ success: (res) => {
+ console.log("copy成功: ", res)
+ },
+ fail: (err) => {
+ console.log("copy失败: ", err)
+ }
+ })
+ }
+ }
+ })
+ },
+
onUnload() {
if (this._audioContext != null) {
this.pause();
@@ -97,16 +111,16 @@
this._audioContext!.pause();
this.isPlaying = false;
},
- play(audioUrl:string, index:number) {
- console.log(index,audioUrl);
+ play(audioUrl : string, index : number) {
+ console.log(index, audioUrl);
if (this.isPlaying && this.playIndex == index) {
this.pause();
return;
- }
- if(audioUrl == 'env'){
- audioUrl=this.nativePath
- }
-
+ }
+ if (audioUrl == 'env') {
+ audioUrl = this.nativePath
+ }
+
this.playIndex = index
this._audioContext!.src = audioUrl;
this._audioContext!.play();
diff --git a/pages/API/create-selector-query/create-selector-query.test.js b/pages/API/create-selector-query/create-selector-query.test.js
index 719db99a1edbff7cc30e38bb79c8c4b55c73cb1e..b13931bee0446741ad635f10c40f75edae13b080 100644
--- a/pages/API/create-selector-query/create-selector-query.test.js
+++ b/pages/API/create-selector-query/create-selector-query.test.js
@@ -76,7 +76,10 @@ describe('nodes-info', () => {
// #endif
it('test filelds', async () => {
- if (process.env.uniTestPlatformInfo.startsWith('web')) {
+ if (
+ process.env.uniTestPlatformInfo.startsWith('web') ||
+ process.env.uniTestPlatformInfo.startsWith('mp')
+ ) {
expect(true).toBe(true)
} else {
const pageData = await page.data()
@@ -85,7 +88,10 @@ describe('nodes-info', () => {
})
it('test node', async () => {
- if (process.env.uniTestPlatformInfo.startsWith('web')) {
+ if (
+ process.env.uniTestPlatformInfo.startsWith('web') ||
+ process.env.uniTestPlatformInfo.startsWith('mp')
+ ) {
expect(true).toBe(true)
} else {
const pageData = await page.data()
diff --git a/pages/API/get-element-by-id/get-element-by-id-multiple-root-node.test.js b/pages/API/get-element-by-id/get-element-by-id-multiple-root-node.test.js
index daa1d2cf71356d75a22c90404fd7d4b8d99b3484..4e4f39281b20c2e336e0ff8b3535d4ccfb1a78b3 100644
--- a/pages/API/get-element-by-id/get-element-by-id-multiple-root-node.test.js
+++ b/pages/API/get-element-by-id/get-element-by-id-multiple-root-node.test.js
@@ -11,8 +11,10 @@ describe("getElementByIdForMultipleRootNode", () => {
const res = await page.callMethod("getElementByNotExistId");
expect(res).toBe(null);
});
- it("changeStyle", async () => {
- await page.callMethod("changePageHeadBackgroundColor");
+ it("changeStyle", async () => {
+ if (!process.env.uniTestPlatformInfo.startsWith('mp')) {
+ await page.callMethod("changePageHeadBackgroundColor");
+ }
await page.callMethod("changeTextColor");
await page.callMethod("changeViewStyle");
await page.waitFor(500);
diff --git a/pages/API/get-element-by-id/get-element-by-id.test.js b/pages/API/get-element-by-id/get-element-by-id.test.js
index 74f2e9dd4d4a2c58326f5eddde79d100268bd9ac..9c5478ba805b2948dd15a52bd41c4128e3923ed9 100644
--- a/pages/API/get-element-by-id/get-element-by-id.test.js
+++ b/pages/API/get-element-by-id/get-element-by-id.test.js
@@ -11,7 +11,9 @@ describe("getElementById", () => {
expect(res).toBe(null);
});
it("changeStyle", async () => {
- await page.callMethod("changePageHeadBackgroundColor");
+ if (!process.env.uniTestPlatformInfo.startsWith('mp')) {
+ await page.callMethod("changePageHeadBackgroundColor");
+ }
await page.callMethod("changeTextColor");
await page.callMethod("changeViewStyle");
await page.waitFor(500);
diff --git a/pages/API/request/request.uvue b/pages/API/request/request.uvue
index 7ef3e6a8cab5984343301af46355aff199a0e4aa..da0fa2e23ea8bdfce0f01f4f89367722945bc338 100644
--- a/pages/API/request/request.uvue
+++ b/pages/API/request/request.uvue
@@ -9,7 +9,7 @@
请求方式 : {{method}}
-
+
diff --git a/pages/API/upload-file/upload-file.test.js b/pages/API/upload-file/upload-file.test.js
index 9dad0a2fba6c36146187b2a20e9c6b9754ba0ae8..524a117dcbeb943f9395859a5579c8abc97ebde6 100644
--- a/pages/API/upload-file/upload-file.test.js
+++ b/pages/API/upload-file/upload-file.test.js
@@ -7,35 +7,39 @@ describe('ExtApi-UploadFile', () => {
expect(1).toBe(1)
})
return
- }
+ }
+
+ const isUploadProjectFileSupported = !process.env.uniTestPlatformInfo.startsWith('mp')
let page;
let res;
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
- await page.waitFor(600);
- await page.callMethod('jest_uploadFile');
- await page.waitFor(2000);
- res = await page.data('jest_result');
});
beforeEach(async () => {
await page.setData({
jest_result: false
})
- });
-
- it('Check ', async () => {
- expect(res).toBe(true);
- });
-
- it('Check files upload', async () => {
- res = await page.callMethod('jest_files_upload')
- await page.waitFor(2000);
- res = await page.data('jest_result');
- expect(res).toBe(true)
});
+ if(isUploadProjectFileSupported) {
+ it('Check ', async () => {
+ await page.waitFor(600);
+ await page.callMethod('jest_uploadFile');
+ await page.waitFor(2000);
+ res = await page.data('jest_result');
+ expect(res).toBe(true);
+ });
+
+ it('Check files upload', async () => {
+ res = await page.callMethod('jest_files_upload')
+ await page.waitFor(2000);
+ res = await page.data('jest_result');
+ expect(res).toBe(true)
+ });
+ }
+
it('Check uni.env', async () => {
await page.callMethod('jest_uploadFile_with_uni_env');
await page.waitFor(2000);
diff --git a/pages/API/upload-file/upload-file.uvue b/pages/API/upload-file/upload-file.uvue
index 938c9a54e73a031bd88c59cd067aea8c186358a9..a7e4d7da495be60f94da2ebb79a16174b2fe0373 100644
--- a/pages/API/upload-file/upload-file.uvue
+++ b/pages/API/upload-file/upload-file.uvue
@@ -9,7 +9,8 @@
+ 选择图片
-
+
+
@@ -104,8 +105,11 @@
},
})
},
- jest_uploadFile_with_uni_env() {
- const filePath = `${uni.env.CACHE_PATH}/download/uni-app.png`
+ jest_uploadFile_with_uni_env() {
+ /**
+ * 微信小程序只支持USER_DATA_PATH,且子目录未创建的情况下不能直接下载到子目录内
+ */
+ const filePath = `${uni.env.USER_DATA_PATH}/uni-app.png`
uni.downloadFile({
url: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni-app.png",
filePath: filePath,
diff --git a/pages/component/button/button.test.js b/pages/component/button/button.test.js
index ed8384a5b1b7e6ad518bd6208ee55189f7806c2d..e6bcba6e6ceba3bbcad1a5b5630a71d586e06c77 100644
--- a/pages/component/button/button.test.js
+++ b/pages/component/button/button.test.js
@@ -79,7 +79,7 @@ describe('Button.uvue', () => {
})
it("checkUniButtonElement", async () => {
- if (process.env.uniTestPlatformInfo.startsWith('web')) {
+ if (process.env.uniTestPlatformInfo.startsWith('mp')) {
expect(1).toBe(1)
return
}
diff --git a/pages/component/canvas/canvas.uvue b/pages/component/canvas/canvas.uvue
index 7113f1eef3d4dba07d1b2585c280302653e2dc06..28deb64585c25caa9247f6e4f5c9cc9063c71fde 100644
--- a/pages/component/canvas/canvas.uvue
+++ b/pages/component/canvas/canvas.uvue
@@ -94,14 +94,19 @@
// #ifdef WEB
context.toBlob((blob : Blob) => {
this.testToBlobResult = (blob.size > 0 && blob.type == 'image/jpeg')
- }, 'image/jpeg', 0.95)
+ }, 'image/jpeg', 0.95);
+ this.testToDataURLResult = this.canvasContext!.toDataURL().startsWith('data:image/png;base64')
// #endif
- this.testToDataURLResult = context.toDataURL().startsWith('data:image/png;base64')
this.testCanvasContext = true
}
})
},
onReady() {
+ // TODO app-android 需要延迟调用
+ // #ifdef APP
+ this.testToDataURLResult = this.canvasContext!.toDataURL().startsWith('data:image/png;base64')
+ // #endif
+
// 同步调用方式,仅支持 app/web
// let canvas = uni.getElementById("canvas") as UniCanvasElement
// this.renderingContext = canvas.getContext("2d")
diff --git a/pages/component/checkbox/checkbox.test.js b/pages/component/checkbox/checkbox.test.js
index 7cfb5cc12fb936669ab46d519a69487670e5be84..aa9c9cf9dab0669863df41eb94cdb6026170f7ec 100644
--- a/pages/component/checkbox/checkbox.test.js
+++ b/pages/component/checkbox/checkbox.test.js
@@ -14,18 +14,23 @@ beforeAll(async () => {
})
describe('Checkbox.uvue', () => {
+ const isMP = process.env.uniTestPlatformInfo.startsWith('mp')
it('change', async () => {
expect(await getData('value')).toEqual([])
const cb1 = await page.$('.cb1')
await cb1.tap()
+ await page.waitFor(100)
expect(await getData('value')).toEqual(['cb', 'cb1'])
const cb = await page.$('.cb')
await cb.tap()
+ await page.waitFor(100)
expect(await getData('value')).toEqual(['cb1'])
const cb2 = await page.$('.cb2')
await cb2.tap()
+ await page.waitFor(100)
expect(await getData('value')).toEqual(['cb1'])
await cb1.tap()
+ await page.waitFor(100)
expect(await getData('value')).toEqual([])
})
it('length', async () => {
@@ -42,6 +47,29 @@ describe('Checkbox.uvue', () => {
})
expect(await cb.text()).toEqual('not selected')
})
+ if(isMP) {
+ it('disabled', async () => {
+ const cb = await page.$('.cb2')
+ const disabled1 = await cb.property('disabled')
+ expect(disabled1).toBe(true)
+ await page.setData({
+ disabled: false,
+ })
+ const disabled2 = await cb.property('disabled')
+ expect(disabled2).toBe(false)
+ })
+ } else {
+ it('disabled', async () => {
+ const cb = await page.$('.cb2')
+ const disabled1 = await cb.attribute('disabled')
+ expect(disabled1).toBe(true + '')
+ await page.setData({
+ disabled: false,
+ })
+ const disabled2 = await cb.attribute('disabled')
+ expect(disabled2).toBe(false + '')
+ })
+ }
it('checked', async () => {
const cb = await page.$('.cb')
// TODO
@@ -54,44 +82,38 @@ describe('Checkbox.uvue', () => {
const newValue2 = await cb.property('checked')
expect(newValue2.toString()).toBe(false + '')
})
- it('color', async () => {
- const cb = await page.$('.cb')
- expect(await cb.attribute('color')).toBe('#007aff')
- await page.setData({
- color: '#63acfc',
+ if(!isMP) {
+ it('color', async () => {
+ const cb = await page.$('.cb')
+ expect(await cb.attribute('color')).toBe('#007aff')
+ await page.setData({
+ color: '#63acfc',
+ })
+ expect(await cb.attribute('color')).toBe('#63acfc')
})
- expect(await cb.attribute('color')).toBe('#63acfc')
- })
- it('icon color', async () => {
- const cb = await page.$('.cb')
- expect(await cb.attribute('iconColor')).toBe('#211cfe')
- await page.setData({
- iconColor: '#63acfc',
+ it('icon color', async () => {
+ const cb = await page.$('.cb')
+ expect(await cb.attribute('iconColor')).toBe('#211cfe')
+ await page.setData({
+ iconColor: '#63acfc',
+ })
+ expect(await cb.attribute('iconColor')).toBe('#63acfc')
})
- expect(await cb.attribute('iconColor')).toBe('#63acfc')
- })
- it('foreColor', async () => {
- const cb = await page.$('.cb')
- expect(await cb.attribute('foreColor')).toBe('#ff0000')
- await page.setData({
- foreColor: '#63acfe',
+ it('foreColor', async () => {
+ const cb = await page.$('.cb')
+ expect(await cb.attribute('foreColor')).toBe('#ff0000')
+ await page.setData({
+ foreColor: '#63acfe',
+ })
+ expect(await cb.attribute('foreColor')).toBe('#63acfe')
})
- expect(await cb.attribute('foreColor')).toBe('#63acfe')
- })
- it('disabled', async () => {
- const cb = await page.$('.cb2')
- expect(await cb.attribute('disabled')).toBe(true + '')
- await page.setData({
- disabled: false,
+ it('trigger UniCheckboxGroupChangeEvent', async () => {
+ const element = await page.$('.checkbox-item-0')
+ await element.tap()
+ await page.waitFor(1000)
+ const { testEvent } = await page.data()
+ expect(testEvent).toBe(true)
})
- expect(await cb.attribute('disabled')).toBe(false + '')
- })
- it('trigger UniCheckboxGroupChangeEvent', async () => {
- const element = await page.$('.checkbox-item-0')
- await element.tap()
- await page.waitFor(1000)
- const { testEvent } = await page.data()
- expect(testEvent).toBe(true)
- })
+ }
})
diff --git a/pages/component/form/form.test.js b/pages/component/form/form.test.js
index faa9024b25d3c5d4ea861e6c97a919ac0ce8798a..543e5555e29ea7fcb4e7913d1313c7443cc4ccff 100644
--- a/pages/component/form/form.test.js
+++ b/pages/component/form/form.test.js
@@ -15,6 +15,7 @@ const CHANGE_SWITCH = false
const CHANGE_COMMENT = '备注'
describe('form', () => {
+ const isMP = process.env.uniTestPlatformInfo.startsWith('mp')
let page
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
@@ -39,9 +40,14 @@ describe('form', () => {
expect(formData['age']).toBe(CHANGE_AGE)
expect(formData['switch']).toBe(CHANGE_SWITCH)
expect(formData['comment']).toBe(CHANGE_COMMENT)
-
- expect(testVerifySubmit).toBe(true)
+ if(!isMP) {
+ expect(testVerifySubmit).toBe(true)
+ }
})
+ if(isMP) {
+ // 微信小程序reset和app、web表现不一致。暂时屏蔽reset测试例,后续如果拉齐再放开
+ return
+ }
it('reset', async () => {
await changeData(page)
diff --git a/pages/component/global-events/global-events.test.js b/pages/component/global-events/global-events.test.js
index 0198554f859314f7a3d69ca11d8bb16b0c0439b9..0b1fd9b793a5d34554ed0b295bce7e22d828f16b 100644
--- a/pages/component/global-events/global-events.test.js
+++ b/pages/component/global-events/global-events.test.js
@@ -41,7 +41,8 @@ describe('event trigger', () => {
screenX: 101,
screenY: 101
}, ],
- })
+ })
+ await page.waitFor(100)
const touchStartTouchTargetIdentifier = '1'
const touchStartTouchTargetValue = '101'
const touchStartTouchIdentifier = await page.$('#touch-start-touch-identifier')
@@ -93,7 +94,8 @@ describe('event trigger', () => {
screenX: 102,
screenY: 102
}, ],
- })
+ })
+ await page.waitFor(100)
const touchMoveTouchTargetIdentifier = '1'
const touchMoveTouchTargetValue = '102'
@@ -145,7 +147,8 @@ describe('event trigger', () => {
screenX: 103,
screenY: 103
}, ],
- })
+ })
+ await page.waitFor(100)
const touchEndTouchTargetIdentifier = '1'
const touchEndTouchTargetValue = '103'
const touchEndTouchIdentifier = await page.$('#touch-end-touch-identifier')
@@ -193,6 +196,7 @@ describe('event trigger', () => {
} else {
const el = await page.$('#longpress-target')
await el.tap()
+ await page.waitFor(100)
const targetX = '0'
const targetY = '0'
const tapEventX = await page.$('#tap-event-x')
@@ -209,7 +213,8 @@ describe('event trigger', () => {
it('longPress', async () => {
if (!process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
const el = await page.$('#longpress-target')
- await el.longpress()
+ await el.longpress()
+ await page.waitFor(100)
if (isMP) {
const longPressTouchIdentifier = await page.$('#long-press-touch-identifier')
expect(await longPressTouchIdentifier.text()).toBe('0')
diff --git a/pages/component/global-events/touch-events.test.js b/pages/component/global-events/touch-events.test.js
index 83c574fcd7a10e0b5cf3c30b08e46e1d6e1be82d..a822c179f3a38c8ea6e401d2c7eac136998abb4b 100644
--- a/pages/component/global-events/touch-events.test.js
+++ b/pages/component/global-events/touch-events.test.js
@@ -3,7 +3,11 @@ const PAGE_PATH = '/pages/component/global-events/touch-events'
describe('touch-events-test', () => {
// 先屏蔽 android 及 web 平台
- if (process.env.uniTestPlatformInfo.startsWith('android') || process.env.uniTestPlatformInfo.startsWith('web')) {
+ if (
+ process.env.uniTestPlatformInfo.startsWith('android') ||
+ process.env.uniTestPlatformInfo.startsWith('web') ||
+ process.env.uniTestPlatformInfo.startsWith('mp')
+ ) {
it('other platform', () => {
expect(1).toBe(1)
})
diff --git a/pages/component/grid-view/grid-view.test.js b/pages/component/grid-view/grid-view.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..deb6dae20e253ededf27430e12b5de7e43758f3b
--- /dev/null
+++ b/pages/component/grid-view/grid-view.test.js
@@ -0,0 +1,115 @@
+const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
+const isMP = platformInfo.startsWith('mp')
+
+describe('component-native-grid-view', () => {
+ if (isMP) {
+ it('skip mp', () => {
+ expect(1).toBe(1)
+ })
+ return
+ }
+
+ let page
+ beforeAll(async () => {
+ //打开grid-view测试页
+ page = await program.reLaunch('/pages/component/grid-view/grid-view')
+ await page.waitFor(600)
+ })
+
+ //检测竖向scrolltop属性赋值
+ it('check_scroll_top', async () => {
+ await page.callMethod('confirm_scroll_top_input', 600)
+ await page.waitFor(600)
+ const listElement = await page.$('#gridview')
+ const scrollTop = await listElement.attribute("scrollTop")
+ console.log("check_scroll_top---"+scrollTop)
+ expect(scrollTop-600).toBeGreaterThanOrEqual(0)
+ })
+
+ it('Event check_scroll', async () => {
+ await page.callMethod('confirm_scroll_top_input', 300)
+ await page.waitFor(600)
+ const scrollDetail = await page.data('scrollDetailTest')
+ // console.log('scrollDetailTest:', scrollDetail)
+ expect(scrollDetail.scrollLeft).toBe(0)
+ // scrollTop和deltaY 在安卓端差异 299.8095
+ expect([300, 299.8095]).toContain(scrollDetail.scrollTop);
+ expect(scrollDetail.scrollHeight).toBeGreaterThan(0)
+ expect(scrollDetail.scrollWidth).toBeGreaterThan(0)
+ expect(scrollDetail.deltaX).toBe(0)
+ //此处可判断安卓issues:9121的问题
+ expect([300.1905, 300, 299.8095]).toContain(scrollDetail.deltaY);
+ expect(await page.data('isScrollTest')).toBe('scroll:Success')
+ })
+
+ it('Event scrolltolower-滚动到底部/右边',async()=>{
+ // 滚动到底部,是否触发scrolltolower事件
+ await page.callMethod('confirm_scroll_top_input', 2500)
+ await page.waitFor(600)
+ expect(await page.data('isScrolltolowerTest')).toBe('scrolltolower:Success-bottom')
+ })
+
+ it('Event scrolltoupper-滚动到顶部/左边',async()=>{
+ // 滚动到顶部50,是否触发scrolltoupper事件
+ await page.callMethod('confirm_scroll_top_input', 50)
+ await page.waitFor(1000)
+ expect(await page.data('isScrolltoupperTest')).toBe('scrolltoupper:Success-top')
+ })
+
+ it('Event scrollend-滚动结束时触发',async()=>{
+ // 仅App端支持,向上滑动页面
+ await program.swipe({
+ startPoint: { x: 100, y: 300 },
+ endPoint: { x: 100, y: 100 },
+ duration: 100
+ })
+ await page.waitFor(600)
+ const endDetail = await page.data('scrollEndDetailTest')
+ // console.log('scrollEndDetailTest:', endDetail)
+ expect(endDetail.deltaY).toBe(0)
+ expect(endDetail.deltaX).toBe(0)
+ expect(endDetail.scrollLeft).toBe(0)
+ expect(endDetail.scrollTop).toBeGreaterThan(0)
+ expect(endDetail.scrollHeight).toBeGreaterThan(0)
+ expect(endDetail.scrollWidth).toBeGreaterThan(0)
+ })
+
+ //检测竖向可滚动区域
+ it('check_scroll_height', async () => {
+ await page.waitFor(600)
+ const value = await page.callMethod('check_scroll_height')
+ expect(value).toBe(true)
+ })
+
+ // //检测下拉刷新 备注:iOS本地测试结果正确,但是自动化测试结果错误
+ it('check_refresher', async () => {
+ await page.callMethod('confirm_scroll_top_input', 0)
+ await page.setData({
+ refresher_enabled_boolean: true,
+ refresher_triggered_boolean: true
+ })
+ await page.waitFor(2000)
+ expect(await page.data('refresherrefresh')).toBe(true)
+ //延迟 等待下拉刷新执行结束 防止后续测试任务结果异常
+ await page.waitFor(1000)
+ })
+
+ //检测竖向scroll_into_view属性赋值 备注:iOS本地测试结果正确,但是自动化测试结果错误
+ it('check_scroll_into_view_top', async () => {
+ await page.callMethod('setScrollIntoView', 'item---3')
+ await page.waitFor(600)
+ const gridElement = await page.$('#gridview')
+ const scrollTop = await gridElement.attribute("scrollTop")
+ console.log("check_scroll_into_view_top--"+scrollTop)
+ await page.callMethod('setScrollIntoView', 'item---0')
+ expect(scrollTop-280).toBeGreaterThanOrEqual(0)
+ })
+
+ //检测grid-view属性变化 截图校验
+ it('check_grid_view_props', async () => {
+ await page.callMethod('testModifyGridViewProps')
+ await page.waitFor(600)
+ const image = await program.screenshot({fullPage: false});
+ expect(image).toSaveImageSnapshot();
+ })
+})
diff --git a/pages/component/grid-view/grid-view.uvue b/pages/component/grid-view/grid-view.uvue
new file mode 100644
index 0000000000000000000000000000000000000000..f10076590783c50f532e557d97402d36bf7c852d
--- /dev/null
+++ b/pages/component/grid-view/grid-view.uvue
@@ -0,0 +1,341 @@
+
+
+
+
+
+
+
+ {{item.text}}
+
+
+
+ {{text[state]}}
+
+
+ 加载更多
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 拖动设置cross-axis-gap
+
+
+
+
+
+ 拖动设置main-axis-gap
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/component/image/image.test.js b/pages/component/image/image.test.js
index 39845564e9dc8a754c6dc93bbd39dcb6265790ae..0a4b385a4d6138389652aa29a88fac26ed758351 100644
--- a/pages/component/image/image.test.js
+++ b/pages/component/image/image.test.js
@@ -1,6 +1,8 @@
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
-describe('component-native-image', () => {
+describe('component-native-image', () => {
+ const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
+ const isMP = platformInfo.startsWith('mp')
let page;
let start = 0;
async function getWindowInfo() {
@@ -79,17 +81,8 @@ describe('component-native-image', () => {
await page.waitFor(async () => {
return (await page.data('eventLoad')) || (Date.now() - start > 1000);
});
- if(process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) {
- expect(await page.data('eventLoad')).toEqual({
- tagName: 'IMAGE',
- type: 'load',
- width: 10,
- height: 10
- });
- return
- }
expect(await page.data('eventLoad')).toEqual({
- tagName: 'IMAGE',
+ tagName: isMP ? undefined : 'IMAGE',
type: 'load',
width: 10,
height: 10
@@ -104,17 +97,10 @@ describe('component-native-image', () => {
await page.waitFor(async () => {
return (await page.data('eventError')) || (Date.now() - start > 1000);
});
- if(process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) {
- expect(await page.data('eventError')).toEqual({
- tagName: 'IMAGE',
- type: 'error'
- });
- }else {
- expect(await page.data('eventError')).toEqual({
- tagName: 'IMAGE',
- type: 'error'
- });
- }
+ expect(await page.data('eventError')).toEqual({
+ tagName: isMP ? undefined : 'IMAGE',
+ type: 'error'
+ });
await page.setData({
autoTest: false
diff --git a/pages/component/input/input.test.js b/pages/component/input/input.test.js
index 23113f64de76e8f483c78bed507549ed277fe45f..ada82a47c2ee6b63e4baecef7353bd28e98ab301 100644
--- a/pages/component/input/input.test.js
+++ b/pages/component/input/input.test.js
@@ -1,7 +1,9 @@
describe('component-native-input', () => {
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android')
- const isIos = platformInfo.startsWith('ios')
+ const isIOS = platformInfo.startsWith('ios')
+ const isMP = platformInfo.startsWith('mp')
+ const isWeb = platformInfo.startsWith('web')
let page;
beforeAll(async () => {
page = await program.reLaunch('/pages/component/input/input')
@@ -14,31 +16,33 @@ describe('component-native-input', () => {
// })
// expect(image).toSaveImageSnapshot()
// })
- // 测试焦点及键盘弹起
- it('focus', async () => {
- const input = await page.$('#uni-input-focus');
- expect(await input.attribute('focus')).toBe("true")
- // expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(true)
- await page.setData({
- focus: false,
- })
- expect(await input.attribute('focus')).toBe("false")
- // await page.waitFor(1000)
- // expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(false)
- // await page.setData({
- // focus: true,
- // })
- // expect(await input.attribute('focus')).toBe(true)
- // await page.waitFor(1000)
- // expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(true)
- // await page.setData({
- // focus: false,
- // })
- // expect(await input.attribute('focus')).toBe(false)
- // await page.waitFor(1000)
- // expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(false)
- // await page.waitFor(1000)
- });
+ // 测试焦点及键盘弹起
+ if(!isMP) {
+ it('focus', async () => {
+ const input = await page.$('#uni-input-focus');
+ expect(await input.attribute('focus')).toBe("true")
+ // expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(true)
+ await page.setData({
+ focus: false,
+ })
+ expect(await input.attribute('focus')).toBe("false")
+ // await page.waitFor(1000)
+ // expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(false)
+ // await page.setData({
+ // focus: true,
+ // })
+ // expect(await input.attribute('focus')).toBe(true)
+ // await page.waitFor(1000)
+ // expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(true)
+ // await page.setData({
+ // focus: false,
+ // })
+ // expect(await input.attribute('focus')).toBe(false)
+ // await page.waitFor(1000)
+ // expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(false)
+ // await page.waitFor(1000)
+ });
+ }
// 测试修改value属性
it("value", async () => {
@@ -116,20 +120,49 @@ describe('component-native-input', () => {
// "backgroundColor": "#FFA500"
// })
// expect(await placeholder2.attribute("placeholder")).toEqual("占位符背景色为绿色")
- // })
-
- it("disable", async () => {
- const input = await page.$('#uni-input-disable');
- expect(await input.attribute("disabled")).toBe("true")
- })
+ // })
+
+ if(isMP) {
+ it("disable", async () => {
+ const input = await page.$('#uni-input-disable');
+ expect(await input.property("disabled")).toBe(true)
+ })
+ // 如下属性在自动化测试通过property、attribute + confirmType、confirm-type均无法获取
+ // it("confirm-type", async () => {
+ // expect(await (await page.$('#uni-input-confirm-send')).attribute("confirm-type")).toEqual("send")
+ // expect(await (await page.$('#uni-input-confirm-search')).property("confirmType")).toEqual("search")
+ // expect(await (await page.$('#uni-input-confirm-next')).property("confirmType")).toEqual("next")
+ // expect(await (await page.$('#uni-input-confirm-go')).property("confirmType")).toEqual("go")
+ // expect(await (await page.$('#uni-input-confirm-done')).property("confirmType")).toEqual("done")
+ // })
+ // it("cursor-color", async () => {
+ // await page.setData({
+ // cursor_color: "red",
+ // })
+ // await page.waitFor(500)
+ // expect(await (await page.$('#uni-input-cursor-color')).property("cursor-color")).toBe("red")
+ // })
+ } else {
+ it("disable", async () => {
+ const input = await page.$('#uni-input-disable');
+ expect(await input.attribute("disabled")).toBe("true")
+ })
+ it("confirm-type", async () => {
+ expect(await (await page.$('#uni-input-confirm-send')).attribute("confirmType")).toEqual("send")
+ expect(await (await page.$('#uni-input-confirm-search')).attribute("confirmType")).toEqual("search")
+ expect(await (await page.$('#uni-input-confirm-next')).attribute("confirmType")).toEqual("next")
+ expect(await (await page.$('#uni-input-confirm-go')).attribute("confirmType")).toEqual("go")
+ expect(await (await page.$('#uni-input-confirm-done')).attribute("confirmType")).toEqual("done")
+ })
+ it("cursor-color", async () => {
+ await page.setData({
+ cursor_color: "red",
+ })
+ await page.waitFor(500)
+ expect(await (await page.$('#uni-input-cursor-color')).attribute("cursor-color")).toBe("red")
+ })
+ }
- it("confirm-type", async () => {
- expect(await (await page.$('#uni-input-confirm-send')).attribute("confirmType")).toEqual("send")
- expect(await (await page.$('#uni-input-confirm-search')).attribute("confirmType")).toEqual("search")
- expect(await (await page.$('#uni-input-confirm-next')).attribute("confirmType")).toEqual("next")
- expect(await (await page.$('#uni-input-confirm-go')).attribute("confirmType")).toEqual("go")
- expect(await (await page.$('#uni-input-confirm-done')).attribute("confirmType")).toEqual("done")
- })
// it("maxlength", async () => {
// const input = await page.$('.uni-input-maxlength');
@@ -139,13 +172,6 @@ describe('component-native-input', () => {
// await page.waitFor(500)
// })
- it("cursor-color", async () => {
- await page.setData({
- cursor_color: "red",
- })
- await page.waitFor(500)
- expect(await (await page.$('#uni-input-cursor-color')).attribute("cursor-color")).toBe("red")
- })
it("maxlength", async () => {
const input = await page.$('#uni-input-maxlength');
@@ -173,11 +199,7 @@ describe('component-native-input', () => {
})
it("keyboard height changed after page back", async () => {
- if (process.env.uniTestPlatformInfo.toLocaleLowerCase().startsWith('web')) {
- expect(1).toBe(1)
- return
- }
- if (process.env.uniTestPlatformInfo.startsWith('ios')) {
+ if (isWeb || isMP || isIOS) {
expect(1).toBe(1)
return
}
diff --git a/pages/component/list-view/list-view.test.js b/pages/component/list-view/list-view.test.js
index 16877dedab99a9b356045cf86b9aeed314439b19..047b9fea485f59a6019cdc5ae51fe9e049963c9a 100644
--- a/pages/component/list-view/list-view.test.js
+++ b/pages/component/list-view/list-view.test.js
@@ -164,12 +164,12 @@ describe('component-native-list-view', () => {
await page.callMethod('change_scroll_y_boolean', false)
await page.waitFor(600)
}
- await page.callMethod('item_change_size_enum', 3)
+ await page.callMethod('setScrollIntoView', "item---3")
await page.waitFor(600)
const listElement = await page.$('#listview')
const scrollLeft = await listElement.attribute("scrollLeft")
console.log("check_scroll_into_view_left--"+scrollLeft)
- await page.callMethod('item_change_size_enum', 0)
+ await page.callMethod('setScrollIntoView', "item---0")
expect(scrollLeft-1080).toBeGreaterThanOrEqual(0)
})
})
diff --git a/pages/component/list-view/list-view.uvue b/pages/component/list-view/list-view.uvue
index b2577c0b046228f31f8ce0d88045340c2e1a0088..0fe53649443effba294fa251872138f77519b1bb 100644
--- a/pages/component/list-view/list-view.uvue
+++ b/pages/component/list-view/list-view.uvue
@@ -151,6 +151,8 @@
confirm_scroll_left_input(value : number) { this.scroll_left_input = value },
confirm_refresher_background_input(value : string) { this.refresher_background_input = value },
item_change_size_enum(index : number) { this.scrollIntoView = "item---" + index },
+ //自动化测试专用
+ setScrollIntoView(id : string) { this.scrollIntoView = id },
// 自动化测试专用(由于事件event参数对象中存在循环引用,在ios端JSON.stringify报错,自动化测试无法page.data获取)
checkEventTest(e : ScrollEventTest, eventName : String) {
const isPass = e.type === eventName && e.target instanceof UniElement && e.currentTarget instanceof UniElement;
diff --git a/pages/tabBar/template.uvue b/pages/tabBar/template.uvue
index a2feb6588b5ccb4e6c08118825bad699769efc8a..50de9860e23fcc331fab60708b82bfb41e731939 100644
--- a/pages/tabBar/template.uvue
+++ b/pages/tabBar/template.uvue
@@ -216,8 +216,8 @@
// #endif
// #ifdef MP
{
- id: 'vant-button',
- url: 'vant-button',
+ id: 'vant',
+ url: 'vant',
name: '微信自定义组件示例',
open: false,
pages: [] as Page[],
diff --git a/pages/template/vant-button/vant-button.test.js b/pages/template/vant-button/vant-button.test.js
deleted file mode 100644
index a7e8092b11c461177a1b1c824ed1f08c40fc7589..0000000000000000000000000000000000000000
--- a/pages/template/vant-button/vant-button.test.js
+++ /dev/null
@@ -1,24 +0,0 @@
-jest.setTimeout(30000);
-describe('test title', () => {
- let page, vant;
- if (!process.env.uniTestPlatformInfo.startsWith('mp')) {
- it('not support', () => {
- expect(1).toBe(1)
- })
- return
- }
- beforeAll(async () => {
- page = await program.reLaunch('/pages/template/vant-button/vant-button')
- await page.waitFor(3000);
- vant = await page.$('van-button');
- expect(await page.data('jest')).toBe(false);
- });
- it('check title onClick', async () => {
- const titleText = await vant.text();
- expect(titleText).toEqual('vant weapp的van-button按钮组件');
- await vant.tap()
- await page.waitFor(1000);
- console.log('jest', await page.data('jest'))
- // expect(await page.data('jest')).toBe(true);
- });
-});
diff --git a/pages/template/vant-button/vant-button.uvue b/pages/template/vant-button/vant-button.uvue
deleted file mode 100644
index 1640f318a85956053339ba2e8f6eea5b5449fd8a..0000000000000000000000000000000000000000
--- a/pages/template/vant-button/vant-button.uvue
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
- uni-app-x支持在微信小程序端引入微信小程序自定义组件。以下以vant weapp组件为例演示
-
-
-
- vant weapp的van-button按钮组件
-
-
-
-
-
-
diff --git a/pages/template/vant/vant.test.js b/pages/template/vant/vant.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..fced84e2ef4bc5748acdfc9fdcb9ae8999ceb569
--- /dev/null
+++ b/pages/template/vant/vant.test.js
@@ -0,0 +1,28 @@
+jest.setTimeout(30000);
+describe('test vant', () => {
+ let page,vantBtnContainer,vantBtn;
+ if (!process.env.uniTestPlatformInfo.startsWith('mp')) {
+ it('not support', () => {
+ expect(1).toBe(1)
+ })
+ return
+ }
+ beforeAll(async () => {
+ page = await program.reLaunch('/pages/template/vant/vant')
+ await page.waitFor(3000);
+ vantBtnContainer = await page.$('vant-button');
+ expect(await page.data('jest')).toBe(false);
+ });
+ afterAll(async () => {
+ expect(await program.screenshot()).toSaveImageSnapshot();
+ });
+ it('check title onClick', async () => {
+ const titleText = await vantBtnContainer.text();
+ expect(titleText).toEqual('vant weapp的vant-button按钮组件');
+ vantBtn = await vantBtnContainer.$('button')
+ await vantBtn.tap()
+ await page.waitFor(1000);
+ console.log('jest',await page.data('jest'))
+ expect(await page.data('jest')).toBe(true);
+ });
+});
diff --git a/pages/template/vant/vant.uvue b/pages/template/vant/vant.uvue
new file mode 100644
index 0000000000000000000000000000000000000000..915b4a16534c991b3c80f4936732ed030422859d
--- /dev/null
+++ b/pages/template/vant/vant.uvue
@@ -0,0 +1,43 @@
+
+
+
+
+ uni-app-x支持在微信小程序端引入微信小程序自定义组件。以下以vant weapp组件为例演示
+
+ vant-button组件
+ vant weapp的vant-button按钮组件
+ vant-icon组件
+
+ vant-info组件
+
+ vant-loading组件
+
+
+
+
+