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 android.hardware.hdmi.cts; 18 19 import static com.google.common.truth.Truth.assertThat; 20 21 import android.hardware.hdmi.HdmiControlManager; 22 import android.hardware.hdmi.HdmiControlServiceWrapper; 23 import android.hardware.hdmi.HdmiPortInfo; 24 import android.hardware.hdmi.HdmiSwitchClient; 25 26 import androidx.test.ext.junit.runners.AndroidJUnit4; 27 import androidx.test.filters.SmallTest; 28 29 import com.android.compatibility.common.util.AdoptShellPermissionsRule; 30 31 import org.junit.After; 32 import org.junit.Before; 33 import org.junit.Rule; 34 import org.junit.Test; 35 import org.junit.runner.RunWith; 36 37 import java.util.ArrayList; 38 import java.util.List; 39 40 @RunWith(AndroidJUnit4.class) 41 @SmallTest 42 public class HdmiSwitchClientTest { 43 44 private HdmiControlManager mManager; 45 private HdmiSwitchClient mHdmiSwitchClient; 46 private HdmiControlServiceWrapper mService; 47 private final List<HdmiPortInfo> mExpectedInfo = new ArrayList(); 48 49 @Rule 50 public final AdoptShellPermissionsRule shellPermRule = new AdoptShellPermissionsRule(); 51 52 @Before setUp()53 public void setUp() { 54 mService = new HdmiControlServiceWrapper(); 55 int[] types = {HdmiControlServiceWrapper.DEVICE_PURE_CEC_SWITCH}; 56 mService.setDeviceTypes(types); 57 58 mManager = mService.createHdmiControlManager(); 59 mHdmiSwitchClient = mManager.getSwitchClient(); 60 assertThat(mManager).isNotNull(); 61 assertThat(mHdmiSwitchClient).isNotNull(); 62 } 63 64 @After tearDown()65 public void tearDown() { 66 mExpectedInfo.clear(); 67 } 68 69 @Test testGetPortInfo()70 public void testGetPortInfo() { 71 final int id = 0; 72 final int address = 0x1000; 73 final boolean cec = true; 74 final boolean mhl = false; 75 final boolean arc = true; 76 final HdmiPortInfo info = 77 new HdmiPortInfo(id, HdmiPortInfo.PORT_INPUT, address, cec, mhl, arc); 78 mExpectedInfo.add(info); 79 mService.setPortInfo(mExpectedInfo); 80 81 final List<HdmiPortInfo> portInfo = mHdmiSwitchClient.getPortInfo(); 82 assertThat(portInfo).isEqualTo(mExpectedInfo); 83 } 84 } 85