예제 #1
0
 @Override
 public void act(Geocache cache) {
   final Intent intent = new Intent(mActivity, GeoMapActivity.class);
   intent.putExtra("latitude", (float) cache.getLatitude());
   intent.putExtra("longitude", (float) cache.getLongitude());
   intent.putExtra("geocacheId", cache.getId());
   mActivity.startActivity(intent);
 }
예제 #2
0
  @SuppressWarnings("unchecked")
  @Test
  public void testSave() {
    CacheSqlWriter writer = createMock(CacheSqlWriter.class);
    Geocache geocache = createMock(Geocache.class);
    Provider<CacheSqlWriter> cacheWriterProvider = createMock(Provider.class);
    TagReader tagReader = createMock(TagReader.class);
    expect(tagReader.hasTag("LB12345", Tag.FOUND)).andReturn(true);
    expect(cacheWriterProvider.get()).andReturn(writer);
    mockStatic(DatabaseDI.class);

    writer.startWriting();
    expect(geocache.getId()).andReturn("LB12345");
    expect(geocache.getName()).andReturn("");
    expect(geocache.getLatitude()).andReturn(122.0);
    expect(geocache.getLongitude()).andReturn(37.0);
    expect(geocache.getSourceType()).andReturn(Source.GPX);
    expect(geocache.getSourceName()).andReturn("manhattan");
    expect(geocache.getCacheType()).andReturn(CacheType.TRADITIONAL);
    expect(geocache.getDifficulty()).andReturn(3);
    expect(geocache.getTerrain()).andReturn(1);
    expect(geocache.getContainer()).andReturn(2);
    expect(geocache.getAvailable()).andReturn(true);
    expect(geocache.getArchived()).andReturn(false);
    writer.insertAndUpdateCache(
        "LB12345",
        "",
        122,
        37,
        Source.GPX,
        "manhattan",
        CacheType.TRADITIONAL,
        3,
        1,
        2,
        true,
        false,
        true);
    writer.stopWriting();

    replayAll();
    new LocationSaver(cacheWriterProvider, tagReader).saveLocation(geocache);
    verifyAll();
  }
예제 #3
0
  @Test
  public void testActionDelete() {
    CacheWriter cacheWriter = PowerMock.createMock(CacheWriter.class);
    CacheListAdapter cacheList = PowerMock.createMock(CacheListAdapter.class);
    Geocache geocache = PowerMock.createMock(Geocache.class);
    TitleUpdater titleUpdater = PowerMock.createMock(TitleUpdater.class);
    DbFrontend dbFrontend = PowerMock.createMock(DbFrontend.class);
    CachesProviderDb cachesProviderDb = PowerMock.createMock(CachesProviderDb.class);

    expect(dbFrontend.getCacheWriter()).andReturn(cacheWriter);
    expect(geocache.getId()).andReturn("GC123");
    cacheWriter.deleteCache("GC123");
    cacheList.forceRefresh();
    titleUpdater.refresh();
    cachesProviderDb.notifyOfDbChange();

    PowerMock.replayAll();
    new CacheActionDelete(cacheList, titleUpdater, dbFrontend, cachesProviderDb, null)
        .act(geocache);
    PowerMock.verifyAll();
  }