@Test public void testShouldReceiveAnEventWhenDeviceIsConnectedToWifiWithInternetAccess() throws InterruptedException { // given connectivityChangeEvents.clear(); boolean connectedToInternet = true; NetworkState.status = ConnectivityStatus.UNKNOWN; Object eventCatcher = TestUtils.getConnectivityEventCatcher(connectivityChangeEvents); busWrapper.register(eventCatcher); // when onPostReceiveAndSleep(connectedToInternet); // then ConnectivityStatus expectedConnectivityStatus = ConnectivityStatus.WIFI_CONNECTED_HAS_INTERNET; assertExpectedStatusEqualsCurrent(expectedConnectivityStatus, eventCatcher); }
@Test public void testShouldReceiveAnEventWhenDeviceIsConnectedToWifiWithNoInternetAccess() throws InterruptedException { // given connectivityChangeEvents.clear(); boolean connectedToInternet = false; NetworkState.status = ConnectivityStatus.UNKNOWN; Object eventCatcher = TestUtils.getConnectivityEventCatcher(connectivityChangeEvents); busWrapper.register(eventCatcher); // when onPostReceiveAndSleep(connectedToInternet); // then ConnectivityStatus expectedStatus = ConnectivityStatus.WIFI_CONNECTED_HAS_NO_INTERNET; assertExpectedStatusEqualsCurrent(expectedStatus, eventCatcher); }