HDMICEC: Add equals test for HdmiCecMessage

Bug: 168713324
Test: atest HdmiCecMessageTest#testEqualsHdmiCecMessage
Change-Id: I31ddbed919ccf7a52824a0252c8d1db35bb6ebd9
Merged-In: I31ddbed919ccf7a52824a0252c8d1db35bb6ebd9
This commit is contained in:
Venkatarama NG. Avadhani
2020-11-05 18:51:40 +05:30
committed by Nathalie Le Clair
parent 555aa8a7fd
commit 161e9b74a1

View File

@@ -0,0 +1,49 @@
/*
* 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();
}
}