diff options
author | maxbogue <maxbogue@chromium.org> | 2015-05-13 15:43:43 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-13 22:44:55 +0000 |
commit | a465d93b75f40e550a6362c5639d78c6c14b9642 (patch) | |
tree | ce0f507ce3be0718a0b555ff10f26f0145276886 /sync | |
parent | 71b7554b14c1ef97e8d4c487ab357b5dcef891dc (diff) | |
download | chromium_src-a465d93b75f40e550a6362c5639d78c6c14b9642.zip chromium_src-a465d93b75f40e550a6362c5639d78c6c14b9642.tar.gz chromium_src-a465d93b75f40e550a6362c5639d78c6c14b9642.tar.bz2 |
[Sync] Test SCF control states and a regression
Four new tests for SyncCustomizationFragment:
- SCF state is correct starting from sync on and transitioning to off.
- SCF state is correct starting from sync off and transitioning to on.
- SCF's data type controls respond correctly to the sync everything switch.
- SCF opening and closing does not start sync.
In order to prevent flakiness, this CL makes some additional changes.
- Remove MockAccountManager.postAsyncAccountChangedEvent().
Justification: we have no control about when Android performs
the callback from it. The callback coming in at weird points
during other test cases was making tests flaky. Testing mechanisms
should be predictable.
- SCF now caches the backend initialized state in order to filter
syncStateChanged() calls down to only changes to that state.
BUG=480604
Review URL: https://codereview.chromium.org/1118833002
Cr-Commit-Position: refs/heads/master@{#329740}
Diffstat (limited to 'sync')
-rw-r--r-- | sync/test/android/javatests/src/org/chromium/sync/test/util/MockAccountManager.java | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/sync/test/android/javatests/src/org/chromium/sync/test/util/MockAccountManager.java b/sync/test/android/javatests/src/org/chromium/sync/test/util/MockAccountManager.java index 2299beb..59ed22e 100644 --- a/sync/test/android/javatests/src/org/chromium/sync/test/util/MockAccountManager.java +++ b/sync/test/android/javatests/src/org/chromium/sync/test/util/MockAccountManager.java @@ -143,18 +143,46 @@ public class MockAccountManager implements AccountManagerDelegate { public boolean addAccountExplicitly(Account account, String password, Bundle userdata) { AccountHolder accountHolder = AccountHolder.create().account(account).password(password).build(); - return addAccountHolderExplicitly(accountHolder); + return addAccountHolderExplicitly(accountHolder, false); } public boolean addAccountHolderExplicitly(AccountHolder accountHolder) { + return addAccountHolderExplicitly(accountHolder, false); + } + + /** + * Add an AccountHolder directly. + * + * @param accountHolder the account holder to add + * @param broadcastEvent whether to broadcast an AccountChangedEvent + * @return whether the account holder was added successfully + */ + public boolean addAccountHolderExplicitly(AccountHolder accountHolder, + boolean broadcastEvent) { boolean result = mAccounts.add(accountHolder); - postAsyncAccountChangedEvent(); + if (broadcastEvent) { + postAsyncAccountChangedEvent(); + } return result; } public boolean removeAccountHolderExplicitly(AccountHolder accountHolder) { + return removeAccountHolderExplicitly(accountHolder, false); + } + + /** + * Remove an AccountHolder directly. + * + * @param accountHolder the account holder to remove + * @param broadcastEvent whether to broadcast an AccountChangedEvent + * @return whether the account holder was removed successfully + */ + public boolean removeAccountHolderExplicitly(AccountHolder accountHolder, + boolean broadcastEvent) { boolean result = mAccounts.remove(accountHolder); - postAsyncAccountChangedEvent(); + if (broadcastEvent) { + postAsyncAccountChangedEvent(); + } return result; } |