Example #1
0
 @Test
 public void shouldShowLocationMarker() throws Exception {
   mapFragment.getMap().layers().remove(mapFragment.getLocationMarkerLayer());
   mapFragment.showLocationMarker();
   assertThat(mapFragment.getMap().layers().contains(mapFragment.getLocationMarkerLayer()))
       .isTrue();
 }
Example #2
0
 @Test
 public void hideProgress_shouldHideProgressView() throws Exception {
   FragmentTestUtil.startFragment(mapFragment);
   mapFragment.showProgress();
   mapFragment.hideProgress();
   assertThat(mapFragment.getView().findViewById(R.id.progress)).isNotVisible();
 }
Example #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();
 }
Example #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);
 }
Example #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();
 }
Example #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();
 }
Example #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);
 }
Example #8
0
 @Test
 public void shouldPointToDefaultTileService() throws Exception {
   assertThat(mapFragment.getTileBaseSource())
       .isEqualTo(
           mapFragment
               .getActivity()
               .getResources()
               .getString(R.string.settings_default_mapsource));
 }
Example #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);
 }
Example #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();
 }
Example #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");
 }
Example #12
0
 @Before
 public void setUp() throws Exception {
   ((TestMapzenApplication) Robolectric.application).inject(this);
   activity = initBaseActivity();
   listener = new TestPoiClickListener();
   mapFragment = activity.getMapFragment();
   mapFragment.setOnPoiClickListener(listener);
 }
Example #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);
  }
Example #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);
  }
Example #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");
  }
Example #16
0
 @Test
 public void shouldHideLocationMarker() throws Exception {
   mapFragment.hideLocationMarker();
   assertThat(mapFragment.getMap().layers().contains(mapFragment.getLocationMarkerLayer()))
       .isFalse();
 }
Example #17
0
 @Test
 public void shouldHaveMeMarkerLayer() throws Exception {
   assertThat(mapFragment.getLocationMarkerLayer()).isNotNull();
 }
Example #18
0
 @Test
 public void shouldHavePoiLayer() throws Exception {
   assertThat(mapFragment.getPoiLayer()).isNotNull();
 }
Example #19
0
 @Test
 public void showLocationMarker_shouldNotCrashIfLayersIsNull() throws Exception {
   mapFragment.setAct(new BaseActivityWithNullLayers());
   mapFragment.showLocationMarker();
 }
Example #20
0
 @Test
 public void onActivityCreated_shouldVerifyTileCacheDirectoryIsAvailable() throws Exception {
   BaseActivityWithNullCache baseActivityWithNullCache = new BaseActivityWithNullCache();
   mapFragment.setAct(baseActivityWithNullCache);
   mapFragment.onActivityCreated(null);
 }
Example #21
0
 @Test(expected = IllegalArgumentException.class)
 public void onPause_shouldUnregisterLocationUpdatesSubscriber() {
   mapFragment.onPause();
   bus.unregister(mapFragment);
 }
Example #22
0
 @Test
 public void shouldPointToConfiguredTileService() throws Exception {
   String expected = "http://test.com";
   setTileSourceConfiguration(expected);
   assertThat(mapFragment.getTileBaseSource()).isEqualTo(expected);
 }
Example #23
0
 @Test
 public void shouldSetupLocationMarker() throws Exception {
   assertThat(mapFragment.getMap().layers().contains(mapFragment.getLocationMarkerLayer()))
       .isTrue();
 }