From f54fc26af70d5ee42d7c67398e8fb645a80d8dd5 Mon Sep 17 00:00:00 2001 From: Tomasz Wasilczyk Date: Tue, 22 Jan 2019 14:55:39 -0800 Subject: Don't over-specify testcases with verifyNoMoreInteractions. In this specific case, there is a race condition between verify(...).onProgramInfoChanged(...) and verifyNoMoreInteractions call. As it's being called in the middle of the testcases, it's not possible to pull the callback from the radio service to prevent the race condition. However, Mockito docs ask to not overuse this method for over-specification of the tests, so let's just comply with what the doc says. Bug: 122715569 Test: atest BroadcastRadioTests Change-Id: I978b13c7c7607773f12cc5a3a9f72f782fb3f345 --- .../hardware/radio/tests/functional/RadioTunerTest.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/core/tests/BroadcastRadioTests/src/android/hardware/radio/tests/functional/RadioTunerTest.java b/core/tests/BroadcastRadioTests/src/android/hardware/radio/tests/functional/RadioTunerTest.java index d2bd1e172ee2..11eb158317e9 100644 --- a/core/tests/BroadcastRadioTests/src/android/hardware/radio/tests/functional/RadioTunerTest.java +++ b/core/tests/BroadcastRadioTests/src/android/hardware/radio/tests/functional/RadioTunerTest.java @@ -18,13 +18,13 @@ package android.hardware.radio.tests.functional; import static org.junit.Assert.*; import static org.junit.Assume.*; import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyBoolean; +import static org.mockito.Matchers.anyInt; import static org.mockito.Mockito.after; -import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.atMost; import static org.mockito.Mockito.never; import static org.mockito.Mockito.timeout; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.testng.Assert.assertThrows; import android.Manifest; @@ -119,10 +119,9 @@ public class RadioTunerTest { } private void resetCallback() { - verify(mCallback, atLeast(0)).onMetadataChanged(any()); - verify(mCallback, atLeast(0)).onProgramInfoChanged(any()); - verify(mCallback, atLeast(0)).onProgramListChanged(); - verifyNoMoreInteractions(mCallback); + verify(mCallback, never()).onError(anyInt()); + verify(mCallback, never()).onTuneFailed(anyInt(), any()); + verify(mCallback, never()).onControlChanged(anyBoolean()); Mockito.reset(mCallback); } -- cgit v1.2.3-59-g8ed1b