### Question:
CompanionProxyShard implements Closeable { @MainThread public void startNetwork() { DebugAssert.isMainThread(); maybeLogDebug("startNetwork()"); mHandler.sendEmptyMessage(WHAT_START_SYSPROXY); } CompanionProxyShard(
            @NonNull final Context context,
            @NonNull final ProxyServiceHelper proxyServiceHelper,
            @NonNull final BluetoothDevice companionDevice,
            @NonNull final Listener listener,
            final int networkScore); @MainThread @Override // Closable void close(); @MainThread void startNetwork(); @MainThread void updateNetwork(final int networkScore); void dump(@NonNull final IndentingPrintWriter ipw);  }### Answer:
@Test public void testStartNetwork_WasConnectedWithWifiInternet() { connectNetworkWithWifiInternet(); verify(mockCompanionProxyShardListener).onProxyConnectionChange(CONNECTED, NETWORK_SCORE, WITH_INTERNET); mCompanionProxyShard.startNetwork(); ShadowLooper.runMainLooperOneTask(); verify(mockCompanionProxyShardListener, times(2)).onProxyConnectionChange(CONNECTED, NETWORK_SCORE, WITH_INTERNET); verify(mockProxyServiceHelper, times(2)).startNetworkSession(anyString(), anyObject()); ensureMessageQueueEmpty(); }
@Test public void testStartNetwork_WasConnectedNoInternet() { connectNetworkNoInternet(); verify(mockCompanionProxyShardListener).onProxyConnectionChange(CONNECTED, NETWORK_SCORE, NO_INTERNET); mCompanionProxyShard.startNetwork(); ShadowLooper.runMainLooperOneTask(); verify(mockCompanionProxyShardListener, times(2)).onProxyConnectionChange(CONNECTED, NETWORK_SCORE, NO_INTERNET); verify(mockProxyServiceHelper, times(2)).stopNetworkSession(anyString()); ensureMessageQueueEmpty(); }
@Test public void testStartNetwork_Closed() { connectNetworkWithWifiInternet(); mCompanionProxyShard.mIsClosed = true; mCompanionProxyShard.startNetwork(); ShadowLooper.runMainLooperOneTask(); verify(mockProxyServiceHelper).getNetworkScore(); assertEquals(1, mCompanionProxyShard.mStartAttempts); ensureMessageQueueEmpty(); }
@Test public void testResetConnection_SysproxyConnected() { connectNetworkWithWifiInternet(); setWaitingForAsyncDiconnectResponse(true); try { mCompanionProxyShard.startNetwork(); ShadowLooper.runMainLooperOneTask(); assertTrue(mCompanionProxyShard.mHandler.hasMessages(WHAT_RESET_CONNECTION)); ShadowLooper.runUiThreadTasksIncludingDelayedTasks(); assertEquals(1, mCompanionProxyShard.connectNativeCount); assertEquals(1, mCompanionProxyShard.disconnectNativeCount); assertEquals(mCompanionProxyShard.disconnectReturnValue, getWaitingForAsyncDiconnectResponse()); } finally { setWaitingForAsyncDiconnectResponse(false); } }