use of net.grandcentrix.tray.core.TrayItem in project tray by grandcentrix.
the class SaveNull method testSaveNullAsString.
public void testSaveNullAsString() throws Exception {
assertEquals("default", mPref.getString(KEY, "default"));
mPref.put(KEY, null);
final TrayItem pref = mPref.getPref(KEY);
assertNotNull(pref);
assertEquals(null, pref.value());
assertEquals(null, mPref.getString(KEY));
}
use of net.grandcentrix.tray.core.TrayItem in project tray by grandcentrix.
the class ChangedListenerTest method testApiLevel15OnChange.
public void testApiLevel15OnChange() throws Exception {
final CountDownLatch latch = new CountDownLatch(// first time called in checkChangeListener() second time in this test
2);
final ArrayList<TrayItem> changed = new ArrayList<>();
final OnTrayPreferenceChangeListener listener = new OnTrayPreferenceChangeListener() {
@Override
public void onTrayPreferenceChanged(final Collection<TrayItem> items) {
changed.addAll(items);
latch.countDown();
}
};
final ContentProviderStorage storage = checkChangeListener(true, listener);
storage.put("some", "value");
storage.put("foo", "bar");
new HandlerThread("change") {
@Override
protected void onLooperPrepared() {
super.onLooperPrepared();
storage.mObserver.onChange(false);
}
}.start();
latch.await(3000, TimeUnit.MILLISECONDS);
assertEquals(2, changed.size());
}
use of net.grandcentrix.tray.core.TrayItem in project tray by grandcentrix.
the class ContentProviderStorageTest method checkReadDataWithUndefined.
private void checkReadDataWithUndefined(final ContentProviderStorage original) throws Exception {
final ContentProviderStorage undefined = new ContentProviderStorage(getProviderMockContext(), original.getModuleName(), TrayStorage.Type.UNDEFINED);
assertEquals(TrayStorage.Type.UNDEFINED, undefined.getType());
assertEquals(original.getAll().size(), undefined.getAll().size());
final TrayItem item = undefined.get(TEST_KEY);
assertNotNull(item);
assertEquals(original.get(TEST_KEY).value(), item.value());
assertEquals(original.getVersion(), undefined.getVersion());
assertEquals(original.getModuleName(), undefined.getModuleName());
}
use of net.grandcentrix.tray.core.TrayItem in project tray by grandcentrix.
the class ContentProviderStorageTest method testGetUser.
public void testGetUser() throws Exception {
final ContentProviderStorage storage = new ContentProviderStorage(getProviderMockContext(), "testGet_User", TrayStorage.Type.USER);
assertNull(storage.get("test"));
assertTrue(storage.put("test", "foo"));
final TrayItem item = storage.get("test");
assertNotNull(item);
assertEquals("test", item.key());
assertEquals("foo", item.value());
}
use of net.grandcentrix.tray.core.TrayItem in project tray by grandcentrix.
the class ContentProviderStorageTest method testGetDevice.
public void testGetDevice() throws Exception {
final ContentProviderStorage storage = new ContentProviderStorage(getProviderMockContext(), "testGet_Device", TrayStorage.Type.DEVICE);
assertNull(storage.get("test"));
assertTrue(storage.put("test", "foo"));
final TrayItem item = storage.get("test");
assertNotNull(item);
assertEquals("test", item.key());
assertEquals("foo", item.value());
}
Aggregations