提交 403fa446 编写于 作者: zhaofengliang920817's avatar zhaofengliang920817

更新 overflow-visible-event 页面自动化脚本,支持iOS模拟点击手势。

上级 f26abe98
// uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe('/pages/CSS/overflow/overflow-visible-event.uvue', () => {
if (!process.env.uniTestPlatformInfo.startsWith('android')) {
let isAndroid = process.env.uniTestPlatformInfo.startsWith('android')
if (!process.env.uniTestPlatformInfo.startsWith('android') && !process.env.uniTestPlatformInfo.toLowerCase().includes('ios')) {
it('dummyTest', async () => {
expect(1).toBe(1)
})
return
}
let page;
let res;
beforeAll(async () => {
......@@ -27,7 +27,11 @@ describe('/pages/CSS/overflow/overflow-visible-event.uvue', () => {
res = await page.callMethod('jest_getRect')
const point_x = await page.data('jest_click_x');
const point_y = await page.data('jest_click_y');
await program.adbCommand("input tap" + " " + point_x + " " + point_y)
if (isAndroid){
await program.adbCommand("input tap" + " " + point_x + " " + point_y)
} else {
await program.tap({x: point_x, y: point_y})
}
await page.waitFor(500);
res = await page.data('jest_result');
expect(res).toBe(true)
......@@ -41,7 +45,21 @@ describe('/pages/CSS/overflow/overflow-visible-event.uvue', () => {
const distance = 100;
const destY = point_y + 100
const duration = 1000
await program.adbCommand("input swipe" + " " + point_x + " " + point_y + " " + point_x + " " + destY + " " + duration)
if (isAndroid) {
await program.adbCommand("input swipe" + " " + point_x + " " + point_y + " " + point_x + " " + destY + " " + duration)
} else {
await program.swipe({
startPoint: {
x: point_x,
y: point_y
},
endPoint: {
x: point_x,
y: destY
},
duration: duration
})
}
await page.waitFor(1500);
await page.callMethod('jest_getParentRect')
const currentParentTop = await page.data('jest_parent_top');
......@@ -57,7 +75,11 @@ describe('/pages/CSS/overflow/overflow-visible-event.uvue', () => {
const point_x = await page.data('jest_click_x');
const point_y = await page.data('jest_click_y');
console.log("input tap" + " " + point_x + " " + point_y);
await program.adbCommand("input tap" + " " + point_x + " " + point_y)
if (isAndroid) {
await program.adbCommand("input tap" + " " + point_x + " " + point_y)
} else {
await program.tap({x: point_x, y: point_y})
}
await page.waitFor(500);
res = await page.data('jest_result');
expect(res).toBe(true)
......@@ -69,7 +91,11 @@ describe('/pages/CSS/overflow/overflow-visible-event.uvue', () => {
const point_x = await page.data('jest_click_x');
const point_y = await page.data('jest_click_y');
console.log("input tap" + " " + point_x + " " + point_y);
await program.adbCommand("input tap" + " " + point_x + " " + point_y)
if (isAndroid) {
await program.adbCommand("input tap" + " " + point_x + " " + point_y)
} else {
await program.tap({x: point_x, y: point_y})
}
await page.waitFor(500);
res = await page.data('jest_result');
expect(res).toBe(true)
......
......@@ -100,7 +100,10 @@
jest_getRect() {
const rect = uni.getElementById('child')?.getBoundingClientRect()
if (rect != null) {
const ratio = uni.getSystemInfoSync().devicePixelRatio
let ratio = 1
// #ifdef APP-ANDROID
ratio = uni.getSystemInfoSync().devicePixelRatio
// #endif
this.jest_click_x = rect.x * ratio + 10
this.jest_click_y = rect.bottom * ratio - 10
}
......@@ -109,8 +112,11 @@
const transform = uni.getElementById('parent')?.style.getPropertyValue("transform")
if (transform != null) {
let value = transform as string
value = value.split(",")[1].slice(0, -3)
const ratio = uni.getSystemInfoSync().devicePixelRatio
value = value.split(",")[1].slice(0, -3)
let ratio = 1
// #ifdef APP-ANDROID
ratio = uni.getSystemInfoSync().devicePixelRatio
// #endif
this.jest_parent_top = Math.round((parseFloat(value) * ratio))
}
},
......@@ -118,8 +124,11 @@
const rect = uni.getElementById('absolute-view')?.getBoundingClientRect()
if (rect != null) {
const systemInfo = uni.getSystemInfoSync()
const titleBarHeight = systemInfo.screenHeight - systemInfo.windowHeight
const ratio = systemInfo.devicePixelRatio
const titleBarHeight = systemInfo.screenHeight - systemInfo.windowHeight
let ratio = 1
// #ifdef APP-ANDROID
ratio = systemInfo.devicePixelRatio
// #endif
this.jest_click_x = rect.x * ratio + 10
this.jest_click_y = (rect.top + titleBarHeight + 10) * ratio
}
......@@ -130,8 +139,11 @@
if (rect != null) {
scrollView.scrollTo(0, rect.top)
setTimeout(() => {
const systemInfo = uni.getSystemInfoSync()
const ratio = systemInfo.devicePixelRatio
const systemInfo = uni.getSystemInfoSync()
let ratio = 1
// #ifdef APP-ANDROID
ratio = systemInfo.devicePixelRatio
// #endif
const titleBarHeight = systemInfo.screenHeight - systemInfo.windowHeight
const afterRect = uni.getElementById('deep-overflow')?.getBoundingClientRect()
if (afterRect != null) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册