FileDocCategorySizeDatePackage
RankingHelperTest.javaAPI DocAndroid 5.1 API5575Thu Mar 12 22:22:42 GMT 2015com.android.server.notification

RankingHelperTest

public class RankingHelperTest extends android.test.AndroidTestCase

Fields Summary
private android.app.Notification
mNotiGroupGSortA
private android.app.Notification
mNotiGroupGSortB
private android.app.Notification
mNotiNoGroup
private android.app.Notification
mNotiNoGroup2
private android.app.Notification
mNotiNoGroupSortA
private NotificationRecord
mRecordGroupGSortA
private NotificationRecord
mRecordGroupGSortB
private NotificationRecord
mRecordNoGroup
private NotificationRecord
mRecordNoGroup2
private NotificationRecord
mRecordNoGroupSortA
private RankingHelper
mHelper
Constructors Summary
Methods Summary
public voidsetUp()

        UserHandle user = UserHandle.ALL;

        mHelper = new RankingHelper(getContext(), null, new String[0]);

        mNotiGroupGSortA = new Notification.Builder(getContext())
                .setContentTitle("A")
                .setGroup("G")
                .setSortKey("A")
                .setWhen(1205)
                .build();
        mRecordGroupGSortA = new NotificationRecord(new StatusBarNotification(
                "package", "package", 1, null, 0, 0, 0, mNotiGroupGSortA, user), 0);

        mNotiGroupGSortB = new Notification.Builder(getContext())
                .setContentTitle("B")
                .setGroup("G")
                .setSortKey("B")
                .setWhen(1200)
                .build();
        mRecordGroupGSortB = new NotificationRecord(new StatusBarNotification(
                "package", "package", 1, null, 0, 0, 0, mNotiGroupGSortB, user), 0);

        mNotiNoGroup = new Notification.Builder(getContext())
                .setContentTitle("C")
                .setWhen(1201)
                .build();
        mRecordNoGroup = new NotificationRecord(new StatusBarNotification(
                "package", "package", 1, null, 0, 0, 0, mNotiNoGroup, user), 0);

        mNotiNoGroup2 = new Notification.Builder(getContext())
                .setContentTitle("D")
                .setWhen(1202)
                .build();
        mRecordNoGroup2 = new NotificationRecord(new StatusBarNotification(
                "package", "package", 1, null, 0, 0, 0, mNotiNoGroup2, user), 0);

        mNotiNoGroupSortA = new Notification.Builder(getContext())
                .setContentTitle("E")
                .setWhen(1201)
                .setSortKey("A")
                .build();
        mRecordNoGroupSortA = new NotificationRecord(new StatusBarNotification(
                "package", "package", 1, null, 0, 0, 0, mNotiNoGroupSortA, user), 0);
    
public voidtestFindAfterRankingWithASplitGroup()

        ArrayList<NotificationRecord> notificationList = new ArrayList<NotificationRecord>(3);
        notificationList.add(mRecordGroupGSortA);
        notificationList.add(mRecordGroupGSortB);
        notificationList.add(mRecordNoGroup);
        notificationList.add(mRecordNoGroupSortA);
        mHelper.sort(notificationList);
        assertTrue(mHelper.indexOf(notificationList, mRecordGroupGSortA) >= 0);
        assertTrue(mHelper.indexOf(notificationList, mRecordGroupGSortB) >= 0);
        assertTrue(mHelper.indexOf(notificationList, mRecordNoGroup) >= 0);
        assertTrue(mHelper.indexOf(notificationList, mRecordNoGroupSortA) >= 0);
    
public voidtestSortShouldNotThrowOnEmptyList()

        ArrayList<NotificationRecord> notificationList = new ArrayList<NotificationRecord>();
        mHelper.sort(notificationList);
    
public voidtestSortShouldNotThrowOneNotification()

        ArrayList<NotificationRecord> notificationList = new ArrayList<NotificationRecord>(1);
        notificationList.add(mRecordNoGroup);
        mHelper.sort(notificationList);
    
public voidtestSortShouldNotThrowOneSortKey()

        ArrayList<NotificationRecord> notificationList = new ArrayList<NotificationRecord>(1);
        notificationList.add(mRecordGroupGSortB);
        mHelper.sort(notificationList);
    
public voidtestSortShouldNotThrowOneSorted()

        ArrayList<NotificationRecord> notificationList = new ArrayList<NotificationRecord>(2);
        notificationList.add(mRecordNoGroup);
        notificationList.add(mRecordNoGroupSortA);
        mHelper.sort(notificationList);
    
public voidtestSortShouldNotThrowWithPlainNotifications()

        ArrayList<NotificationRecord> notificationList = new ArrayList<NotificationRecord>(2);
        notificationList.add(mRecordNoGroup);
        notificationList.add(mRecordNoGroup2);
        mHelper.sort(notificationList);