@Test
 public void success_shouldAddMarkerLayerOnce() throws Exception {
   fragment.createRouteToDestination();
   fragment.success(new Route(getFixture("around_the_block")));
   fragment.success(new Route(getFixture("around_the_block")));
   assertThat(mapController.getMap().layers().contains(fragment.markers)).isTrue();
 }
 @Test
 public void success_shouldAddBubblesAandB() throws Exception {
   Route testRoute = new Route(getFixture("around_the_block"));
   fragment.createRouteToDestination();
   fragment.success(testRoute);
   assertThat(fragment.markers.size()).isEqualTo(2);
 }
 @Test
 public void setRouteTo_failureShouldDismissLoadingDialogUpon() throws Exception {
   fragment.createRouteToDestination();
   fragment.failure(500);
   assertThat(activity.getMapFragment().getView().findViewById(R.id.map)).isVisible();
   assertThat(activity.getMapFragment().getView().findViewById(R.id.progress)).isNotVisible();
 }
 @Test
 public void setRouteTo_successShouldDismissLoadingDialogUpon() throws Exception {
   fragment.createRouteToDestination();
   fragment.success(new Route(getFixture("around_the_block")));
   assertThat(activity.getMapFragment().getView().findViewById(R.id.map)).isVisible();
   assertThat(activity.getMapFragment().getView().findViewById(R.id.progress)).isNotVisible();
 }
 @Test
 public void failure_shouldClearPreviousRoutes() throws Exception {
   fragment.createRouteToDestination();
   fragment.success(new Route(getFixture("around_the_block")));
   fragment.createRouteToDestination();
   fragment.failure(500);
   assertThat(fragment.path.getPoints()).isEmpty();
 }
 @Test
 public void start_shouldClearBubbles() throws Exception {
   fragment.createRouteToDestination();
   Route testRoute = new Route(getFixture("around_the_block"));
   fragment.success(testRoute);
   fragment.routingCircle.performClick();
   assertThat(mapController.getMap().layers().contains(fragment.markers)).isFalse();
 }
 @Test
 public void onDetach_shouldRemovePath() throws Exception {
   fragment.createRouteToDestination();
   Route testRoute = new Route(getFixture("around_the_block"));
   fragment.success(testRoute);
   fragment.onDetach();
   assertThat(mapController.getMap().layers().contains(fragment.path)).isFalse();
 }
 @Test
 public void onStart_shouldHaveCurrentLocation() throws Exception {
   TextView textView = (TextView) fragment.getView().findViewById(R.id.starting_point);
   fragment.createRouteToDestination();
   fragment.success(new Route(getFixture("around_the_block")));
   assertThat(textView).isNotNull();
   assertThat(textView).hasText("Current Location");
 }
 @Test
 public void success_shouldDrawFullRoute() throws Exception {
   fragment.createRouteToDestination();
   Route route = new Route(getFixture("under_hundred"));
   fragment.success(route);
   for (Location loc : route.getGeometry()) {
     assertThat(fragment.path.getPoints()).contains(locationToGeoPoint(loc));
   }
 }
Esempio n. 10
0
 @Test
 public void success_shouldClearPreviousRoutes() throws Exception {
   Route route = new Route(getFixture("around_the_block"));
   fragment.createRouteToDestination();
   fragment.success(route);
   fragment.createRouteToDestination();
   fragment.success(route);
   assertThat(fragment.path.getPoints()).hasSize(route.getGeometry().size());
 }
Esempio n. 11
0
 @Test
 public void onStart_shouldHaveDestinationLocation() throws Exception {
   SimpleFeature feature = getTestSimpleFeature();
   TextView textView = (TextView) fragment.getView().findViewById(R.id.destination);
   fragment.createRouteToDestination();
   fragment.success(new Route(getFixture("around_the_block")));
   assertThat(textView).isNotNull();
   assertThat(textView).hasText(feature.getProperty(TEXT));
 }
Esempio n. 12
0
 @Test
 public void start_shouldStartRouting() throws Exception {
   fragment.createRouteToDestination();
   Route testRoute = new Route(getFixture("around_the_block"));
   fragment.success(testRoute);
   ImageButton startBtn = (ImageButton) fragment.getView().findViewById(R.id.routing_circle);
   startBtn.performClick();
   assertThat(activity.getSupportFragmentManager()).hasFragmentWithTag(RouteFragment.TAG);
 }
Esempio n. 13
0
 @Test
 public void reverse_shouldToggleCircleButtonToStart() throws Exception {
   fragment.createRouteToDestination();
   Route testRoute = new Route(getFixture("around_the_block"));
   fragment.success(testRoute);
   fragment.reverse();
   fragment.reverse();
   assertThat(fragment.routingCircle.getTag()).isEqualTo(activity.getString(R.string.start));
 }
Esempio n. 14
0
 @Test
 public void onDetach_shouldRedrawMap() throws Exception {
   MapFragment mockMapFragment = mock(MapFragment.class);
   fragment.createRouteToDestination();
   Route testRoute = new Route(getFixture("around_the_block"));
   fragment.success(testRoute);
   fragment.setMapFragment(mockMapFragment);
   fragment.onDetach();
   verify(mockMapFragment).updateMap();
 }
