зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1411654 - Part 2: Update Robolectric to 3.5.1. r=mcomella
There were a few API changes, mostly around explicitly creating Services/Activities/ContentProvider instances, but they were pretty easy to address. Sadly, Robolectric doesn't really work with the new aapt2 processing in Android-Gradle plugin 3.0+ -- see in particular https://github.com/robolectric/robolectric/issues/3333#issuecomment-324300418 -- so we have to opt-out of the new implementation for now. Hopefully plugin 3.1+ will address these issues, which are widespread. MozReview-Commit-ID: dlbd32kMs6 --HG-- extra : rebase_source : fe30729161e5dc91ea9173f9b7aaa9135d096791 extra : source : 690e265c684ce70ecb89355314fd1574bb421f0b
This commit is contained in:
Родитель
edf219ba3b
Коммит
ea45b76573
|
@ -1,3 +1,4 @@
|
|||
org.gradle.parallel=true
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xmx2560M
|
||||
android.enableAapt2=false
|
||||
|
|
|
@ -236,6 +236,9 @@ android {
|
|||
}
|
||||
|
||||
testOptions {
|
||||
// For Robolectric: see https://github.com/robolectric/robolectric/issues/3333#issuecomment-324300418.
|
||||
unitTests.includeAndroidResources true
|
||||
|
||||
unitTests.all {
|
||||
// We'd like to use (Runtime.runtime.availableProcessors()/2), but
|
||||
// we have tests that start test servers and the bound ports
|
||||
|
@ -289,7 +292,7 @@ dependencies {
|
|||
implementation project(path: ':thirdparty')
|
||||
|
||||
testImplementation 'junit:junit:4.12'
|
||||
testImplementation 'org.robolectric:robolectric:3.1.2'
|
||||
testImplementation 'org.robolectric:robolectric:3.5.1'
|
||||
testImplementation 'org.simpleframework:simple-http:6.0.1'
|
||||
testImplementation 'org.mockito:mockito-core:1.10.19'
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentProviderClient;
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
|
@ -15,7 +16,6 @@ import org.mozilla.gecko.background.testhelpers.TestRunner;
|
|||
import org.mozilla.gecko.db.BrowserContract;
|
||||
import org.mozilla.gecko.db.BrowserContract.PageMetadata;
|
||||
import org.mozilla.gecko.db.BrowserDB;
|
||||
import org.mozilla.gecko.db.BrowserProvider;
|
||||
import org.mozilla.gecko.db.LocalBrowserDB;
|
||||
import org.robolectric.shadows.ShadowContentResolver;
|
||||
|
||||
|
@ -27,11 +27,8 @@ public class GlobalPageMetadataTest {
|
|||
public void testQueueing() throws Exception {
|
||||
BrowserDB db = new LocalBrowserDB("default");
|
||||
|
||||
BrowserProvider provider = new BrowserProvider();
|
||||
final ContentProvider provider = DelegatingTestContentProvider.createDelegatingBrowserProvider();
|
||||
try {
|
||||
provider.onCreate();
|
||||
ShadowContentResolver.registerProvider(BrowserContract.AUTHORITY, new DelegatingTestContentProvider(provider));
|
||||
|
||||
ShadowContentResolver cr = new ShadowContentResolver();
|
||||
ContentProviderClient pageMetadataClient = cr.acquireContentProviderClient(PageMetadata.CONTENT_URI);
|
||||
|
||||
|
@ -64,11 +61,8 @@ public class GlobalPageMetadataTest {
|
|||
// Start listening for events.
|
||||
GlobalPageMetadata.getInstance().init();
|
||||
|
||||
BrowserProvider provider = new BrowserProvider();
|
||||
final ContentProvider provider = DelegatingTestContentProvider.createDelegatingBrowserProvider();
|
||||
try {
|
||||
provider.onCreate();
|
||||
ShadowContentResolver.registerProvider(BrowserContract.AUTHORITY, new DelegatingTestContentProvider(provider));
|
||||
|
||||
ShadowContentResolver cr = new ShadowContentResolver();
|
||||
ContentProviderClient historyClient = cr.acquireContentProviderClient(BrowserContract.History.CONTENT_URI);
|
||||
ContentProviderClient pageMetadataClient = cr.acquireContentProviderClient(PageMetadata.CONTENT_URI);
|
||||
|
@ -171,4 +165,4 @@ public class GlobalPageMetadataTest {
|
|||
cursor.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,29 +3,21 @@
|
|||
|
||||
package org.mozilla.gecko.icons.loader;
|
||||
|
||||
import android.content.ContentProvider;
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mozilla.gecko.GeckoProfile;
|
||||
import org.mozilla.gecko.background.db.DelegatingTestContentProvider;
|
||||
import org.mozilla.gecko.background.testhelpers.TestRunner;
|
||||
import org.mozilla.gecko.db.BrowserContract;
|
||||
import org.mozilla.gecko.db.BrowserDB;
|
||||
import org.mozilla.gecko.db.BrowserProvider;
|
||||
import org.mozilla.gecko.icons.IconDescriptor;
|
||||
import org.mozilla.gecko.icons.IconRequest;
|
||||
import org.mozilla.gecko.icons.IconResponse;
|
||||
import org.mozilla.gecko.icons.Icons;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.shadows.ShadowContentResolver;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
@ -46,9 +38,7 @@ public class TestLegacyLoader {
|
|||
// We need to ensure we close our db connection properly.
|
||||
// This is the only test in this class that actually accesses a database. If that changes,
|
||||
// move BrowserProvider registration into a @Before method, and provider.shutdown into @After.
|
||||
final BrowserProvider provider = new BrowserProvider();
|
||||
provider.onCreate();
|
||||
ShadowContentResolver.registerProvider(BrowserContract.AUTHORITY, new DelegatingTestContentProvider(provider));
|
||||
final ContentProvider provider = DelegatingTestContentProvider.createDelegatingBrowserProvider();
|
||||
try {
|
||||
final IconRequest request = Icons.with(RuntimeEnvironment.application)
|
||||
.pageUrl(TEST_PAGE_URL)
|
||||
|
@ -61,8 +51,8 @@ public class TestLegacyLoader {
|
|||
|
||||
verify(loader).loadBitmapFromDatabase(request);
|
||||
Assert.assertNull(response);
|
||||
// Close any open db connections.
|
||||
} finally {
|
||||
// Close any open db connections.
|
||||
provider.shutdown();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,13 +12,17 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mozilla.gecko.background.testhelpers.TestRunner;
|
||||
import org.mozilla.gecko.util.NetworkUtils.*;
|
||||
import org.mozilla.gecko.util.NetworkUtils.ConnectionSubType;
|
||||
import org.mozilla.gecko.util.NetworkUtils.ConnectionType;
|
||||
import org.mozilla.gecko.util.NetworkUtils.NetworkStatus;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.internal.ShadowExtractor;
|
||||
import org.robolectric.shadow.api.Shadow;
|
||||
import org.robolectric.shadows.ShadowConnectivityManager;
|
||||
import org.robolectric.shadows.ShadowNetworkInfo;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(TestRunner.class)
|
||||
public class NetworkUtilsTest {
|
||||
|
@ -31,7 +35,7 @@ public class NetworkUtilsTest {
|
|||
|
||||
// Not using Shadows.shadowOf(connectivityManager) because of Robolectric bug when using API23+
|
||||
// See: https://github.com/robolectric/robolectric/issues/1862
|
||||
shadowConnectivityManager = (ShadowConnectivityManager) ShadowExtractor.extract(connectivityManager);
|
||||
shadowConnectivityManager = (ShadowConnectivityManager) Shadow.extract(connectivityManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -182,4 +186,4 @@ public class NetworkUtilsTest {
|
|||
);
|
||||
assertEquals(NetworkStatus.UP, NetworkUtils.getNetworkStatus(connectivityManager));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
sdk=21
|
||||
sdk=23
|
||||
constants=org.mozilla.gecko.BuildConfig
|
||||
packageName=org.mozilla.gecko
|
||||
|
|
|
@ -8,13 +8,19 @@ import android.content.ContentProvider;
|
|||
import android.content.ContentProviderOperation;
|
||||
import android.content.ContentProviderResult;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.OperationApplicationException;
|
||||
import android.content.pm.ProviderInfo;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import org.mozilla.gecko.db.BrowserContract;
|
||||
import org.mozilla.gecko.db.BrowserProvider;
|
||||
import org.mozilla.gecko.db.TabsProvider;
|
||||
import org.robolectric.android.controller.ContentProviderController;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -22,17 +28,54 @@ import java.util.ArrayList;
|
|||
* Wrap a ContentProvider, appending &test=1 to all queries.
|
||||
*/
|
||||
public class DelegatingTestContentProvider extends ContentProvider {
|
||||
protected final ContentProvider mTargetProvider;
|
||||
protected ContentProvider mTargetProvider;
|
||||
|
||||
protected static Uri appendUriParam(Uri uri, String param, String value) {
|
||||
return uri.buildUpon().appendQueryParameter(param, value).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and register a new <tt>BrowserProvider</tt> that has test delegation.
|
||||
* <p>
|
||||
* Robolectric doesn't make it easy to parameterize a created
|
||||
* <tt>ContentProvider</tt>, so we modify a built-in helper to do it.
|
||||
* @return delegated <tt>ContentProvider</tt>.
|
||||
*/
|
||||
public static ContentProvider createDelegatingBrowserProvider() {
|
||||
final ContentProviderController<DelegatingTestContentProvider> contentProviderController
|
||||
= ContentProviderController.of(ReflectionHelpers.callConstructor(DelegatingTestContentProvider.class,
|
||||
ReflectionHelpers.ClassParameter.from(ContentProvider.class, new BrowserProvider())));
|
||||
return contentProviderController.create(BrowserContract.AUTHORITY).get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and register a new <tt>TabsProvider</tt> that has test delegation.
|
||||
* <p>
|
||||
* Robolectric doesn't make it easy to parameterize a created
|
||||
* <tt>ContentProvider</tt>, so we modify a built-in helper to do it.
|
||||
* @return delegated <tt>ContentProvider</tt>.
|
||||
*/
|
||||
public static ContentProvider createDelegatingTabsProvider() {
|
||||
final ContentProviderController<DelegatingTestContentProvider> contentProviderController
|
||||
= ContentProviderController.of(ReflectionHelpers.callConstructor(DelegatingTestContentProvider.class,
|
||||
ReflectionHelpers.ClassParameter.from(ContentProvider.class, new TabsProvider())));
|
||||
return contentProviderController.create(BrowserContract.TABS_AUTHORITY).get();
|
||||
}
|
||||
|
||||
public DelegatingTestContentProvider(ContentProvider targetProvider) {
|
||||
super();
|
||||
mTargetProvider = targetProvider;
|
||||
}
|
||||
|
||||
public void attachInfo(Context context, ProviderInfo info) {
|
||||
// With newer Robolectric versions, we must create the target provider
|
||||
// before calling into super. If we don't do this, the target
|
||||
// provider's onCreate() will witness a null getContext(), which the
|
||||
// Android documentation guarantees never happens on device.
|
||||
mTargetProvider.attachInfo(context, null);
|
||||
super.attachInfo(context, info);
|
||||
}
|
||||
|
||||
private Uri appendTestParam(Uri uri) {
|
||||
return appendUriParam(uri, BrowserContract.PARAM_IS_TEST, "1");
|
||||
}
|
||||
|
@ -88,6 +131,10 @@ public class DelegatingTestContentProvider extends ContentProvider {
|
|||
return mTargetProvider.call(method, arg, extras);
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
mTargetProvider.shutdown();
|
||||
}
|
||||
|
||||
public ContentProvider getTargetProvider() {
|
||||
return mTargetProvider;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
package org.mozilla.gecko.background.db;
|
||||
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentProviderClient;
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
|
@ -17,7 +18,6 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.mozilla.gecko.background.testhelpers.TestRunner;
|
||||
import org.mozilla.gecko.db.BrowserContract;
|
||||
import org.mozilla.gecko.db.TabsProvider;
|
||||
import org.mozilla.gecko.sync.repositories.android.BrowserContractHelpers;
|
||||
import org.mozilla.gecko.sync.repositories.android.FennecTabsRepository;
|
||||
import org.mozilla.gecko.sync.repositories.domain.TabsRecord;
|
||||
|
@ -35,13 +35,11 @@ public class TestTabsProvider {
|
|||
protected Tab testTab2;
|
||||
protected Tab testTab3;
|
||||
|
||||
protected TabsProvider provider;
|
||||
protected ContentProvider provider;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
provider = new TabsProvider();
|
||||
provider.onCreate();
|
||||
ShadowContentResolver.registerProvider(BrowserContract.TABS_AUTHORITY, new DelegatingTestContentProvider(provider));
|
||||
provider = DelegatingTestContentProvider.createDelegatingTabsProvider();
|
||||
}
|
||||
|
||||
@After
|
||||
|
|
|
@ -13,6 +13,8 @@ import org.mozilla.gecko.sync.net.BasicAuthHeaderProvider;
|
|||
import org.mozilla.gecko.sync.stage.CompletedStage;
|
||||
import org.mozilla.gecko.sync.stage.GlobalSyncStage;
|
||||
import org.mozilla.gecko.sync.stage.GlobalSyncStage.Stage;
|
||||
import org.robolectric.Robolectric;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
@ -26,7 +28,7 @@ public class MockGlobalSession extends MockPrefsGlobalSession {
|
|||
|
||||
public MockGlobalSession(SyncConfiguration config, GlobalSessionCallback callback)
|
||||
throws SyncConfigurationException, IllegalArgumentException, IOException, NonObjectJSONException {
|
||||
super(config, callback, null, null);
|
||||
super(config, callback, RuntimeEnvironment.application, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -53,9 +53,4 @@ public class MockPrefsGlobalSession extends GlobalSession {
|
|||
config.syncKeyBundle = syncKeyBundle;
|
||||
return new MockPrefsGlobalSession(config, callback, context, clientsDelegate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context getContext() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
package org.mozilla.gecko.db;
|
||||
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentProviderClient;
|
||||
import android.content.ContentUris;
|
||||
import android.content.ContentValues;
|
||||
|
@ -17,12 +18,11 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.mozilla.gecko.background.db.DelegatingTestContentProvider;
|
||||
import org.mozilla.gecko.background.testhelpers.TestRunner;
|
||||
import org.mozilla.gecko.db.BrowserContract.Bookmarks;
|
||||
import org.mozilla.gecko.sync.Utils;
|
||||
import org.mozilla.gecko.sync.repositories.android.BrowserContractHelpers;
|
||||
import org.robolectric.shadows.ShadowContentResolver;
|
||||
|
||||
import org.mozilla.gecko.db.BrowserContract.Bookmarks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -41,8 +41,9 @@ import static org.mozilla.gecko.db.BrowserProviderGeneralTest.INVALID_TIMESTAMP;
|
|||
import static org.mozilla.gecko.db.BrowserProviderGeneralTest.assertVersionsForSelection;
|
||||
import static org.mozilla.gecko.db.BrowserProviderGeneralTest.bookmarksTestSyncUri;
|
||||
import static org.mozilla.gecko.db.BrowserProviderGeneralTest.bookmarksTestUri;
|
||||
import static org.mozilla.gecko.db.BrowserProviderGeneralTest.getBookmarksTestSyncIncrementLocalVersionUri;
|
||||
import static org.mozilla.gecko.db.BrowserProviderGeneralTest.getBookmarkIdFromGuid;
|
||||
import static org.mozilla.gecko.db.BrowserProviderGeneralTest
|
||||
.getBookmarksTestSyncIncrementLocalVersionUri;
|
||||
import static org.mozilla.gecko.db.BrowserProviderGeneralTest.insertBookmark;
|
||||
import static org.mozilla.gecko.db.BrowserProviderGeneralTest.withDeleted;
|
||||
import static org.mozilla.gecko.db.BrowserProviderGeneralTest.withSync;
|
||||
|
@ -53,13 +54,11 @@ import static org.mozilla.gecko.db.BrowserProviderGeneralTest.withSync;
|
|||
@RunWith(TestRunner.class)
|
||||
public class BrowserProviderBookmarksTest {
|
||||
private ContentProviderClient bookmarksClient;
|
||||
private BrowserProvider provider;
|
||||
private ContentProvider provider;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
provider = new BrowserProvider();
|
||||
provider.onCreate();
|
||||
ShadowContentResolver.registerProvider(BrowserContract.AUTHORITY, new DelegatingTestContentProvider(provider));
|
||||
provider = DelegatingTestContentProvider.createDelegatingBrowserProvider();
|
||||
|
||||
ShadowContentResolver contentResolver = new ShadowContentResolver();
|
||||
bookmarksClient = contentResolver.acquireContentProviderClient(BrowserContractHelpers.BOOKMARKS_CONTENT_URI);
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
|
||||
package org.mozilla.gecko.db;
|
||||
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentProviderClient;
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
import android.provider.Browser;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
@ -41,15 +41,12 @@ public class BrowserProviderGeneralTest {
|
|||
|
||||
private static final long INVALID_ID = -1;
|
||||
|
||||
private BrowserProvider provider;
|
||||
private ContentProvider provider;
|
||||
private ContentProviderClient browserClient;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
provider = new BrowserProvider();
|
||||
provider.onCreate();
|
||||
|
||||
ShadowContentResolver.registerProvider(BrowserContract.AUTHORITY, new DelegatingTestContentProvider(provider));
|
||||
provider = DelegatingTestContentProvider.createDelegatingBrowserProvider();
|
||||
|
||||
ShadowContentResolver contentResolver = new ShadowContentResolver();
|
||||
browserClient = contentResolver.acquireContentProviderClient(BrowserContractHelpers.BOOKMARKS_CONTENT_URI);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
package org.mozilla.gecko.db;
|
||||
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentProviderClient;
|
||||
import android.content.ContentValues;
|
||||
import android.net.Uri;
|
||||
|
@ -14,21 +15,17 @@ import org.mozilla.gecko.background.db.DelegatingTestContentProvider;
|
|||
import org.mozilla.gecko.sync.repositories.android.BrowserContractHelpers;
|
||||
import org.robolectric.shadows.ShadowContentResolver;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class BrowserProviderHistoryVisitsTestBase {
|
||||
/* package-private */ ShadowContentResolver contentResolver;
|
||||
/* package-private */ ContentProviderClient historyClient;
|
||||
/* package-private */ ContentProviderClient visitsClient;
|
||||
/* package-private */ Uri historyTestUri;
|
||||
/* package-private */ Uri visitsTestUri;
|
||||
/* package-private */ BrowserProvider provider;
|
||||
/* package-private */ ContentProvider provider;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
provider = new BrowserProvider();
|
||||
provider.onCreate();
|
||||
ShadowContentResolver.registerProvider(BrowserContract.AUTHORITY, new DelegatingTestContentProvider(provider));
|
||||
provider = DelegatingTestContentProvider.createDelegatingBrowserProvider();
|
||||
|
||||
contentResolver = new ShadowContentResolver();
|
||||
historyClient = contentResolver.acquireContentProviderClient(BrowserContractHelpers.HISTORY_CONTENT_URI);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
package org.mozilla.gecko.db;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentProviderClient;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
|
@ -44,15 +45,13 @@ public class LocalBrowserDBTest {
|
|||
private static final String FOLDER_NAME = "folder1";
|
||||
|
||||
private Context context;
|
||||
private BrowserProvider provider;
|
||||
private ContentProvider provider;
|
||||
private ContentProviderClient bookmarkClient;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
context = RuntimeEnvironment.application;
|
||||
provider = new BrowserProvider();
|
||||
provider.onCreate();
|
||||
ShadowContentResolver.registerProvider(BrowserContract.AUTHORITY, new DelegatingTestContentProvider(provider));
|
||||
provider = DelegatingTestContentProvider.createDelegatingBrowserProvider();
|
||||
|
||||
ShadowContentResolver contentResolver = new ShadowContentResolver();
|
||||
bookmarkClient = contentResolver.acquireContentProviderClient(BrowserContractHelpers.BOOKMARKS_CONTENT_URI);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
package org.mozilla.gecko.fxa.devices;
|
||||
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentProviderClient;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
|
@ -21,7 +22,6 @@ import org.mozilla.gecko.background.db.DelegatingTestContentProvider;
|
|||
import org.mozilla.gecko.background.fxa.FxAccountClient;
|
||||
import org.mozilla.gecko.background.testhelpers.TestRunner;
|
||||
import org.mozilla.gecko.db.BrowserContract;
|
||||
import org.mozilla.gecko.db.BrowserProvider;
|
||||
import org.mozilla.gecko.fxa.authenticator.AndroidFxAccount;
|
||||
import org.mozilla.gecko.fxa.login.State;
|
||||
import org.robolectric.shadows.ShadowContentResolver;
|
||||
|
@ -119,12 +119,9 @@ public class TestFxAccountDeviceListUpdater {
|
|||
public void testBrowserProvider() {
|
||||
Uri uri = testUri(BrowserContract.RemoteDevices.CONTENT_URI);
|
||||
|
||||
BrowserProvider provider = new BrowserProvider();
|
||||
final ContentProvider provider = DelegatingTestContentProvider.createDelegatingBrowserProvider();
|
||||
Cursor c = null;
|
||||
try {
|
||||
provider.onCreate();
|
||||
ShadowContentResolver.registerProvider(BrowserContract.AUTHORITY, new DelegatingTestContentProvider(provider));
|
||||
|
||||
final ShadowContentResolver cr = new ShadowContentResolver();
|
||||
ContentProviderClient remoteDevicesClient = cr.acquireContentProviderClient(BrowserContract.RemoteDevices.CONTENT_URI);
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
package org.mozilla.gecko.sync.repositories.android;
|
||||
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentProviderClient;
|
||||
import android.content.ContentValues;
|
||||
import android.net.Uri;
|
||||
|
@ -16,7 +17,6 @@ import org.junit.runner.RunWith;
|
|||
import org.mozilla.gecko.background.db.DelegatingTestContentProvider;
|
||||
import org.mozilla.gecko.background.testhelpers.TestRunner;
|
||||
import org.mozilla.gecko.db.BrowserContract;
|
||||
import org.mozilla.gecko.db.BrowserProvider;
|
||||
import org.robolectric.shadows.ShadowContentResolver;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
@ -56,11 +56,8 @@ public class VisitsHelperTest {
|
|||
Uri historyTestUri = testUri(BrowserContract.History.CONTENT_URI);
|
||||
Uri visitsTestUri = testUri(BrowserContract.Visits.CONTENT_URI);
|
||||
|
||||
BrowserProvider provider = new BrowserProvider();
|
||||
final ContentProvider provider = DelegatingTestContentProvider.createDelegatingBrowserProvider();
|
||||
try {
|
||||
provider.onCreate();
|
||||
ShadowContentResolver.registerProvider(BrowserContract.AUTHORITY, new DelegatingTestContentProvider(provider));
|
||||
|
||||
final ShadowContentResolver cr = new ShadowContentResolver();
|
||||
ContentProviderClient historyClient = cr.acquireContentProviderClient(BrowserContractHelpers.HISTORY_CONTENT_URI);
|
||||
ContentProviderClient visitsClient = cr.acquireContentProviderClient(BrowserContractHelpers.VISITS_CONTENT_URI);
|
||||
|
|
Загрузка…
Ссылка в новой задаче