Search in sources :

Example 11 with TestTrayModulePreferences

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());
}
Also used : TrayItem(net.grandcentrix.tray.core.TrayItem) TestTrayModulePreferences(net.grandcentrix.tray.mock.TestTrayModulePreferences)

Example 12 with TestTrayModulePreferences

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);
}
Also used : TestTrayModulePreferences(net.grandcentrix.tray.mock.TestTrayModulePreferences) MockContentProvider(android.test.mock.MockContentProvider) Uri(android.net.Uri)

Example 13 with TestTrayModulePreferences

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);
}
Also used : TestTrayModulePreferences(net.grandcentrix.tray.mock.TestTrayModulePreferences)

Aggregations

TestTrayModulePreferences (net.grandcentrix.tray.mock.TestTrayModulePreferences)13 Uri (android.net.Uri)1 IsolatedContext (android.test.IsolatedContext)1 MockContentProvider (android.test.mock.MockContentProvider)1 AppPreferences (net.grandcentrix.tray.AppPreferences)1 TrayItem (net.grandcentrix.tray.core.TrayItem)1