1 /*
2  * Copyright (C) 2018 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 package com.android.server.hdmi;
17 
18 import android.platform.test.annotations.Presubmit;
19 
20 import androidx.test.filters.SmallTest;
21 
22 import com.google.common.testing.EqualsTester;
23 
24 import org.junit.Test;
25 import org.junit.runner.RunWith;
26 import org.junit.runners.JUnit4;
27 
28 /** Tests for {@link HdmiCecMessage} class. */
29 @SmallTest
30 @Presubmit
31 @RunWith(JUnit4.class)
32 public class HdmiCecMessageTest {
33 
34     @Test
testEqualsHdmiCecMessage()35     public void testEqualsHdmiCecMessage() {
36         int source = 0;
37         int destination = 1;
38         int opcode = 0x7f;
39         byte[] params1 = {0x00, 0x1a, 0x2b, 0x3c};
40         byte[] params2 = {0x00, 0x1a, 0x2b, 0x3c, 0x4d};
41 
42         new EqualsTester()
43                 .addEqualityGroup(
44                         HdmiCecMessage.build(source, destination, opcode, params1),
45                         HdmiCecMessage.build(source, destination, opcode, params1))
46                 .addEqualityGroup(HdmiCecMessage.build(source, destination, opcode, params2))
47                 .addEqualityGroup(HdmiCecMessage.build(source + 1, destination, opcode, params1))
48                 .addEqualityGroup(HdmiCecMessage.build(source, destination + 1, opcode, params1))
49                 .addEqualityGroup(HdmiCecMessage.build(source, destination, opcode + 1, params1))
50                 .testEquals();
51     }
52 }
53