• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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.car.navigation;
18 
19 import static com.google.common.truth.Truth.assertThat;
20 
21 import android.os.Parcel;
22 
23 import org.junit.Test;
24 import org.junit.runner.RunWith;
25 import org.mockito.junit.MockitoJUnitRunner;
26 
27 @RunWith(MockitoJUnitRunner.class)
28 public final class CarNavigationInstrumentClusterTest {
29 
30     @Test
testCopyConstructor_constructsAsExpected()31     public void testCopyConstructor_constructsAsExpected() {
32         CarNavigationInstrumentCluster carNavigationInstrumentCluster =
33                 CarNavigationInstrumentCluster.createCustomImageCluster(
34                         /* minIntervalMillis= */ 100, /* imageWidth= */ 800,
35                         /* imageHeight= */ 480, /* imageColorDepthBits= */ 32);
36 
37         CarNavigationInstrumentCluster copy = new CarNavigationInstrumentCluster(
38                 carNavigationInstrumentCluster);
39 
40         assertThat(copy.getExtra().keySet()).isEmpty();
41         assertThat(copy.getImageColorDepthBits()).isEqualTo(32);
42         assertThat(copy.getImageHeight()).isEqualTo(480);
43         assertThat(copy.getImageWidth()).isEqualTo(800);
44         assertThat(copy.getMinIntervalMillis()).isEqualTo(100);
45     }
46 
47     @Test
testNewArray()48     public void testNewArray() {
49         CarNavigationInstrumentCluster[] carNavigationInstrumentClusters =
50                 CarNavigationInstrumentCluster.CREATOR.newArray(10);
51 
52         assertThat(carNavigationInstrumentClusters).hasLength(10);
53     }
54 
55     @Test
testCreateFromParcel()56     public void testCreateFromParcel() {
57         CarNavigationInstrumentCluster carNavigationInstrumentCluster =
58                 CarNavigationInstrumentCluster.createCustomImageCluster(
59                         /* minIntervalMillis= */ 100, /* imageWidth= */ 800,
60                         /* imageHeight= */ 480, /* imageColorDepthBits= */ 32);
61         Parcel parcel = Parcel.obtain();
62         carNavigationInstrumentCluster.writeToParcel(parcel, 0);
63         parcel.setDataPosition(0);
64 
65         CarNavigationInstrumentCluster navigationClusterInfoFromParcel =
66                 CarNavigationInstrumentCluster.CREATOR.createFromParcel(parcel);
67 
68         assertThat(navigationClusterInfoFromParcel.getExtra().keySet()).isEmpty();
69         assertThat(navigationClusterInfoFromParcel.getImageColorDepthBits()).isEqualTo(32);
70         assertThat(navigationClusterInfoFromParcel.getImageHeight()).isEqualTo(480);
71         assertThat(navigationClusterInfoFromParcel.getImageWidth()).isEqualTo(800);
72         assertThat(navigationClusterInfoFromParcel.getMinIntervalMillis()).isEqualTo(100);
73     }
74 }
75