Search in sources :

Example 46 with UiThreadTest

use of androidx.test.annotation.UiThreadTest in project iterable-android-sdk by Iterable.

the class IterableInAppTest method testGetLocationCenter.

@Test
@UiThreadTest
public void testGetLocationCenter() {
    Rect padding = new Rect(0, -1, 0, -1);
    int verticalLocation = notification.getVerticalLocation(padding);
    assertEquals(Gravity.CENTER_VERTICAL, verticalLocation);
}
Also used : Rect(android.graphics.Rect) MediumTest(androidx.test.filters.MediumTest) UiThreadTest(androidx.test.annotation.UiThreadTest) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 47 with UiThreadTest

use of androidx.test.annotation.UiThreadTest in project iterable-android-sdk by Iterable.

the class IterableInAppTest method testGetLocationFull.

@Test
@UiThreadTest
public void testGetLocationFull() {
    Rect padding = new Rect(0, 0, 0, 0);
    int verticalLocation = notification.getVerticalLocation(padding);
    assertEquals(Gravity.CENTER_VERTICAL, verticalLocation);
}
Also used : Rect(android.graphics.Rect) MediumTest(androidx.test.filters.MediumTest) UiThreadTest(androidx.test.annotation.UiThreadTest) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 48 with UiThreadTest

use of androidx.test.annotation.UiThreadTest in project android_packages_apps_Settings by omnirom.

the class ChannelListPreferenceControllerTest method testUpdateFullList_channelUpdates.

