diff --git a/pages/API/dialog-page/dialog-1.uvue b/pages/API/dialog-page/dialog-1.uvue index 8f7dccee7551039d03093fc8cf69c3dbd1e676cd..a75bb228bdb95beec1bc0d62528fa20e73333768 100644 --- a/pages/API/dialog-page/dialog-1.uvue +++ b/pages/API/dialog-page/dialog-1.uvue @@ -8,6 +8,7 @@ + diff --git a/pages/API/dialog-page/dialog-page.test.js b/pages/API/dialog-page/dialog-page.test.js index 7f8935d6bdce6f1e2d0ea8143d4b2b257699acb2..a04a9541557f2e87baffaed4358f7289a03fa5e0 100644 --- a/pages/API/dialog-page/dialog-page.test.js +++ b/pages/API/dialog-page/dialog-page.test.js @@ -1,7 +1,8 @@ jest.setTimeout(20000) const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() -const isWeb = platformInfo.startsWith('web') +const isWeb = platformInfo.startsWith('web') +const isAndroid = platformInfo.startsWith('android') const FIRST_PAGE_PATH = '/pages/API/dialog-page/dialog-page' const NEXT_PAGE_PATH = '/pages/API/dialog-page/next-page' @@ -23,8 +24,8 @@ describe('dialog page', () => { await page.callMethod('setLifeCycleNum', 0) lifecycleNum = await page.callMethod('getLifeCycleNum') expect(lifecycleNum).toBe(0) - }); - + }); + it('open dialog1', async () => { await page.callMethod('openDialog1'); // 无法通过获取 dom 元素来判断是否打开了 dialogPage @@ -280,7 +281,33 @@ describe('dialog page', () => { lifecycleNum = await page.callMethod('getLifeCycleNum') expect(lifecycleNum).toBe(2) }) - + + + it('input-hold-keyboard in dialog', async () => { + await page.callMethod('jest_OpenDialog1') + await page.waitFor(2000); + await page.callMethod('jest_getTapPoint') + const point_x = await page.data('jest_click_x'); + const point_y = await page.data('jest_click_y'); + if (isAndroid){ + await program.adbCommand("input tap" + " " + point_x + " " + point_y) + console.log("input tap" + " " + point_x + " " + point_y); + } else { + await program.tap({x: point_x, y: point_y}) + } + + await page.waitFor(1000); + const image = await program.screenshot({ + deviceShot: true, + area: { + x: 0, + y: 200, + } + }) + expect(image).toSaveImageSnapshot() + await page.waitFor(2000); + await page.callMethod('jest_CloseDialog1') + }) 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 index cd9768b71db33d6dda2d05ba853e8211b57f41af..28573013858fa18b519699b1c0d57d89dc0bd699 100644 --- a/pages/API/dialog-page/dialog-page.uvue +++ b/pages/API/dialog-page/dialog-page.uvue @@ -15,7 +15,13 @@ setLifeCycleNum } from '@/store/index.uts' - export default { + export default { + data() { + return { + jest_click_x: -1, + jest_click_y: -1 + } + }, onLoad() { console.log('dialogPage parent onLoad') }, @@ -170,6 +176,23 @@ }, getLifeCycleNum(): number { return state.lifeCycleNum + }, + jest_OpenDialog1(){ + uni.openDialogPage({ + url: '/pages/API/dialog-page/dialog-1?name=dialog1' + }) + }, + jest_CloseDialog1(){ + uni.closeDialogPage({}) + }, + jest_getTapPoint(){ + const systemInfo = uni.getSystemInfoSync() + let ratio = 1 + if (systemInfo.platform == 'android'){ + ratio = systemInfo.devicePixelRatio + } + this.jest_click_x = systemInfo.screenWidth / 2 * ratio + this.jest_click_y = systemInfo.statusBarHeight * ratio + 10 } } }