Пример #1
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();
 }
Пример #2
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);
 }
Пример #3
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();
 }
Пример #4
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();
 }
Пример #5
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();
 }
Пример #6
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();
 }
Пример #7
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();
 }
Пример #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 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));
   }
 }
Пример #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());
 }
Пример #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 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);
 }
Пример #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 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();
 }
Пример #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 onDestroy_shouldHideLocationMarker() throws Exception {
   fragment.onDestroy();
   assertThat(
           fragment
               .getMapFragment()
               .getMap()
               .layers()
               .contains(fragment.getMapFragment().getLocationMarkerLayer()))
       .isTrue();
 }
Пример #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);
 }
Пример #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();
 }
Пример #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));
 }
Пример #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});
 }
Пример #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);
 }
Пример #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();
 }
Пример #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));
 }
Пример #24
0
 @Test
 public void shouldRetainInstanceState() throws Exception {
   assertThat(fragment.getRetainInstance()).isTrue();
 }
Пример #25
0
 @Test
 public void onAttach_shouldResetReferenceToActivity() throws Exception {
   BaseActivity newActivity = initBaseActivity();
   fragment.onAttach(newActivity);
   assertThat(fragment.getBaseActivity()).isEqualTo(newActivity);
 }
Пример #26
0
 @Test
 public void onViewCreated_shouldHideActionBar() throws Exception {
   activity.getSupportActionBar().show();
   fragment.onViewCreated(fragment.getView(), null);
   assertThat(activity.getSupportActionBar().isShowing()).isFalse();
 }
Пример #27
0
 @Test(expected = IllegalArgumentException.class)
 public void onDestroy_shouldUnregisterWithEventBus() throws Exception {
   fragment.onDestroy();
   bus.unregister(fragment);
 }
Пример #28
0
 @Test
 public void newInstance_shouldReturnInstanceOfRoutePreviewFragment() throws Exception {
   assertThat(RoutePreviewFragment.newInstance(activity, destination))
       .isInstanceOf(RoutePreviewFragment.class);
 }
Пример #29
0
 @Test
 public void setRouteTo_shouldClearMap() throws Exception {
   fragment.getMapFragment().addPoi(getTestSimpleFeature());
   fragment.createRouteToDestination();
   assertThat(fragment.getMapFragment().getPoiLayer().size()).isEqualTo(0);
 }
Пример #30
0
 @Test
 public void onViewUpdate_shouldCreateRoute() throws Exception {
   fragment.onViewUpdate(new ViewUpdateEvent());
   verify(router, times(2)).fetch();
 }