use of net.grandcentrix.tray.mock.TestTrayModulePreferences in project tray by grandcentrix.
the class TrayTest method testGetAll.
public void testGetAll() throws Exception {
final TestTrayModulePreferences module2 = new TestTrayModulePreferences(getProviderMockContext(), "module2");
mTrayModulePref.put("test", "test");
module2.put("test", "test");
mTrayModulePref.put("test2", "test");
module2.put("test2", "test");
assertUserDatabaseSize(4);
final Collection<TrayItem> all = mTray.getAll();
assertEquals(4, all.size());
}
use of net.grandcentrix.tray.mock.TestTrayModulePreferences in project tray by grandcentrix.
the class TrayTest method testClearAllFails.
public void testClearAllFails() throws Exception {
final MockContentProvider mockContentProvider = new MockContentProvider(getProviderMockContext()) {
@Override
public int delete(final Uri uri, final String selection, final String[] selectionArgs) {
throw new IllegalStateException("something serious is wrong");
}
};
getProviderMockContext().addProvider(MockProvider.AUTHORITY, mockContentProvider);
getProviderMockContext().enableMockResolver(true);
final Tray tray = new Tray(getProviderMockContext());
final TestTrayModulePreferences module2 = new TestTrayModulePreferences(getProviderMockContext(), "module2");
module2.put("blubb", "hello");
mTrayModulePref.put("test", "test");
assertUserDatabaseSize(2);
assertFalse(tray.clear());
assertUserDatabaseSize(2);
}
use of net.grandcentrix.tray.mock.TestTrayModulePreferences in project tray by grandcentrix.
the class TrayTest method testClearModules.
public void testClearModules() throws Exception {
final TestTrayModulePreferences module1 = new TestTrayModulePreferences(getProviderMockContext(), "module1");
final TestTrayModulePreferences module2 = new TestTrayModulePreferences(getProviderMockContext(), "module2");
module1.put("test", "test");
module2.put("test", "test");
module1.put("test2", "test");
module2.put("test2", "test");
assertUserDatabaseSize(4);
Tray.clear(new TestTrayModulePreferences(getProviderMockContext(), "module1"));
assertUserDatabaseSize(2);
Tray.clear(new TestTrayModulePreferences(getProviderMockContext(), "module2"));
assertUserDatabaseSize(0);
module1.put("test", "test");
module2.put("test", "test");
Tray.clear((TrayPreferences) null);
assertUserDatabaseSize(2);
}
Aggregations