You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			39 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Java
		
	
		
		
			
		
	
	
			39 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Java
		
	
| 
											7 years ago
										 | package org.thoughtcrime.securesms.conversation; | ||
| 
											10 years ago
										 | 
 | ||
|  | import android.database.Cursor; | ||
|  | 
 | ||
|  | import org.junit.Before; | ||
|  | import org.junit.Test; | ||
| 
											7 years ago
										 | import org.thoughtcrime.securesms.BaseUnitTest; | ||
|  | import org.thoughtcrime.securesms.conversation.ConversationAdapter; | ||
| 
											10 years ago
										 | 
 | ||
|  | 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 { | ||
| 
											7 years ago
										 |   private Cursor              cursor = mock(Cursor.class); | ||
| 
											10 years ago
										 |   private ConversationAdapter adapter; | ||
|  | 
 | ||
|  |   @Override | ||
|  |   @Before | ||
|  |   public void setUp() throws Exception { | ||
|  |     super.setUp(); | ||
|  |     adapter = new ConversationAdapter(context, cursor); | ||
|  |     when(cursor.getColumnIndexOrThrow(anyString())).thenReturn(0); | ||
|  |   } | ||
|  | 
 | ||
|  |   @Test | ||
| 
											9 years ago
										 |   public void testGetItemIdEquals() throws Exception { | ||
| 
											8 years ago
										 |     when(cursor.getString(anyInt())).thenReturn(null).thenReturn("SMS::1::1"); | ||
| 
											10 years ago
										 |     long firstId = adapter.getItemId(cursor); | ||
| 
											8 years ago
										 |     when(cursor.getString(anyInt())).thenReturn(null).thenReturn("MMS::1::1"); | ||
| 
											10 years ago
										 |     long secondId = adapter.getItemId(cursor); | ||
|  |     assertNotEquals(firstId, secondId); | ||
| 
											8 years ago
										 |     when(cursor.getString(anyInt())).thenReturn(null).thenReturn("MMS::2::1"); | ||
| 
											9 years ago
										 |     long thirdId = adapter.getItemId(cursor); | ||
|  |     assertNotEquals(secondId, thirdId); | ||
| 
											10 years ago
										 |   } | ||
|  | } |