Hack to wait for both suggestion/category to load
- This is unfortunately necessary to avoid a jank when category load completes before suggestion load, in which case user has to manually scroll up to see the suggestions. - We could technically just add scrollTo(0), but that causes the list scroll on its own within 0.5 second of settings start, and that's bad. Change-Id: I8dc869a69a5bf11bbf7644b281cc1778dd1a90e8 Fixes: 69068691 Test: visual Test: robotests
This commit is contained in:
@@ -18,9 +18,7 @@ package com.android.settings.dashboard.suggestions;
|
||||
|
||||
import static android.arch.lifecycle.Lifecycle.Event.ON_START;
|
||||
import static android.arch.lifecycle.Lifecycle.Event.ON_STOP;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -37,9 +35,9 @@ import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@@ -49,19 +47,18 @@ import org.robolectric.annotation.Config;
|
||||
})
|
||||
public class SuggestionControllerMixinTest {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private SuggestionControllerMixin.SuggestionControllerHost mHost;
|
||||
private Context mContext;
|
||||
private Lifecycle mLifecycle;
|
||||
private SuggestionControllerMixin mMixin;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
FakeFeatureFactory.setupForTest(mContext);
|
||||
mContext = RuntimeEnvironment.application;
|
||||
FakeFeatureFactory.setupForTest();
|
||||
mLifecycle = new Lifecycle(() -> mLifecycle);
|
||||
when(mContext.getApplicationContext()).thenReturn(mContext);
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -111,4 +108,17 @@ public class SuggestionControllerMixinTest {
|
||||
|
||||
verify(mHost).getLoaderManager();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doneLoadingg_shouldSetSuggestionLoaded() {
|
||||
mMixin = new SuggestionControllerMixin(mContext, mHost, mLifecycle);
|
||||
|
||||
mMixin.onLoadFinished(mock(SuggestionLoader.class), null);
|
||||
|
||||
assertThat(mMixin.isSuggestionLoaded()).isTrue();
|
||||
|
||||
mMixin.onLoaderReset(mock(SuggestionLoader.class));
|
||||
|
||||
assertThat(mMixin.isSuggestionLoaded()).isFalse();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user