diff options
author | Mark Tabry <mtab@google.com> | 2020-05-15 13:46:01 -0700 |
---|---|---|
committer | Mark Tabry <mtab@google.com> | 2020-05-15 15:12:25 -0700 |
commit | bf1ff0dc30a225997130b80dbda92240b1df5d34 (patch) | |
tree | a963501fb605aebacc5435a19234a0a4abf4736a /tests/carservice_unit_test/src/com/android/car/vms/VmsProviderInfoStoreTest.java | |
parent | 98b2a6e7abcd27b3f8d0568a79f982b1ad603402 (diff) | |
download | Car-bf1ff0dc30a225997130b80dbda92240b1df5d34.tar.gz |
Rename VmsPublishersInfo to VmsProviderInfoStore and move it under vms.
Bug: 148239926
Test: atest AndroidCarApiTest CarServiceTest CarServiceUnitTest
Change-Id: I17cfb4f154ab6a3f85b2795a551c3a769094a7e5
Diffstat (limited to 'tests/carservice_unit_test/src/com/android/car/vms/VmsProviderInfoStoreTest.java')
-rw-r--r-- | tests/carservice_unit_test/src/com/android/car/vms/VmsProviderInfoStoreTest.java | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/carservice_unit_test/src/com/android/car/vms/VmsProviderInfoStoreTest.java b/tests/carservice_unit_test/src/com/android/car/vms/VmsProviderInfoStoreTest.java new file mode 100644 index 0000000000..ae28fd190b --- /dev/null +++ b/tests/carservice_unit_test/src/com/android/car/vms/VmsProviderInfoStoreTest.java @@ -0,0 +1,68 @@ +/* + * 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 com.android.car.vms; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import org.junit.Before; +import org.junit.Test; + +public class VmsProviderInfoStoreTest { + private static final byte[] MOCK_INFO_1 = new byte[]{2, 3, 5, 7, 11, 13, 17}; + private static final byte[] SAME_MOCK_INFO_1 = new byte[]{2, 3, 5, 7, 11, 13, 17}; + private static final byte[] MOCK_INFO_2 = new byte[]{2, 3, 5, 7, 11, 13, 17, 19}; + + private VmsProviderInfoStore mProviderInfoStore; + + @Before + public void setUp() throws Exception { + mProviderInfoStore = new VmsProviderInfoStore(); + } + + @Test + public void testSingleInfo() { + int id = mProviderInfoStore.getProviderId(MOCK_INFO_1); + assertEquals(1, id); + assertArrayEquals(MOCK_INFO_1, mProviderInfoStore.getProviderInfo(id)); + } + + @Test + public void testSingleInfo_NoSuchId() { + assertNull(mProviderInfoStore.getProviderInfo(12345)); + } + + @Test + public void testTwoInfos() { + int id1 = mProviderInfoStore.getProviderId(MOCK_INFO_1); + int id2 = mProviderInfoStore.getProviderId(MOCK_INFO_2); + assertEquals(1, id1); + assertEquals(2, id2); + assertArrayEquals(MOCK_INFO_1, mProviderInfoStore.getProviderInfo(id1)); + assertArrayEquals(MOCK_INFO_2, mProviderInfoStore.getProviderInfo(id2)); + } + + @Test + public void testSingleInfoInsertedTwice() { + int id = mProviderInfoStore.getProviderId(MOCK_INFO_1); + assertEquals(1, id); + + int sameId = mProviderInfoStore.getProviderId(SAME_MOCK_INFO_1); + assertEquals(sameId, id); + } +} |