提交 616d566b 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

test: 优化截图测试位置

上级 b523a15e
...@@ -6,6 +6,7 @@ const isAndroid = platformInfo.startsWith('android') ...@@ -6,6 +6,7 @@ const isAndroid = platformInfo.startsWith('android')
const isIos = platformInfo.startsWith('ios') const isIos = platformInfo.startsWith('ios')
const isMP = platformInfo.startsWith('mp') const isMP = platformInfo.startsWith('mp')
const isHarmony = platformInfo.startsWith('harmony') const isHarmony = platformInfo.startsWith('harmony')
const isApp = isAndroid || isIos || isHarmony
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'
...@@ -469,7 +470,7 @@ describe('dialog page', () => { ...@@ -469,7 +470,7 @@ describe('dialog page', () => {
}) })
if (isAndroid || isIos || isHarmony) { if (isApp) {
it('after closeDialogPage reset statusBar color', async () => { it('after closeDialogPage reset statusBar color', async () => {
const screenShotArea = { const screenShotArea = {
x: 342, x: 342,
...@@ -482,11 +483,11 @@ describe('dialog page', () => { ...@@ -482,11 +483,11 @@ describe('dialog page', () => {
screenShotArea.y = 20 screenShotArea.y = 20
screenShotArea.width = 40 screenShotArea.width = 40
screenShotArea.height = 20 screenShotArea.height = 20
} else if (process.env.uniTestPlatformInfo.startsWith('android 6')) { } else if (platformInfo.startsWith('android 6')) {
screenShotArea.x = 204 screenShotArea.x = 204
screenShotArea.width = 34 screenShotArea.width = 34
screenShotArea.height = 16 screenShotArea.height = 16
} else if (process.env.uniTestPlatformInfo.startsWith('android 12')) { } else if (platformInfo.startsWith('android 12')) {
screenShotArea.x = 336 screenShotArea.x = 336
screenShotArea.y = 3 screenShotArea.y = 3
screenShotArea.width = 50 screenShotArea.width = 50
......
const CURRENT_PAGE_PATH = const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
"/pages/template/navbar-lite/navbar-lite"; const isAndroid = platformInfo.startsWith('android')
const isIos = platformInfo.startsWith('ios')
const isHarmony = platformInfo.startsWith('harmony')
const isApp = isAndroid || isIos || isHarmony
const CURRENT_PAGE_PATH = "/pages/template/navbar-lite/navbar-lite";
describe("setCustomNavigationBarColor", () => { describe("setCustomNavigationBarColor", () => {
let page; let page;
...@@ -11,18 +16,29 @@ describe("setCustomNavigationBarColor", () => { ...@@ -11,18 +16,29 @@ describe("setCustomNavigationBarColor", () => {
width: 40, width: 40,
height: 20 height: 20
}; };
if (isIos) {
screenShotArea.x = 310
screenShotArea.y = 20
screenShotArea.width = 40
screenShotArea.height = 20
} else if (platformInfo.startsWith('android 6')) {
screenShotArea.x = 204
screenShotArea.width = 34
screenShotArea.height = 16
} else if (platformInfo.startsWith('android 12')) {
screenShotArea.x = 336
screenShotArea.y = 3
screenShotArea.width = 50
screenShotArea.height = 20
} else if (isHarmony) {
screenShotArea.x = 295
screenShotArea.y = 14
screenShotArea.width = 40
screenShotArea.height = 20
}
beforeAll(async () => { beforeAll(async () => {
page = await program.navigateTo(CURRENT_PAGE_PATH); page = await program.navigateTo(CURRENT_PAGE_PATH);
if (process.env.uniTestPlatformInfo.startsWith('android 6')) { await page.waitFor('view');
screenShotArea.x = 204
screenShotArea.width = 34
screenShotArea.height = 16
} else if (process.env.uniTestPlatformInfo.startsWith('android 12')) {
screenShotArea.x = 442
screenShotArea.width = 27
screenShotArea.height = 24
}
await page.waitFor(1000);
originLifeCycleNum = await page.callMethod("getLifeCycleNum"); originLifeCycleNum = await page.callMethod("getLifeCycleNum");
}); });
...@@ -35,7 +51,7 @@ describe("setCustomNavigationBarColor", () => { ...@@ -35,7 +51,7 @@ describe("setCustomNavigationBarColor", () => {
it("setNavigationBarColor2", async () => { it("setNavigationBarColor2", async () => {
await page.callMethod("setNavigationBarColor2"); await page.callMethod("setNavigationBarColor2");
await page.waitFor(1000); await page.waitFor(1000);
if (isAndroid) { if (isApp) {
const image = await program.screenshot({ const image = await program.screenshot({
deviceShot: true, deviceShot: true,
area: screenShotArea, area: screenShotArea,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册