Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a730b44c authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes I31ddbed9,I702a2449

* changes:
  HDMICEC: Add equals test for HdmiCecMessage
  HDMICEC: Add equals test for DeviceConfig
parents cdfdcdad 161e9b74
Loading
Loading
Loading
Loading
+49 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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 com.android.server.hdmi;

import androidx.test.filters.SmallTest;

import com.google.common.testing.EqualsTester;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Tests for {@link HdmiCecMessage} class. */
@SmallTest
@RunWith(JUnit4.class)
public class HdmiCecMessageTest {

    @Test
    public void testEqualsHdmiCecMessage() {
        int source = 0;
        int destination = 1;
        int opcode = 0x7f;
        byte[] params1 = {0x00, 0x1a, 0x2b, 0x3c};
        byte[] params2 = {0x00, 0x1a, 0x2b, 0x3c, 0x4d};

        new EqualsTester()
                .addEqualityGroup(
                        new HdmiCecMessage(source, destination, opcode, params1),
                        new HdmiCecMessage(source, destination, opcode, params1))
                .addEqualityGroup(new HdmiCecMessage(source, destination, opcode, params2))
                .addEqualityGroup(new HdmiCecMessage(source + 1, destination, opcode, params1))
                .addEqualityGroup(new HdmiCecMessage(source, destination + 1, opcode, params1))
                .addEqualityGroup(new HdmiCecMessage(source, destination, opcode + 1, params1))
                .testEquals();
    }
}
+29 −0
Original line number Diff line number Diff line
@@ -125,6 +125,35 @@ public class HdmiUtilsTest {
                .testEquals();
    }

    @Test
    public void testEqualsDeviceConfig() {
        String name = "Name";

        CodecSad expectedCodec1 = new CodecSad(Constants.AUDIO_CODEC_LPCM, "011a03");
        CodecSad expectedCodec2 = new CodecSad(Constants.AUDIO_CODEC_DD, "0d0506");
        CodecSad expectedCodec3 = new CodecSad(Constants.AUDIO_CODEC_LPCM, "010203");
        CodecSad expectedCodec4 = new CodecSad(Constants.AUDIO_CODEC_DD, "040506");

        List<CodecSad> list1 = new ArrayList();
        list1.add(expectedCodec1);
        list1.add(expectedCodec2);
        list1.add(expectedCodec3);

        List<CodecSad> list1Duplicate = new ArrayList(list1);

        List<CodecSad> list2 = new ArrayList(list1);
        list2.add(expectedCodec4);

        new EqualsTester()
                .addEqualityGroup(
                        new HdmiUtils.DeviceConfig(name, list1),
                        new HdmiUtils.DeviceConfig(name, list1Duplicate))
                .addEqualityGroup(new HdmiUtils.DeviceConfig(name, list2))
                .addEqualityGroup(new HdmiUtils.DeviceConfig("my" + name, list1))
                .addEqualityGroup(new HdmiUtils.DeviceConfig("my" + name, list2))
                .testEquals();
    }

    @Test
    public void parseSampleXML() {
        List<DeviceConfig> config = new ArrayList<>();