GuidanceManeuverView extends BaseView { public void setViewState(@Nullable final State state) { mState = state; if (state == null) { setVisibility(GONE); return; } setVisibility(View.VISIBLE); if (State.NO_DATA.equals(mState)) { populateDefaultState(); } else if (State.UPDATING.equals(mState)) { populateBusyProgressBarView(); } else { populate(state.mGuidanceManeuverData); } } GuidanceManeuverView(@NonNull Context context);  GuidanceManeuverView(@NonNull Context context, @Nullable AttributeSet attrs);  GuidanceManeuverView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr); @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)  GuidanceManeuverView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes); @Nullable GuidanceManeuverData getManeuverData(); void setManeuverData(@NonNull GuidanceManeuverData maneuverData); State getViewState(); void setViewState(@Nullable final State state); void highLightManeuver(int color); @Override void onRestoreInstanceState(Parcelable state); static final int ICON_GONE; }
@Test public void testWhenManeuverForRouteRecalculation() { mGuidanceManeuverView.setViewState(GuidanceManeuverView.State.UPDATING); final TextView distanceView = (TextView) mGuidanceManeuverView.findViewById(R.id.distanceView); final TextView infoView1 = (TextView) mGuidanceManeuverView.findViewById(R.id.infoView1); final TextView infoView2 = (TextView) mGuidanceManeuverView.findViewById(R.id.infoView2); final ImageView iconView = (ImageView) mGuidanceManeuverView.findViewById(R.id.maneuverIconView); final ProgressBar busyProgressBar = (ProgressBar) mGuidanceManeuverView.findViewById( R.id.busyStateProgressBar); final TextView defaultView = mGuidanceManeuverView.findViewById(R.id.defaultViewText); assertEquals(distanceView.getVisibility(), View.GONE); assertEquals(infoView1.getVisibility(), View.GONE); assertEquals(defaultView.getVisibility(), View.VISIBLE); assertThat(defaultView.getText().toString(), is(getString(R.string.msdkui_maneuverpanel_updating))); assertEquals(infoView2.getVisibility(), View.GONE); assertEquals(iconView.getVisibility(), View.INVISIBLE); assertEquals(busyProgressBar.getVisibility(), View.VISIBLE); }
@Test public void testExtraIconView() { final ImageView extraIconView = (ImageView) mGuidanceManeuverView.findViewById(R.id.extraIconView); assertEquals(extraIconView.getVisibility(), View.GONE); GuidanceManeuverData data = new GuidanceManeuverData(-1, -1L, "", "", Mockito.mock(Bitmap.class)); mGuidanceManeuverView.setViewState(new GuidanceManeuverView.State(data)); assertEquals(extraIconView.getVisibility(), View.VISIBLE); }
@Test public void testUIWhenSomeDataIsNull() { GuidanceManeuverData data = createData(0, null, null, null); mGuidanceManeuverView.setViewState(new GuidanceManeuverView.State(data)); final TextView distanceView = (TextView) mGuidanceManeuverView.findViewById(R.id.distanceView); final TextView infoView1 = (TextView) mGuidanceManeuverView.findViewById(R.id.infoView1); final TextView infoView2 = (TextView) mGuidanceManeuverView.findViewById(R.id.infoView2); final ImageView iconView = (ImageView) mGuidanceManeuverView.findViewById(R.id.maneuverIconView); assertEquals(distanceView.getVisibility(), View.GONE); assertEquals(infoView1.getVisibility(), View.GONE); assertEquals(infoView2.getVisibility(), View.GONE); assertEquals(iconView.getVisibility(), View.GONE); }