• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 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 package org.robolectric.shadows.testing.bitmapcomparers;
17 
18 /** This abstract class can be used by the tester to implement their own comparison methods */
19 public abstract class BitmapComparer {
20   /**
21    * Compares the two bitmaps given using Java.
22    *
23    * @param offset where in the bitmaps to start
24    * @param stride how much to skip between two different rows
25    * @param width the width of the subsection being tested
26    * @param height the height of the subsection being tested
27    */
verifySame( int[] ideal, int[] given, int offset, int stride, int width, int height)28   public abstract boolean verifySame(
29       int[] ideal, int[] given, int offset, int stride, int width, int height);
30 
31   /**
32    * This calculates the position in an array that would represent a bitmap given the parameters.
33    */
indexFromXAndY(int x, int y, int stride, int offset)34   protected static int indexFromXAndY(int x, int y, int stride, int offset) {
35     return x + (y * stride) + offset;
36   }
37 }
38