2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.mediaframeworktest.functional;
20 //import android.content.Resources;
21 import android.util.Log;
23 import android.media.ToneGenerator;
24 import android.media.AudioManager;
27 * Junit / Instrumentation test case for the Sim tones tests
30 public class TonesAutoTest {
31 private static String TAG = "TonesAutoTest";
33 // Test all DTMF tones one by one
34 public static boolean tonesDtmfTest() throws Exception {
35 Log.v(TAG, "DTMF tones test");
36 ToneGenerator toneGen;
38 boolean result = true;
40 toneGen = new ToneGenerator(AudioManager.STREAM_MUSIC, 100);
42 for (type = ToneGenerator.TONE_DTMF_0; type <= ToneGenerator.TONE_DTMF_D; type++) {
43 if (toneGen.startTone(type)) {
57 // Test all supervisory tones one by one
58 public static boolean tonesSupervisoryTest() throws Exception {
59 Log.v(TAG, "Supervisory tones test");
60 ToneGenerator toneGen;
62 boolean result = true;
64 toneGen = new ToneGenerator(AudioManager.STREAM_MUSIC, 100);
66 for (type = ToneGenerator.TONE_SUP_DIAL;
67 type <= ToneGenerator.TONE_SUP_RINGTONE; type++) {
68 if (toneGen.startTone(type)) {
78 for (type = ToneGenerator.TONE_SUP_INTERCEPT;
79 type <= ToneGenerator.TONE_SUP_PIP; type++) {
80 if (toneGen.startTone(type)) {
94 // Test all proprietary tones one by one
95 public static boolean tonesProprietaryTest() throws Exception {
96 Log.v(TAG, "Proprietary tones test");
97 ToneGenerator toneGen;
99 boolean result = true;
101 toneGen = new ToneGenerator(AudioManager.STREAM_MUSIC, 100);
103 for (type = ToneGenerator.TONE_PROP_BEEP; type <= ToneGenerator.TONE_PROP_BEEP2; type++) {
104 if (toneGen.startTone(type)) {
118 // Test playback of 2 tones simultaneously
119 public static boolean tonesSimultaneousTest() throws Exception {
120 Log.v(TAG, "Simultaneous tones test");
121 ToneGenerator toneGen1;
122 ToneGenerator toneGen2;
124 boolean result = true;
126 toneGen1 = new ToneGenerator(AudioManager.STREAM_MUSIC, 100);
127 toneGen2 = new ToneGenerator(AudioManager.STREAM_MUSIC, 50);
129 if (toneGen1.startTone(ToneGenerator.TONE_DTMF_1)) {
131 if (toneGen2.startTone(ToneGenerator.TONE_DTMF_2)) {
149 // Test start of new tone without stopping previous one
150 public static boolean tonesStressTest() throws Exception {
151 Log.v(TAG, "Stress tones test");
152 ToneGenerator toneGen;
154 boolean result = true;
156 toneGen = new ToneGenerator(AudioManager.STREAM_MUSIC, 100);
158 for (type = ToneGenerator.TONE_DTMF_1; type <= ToneGenerator.TONE_DTMF_9; type++) {
159 if (toneGen.startTone(type)) {
171 // Perform all tones tests
172 public static boolean tonesAllTest() throws Exception {
173 Log.v(TAG, "All tones tests");
175 if (!tonesDtmfTest()) {
178 if (!tonesSupervisoryTest()) {
181 if (!tonesProprietaryTest()) {
184 if (!tonesSimultaneousTest()) {
187 if (!tonesStressTest()) {