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

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

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