### Question:
OkHttpProtocolNegotiator { public String getSelectedProtocol(SSLSocket socket) { return platform.getSelectedProtocol(socket); } @VisibleForTesting  OkHttpProtocolNegotiator(Platform platform); static OkHttpProtocolNegotiator get(); String negotiate(
      SSLSocket sslSocket, String hostname, @Nullable List<Protocol> protocols); String getSelectedProtocol(SSLSocket socket);  }### Answer:
@Test public void getSelectedProtocol_alpn() throws Exception { when(platform.getTlsExtensionType()).thenReturn(TlsExtensionType.ALPN_AND_NPN); AndroidNegotiator negotiator = new AndroidNegotiator(platform); FakeAndroidSslSocket androidSock = new FakeAndroidSslSocketAlpn(); String actual = negotiator.getSelectedProtocol(androidSock); assertEquals("h2", actual); }
@Test public void getSelectedProtocol_npn() throws Exception { when(platform.getTlsExtensionType()).thenReturn(TlsExtensionType.NPN); AndroidNegotiator negotiator = new AndroidNegotiator(platform); FakeAndroidSslSocket androidSock = new FakeAndroidSslSocketNpn(); String actual = negotiator.getSelectedProtocol(androidSock); assertEquals("h2", actual); }
@Test public void getSelectedProtocol_alpn() throws Exception { AndroidNegotiator negotiator = new AndroidNegotiator(platform, TlsExtensionType.ALPN_AND_NPN); FakeAndroidSslSocket androidSock = new FakeAndroidSslSocketAlpn(); String actual = negotiator.getSelectedProtocol(androidSock); assertEquals("h2", actual); }
@Test public void getSelectedProtocol_npn() throws Exception { AndroidNegotiator negotiator = new AndroidNegotiator(platform, TlsExtensionType.NPN); FakeAndroidSslSocket androidSock = new FakeAndroidSslSocketNpn(); String actual = negotiator.getSelectedProtocol(androidSock); assertEquals("h2", actual); }