1 /*
2  * Copyright 2019 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 com.android.mediatunertest;
18 
19 import static org.junit.Assert.assertNotNull;
20 
21 import android.content.Context;
22 import android.content.pm.PackageManager;
23 import android.media.tv.TvInputService;
24 import android.media.tv.tuner.Descrambler;
25 import android.media.tv.tuner.Tuner;
26 
27 import androidx.test.InstrumentationRegistry;
28 import androidx.test.filters.SmallTest;
29 import androidx.test.runner.AndroidJUnit4;
30 
31 import com.android.compatibility.common.util.RequiredFeatureRule;
32 
33 import org.junit.After;
34 import org.junit.Before;
35 import org.junit.Rule;
36 import org.junit.Test;
37 import org.junit.runner.RunWith;
38 
39 @RunWith(AndroidJUnit4.class)
40 @SmallTest
41 // TODO: (b/174500129) add TEST_MAPPING on TunerTest when TunerService is ready
42 public class TunerTest {
43     private static final String TAG = "MediaTunerTest";
44 
45     @Rule
46     public RequiredFeatureRule featureRule = new RequiredFeatureRule(
47             PackageManager.FEATURE_TUNER);
48 
49     private Context mContext;
50 
51     @Before
setUp()52     public void setUp() throws Exception {
53         mContext = InstrumentationRegistry.getTargetContext();
54     }
55 
56     @After
tearDown()57     public void tearDown() {
58     }
59 
60     @Test
testTunerConstructor()61     public void testTunerConstructor() throws Exception {
62         Tuner tuner = new Tuner(mContext, null,
63                 TvInputService.PRIORITY_HINT_USE_CASE_TYPE_BACKGROUND);
64         assertNotNull(tuner);
65     }
66 
67     @Test
testOpenDescrambler()68     public void testOpenDescrambler() throws Exception {
69         Tuner tuner = new Tuner(mContext, null,
70                 TvInputService.PRIORITY_HINT_USE_CASE_TYPE_BACKGROUND);
71         Descrambler descrambler = tuner.openDescrambler();
72         assertNotNull(descrambler);
73     }
74 }
75