LocationsInfoWindowAdapter implements GoogleMap.InfoWindowAdapter { void setHtmlTextIfNotEmpty(TextView textView, String text) { if (TextUtils.isEmpty(text)) { textView.setVisibility(View.GONE); } else { textView.setVisibility(View.VISIBLE); textView.setText(CompatibilityUtils.fromHtml(text)); } } LocationsInfoWindowAdapter(Context context, Map<Marker, Location> markerLocations); @Override View getInfoWindow(Marker marker); @Override View getInfoContents(Marker marker); Location getLocationForMarker(@NonNull Marker marker);  }
@Test public void should_set_view_to_gone_if_content_is_empty() { TextView tv1 = new TextView(RuntimeEnvironment.application); TextView tv2 = new TextView(RuntimeEnvironment.application); adapter.setHtmlTextIfNotEmpty(tv1, null); adapter.setHtmlTextIfNotEmpty(tv2, ""); assertThat(tv1.getVisibility()).isEqualTo(View.GONE); assertThat(tv2.getVisibility()).isEqualTo(View.GONE); }
@Test public void should_set_view_to_visible_if_content_is_not_empty() { TextView tv = new TextView(RuntimeEnvironment.application); adapter.setHtmlTextIfNotEmpty(tv, "Great"); assertThat(tv.getVisibility()).isEqualTo(View.VISIBLE); assertThat(tv.getText().toString()).isEqualTo("Great"); }