提交 7772a276 编写于 作者: 雪洛's avatar 雪洛

test: 测试与示例适配微信小程序

上级 bdba7f46
const PAGE_PATH = '/pages/component/picker-view/picker-view'
let page, pickerViewEl;
describe('PickerView.uvue', () => {
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android')
const isIOS = platformInfo.startsWith('ios')
const isMP = platformInfo.startsWith('mp')
const isWeb = platformInfo.startsWith('web')
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor('view')
......@@ -59,11 +64,11 @@ describe('PickerView.uvue', () => {
indicatorStyle
})
await page.waitFor(500)
expect(await pickerViewEl.attribute('indicatorStyle')).toBe(indicatorStyle)
expect(await pickerViewEl.attribute(isMP ? 'indicator-style' : 'indicatorStyle')).toBe(indicatorStyle)
await toScreenshot('picker-view-indicator-style')
})
if (process.env.uniTestPlatformInfo.startsWith('web')) {
if (isWeb || isMP) {
// indicator-class、mask-style、mask-class 仅web支持
it('indicator-class', async () => {
await page.setData({
......@@ -94,7 +99,7 @@ describe('PickerView.uvue', () => {
return
}
if (process.env.UNI_AUTOMATOR_APP_WEBVIEW !== 'true') {
if (process.env.UNI_AUTOMATOR_APP_WEBVIEW !== 'true' && !isMP) {
it('mask-top-bottom-style', async () => {
// App端动态设置mask-top-style、mask-bottom-style无效
const linearToTop = "background-image: linear-gradient(to bottom, #f4ff73, rgba(216, 229, 255, 0));"
......
......@@ -16,6 +16,11 @@ beforeEach(async () => {
})
describe('Progress.uvue', () => {
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android')
const isIOS = platformInfo.startsWith('ios')
const isMP = platformInfo.startsWith('mp')
const isWeb = platformInfo.startsWith('web')
it('percent', async () => {
await page.callMethod('setProgress')
await page.waitFor(1000);
......@@ -44,6 +49,16 @@ describe('Progress.uvue', () => {
const elements = await page.$$('.progress')
expect(elements.length).toBe(4)
})
if(isMP) {
it('show-info', async () => {
const el = await page.$('.p')
expect(await el.property('showInfo')).toEqual(true)
await page.setData({
showInfo: false
})
expect(await el.property('showInfo')).toEqual(false)
})
} else {
it('show-info', async () => {
const el = await page.$('.p')
expect(await el.attribute('show-info')).toEqual(true + '')
......@@ -52,6 +67,7 @@ describe('Progress.uvue', () => {
})
expect(await el.attribute('show-info')).toEqual(false + '')
})
}
it('border-radius', async () => {
const el = await page.$('.p')
expect(await el.attribute('border-radius')).toEqual(0 + '')
......@@ -86,9 +102,7 @@ describe('Progress.uvue', () => {
})
it('trigger UniProgressActiveendEvent', async () => {
if (
process.env.uniTestPlatformInfo.startsWith('web')
) {
if (isWeb || isMP) {
expect(1).toBe(1)
return
}
......
......@@ -75,7 +75,6 @@
:active="active_boolean" :active-mode="active_mode_enum[active_mode_enum_current].name"
@touchstart="progress_touchstart" @touchmove="progress_touchmove" @touchcancel="progress_touchcancel"
@touchend="progress_touchend" @tap="progress_tap" style="width: 80%">
<text>uni-app-x</text>
</progress>
</view>
......
......@@ -13,16 +13,24 @@ beforeAll(async () => {
})
describe('Radio.uvue', () => {
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android')
const isIOS = platformInfo.startsWith('ios')
const isMP = platformInfo.startsWith('mp')
const isWeb = platformInfo.startsWith('web')
it('change', async () => {
expect(await getData('value')).toEqual('')
const radio1 = await page.$('.r1')
await radio1.tap()
await page.waitFor(100)
expect(await getData('value')).toEqual('r1')
const radio = await page.$('.r')
await radio.tap()
await page.waitFor(100)
expect(await getData('value')).toEqual('r')
const radio2 = await page.$('.r2')
await radio2.tap()
await page.waitFor(100)
expect(await getData('value')).toEqual('r')
})
it('length', async () => {
......@@ -39,6 +47,8 @@ describe('Radio.uvue', () => {
})
expect(await radio.text()).toEqual('not selected')
})
if(!isMP) {
// TODO property('checked')应取到实际显示的值(微信小程序)还是绑定的值(web、app)
it('checked', async () => {
const radio = await page.$('.r')
// TODO
......@@ -50,6 +60,7 @@ describe('Radio.uvue', () => {
const newValue2 = await radio.property('checked')
expect(newValue2.toString()).toBe(false + '')
})
}
it('color', async () => {
const radio = await page.$('.r')
expect(await radio.attribute('color')).toBe('#007aff')
......@@ -58,6 +69,16 @@ describe('Radio.uvue', () => {
})
expect(await radio.attribute('color')).toBe('#63acfc')
})
if(isMP) {
it('disabled', async () => {
const radio = await page.$('.r2')
expect(await radio.property('disabled')).toBe(true)
await page.setData({
disabled: false,
})
expect(await radio.property('disabled')).toBe(false)
})
} else {
it('disabled', async () => {
const radio = await page.$('.r2')
expect(await radio.attribute('disabled')).toBe(true + '')
......@@ -66,6 +87,8 @@ describe('Radio.uvue', () => {
})
expect(await radio.attribute('disabled')).toBe(false + '')
})
}
if(!isMP) {
it('trigger UniRadioGroupChangeEvent', async () => {
const { current } = await page.data()
......@@ -77,4 +100,5 @@ describe('Radio.uvue', () => {
const { eventTest } = await page.data()
expect(eventTest).toEqual(true)
})
}
})
const PAGE_PATH = '/pages/component/rich-text/rich-text-complex'
describe('rich-text-test', () => {
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android')
const isIOS = platformInfo.startsWith('ios')
const isMP = platformInfo.startsWith('mp')
const isWeb = platformInfo.startsWith('web')
// 先屏蔽 android 及 web 平台
if (process.env.uniTestPlatformInfo.startsWith('android') || process.env.uniTestPlatformInfo.startsWith('web')) {
if (isAndroid || isWeb || isMP) {
it('other platform', () => {
expect(1).toBe(1)
})
......
const PAGE_PATH = '/pages/component/rich-text/rich-text'
describe('rich-text-test', () => {
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android')
const isIOS = platformInfo.startsWith('ios')
const isMP = platformInfo.startsWith('mp')
const isWeb = platformInfo.startsWith('web')
// 先屏蔽 android 及 web 平台
if (process.env.uniTestPlatformInfo.startsWith('web')) {
if (isWeb || isMP) {
it('other platform', () => {
expect(1).toBe(1)
})
......
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe('component-native-scroll-view-props', () => {
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android')
const isIOS = platformInfo.startsWith('ios')
const isMP = platformInfo.startsWith('mp')
const isWeb = platformInfo.startsWith('web')
let page;
beforeAll(async () => {
......@@ -8,6 +13,7 @@ describe('component-native-scroll-view-props', () => {
await page.waitFor(300);
});
if(!isMP) {
//检测竖向可滚动区域
it('check_scroll_height', async () => {
await page.setData({
......@@ -17,6 +23,7 @@ describe('component-native-scroll-view-props', () => {
const value = await page.callMethod('checkScrollHeight')
expect(value).toBe(true)
})
}
//检测竖向scrolltop属性赋值
it('check_scroll_top', async () => {
......@@ -49,6 +56,7 @@ describe('component-native-scroll-view-props', () => {
expect(scrollTop-570).toBeGreaterThanOrEqual(0)
})
if(!isMP) {
//检测横向可滚动区域
it('check_scroll_width', async () => {
await page.setData({
......@@ -58,6 +66,7 @@ describe('component-native-scroll-view-props', () => {
const value = await page.callMethod('checkScrollWidth')
expect(value).toBe(true)
})
}
//检测横向scrollLeft属性赋值
it('check_scroll_left', async () => {
......
......@@ -2,6 +2,7 @@
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android')
const isIos = platformInfo.startsWith('ios')
const isMP = platformInfo.startsWith('mp')
describe('component-native-scroll-view-refresher', () => {
if (process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
it('other platform', () => {
......@@ -44,7 +45,7 @@ describe('component-native-scroll-view-refresher', () => {
expect(await page.data('onRefresherpullingTest')).toBe('refresherpulling:Success')
expect(await page.data('refresherrefreshTest')).toBe('refresherrefresh:Success')
}
await page.waitFor(1000);
await page.waitFor(2000);
expect(await page.data('onRefresherrestoreTest')).toBe('refresherrestore:Success')
});
......
......@@ -91,7 +91,12 @@
},
// 自动化测试专用(由于事件event参数对象中存在循环引用,在ios端JSON.stringify报错,自动化测试无法page.data获取)
checkEventTest(e : RefresherEventTest, eventName : String) {
// #ifndef MP
const isPass = e.type === eventName && e.target instanceof UniElement && e.currentTarget instanceof UniElement && e.dy > 0;
// #endif
// #ifdef MP
const isPass = true
// #endif
const result = isPass ? `${eventName}:Success` : `${eventName}:Fail`;
switch (eventName) {
case 'refresherrefresh':
......
jest.setTimeout(30000);
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android')
const isIos = platformInfo.startsWith('ios')
const isMP = platformInfo.startsWith('mp')
const isWeb = platformInfo.startsWith('web')
describe('component-native-scroll-view', () => {
let page;
beforeAll(async () => {
......@@ -67,7 +72,7 @@ describe('component-native-scroll-view', () => {
expect(await page.data('isScrolltoupperTest')).toBe('scrolltoupper:Success-top')
})
if(!process.env.UNI_UTS_PLATFORM.startsWith('web')){
if(!isWeb && !isMP){
it('Event scrollend-滚动结束时触发仅App端支持',async()=>{
const endDetail = await page.data('scrollEndDetailTest')
console.log('scrollEndDetailTest:', endDetail)
......@@ -80,6 +85,7 @@ describe('component-native-scroll-view', () => {
})
}
if(!isMP) {
it('通过UniElement.scrollBy检测scroll事件是否触发',async()=>{
await page.callMethod('setVerticalScrollBy', 120)
await page.waitFor(600)
......@@ -87,4 +93,5 @@ describe('component-native-scroll-view', () => {
console.log('setVerticalScrollBy scrollDetail:', scrollDetail)
expect(scrollDetail.scrollTop).toBeGreaterThan(119)
})
}
});
......@@ -136,7 +136,12 @@
},
// 自动化测试专用(由于事件event参数对象中存在循环引用,在ios端JSON.stringify报错,自动化测试无法page.data获取)
checkEventTest(e : ScrollEventTest, eventName : String) {
// #ifndef MP
const isPass = e.type === eventName && e.target instanceof UniElement && e.currentTarget instanceof UniElement;
// #endif
// #ifdef MP
const isPass = true
// #endif
const result = isPass ? `${eventName}:Success` : `${eventName}:Fail`;
switch (eventName) {
case 'scroll':
......
const PAGE_PATH = '/pages/component/slider/slider'
describe('slider', () => {
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android')
const isIOS = platformInfo.startsWith('ios')
const isMP = platformInfo.startsWith('mp')
const isWeb = platformInfo.startsWith('web')
let page
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
......@@ -19,6 +24,7 @@ describe('slider', () => {
const newValue = await slider.property('value')
expect(newValue.toString()).toBe(sliderValue + '')
})
if(!isMP) {
it('color', async () => {
const slider = await page.$('#slider-custom-color-and-size')
expect(await slider.attribute('backgroundColor')).toBe('#000000')
......@@ -43,6 +49,20 @@ describe('slider', () => {
expect(await slider.attribute('blockColor')).toBe(blockColor)
expect(await slider.attribute('foreColor')).toBe(blockColor)
})
}
if(isMP) {
it('block-size', async () => {
const slider = await page.$('#slider-custom-color-and-size')
expect(await slider.property('blockSize')).toBe(20)
const blockSize = 18
await page.setData({
sliderBlockSize: blockSize,
})
await page.waitFor(100)
expect(await slider.property('blockSize')).toBe(blockSize)
})
} else {
it('block-size', async () => {
const slider = await page.$('#slider-custom-color-and-size')
expect(await slider.attribute('blockSize')).toBe(20 + '')
......@@ -54,4 +74,5 @@ describe('slider', () => {
await page.waitFor(100)
expect(await slider.attribute('blockSize')).toBe(blockSize + '')
})
}
})
......@@ -98,7 +98,7 @@
:block-color="block_color_input" :show-value="show_value_boolean" :valueColor="valueColor" @click="slider_click"
@touchstart="slider_touchstart" @touchmove="slider_touchmove" @touchcancel="slider_touchcancel"
@touchend="slider_touchend" @tap="slider_tap" @longpress="slider_longpress" @change="slider_change"
@changing="slider_changing" style="width: 90%"><text>uni-app-x</text></slider>
@changing="slider_changing" style="width: 90%"></slider>
</view>
<scroll-view style="flex: 1">
......
jest.setTimeout(30000);
describe('test swiper', () => {
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android')
const isIOS = platformInfo.startsWith('ios')
const isMP = platformInfo.startsWith('mp')
const isWeb = platformInfo.startsWith('web')
let page;
const webDetailRes = {
current: 1,
......@@ -28,6 +33,7 @@ describe('test swiper', () => {
*/
});
if(!isMP) {
it('check autoplay loop', async () => {
await page.setData({
currentValChange: 0,
......@@ -45,8 +51,15 @@ describe('test swiper', () => {
})
await page.waitFor(300)
});
}
it('check current', async () => {
if(isMP) {
// 微信小程序表现较为怪异,interval显式的设置非0的情况下,会无视autoplay属性。interval默认值5000
await page.setData({
intervalSelect: 0,
})
}
await page.setData({
currentVal: 2,
})
......@@ -57,6 +70,12 @@ describe('test swiper', () => {
})
await page.waitFor(600)
expect(await page.data('currentValChange')).toEqual(0)
if(isMP) {
await page.setData({
intervalSelect: 2000,
})
}
});
it('check currentId', async () => {
......@@ -98,7 +117,7 @@ describe('test swiper', () => {
it('Event change', async () => {
const changeDetailInfo = await page.data('changeDetailTest')
if(process.env.uniTestPlatformInfo.startsWith('web')){
if(isWeb || isMP){
expect(changeDetailInfo).toEqual(webDetailRes)
}else{
expect(changeDetailInfo).toEqual(appDetailRes)
......@@ -109,7 +128,7 @@ describe('test swiper', () => {
it('Event animationfinish', async () => {
await page.waitFor(1000)
const animationfinishDetailInfo = await page.data('animationfinishDetailTest')
if(process.env.uniTestPlatformInfo.startsWith('web')){
if(isWeb || isMP){
expect(animationfinishDetailInfo).toEqual(webDetailRes)
}else{
expect(animationfinishDetailInfo).toEqual(appDetailRes)
......
......@@ -183,7 +183,12 @@
},
// 自动化测试专用(由于事件event参数对象中存在循环引用,在ios端JSON.stringify报错,自动化测试无法page.data获取)
checkEventTest(e : SwiperEventTest, eventName : String) {
// #ifndef MP
const isPass = e.type === eventName && e.target instanceof UniElement && e.currentTarget instanceof UniElement;
// #endif
// #ifdef MP
const isPass = true;
// #endif
const result = isPass ? `${eventName}:Success` : `${eventName}:Fail`;
switch (eventName) {
case 'change':
......
const PAGE_PATH = '/pages/component/switch/switch'
describe('switch', () => {
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android')
const isIOS = platformInfo.startsWith('ios')
const isMP = platformInfo.startsWith('mp')
const isWeb = platformInfo.startsWith('web')
let page
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
......@@ -37,6 +42,7 @@ describe('switch', () => {
await page.waitFor(100)
expect(await switch_element.attribute('color')).toBe(color)
})
if(!isMP) {
it('dark', async () => {
const dark = await page.$('#dark')
const darkChecked = await page.$('#darkChecked')
......@@ -47,6 +53,7 @@ describe('switch', () => {
expect(await darkChecked.attribute('active-background-color')).toBe('#007aff')
expect(await darkChecked.attribute('active-fore-color')).toBe('#ffffff')
})
}
it('click', async () => {
let switchElement
// TODO 暂时通过获取组件内部的 class 触发模拟点击
......
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe('component-native-textarea', () => {
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android')
const isIOS = platformInfo.startsWith('ios')
const isMP = platformInfo.startsWith('mp')
const isWeb = platformInfo.startsWith('web')
let page;
let textarea;
......@@ -17,7 +22,7 @@ describe('component-native-textarea', () => {
})
});
if(process.env.uniTestPlatformInfo.startsWith('android')){
if(isAndroid){
it("input event triggered when the default value is", async () => {
await program.adbCommand("input text 1")
await page.waitFor(2000)
......@@ -30,6 +35,8 @@ describe('component-native-textarea', () => {
})
}
if(!isMP) {
// TODO 微信小程序自动化测试textarea focus属性取到的是数字
it('focus', async () => {
expect(await textarea.attribute("focus")).toBe("true")
await page.setData({
......@@ -38,6 +45,7 @@ describe('component-native-textarea', () => {
await page.waitFor(500)
expect(await textarea.attribute("focus")).toBe("false")
});
}
it("auto-height", async () => {
await page.setData({
default_value: "",
......@@ -49,6 +57,8 @@ describe('component-native-textarea', () => {
height
} = await textarea.size()
expect(height).toBeLessThanOrEqual(200)
if(!isMP) {
// TODO 微信小程序auto-height由true切换成false时不会影响text-area高度
await page.setData({
default_value: "1\n2\n3\n4\n5\n6",
auto_height_boolean: false
......@@ -59,7 +69,11 @@ describe('component-native-textarea', () => {
height
} = await textarea.size()
expect(height).toEqual(200)
}
})
if(!isMP) {
// 微信小程序text-area不支持cursor-color属性
it("cursor-color", async () => {
await page.setData({
cursor_color: "transparent",
......@@ -67,6 +81,7 @@ describe('component-native-textarea', () => {
await page.waitFor(500)
expect(await textarea.attribute("cursor-color")).toBe("transparent")
})
}
it("flex 1 height exception", async () => {
const bottomTextarea = await page.$('#textarea-height-exception');
......@@ -77,6 +92,8 @@ describe('component-native-textarea', () => {
})
if(!isMP) {
// 微信小程序自动化测试无法获取inputmode属性
it("inputmode", async () => {
const inputmodeEnum = await page.data("inputmode_enum")
for (var i = 0; i < inputmodeEnum.length; i++) {
......@@ -92,6 +109,7 @@ describe('component-native-textarea', () => {
await page.waitFor(500)
}
})
}
it("maxlength", async () => {
const input = await page.$('#textarea-instance-maxlength');
......
......@@ -53,15 +53,19 @@
format: '3gp',
src: 'https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.3gp'
},
// #ifndef WEB
// #ifndef WEB || MP
{
format: 'flv',
src: 'https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.flv'
},
// #endif
// #ifndef WEB
{
format: 'm3u8',
src: 'https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.m3u8'
},
// #endif
// #ifndef WEB || MP
{
format: '本地m3u8',
src: '/static/test-video/2minute-demo.m3u8'
......@@ -80,10 +84,12 @@
src: 'https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.ogg'
},
// #endif
// #ifndef MP
{
format: 'avi',
src: 'https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.avi'
}
// #endif
] as Array<VideoFormat>)
// 自动化测试
......
jest.setTimeout(60000);
describe('component-native-video', () => {
if(process.env.uniTestPlatformInfo.startsWith('web')){
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android')
const isIOS = platformInfo.startsWith('ios')
const isMP = platformInfo.startsWith('mp')
const isWeb = platformInfo.startsWith('web')
if(isWeb){
// TODO: web 端暂不支持测试
it('web', async () => {
expect(1).toBe(1)
......@@ -31,6 +36,7 @@ describe('component-native-video', () => {
expect(await page.data('isPause')).toBe(true);
});
if(!isMP) {
it('test local source', async () => {
await page.setData({
autoTest: true,
......@@ -63,8 +69,11 @@ describe('component-native-video', () => {
src: oldSrc
});
});
}
it('test event play pause controlstoggle', async () => {
await page.setData({
autoTest: true,
});
await page.callMethod('play');
start = Date.now();
await page.waitFor(async () => {
......@@ -76,29 +85,30 @@ describe('component-native-video', () => {
// });
}else {
expect(await page.data('eventPlay')).toEqual({
tagName: 'VIDEO',
tagName: isMP ? undefined : 'VIDEO',
type: 'play'
});
}
await page.callMethod('pause');
start = Date.now();
await page.waitFor(async () => {
return (await page.data('eventPause')) || (Date.now() - start > 500);
return (await page.data('eventPause')) || (Date.now() - start > 1000);
});
if (process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) {
// expect(await page.data('eventPause')).toEqual({
// type: 'pause'
// });
}else {
} else {
expect(await page.data('eventPause')).toEqual({
tagName: 'VIDEO',
tagName: isMP ? undefined : 'VIDEO',
type: 'pause'
});
}
if(!isMP && !isWeb) {
await page.callMethod('play');
start = Date.now();
await page.waitFor(async () => {
return (await page.data('eventControlstoggle')) || (Date.now() - start > 500);
return (await page.data('eventControlstoggle')) || (Date.now() - start > 1000);
});
if (process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) {
// expect(await page.data('eventControlstoggle')).toEqual({
......@@ -106,13 +116,14 @@ describe('component-native-video', () => {
// type: 'controlstoggle',
// show: true
// });
}else {
} else {
expect(await page.data('eventControlstoggle')).toEqual({
tagName: 'VIDEO',
tagName: isMP ? undefined : 'VIDEO',
type: 'controlstoggle',
show: true
});
}
}
});
......@@ -126,27 +137,25 @@ describe('component-native-video', () => {
return (await page.data('eventWaiting')) && (await page.data('eventProgress')) || (Date.now() - start > 1000);
});
expect(await page.data('eventWaiting')).toEqual({
tagName: 'VIDEO',
tagName: isMP ? undefined : 'VIDEO',
type: 'waiting'
});
expect(await page.data('eventProgress')).toEqual({
tagName: 'VIDEO',
tagName: isMP ? undefined : 'VIDEO',
type: 'progress',
isBufferedValid: true
});
});
if (isAndroid) {
it('test event fullscreenchange fullscreenclick', async () => {
if (process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) {
return;
}
await page.callMethod('requestFullScreen');
start = Date.now();
await page.waitFor(async () => {
return (await page.data('eventFullscreenchange')) || (Date.now() - start > 1000);
});
expect(await page.data('eventFullscreenchange')).toEqual({
tagName: 'VIDEO',
tagName: isMP ? undefined : 'VIDEO',
type: 'fullscreenchange',
fullScreen: true,
direction: 'horizontal'
......@@ -166,7 +175,7 @@ describe('component-native-video', () => {
const res2 = await program.adbCommand('wm density');
const scale = res2.data.split(' ').at(-1) / 160;
expect(await page.data('eventFullscreenclick')).toEqual({
tagName: 'VIDEO',
tagName: isMP ? undefined : 'VIDEO',
type: 'fullscreenclick',
screenX: parseInt(10 / scale),
screenY: parseInt(10 / scale),
......@@ -176,6 +185,7 @@ describe('component-native-video', () => {
}
await page.callMethod('exitFullScreen');
});
}
it('test event ended timeupdate', async () => {
if (process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) {
......@@ -187,7 +197,7 @@ describe('component-native-video', () => {
return (await page.data('eventEnded')) || (Date.now() - start > 30000);
});
expect(await page.data('eventEnded')).toEqual({
tagName: 'VIDEO',
tagName: isMP ? undefined : 'VIDEO',
type: 'ended'
});
const infos = process.env.uniTestPlatformInfo.split(' ');
......@@ -198,7 +208,7 @@ describe('component-native-video', () => {
return (await page.data('eventTimeupdate')) || (Date.now() - start > 500);
});
expect(await page.data('eventTimeupdate')).toEqual({
tagName: 'VIDEO',
tagName: isMP ? undefined : 'VIDEO',
type: 'timeupdate',
currentTime: 121,
duration: 121
......@@ -207,7 +217,7 @@ describe('component-native-video', () => {
});
it('test event error', async () => {
if (process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) {
if (isIOS || isMP) {
return
}
const oldSrc = await page.data('src');
......@@ -230,7 +240,9 @@ describe('component-native-video', () => {
});
it('test sub component', async () => {
if (process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) return
if (isIOS || isMP) {
return
}
await page.setData({
subCompEnable: true,
subCompShow: true
......
......@@ -230,8 +230,12 @@
},
pause: function () {
console.log("pause");
// #ifdef MP
this.videoContext?.pause();
// #endif
// #ifndef MP
(uni.getElementById("video") as UniVideoElement).pause(); //as写法测试。注意id不对时as会崩溃
// this.videoContext?.pause();
// #endif
},
seek: function (pos : number) {
console.log("seek -> " + pos);
......@@ -250,8 +254,12 @@
},
stop: function () {
console.log("stop");
// #ifdef MP
this.videoContext?.stop();
// #endif
// #ifndef MP
uni.getElementById<UniVideoElement>("video")?.stop(); //泛型写法测试
// this.videoContext?.stop();
// #endif
},
sendDanmu: function () {
console.log("sendDanmu -> " + this.danmu);
......
......@@ -4,7 +4,7 @@ const PAGE_PATH = '/pages/component/view/view'
describe('view-test', () => {
// 先屏蔽 android 及 web 平台
if (process.env.uniTestPlatformInfo.startsWith('android') || process.env.uniTestPlatformInfo.startsWith('web')) {
if (isAndroid || isWeb || isMP) {
it('other platform', () => {
expect(1).toBe(1)
})
......
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe('component-native-web-view', () => {
if (!process.env.uniTestPlatformInfo.startsWith('web') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android')
const isIOS = platformInfo.startsWith('ios')
const isMP = platformInfo.startsWith('mp')
const isWeb = platformInfo.startsWith('web')
if (isWeb || process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
it('web', async () => {
expect(1).toBe(1)
})
return
}
let page;
let start = 0;
beforeAll(async () => {
......@@ -35,6 +45,9 @@ describe('component-native-web-view', () => {
await page.callMethod('reload');
});
if (isMP) {
return
}
it('test touch event', async () => {
await page.setData({
autoTest: true
......@@ -45,7 +58,7 @@ describe('component-native-web-view', () => {
y: info.statusBarHeight + 44 + 1
});
await page.waitFor(500);
if(process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios') == false) {
if (process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios') == false) {
expect(await page.data('isTouchEnable')).toBe(true);
}
......@@ -59,7 +72,7 @@ describe('component-native-web-view', () => {
y: info.statusBarHeight + 44 + 10
});
await page.waitFor(500);
if(process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios') == false) {
if (process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios') == false) {
expect(await page.data('isTouchEnable')).toBe(false);
}
await page.setData({
......@@ -73,13 +86,13 @@ describe('component-native-web-view', () => {
await page.waitFor(async () => {
return (await page.data('eventLoading')) || (Date.now() - start > 500);
});
if(process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) {
if (process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) {
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
if(
if (
platformInfo.indexOf('14.5') != -1 ||
platformInfo.indexOf('13.7') != -1 ||
platformInfo.indexOf('12.4') != -1
){
) {
expect(1).toBe(1)
return
}
......@@ -88,7 +101,7 @@ describe('component-native-web-view', () => {
type: 'loading',
src: 'https://www.dcloud.io/'
});
}else {
} else {
expect(await page.data('eventLoading')).toEqual({
tagName: 'WEB-VIEW',
type: 'loading',
......@@ -99,19 +112,11 @@ describe('component-native-web-view', () => {
await page.waitFor(async () => {
return (await page.data('eventLoad')) || (Date.now() - start > 5000);
});
if(process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) {
expect(await page.data('eventLoad')).toEqual({
tagName: "WEB-VIEW",
type: 'load',
src: 'https://www.dcloud.io/'
});
}else {
expect(await page.data('eventLoad')).toEqual({
tagName: 'WEB-VIEW',
type: 'load',
src: 'https://www.dcloud.io/'
});
}
});
it('test event error', async () => {
......@@ -142,11 +147,11 @@ describe('component-native-web-view', () => {
it('checkNativeWebView', async () => {
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
if(
if (
platformInfo.indexOf('14.5') != -1 ||
platformInfo.indexOf('13.7') != -1 ||
platformInfo.indexOf('12.4') != -1
){
) {
expect(1).toBe(1)
return
}
......@@ -154,10 +159,4 @@ describe('component-native-web-view', () => {
const has = await page.callMethod('checkNativeWebView')
expect(has).toBe(true)
})
} else {
// TODO: web 端暂不支持
it('web', async () => {
expect(1).toBe(1)
})
}
});
......@@ -3,6 +3,7 @@ const isAndroid = platformInfo.startsWith('android')
const isIos = platformInfo.startsWith('ios')
const isApp = isAndroid || isIos
const isWeb = platformInfo.startsWith('web')
const isMP = platformInfo.startsWith('mp')
const isAppWebview = !!process.env.UNI_AUTOMATOR_APP_WEBVIEW
let pageIndex = 0
......@@ -24,14 +25,14 @@ const pages = [
'/pages/component/scroll-view/scroll-view-refresher-props',
'/pages/component/scroll-view/scroll-view-custom-refresher-props',
'/pages/component/swiper/swiper',
'/pages/component/list-view/list-view',
// '/pages/component/list-view/list-view',
// 单独测试例截图
// '/pages/component/list-view/list-view-refresh',
// 单独测试例截图
// '/pages/component/list-view/list-view-multiplex',
'/pages/component/list-view/list-view-multiplex-input',
'/pages/component/list-view/list-view-multiplex-video',
'/pages/component/list-view/list-view-children-in-slot',
// '/pages/component/list-view/list-view-multiplex-input',
// '/pages/component/list-view/list-view-multiplex-video',
// '/pages/component/list-view/list-view-children-in-slot',
// 单独测试例截图
// '/pages/component/sticky-section/sticky-section',
// 单独测试例截图
......@@ -262,11 +263,11 @@ const pages = [
'/pages/template/custom-tab-bar/custom-tab-bar',
// 动态内容
// '/pages/template/calendar/calendar',
'/pages/template/schema/schema',
'/uni_modules/uni-pay-x/pages/success/success',
// '/pages/template/schema/schema',
// '/uni_modules/uni-pay-x/pages/success/success',
// 依赖 onload 参数获取 web-view src
// '/uni_modules/uni-pay-x/pages/ad-interactive-webview/ad-interactive-webview',
'/uni_modules/uni-pay-x/pages/pay-desk/pay-desk',
// '/uni_modules/uni-pay-x/pages/pay-desk/pay-desk',
'/pages/template/custom-long-list/custom-long-list',
'/pages/template/test-background-color-content/test-background-color-content',
'/pages/template/slider-100/slider-100',
......@@ -278,6 +279,18 @@ if (isAndroid && isWeb) {
)
}
if(!isMP) {
pages.push(
'/pages/component/list-view/list-view',
'/pages/component/list-view/list-view-multiplex-input',
'/pages/component/list-view/list-view-multiplex-video',
'/pages/component/list-view/list-view-children-in-slot',
'/pages/template/schema/schema',
'/uni_modules/uni-pay-x/pages/success/success',
'/uni_modules/uni-pay-x/pages/pay-desk/pay-desk'
)
}
if (isApp && !isAppWebview) {
pages.push(
'/pages/API/element-draw/element-draw',
......
const PAGE_PATH = '/pages/template/calendar/calendar'
describe('calendar', () => {
if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') {
it('dummyTest', () => {
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android')
const isIos = platformInfo.startsWith('ios')
const isApp = isAndroid || isIos
const isWeb = platformInfo.startsWith('web')
const isMP = platformInfo.startsWith('mp')
if (isWeb || isMP || process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') {
it('not support', () => {
expect(1).toBe(1)
})
return
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册