Code example for Account

0
        assertEquals(false, engine.getSyncAutomatically(account2, 0, authorityCalendarNew));
    } 
 
    @SmallTest 
    public void testSyncableMigration() throws Exception { 
        final Account account = new Account("acc", "type");
 
        MockContentResolver mockResolver = new MockContentResolver();
 
        final TestContext testContext = new TestContext(mockResolver, getContext());
 
        byte[] accountsFileData = ("<?xml version='1.0' encoding='utf-8' standalone='yes' ?>\n"
                + "<accounts>\n" 
                + "<authority id=\"0\" account=\"acc\" authority=\"other1\" />\n" 
                + "<authority id=\"1\" account=\"acc\" type=\"type\" authority=\"other2\" />\n" 
                + "<authority id=\"2\" account=\"acc\" type=\"type\" syncable=\"false\"" 
                + " authority=\"other3\" />\n" 
                + "<authority id=\"3\" account=\"acc\" type=\"type\" syncable=\"true\"" 
                + " authority=\"other4\" />\n" 
                + "</accounts>\n").getBytes();
 
        File syncDir = new File(new File(testContext.getFilesDir(), "system"), "sync");
        syncDir.mkdirs();
        AtomicFile accountInfoFile = new AtomicFile(new File(syncDir, "accounts.xml"));
        FileOutputStream fos = accountInfoFile.startWrite();
        fos.write(accountsFileData);
        accountInfoFile.finishWrite(fos);
 
        SyncStorageEngine engine = SyncStorageEngine.newTestInstance(testContext);
 
        assertEquals(-1, engine.getIsSyncable(account, 0, "other1"));
        assertEquals(1, engine.getIsSyncable(account, 0, "other2"));
        assertEquals(0, engine.getIsSyncable(account, 0, "other3"));
        assertEquals(1, engine.getIsSyncable(account, 0, "other4"));
    } 
} 
 
class TestContext extends ContextWrapper {