Example #1
0
  @Test
  public void createNull() throws Exception {
    SharedPreferences sharedPreferences = PowerMock.createMock(SharedPreferences.class);
    Activity parent = PowerMock.createMock(Activity.class);

    EasyMock.expect(
            sharedPreferences.getString(ActivitySaver.LAST_ACTIVITY, ActivityType.NONE.name()))
        .andReturn(ActivityType.NONE.name());

    PowerMock.replayAll();
    new ActivityRestorer(parent, null, sharedPreferences)
        .restore(Intent.FLAG_ACTIVITY_NEW_TASK, ActivityType.CACHE_LIST);
    PowerMock.verifyAll();
  }
Example #2
0
  @Test
  public void createCacheListIntent() throws Exception {
    SharedPreferences sharedPreferences = PowerMock.createMock(SharedPreferences.class);
    Activity parent = PowerMock.createMock(Activity.class);
    Intent intent = PowerMock.createMock(Intent.class);

    String cacheList = ActivityType.CACHE_LIST.name();
    EasyMock.expect(
            sharedPreferences.getString(ActivitySaver.LAST_ACTIVITY, ActivityType.NONE.name()))
        .andReturn(cacheList);
    PowerMock.expectNew(Intent.class, parent, CacheListActivity.class).andReturn(intent);
    parent.startActivity(intent);
    parent.finish();

    PowerMock.replayAll();
    new ActivityRestorer(parent, null, sharedPreferences)
        .restore(Intent.FLAG_ACTIVITY_NEW_TASK, ActivityType.NONE);
    PowerMock.verifyAll();
  }
Example #3
0
  @Test
  public void createViewCache() throws Exception {
    SharedPreferences sharedPreferences = PowerMock.createMock(SharedPreferences.class);
    Activity parent = PowerMock.createMock(Activity.class);
    GeocacheFromPreferencesFactory geocacheFromPreferencesFactory =
        PowerMock.createMock(GeocacheFromPreferencesFactory.class);
    Geocache geocache = PowerMock.createMock(Geocache.class);
    Intent intent = PowerMock.createMock(Intent.class);

    String viewCache = ActivityType.VIEW_CACHE.name();
    EasyMock.expect(
            sharedPreferences.getString(ActivitySaver.LAST_ACTIVITY, ActivityType.NONE.name()))
        .andReturn(viewCache);
    EasyMock.expect(geocacheFromPreferencesFactory.create(sharedPreferences)).andReturn(geocache);
    PowerMock.expectNew(Intent.class, parent, GeoBeagle.class).andReturn(intent);
    EasyMock.expect(intent.putExtra("geocache", geocache)).andReturn(intent);
    EasyMock.expect(intent.setAction(GeocacheListController.SELECT_CACHE)).andReturn(intent);
    parent.startActivity(intent);

    PowerMock.replayAll();
    new ActivityRestorer(parent, geocacheFromPreferencesFactory, sharedPreferences)
        .restore(Intent.FLAG_ACTIVITY_NEW_TASK, ActivityType.NONE);
    PowerMock.verifyAll();
  }