mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Fix Leak canary test
This commit is contained in:
parent
0101dc4820
commit
6a6ba7d542
2 changed files with 10 additions and 4 deletions
|
|
@ -130,11 +130,9 @@ public class CommonsApplication extends Application implements HasActivityInject
|
|||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
if (LeakCanary.isInAnalyzerProcess(this)) {
|
||||
refWatcher = RefWatcher.DISABLED;
|
||||
if (setupLeakCanary() == RefWatcher.DISABLED) {
|
||||
return;
|
||||
}
|
||||
refWatcher = LeakCanary.install(this);
|
||||
|
||||
Timber.plant(new Timber.DebugTree());
|
||||
|
||||
|
|
@ -159,6 +157,13 @@ public class CommonsApplication extends Application implements HasActivityInject
|
|||
cacheData = new CacheController();
|
||||
}
|
||||
|
||||
protected RefWatcher setupLeakCanary() {
|
||||
if (LeakCanary.isInAnalyzerProcess(this)) {
|
||||
return RefWatcher.DISABLED;
|
||||
}
|
||||
return LeakCanary.install(this);
|
||||
}
|
||||
|
||||
public static RefWatcher getRefWatcher(Context context) {
|
||||
CommonsApplication application = (CommonsApplication) context.getApplicationContext();
|
||||
return application.refWatcher;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ import com.squareup.leakcanary.RefWatcher;
|
|||
|
||||
// This class is automatically discovered by Robolectric
|
||||
public class TestCommonsApplication extends CommonsApplication {
|
||||
@Override protected RefWatcher setupLeakCanary() {
|
||||
@Override
|
||||
protected RefWatcher setupLeakCanary() {
|
||||
// No leakcanary in unit tests.
|
||||
return RefWatcher.DISABLED;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue