2019-01-31 19:28:40 -08:00
|
|
|
package org.thoughtcrime.securesms.conversation;
|
2015-11-13 13:20:16 -08:00
|
|
|
|
|
|
|
import android.database.Cursor;
|
|
|
|
|
|
|
|
import org.junit.Before;
|
2019-03-21 09:34:26 -03:00
|
|
|
import org.junit.Ignore;
|
2015-11-13 13:20:16 -08:00
|
|
|
import org.junit.Test;
|
2019-01-31 19:28:40 -08:00
|
|
|
import org.thoughtcrime.securesms.BaseUnitTest;
|
|
|
|
import org.thoughtcrime.securesms.conversation.ConversationAdapter;
|
2015-11-13 13:20:16 -08:00
|
|
|
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
import static org.mockito.Matchers.anyInt;
|
|
|
|
import static org.mockito.Matchers.anyString;
|
|
|
|
import static org.powermock.api.mockito.PowerMockito.mock;
|
|
|
|
import static org.powermock.api.mockito.PowerMockito.when;
|
|
|
|
|
|
|
|
public class ConversationAdapterTest extends BaseUnitTest {
|
2019-01-31 19:28:40 -08:00
|
|
|
private Cursor cursor = mock(Cursor.class);
|
2015-11-13 13:20:16 -08:00
|
|
|
private ConversationAdapter adapter;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Before
|
|
|
|
public void setUp() throws Exception {
|
|
|
|
super.setUp();
|
|
|
|
adapter = new ConversationAdapter(context, cursor);
|
|
|
|
when(cursor.getColumnIndexOrThrow(anyString())).thenReturn(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2019-03-21 09:34:26 -03:00
|
|
|
@Ignore("TODO: Fix test")
|
2017-02-26 17:20:11 +01:00
|
|
|
public void testGetItemIdEquals() throws Exception {
|
2017-06-29 23:21:09 -05:00
|
|
|
when(cursor.getString(anyInt())).thenReturn(null).thenReturn("SMS::1::1");
|
2015-11-13 13:20:16 -08:00
|
|
|
long firstId = adapter.getItemId(cursor);
|
2017-06-29 23:21:09 -05:00
|
|
|
when(cursor.getString(anyInt())).thenReturn(null).thenReturn("MMS::1::1");
|
2015-11-13 13:20:16 -08:00
|
|
|
long secondId = adapter.getItemId(cursor);
|
|
|
|
assertNotEquals(firstId, secondId);
|
2017-06-29 23:21:09 -05:00
|
|
|
when(cursor.getString(anyInt())).thenReturn(null).thenReturn("MMS::2::1");
|
2017-02-26 17:20:11 +01:00
|
|
|
long thirdId = adapter.getItemId(cursor);
|
|
|
|
assertNotEquals(secondId, thirdId);
|
2015-11-13 13:20:16 -08:00
|
|
|
}
|
|
|
|
}
|