Skip to content

Commit

Permalink
fix: lifecycle owner being garbage collected
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoweii committed Mar 13, 2024
1 parent 8fef15e commit ed554ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public final class ActivityLifecycleManagerUnitTest {
private Application.ActivityLifecycleCallbacks callbacks;
private Log log;
private LifecycleRegistry lifecycle;
private LifecycleOwner owner;
private ActivityLifecycleManager lifecycleManager;

/**
Expand All @@ -65,8 +66,8 @@ public void setup() throws Exception {
this.callbacks = lifecycleManager;
log = mock(Log.class);
ReflectUtil.modifyFiled(this.callbacks, "LOG", log);

lifecycle = new LifecycleRegistry(mock(LifecycleOwner.class));
owner = mock(LifecycleOwner.class);
lifecycle = new LifecycleRegistry(owner);
lifecycleManager.startLifecycleTracking(ApplicationProvider.getApplicationContext(), lifecycle);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public class AutoRecordEventClientTest {
private ClickstreamContext clickstreamContext;
private AutoRecordEventClient client;
private LifecycleRegistry lifecycle;
private LifecycleOwner owner;

/**
* prepare AutoRecordEventClient and context.
Expand All @@ -95,7 +96,8 @@ public void setup() {
callbacks = new ActivityLifecycleManager(clickstreamManager);

ActivityLifecycleManager lifecycleManager = new ActivityLifecycleManager(clickstreamManager);
lifecycle = new LifecycleRegistry(mock(LifecycleOwner.class));
owner = mock(LifecycleOwner.class);
lifecycle = new LifecycleRegistry(owner);
lifecycleManager.startLifecycleTracking(ApplicationProvider.getApplicationContext(), lifecycle);
}

Expand Down

0 comments on commit ed554ec

Please sign in to comment.