GuidanceEstimatedArrivalView extends BaseView { public void setEstimatedArrivalData(@Nullable GuidanceEstimatedArrivalViewData data) { mData = data; populate(data); } GuidanceEstimatedArrivalView(Context context);  GuidanceEstimatedArrivalView(Context context, @Nullable AttributeSet attrs);  GuidanceEstimatedArrivalView(Context context, @Nullable AttributeSet attrs, int defStyleAttr); @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)  GuidanceEstimatedArrivalView(Context context, @Nullable AttributeSet attrs, int defStyleAttr,
                                        int defStyleRes); @Nullable GuidanceEstimatedArrivalViewData getEstimatedArrivalData(); void setEstimatedArrivalData(@Nullable GuidanceEstimatedArrivalViewData data); @Override void onRestoreInstanceState(Parcelable state);  }
@Test public void testUIInit() { final TextView etaView = mEstimatedArrivalView.findViewById(R.id.eta); final TextView distanceView = mEstimatedArrivalView.findViewById(R.id.distance); final TextView durationView = mEstimatedArrivalView.findViewById(R.id.duration); final TextView dotView = mEstimatedArrivalView.findViewById(R.id.dot); assertThat(etaView.getText().toString(), is(getString(R.string.msdkui_value_not_available))); assertThat(distanceView.getText().toString(), is(getString(R.string.msdkui_value_not_available))); assertThat(durationView.getText().toString(), is(getString(R.string.msdkui_value_not_available))); assertThat(dotView.getText().toString(), is(getString(R.string.msdkui_bullet))); GuidanceEstimatedArrivalViewData data = new GuidanceEstimatedArrivalViewData(ETA_DATE, DISTANCE, DURATION); mEstimatedArrivalView.setEstimatedArrivalData(data); assertEquals(etaView.getVisibility(), View.VISIBLE); assertEquals(distanceView.getVisibility(), View.VISIBLE); assertEquals(durationView.getVisibility(), View.VISIBLE); assertEquals(dotView.getVisibility(), View.VISIBLE); assertThat(etaView.getText(), is(equalTo(DateFormatterUtil.format(getApplicationContext(), ETA_DATE)))); assertThat(distanceView.getText(), is(equalTo("10 km"))); assertThat(durationView.getText(), is("2 min")); }
@Test public void setNullSetting() { mEstimatedArrivalView.setEstimatedArrivalData(null); assertThat(mEstimatedArrivalView.getVisibility(), is(View.GONE)); }
@Test public void testUIWhenDataIsInvalid() { final TextView eta = mEstimatedArrivalView.findViewById(R.id.eta); final TextView distance = mEstimatedArrivalView.findViewById(R.id.distance); final TextView duration = mEstimatedArrivalView.findViewById(R.id.duration); GuidanceEstimatedArrivalViewData data = new GuidanceEstimatedArrivalViewData(null, null, null); mEstimatedArrivalView.setEstimatedArrivalData(data); assertEquals(eta.getVisibility(), View.VISIBLE); assertEquals(distance.getVisibility(), View.VISIBLE); assertEquals(duration.getVisibility(), View.VISIBLE); assertThat(eta.getText().toString(), is(getString(R.string.msdkui_value_not_available))); assertThat(distance.getText().toString(), is(getString(R.string.msdkui_value_not_available))); assertThat(duration.getText().toString(), is(getString(R.string.msdkui_value_not_available))); }