// I have 3 views on my adapter, name, number and photo public void testGetView_fills_list_item_view_with_data_and_executes_request() throws IOException, InterruptedException { // given; byte[] data = IOUtils.toByteArray( getInstrumentation().getContext().getResources().openRawResource(R.raw.binary)); mockWebServer.enqueue(new MockResponse().setBody(data)); mockWebServer.play(); // when View view = adapter.getView(0, null, null); adapter.await(ADAPTER_UPDATE_TIME_OUT); assertTrue(adapter.isLoadBitmapHasBeenCalled()); // then TextView nameView = (TextView) view.findViewById(R.id.user_name_textview); ImageView photoView = (ImageView) view.findViewById(R.id.thumbnail_imageview); assertNotNull("View is null. ", view); assertNotNull("Name TextView is null. ", nameView); assertNotNull("Photo ImageView is null. ", photoView); assertEquals("Names doesn't match.", data1.getFoo(), nameView.getText()); // could we get notified of this request ? assertEquals(1, mockWebServer.getRequestCount()); RecordedRequest first = mockWebServer.takeRequest(); assertEquals("GET /" + data1.getImageUrl() + " HTTP/1.1", first.getRequestLine()); InputStream cacheInputStream = new FileInputStream(cacheFile); assertTrue( IOUtils.contentEquals( cacheInputStream, getInstrumentation().getContext().getResources().openRawResource(R.raw.binary))); }
public void testGetItemId_at_position_0() { assertEquals("Wrong ID.", 0, adapter.getItemId(0)); }
public void testGetCount() { assertEquals("Contacts amount incorrect.", data.size(), adapter.getCount()); }
public void testGetItem_at_position_0() { assertEquals("data1 was expected.", data1.getFoo(), adapter.getItem(0).getFoo()); }