Merge "Update language to comply with Android’s inclusive language guidance" am: f366f37aa1 am: 5383e257e2
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1372976 Change-Id: Ic3ef5f4df089968c4105fec48c9c494c57f1f608
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<!-- testFromJsonString -->
|
<!-- testFromJsonString -->
|
||||||
<string name="blacklist_json_string" translatable="false">
|
<string name="blocklist_json_string" translatable="false">
|
||||||
{
|
{
|
||||||
\"entries\":[
|
\"entries\":[
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -47,32 +47,32 @@ public class KeyRevocationListTest {
|
|||||||
|
|
||||||
private static Context sContext;
|
private static Context sContext;
|
||||||
|
|
||||||
private static String sBlacklistJsonString;
|
private static String sBlocklistJsonString;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpClass() throws Exception {
|
public static void setUpClass() throws Exception {
|
||||||
sContext = InstrumentationRegistry.getInstrumentation().getContext();
|
sContext = InstrumentationRegistry.getInstrumentation().getContext();
|
||||||
sBlacklistJsonString =
|
sBlocklistJsonString =
|
||||||
sContext.getString(com.android.dynsystem.tests.R.string.blacklist_json_string);
|
sContext.getString(com.android.dynsystem.tests.R.string.blocklist_json_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public void testFromJsonString() throws JSONException {
|
public void testFromJsonString() throws JSONException {
|
||||||
KeyRevocationList blacklist;
|
KeyRevocationList blocklist;
|
||||||
blacklist = KeyRevocationList.fromJsonString(sBlacklistJsonString);
|
blocklist = KeyRevocationList.fromJsonString(sBlocklistJsonString);
|
||||||
Assert.assertNotNull(blacklist);
|
Assert.assertNotNull(blocklist);
|
||||||
Assert.assertFalse(blacklist.mEntries.isEmpty());
|
Assert.assertFalse(blocklist.mEntries.isEmpty());
|
||||||
blacklist = KeyRevocationList.fromJsonString("{}");
|
blocklist = KeyRevocationList.fromJsonString("{}");
|
||||||
Assert.assertNotNull(blacklist);
|
Assert.assertNotNull(blocklist);
|
||||||
Assert.assertTrue(blacklist.mEntries.isEmpty());
|
Assert.assertTrue(blocklist.mEntries.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public void testFromUrl() throws IOException, JSONException {
|
public void testFromUrl() throws IOException, JSONException {
|
||||||
URLConnection mockConnection = mock(URLConnection.class);
|
URLConnection mockConnection = mock(URLConnection.class);
|
||||||
doReturn(new ByteArrayInputStream(sBlacklistJsonString.getBytes()))
|
doReturn(new ByteArrayInputStream(sBlocklistJsonString.getBytes()))
|
||||||
.when(mockConnection).getInputStream();
|
.when(mockConnection).getInputStream();
|
||||||
URL mockUrl = new URL(
|
URL mockUrl = new URL(
|
||||||
"http", // protocol
|
"http", // protocol
|
||||||
@@ -97,36 +97,36 @@ public class KeyRevocationListTest {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
KeyRevocationList blacklist = KeyRevocationList.fromUrl(mockUrl);
|
KeyRevocationList blocklist = KeyRevocationList.fromUrl(mockUrl);
|
||||||
Assert.assertNotNull(blacklist);
|
Assert.assertNotNull(blocklist);
|
||||||
Assert.assertFalse(blacklist.mEntries.isEmpty());
|
Assert.assertFalse(blocklist.mEntries.isEmpty());
|
||||||
|
|
||||||
blacklist = null;
|
blocklist = null;
|
||||||
try {
|
try {
|
||||||
blacklist = KeyRevocationList.fromUrl(mockBadUrl);
|
blocklist = KeyRevocationList.fromUrl(mockBadUrl);
|
||||||
// Up should throw, down should be unreachable
|
// Up should throw, down should be unreachable
|
||||||
Assert.fail("Expected IOException not thrown");
|
Assert.fail("Expected IOException not thrown");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// This is expected, do nothing
|
// This is expected, do nothing
|
||||||
}
|
}
|
||||||
Assert.assertNull(blacklist);
|
Assert.assertNull(blocklist);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public void testIsRevoked() {
|
public void testIsRevoked() {
|
||||||
KeyRevocationList blacklist = new KeyRevocationList();
|
KeyRevocationList blocklist = new KeyRevocationList();
|
||||||
blacklist.addEntry("key1", "REVOKED", "reason for key1");
|
blocklist.addEntry("key1", "REVOKED", "reason for key1");
|
||||||
|
|
||||||
KeyRevocationList.RevocationStatus revocationStatus =
|
KeyRevocationList.RevocationStatus revocationStatus =
|
||||||
blacklist.getRevocationStatusForKey("key1");
|
blocklist.getRevocationStatusForKey("key1");
|
||||||
Assert.assertNotNull(revocationStatus);
|
Assert.assertNotNull(revocationStatus);
|
||||||
Assert.assertEquals(revocationStatus.mReason, "reason for key1");
|
Assert.assertEquals(revocationStatus.mReason, "reason for key1");
|
||||||
|
|
||||||
revocationStatus = blacklist.getRevocationStatusForKey("key2");
|
revocationStatus = blocklist.getRevocationStatusForKey("key2");
|
||||||
Assert.assertNull(revocationStatus);
|
Assert.assertNull(revocationStatus);
|
||||||
|
|
||||||
Assert.assertTrue(blacklist.isRevoked("key1"));
|
Assert.assertTrue(blocklist.isRevoked("key1"));
|
||||||
Assert.assertFalse(blacklist.isRevoked("key2"));
|
Assert.assertFalse(blocklist.isRevoked("key2"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user