Make a strong reference to LifecycleOwner in tests

Change-Id: Id3b26ded6c903b67b9880dbfe1a0656a564c8947
Fixes: 71867776
Test: rerun tests
This commit is contained in:
Fan Zhang
2018-01-11 14:30:16 -08:00
parent 66898b0cc9
commit 4e08869e1a
45 changed files with 190 additions and 54 deletions

View File

@@ -33,6 +33,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.Activity;
import android.arch.lifecycle.LifecycleOwner;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -154,6 +155,7 @@ public class WifiDetailPreferenceControllerTest {
private Context mContext;
private Lifecycle mLifecycle;
private LifecycleOwner mLifecycleOwner;
private LinkProperties mLinkProperties;
private WifiDetailPreferenceController mController;
@@ -214,7 +216,8 @@ public class WifiDetailPreferenceControllerTest {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
mLifecycle = new Lifecycle(() -> mLifecycle);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
when(mockAccessPoint.getConfig()).thenReturn(mockWifiConfig);
when(mockAccessPoint.getLevel()).thenReturn(LEVEL);