1 /*
2  * Copyright 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package androidx.test.screenshot.matchers
18 
19 import android.graphics.Bitmap
20 
21 /** Interface to implement to provide custom bitmap matchers. */
22 interface BitmapMatcher {
23     /**
24      * Compares the given bitmaps and returns result of the operation.
25      *
26      * The images need to have same size.
27      *
28      * @param expected The reference / golden image.
29      * @param given The image taken during the test.
30      * @param width Width of both of the images.
31      * @param height Height of both of the images.
32      */
compareBitmapsnull33     fun compareBitmaps(expected: IntArray, given: IntArray, width: Int, height: Int): MatchResult
34 }
35 
36 /**
37  * Result of the matching performed by [BitmapMatcher].
38  *
39  * @param matches True if bitmaps match.
40  * @param comparisonStatistics Matching statistics provided by this matcher that performed the
41  *   comparison.
42  * @param diff Diff bitmap that highlights the differences between the images. Can be null if match
43  *   was found.
44  */
45 class MatchResult(val matches: Boolean, val comparisonStatistics: String, val diff: Bitmap?)
46