HDMICEC: 11.1.13-1 Remote Control Passthrough to Recorder device
Test to check that the DUT sends the appropriate remote control
passthrough messages to a Recording Device.
Bug: 173468440
Test: atest cect_11_1_13_1_RemoteControlMessagesToRecorder
Change-Id: Id220ebcbd08a3d2b9e66985394283ee57d0e03de
diff --git a/hostsidetests/hdmicec/src/android/hdmicec/cts/tv/HdmiCecRemoteControlPassThroughTest.java b/hostsidetests/hdmicec/src/android/hdmicec/cts/tv/HdmiCecRemoteControlPassThroughTest.java
new file mode 100644
index 0000000..75086ec
--- /dev/null
+++ b/hostsidetests/hdmicec/src/android/hdmicec/cts/tv/HdmiCecRemoteControlPassThroughTest.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hdmicec.cts.tv;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.hdmicec.cts.BaseHdmiCecCtsTest;
+import android.hdmicec.cts.CecMessage;
+import android.hdmicec.cts.CecOperand;
+import android.hdmicec.cts.HdmiCecConstants;
+import android.hdmicec.cts.LogicalAddress;
+
+import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.rules.RuleChain;
+import org.junit.runner.RunWith;
+import org.junit.Test;
+
+import java.util.HashMap;
+
+/** HDMI CEC test to check Remote Control Pass Through behaviour (Sections 11.1.13) */
+@RunWith(DeviceJUnit4ClassRunner.class)
+public final class HdmiCecRemoteControlPassThroughTest extends BaseHdmiCecCtsTest {
+
+ private HashMap<String, Integer> remoteControlKeys = new HashMap<String, Integer>();
+
+ @Rule
+ public RuleChain ruleChain =
+ RuleChain.outerRule(CecRules.requiresCec(this))
+ .around(CecRules.requiresLeanback(this))
+ .around(CecRules.requiresDeviceType(this, LogicalAddress.TV))
+ .around(hdmiCecClient);
+
+ public HdmiCecRemoteControlPassThroughTest() {
+ super(LogicalAddress.TV, "-t", "r");
+ mapRemoteControlKeys();
+ }
+
+ @Before
+ public void checkForInitialActiveSourceMessage() throws Exception {
+ try {
+ /*
+ * Check for the broadcasted <ACTIVE_SOURCE> message from Recorder_1, which was sent as
+ * a response to <SET_STREAM_PATH> message from the TV.
+ */
+ String message =
+ hdmiCecClient.checkExpectedMessageFromClient(
+ LogicalAddress.RECORDER_1, CecOperand.ACTIVE_SOURCE);
+ } catch (Exception e) {
+ /*
+ * In case the TV does not send <Set Stream Path> to CEC adapter, or the client does
+ * not make recorder active source, broadcast an <Active Source> message from the
+ * adapter.
+ */
+ hdmiCecClient.broadcastActiveSource(
+ LogicalAddress.RECORDER_1, hdmiCecClient.getPhysicalAddress());
+ }
+ }
+
+ /**
+ * Test 11.1.13-1
+ *
+ * <p>Tests that the DUT sends the appropriate messages for remote control pass through to a
+ * Recording Device.
+ */
+ @Test
+ public void cect_11_1_13_1_RemoteControlMessagesToRecorder() throws Exception {
+ hdmiCecClient.broadcastActiveSource(
+ LogicalAddress.RECORDER_1, hdmiCecClient.getPhysicalAddress());
+ validateKeyeventToUserControlPress(LogicalAddress.RECORDER_1);
+ }
+
+ private void mapRemoteControlKeys() {
+ remoteControlKeys.put("DPAD_UP", HdmiCecConstants.CEC_CONTROL_UP);
+ remoteControlKeys.put("DPAD_DOWN", HdmiCecConstants.CEC_CONTROL_DOWN);
+ remoteControlKeys.put("DPAD_LEFT", HdmiCecConstants.CEC_CONTROL_LEFT);
+ remoteControlKeys.put("DPAD_RIGHT", HdmiCecConstants.CEC_CONTROL_RIGHT);
+ }
+
+ private void validateKeyeventToUserControlPress(LogicalAddress toDevice) throws Exception {
+ ITestDevice device = getDevice();
+ for (String remoteKey : remoteControlKeys.keySet()) {
+ device.executeShellCommand("input keyevent KEYCODE_" + remoteKey);
+ String message =
+ hdmiCecClient.checkExpectedOutput(toDevice, CecOperand.USER_CONTROL_PRESSED);
+ assertThat(CecMessage.getParams(message)).isEqualTo(remoteControlKeys.get(remoteKey));
+ hdmiCecClient.checkExpectedOutput(toDevice, CecOperand.USER_CONTROL_RELEASED);
+ }
+ }
+}