コード例 #1
0
  @Test
  public void testCreateNullLocation() {
    LocationControlBuffered locationControlBuffered =
        PowerMock.createMock(LocationControlBuffered.class);

    EasyMock.expect(locationControlBuffered.getLocation()).andReturn(null);

    PowerMock.replayAll();
    assertEquals(null, new GeocacheFromMyLocationFactory(null, locationControlBuffered).create());
    PowerMock.verifyAll();
  }
コード例 #2
0
  @SuppressWarnings("unchecked")
  @Test
  public void testRefresh() {
    LocationControlBuffered locationControlBuffered =
        PowerMock.createMock(LocationControlBuffered.class);
    Location location = PowerMock.createMock(Location.class);
    Provider<DbFrontend> dbFrontendProvider = PowerMock.createMock(Provider.class);
    DbFrontend dbFrontend = PowerMock.createMock(DbFrontend.class);
    WhereFactory whereFactory = PowerMock.createMock(WhereFactory.class);
    CacheListData cacheListData = PowerMock.createMock(CacheListData.class);
    TitleUpdater titleUpdater = PowerMock.createMock(TitleUpdater.class);
    FilterNearestCaches filterNearestCaches = PowerMock.createMock(FilterNearestCaches.class);
    ActivityVisible activityVisible = PowerMock.createMock(ActivityVisible.class);
    ArrayList<Geocache> geocaches = new ArrayList<Geocache>();

    EasyMock.expect(activityVisible.getVisible()).andReturn(true);
    EasyMock.expect(location.getLatitude()).andReturn(37.0);
    EasyMock.expect(location.getLongitude()).andReturn(-122.0);
    EasyMock.expect(filterNearestCaches.getWhereFactory()).andReturn(whereFactory);
    EasyMock.expect(locationControlBuffered.getLocation()).andReturn(location);
    EasyMock.expect(dbFrontendProvider.get()).andReturn(dbFrontend);
    EasyMock.expect(dbFrontend.loadCaches(37.0, -122.0, whereFactory)).andReturn(geocaches);
    EasyMock.expect(cacheListData.size()).andReturn(100);
    EasyMock.expect(dbFrontend.countAll()).andReturn(2300);
    cacheListData.add(geocaches, locationControlBuffered);
    titleUpdater.update(2300, 100);

    PowerMock.replayAll();
    new SqlCacheLoader(
            dbFrontendProvider,
            filterNearestCaches,
            cacheListData,
            locationControlBuffered,
            titleUpdater,
            mTiming,
            activityVisible)
        .refresh();
    PowerMock.verifyAll();
  }
コード例 #3
0
  @Test
  public void testCreate() {
    LocationControlBuffered locationControlBuffered =
        PowerMock.createMock(LocationControlBuffered.class);
    Location location = PowerMock.createMock(Location.class);
    GeocacheFactory geocacheFactory = PowerMock.createMock(GeocacheFactory.class);
    Geocache geocache = PowerMock.createMock(Geocache.class);
    Locale.setDefault(Locale.ENGLISH);
    TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));

    EasyMock.expect(locationControlBuffered.getLocation()).andReturn(location);
    EasyMock.expect(location.getTime()).andReturn(1000000L);
    EasyMock.expect(location.getLatitude()).andReturn(37.0);
    EasyMock.expect(location.getLongitude()).andReturn(-122.0);
    EasyMock.expect(
            geocacheFactory.create(
                "ML161640",
                "[16:16] My Location",
                37.0,
                -122.0,
                Source.MY_LOCATION,
                null,
                CacheType.MY_LOCATION,
                0,
                0,
                0,
                true,
                false))
        .andReturn(geocache);

    PowerMock.replayAll();
    assertEquals(
        geocache,
        new GeocacheFromMyLocationFactory(geocacheFactory, locationControlBuffered).create());
    PowerMock.verifyAll();
  }