diff options
| author | 2022-12-02 15:17:20 -0800 | |
|---|---|---|
| committer | 2022-12-02 15:17:20 -0800 | |
| commit | 167c65e1a3dc527036a1cbf517989b747cc76614 (patch) | |
| tree | bba4cb4cbeff661a1f404acc4fb10038d22af9d0 /java/tests/src | |
| parent | d293b3b3102ef5e3944422fd6bc2cbe7109edf36 (diff) | |
Fix flakey unit test
The test sometime failed locally apparently due to concurrency with
shortcut loading logic.
Test: the test itself
Change-Id: I2bd3bc5df194814dfca021b2010d863a375deb7c
Diffstat (limited to 'java/tests/src')
| -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 da72a749..81a5897d 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; @@ -774,7 +775,7 @@ public class UnbundledChooserActivityTest { } @Test - public void copyTextToClipboardLogging() throws Exception { + public void copyTextToClipboardLogging() { Intent sendIntent = createSendTextIntent(); List<ResolvedComponentInfo> resolvedComponentInfos = createResolvedComponentsForTest(2); @@ -796,12 +797,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 { |