提交 a5492d13 编写于 作者: taohebin@dcloud.io's avatar taohebin@dcloud.io

update: dialog-page.uvue

上级 2c8ae5df
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<button class="mt-10" id="dialog1-close-dialog" @click="closeDialog">closeDialog</button> <button class="mt-10" id="dialog1-close-dialog" @click="closeDialog">closeDialog</button>
<button class="mt-10" id="dialog1-close-this-dialog" @click="closeThisDialog">closeThisDialog</button> <button class="mt-10" id="dialog1-close-this-dialog" @click="closeThisDialog">closeThisDialog</button>
<button class="mt-10" id="dialog1-back" @click="back">back</button> <button class="mt-10" id="dialog1-back" @click="back">back</button>
<input class="uni-common-mt" style="border-width: 1px;border-style: solid;" :focus="true" value="DialogPage中焦点测试"/>
</view> </view>
</view> </view>
</template> </template>
......
jest.setTimeout(20000) jest.setTimeout(20000)
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() 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 FIRST_PAGE_PATH = '/pages/API/dialog-page/dialog-page'
const NEXT_PAGE_PATH = '/pages/API/dialog-page/next-page' const NEXT_PAGE_PATH = '/pages/API/dialog-page/next-page'
...@@ -23,8 +24,8 @@ describe('dialog page', () => { ...@@ -23,8 +24,8 @@ describe('dialog page', () => {
await page.callMethod('setLifeCycleNum', 0) await page.callMethod('setLifeCycleNum', 0)
lifecycleNum = await page.callMethod('getLifeCycleNum') lifecycleNum = await page.callMethod('getLifeCycleNum')
expect(lifecycleNum).toBe(0) expect(lifecycleNum).toBe(0)
}); });
it('open dialog1', async () => { it('open dialog1', async () => {
await page.callMethod('openDialog1'); await page.callMethod('openDialog1');
// 无法通过获取 dom 元素来判断是否打开了 dialogPage // 无法通过获取 dom 元素来判断是否打开了 dialogPage
...@@ -280,7 +281,33 @@ describe('dialog page', () => { ...@@ -280,7 +281,33 @@ describe('dialog page', () => {
lifecycleNum = await page.callMethod('getLifeCycleNum') lifecycleNum = await page.callMethod('getLifeCycleNum')
expect(lifecycleNum).toBe(2) 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 () => { afterAll(async () => {
await page.callMethod('setLifeCycleNum', initLifeCycleNum) await page.callMethod('setLifeCycleNum', initLifeCycleNum)
......
...@@ -15,7 +15,13 @@ ...@@ -15,7 +15,13 @@
setLifeCycleNum setLifeCycleNum
} from '@/store/index.uts' } from '@/store/index.uts'
export default { export default {
data() {
return {
jest_click_x: -1,
jest_click_y: -1
}
},
onLoad() { onLoad() {
console.log('dialogPage parent onLoad') console.log('dialogPage parent onLoad')
}, },
...@@ -170,6 +176,23 @@ ...@@ -170,6 +176,23 @@
}, },
getLifeCycleNum(): number { getLifeCycleNum(): number {
return state.lifeCycleNum 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
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册