提交 37761836 编写于 作者: 杜庆泉's avatar 杜庆泉

prompt 优化自动化测试截图区域,避免某些型号系统区域影响对比结果

上级 9394e36f
...@@ -23,7 +23,7 @@ describe('API-loading', () => { ...@@ -23,7 +23,7 @@ describe('API-loading', () => {
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 100,
width:windowWidth width:windowWidth
}, },
}); });
...@@ -64,7 +64,7 @@ describe('API-loading', () => { ...@@ -64,7 +64,7 @@ describe('API-loading', () => {
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 100,
width:windowWidth width:windowWidth
}, },
}); });
...@@ -106,7 +106,7 @@ describe('API-loading', () => { ...@@ -106,7 +106,7 @@ describe('API-loading', () => {
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 100,
width:windowWidth width:windowWidth
}, },
}); });
...@@ -147,7 +147,7 @@ describe('API-loading', () => { ...@@ -147,7 +147,7 @@ describe('API-loading', () => {
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 100,
width:windowWidth width:windowWidth
}, },
}); });
...@@ -188,7 +188,7 @@ describe('API-loading', () => { ...@@ -188,7 +188,7 @@ describe('API-loading', () => {
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 100,
width:windowWidth width:windowWidth
}, },
}); });
...@@ -229,7 +229,7 @@ describe('API-loading', () => { ...@@ -229,7 +229,7 @@ describe('API-loading', () => {
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 100,
width:windowWidth width:windowWidth
}, },
}); });
...@@ -273,7 +273,7 @@ describe('API-loading', () => { ...@@ -273,7 +273,7 @@ describe('API-loading', () => {
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 100,
width:windowWidth width:windowWidth
}, },
}); });
...@@ -314,7 +314,7 @@ describe('API-loading', () => { ...@@ -314,7 +314,7 @@ describe('API-loading', () => {
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 100,
width:windowWidth width:windowWidth
}, },
}); });
...@@ -355,7 +355,7 @@ describe('API-loading', () => { ...@@ -355,7 +355,7 @@ describe('API-loading', () => {
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 100,
width:windowWidth width:windowWidth
}, },
}); });
...@@ -396,7 +396,7 @@ describe('API-loading', () => { ...@@ -396,7 +396,7 @@ describe('API-loading', () => {
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 100,
width:windowWidth width:windowWidth
}, },
}); });
...@@ -438,7 +438,7 @@ describe('API-loading', () => { ...@@ -438,7 +438,7 @@ describe('API-loading', () => {
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 100,
width:windowWidth width:windowWidth
}, },
}); });
...@@ -479,7 +479,7 @@ describe('API-loading', () => { ...@@ -479,7 +479,7 @@ describe('API-loading', () => {
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 100,
width:windowWidth width:windowWidth
}, },
}); });
...@@ -520,7 +520,7 @@ describe('API-loading', () => { ...@@ -520,7 +520,7 @@ describe('API-loading', () => {
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 100,
width:windowWidth width:windowWidth
}, },
}); });
......
...@@ -16,13 +16,15 @@ describe('API-loading', () => { ...@@ -16,13 +16,15 @@ describe('API-loading', () => {
if (isAndroid) { if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo') const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio; const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({ const image = await program.screenshot({
adb: true, adb: true,
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 200,
width:windowWidth
}, },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
...@@ -54,13 +56,15 @@ describe('API-loading', () => { ...@@ -54,13 +56,15 @@ describe('API-loading', () => {
if (isAndroid) { if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo') const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio; const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({ const image = await program.screenshot({
adb: true, adb: true,
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 200,
width:windowWidth
}, },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
...@@ -93,13 +97,15 @@ describe('API-loading', () => { ...@@ -93,13 +97,15 @@ describe('API-loading', () => {
if (isAndroid) { if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo') const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio; const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({ const image = await program.screenshot({
adb: true, adb: true,
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 200,
width:windowWidth
}, },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
...@@ -132,13 +138,15 @@ describe('API-loading', () => { ...@@ -132,13 +138,15 @@ describe('API-loading', () => {
if (isAndroid) { if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo') const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio; const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({ const image = await program.screenshot({
adb: true, adb: true,
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 200,
width:windowWidth
}, },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
...@@ -171,13 +179,15 @@ describe('API-loading', () => { ...@@ -171,13 +179,15 @@ describe('API-loading', () => {
if (isAndroid) { if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo') const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio; const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({ const image = await program.screenshot({
adb: true, adb: true,
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 200,
width:windowWidth
}, },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
...@@ -210,13 +220,14 @@ describe('API-loading', () => { ...@@ -210,13 +220,14 @@ describe('API-loading', () => {
if (isAndroid) { if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo') const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio; const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({ const image = await program.screenshot({
adb: true, adb: true,
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 200,
width:windowWidth
}, },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
...@@ -249,13 +260,14 @@ describe('API-loading', () => { ...@@ -249,13 +260,14 @@ describe('API-loading', () => {
if (isAndroid) { if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo') const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio; const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({ const image = await program.screenshot({
adb: true, adb: true,
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 200,
width:windowWidth
}, },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
...@@ -288,13 +300,14 @@ describe('API-loading', () => { ...@@ -288,13 +300,14 @@ describe('API-loading', () => {
if (isAndroid) { if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo') const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio; const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({ const image = await program.screenshot({
adb: true, adb: true,
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 200,
width:windowWidth
}, },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
...@@ -327,13 +340,14 @@ describe('API-loading', () => { ...@@ -327,13 +340,14 @@ describe('API-loading', () => {
if (isAndroid) { if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo') const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio; const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({ const image = await program.screenshot({
adb: true, adb: true,
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 200,
width:windowWidth
}, },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
...@@ -366,13 +380,15 @@ describe('API-loading', () => { ...@@ -366,13 +380,15 @@ describe('API-loading', () => {
if (isAndroid) { if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo') const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio; const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({ const image = await program.screenshot({
adb: true, adb: true,
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 200,
width:windowWidth
}, },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
...@@ -405,13 +421,15 @@ describe('API-loading', () => { ...@@ -405,13 +421,15 @@ describe('API-loading', () => {
if (isAndroid) { if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo') const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio; const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({ const image = await program.screenshot({
adb: true, adb: true,
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 200,
width:windowWidth
}, },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
...@@ -444,13 +462,15 @@ describe('API-loading', () => { ...@@ -444,13 +462,15 @@ describe('API-loading', () => {
if (isAndroid) { if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo') const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio; const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({ const image = await program.screenshot({
adb: true, adb: true,
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 200,
width:windowWidth
}, },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
...@@ -483,13 +503,15 @@ describe('API-loading', () => { ...@@ -483,13 +503,15 @@ describe('API-loading', () => {
if (isAndroid) { if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo') const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio; const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({ const image = await program.screenshot({
adb: true, adb: true,
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 200,
width:windowWidth
}, },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
...@@ -522,13 +544,15 @@ describe('API-loading', () => { ...@@ -522,13 +544,15 @@ describe('API-loading', () => {
if (isAndroid) { if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo') const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio; const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({ const image = await program.screenshot({
adb: true, adb: true,
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 200,
width:windowWidth
}, },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
...@@ -561,13 +585,15 @@ describe('API-loading', () => { ...@@ -561,13 +585,15 @@ describe('API-loading', () => {
if (isAndroid) { if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo') const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio; const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({ const image = await program.screenshot({
adb: true, adb: true,
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 200,
width:windowWidth
}, },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
...@@ -601,13 +627,14 @@ describe('API-loading', () => { ...@@ -601,13 +627,14 @@ describe('API-loading', () => {
if (isAndroid) { if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo') const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio; const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({ const image = await program.screenshot({
adb: true, adb: true,
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 200,
width:windowWidth
}, },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
...@@ -640,13 +667,15 @@ describe('API-loading', () => { ...@@ -640,13 +667,15 @@ describe('API-loading', () => {
if (isAndroid) { if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo') const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio; const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({ const image = await program.screenshot({
adb: true, adb: true,
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 200,
width:windowWidth
}, },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
...@@ -679,13 +708,14 @@ describe('API-loading', () => { ...@@ -679,13 +708,14 @@ describe('API-loading', () => {
if (isAndroid) { if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo') const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio; const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({ const image = await program.screenshot({
adb: true, adb: true,
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight, height: windowHeight - 200,
width:windowWidth
}, },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
......
...@@ -5,6 +5,7 @@ describe('API-toast', () => { ...@@ -5,6 +5,7 @@ describe('API-toast', () => {
let page; let page;
const isAndroid = process.env.UNI_OS_NAME === "android"; const isAndroid = process.env.UNI_OS_NAME === "android";
beforeAll(async () => { beforeAll(async () => {
page = await program.reLaunch('/pages/API/toast/toast') page = await program.reLaunch('/pages/API/toast/toast')
await page.waitFor(600); await page.waitFor(600);
...@@ -13,12 +14,21 @@ describe('API-toast', () => { ...@@ -13,12 +14,21 @@ describe('API-toast', () => {
it("onload-toast-test", async () => { it("onload-toast-test", async () => {
if (isAndroid) { if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({ const image = await program.screenshot({
adb: true, adb: true,
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight - 200,
width:windowWidth
}, },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
...@@ -38,11 +48,18 @@ describe('API-toast', () => { ...@@ -38,11 +48,18 @@ describe('API-toast', () => {
await btnToastDefaultButton.tap() await btnToastDefaultButton.tap()
await page.waitFor(200) await page.waitFor(200)
if (isAndroid) { if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({ const image = await program.screenshot({
adb: true, adb: true,
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight - 200,
width:windowWidth
}, },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
...@@ -62,11 +79,16 @@ describe('API-toast', () => { ...@@ -62,11 +79,16 @@ describe('API-toast', () => {
await btnToastDurationButton.tap() await btnToastDurationButton.tap()
await page.waitFor(2000) await page.waitFor(2000)
if (isAndroid) { if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({ const image = await program.screenshot({
adb: true, adb: true,
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight - 200,
width:windowWidth
}, },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
...@@ -84,11 +106,16 @@ describe('API-toast', () => { ...@@ -84,11 +106,16 @@ describe('API-toast', () => {
await btnToastErrorIconButton.tap() await btnToastErrorIconButton.tap()
await page.waitFor(200) await page.waitFor(200)
if (isAndroid) { if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({ const image = await program.screenshot({
adb: true, adb: true,
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight - 200,
width:windowWidth
}, },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
...@@ -112,11 +139,16 @@ describe('API-toast', () => { ...@@ -112,11 +139,16 @@ describe('API-toast', () => {
await page.waitFor(200) await page.waitFor(200)
if (isAndroid) { if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({ const image = await program.screenshot({
adb: true, adb: true,
area: { area: {
x: 0, x: 0,
y: 200, y: 200,
height: windowHeight - 200,
width:windowWidth
}, },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
......
...@@ -37,6 +37,10 @@ ...@@ -37,6 +37,10 @@
}, 2000); }, 2000);
}, },
methods: { methods: {
//自动化测试例专用
jest_getWindowInfo() : GetWindowInfoResult {
return uni.getWindowInfo();
},
toast1Tap: function () { toast1Tap: function () {
uni.showToast({ uni.showToast({
title: "默认", title: "默认",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册