GuidanceNextManeuverView extends BaseView { public void setNextManeuverData(@Nullable GuidanceNextManeuverData data) { mNextManeuverData = data; populate(data); } GuidanceNextManeuverView(Context context);  GuidanceNextManeuverView(Context context, @Nullable AttributeSet attrs);  GuidanceNextManeuverView(Context context, @Nullable AttributeSet attrs, int defStyleAttr); @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)  GuidanceNextManeuverView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes); @Nullable GuidanceNextManeuverData getNextManeuverData(); void setNextManeuverData(@Nullable GuidanceNextManeuverData data); @Override void onRestoreInstanceState(Parcelable state);  }
@Test public void testUIInit() { final TextView distanceView = mGuidanceNextManeuverView.findViewById(R.id.nextManeuverDistance); final TextView streetName = mGuidanceNextManeuverView.findViewById(R.id.afterNextManeuverStreetName); assertEquals(View.GONE, mGuidanceNextManeuverView.getVisibility()); GuidanceNextManeuverData data = createData(mIconId, mDistance, mStreetName); mGuidanceNextManeuverView.setNextManeuverData(data); assertEquals(mGuidanceNextManeuverView.getVisibility(), View.VISIBLE); assertThat(distanceView.getText(), is(equalTo(mDistance + " m"))); assertThat(streetName.getText(), is(equalTo(mStreetName))); }
@Test public void testUIInitWithDifferentConstructor() { mGuidanceNextManeuverView = new GuidanceNextManeuverView(getApplicationContext(), null, 0, 0); final TextView distanceView = mGuidanceNextManeuverView.findViewById(R.id.nextManeuverDistance); final TextView streetName = mGuidanceNextManeuverView.findViewById(R.id.afterNextManeuverStreetName); assertEquals(View.GONE, mGuidanceNextManeuverView.getVisibility()); GuidanceNextManeuverData data = createData(mIconId, mDistance, mStreetName); mGuidanceNextManeuverView.setNextManeuverData(data); assertEquals(mGuidanceNextManeuverView.getVisibility(), View.VISIBLE); assertThat(distanceView.getText(), is(equalTo(mDistance + " m"))); assertThat(streetName.getText(), is(equalTo(mStreetName))); }
@Test public void testUIInitWithNullForFieldVisibility() { final TextView distanceView = mGuidanceNextManeuverView.findViewById(R.id.nextManeuverDistance); final TextView streetName = mGuidanceNextManeuverView.findViewById(R.id.afterNextManeuverStreetName); final TextView dotView = mGuidanceNextManeuverView.findViewById(R.id.dot); assertEquals(View.GONE, mGuidanceNextManeuverView.getVisibility()); GuidanceNextManeuverData data = createData(null, null, null); mGuidanceNextManeuverView.setNextManeuverData(data); assertEquals(mGuidanceNextManeuverView.getVisibility(), View.VISIBLE); assertEquals(View.GONE, distanceView.getVisibility()); assertEquals(View.GONE, streetName.getVisibility()); assertEquals(View.GONE, dotView.getVisibility()); }