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);
}
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);
}
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());
}
}
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());
}
}
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);
}
Aggregations