Пример #1
0
 @Before
 public void setUp() throws Exception {
   ((TestMapzenApplication) Robolectric.application).inject(this);
   activity = initBaseActivity();
   listener = new TestPoiClickListener();
   mapFragment = activity.getMapFragment();
   mapFragment.setOnPoiClickListener(listener);
 }
Пример #2
0
 public static RouteFragment newInstance(BaseActivity act, SimpleFeature simpleFeature) {
   final RouteFragment fragment = new RouteFragment();
   fragment.setAct(act);
   fragment.setMapFragment(act.getMapFragment());
   fragment.setSimpleFeature(simpleFeature);
   fragment.groupId = UUID.randomUUID().toString();
   fragment.inject();
   fragment.setRetainInstance(true);
   return fragment;
 }
Пример #3
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);
 }
Пример #4
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");
  }
Пример #5
0
 private void setTileSourceConfiguration(String source) {
   SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
   SharedPreferences.Editor prefEditor = prefs.edit();
   prefEditor.putString(activity.getString(R.string.settings_key_mapsource), source);
   prefEditor.commit();
 }