1 /* 2 * Copyright (C) 2015 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.telecom.cts; 18 19 import static android.telecom.cts.TestUtils.shouldTestTelecom; 20 21 import android.net.Uri; 22 import android.telecom.Connection; 23 import android.telecom.ConnectionRequest; 24 import android.telecom.PhoneAccount; 25 import android.telecom.PhoneAccountHandle; 26 27 /** 28 * Tests that certain numbers make their way through to the connection service. 29 */ 30 public class NumberDialingTest extends BaseTelecomTestWithMockServices { 31 32 /** 33 * Amount of time to wait for an asynchronous method invocation to ConnectionService. 34 */ 35 private static final int CS_WAIT_MILLIS = 2000; 36 37 public void testEndInPound() throws Exception { 38 if (!mShouldTestTelecom) { 39 return; 40 } 41 42 final Object[] res = new Object[1]; 43 Uri address = Uri.fromParts("tel", "*1234#", null); 44 45 PhoneAccount account = setupConnectionService( 46 new MockConnectionService() { 47 @Override 48 public Connection onCreateOutgoingConnection( 49 PhoneAccountHandle connectionManagerPhoneAccount, 50 ConnectionRequest request) { 51 res[0] = request.getAddress(); 52 synchronized(res) { 53 res.notify(); 54 } 55 return null; // do not actually place the call. 56 } 57 58 }, FLAG_REGISTER | FLAG_ENABLE); 59 60 startCallTo(address, account.getAccountHandle()); 61 synchronized(res) { 62 res.wait(CS_WAIT_MILLIS); 63 } 64 assertEquals(address, res[0]); 65 } 66 } 67