コード例 #1
0
 @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();
 }
コード例 #2
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());
 }
コード例 #3
0
 @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();
 }
コード例 #4
0
 @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);
 }
コード例 #5
0
 @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();
 }
コード例 #6
0
 @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();
 }
コード例 #7
0
 @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();
 }
コード例 #8
0
 @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");
 }
コード例 #9
0
 @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();
 }
コード例 #10
0
 @Test
 public void createRouteToDestination_shouldGetCurrentLocationFirst() throws Exception {
   mapController.setLocation(getTestLocation(22.22, 44.44));
   fragment.createRouteToDestination();
   verify(router, Mockito.times(4)).setLocation(location.capture());
   List<double[]> values = location.getAllValues();
   assertThat(values.get(2)).isEqualTo(new double[] {22.22, 44.44});
   assertThat(values.get(3)).isEqualTo(new double[] {1.0, 1.0});
 }
コード例 #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));
 }
コード例 #12
0
 @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));
   }
 }
コード例 #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));
 }
コード例 #14
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);
 }
コード例 #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));
    }
  }
コード例 #16
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();
 }
コード例 #17
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));
 }
コード例 #18
0
 @Test
 public void success_shouldClearMarkerLayer() throws Exception {
   fragment.createRouteToDestination();
   fragment.success(new Route(getFixture("around_the_block")));
   assertThat(fragment.markers.size()).isEqualTo(2);
 }
コード例 #19
0
 @Test
 public void setRouteTo_shouldClearMap() throws Exception {
   fragment.getMapFragment().addPoi(getTestSimpleFeature());
   fragment.createRouteToDestination();
   assertThat(fragment.getMapFragment().getPoiLayer().size()).isEqualTo(0);
 }
コード例 #20
0
 @Test
 public void setRouteTo_shouldShowLoadingDialog() throws Exception {
   fragment.createRouteToDestination();
   assertThat(activity.getMapFragment().getView().findViewById(R.id.progress)).isVisible();
 }