Search in sources :

Example 56 with Config

use of org.robolectric.annotation.Config in project robolectric by robolectric.

the class ShadowSoundPoolTest method shouldCreateSoundPool_JellyBean.

@Test
@Config(maxSdk = JELLY_BEAN_MR2)
public void shouldCreateSoundPool_JellyBean() {
    SoundPool soundPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
    assertThat(soundPool).isNotNull();
}
Also used : SoundPool(android.media.SoundPool) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 57 with Config

use of org.robolectric.annotation.Config in project robolectric by robolectric.

the class ShadowRelativeLayoutTest method getRules_shouldShowAddRuleData_uptoApiLevel16.

@Test
@Config(maxSdk = JELLY_BEAN)
public void getRules_shouldShowAddRuleData_uptoApiLevel16() throws Exception {
    ImageView imageView = new ImageView(RuntimeEnvironment.application);
    RelativeLayout layout = new RelativeLayout(RuntimeEnvironment.application);
    layout.addView(imageView, new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) imageView.getLayoutParams();
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    layoutParams.addRule(RelativeLayout.ALIGN_TOP, 1234);
    int[] rules = layoutParams.getRules();
    assertThat(rules).isEqualTo(new int[] { 0, 0, 0, 0, 0, 0, 1234, 0, 0, 0, 0, -1, 0, 0, 0, 0 });
}
Also used : RelativeLayout(android.widget.RelativeLayout) ImageView(android.widget.ImageView) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 58 with Config

use of org.robolectric.annotation.Config in project robolectric by robolectric.

the class ShadowResourcesTest method shouldLoadRawResources_supportsDrawableWithQualifiers.

@Test
@Config(qualifiers = "hdpi")
public void shouldLoadRawResources_supportsDrawableWithQualifiers() throws Exception {
    InputStream resourceStream = resources.openRawResource(R.drawable.text_file_posing_as_image);
    assertThat(resourceStream).isNotNull();
    assertThat(TestUtil.readString(resourceStream)).isEqualTo("drawable-hdpi.png image\n");
}
Also used : InputStream(java.io.InputStream) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 59 with Config

use of org.robolectric.annotation.Config 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 60 with Config

use of org.robolectric.annotation.Config in project robolectric by robolectric.

the class ShadowTelephonyManagerTest method shouldGiveAllCellInfo.

@Test
@Config(minSdk = JELLY_BEAN_MR1)
public void shouldGiveAllCellInfo() {
    TelephonyManager telephonyManager = (TelephonyManager) application.getSystemService(TELEPHONY_SERVICE);
    ShadowTelephonyManager shadowTelephonyManager = shadowOf(telephonyManager);
    List<CellInfo> allCellInfo = new ArrayList<CellInfo>();
    shadowTelephonyManager.setAllCellInfo(allCellInfo);
    assertEquals(allCellInfo, telephonyManager.getAllCellInfo());
}
Also used : CellInfo(android.telephony.CellInfo) TelephonyManager(android.telephony.TelephonyManager) ArrayList(java.util.ArrayList) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Aggregations

Config (org.robolectric.annotation.Config)158 Test (org.junit.Test)153 Intent (android.content.Intent)21 ComponentName (android.content.ComponentName)16 Bundle (android.os.Bundle)10 Activity (android.app.Activity)7 Bitmap (android.graphics.Bitmap)7 Notification (android.app.Notification)6 Button (android.widget.Button)6 TextView (android.widget.TextView)6 BuildConfig (com.firebase.ui.auth.BuildConfig)6 BuildConfig (com.onesignal.BuildConfig)6 ShadowRecyclerView (io.github.hidroh.materialistic.test.shadow.ShadowRecyclerView)6 SlowTest (io.github.hidroh.materialistic.test.suite.SlowTest)6 Properties (java.util.Properties)6 Account (android.accounts.Account)5 Network (android.net.Network)5 NetworkInfo (android.net.NetworkInfo)5 RecyclerView (android.support.v7.widget.RecyclerView)5 BitmapDrawable (android.graphics.drawable.BitmapDrawable)4