Log source with visibility change
- Add a method in VisibilityLoggerMixin to log visible event using LogMaker, which allows logging additional FIELD_CONTEXT field. - In Utils.startFragment, add current page's metricsCategory as an extra to next page. - In next page's onResume(), extract the previous page's metricsCategory and send it to VisibilityLoggerMixin.visible() - Update all caller with additional paramters Change-Id: I8e1f2597fa465b7d3aa16fa1d21c052a3219694a Fix: 35359289 Test: RunSettingsRoboTests
This commit is contained in:
@@ -98,7 +98,8 @@ public class DashboardFeatureProviderImplTest {
|
||||
tile.metaData = new Bundle();
|
||||
tile.metaData.putString(SettingsActivity.META_DATA_KEY_FRAGMENT_CLASS, "HI");
|
||||
tile.priority = 10;
|
||||
mImpl.bindPreferenceToTile(mActivity, preference, tile, "123", Preference.DEFAULT_ORDER);
|
||||
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
|
||||
preference, tile, "123", Preference.DEFAULT_ORDER);
|
||||
|
||||
assertThat(preference.getTitle()).isEqualTo(tile.title);
|
||||
assertThat(preference.getSummary()).isEqualTo(tile.summary);
|
||||
@@ -118,7 +119,8 @@ public class DashboardFeatureProviderImplTest {
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
|
||||
mImpl.bindPreferenceToTile(mActivity, preference, tile, "123", Preference.DEFAULT_ORDER);
|
||||
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
|
||||
preference, tile, "123", Preference.DEFAULT_ORDER);
|
||||
|
||||
assertThat(preference.getFragment()).isNull();
|
||||
assertThat(preference.getOnPreferenceClickListener()).isNotNull();
|
||||
@@ -140,7 +142,8 @@ public class DashboardFeatureProviderImplTest {
|
||||
when(mActivity.getSystemService(Context.USER_SERVICE))
|
||||
.thenReturn(mUserManager);
|
||||
|
||||
mImpl.bindPreferenceToTile(mActivity, preference, tile, "123", Preference.DEFAULT_ORDER);
|
||||
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
|
||||
preference, tile, "123", Preference.DEFAULT_ORDER);
|
||||
preference.getOnPreferenceClickListener().onPreferenceClick(null);
|
||||
|
||||
verify(mActivity).getFragmentManager();
|
||||
@@ -160,7 +163,8 @@ public class DashboardFeatureProviderImplTest {
|
||||
when(mActivity.getSystemService(Context.USER_SERVICE))
|
||||
.thenReturn(mUserManager);
|
||||
|
||||
mImpl.bindPreferenceToTile(mActivity, preference, tile, "123", Preference.DEFAULT_ORDER);
|
||||
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
|
||||
preference, tile, "123", Preference.DEFAULT_ORDER);
|
||||
preference.getOnPreferenceClickListener().onPreferenceClick(null);
|
||||
verify(mFeatureFactory.metricsFeatureProvider).action(
|
||||
any(Context.class),
|
||||
@@ -177,8 +181,8 @@ public class DashboardFeatureProviderImplTest {
|
||||
final Tile tile = new Tile();
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
mImpl.bindPreferenceToTile(mActivity, preference, tile, null /* key */
|
||||
, Preference.DEFAULT_ORDER);
|
||||
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
|
||||
preference, tile, null /*key */, Preference.DEFAULT_ORDER);
|
||||
|
||||
assertThat(preference.getKey()).isNotNull();
|
||||
assertThat(preference.getOrder()).isEqualTo(Preference.DEFAULT_ORDER);
|
||||
@@ -192,8 +196,8 @@ public class DashboardFeatureProviderImplTest {
|
||||
tile.key = "key";
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
mImpl.bindPreferenceToTile(mActivity, preference, tile, null /* key */
|
||||
, Preference.DEFAULT_ORDER);
|
||||
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
|
||||
preference, tile, null /* key */, Preference.DEFAULT_ORDER);
|
||||
|
||||
assertThat(preference.getKey()).isEqualTo(tile.key);
|
||||
}
|
||||
@@ -206,7 +210,8 @@ public class DashboardFeatureProviderImplTest {
|
||||
final Tile tile = new Tile();
|
||||
tile.metaData = new Bundle();
|
||||
tile.priority = 10;
|
||||
mImpl.bindPreferenceToTile(mActivity, preference, tile, "123", baseOrder);
|
||||
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
|
||||
preference, tile, "123", baseOrder);
|
||||
|
||||
assertThat(preference.getOrder()).isEqualTo(-tile.priority + baseOrder);
|
||||
}
|
||||
@@ -223,12 +228,16 @@ public class DashboardFeatureProviderImplTest {
|
||||
tile.metaData = new Bundle();
|
||||
tile.metaData.putString("com.android.settings.intent.action", "TestAction");
|
||||
tile.userHandle = null;
|
||||
mImpl.bindPreferenceToTile(activity, preference, tile, "123", Preference.DEFAULT_ORDER);
|
||||
mImpl.bindPreferenceToTile(activity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
|
||||
preference, tile, "123", Preference.DEFAULT_ORDER);
|
||||
preference.performClick();
|
||||
ShadowActivity shadowActivity = shadowOf(activity);
|
||||
|
||||
assertThat(shadowActivity.getNextStartedActivityForResult().intent.getAction())
|
||||
final Intent launchIntent = shadowActivity.getNextStartedActivityForResult().intent;
|
||||
assertThat(launchIntent.getAction())
|
||||
.isEqualTo("TestAction");
|
||||
assertThat(launchIntent.getIntExtra(SettingsActivity.EXTRA_SOURCE_METRICS_CATEGORY, 0))
|
||||
.isEqualTo(MetricsProto.MetricsEvent.SETTINGS_GESTURES);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -236,7 +245,8 @@ public class DashboardFeatureProviderImplTest {
|
||||
final DashboardFeatureProviderImpl mSpy = spy(mImpl);
|
||||
when(mSpy.isEnabled()).thenReturn(false);
|
||||
|
||||
assertThat(mSpy.getPreferencesForCategory(null, null, CategoryKey.CATEGORY_HOMEPAGE))
|
||||
assertThat(mSpy.getPreferencesForCategory(null, null,
|
||||
MetricsProto.MetricsEvent.SETTINGS_GESTURES, CategoryKey.CATEGORY_HOMEPAGE))
|
||||
.isNull();
|
||||
}
|
||||
|
||||
@@ -248,7 +258,8 @@ public class DashboardFeatureProviderImplTest {
|
||||
when(mCategoryManager.getTilesByCategory(mActivity, CategoryKey.CATEGORY_HOMEPAGE))
|
||||
.thenReturn(null);
|
||||
|
||||
assertThat(mSpy.getPreferencesForCategory(null, null, CategoryKey.CATEGORY_HOMEPAGE))
|
||||
assertThat(mSpy.getPreferencesForCategory(null, null,
|
||||
MetricsProto.MetricsEvent.SETTINGS_GESTURES, CategoryKey.CATEGORY_HOMEPAGE))
|
||||
.isNull();
|
||||
}
|
||||
|
||||
@@ -260,7 +271,8 @@ public class DashboardFeatureProviderImplTest {
|
||||
when(mCategoryManager.getTilesByCategory(mActivity, CategoryKey.CATEGORY_HOMEPAGE))
|
||||
.thenReturn(new DashboardCategory());
|
||||
|
||||
assertThat(mSpy.getPreferencesForCategory(null, null, CategoryKey.CATEGORY_HOMEPAGE))
|
||||
assertThat(mSpy.getPreferencesForCategory(null, null,
|
||||
MetricsProto.MetricsEvent.SETTINGS_GESTURES, CategoryKey.CATEGORY_HOMEPAGE))
|
||||
.isNull();
|
||||
}
|
||||
|
||||
@@ -277,6 +289,7 @@ public class DashboardFeatureProviderImplTest {
|
||||
|
||||
assertThat(mSpy.getPreferencesForCategory(mActivity,
|
||||
ShadowApplication.getInstance().getApplicationContext(),
|
||||
MetricsProto.MetricsEvent.SETTINGS_GESTURES,
|
||||
CategoryKey.CATEGORY_HOMEPAGE).isEmpty())
|
||||
.isFalse();
|
||||
}
|
||||
|
Reference in New Issue
Block a user