@@ -22,6 +22,21 @@ function isIgnored(x, y, ignoredAreas) {
22
22
) ;
23
23
}
24
24
25
+ function applyIgnoredAreas ( img , ignoredAreas ) {
26
+ const { width, height } = img ;
27
+ for ( let y = 0 ; y < height ; y ++ ) {
28
+ for ( let x = 0 ; x < width ; x ++ ) {
29
+ if ( isIgnored ( x , y , ignoredAreas ) ) {
30
+ const idx = ( width * y + x ) << 2 ;
31
+ img . data [ idx ] = 0 ; // R
32
+ img . data [ idx + 1 ] = 0 ; // G
33
+ img . data [ idx + 2 ] = 0 ; // B
34
+ img . data [ idx + 3 ] = 0 ; // A (transparent)
35
+ }
36
+ }
37
+ }
38
+ }
39
+
25
40
const failedComparisons = [ ] ;
26
41
27
42
fs . readdirSync ( actualDir ) . forEach ( file => {
@@ -40,13 +55,20 @@ fs.readdirSync(actualDir).forEach(file => {
40
55
ignoredAreas = [
41
56
{ x : 0 , y : height - 40 , width, height : 40 } // Ignore bottom 40 pixels where is Home Indicator on iOS
42
57
] ;
58
+ } else if ( platform === 'android' ) {
59
+ ignoredAreas = [
60
+ { x : 0 , y : 0 , width, height : 40 } // Ignore top 40 pixels on Android
61
+ ] ;
43
62
}
44
63
64
+ applyIgnoredAreas ( actualImg , ignoredAreas ) ;
65
+ applyIgnoredAreas ( expectedImg , ignoredAreas ) ;
66
+
45
67
const numDiffPixels = pixelmatch ( actualImg . data , expectedImg . data , diff . data , width , height , {
46
68
threshold : 0.1 ,
47
69
includeAA : false ,
48
70
diffMask : true
49
- } , ( x , y ) => isIgnored ( x , y , ignoredAreas ) ) ;
71
+ } ) ;
50
72
51
73
const pixelTolerance = 50 ;
52
74
0 commit comments