Home | History | Annotate | Download | only in telephony
      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 package com.android.internal.telephony;
     17 
     18 import android.media.ToneGenerator;
     19 import android.test.suitebuilder.annotation.SmallTest;
     20 import com.android.internal.telephony.cdma.SignalToneUtil;
     21 import org.junit.Test;
     22 import static org.junit.Assert.assertEquals;
     23 
     24 public class SignalToneUtilTest {
     25     /* no need to initialization, everything is static */
     26     @Test
     27     @SmallTest
     28     public void testSignalToneUtil() {
     29         int audioToneResult = SignalToneUtil.getAudioToneFromSignalInfo(
     30                 SignalToneUtil.IS95_CONST_IR_SIGNAL_IS54B,
     31                 SignalToneUtil.IS95_CONST_IR_ALERT_LOW,
     32                 SignalToneUtil.IS95_CONST_IR_SIG_IS54B_L);
     33         assertEquals(ToneGenerator.TONE_CDMA_LOW_L, audioToneResult);
     34 
     35         audioToneResult = SignalToneUtil.getAudioToneFromSignalInfo(
     36                 SignalToneUtil.IS95_CONST_IR_SIGNAL_TONE,
     37                 SignalToneUtil.IS95_CONST_IR_ALERT_LOW,
     38                 SignalToneUtil.IS95_CONST_IR_SIG_TONE_DIAL);
     39         assertEquals(ToneGenerator.TONE_CDMA_DIAL_TONE_LITE, audioToneResult);
     40         /* if signal type is not IS54B, different alert pitch all map to
     41            SIGNAL_PITCH_UNKNOWN, expect get same result
     42          */
     43         audioToneResult = SignalToneUtil.getAudioToneFromSignalInfo(
     44                 SignalToneUtil.IS95_CONST_IR_SIGNAL_TONE,
     45                 SignalToneUtil.IS95_CONST_IR_ALERT_HIGH,
     46                 SignalToneUtil.IS95_CONST_IR_SIG_TONE_DIAL);
     47         assertEquals(ToneGenerator.TONE_CDMA_DIAL_TONE_LITE, audioToneResult);
     48         audioToneResult = SignalToneUtil.getAudioToneFromSignalInfo(
     49                 SignalToneUtil.IS95_CONST_IR_SIGNAL_TONE,
     50                 SignalToneUtil.TAPIAMSSCDMA_SIGNAL_PITCH_UNKNOWN,
     51                 SignalToneUtil.IS95_CONST_IR_SIG_TONE_DIAL);
     52         assertEquals(ToneGenerator.TONE_CDMA_DIAL_TONE_LITE, audioToneResult);
     53     }
     54 
     55     @SmallTest
     56     @Test
     57     public void testSignalToneUtilInvalidInput() {
     58         int audioToneResult = SignalToneUtil.getAudioToneFromSignalInfo(
     59                 SignalToneUtil.CDMA_INVALID_TONE,
     60                 SignalToneUtil.IS95_CONST_IR_ALERT_HIGH,
     61                 SignalToneUtil.IS95_CONST_IR_SIG_TONE_DIAL);
     62         assertEquals(SignalToneUtil.CDMA_INVALID_TONE, audioToneResult);
     63 
     64         audioToneResult = SignalToneUtil.getAudioToneFromSignalInfo(
     65                 SignalToneUtil.IS95_CONST_IR_SIGNAL_TONE,
     66                 SignalToneUtil.CDMA_INVALID_TONE,
     67                 SignalToneUtil.IS95_CONST_IR_SIG_TONE_DIAL);
     68         assertEquals(SignalToneUtil.CDMA_INVALID_TONE, audioToneResult);
     69 
     70         audioToneResult = SignalToneUtil.getAudioToneFromSignalInfo(
     71                 SignalToneUtil.IS95_CONST_IR_SIGNAL_TONE,
     72                 SignalToneUtil.IS95_CONST_IR_ALERT_HIGH,
     73                 SignalToneUtil.CDMA_INVALID_TONE);
     74         assertEquals(SignalToneUtil.CDMA_INVALID_TONE, audioToneResult);
     75     }
     76 }
     77