| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.sync; | 5 package org.chromium.chrome.browser.sync; |
| 6 | 6 |
| 7 import android.accounts.Account; | 7 import android.accounts.Account; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 | 9 |
| 10 import org.chromium.base.ThreadUtils; | 10 import org.chromium.base.ThreadUtils; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 @Override | 86 @Override |
| 87 protected void setUp() throws Exception { | 87 protected void setUp() throws Exception { |
| 88 // This must be called before doing anything with the SharedPreferences
because | 88 // This must be called before doing anything with the SharedPreferences
because |
| 89 // super.setUp() normally wipes them clean between runs. Setting a Shar
edPreference here | 89 // super.setUp() normally wipes them clean between runs. Setting a Shar
edPreference here |
| 90 // via the SigninTestUtil.setUpAuthForTest() call below causes Android t
o cache them before | 90 // via the SigninTestUtil.setUpAuthForTest() call below causes Android t
o cache them before |
| 91 // the files get cleared, meaning that a data clear is useless and test
runs influence each | 91 // the files get cleared, meaning that a data clear is useless and test
runs influence each |
| 92 // other. | 92 // other. |
| 93 ApplicationTestUtils.clearAppData(getInstrumentation().getTargetContext(
)); | 93 ApplicationTestUtils.clearAppData(getInstrumentation().getTargetContext(
)); |
| 94 | 94 |
| 95 // This must be called before super.setUp() in order for test authentica
tion to work. | 95 // This must be called before super.setUp() in order for test authentica
tion to work. |
| 96 SigninTestUtil.setUpAuthForTest(getInstrumentation()); | 96 SigninTestUtil.setUpAuthForTest(); |
| 97 | 97 |
| 98 super.setUp(); | 98 super.setUp(); |
| 99 mContext = getInstrumentation().getTargetContext(); | 99 mContext = getInstrumentation().getTargetContext(); |
| 100 | 100 |
| 101 setUpMockAndroidSyncSettings(); | 101 setUpMockAndroidSyncSettings(); |
| 102 | 102 |
| 103 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 103 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 104 @Override | 104 @Override |
| 105 public void run() { | 105 public void run() { |
| 106 // Ensure SyncController is registered with the new AndroidSyncS
ettings. | 106 // Ensure SyncController is registered with the new AndroidSyncS
ettings. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 129 @Override | 129 @Override |
| 130 protected void tearDown() throws Exception { | 130 protected void tearDown() throws Exception { |
| 131 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 131 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 132 @Override | 132 @Override |
| 133 public void run() { | 133 public void run() { |
| 134 mProfileSyncService.requestStop(); | 134 mProfileSyncService.requestStop(); |
| 135 FakeServerHelper.deleteFakeServer(); | 135 FakeServerHelper.deleteFakeServer(); |
| 136 } | 136 } |
| 137 }); | 137 }); |
| 138 SigninTestUtil.resetSigninState(); | 138 SigninTestUtil.resetSigninState(); |
| 139 SigninTestUtil.tearDownAuthForTest(); | |
| 140 | 139 |
| 141 super.tearDown(); | 140 super.tearDown(); |
| 142 } | 141 } |
| 143 | 142 |
| 144 private void setUpMockAndroidSyncSettings() { | 143 private void setUpMockAndroidSyncSettings() { |
| 145 mSyncContentResolver = new MockSyncContentResolverDelegate(); | 144 mSyncContentResolver = new MockSyncContentResolverDelegate(); |
| 146 mSyncContentResolver.setMasterSyncAutomatically(true); | 145 mSyncContentResolver.setMasterSyncAutomatically(true); |
| 147 AndroidSyncSettings.overrideForTests(mContext, mSyncContentResolver); | 146 AndroidSyncSettings.overrideForTests(mContext, mSyncContentResolver); |
| 148 } | 147 } |
| 149 | 148 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 mProfileSyncService.setPreferredDataTypes(false, preferredTypes)
; | 233 mProfileSyncService.setPreferredDataTypes(false, preferredTypes)
; |
| 235 } | 234 } |
| 236 }); | 235 }); |
| 237 } | 236 } |
| 238 | 237 |
| 239 protected void pollInstrumentationThread(Criteria criteria) { | 238 protected void pollInstrumentationThread(Criteria criteria) { |
| 240 CriteriaHelper.pollInstrumentationThread( | 239 CriteriaHelper.pollInstrumentationThread( |
| 241 criteria, SyncTestUtil.TIMEOUT_MS, SyncTestUtil.INTERVAL_MS); | 240 criteria, SyncTestUtil.TIMEOUT_MS, SyncTestUtil.INTERVAL_MS); |
| 242 } | 241 } |
| 243 } | 242 } |
| OLD | NEW |