Test for copy action logging

Adding a test case that checks the new logging introduced by ag/9385993
for copy action within sharesheet

Bug: 140928181
Test: This is the test
Change-Id: I9511919134ca8b6db5beb1fd454b208387216169
This commit is contained in:
Susi Kharraz-Post
2019-09-19 11:20:01 -04:00
parent 069fed9b7f
commit 9e91318615

View File

@@ -480,6 +480,36 @@ public class ChooserActivityTest {
assertThat("text/plain", is(clipDescription.getMimeType(0)));
}
@Test
public void copyTextToClipboardLogging() throws Exception {
Intent sendIntent = createSendTextIntent();
List<ResolvedComponentInfo> resolvedComponentInfos = createResolvedComponentsForTest(2);
when(ChooserWrapperActivity.sOverrides.resolverListController.getResolversForIntent(
Mockito.anyBoolean(),
Mockito.anyBoolean(),
Mockito.isA(List.class))).thenReturn(resolvedComponentInfos);
MetricsLogger mockLogger = sOverrides.metricsLogger;
ArgumentCaptor<LogMaker> logMakerCaptor = ArgumentCaptor.forClass(LogMaker.class);
final ChooserWrapperActivity activity = mActivityRule
.launchActivity(Intent.createChooser(sendIntent, null));
waitForIdle();
onView(withId(R.id.copy_button)).check(matches(isDisplayed()));
onView(withId(R.id.copy_button)).perform(click());
verify(mockLogger, atLeastOnce()).write(logMakerCaptor.capture());
// First is Activity shown, Second is "with preview"
assertThat(logMakerCaptor.getAllValues().get(2).getCategory(),
is(MetricsEvent.ACTION_ACTIVITY_CHOOSER_PICKED_SYSTEM_TARGET));
assertThat(logMakerCaptor
.getAllValues().get(2)
.getSubtype(),
is(1));
}
@Test
public void oneVisibleImagePreview() throws InterruptedException {
Uri uri = Uri.parse("android.resource://com.android.frameworks.coretests/"