diff options
author | Luis Vidal <lvidal@cyngn.com> | 2016-06-16 15:48:41 -0700 |
---|---|---|
committer | Luis Vidal <lvidal@cyngn.com> | 2016-06-16 16:05:42 -0700 |
commit | b25a32413c96bff5ad36786e32f490cd772e70ef (patch) | |
tree | 7bbd1fea2bab3dc248f8ccde7f9f1068dee375e4 /tests | |
parent | 3251a4506fb6cda6f8699e6abe78de06b33dc465 (diff) | |
download | vendor_cmsdk-b25a32413c96bff5ad36786e32f490cd772e70ef.zip vendor_cmsdk-b25a32413c96bff5ad36786e32f490cd772e70ef.tar.gz vendor_cmsdk-b25a32413c96bff5ad36786e32f490cd772e70ef.tar.bz2 |
Weather API test: Wait for a bit before Mockito verifies if method was called
Sometimes the runnable posted to runOnServiceThread() might run a bit
faster than the calls made to the mocked weather provider, which causes
Mockito to throw an exception. Add a timeout to instruct Mockito to
wait for a bit before it verifies if the method was actually called.
Also removed an unused variable in CMWeatherManagerTest
TICKET: CYNGNOS-3043
Change-Id: I53b6541aeb571a6c83d1c26b6723d74c3661e8cc
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/org/cyanogenmod/tests/weather/unit/CMWeatherManagerTest.java | 1 | ||||
-rw-r--r-- | tests/src/org/cyanogenmod/tests/weather/unit/WeatherProviderServiceTest.java | 13 |
2 files changed, 7 insertions, 7 deletions
diff --git a/tests/src/org/cyanogenmod/tests/weather/unit/CMWeatherManagerTest.java b/tests/src/org/cyanogenmod/tests/weather/unit/CMWeatherManagerTest.java index c382d3f..3453c77 100644 --- a/tests/src/org/cyanogenmod/tests/weather/unit/CMWeatherManagerTest.java +++ b/tests/src/org/cyanogenmod/tests/weather/unit/CMWeatherManagerTest.java @@ -46,7 +46,6 @@ public class CMWeatherManagerTest extends AndroidTestCase { private static final int REQUEST_ID = 42; private static final String MOCKED_WEATHER_PROVIDER_LABEL = "Mock'd Weather Service"; private ICMWeatherManager.Stub mICMWeatherManagerSpy; - private static final String DESCRIPTOR = "cyanogenmod.weather.ICMWeatherManager"; @Override protected void setUp() throws Exception { diff --git a/tests/src/org/cyanogenmod/tests/weather/unit/WeatherProviderServiceTest.java b/tests/src/org/cyanogenmod/tests/weather/unit/WeatherProviderServiceTest.java index 958dce4..fd1e2ff 100644 --- a/tests/src/org/cyanogenmod/tests/weather/unit/WeatherProviderServiceTest.java +++ b/tests/src/org/cyanogenmod/tests/weather/unit/WeatherProviderServiceTest.java @@ -45,6 +45,7 @@ public class WeatherProviderServiceTest extends ThreadServiceTestCase<MockWeathe } private static final String CITY_NAME = "Seattle"; + private static final int TIMEOUT = 5000; public void testCityNameLookupRequest() throws Exception { IBinder binder = bindService((ServiceRunnable) null); @@ -61,7 +62,7 @@ public class WeatherProviderServiceTest extends ThreadServiceTestCase<MockWeathe ArgumentCaptor<ServiceRequest> params = ArgumentCaptor.forClass(ServiceRequest.class); - Mockito.verify(getService().getCallTracker(), Mockito.times(1)) + Mockito.verify(getService().getCallTracker(), Mockito.timeout(TIMEOUT).times(1)) .onRequestSubmitted(params.capture()); ServiceRequest request = params.getValue(); @@ -88,7 +89,7 @@ public class WeatherProviderServiceTest extends ThreadServiceTestCase<MockWeathe ArgumentCaptor<ServiceRequest> params = ArgumentCaptor.forClass(ServiceRequest.class); - Mockito.verify(getService().getCallTracker(), Mockito.times(1)) + Mockito.verify(getService().getCallTracker(), Mockito.timeout(TIMEOUT).times(1)) .onRequestSubmitted(params.capture()); ServiceRequest request = params.getValue(); @@ -117,7 +118,7 @@ public class WeatherProviderServiceTest extends ThreadServiceTestCase<MockWeathe ArgumentCaptor<ServiceRequest> params = ArgumentCaptor.forClass(ServiceRequest.class); - Mockito.verify(getService().getCallTracker(), Mockito.times(1)) + Mockito.verify(getService().getCallTracker(), Mockito.timeout(TIMEOUT).times(1)) .onRequestSubmitted(params.capture()); ServiceRequest request = params.getValue(); @@ -211,7 +212,7 @@ public class WeatherProviderServiceTest extends ThreadServiceTestCase<MockWeathe ArgumentCaptor<ServiceRequest> params = ArgumentCaptor.forClass(ServiceRequest.class); - Mockito.verify(getService().getCallTracker(), Mockito.times(1)) + Mockito.verify(getService().getCallTracker(), Mockito.timeout(TIMEOUT).times(1)) .onRequestSubmitted(params.capture()); ServiceRequest request = params.getValue(); @@ -227,7 +228,7 @@ public class WeatherProviderServiceTest extends ThreadServiceTestCase<MockWeathe ArgumentCaptor<ServiceRequest> params = ArgumentCaptor.forClass(ServiceRequest.class); - Mockito.verify(getService().getCallTracker(), Mockito.times(1)) + Mockito.verify(getService().getCallTracker(), Mockito.timeout(TIMEOUT).times(1)) .onRequestSubmitted(params.capture()); ServiceRequest request = params.getValue(); @@ -243,7 +244,7 @@ public class WeatherProviderServiceTest extends ThreadServiceTestCase<MockWeathe ArgumentCaptor<ServiceRequest> params = ArgumentCaptor.forClass(ServiceRequest.class); - Mockito.verify(getService().getCallTracker(), Mockito.times(1)) + Mockito.verify(getService().getCallTracker(), Mockito.timeout(TIMEOUT).times(1)) .onRequestSubmitted(params.capture()); ServiceRequest request = params.getValue(); |