Fixing a bug in suggestion logging and adding more tests.
Test: RunSettingsRoboTests Fixes: b/35802845 Change-Id: I216b3ff344ccdffd038d924649109483e80f5437
This commit is contained in:
@@ -406,7 +406,8 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
|||||||
popup.show();
|
popup.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onBindSuggestionHeader(final DashboardItemHolder holder, DashboardData
|
@VisibleForTesting
|
||||||
|
void onBindSuggestionHeader(final DashboardItemHolder holder, DashboardData
|
||||||
.SuggestionHeaderData data) {
|
.SuggestionHeaderData data) {
|
||||||
final boolean moreSuggestions = data.hasMoreSuggestions;
|
final boolean moreSuggestions = data.hasMoreSuggestions;
|
||||||
final int undisplayedSuggestionCount = data.undisplayedSuggestionCount;
|
final int undisplayedSuggestionCount = data.undisplayedSuggestionCount;
|
||||||
@@ -436,10 +437,8 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
|||||||
final int suggestionMode;
|
final int suggestionMode;
|
||||||
if (moreSuggestions) {
|
if (moreSuggestions) {
|
||||||
suggestionMode = DashboardData.SUGGESTION_MODE_EXPANDED;
|
suggestionMode = DashboardData.SUGGESTION_MODE_EXPANDED;
|
||||||
List<Tile> expandedSuggestions = mDashboardData.getSuggestions().subList(
|
|
||||||
DashboardData.DEFAULT_SUGGESTION_COUNT,
|
for (Tile suggestion : mDashboardData.getSuggestions()) {
|
||||||
mDashboardData.getSuggestions().size());
|
|
||||||
for (Tile suggestion : expandedSuggestions) {
|
|
||||||
String suggestionId =
|
String suggestionId =
|
||||||
DashboardAdapter.getSuggestionIdentifier(mContext, suggestion);
|
DashboardAdapter.getSuggestionIdentifier(mContext, suggestion);
|
||||||
if (!mSuggestionsShownLogged.contains(suggestionId)) {
|
if (!mSuggestionsShownLogged.contains(suggestionId)) {
|
||||||
|
@@ -18,9 +18,11 @@ package com.android.settings.dashboard;
|
|||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.Resources;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||||
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsRobolectricTestRunner;
|
import com.android.settings.SettingsRobolectricTestRunner;
|
||||||
import com.android.settings.TestConfig;
|
import com.android.settings.TestConfig;
|
||||||
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
|
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
|
||||||
@@ -35,12 +37,16 @@ import org.mockito.Captor;
|
|||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import org.mockito.Matchers;
|
||||||
import static org.mockito.Mockito.any;
|
import static org.mockito.Mockito.any;
|
||||||
|
import static org.mockito.Mockito.eq;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@@ -48,8 +54,7 @@ import static org.mockito.Mockito.when;
|
|||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||||
public class DashboardAdapterTest {
|
public class DashboardAdapterTest {
|
||||||
@Mock
|
|
||||||
private Context mContext;
|
|
||||||
@Mock
|
@Mock
|
||||||
private View mView;
|
private View mView;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -57,18 +62,29 @@ public class DashboardAdapterTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private MetricsFeatureProvider mMetricsFeatureProvider;
|
private MetricsFeatureProvider mMetricsFeatureProvider;
|
||||||
@Mock
|
@Mock
|
||||||
private TypedArray mTypedArray;
|
private Resources mResources;
|
||||||
|
@Mock
|
||||||
|
private DashboardData mDashboardData;
|
||||||
@Captor
|
@Captor
|
||||||
private ArgumentCaptor<Integer> mActionCategoryCaptor = ArgumentCaptor.forClass(Integer.class);
|
private ArgumentCaptor<Integer> mActionCategoryCaptor = ArgumentCaptor.forClass(Integer.class);
|
||||||
@Captor
|
@Captor
|
||||||
private ArgumentCaptor<String> mActionPackageCaptor = ArgumentCaptor.forClass(String.class);
|
private ArgumentCaptor<String> mActionPackageCaptor = ArgumentCaptor.forClass(String.class);
|
||||||
private DashboardAdapter mDashboardAdapter;
|
private DashboardAdapter mDashboardAdapter;
|
||||||
|
private DashboardAdapter.DashboardItemHolder mSuggestionHolder;
|
||||||
|
private DashboardData.SuggestionHeaderData mSuggestionHeaderData;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mDashboardAdapter = new DashboardAdapter(mContext, null, mMetricsFeatureProvider,
|
Context context = RuntimeEnvironment.application;
|
||||||
|
context = spy(context);
|
||||||
|
when(context.getResources()).thenReturn(mResources);
|
||||||
|
when(mResources
|
||||||
|
.getQuantityString(any(int.class), any(int.class), Matchers.<Object>anyVararg()))
|
||||||
|
.thenReturn("");
|
||||||
|
mDashboardAdapter = new DashboardAdapter(context, null, mMetricsFeatureProvider,
|
||||||
null, null);
|
null, null);
|
||||||
|
mSuggestionHeaderData = new DashboardData.SuggestionHeaderData(true, 1, 0);
|
||||||
when(mView.getTag()).thenReturn(mCondition);
|
when(mView.getTag()).thenReturn(mCondition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,20 +97,29 @@ public class DashboardAdapterTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuggestionsLogs() {
|
public void testSuggestionsLogs_NotExpanded() {
|
||||||
when(mTypedArray.getColor(any(int.class), any(int.class))).thenReturn(0);
|
setUpSuggestions(makeSuggestions(new String[]{"pkg1", "pkg2", "pkg3"}));
|
||||||
when(mContext.obtainStyledAttributes(any(int[].class))).thenReturn(mTypedArray);
|
verify(mMetricsFeatureProvider, times(2)).action(
|
||||||
List<Tile> suggestions = new ArrayList<Tile>();
|
any(Context.class), mActionCategoryCaptor.capture(),
|
||||||
suggestions.add(makeSuggestion("pkg1", "cls1"));
|
mActionPackageCaptor.capture());
|
||||||
suggestions.add(makeSuggestion("pkg2", "cls2"));
|
String[] expectedPackages = new String[]{"pkg1", "pkg2"};
|
||||||
suggestions.add(makeSuggestion("pkg3", "cls3"));
|
Integer[] expectedActions = new Integer[]{
|
||||||
mDashboardAdapter.setCategoriesAndSuggestions(
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||||
new ArrayList<DashboardCategory>(), suggestions);
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION
|
||||||
|
};
|
||||||
|
assertThat(mActionPackageCaptor.getAllValues().toArray()).isEqualTo(expectedPackages);
|
||||||
|
assertThat(mActionCategoryCaptor.getAllValues().toArray()).isEqualTo(expectedActions);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSuggestionsLogs_NotExpandedAndPaused() {
|
||||||
|
setUpSuggestions(makeSuggestions(new String[]{"pkg1", "pkg2", "pkg3"}));
|
||||||
mDashboardAdapter.onPause();
|
mDashboardAdapter.onPause();
|
||||||
verify(mMetricsFeatureProvider, times(4)).action(
|
verify(mMetricsFeatureProvider, times(4)).action(
|
||||||
any(Context.class), mActionCategoryCaptor.capture(), mActionPackageCaptor.capture());
|
any(Context.class), mActionCategoryCaptor.capture(),
|
||||||
String[] expectedPackages = new String[] {"pkg1", "pkg2", "pkg1", "pkg2"};
|
mActionPackageCaptor.capture());
|
||||||
Integer[] expectedActions = new Integer[] {
|
String[] expectedPackages = new String[]{"pkg1", "pkg2", "pkg1", "pkg2"};
|
||||||
|
Integer[] expectedActions = new Integer[]{
|
||||||
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||||
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||||
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION,
|
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION,
|
||||||
@@ -103,6 +128,188 @@ public class DashboardAdapterTest {
|
|||||||
assertThat(mActionCategoryCaptor.getAllValues().toArray()).isEqualTo(expectedActions);
|
assertThat(mActionCategoryCaptor.getAllValues().toArray()).isEqualTo(expectedActions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSuggestionsLogs_Expanded() {
|
||||||
|
setUpSuggestions(makeSuggestions(new String[]{"pkg1", "pkg2", "pkg3"}));
|
||||||
|
mDashboardAdapter.onBindSuggestionHeader(
|
||||||
|
mSuggestionHolder, mSuggestionHeaderData);
|
||||||
|
mSuggestionHolder.itemView.callOnClick();
|
||||||
|
verify(mMetricsFeatureProvider, times(3)).action(
|
||||||
|
any(Context.class), mActionCategoryCaptor.capture(),
|
||||||
|
mActionPackageCaptor.capture());
|
||||||
|
String[] expectedPackages = new String[]{"pkg1", "pkg2", "pkg3"};
|
||||||
|
Integer[] expectedActions = new Integer[]{
|
||||||
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION
|
||||||
|
};
|
||||||
|
assertThat(mActionPackageCaptor.getAllValues().toArray()).isEqualTo(expectedPackages);
|
||||||
|
assertThat(mActionCategoryCaptor.getAllValues().toArray()).isEqualTo(expectedActions);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSuggestionsLogs_ExpandedAndPaused() {
|
||||||
|
setUpSuggestions(makeSuggestions(new String[]{"pkg1", "pkg2", "pkg3"}));
|
||||||
|
mDashboardAdapter.onBindSuggestionHeader(
|
||||||
|
mSuggestionHolder, mSuggestionHeaderData);
|
||||||
|
mSuggestionHolder.itemView.callOnClick();
|
||||||
|
mDashboardAdapter.onPause();
|
||||||
|
verify(mMetricsFeatureProvider, times(6)).action(
|
||||||
|
any(Context.class), mActionCategoryCaptor.capture(),
|
||||||
|
mActionPackageCaptor.capture());
|
||||||
|
String[] expectedPackages = new String[]{"pkg1", "pkg2", "pkg3", "pkg1", "pkg2", "pkg3"};
|
||||||
|
Integer[] expectedActions = new Integer[]{
|
||||||
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION
|
||||||
|
};
|
||||||
|
assertThat(mActionPackageCaptor.getAllValues().toArray()).isEqualTo(expectedPackages);
|
||||||
|
assertThat(mActionCategoryCaptor.getAllValues().toArray()).isEqualTo(expectedActions);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSuggestionsLogs_ExpandedAfterPause() {
|
||||||
|
setUpSuggestions(makeSuggestions(new String[]{"pkg1", "pkg2", "pkg3"}));
|
||||||
|
mDashboardAdapter.onPause();
|
||||||
|
mDashboardAdapter.onBindSuggestionHeader(
|
||||||
|
mSuggestionHolder, mSuggestionHeaderData);
|
||||||
|
mSuggestionHolder.itemView.callOnClick();
|
||||||
|
verify(mMetricsFeatureProvider, times(7)).action(
|
||||||
|
any(Context.class), mActionCategoryCaptor.capture(),
|
||||||
|
mActionPackageCaptor.capture());
|
||||||
|
String[] expectedPackages = new String[]{
|
||||||
|
"pkg1", "pkg2", "pkg1", "pkg2", "pkg1", "pkg2", "pkg3"};
|
||||||
|
Integer[] expectedActions = new Integer[]{
|
||||||
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION
|
||||||
|
};
|
||||||
|
assertThat(mActionPackageCaptor.getAllValues().toArray()).isEqualTo(expectedPackages);
|
||||||
|
assertThat(mActionCategoryCaptor.getAllValues().toArray()).isEqualTo(expectedActions);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSuggestionsLogs_ExpandedAfterPauseAndPausedAgain() {
|
||||||
|
setUpSuggestions(makeSuggestions(new String[]{"pkg1", "pkg2", "pkg3"}));
|
||||||
|
mDashboardAdapter.onPause();
|
||||||
|
mDashboardAdapter.onBindSuggestionHeader(
|
||||||
|
mSuggestionHolder, mSuggestionHeaderData);
|
||||||
|
mSuggestionHolder.itemView.callOnClick();
|
||||||
|
mDashboardAdapter.onPause();
|
||||||
|
verify(mMetricsFeatureProvider, times(10)).action(
|
||||||
|
any(Context.class), mActionCategoryCaptor.capture(),
|
||||||
|
mActionPackageCaptor.capture());
|
||||||
|
String[] expectedPackages = new String[]{
|
||||||
|
"pkg1", "pkg2", "pkg1", "pkg2", "pkg1", "pkg2", "pkg3", "pkg1", "pkg2", "pkg3"};
|
||||||
|
Integer[] expectedActions = new Integer[]{
|
||||||
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION
|
||||||
|
};
|
||||||
|
assertThat(mActionPackageCaptor.getAllValues().toArray()).isEqualTo(expectedPackages);
|
||||||
|
assertThat(mActionCategoryCaptor.getAllValues().toArray()).isEqualTo(expectedActions);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSuggestionsLogs_ExpandedWithLessThanDefaultShown() {
|
||||||
|
setUpSuggestions(makeSuggestions(new String[]{"pkg1"}));
|
||||||
|
mDashboardAdapter.onBindSuggestionHeader(
|
||||||
|
mSuggestionHolder, mSuggestionHeaderData);
|
||||||
|
mSuggestionHolder.itemView.callOnClick();
|
||||||
|
verify(mMetricsFeatureProvider, times(1)).action(
|
||||||
|
any(Context.class), mActionCategoryCaptor.capture(),
|
||||||
|
mActionPackageCaptor.capture());
|
||||||
|
String[] expectedPackages = new String[]{"pkg1"};
|
||||||
|
Integer[] expectedActions = new Integer[]{
|
||||||
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||||
|
};
|
||||||
|
assertThat(mActionPackageCaptor.getAllValues().toArray()).isEqualTo(expectedPackages);
|
||||||
|
assertThat(mActionCategoryCaptor.getAllValues().toArray()).isEqualTo(expectedActions);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSuggestionsLogs_ExpandedWithLessThanDefaultShownAndPaused() {
|
||||||
|
setUpSuggestions(makeSuggestions(new String[]{"pkg1"}));
|
||||||
|
mDashboardAdapter.onBindSuggestionHeader(
|
||||||
|
mSuggestionHolder, mSuggestionHeaderData);
|
||||||
|
mSuggestionHolder.itemView.callOnClick();
|
||||||
|
mDashboardAdapter.onPause();
|
||||||
|
verify(mMetricsFeatureProvider, times(2)).action(
|
||||||
|
any(Context.class), mActionCategoryCaptor.capture(),
|
||||||
|
mActionPackageCaptor.capture());
|
||||||
|
String[] expectedPackages = new String[]{"pkg1", "pkg1"};
|
||||||
|
Integer[] expectedActions = new Integer[]{
|
||||||
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION
|
||||||
|
};
|
||||||
|
assertThat(mActionPackageCaptor.getAllValues().toArray()).isEqualTo(expectedPackages);
|
||||||
|
assertThat(mActionCategoryCaptor.getAllValues().toArray()).isEqualTo(expectedActions);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSuggestionsLogs_ExpandedWithLessThanDefaultShownAfterPause() {
|
||||||
|
setUpSuggestions(makeSuggestions(new String[]{"pkg1"}));
|
||||||
|
mDashboardAdapter.onPause();
|
||||||
|
mDashboardAdapter.onBindSuggestionHeader(
|
||||||
|
mSuggestionHolder, mSuggestionHeaderData);
|
||||||
|
mSuggestionHolder.itemView.callOnClick();
|
||||||
|
verify(mMetricsFeatureProvider, times(3)).action(
|
||||||
|
any(Context.class), mActionCategoryCaptor.capture(),
|
||||||
|
mActionPackageCaptor.capture());
|
||||||
|
String[] expectedPackages = new String[]{"pkg1", "pkg1", "pkg1"};
|
||||||
|
Integer[] expectedActions = new Integer[]{
|
||||||
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION
|
||||||
|
};
|
||||||
|
assertThat(mActionPackageCaptor.getAllValues().toArray()).isEqualTo(expectedPackages);
|
||||||
|
assertThat(mActionCategoryCaptor.getAllValues().toArray()).isEqualTo(expectedActions);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSuggestionsLogs_ExpandedWithLessThanDefaultShownAfterPauseAndPausedAgain() {
|
||||||
|
setUpSuggestions(makeSuggestions(new String[]{"pkg1"}));
|
||||||
|
mDashboardAdapter.onPause();
|
||||||
|
mDashboardAdapter.onBindSuggestionHeader(
|
||||||
|
mSuggestionHolder, mSuggestionHeaderData);
|
||||||
|
mSuggestionHolder.itemView.callOnClick();
|
||||||
|
mDashboardAdapter.onPause();
|
||||||
|
verify(mMetricsFeatureProvider, times(4)).action(
|
||||||
|
any(Context.class), mActionCategoryCaptor.capture(),
|
||||||
|
mActionPackageCaptor.capture());
|
||||||
|
String[] expectedPackages = new String[]{"pkg1", "pkg1", "pkg1", "pkg1"};
|
||||||
|
Integer[] expectedActions = new Integer[]{
|
||||||
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||||
|
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION
|
||||||
|
};
|
||||||
|
assertThat(mActionPackageCaptor.getAllValues().toArray()).isEqualTo(expectedPackages);
|
||||||
|
assertThat(mActionCategoryCaptor.getAllValues().toArray()).isEqualTo(expectedActions);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Tile> makeSuggestions(String[] pkgNames) {
|
||||||
|
List<Tile> suggestions = new ArrayList<Tile>();
|
||||||
|
for (String pkgName : pkgNames) {
|
||||||
|
suggestions.add(makeSuggestion(pkgName, "cls"));
|
||||||
|
}
|
||||||
|
return suggestions;
|
||||||
|
}
|
||||||
|
|
||||||
private Tile makeSuggestion(String pkgName, String className) {
|
private Tile makeSuggestion(String pkgName, String className) {
|
||||||
Tile suggestion = new Tile();
|
Tile suggestion = new Tile();
|
||||||
suggestion.intent = new Intent("action");
|
suggestion.intent = new Intent("action");
|
||||||
@@ -110,4 +317,12 @@ public class DashboardAdapterTest {
|
|||||||
return suggestion;
|
return suggestion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setUpSuggestions(List<Tile> suggestions) {
|
||||||
|
mDashboardAdapter.setCategoriesAndSuggestions(
|
||||||
|
new ArrayList<DashboardCategory>(), suggestions);
|
||||||
|
mSuggestionHolder = mDashboardAdapter.onCreateViewHolder(
|
||||||
|
new FrameLayout(RuntimeEnvironment.application),
|
||||||
|
mDashboardAdapter.getItemViewType(0));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user