1 // Copyright 2021 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 package org.chromium.net; 6 7 import android.os.Build; 8 9 import androidx.test.filters.MediumTest; 10 11 import org.junit.Assert; 12 import org.junit.Test; 13 import org.junit.runner.RunWith; 14 15 import org.chromium.base.test.BaseJUnit4ClassRunner; 16 import org.chromium.base.test.util.Batch; 17 import org.chromium.base.test.util.MinAndroidSdkLevel; 18 19 @RunWith(BaseJUnit4ClassRunner.class) 20 @Batch(Batch.UNIT_TESTS) 21 public class AndroidNetworkLibraryTest { 22 @Test 23 @MediumTest 24 @MinAndroidSdkLevel(Build.VERSION_CODES.M) testGetDnsStatus_searchDomains()25 public void testGetDnsStatus_searchDomains() { 26 DnsStatus dnsStatus = AndroidNetworkLibrary.getDnsStatus(/* network= */ null); 27 if (dnsStatus == null) { 28 return; 29 } 30 31 String searchDomains = dnsStatus.getSearchDomains(); 32 if (searchDomains == null || searchDomains.isEmpty()) { 33 return; 34 } 35 36 // Expect a comma-separated list of unknown length. 37 String[] domains = searchDomains.split(","); 38 for (String domain : domains) { 39 Assert.assertNotEquals("", domain); 40 } 41 } 42 } 43