Chromium changes: https://chromium.googlesource.com/chromium/src/+/e61a284712dafc93e2edc3d1f408e0721093ee89 Adapt SyncTestRule to allow AndroidSyncSettings to depend on PSS Problem: AndroidSyncSettings (ASS) will soon depend on ProfileSyncService (PSS), particularly in its constructor. Although this is is fine in production code, SyncTestRule poses two issues for this setup on test code. - ASS is created before a fake PSS provided by tests can be injected. This is a problem because the initial state of PSS will be relevant to the constructor logic of ASS, so we need to be able to fake this initial state to write good tests. - ASS is created before the JNI loads in startMainActivityForSyncTest(). For tests that don't provide a fake PSS, ASS will then attempt to talk to the real PSS before JNI is loaded, causing an error. Solution: When SyncTestRule creates an ASS, the goal is actually just to fake one of its internal dependencies, SyncContentResolverDelegate. In this CL, we convert SyncContentResolverDelegate into a singleton. In this way, a fake for this object can be injected without needing to early construct ASS*. Furthermore, JNI is loaded earlier so that the rule can safely use tools like FakeServer and FakeProfileSyncService. * Note that constructing after startMainActivityForSyncTest() is not an option because there's already code talking to ASS when this function is running. Bug: 1125622
14 lines
812 B
Diff
14 lines
812 B
Diff
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/sync/AndroidSyncSettings.java b/chrome/android/java/src/org/chromium/chrome/browser/sync/AndroidSyncSettings.java
|
|
index 09c8dfc92481b272b536fdc05dfb7b11fbca616d..629b7c451cba0e9f7d0f5c25cf561b76221a68d9 100644
|
|
--- a/chrome/android/java/src/org/chromium/chrome/browser/sync/AndroidSyncSettings.java
|
|
+++ b/chrome/android/java/src/org/chromium/chrome/browser/sync/AndroidSyncSettings.java
|
|
@@ -74,7 +74,7 @@ public class AndroidSyncSettings {
|
|
public static AndroidSyncSettings get() {
|
|
ThreadUtils.assertOnUiThread();
|
|
if (sInstance == null) {
|
|
- sInstance = new AndroidSyncSettings(getSyncAccount());
|
|
+ sInstance = new BraveAndroidSyncSettings(getSyncAccount());
|
|
}
|
|
return sInstance;
|
|
}
|