Esempio n. 15
0
  @Test
  public void success_shouldDrawReducedRoute() throws Exception {
    fragment.createRouteToDestination();
    Route route = new Route(getFixture("ny_to_vermont"));
    fragment.success(route);

    for (Location loc : reduceWithTolerance(route.getGeometry(), REDUCE_TOLERANCE)) {
      assertThat(fragment.path.getPoints()).contains(locationToGeoPoint(loc));
    }
  }
Esempio n. 16
0
 @Test
 public void onDestroy_shouldHideLocationMarker() throws Exception {
   fragment.onDestroy();
   assertThat(
           fragment
               .getMapFragment()
               .getMap()
               .layers()
               .contains(fragment.getMapFragment().getLocationMarkerLayer()))
       .isTrue();
 }
Esempio n. 17
0
 @Test
 public void byFoot_shouldSetImageResource() throws Exception {
   fragment.routingCircle.setImageResource(R.drawable.ic_start);
   fragment.byFoot(true);
   assertThat(Robolectric.shadowOf(fragment.routingCircle.getDrawable()).getCreatedFromResId())
       .isEqualTo(R.drawable.ic_start_walk);
 }
Esempio n. 18
0
 @Test
 public void routeForCar_shouldRouteByCar() throws Exception {
   RadioButton byCar = (RadioButton) fragment.getView().findViewById(R.id.by_car);
   byCar.setChecked(false);
   byCar.performClick();
   verify(router, times(2)).setDriving();
 }
Esempio n. 19
0
 @Test
 public void byCar_shouldSendMixpanelEvent() throws Exception {
   RadioButton byCar = (RadioButton) fragment.getView().findViewById(R.id.by_car);
   byCar.setChecked(false);
   byCar.performClick();
   verify(mixpanelAPI).track(eq(ROUTING_PREVIEW_CAR), any(JSONObject.class));
 }
Esempio n. 20
0
 @Test
 public void reverse_shouldGetFeatureDestinationFirst() throws Exception {
   mapController.setLocation(getTestLocation(22.22, 44.44));
   fragment.reverse();
   verify(router, times(4)).setLocation(location.capture());
   List<double[]> values = location.getAllValues();
   assertThat(values.get(2)).isEqualTo(new double[] {1.0, 1.0});
   assertThat(values.get(3)).isEqualTo(new double[] {22.22, 44.44});
 }
Esempio n. 21
0
 @Before
 public void setup() throws Exception {
   ((TestMapzenApplication) Robolectric.application).inject(this);
   MockitoAnnotations.initMocks(this);
   activity = initBaseActivity();
   activity.disableActionbar();
   destination = getTestSimpleFeature();
   fragment = RoutePreviewFragment.newInstance(activity, destination);
   TestHelper.startFragment(fragment, activity);
 }
Esempio n. 22
0
 @Test
 public void onResume_shouldNotCreateRouteToDestinationIfRouting() throws Exception {
   activity
       .getSupportFragmentManager()
       .beginTransaction()
       .add(new Fragment(), RouteFragment.TAG)
       .commit();
   fragment.onResume();
   verify(router, times(1)).fetch();
 }
Esempio n. 23
0
 @Test
 public void reverse_shouldSwapOriginalLocationAndDestination() throws Exception {
   TextView startingPoint = (TextView) fragment.getView().findViewById(R.id.starting_point);
   TextView destination = (TextView) fragment.getView().findViewById(R.id.destination);
   SimpleFeature feature = getTestSimpleFeature();
   fragment.createRouteToDestination();
   fragment.success(new Route(getFixture("around_the_block")));
   fragment.getView().findViewById(R.id.route_reverse).performClick();
   fragment.success(new Route(getFixture("around_the_block")));
   assertThat(destination).hasText("Current Location");
   assertThat(startingPoint).hasText(feature.getProperty(TEXT));
 }
Esempio n. 24
0
 @Test
 public void shouldRetainInstanceState() throws Exception {
   assertThat(fragment.getRetainInstance()).isTrue();
 }
Esempio n. 25
0
 @Test
 public void onAttach_shouldResetReferenceToActivity() throws Exception {
   BaseActivity newActivity = initBaseActivity();
   fragment.onAttach(newActivity);
   assertThat(fragment.getBaseActivity()).isEqualTo(newActivity);
 }
Esempio n. 26
0
 @Test
 public void onViewCreated_shouldHideActionBar() throws Exception {
   activity.getSupportActionBar().show();
   fragment.onViewCreated(fragment.getView(), null);
   assertThat(activity.getSupportActionBar().isShowing()).isFalse();
 }
Esempio n. 27
0
 @Test(expected = IllegalArgumentException.class)
 public void onDestroy_shouldUnregisterWithEventBus() throws Exception {
   fragment.onDestroy();
   bus.unregister(fragment);
 }
Esempio n. 28
0
 @Test
 public void newInstance_shouldReturnInstanceOfRoutePreviewFragment() throws Exception {
   assertThat(RoutePreviewFragment.newInstance(activity, destination))
       .isInstanceOf(RoutePreviewFragment.class);
 }
Esempio n. 29
0
 @Test
 public void setRouteTo_shouldClearMap() throws Exception {
   fragment.getMapFragment().addPoi(getTestSimpleFeature());
   fragment.createRouteToDestination();
   assertThat(fragment.getMapFragment().getPoiLayer().size()).isEqualTo(0);
 }
Esempio n. 30
0
 @Test
 public void onViewUpdate_shouldCreateRoute() throws Exception {
   fragment.onViewUpdate(new ViewUpdateEvent());
   verify(router, times(2)).fetch();
 }