@Test public void testOnConnectionTimeout() throws Exception { Field handlerField = connectionManager.getClass().getDeclaredField("mHandler"); handlerField.setAccessible(true); handlerField.set(connectionManager, mHander); connectionManager.onConnectionTimeout(mMockPeerProperties); verify(mHander, atLeastOnce()) .post(isA(Runnable.class)); }
@Override public void onConnectionTimeout(final PeerProperties peerProperties) { if (peerProperties != null) { Log.e(TAG, "onConnectionTimeout: Connection attempt with peer " + peerProperties + " timed out"); } else { Log.e(TAG, "onConnectionTimeout"); } if (mListener != null) { mHandler.post(new Runnable() { @Override public void run() { mListener.onConnectionTimeout(peerProperties); } }); } }
ConnectionManager extends AbstractBluetoothConnectivityAgent implements
        BluetoothConnector.BluetoothConnectorListener,
        ConnectionManagerSettings.Listener,
        DiscoveryManagerSettings.Listener { @Override public void onConnectionTimeout(final PeerProperties peerProperties) { if (peerProperties != null) { Log.e(TAG, "onConnectionTimeout: Connection attempt with peer " + peerProperties + " timed out"); } else { Log.e(TAG, "onConnectionTimeout"); } if (mListener != null) { mHandler.post(new Runnable() { @Override public void run() { mListener.onConnectionTimeout(peerProperties); } }); } } }
ConnectionManager extends AbstractBluetoothConnectivityAgent implements
        BluetoothConnector.BluetoothConnectorListener,
        ConnectionManagerSettings.Listener,
        DiscoveryManagerSettings.Listener { @Override public void onConnectionTimeout(final PeerProperties peerProperties) { if (peerProperties != null) { Log.e(TAG, "onConnectionTimeout: Connection attempt with peer " + peerProperties + " timed out"); } else { Log.e(TAG, "onConnectionTimeout"); } if (mListener != null) { mHandler.post(new Runnable() { @Override public void run() { mListener.onConnectionTimeout(peerProperties); } }); } } ConnectionManager(
            Context context, ConnectionManagerListener listener,
            UUID myUuid, String myName);  ConnectionManager(
            Context context, ConnectionManagerListener listener,
            UUID myUuid, String myName, BluetoothManager bluetoothManager,
            SharedPreferences preferences); }
ConnectionManager extends AbstractBluetoothConnectivityAgent implements
        BluetoothConnector.BluetoothConnectorListener,
        ConnectionManagerSettings.Listener,
        DiscoveryManagerSettings.Listener { @Override public void onConnectionTimeout(final PeerProperties peerProperties) { if (peerProperties != null) { Log.e(TAG, "onConnectionTimeout: Connection attempt with peer " + peerProperties + " timed out"); } else { Log.e(TAG, "onConnectionTimeout"); } if (mListener != null) { mHandler.post(new Runnable() { @Override public void run() { mListener.onConnectionTimeout(peerProperties); } }); } } ConnectionManager(
            Context context, ConnectionManagerListener listener,
            UUID myUuid, String myName);  ConnectionManager(
            Context context, ConnectionManagerListener listener,
            UUID myUuid, String myName, BluetoothManager bluetoothManager,
            SharedPreferences preferences); ConnectionManagerState getState(); synchronized boolean startListeningForIncomingConnections(); synchronized void stopListeningForIncomingConnections(); synchronized boolean connect(PeerProperties peerToConnectTo); synchronized boolean cancelConnectionAttempt(PeerProperties peerConnectingTo); synchronized void cancelAllConnectionAttempts(); @Override void dispose(); @Override void onConnectionManagerSettingsChanged(); @Override void onHandshakeRequiredSettingChanged(boolean handshakeRequired); @Override void onBluetoothAdapterScanModeChanged(int mode); @Override void onBluetoothAdapterStateChanged(int state); @Override void onIsServerStartedChanged(boolean isStarted); @Override void onConnecting(String bluetoothDeviceName, String bluetoothDeviceAddress); @Override void onConnected(
            final BluetoothSocket bluetoothSocket, final boolean isIncoming,
            final PeerProperties peerProperties); @Override void onConnectionTimeout(final PeerProperties peerProperties); @Override void onConnectionFailed(final PeerProperties peerProperties, final String errorMessage); @Override void onDiscoveryModeChanged(DiscoveryManager.DiscoveryMode discoveryMode, boolean startIfNotRunning); @Override void onPeerExpirationSettingChanged(long peerExpirationInMilliseconds); @Override void onAdvertiseScanSettingsChanged(); @Override void onPeerExtraInfoChanged(int newExtraInfo); @Override boolean setExtraInfo(int extraInfo); }
ConnectionManager extends AbstractBluetoothConnectivityAgent implements
        BluetoothConnector.BluetoothConnectorListener,
        ConnectionManagerSettings.Listener,
        DiscoveryManagerSettings.Listener { @Override public void onConnectionTimeout(final PeerProperties peerProperties) { if (peerProperties != null) { Log.e(TAG, "onConnectionTimeout: Connection attempt with peer " + peerProperties + " timed out"); } else { Log.e(TAG, "onConnectionTimeout"); } if (mListener != null) { mHandler.post(new Runnable() { @Override public void run() { mListener.onConnectionTimeout(peerProperties); } }); } } ConnectionManager(
            Context context, ConnectionManagerListener listener,
            UUID myUuid, String myName);  ConnectionManager(
            Context context, ConnectionManagerListener listener,
            UUID myUuid, String myName, BluetoothManager bluetoothManager,
            SharedPreferences preferences); ConnectionManagerState getState(); synchronized boolean startListeningForIncomingConnections(); synchronized void stopListeningForIncomingConnections(); synchronized boolean connect(PeerProperties peerToConnectTo); synchronized boolean cancelConnectionAttempt(PeerProperties peerConnectingTo); synchronized void cancelAllConnectionAttempts(); @Override void dispose(); @Override void onConnectionManagerSettingsChanged(); @Override void onHandshakeRequiredSettingChanged(boolean handshakeRequired); @Override void onBluetoothAdapterScanModeChanged(int mode); @Override void onBluetoothAdapterStateChanged(int state); @Override void onIsServerStartedChanged(boolean isStarted); @Override void onConnecting(String bluetoothDeviceName, String bluetoothDeviceAddress); @Override void onConnected(
            final BluetoothSocket bluetoothSocket, final boolean isIncoming,
            final PeerProperties peerProperties); @Override void onConnectionTimeout(final PeerProperties peerProperties); @Override void onConnectionFailed(final PeerProperties peerProperties, final String errorMessage); @Override void onDiscoveryModeChanged(DiscoveryManager.DiscoveryMode discoveryMode, boolean startIfNotRunning); @Override void onPeerExpirationSettingChanged(long peerExpirationInMilliseconds); @Override void onAdvertiseScanSettingsChanged(); @Override void onPeerExtraInfoChanged(int newExtraInfo); @Override boolean setExtraInfo(int extraInfo);  }