@@ -1455,5 +1455,100 @@ describe('rectangles', () => {
14551455 expect ( result . hasIgnoreRectangles ) . toBe ( true )
14561456 expect ( result . ignoredBoxes ) . toMatchSnapshot ( )
14571457 } )
1458+
1459+ it ( 'should scale ignoreRegions by DPR for native iOS app (logical → device pixels)' , async ( ) => {
1460+ const options = createPrepareIgnoreRectanglesOptions ( {
1461+ ignoreRegions : [
1462+ { x : 10 , y : 20 , width : 100 , height : 50 } ,
1463+ ] ,
1464+ devicePixelRatio : 3 ,
1465+ isMobile : true ,
1466+ isNativeContext : true ,
1467+ isAndroid : false ,
1468+ } )
1469+
1470+ const result = await prepareIgnoreRectangles ( options )
1471+
1472+ expect ( result . hasIgnoreRectangles ) . toBe ( true )
1473+ expect ( result . ignoredBoxes ) . toHaveLength ( 1 )
1474+ expect ( result . ignoredBoxes [ 0 ] ) . toEqual ( {
1475+ left : 30 ,
1476+ top : 60 ,
1477+ right : 330 ,
1478+ bottom : 210 ,
1479+ } )
1480+ } )
1481+
1482+ it ( 'should scale multiple ignoreRegions by DPR for native iOS app' , async ( ) => {
1483+ const options = createPrepareIgnoreRectanglesOptions ( {
1484+ ignoreRegions : [
1485+ { x : 0 , y : 0 , width : 390 , height : 47 } ,
1486+ { x : 50 , y : 100 , width : 200 , height : 80 } ,
1487+ ] ,
1488+ devicePixelRatio : 3 ,
1489+ isMobile : true ,
1490+ isNativeContext : true ,
1491+ isAndroid : false ,
1492+ } )
1493+
1494+ const result = await prepareIgnoreRectangles ( options )
1495+
1496+ expect ( result . hasIgnoreRectangles ) . toBe ( true )
1497+ expect ( result . ignoredBoxes ) . toHaveLength ( 2 )
1498+ expect ( result . ignoredBoxes [ 0 ] ) . toEqual ( {
1499+ left : 0 ,
1500+ top : 0 ,
1501+ right : 1170 ,
1502+ bottom : 141 ,
1503+ } )
1504+ expect ( result . ignoredBoxes [ 1 ] ) . toEqual ( {
1505+ left : 150 ,
1506+ top : 300 ,
1507+ right : 750 ,
1508+ bottom : 540 ,
1509+ } )
1510+ } )
1511+
1512+ it ( 'should not scale ignoreRegions for native Android app' , async ( ) => {
1513+ const options = createPrepareIgnoreRectanglesOptions ( {
1514+ ignoreRegions : [ { x : 100 , y : 200 , width : 150 , height : 75 } ] ,
1515+ devicePixelRatio : 3 ,
1516+ isMobile : true ,
1517+ isNativeContext : true ,
1518+ isAndroid : true ,
1519+ } )
1520+
1521+ const result = await prepareIgnoreRectangles ( options )
1522+
1523+ expect ( result . hasIgnoreRectangles ) . toBe ( true )
1524+ expect ( result . ignoredBoxes ) . toHaveLength ( 1 )
1525+ expect ( result . ignoredBoxes [ 0 ] ) . toEqual ( {
1526+ left : 100 ,
1527+ top : 200 ,
1528+ right : 250 ,
1529+ bottom : 275 ,
1530+ } )
1531+ } )
1532+
1533+ it ( 'should not scale ignoreRegions when not native context (e.g. web)' , async ( ) => {
1534+ const options = createPrepareIgnoreRectanglesOptions ( {
1535+ ignoreRegions : [ { x : 10 , y : 20 , width : 100 , height : 50 } ] ,
1536+ devicePixelRatio : 3 ,
1537+ isMobile : true ,
1538+ isNativeContext : false ,
1539+ isAndroid : false ,
1540+ } )
1541+
1542+ const result = await prepareIgnoreRectangles ( options )
1543+
1544+ expect ( result . hasIgnoreRectangles ) . toBe ( true )
1545+ expect ( result . ignoredBoxes ) . toHaveLength ( 1 )
1546+ expect ( result . ignoredBoxes [ 0 ] ) . toEqual ( {
1547+ left : 10 ,
1548+ top : 20 ,
1549+ right : 110 ,
1550+ bottom : 70 ,
1551+ } )
1552+ } )
14581553 } )
14591554} )
0 commit comments