diff --git a/android/app/src/com/android/bluetooth/map/BluetoothMapContentObserver.java b/android/app/src/com/android/bluetooth/map/BluetoothMapContentObserver.java index 305dfcb14137536cab7c5f238cb87b3727d0cf22..c018f3352c1a7dae3b9ea4a43f2bcc559f950672 100644 --- a/android/app/src/com/android/bluetooth/map/BluetoothMapContentObserver.java +++ b/android/app/src/com/android/bluetooth/map/BluetoothMapContentObserver.java @@ -536,7 +536,8 @@ public class BluetoothMapContentObserver { this.mFolders = folderStructure; } - private static class ConvoContactInfo { + @VisibleForTesting + static class ConvoContactInfo { public int mConvoColConvoId = -1; public int mConvoColLastActivity = -1; public int mConvoColName = -1; diff --git a/android/app/tests/unit/src/com/android/bluetooth/map/ConvoContactInfoTest.java b/android/app/tests/unit/src/com/android/bluetooth/map/ConvoContactInfoTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8703e8e12a4b0201871630136677f7a85d48187c --- /dev/null +++ b/android/app/tests/unit/src/com/android/bluetooth/map/ConvoContactInfoTest.java @@ -0,0 +1,68 @@ +/* + * Copyright 2022 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.bluetooth.map; + +import static com.google.common.truth.Truth.assertThat; + +import android.database.MatrixCursor; + +import androidx.test.filters.SmallTest; +import androidx.test.runner.AndroidJUnit4; + +import com.android.bluetooth.mapapi.BluetoothMapContract; + +import org.junit.Test; +import org.junit.runner.RunWith; + +@SmallTest +@RunWith(AndroidJUnit4.class) +public class ConvoContactInfoTest { + + @Test + public void setConvoColumns() { + BluetoothMapContentObserver.ConvoContactInfo info = + new BluetoothMapContentObserver.ConvoContactInfo(); + MatrixCursor cursor = new MatrixCursor( + new String[]{BluetoothMapContract.ConvoContactColumns.CONVO_ID, + BluetoothMapContract.ConvoContactColumns.NAME, + BluetoothMapContract.ConvoContactColumns.NICKNAME, + BluetoothMapContract.ConvoContactColumns.X_BT_UID, + BluetoothMapContract.ConvoContactColumns.CHAT_STATE, + BluetoothMapContract.ConvoContactColumns.UCI, + BluetoothMapContract.ConvoContactColumns.LAST_ACTIVE, + BluetoothMapContract.ConvoContactColumns.PRESENCE_STATE, + BluetoothMapContract.ConvoContactColumns.STATUS_TEXT, + BluetoothMapContract.ConvoContactColumns.PRIORITY, + BluetoothMapContract.ConvoContactColumns.LAST_ONLINE}); + + info.setConvoColunms(cursor); + + assertThat(info.mContactColConvoId).isEqualTo(0); + assertThat(info.mContactColName).isEqualTo(1); + assertThat(info.mContactColNickname).isEqualTo(2); + assertThat(info.mContactColBtUid).isEqualTo(3); + assertThat(info.mContactColChatState).isEqualTo(4); + assertThat(info.mContactColUci).isEqualTo(5); + assertThat(info.mContactColNickname).isEqualTo(2); + assertThat(info.mContactColLastActive).isEqualTo(6); + assertThat(info.mContactColName).isEqualTo(1); + assertThat(info.mContactColPresenceState).isEqualTo(7); + assertThat(info.mContactColPresenceText).isEqualTo(8); + assertThat(info.mContactColPriority).isEqualTo(9); + assertThat(info.mContactColLastOnline).isEqualTo(10); + } +}