Do not start suggestion loader if host isn't attached.

Change-Id: I1ab1de8f0bea6c66d8415e06aedcc7cbc6baf89c
Fixes: 68759380
Test: robotests
This commit is contained in:
Fan Zhang
2017-11-01 10:09:04 -07:00
parent f60c99af53
commit 6d7aa4e951
3 changed files with 28 additions and 4 deletions

View File

@@ -23,7 +23,6 @@ import static org.mockito.Mockito.when;
import android.app.LoaderManager;
import android.content.Context;
import android.database.MatrixCursor;
import com.android.settings.TestConfig;
import com.android.settings.testutils.FakeFeatureFactory;
@@ -88,4 +87,14 @@ public class SuggestionControllerMixinTest {
verify(loaderManager).restartLoader(SuggestionLoader.LOADER_ID_SUGGESTIONS,
null /* args */, mMixin /* callback */);
}
@Test
public void onServiceConnected_hostNotAttached_shouldDoNothing() {
when(mHost.getLoaderManager()).thenReturn(null);
mMixin = new SuggestionControllerMixin(mContext, mHost, mLifecycle);
mMixin.onServiceConnected();
verify(mHost).getLoaderManager();
}
}