Merge changes Icd3d09aa,I4b070964

* changes:
  Include IPv6 DNS servers in wifi details
  Separate multiple DNS addresses with newlines.
This commit is contained in:
Treehugger Robot
2017-09-14 08:10:25 +00:00
committed by Gerrit Code Review
2 changed files with 11 additions and 6 deletions

View File

@@ -415,11 +415,10 @@ public class WifiDetailPreferenceController extends PreferenceController impleme
}
}
// Find IPv4 DNS addresses.
// Find all (IPv4 and IPv6) DNS addresses.
String dnsServers = mLinkProperties.getDnsServers().stream()
.filter(Inet4Address.class::isInstance)
.map(InetAddress::getHostAddress)
.collect(Collectors.joining(","));
.collect(Collectors.joining("\n"));
// Update UI.
updatePreference(mIpAddressPref, ipv4Address);

View File

@@ -402,10 +402,14 @@ public class WifiDetailPreferenceControllerTest {
public void dnsServersPref_shouldHaveDetailTextSet() throws UnknownHostException {
mLinkProperties.addDnsServer(InetAddress.getByAddress(new byte[]{8,8,4,4}));
mLinkProperties.addDnsServer(InetAddress.getByAddress(new byte[]{8,8,8,8}));
mLinkProperties.addDnsServer(Constants.IPV6_DNS);
displayAndResume();
verify(mockDnsPref).setDetailText("8.8.4.4,8.8.8.8");
verify(mockDnsPref).setDetailText(
"8.8.4.4\n" +
"8.8.8.8\n" +
Constants.IPV6_DNS.getHostAddress());
}
@Test
@@ -511,13 +515,15 @@ public class WifiDetailPreferenceControllerTest {
lp.addDnsServer(Constants.IPV6_DNS);
updateLinkProperties(lp);
inOrder.verify(mockDnsPref, never()).setVisible(true);
inOrder.verify(mockDnsPref).setDetailText(Constants.IPV6_DNS.getHostAddress());
inOrder.verify(mockDnsPref).setVisible(true);
lp.addDnsServer(Constants.IPV4_DNS1);
lp.addDnsServer(Constants.IPV4_DNS2);
updateLinkProperties(lp);
inOrder.verify(mockDnsPref).setDetailText(
Constants.IPV4_DNS1.getHostAddress() + "," +
Constants.IPV6_DNS.getHostAddress() + "\n" +
Constants.IPV4_DNS1.getHostAddress() + "\n" +
Constants.IPV4_DNS2.getHostAddress());
inOrder.verify(mockDnsPref).setVisible(true);
}