mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Disable LeakCanary for Robolectric tests
See 'For Robolectric users:' https://github.com/square/leakcanary
This commit is contained in:
parent
10ac64d556
commit
e317c369c1
2 changed files with 21 additions and 6 deletions
|
|
@ -17,6 +17,7 @@ import android.support.v4.util.LruCache;
|
||||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||||
import com.facebook.stetho.Stetho;
|
import com.facebook.stetho.Stetho;
|
||||||
import com.squareup.leakcanary.LeakCanary;
|
import com.squareup.leakcanary.LeakCanary;
|
||||||
|
import com.squareup.leakcanary.RefWatcher;
|
||||||
|
|
||||||
import org.acra.ACRA;
|
import org.acra.ACRA;
|
||||||
import org.acra.ReportingInteractionMode;
|
import org.acra.ReportingInteractionMode;
|
||||||
|
|
@ -117,12 +118,8 @@ public class CommonsApplication extends Application {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
if (LeakCanary.isInAnalyzerProcess(this)) {
|
|
||||||
// This process is dedicated to LeakCanary for heap analysis.
|
setupLeakCanary();
|
||||||
// You should not init your app in this process.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
LeakCanary.install(this);
|
|
||||||
|
|
||||||
Timber.plant(new Timber.DebugTree());
|
Timber.plant(new Timber.DebugTree());
|
||||||
|
|
||||||
|
|
@ -143,6 +140,13 @@ public class CommonsApplication extends Application {
|
||||||
cacheData = new CacheController();
|
cacheData = new CacheController();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected RefWatcher setupLeakCanary() {
|
||||||
|
if (LeakCanary.isInAnalyzerProcess(this)) {
|
||||||
|
return RefWatcher.DISABLED;
|
||||||
|
}
|
||||||
|
return LeakCanary.install(this);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Account|null
|
* @return Account|null
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package fr.free.nrw.commons;
|
||||||
|
|
||||||
|
import com.squareup.leakcanary.RefWatcher;
|
||||||
|
|
||||||
|
// This class is automatically discovered by Robolectric
|
||||||
|
public class TestCommonsApplication extends CommonsApplication {
|
||||||
|
@Override protected RefWatcher setupLeakCanary() {
|
||||||
|
// No leakcanary in unit tests.
|
||||||
|
return RefWatcher.DISABLED;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue