• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package android.provider.cts;
17 
18 import static junit.framework.Assert.assertNotNull;
19 
20 import static org.junit.Assert.assertEquals;
21 
22 import android.provider.FontRequest;
23 import android.util.Base64;
24 
25 import androidx.test.filters.SmallTest;
26 import androidx.test.runner.AndroidJUnit4;
27 
28 import org.junit.Test;
29 import org.junit.runner.RunWith;
30 
31 import java.util.Arrays;
32 import java.util.List;
33 
34 /**
35  * Tests for {@link android.provider.FontRequest}.
36  */
37 @SmallTest
38 @RunWith(AndroidJUnit4.class)
39 public class FontRequestTest {
40     private static final String PROVIDER = "com.test.fontprovider.authority";
41     private static final String QUERY = "query";
42     private static final String PACKAGE = "com.test.fontprovider.package";
43     private static final byte[] BYTE_ARRAY =
44             Base64.decode("e04fd020ea3a6910a2d808002b30", Base64.DEFAULT);
45     private static final List<List<byte[]>> CERTS = Arrays.asList(Arrays.asList(BYTE_ARRAY));
46 
47 
48     @Test(expected = NullPointerException.class)
testShortConstructor_nullAuthority()49     public void testShortConstructor_nullAuthority() {
50         new FontRequest(null, PACKAGE, QUERY);
51     }
52 
53     @Test(expected = NullPointerException.class)
testShortConstructor_nullPackage()54     public void testShortConstructor_nullPackage() {
55         new FontRequest(PROVIDER, null, QUERY);
56     }
57 
58     @Test(expected = NullPointerException.class)
testShortConstructor_nullQuery()59     public void testShortConstructor_nullQuery() {
60         new FontRequest(PROVIDER, PACKAGE, null);
61     }
62 
63     @Test
testShortConstructor_defaults()64     public void testShortConstructor_defaults() {
65         // WHEN we create a request with the short constructor
66         FontRequest request = new FontRequest(PROVIDER, PACKAGE, QUERY);
67 
68         // THEN we expect the defaults to be the following values
69         assertNotNull(request.getCertificates());
70         assertEquals(0, request.getCertificates().size());
71     }
72 
73     @Test(expected = NullPointerException.class)
testLongConstructor_nullAuthority()74     public void testLongConstructor_nullAuthority() {
75         new FontRequest(null, PACKAGE, QUERY, CERTS);
76     }
77 
78     @Test(expected = NullPointerException.class)
testLongConstructor_nullPackage()79     public void testLongConstructor_nullPackage() {
80         new FontRequest(PROVIDER, null, QUERY, CERTS);
81     }
82 
83     @Test(expected = NullPointerException.class)
testLongConstructor_nullQuery()84     public void testLongConstructor_nullQuery() {
85         new FontRequest(PROVIDER, PACKAGE, null, CERTS);
86     }
87 
88     @Test(expected = NullPointerException.class)
testLongConstructor_nullCerts()89     public void testLongConstructor_nullCerts() {
90         new FontRequest(PROVIDER, PACKAGE, QUERY, null);
91     }
92 }
93