1 /* 2 * Copyright (C) 2022 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 platform.test.screenshot 18 19 import platform.test.screenshot.matchers.MSSIMMatcher 20 import platform.test.screenshot.matchers.PixelPerfectMatcher 21 22 /** 23 * The [BitmapMatcher][platform.test.screenshot.matchers.BitmapMatcher] that should be used for 24 * screenshot *unit* tests. 25 */ 26 val UnitTestBitmapMatcher = 27 if (System.getProperty("java.vm.name")?.equals("Dalvik") == false) { // isRobolectric 28 // Different CPU architectures can sometimes end up rendering differently, so we can't do 29 // pixel-perfect matching on different architectures using the same golden. Given that our 30 // presubmits are run on cf_x86_64_phone, our goldens should be perfectly matched on the 31 // x86_64 architecture and use the Structural Similarity Index on others. 32 // TODO(b/237511747): Run our screenshot presubmit tests on arm64 instead so that we can 33 // do pixel perfect matching both at presubmit time and at development time with actual 34 // devices. 35 PixelPerfectMatcher() 36 } else { 37 MSSIMMatcher() 38 } 39 40 /** 41 * The [BitmapMatcher][platform.test.screenshot.matchers.BitmapMatcher] that should be used for 42 * screenshot *unit* tests. 43 * 44 * We use the Structural Similarity Index for integration tests because they usually contain 45 * additional information and noise that shouldn't break the test. 46 */ 47 val IntegrationTestBitmapMatcher = MSSIMMatcher() 48