提交 7c5ef6d0 编写于 作者: W wangjinxin613

test:优化截图对比测试用例

上级 5c285042
......@@ -157,11 +157,14 @@ describe("shot-compare", () => {
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH);
await page.waitFor(500);
await page.callMethod('getWindowInfo');
await page.callMethod('getDeviceInfo');
// set webview-screenshot-comparison page baseSrc
baseSrc =
process.env.UNI_WEB_SERVICE_URL ? `${process.env.UNI_WEB_SERVICE_URL}/#/` :
"http://test.dcloud.io/unix_h5_build/98_dev_hello-uvue/#/";
page.setData({
baseSrc,
});
......
......@@ -6,6 +6,7 @@
</template>
<script>
import { state, setStatusBarHeight, setDevicePixelRatio } from '@/store/index.uts'
export default {
data() {
return {
......@@ -13,17 +14,15 @@
src: '',
webviewContext: null as WebviewContext | null,
isLoaded: false,
statusBarHeight: 0,
statusBarHeight: state.statusBarHeight,
isCustomNavigationBar: false,
devicePixelRatio: 1,
devicePixelRatio: state.devicePixelRatio,
webviewStyles: {
progress: false
}
}
},
onReady() {
this.getWindowInfo();
this.getDeviceInfo();
this.webviewContext = uni.createWebviewContext('webview-screenshot-comparison', this)
},
methods: {
......@@ -36,12 +35,12 @@
getWindowInfo() {
const res = uni.getWindowInfo();
// 获取状态栏, 供截图对比使用
this.statusBarHeight = res.statusBarHeight;
setStatusBarHeight(res.statusBarHeight);
},
getDeviceInfo: function () {
const res = uni.getDeviceInfo();
// 获取像素比, 供截图对比使用
this.devicePixelRatio = res.devicePixelRatio !== null ? parseFloat(res.devicePixelRatio!) : 1
setDevicePixelRatio(res.devicePixelRatio !== null ? parseFloat(res.devicePixelRatio!) : 1);
}
}
}
......
......@@ -148,6 +148,8 @@ describe("shot-compare", () => {
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH);
await page.waitFor(500);
await page.callMethod('getWindowInfo');
await page.callMethod('getDeviceInfo');
// set webview-screenshot page baseSrc
baseSrc =
......
......@@ -6,6 +6,7 @@
</template>
<script>
import { state, setStatusBarHeight, setDevicePixelRatio } from '@/store/index.uts'
export default {
data() {
return {
......@@ -16,13 +17,11 @@
webviewStyles: {
progress: false
},
headerHeight: 0,
devicePixelRatio: 1
headerHeight: state.statusBarHeight,
devicePixelRatio: state.devicePixelRatio
}
},
onReady() {
this.getWindowInfo();
this.getDeviceInfo();
this.webviewContext = uni.createWebviewContext('webview-screenshot', this)
},
methods: {
......@@ -35,12 +34,12 @@
getWindowInfo() {
const res = uni.getWindowInfo();
// 获取状态栏, 供截图对比使用
this.headerHeight = res.statusBarHeight;
setStatusBarHeight(res.statusBarHeight);
},
getDeviceInfo: function () {
const res = uni.getDeviceInfo();
// 获取像素比, 供截图对比使用
this.devicePixelRatio = res.devicePixelRatio !== null ? parseFloat(res.devicePixelRatio!) : 1
setDevicePixelRatio(res.devicePixelRatio !== null ? parseFloat(res.devicePixelRatio!) : 1);
}
}
}
......
......@@ -2,13 +2,19 @@ export type State = {
lifeCycleNum: number
componentMsg: number,
appLaunchPath: string
appShowPath: string
appShowPath: string,
// 状态栏高度
statusBarHeight : number,
// 设备像素比
devicePixelRatio : number
}
export const state = reactive({
lifeCycleNum: 0,
componentMsg: 0,
appLaunchPath: '',
appShowPath: '',
statusBarHeight: 0,
devicePixelRatio: 1
} as State)
export const setLifeCycleNum = (num: number) => {
......@@ -26,3 +32,12 @@ export const setAppLaunchPath = (path: string) => {
export const setAppShowPath = (path: string) => {
state.appShowPath = path
}
export const setStatusBarHeight = (height : number) => {
state.statusBarHeight = height
}
export const setDevicePixelRatio = (devicePixelRatio : number) => {
state.devicePixelRatio = devicePixelRatio
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册