1 /*
2  * Copyright (C) 2020 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 
17 package android.dynamicmime.testapp.assertions;
18 
19 import static android.dynamicmime.common.Constants.PACKAGE_HELPER_APP;
20 import static android.dynamicmime.common.Constants.PACKAGE_UPDATE_APP;
21 
22 import android.content.Context;
23 
24 import org.junit.Assert;
25 
26 import java.util.Set;
27 
28 public abstract class AssertionsByGroupData extends MimeGroupAssertions {
29     @Override
assertMatchedByMimeGroup(String mimeGroup, String mimeType)30     public void assertMatchedByMimeGroup(String mimeGroup, String mimeType) {
31         // We cannot check if type is matched by group via group info from PackageManager
32     }
33 
34     @Override
assertNotMatchedByMimeGroup(String mimeGroup, String mimeType)35     public void assertNotMatchedByMimeGroup(String mimeGroup, String mimeType) {
36         // We cannot check if type is matched by group via group info from PackageManager
37     }
38 
39     @Override
assertMimeGroupInternal(String mimeGroup, Set<String> mimeTypes)40     public void assertMimeGroupInternal(String mimeGroup, Set<String> mimeTypes) {
41         Assert.assertEquals(getMimeGroup(mimeGroup), mimeTypes);
42     }
43 
getMimeGroup(String mimeGroup)44     protected abstract Set<String> getMimeGroup(String mimeGroup);
45 
testApp(Context context)46     public static MimeGroupAssertions testApp(Context context) {
47         return new TestAppAssertionsByGroupData(context);
48     }
49 
helperApp(Context context)50     public static MimeGroupAssertions helperApp(Context context) {
51         return new AppAssertionsByGroupData(context, PACKAGE_HELPER_APP);
52     }
53 
appWithUpdates(Context context)54     public static MimeGroupAssertions appWithUpdates(Context context) {
55         return new AppAssertionsByGroupData(context, PACKAGE_UPDATE_APP);
56     }
57 }
58