Persistence { public long whenDataUpdated() { return preferences.getLong("data_updated_at", 0); } Persistence(); @Nullable DataMap getDataMap(String key); void putDataMap(String key, DataMap dataMap); String getString(String key, String defaultValue); void putString(String key, String value); boolean getBoolean(String key, boolean defaultValue); void putBoolean(String key, boolean value); long whenDataUpdated(); Set<String> getSetOf(String key); void addToSet(String key, String value); void removeFromSet(String key, String value); static void storeDataMap(String key, DataMap dataMap); static Set<String> setOf(String key); static final String COMPLICATION_PROVIDER_PREFERENCES_FILE_KEY; }
@Test public void whenDataUpdatedTest() { Persistence persistence = new Persistence(); DataMap map = new DataMap(); final long whenNotUpdated = persistence.whenDataUpdated(); Persistence.storeDataMap("data-map", map); final long whenUpdatedFirst = persistence.whenDataUpdated(); WearUtilMocker.progressClock(60000); Persistence.storeDataMap("data-map", map); final long whenUpdatedNext = persistence.whenDataUpdated(); assertThat(whenNotUpdated, is(0L)); assertThat(whenUpdatedFirst, is(REF_NOW)); assertThat(whenUpdatedNext, is(REF_NOW + 60000)); }