Merge "Log smart settings suggestion enabled/disabled state for A/B experiments" into oc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
339fd95209
@@ -37,6 +37,7 @@ import android.graphics.drawable.Icon;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Pair;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
@@ -89,6 +90,8 @@ public class DashboardAdapterTest {
|
||||
private ArgumentCaptor<Integer> mActionCategoryCaptor = ArgumentCaptor.forClass(Integer.class);
|
||||
@Captor
|
||||
private ArgumentCaptor<String> mActionPackageCaptor = ArgumentCaptor.forClass(String.class);
|
||||
@Captor
|
||||
private ArgumentCaptor<Pair> mTaggedDataCaptor = ArgumentCaptor.forClass(Pair.class);
|
||||
private FakeFeatureFactory mFactory;
|
||||
private DashboardAdapter mDashboardAdapter;
|
||||
private DashboardAdapter.SuggestionAndConditionHeaderHolder mSuggestionHolder;
|
||||
@@ -123,112 +126,143 @@ public class DashboardAdapterTest {
|
||||
@Test
|
||||
public void testSuggestionsLogs_NotExpanded() {
|
||||
setupSuggestions(makeSuggestions("pkg1", "pkg2", "pkg3"));
|
||||
|
||||
verify(mFactory.metricsFeatureProvider, times(2)).action(
|
||||
any(Context.class), mActionCategoryCaptor.capture(),
|
||||
mActionPackageCaptor.capture());
|
||||
String[] expectedPackages = new String[]{"pkg1", "pkg2"};
|
||||
Integer[] expectedActions = new Integer[]{
|
||||
mActionPackageCaptor.capture(),
|
||||
mTaggedDataCaptor.capture());
|
||||
assertThat(mActionCategoryCaptor.getAllValues()).containsExactly(
|
||||
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION
|
||||
};
|
||||
assertThat(mActionCategoryCaptor.getAllValues().toArray()).isEqualTo(expectedActions);
|
||||
assertThat(mActionPackageCaptor.getAllValues().toArray()).isEqualTo(expectedPackages);
|
||||
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION);
|
||||
assertThat(mActionPackageCaptor.getAllValues()).containsExactly("pkg1", "pkg2");
|
||||
assertThat(mTaggedDataCaptor.getAllValues()).containsExactly(
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuggestionsLogs_NotExpandedAndPaused() {
|
||||
setupSuggestions(makeSuggestions("pkg1", "pkg2", "pkg3"));
|
||||
|
||||
mDashboardAdapter.onPause();
|
||||
|
||||
verify(mFactory.metricsFeatureProvider, times(4)).action(
|
||||
any(Context.class), mActionCategoryCaptor.capture(),
|
||||
mActionPackageCaptor.capture());
|
||||
String[] expectedPackages = new String[]{"pkg1", "pkg2", "pkg1", "pkg2"};
|
||||
Integer[] expectedActions = new Integer[]{
|
||||
mActionPackageCaptor.capture(),
|
||||
mTaggedDataCaptor.capture());
|
||||
assertThat(mActionCategoryCaptor.getAllValues()).containsExactly(
|
||||
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION,
|
||||
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION};
|
||||
assertThat(mActionCategoryCaptor.getAllValues().toArray()).isEqualTo(expectedActions);
|
||||
assertThat(mActionPackageCaptor.getAllValues().toArray()).isEqualTo(expectedPackages);
|
||||
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION);
|
||||
assertThat(mActionPackageCaptor.getAllValues()).containsExactly(
|
||||
"pkg1", "pkg2", "pkg1", "pkg2");
|
||||
assertThat(mTaggedDataCaptor.getAllValues()).containsExactly(
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuggestionsLogs_Expanded() {
|
||||
setupSuggestions(makeSuggestions("pkg1", "pkg2", "pkg3"));
|
||||
|
||||
mDashboardAdapter.onBindSuggestionConditionHeader(mSuggestionHolder, mSuggestionHeaderData);
|
||||
mSuggestionHolder.itemView.callOnClick();
|
||||
|
||||
verify(mFactory.metricsFeatureProvider, times(3)).action(
|
||||
any(Context.class), mActionCategoryCaptor.capture(),
|
||||
mActionPackageCaptor.capture());
|
||||
String[] expectedPackages = new String[]{"pkg1", "pkg2", "pkg3"};
|
||||
Integer[] expectedActions = new Integer[]{
|
||||
mActionPackageCaptor.capture(),
|
||||
mTaggedDataCaptor.capture());
|
||||
assertThat(mActionCategoryCaptor.getAllValues()).containsExactly(
|
||||
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);
|
||||
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION);
|
||||
assertThat(mActionPackageCaptor.getAllValues()).containsExactly(
|
||||
"pkg1", "pkg2", "pkg3");
|
||||
assertThat(mTaggedDataCaptor.getAllValues()).containsExactly(
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuggestionsLogs_ExpandedAndPaused() {
|
||||
setupSuggestions(makeSuggestions("pkg1", "pkg2", "pkg3"));
|
||||
|
||||
mDashboardAdapter.onBindSuggestionConditionHeader(mSuggestionHolder, mSuggestionHeaderData);
|
||||
mSuggestionHolder.itemView.callOnClick();
|
||||
mDashboardAdapter.onPause();
|
||||
|
||||
verify(mFactory.metricsFeatureProvider, times(6)).action(
|
||||
any(Context.class), mActionCategoryCaptor.capture(),
|
||||
mActionPackageCaptor.capture());
|
||||
String[] expectedPackages = new String[]{"pkg1", "pkg2", "pkg3", "pkg1", "pkg2", "pkg3"};
|
||||
Integer[] expectedActions = new Integer[]{
|
||||
mActionPackageCaptor.capture(),
|
||||
mTaggedDataCaptor.capture());
|
||||
assertThat(mActionCategoryCaptor.getAllValues()).containsExactly(
|
||||
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);
|
||||
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION);
|
||||
assertThat(mActionPackageCaptor.getAllValues()).containsExactly(
|
||||
"pkg1", "pkg2", "pkg3", "pkg1", "pkg2", "pkg3");
|
||||
assertThat(mTaggedDataCaptor.getAllValues()).containsExactly(
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuggestionsLogs_ExpandedAfterPause() {
|
||||
setupSuggestions(makeSuggestions("pkg1", "pkg2", "pkg3"));
|
||||
|
||||
mDashboardAdapter.onPause();
|
||||
mDashboardAdapter.onBindSuggestionConditionHeader(mSuggestionHolder, mSuggestionHeaderData);
|
||||
mSuggestionHolder.itemView.callOnClick();
|
||||
|
||||
verify(mFactory.metricsFeatureProvider, 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[]{
|
||||
mActionPackageCaptor.capture(),
|
||||
mTaggedDataCaptor.capture());
|
||||
assertThat(mActionCategoryCaptor.getAllValues()).containsExactly(
|
||||
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);
|
||||
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION);
|
||||
assertThat(mActionPackageCaptor.getAllValues()).containsExactly(
|
||||
"pkg1", "pkg2", "pkg1", "pkg2", "pkg1", "pkg2", "pkg3");
|
||||
assertThat(mTaggedDataCaptor.getAllValues()).containsExactly(
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuggestionsLogs_ExpandedAfterPauseAndPausedAgain() {
|
||||
setupSuggestions(makeSuggestions("pkg1", "pkg2", "pkg3"));
|
||||
|
||||
mDashboardAdapter.onPause();
|
||||
mDashboardAdapter.onBindSuggestionConditionHeader(mSuggestionHolder, mSuggestionHeaderData);
|
||||
mSuggestionHolder.itemView.callOnClick();
|
||||
mDashboardAdapter.onPause();
|
||||
|
||||
verify(mFactory.metricsFeatureProvider, 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[]{
|
||||
mActionPackageCaptor.capture(),
|
||||
mTaggedDataCaptor.capture());
|
||||
assertThat(mActionCategoryCaptor.getAllValues()).containsExactly(
|
||||
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION,
|
||||
@@ -238,63 +272,82 @@ public class DashboardAdapterTest {
|
||||
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);
|
||||
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION);
|
||||
assertThat(mActionPackageCaptor.getAllValues()).containsExactly(
|
||||
"pkg1", "pkg2", "pkg1", "pkg2", "pkg1", "pkg2", "pkg3", "pkg1", "pkg2", "pkg3");
|
||||
assertThat(mTaggedDataCaptor.getAllValues()).containsExactly(
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuggestionsLogs_ExpandedWithLessThanDefaultShown() {
|
||||
setupSuggestions(makeSuggestions("pkg1"));
|
||||
|
||||
mDashboardAdapter.onBindSuggestionConditionHeader(mSuggestionHolder, mSuggestionHeaderData);
|
||||
mSuggestionHolder.itemView.callOnClick();
|
||||
|
||||
verify(mFactory.metricsFeatureProvider, 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);
|
||||
mActionPackageCaptor.capture(),
|
||||
mTaggedDataCaptor.capture());
|
||||
assertThat(mActionCategoryCaptor.getAllValues()).containsExactly(
|
||||
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION);
|
||||
assertThat(mActionPackageCaptor.getAllValues()).containsExactly("pkg1");
|
||||
assertThat(mTaggedDataCaptor.getAllValues()).containsExactly(
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuggestionsLogs_ExpandedWithLessThanDefaultShownAndPaused() {
|
||||
setupSuggestions(makeSuggestions("pkg1"));
|
||||
|
||||
mDashboardAdapter.onBindSuggestionConditionHeader(mSuggestionHolder, mSuggestionHeaderData);
|
||||
mSuggestionHolder.itemView.callOnClick();
|
||||
mDashboardAdapter.onPause();
|
||||
|
||||
verify(mFactory.metricsFeatureProvider, times(2)).action(
|
||||
any(Context.class), mActionCategoryCaptor.capture(),
|
||||
mActionPackageCaptor.capture());
|
||||
String[] expectedPackages = new String[]{"pkg1", "pkg1"};
|
||||
Integer[] expectedActions = new Integer[]{
|
||||
mActionPackageCaptor.capture(),
|
||||
mTaggedDataCaptor.capture());
|
||||
assertThat(mActionCategoryCaptor.getAllValues()).containsExactly(
|
||||
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION
|
||||
};
|
||||
assertThat(mActionPackageCaptor.getAllValues().toArray()).isEqualTo(expectedPackages);
|
||||
assertThat(mActionCategoryCaptor.getAllValues().toArray()).isEqualTo(expectedActions);
|
||||
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION);
|
||||
assertThat(mActionPackageCaptor.getAllValues()).containsExactly("pkg1", "pkg1");
|
||||
assertThat(mTaggedDataCaptor.getAllValues()).containsExactly(
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuggestionsLogs_ExpandedWithLessThanDefaultShownAfterPause() {
|
||||
setupSuggestions(makeSuggestions("pkg1"));
|
||||
|
||||
mDashboardAdapter.onPause();
|
||||
mDashboardAdapter.onBindSuggestionConditionHeader(mSuggestionHolder, mSuggestionHeaderData);
|
||||
mSuggestionHolder.itemView.callOnClick();
|
||||
|
||||
verify(mFactory.metricsFeatureProvider, times(3)).action(
|
||||
any(Context.class), mActionCategoryCaptor.capture(),
|
||||
mActionPackageCaptor.capture());
|
||||
String[] expectedPackages = new String[]{"pkg1", "pkg1", "pkg1"};
|
||||
Integer[] expectedActions = new Integer[]{
|
||||
mActionPackageCaptor.capture(),
|
||||
mTaggedDataCaptor.capture());
|
||||
assertThat(mActionCategoryCaptor.getAllValues()).containsExactly(
|
||||
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);
|
||||
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION);
|
||||
assertThat(mActionPackageCaptor.getAllValues()).containsExactly("pkg1", "pkg1", "pkg1");
|
||||
assertThat(mTaggedDataCaptor.getAllValues()).containsExactly(
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -304,18 +357,46 @@ public class DashboardAdapterTest {
|
||||
mDashboardAdapter.onBindSuggestionConditionHeader(mSuggestionHolder, mSuggestionHeaderData);
|
||||
mSuggestionHolder.itemView.callOnClick();
|
||||
mDashboardAdapter.onPause();
|
||||
|
||||
verify(mFactory.metricsFeatureProvider, times(4)).action(
|
||||
any(Context.class), mActionCategoryCaptor.capture(),
|
||||
mActionPackageCaptor.capture());
|
||||
String[] expectedPackages = new String[]{"pkg1", "pkg1", "pkg1", "pkg1"};
|
||||
Integer[] expectedActions = new Integer[]{
|
||||
mActionPackageCaptor.capture(),
|
||||
mTaggedDataCaptor.capture());
|
||||
assertThat(mActionCategoryCaptor.getAllValues()).containsExactly(
|
||||
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);
|
||||
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION);
|
||||
assertThat(mActionPackageCaptor.getAllValues()).containsExactly(
|
||||
"pkg1", "pkg1", "pkg1", "pkg1");
|
||||
assertThat(mTaggedDataCaptor.getAllValues()).containsExactly(
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuggestionsLogs_SmartSuggestionEnabled() {
|
||||
when(mFactory.suggestionsFeatureProvider
|
||||
.isSmartSuggestionEnabled(any(Context.class))).thenReturn(true);
|
||||
setupSuggestions(makeSuggestions("pkg1"));
|
||||
|
||||
mDashboardAdapter.onBindSuggestionConditionHeader(mSuggestionHolder, mSuggestionHeaderData);
|
||||
mSuggestionHolder.itemView.callOnClick();
|
||||
mDashboardAdapter.onPause();
|
||||
|
||||
verify(mFactory.metricsFeatureProvider, times(2)).action(
|
||||
any(Context.class), mActionCategoryCaptor.capture(),
|
||||
mActionPackageCaptor.capture(),
|
||||
mTaggedDataCaptor.capture());
|
||||
assertThat(mActionCategoryCaptor.getAllValues()).containsExactly(
|
||||
MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
|
||||
MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION);
|
||||
assertThat(mActionPackageCaptor.getAllValues()).containsExactly("pkg1", "pkg1");
|
||||
assertThat(mTaggedDataCaptor.getAllValues()).containsExactly(
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 1),
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -35,7 +35,9 @@ import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.provider.Settings.Secure;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Settings.AmbientDisplayPickupSuggestionActivity;
|
||||
@@ -60,6 +62,8 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
@@ -93,6 +97,8 @@ public class SuggestionFeatureProviderImplTest {
|
||||
private FingerprintManager mFingerprintManager;
|
||||
@Mock
|
||||
private SharedPreferences mSharedPreferences;
|
||||
@Captor
|
||||
private ArgumentCaptor<Pair> mTaggedDataCaptor = ArgumentCaptor.forClass(Pair.class);
|
||||
|
||||
private FakeFeatureFactory mFactory;
|
||||
private SuggestionFeatureProviderImpl mProvider;
|
||||
@@ -335,7 +341,10 @@ public class SuggestionFeatureProviderImplTest {
|
||||
verify(mFactory.metricsFeatureProvider).action(
|
||||
eq(mContext),
|
||||
eq(MetricsProto.MetricsEvent.ACTION_SETTINGS_DISMISS_SUGGESTION),
|
||||
anyString());
|
||||
anyString(),
|
||||
mTaggedDataCaptor.capture());
|
||||
assertThat(mTaggedDataCaptor.getAllValues()).containsExactly(
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0));
|
||||
verify(mContext, never()).getPackageManager();
|
||||
}
|
||||
|
||||
@@ -356,8 +365,10 @@ public class SuggestionFeatureProviderImplTest {
|
||||
verify(mFactory.metricsFeatureProvider).action(
|
||||
eq(mContext),
|
||||
eq(MetricsProto.MetricsEvent.ACTION_SETTINGS_DISMISS_SUGGESTION),
|
||||
anyString());
|
||||
|
||||
anyString(),
|
||||
mTaggedDataCaptor.capture());
|
||||
assertThat(mTaggedDataCaptor.getAllValues()).containsExactly(
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0));
|
||||
verify(mContext.getPackageManager())
|
||||
.setComponentEnabledSetting(mSuggestion.intent.getComponent(),
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
||||
|
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.dashboard.suggestions;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.util.Pair;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class SuggestionLogHelperTest {
|
||||
|
||||
@Test
|
||||
public void testGetSmartSuggestionEnabledTaggedData_disabled() {
|
||||
assertThat(SuggestionLogHelper.getSuggestionTaggedData(false)).asList().containsExactly(
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSmartSuggestionEnabledTaggedData_enabled() {
|
||||
assertThat(SuggestionLogHelper.getSuggestionTaggedData(true)).asList().containsExactly(
|
||||
Pair.create(MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, 1));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user