@Test
@UiThreadTest
public void testUpdateFullList_channelUpdates() {
    List<NotificationChannelGroup> inGroups = new ArrayList<>();
    NotificationChannelGroup inGroup = new NotificationChannelGroup("group", "Group");
    NotificationChannel channelA = new NotificationChannel("channelA", "Channel A", IMPORTANCE_HIGH);
    NotificationChannel channelB = new NotificationChannel("channelB", "Channel B", IMPORTANCE_NONE);
    inGroup.addChannel(channelA);
    inGroup.addChannel(channelB);
    inGroups.add(inGroup);
    NotificationsSentState sentA = new NotificationsSentState();
    sentA.avgSentDaily = 2;
    sentA.avgSentWeekly = 10;
    NotificationsSentState sentB = new NotificationsSentState();
    sentB.avgSentDaily = 0;
    sentB.avgSentWeekly = 2;
    mAppRow.sentByChannel.put("channelA", sentA);
    // Test that the channels' properties are reflected in the preference
    mController.updateFullList(mGroupList, inGroups);
    {
        assertEquals(1, mGroupList.getPreferenceCount());
        PreferenceGroup group = (PreferenceGroup) mGroupList.getPreference(0);
        assertEquals("group", group.getKey());
        assertEquals(3, group.getPreferenceCount());
        assertNull(group.getPreference(0).getKey());
        assertEquals("All \"Group\" notifications", group.getPreference(0).getTitle());
        PrimarySwitchPreference channelAPref = (PrimarySwitchPreference) group.getPreference(1);
        assertEquals("channelA", channelAPref.getKey());
        assertEquals("Channel A", channelAPref.getTitle());
        assertEquals(Boolean.TRUE, channelAPref.getCheckedState());
        assertEquals("~2 notifications per day", channelAPref.getSummary());
        assertNotNull(channelAPref.getIcon());
        PrimarySwitchPreference channelBPref = (PrimarySwitchPreference) group.getPreference(2);
        assertEquals("channelB", channelBPref.getKey());
        assertEquals("Channel B", channelBPref.getTitle());
        assertEquals(Boolean.FALSE, channelBPref.getCheckedState());
        assertNull(channelBPref.getSummary());
        assertNull(channelBPref.getIcon());
    }
    channelA.setImportance(IMPORTANCE_NONE);
    channelB.setImportance(IMPORTANCE_DEFAULT);
    mAppRow.sentByChannel.remove("channelA");
    mAppRow.sentByChannel.put("channelB", sentB);
    // Test that changing the channels' properties correctly updates the preference
    mController.updateFullList(mGroupList, inGroups);
    {
        assertEquals(1, mGroupList.getPreferenceCount());
        PreferenceGroup group = (PreferenceGroup) mGroupList.getPreference(0);
        assertEquals("group", group.getKey());
        assertEquals(3, group.getPreferenceCount());
        assertNull(group.getPreference(0).getKey());
        assertEquals("All \"Group\" notifications", group.getPreference(0).getTitle());
        PrimarySwitchPreference channelAPref = (PrimarySwitchPreference) group.getPreference(1);
        assertEquals("channelA", channelAPref.getKey());
        assertEquals("Channel A", channelAPref.getTitle());
        assertEquals(Boolean.FALSE, channelAPref.getCheckedState());
        assertNull(channelAPref.getSummary());
        assertNull(channelAPref.getIcon());
        PrimarySwitchPreference channelBPref = (PrimarySwitchPreference) group.getPreference(2);
        assertEquals("channelB", channelBPref.getKey());
        assertEquals("Channel B", channelBPref.getTitle());
        assertEquals(Boolean.TRUE, channelBPref.getCheckedState());
        assertEquals("~2 notifications per week", channelBPref.getSummary());
        assertNotNull(channelBPref.getIcon());
    }
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationChannelGroup(android.app.NotificationChannelGroup) NotificationsSentState(com.android.settings.notification.NotificationBackend.NotificationsSentState) ArrayList(java.util.ArrayList) PreferenceGroup(androidx.preference.PreferenceGroup) PrimarySwitchPreference(com.android.settings.widget.PrimarySwitchPreference) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 49 with UiThreadTest

use of androidx.test.annotation.UiThreadTest in project android_packages_apps_Settings by omnirom.

the class ChannelListPreferenceControllerTest method testUpdateFullList_groupBlockedChange.

@Test
@UiThreadTest
public void testUpdateFullList_groupBlockedChange() {
    List<NotificationChannelGroup> inGroups = new ArrayList<>();
    NotificationChannelGroup inGroup = new NotificationChannelGroup("group", "My Group");
    inGroup.addChannel(new NotificationChannel("channelA", "Channel A", IMPORTANCE_DEFAULT));
    inGroup.addChannel(new NotificationChannel("channelB", "Channel B", IMPORTANCE_NONE));
    inGroups.add(inGroup);
    // Test that the group is initially showing all preferences
    mController.updateFullList(mGroupList, inGroups);
    {
        assertEquals(1, mGroupList.getPreferenceCount());
        PreferenceGroup group = (PreferenceGroup) mGroupList.getPreference(0);
        assertEquals("group", group.getKey());
        assertEquals(3, group.getPreferenceCount());
        SwitchPreference groupBlockPref = (SwitchPreference) group.getPreference(0);
        assertNull(groupBlockPref.getKey());
        assertEquals("All \"My Group\" notifications", groupBlockPref.getTitle());
        assertTrue(groupBlockPref.isChecked());
        PrimarySwitchPreference channelAPref = (PrimarySwitchPreference) group.getPreference(1);
        assertEquals("channelA", channelAPref.getKey());
        assertEquals("Channel A", channelAPref.getTitle());
        assertEquals(Boolean.TRUE, channelAPref.getCheckedState());
        PrimarySwitchPreference channelBPref = (PrimarySwitchPreference) group.getPreference(2);
        assertEquals("channelB", channelBPref.getKey());
        assertEquals("Channel B", channelBPref.getTitle());
        assertEquals(Boolean.FALSE, channelBPref.getCheckedState());
    }
    // Test that when a group is blocked, the list removes its individual channel preferences
    inGroup.setBlocked(true);
    mController.updateFullList(mGroupList, inGroups);
    {
        assertEquals(1, mGroupList.getPreferenceCount());
        PreferenceGroup group = (PreferenceGroup) mGroupList.getPreference(0);
        assertEquals("group", group.getKey());
        assertEquals(1, group.getPreferenceCount());
        SwitchPreference groupBlockPref = (SwitchPreference) group.getPreference(0);
        assertNull(groupBlockPref.getKey());
        assertEquals("All \"My Group\" notifications", groupBlockPref.getTitle());
        assertFalse(groupBlockPref.isChecked());
    }
    // Test that when a group is unblocked, the list adds its individual channel preferences
    inGroup.setBlocked(false);
    mController.updateFullList(mGroupList, inGroups);
    {
        assertEquals(1, mGroupList.getPreferenceCount());
        PreferenceGroup group = (PreferenceGroup) mGroupList.getPreference(0);
        assertEquals("group", group.getKey());
        assertEquals(3, group.getPreferenceCount());
        SwitchPreference groupBlockPref = (SwitchPreference) group.getPreference(0);
        assertNull(groupBlockPref.getKey());
        assertEquals("All \"My Group\" notifications", groupBlockPref.getTitle());
        assertTrue(groupBlockPref.isChecked());
        PrimarySwitchPreference channelAPref = (PrimarySwitchPreference) group.getPreference(1);
        assertEquals("channelA", channelAPref.getKey());
        assertEquals("Channel A", channelAPref.getTitle());
        assertEquals(Boolean.TRUE, channelAPref.getCheckedState());
        PrimarySwitchPreference channelBPref = (PrimarySwitchPreference) group.getPreference(2);
        assertEquals("channelB", channelBPref.getKey());
        assertEquals("Channel B", channelBPref.getTitle());
        assertEquals(Boolean.FALSE, channelBPref.getCheckedState());
    }
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationChannelGroup(android.app.NotificationChannelGroup) SwitchPreference(androidx.preference.SwitchPreference) PrimarySwitchPreference(com.android.settings.widget.PrimarySwitchPreference) ArrayList(java.util.ArrayList) PreferenceGroup(androidx.preference.PreferenceGroup) PrimarySwitchPreference(com.android.settings.widget.PrimarySwitchPreference) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 50 with UiThreadTest

use of androidx.test.annotation.UiThreadTest in project android_packages_apps_Settings by omnirom.

the class NetworkProviderSimListControllerTest method getAvailablePhysicalSubscription_withTwoPhysicalSims_returnTwo.

@Test
@UiThreadTest
public void getAvailablePhysicalSubscription_withTwoPhysicalSims_returnTwo() {
    final SubscriptionInfo info1 = mock(SubscriptionInfo.class);
    when(info1.isEmbedded()).thenReturn(false);
    final SubscriptionInfo info2 = mock(SubscriptionInfo.class);
    when(info2.isEmbedded()).thenReturn(false);
    when(mSubscriptionManager.getAvailableSubscriptionInfoList()).thenReturn(Arrays.asList(info1, info2));
    displayPreferenceWithLifecycle();
    assertThat(mController.getAvailablePhysicalSubscription().size()).isEqualTo(2);
}
Also used : SubscriptionInfo(android.telephony.SubscriptionInfo) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Aggregations

UiThreadTest (androidx.test.annotation.UiThreadTest)136 Test (org.junit.Test)129 View (android.view.View)41 Unbinder (butterknife.Unbinder)31 Context (android.content.Context)23 AdapterView (android.widget.AdapterView)18 TextView (android.widget.TextView)15 RecordingObserver (com.jakewharton.rxbinding4.RecordingObserver)15 MediumTest (androidx.test.filters.MediumTest)14 Intent (android.content.Intent)10 SubscriptionInfo (android.telephony.SubscriptionInfo)10 CountDownLatch (java.util.concurrent.CountDownLatch)10 LocalPSMP (de.danoeh.antennapod.core.service.playback.LocalPSMP)9 PlaybackServiceMediaPlayer (de.danoeh.antennapod.playback.base.PlaybackServiceMediaPlayer)9 Slice (androidx.slice.Slice)8 Playable (de.danoeh.antennapod.model.playback.Playable)8 AssertionFailedError (junit.framework.AssertionFailedError)8 Before (org.junit.Before)7 ViewGroup (android.view.ViewGroup)6 FrameLayout (android.widget.FrameLayout)6