Ejemplo n.º 1
0
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    clearAppData();

    // Mock out the account manager on the device.
    mContext = new SyncTestUtil.SyncTestContext(getInstrumentation().getTargetContext());
    mAccountManager = new MockAccountManager(mContext, getInstrumentation().getContext());
    AccountManagerHelper.overrideAccountManagerHelperForTests(mContext, mAccountManager);
    MockSyncContentResolverDelegate syncContentResolverDelegate =
        new MockSyncContentResolverDelegate();
    syncContentResolverDelegate.setMasterSyncAutomatically(true);
    SyncStatusHelper.overrideSyncStatusHelperForTests(mContext, syncContentResolverDelegate);
    // This call initializes the ChromeSigninController to use our test context.
    ChromeSigninController.get(mContext);
    startChromeBrowserProcessSync(getInstrumentation().getTargetContext());
    ThreadUtils.runOnUiThreadBlocking(
        new Runnable() {
          @Override
          public void run() {
            mSyncController = SyncController.get(mContext);
          }
        });
    SyncTestUtil.verifySyncServerIsRunning();
  }
 private void setupSync(boolean syncEnabled) {
   MockSyncContentResolverDelegate contentResolver = new MockSyncContentResolverDelegate();
   // Android master sync can safely always be on.
   contentResolver.setMasterSyncAutomatically(true);
   // We don't want to use the system content resolver, so we override it.
   SyncStatusHelper.overrideSyncStatusHelperForTests(mContext, contentResolver);
   Account account = AccountManagerHelper.createAccountFromName("*****@*****.**");
   SyncStatusHelper syncStatusHelper = SyncStatusHelper.get(mContext);
   syncStatusHelper.setSignedInAccountName(account.name);
   if (syncEnabled) {
     syncStatusHelper.enableAndroidSync(account);
   } else {
     syncStatusHelper.disableAndroidSync(account);
   }
 }
Ejemplo n.º 3
0
 @Override
 public void setSyncAutomatically(Account account, String authority, boolean sync) {
   mSetSyncAutomaticallyCalls++;
   super.setSyncAutomatically(account, authority, sync);
 }
Ejemplo n.º 4
0
 @Override
 public void removePeriodicSync(Account account, String authority, Bundle extras) {
   mRemovePeriodicSyncCalls++;
   super.removePeriodicSync(account, authority, extras);
 }
Ejemplo n.º 5
0
 @Override
 public void setIsSyncable(Account account, String authority, int syncable) {
   mSetIsSyncableCalls++;
   super.setIsSyncable(account, authority, syncable);
 }