Exemple #1
0
 @Test
 public void shouldShowLocationMarker() throws Exception {
   mapFragment.getMap().layers().remove(mapFragment.getLocationMarkerLayer());
   mapFragment.showLocationMarker();
   assertThat(mapFragment.getMap().layers().contains(mapFragment.getLocationMarkerLayer()))
       .isTrue();
 }
Exemple #2
0
 @Test
 public void hideProgress_shouldHideProgressView() throws Exception {
   FragmentTestUtil.startFragment(mapFragment);
   mapFragment.showProgress();
   mapFragment.hideProgress();
   assertThat(mapFragment.getView().findViewById(R.id.progress)).isNotVisible();
 }
Exemple #3
0
 @Test
 public void showProgress_shouldDisableMap() throws Exception {
   FragmentTestUtil.startFragment(mapFragment);
   mapFragment.getView().findViewById(R.id.map).setClickable(true);
   mapFragment.showProgress();
   assertThat(mapFragment.getView().findViewById(R.id.map)).isNotClickable();
 }
Exemple #4
0
 @Test
 public void onPause_shouldEmptyMeMarkers() throws Exception {
   ItemizedLayer<MarkerItem> meMarkerLayer = mapFragment.getLocationMarkerLayer();
   meMarkerLayer.addItem(new MarkerItem("Title", "Description", new GeoPoint(0, 0)));
   mapFragment.onPause();
   assertThat(meMarkerLayer.size()).isEqualTo(0);
 }
Exemple #5
0
 @Test
 public void hideProgress_shouldEnableMap() throws Exception {
   FragmentTestUtil.startFragment(mapFragment);
   mapFragment.getView().findViewById(R.id.map).setClickable(false);
   mapFragment.hideProgress();
   assertThat(mapFragment.getView().findViewById(R.id.map)).isClickable();
 }
Exemple #6
0
 @Test
 public void clearMarkers_shouldEmptyMapPois() throws Exception {
   mapFragment.addPoi(getTestSimpleFeature());
   mapFragment.addPoi(getTestSimpleFeature());
   ItemizedLayer<MarkerItem> poiMarkerLayer = mapFragment.getPoiLayer();
   mapFragment.clearMarkers();
   assertThat(poiMarkerLayer.size()).isZero();
 }
Exemple #7
0
 @Test
 public void onPause_shouldEmptyPoiMarkers() throws Exception {
   mapFragment.addPoi(getTestSimpleFeature());
   mapFragment.addPoi(getTestSimpleFeature());
   ItemizedLayer<MarkerItem> poiMarkerLayer = mapFragment.getPoiLayer();
   mapFragment.onPause();
   assertThat(poiMarkerLayer.size()).isEqualTo(0);
 }
Exemple #8
0
 @Test
 public void shouldPointToDefaultTileService() throws Exception {
   assertThat(mapFragment.getTileBaseSource())
       .isEqualTo(
           mapFragment
               .getActivity()
               .getResources()
               .getString(R.string.settings_default_mapsource));
 }
Exemple #9
0
 @Test
 public void findMe_shouldNotResetZoomAndPointNorthAfterMapPositionEvent() throws Exception {
   FragmentTestUtil.startFragment(mapFragment);
   mapFragment.findMe();
   MapPosition mapPosition = new MapPosition();
   mapPosition.setZoomLevel(10);
   activity.getMap().events.fire(Map.POSITION_EVENT, mapPosition);
   mapFragment.findMe();
   assertThat(mapFragment.mapController.getZoomLevel()).isEqualTo(10);
 }
Exemple #10
0
 @Test
 public void onPause_shouldUnregisterFindMeReceiver() {
   mapFragment.onPause();
   Intent expectedIntent = new Intent(COM_MAPZEN_FIND_ME);
   List<BroadcastReceiver> findMeReceivers =
       Robolectric.getShadowApplication().getReceiversForIntent(expectedIntent);
   assertThat(findMeReceivers).isEmpty();
 }
Exemple #11
0
 @Test
 public void onItemSingleTapUp_shouldNotifyListener() throws Exception {
   ItemizedLayer<MarkerItem> poiLayer = mapFragment.getPoiLayer();
   poiLayer.addItem(new MarkerItem("Title", "Description", new GeoPoint(0, 0)));
   poiLayer.onGesture(Gesture.TAP, new FakeMotionEvent(0, 0));
   assertThat(listener.getIndex()).isEqualTo(0);
   assertThat(listener.getItem().getTitle()).isEqualTo("Title");
 }
