From a211bbdbdc525e3fc06e886486b626c56e2d6276 Mon Sep 17 00:00:00 2001 From: Martin Yankov Date: Fri, 19 Oct 2018 18:48:20 +0300 Subject: [PATCH] test(safe-area): fix ios 12 landscape tests (#6434) --- tests/app/ui/layouts/layout-tests-helper.ts | 6 +++ tests/app/ui/layouts/safe-area-tests.ts | 22 ++++---- .../ui/list-view/list-view-safe-area-tests.ts | 12 +++-- tests/app/ui/page/page-tests-common.ts | 53 ++++++++++++++++++- .../scroll-view-safe-area-tests.ts | 11 ++-- 5 files changed, 83 insertions(+), 21 deletions(-) diff --git a/tests/app/ui/layouts/layout-tests-helper.ts b/tests/app/ui/layouts/layout-tests-helper.ts index 69052330e..cacd342ec 100644 --- a/tests/app/ui/layouts/layout-tests-helper.ts +++ b/tests/app/ui/layouts/layout-tests-helper.ts @@ -39,6 +39,12 @@ export function lessOrCloseEnough(a: number, b: number, message?: string) { message ? TKUnit.assertTrue(less || close, message) : TKUnit.assertTrue(less || close); } +export function greaterOrCloseEnough(a: number, b: number, message?: string) { + const greater = a > b; + const close = Math.abs(a - b) <= EPS; + message ? TKUnit.assertTrue(greater || close, message) : TKUnit.assertTrue(greater || close); +} + export function notEqual(a: T, b: T, message?: string) { message ? TKUnit.assertNotEqual(a, b, message) : TKUnit.assertNotEqual(a, b); } diff --git a/tests/app/ui/layouts/safe-area-tests.ts b/tests/app/ui/layouts/safe-area-tests.ts index 6db8379dc..ec6e7aeca 100644 --- a/tests/app/ui/layouts/safe-area-tests.ts +++ b/tests/app/ui/layouts/safe-area-tests.ts @@ -8,7 +8,7 @@ import * as helper from "../helper"; import { parse } from "tns-core-modules/ui/builder"; import { dipToDp, left, top, right, bottom, height, width, - equal, closeEnough, lessOrCloseEnough, check, + equal, closeEnough, lessOrCloseEnough, greaterOrCloseEnough, check, isLeftAlignedWith, isRightAlignedWith, isTopAlignedWith, isBottomAlignedWith, isLeftWith, isAboveWith, isRightWith, isBelowWith } from "./layout-tests-helper"; @@ -1011,13 +1011,15 @@ export class SafeAreaTests extends testModule.UITest { isBottomAlignedWith(grid, cells[2][1]); isBottomAlignedWith(grid, cells[2][2]); - check(height(cells[0][1]) >= height(cells[1][1]), `cell01 height<${height(cells[0][1])}> not greater or equal cell11 height<${height(cells[1][1])}>`); - lessOrCloseEnough(height(cells[1][1]), height(cells[2][1]), `cell11 height<${height(cells[1][1])}> not less or equal cell21 height<${height(cells[2][1])}>`); + greaterOrCloseEnough(height(cells[0][1]), height(cells[1][1]), `cell01 height<${height(cells[0][1])}> not greater or close enough cell11 height<${height(cells[1][1])}>`); + lessOrCloseEnough(height(cells[1][1]), height(cells[2][1]), `cell11 height<${height(cells[1][1])}> not less or close enough cell21 height<${height(cells[2][1])}>`); + const sumOfNestedGridHeights = height(cells[0][1]) + height(cells[1][1]) + height(cells[2][1]); equal(height(grid), sumOfNestedGridHeights, `grid height<${height(grid)}> sum of nested grids height <${sumOfNestedGridHeights}>`); - check(width(cells[1][0]) >= width(cells[1][1]), `cell10 width<${width(cells[1][0])}> not greater or equal cell11 width<${width(cells[1][1])}>`); - check(width(cells[1][1]) <= width(cells[1][2]), `cell11 width<${width(cells[1][1])}> not less or equal cell12 width<${width(cells[1][2])}>`); + greaterOrCloseEnough(width(cells[1][0]), width(cells[1][1]), `cell10 width<${width(cells[1][0])}> not greater or close enough cell11 width<${width(cells[1][1])}>`); + lessOrCloseEnough(width(cells[1][1]), width(cells[1][2]), `cell11 width<${width(cells[1][1])}> not less or close enough cell12 width<${width(cells[1][2])}>`); + const sumOfNestedGridWidths = width(cells[1][0]) + width(cells[1][1]) + width(cells[1][2]) equal(width(grid), sumOfNestedGridWidths, `grid width<${width(grid)}> sum of nested grids width <${sumOfNestedGridWidths}>`); }, @@ -1364,8 +1366,8 @@ export class SafeAreaTests extends testModule.UITest { private wrap_horizontal_children_components_in_safe_area(pageOptions?: helper.PageOptions) { const snippet = ` - - + + `; @@ -1400,8 +1402,8 @@ export class SafeAreaTests extends testModule.UITest { private wrap_vertical_children_components_in_safe_area(pageOptions?: helper.PageOptions) { const snippet = ` - - + + `; @@ -1438,7 +1440,7 @@ export class SafeAreaTests extends testModule.UITest { const snippet = ` -