1 /* 2 * Copyright (C) 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 android.hardware.hdmi; 18 19 import android.platform.test.annotations.Presubmit; 20 21 import androidx.test.filters.SmallTest; 22 23 import com.google.common.testing.EqualsTester; 24 25 import org.junit.Test; 26 import org.junit.runner.RunWith; 27 import org.junit.runners.JUnit4; 28 29 /** Tests for {@link HdmiDeviceInfo} */ 30 @Presubmit 31 @RunWith(JUnit4.class) 32 @SmallTest 33 public class HdmiDeviceInfoTest { 34 35 @Test testEquals()36 public void testEquals() { 37 int logicalAddr = 0x00; 38 int phyAddr = 0x1000; 39 int portId = 1; 40 int deviceType = 0; 41 int vendorId = 0x123456; 42 String displayName = "test device"; 43 int cecVersion = HdmiControlManager.HDMI_CEC_VERSION_2_0; 44 int powerStatus = HdmiControlManager.POWER_STATUS_TRANSIENT_TO_STANDBY; 45 int deviceId = 3; 46 int adopterId = 2; 47 48 new EqualsTester() 49 .addEqualityGroup(HdmiDeviceInfo.INACTIVE_DEVICE) 50 .addEqualityGroup( 51 HdmiDeviceInfo.hardwarePort(phyAddr, portId), 52 HdmiDeviceInfo.hardwarePort(phyAddr, portId)) 53 .addEqualityGroup( 54 HdmiDeviceInfo.mhlDevice(phyAddr, portId, adopterId, deviceId), 55 HdmiDeviceInfo.mhlDevice(phyAddr, portId, adopterId, deviceId)) 56 .addEqualityGroup( 57 HdmiDeviceInfo.cecDeviceBuilder() 58 .setLogicalAddress(logicalAddr) 59 .setPhysicalAddress(phyAddr) 60 .setPortId(portId) 61 .setDeviceType(deviceType) 62 .setVendorId(vendorId) 63 .setDisplayName(displayName) 64 .setDevicePowerStatus(powerStatus) 65 .setCecVersion(cecVersion).build(), 66 HdmiDeviceInfo.cecDeviceBuilder() 67 .setLogicalAddress(logicalAddr) 68 .setPhysicalAddress(phyAddr) 69 .setPortId(portId) 70 .setDeviceType(deviceType) 71 .setVendorId(vendorId) 72 .setDisplayName(displayName) 73 .setDevicePowerStatus(powerStatus) 74 .setCecVersion(cecVersion).build()) 75 .testEquals(); 76 } 77 } 78