Exemple #12
0
 @Before
 public void setUp() throws Exception {
   ((TestMapzenApplication) Robolectric.application).inject(this);
   activity = initBaseActivity();
   listener = new TestPoiClickListener();
   mapFragment = activity.getMapFragment();
   mapFragment.setOnPoiClickListener(listener);
 }
Exemple #13
0
  @Test
  public void shouldUseOkHttp() throws Exception {
    Map map = mapFragment.getMap();
    TileLayer baseLayer = field("mBaseLayer").ofType(TileLayer.class).in(map).get();
    TileSource tileSource = field("mTileSource").ofType(TileSource.class).in(baseLayer).get();
    HttpEngine.Factory factory =
        field("mHttpFactory").ofType(HttpEngine.Factory.class).in(tileSource).get();

    assertThat(factory).isInstanceOf(OkHttpEngine.OkHttpFactory.class);
  }
Exemple #14
0
  @Test
  public void shouldUse10MegResponseCache() throws Exception {
    Map map = mapFragment.getMap();
    TileLayer baseLayer = field("mBaseLayer").ofType(TileLayer.class).in(map).get();
    UrlTileSource tileSource =
        (UrlTileSource) field("mTileSource").ofType(TileSource.class).in(baseLayer).get();
    HttpEngine.Factory engine =
        field("mHttpFactory").ofType(HttpEngine.Factory.class).in(tileSource).get();
    OkHttpClient client = field("mClient").ofType(OkHttpClient.class).in(engine).get();

    HttpResponseCache cache =
        (HttpResponseCache) field("responseCache").ofType(OkResponseCache.class).in(client).get();
    assertThat(cache.getMaxSize()).isEqualTo(MapFragment.CACHE_SIZE);
  }
Exemple #15
0
  @Test
  public void shouldUseResponseCacheStoredOnFile() throws Exception {
    Map map = mapFragment.getMap();
    TileLayer baseLayer = field("mBaseLayer").ofType(TileLayer.class).in(map).get();
    UrlTileSource tileSource =
        (UrlTileSource) field("mTileSource").ofType(TileSource.class).in(baseLayer).get();
    HttpEngine.Factory engine =
        field("mHttpFactory").ofType(HttpEngine.Factory.class).in(tileSource).get();
    OkHttpClient client = field("mClient").ofType(OkHttpClient.class).in(engine).get();

    HttpResponseCache cache =
        (HttpResponseCache) field("responseCache").ofType(OkResponseCache.class).in(client).get();
    assertThat(cache.getDirectory().getAbsolutePath())
        .isEqualTo(activity.getExternalCacheDir().getAbsolutePath() + "/tile-cache");
  }
Exemple #16
0
 @Test
 public void shouldHideLocationMarker() throws Exception {
   mapFragment.hideLocationMarker();
   assertThat(mapFragment.getMap().layers().contains(mapFragment.getLocationMarkerLayer()))
       .isFalse();
 }
Exemple #17
0
 @Test
 public void shouldHaveMeMarkerLayer() throws Exception {
   assertThat(mapFragment.getLocationMarkerLayer()).isNotNull();
 }
Exemple #18
0
 @Test
 public void shouldHavePoiLayer() throws Exception {
   assertThat(mapFragment.getPoiLayer()).isNotNull();
 }
Exemple #19
0
 @Test
 public void showLocationMarker_shouldNotCrashIfLayersIsNull() throws Exception {
   mapFragment.setAct(new BaseActivityWithNullLayers());
   mapFragment.showLocationMarker();
 }
Exemple #20
0
 @Test
 public void onActivityCreated_shouldVerifyTileCacheDirectoryIsAvailable() throws Exception {
   BaseActivityWithNullCache baseActivityWithNullCache = new BaseActivityWithNullCache();
   mapFragment.setAct(baseActivityWithNullCache);
   mapFragment.onActivityCreated(null);
 }
Exemple #21
0
 @Test(expected = IllegalArgumentException.class)
 public void onPause_shouldUnregisterLocationUpdatesSubscriber() {
   mapFragment.onPause();
   bus.unregister(mapFragment);
 }
Exemple #22
0
 @Test
 public void shouldPointToConfiguredTileService() throws Exception {
   String expected = "http://test.com";
   setTileSourceConfiguration(expected);
   assertThat(mapFragment.getTileBaseSource()).isEqualTo(expected);
 }
Exemple #23
0
 @Test
 public void shouldSetupLocationMarker() throws Exception {
   assertThat(mapFragment.getMap().layers().contains(mapFragment.getLocationMarkerLayer()))
       .isTrue();
 }