• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (C) 2016 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.cellbroadcastreceiver;
18 
19 import android.telephony.CarrierConfigManager;
20 import android.test.suitebuilder.annotation.SmallTest;
21 
22 import com.android.cellbroadcastreceiver.CellBroadcastAlertAudio.ToneType;
23 import com.android.cellbroadcastreceiver.CellBroadcastOtherChannelsManager.CellBroadcastChannelRange;
24 
25 import org.junit.After;
26 import org.junit.Before;
27 import org.junit.Test;
28 
29 import java.util.ArrayList;
30 
31 import static junit.framework.Assert.assertEquals;
32 
33 /**
34  * APN retry manager tests
35  */
36 public class CellBroadcastOtherChannelsManagerTest extends CellBroadcastTest {
37 
38     @Before
setUp()39     public void setUp() throws Exception {
40         super.setUp(getClass().getSimpleName());
41     }
42 
43     @After
tearDown()44     public void tearDown() throws Exception {
45         super.tearDown();
46     }
47 
48     /**
49      * Test getting cell broadcast additional channels from Carrier Config.
50      */
51     @Test
52     @SmallTest
testGetCellBroadcastChannelRanges()53     public void testGetCellBroadcastChannelRanges() throws Exception {
54         int subId = 1;
55         carrierConfigSetStringArray(subId,
56                 CarrierConfigManager.KEY_CARRIER_ADDITIONAL_CBS_CHANNELS_STRINGS,
57                 new String[]{
58                         "12:type=earthquake",
59                         "456:type=tsunami",
60                         "0xAC00-0xAFED:type=other",
61                         "54-60"});
62         ArrayList<CellBroadcastChannelRange> list = CellBroadcastOtherChannelsManager.getInstance().
63                 getCellBroadcastChannelRanges(mContext, subId);
64 
65         assertEquals(12, list.get(0).mStartId);
66         assertEquals(12, list.get(0).mEndId);
67         assertEquals(ToneType.EARTHQUAKE, list.get(0).mToneType);
68 
69         assertEquals(456, list.get(1).mStartId);
70         assertEquals(456, list.get(1).mEndId);
71         assertEquals(ToneType.TSUNAMI, list.get(1).mToneType);
72 
73         assertEquals(0xAC00, list.get(2).mStartId);
74         assertEquals(0xAFED, list.get(2).mEndId);
75         assertEquals(ToneType.OTHER, list.get(2).mToneType);
76 
77         assertEquals(54, list.get(3).mStartId);
78         assertEquals(60, list.get(3).mEndId);
79         assertEquals(ToneType.CMAS_DEFAULT, list.get(3).mToneType);
80     }
81 }
82