diff options
| author | 2022-12-08 18:03:35 +0000 | |
|---|---|---|
| committer | 2022-12-08 18:03:35 +0000 | |
| commit | 12becfbc745f2bd9ab065c03ac6f4b5cf6267de8 (patch) | |
| tree | 2a6acae4c6b2b6070cbd6aaa1a02b66925d2eff1 /java | |
| parent | 92269439a35e7bc3b81c7e7efdef7ae0b63a6637 (diff) | |
| parent | 167c65e1a3dc527036a1cbf517989b747cc76614 (diff) | |
Merge "Fix flakey unit test" into tm-qpr-dev
Diffstat (limited to 'java')
| -rw-r--r-- | java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java b/java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java index 28b68530..ff166fb7 100644 --- a/java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java +++ b/java/tests/src/com/android/intentresolver/UnbundledChooserActivityTest.java @@ -46,6 +46,7 @@ import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; @@ -775,7 +776,7 @@ public class UnbundledChooserActivityTest { } @Test - public void copyTextToClipboardLogging() throws Exception { + public void copyTextToClipboardLogging() { Intent sendIntent = createSendTextIntent(); List<ResolvedComponentInfo> resolvedComponentInfos = createResolvedComponentsForTest(2); @@ -797,12 +798,16 @@ public class UnbundledChooserActivityTest { verify(mockLogger, atLeastOnce()).write(logMakerCaptor.capture()); // The last captured event is the selection of the target. - assertThat(logMakerCaptor.getValue().getCategory(), - is(MetricsEvent.ACTION_ACTIVITY_CHOOSER_PICKED_SYSTEM_TARGET)); + boolean containsTargetEvent = logMakerCaptor.getAllValues() + .stream() + .anyMatch(item -> + item.getCategory() + == MetricsEvent.ACTION_ACTIVITY_CHOOSER_PICKED_SYSTEM_TARGET); + assertTrue( + "ACTION_ACTIVITY_CHOOSER_PICKED_SYSTEM_TARGET is expected", containsTargetEvent); assertThat(logMakerCaptor.getValue().getSubtype(), is(1)); } - @Test @Ignore public void testNearbyShareLogging() throws Exception { |