Search in sources :

Example 1 with PhoneAccountHandle

use of android.telecom.PhoneAccountHandle in project robolectric by robolectric.

the class ShadowTelecomManagerTest method clearAccounts.

@Test
public void clearAccounts() {
    PhoneAccountHandle anotherPackageHandle = createHandle("some.other.package", "id");
    telecomService.registerPhoneAccount(PhoneAccount.builder(anotherPackageHandle, "another_package").build());
}
Also used : PhoneAccountHandle(android.telecom.PhoneAccountHandle) Test(org.junit.Test)

Example 2 with PhoneAccountHandle

use of android.telecom.PhoneAccountHandle in project robolectric by robolectric.

the class ShadowTelecomManagerTest method getSimCallManager.

@Test
public void getSimCallManager() {
    PhoneAccountHandle handle = createHandle("id");
    shadowOf(telecomService).setSimCallManager(handle);
    assertThat(telecomService.getConnectionManager().getId()).isEqualTo("id");
}
Also used : PhoneAccountHandle(android.telecom.PhoneAccountHandle) Test(org.junit.Test)

Example 3 with PhoneAccountHandle

use of android.telecom.PhoneAccountHandle in project robolectric by robolectric.

the class ShadowTelecomManagerTest method getPhoneAccountsForPackage.

@Test
@Config(minSdk = LOLLIPOP_MR1)
public void getPhoneAccountsForPackage() {
    PhoneAccountHandle handleInThisApplicationsPackage = createHandle("id1");
    telecomService.registerPhoneAccount(PhoneAccount.builder(handleInThisApplicationsPackage, "this_package").build());
    PhoneAccountHandle anotherPackageHandle = createHandle("some.other.package", "id2");
    telecomService.registerPhoneAccount(PhoneAccount.builder(anotherPackageHandle, "another_package").build());
    List<PhoneAccountHandle> phoneAccountsForPackage = telecomService.getPhoneAccountsForPackage();
    assertThat(phoneAccountsForPackage).contains(handleInThisApplicationsPackage);
    assertThat(phoneAccountsForPackage).doesNotContain(anotherPackageHandle);
}
Also used : PhoneAccountHandle(android.telecom.PhoneAccountHandle) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 4 with PhoneAccountHandle

use of android.telecom.PhoneAccountHandle in project robolectric by robolectric.

the class ShadowTelecomManagerTest method registerAndUnRegister.

@Test
public void registerAndUnRegister() {
    assertThat(shadowOf(telecomService).getAllPhoneAccountsCount()).isEqualTo(0);
    assertThat(shadowOf(telecomService).getAllPhoneAccounts()).hasSize(0);
    PhoneAccountHandle handler = createHandle("id");
    PhoneAccount phoneAccount = PhoneAccount.builder(handler, "main_account").build();
    telecomService.registerPhoneAccount(phoneAccount);
    assertThat(shadowOf(telecomService).getAllPhoneAccountsCount()).isEqualTo(1);
    assertThat(shadowOf(telecomService).getAllPhoneAccounts()).hasSize(1);
    assertThat(telecomService.getAllPhoneAccountHandles()).hasSize(1);
    assertThat(telecomService.getAllPhoneAccountHandles()).contains(handler);
    assertThat(telecomService.getPhoneAccount(handler).getLabel()).isEqualTo(phoneAccount.getLabel());
    telecomService.unregisterPhoneAccount(handler);
    assertThat(shadowOf(telecomService).getAllPhoneAccountsCount()).isEqualTo(0);
    assertThat(shadowOf(telecomService).getAllPhoneAccounts()).hasSize(0);
    assertThat(telecomService.getAllPhoneAccountHandles()).hasSize(0);
}
Also used : PhoneAccount(android.telecom.PhoneAccount) PhoneAccountHandle(android.telecom.PhoneAccountHandle) Test(org.junit.Test)

Example 5 with PhoneAccountHandle

use of android.telecom.PhoneAccountHandle in project robolectric by robolectric.

the class ShadowTelecomManagerTest method getPhoneAccountsSupportingScheme.

@Test
public void getPhoneAccountsSupportingScheme() {
    PhoneAccountHandle handleMatchingScheme = createHandle("id1");
    telecomService.registerPhoneAccount(PhoneAccount.builder(handleMatchingScheme, "some_scheme").addSupportedUriScheme("some_scheme").build());
    PhoneAccountHandle handleNotMatchingScheme = createHandle("id2");
    telecomService.registerPhoneAccount(PhoneAccount.builder(handleNotMatchingScheme, "another_scheme").addSupportedUriScheme("another_scheme").build());
    List<PhoneAccountHandle> actual = telecomService.getPhoneAccountsSupportingScheme("some_scheme");
    assertThat(actual).contains(handleMatchingScheme);
    assertThat(actual).doesNotContain(handleNotMatchingScheme);
}
Also used : PhoneAccountHandle(android.telecom.PhoneAccountHandle) Test(org.junit.Test)

Aggregations

PhoneAccountHandle (android.telecom.PhoneAccountHandle)49 PhoneAccount (android.telecom.PhoneAccount)17 TelecomManager (android.telecom.TelecomManager)14 ComponentName (android.content.ComponentName)9 Test (org.junit.Test)7 UserHandle (android.os.UserHandle)5 PackageManagerInternal (android.content.pm.PackageManagerInternal)4 SubscriptionInfo (android.telephony.SubscriptionInfo)4 TelephonyManager (android.telephony.TelephonyManager)4 IntArray (android.util.IntArray)4 Config (org.robolectric.annotation.Config)3 AlertDialog (android.app.AlertDialog)2 Context (android.content.Context)2 DialogInterface (android.content.DialogInterface)2 LinkedList (java.util.LinkedList)2 Implementation (org.robolectric.annotation.Implementation)2 Dialog (android.app.Dialog)1 Resources (android.content.res.Resources)1 SwitchPreference (android.support.v14.preference.SwitchPreference)1 Preference (android.support.v7.preference.Preference)1