summaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/contacts/interactions/CallLogInteractionsLoaderTest.java
blob: 079411f70a0af1d8e2be30138fe69c97112da4f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package com.android.contacts.interactions;

import android.content.ContentValues;
import android.provider.CallLog.Calls;
import android.test.AndroidTestCase;

import java.util.ArrayList;
import java.util.List;

/**
 * Tests {@link CallLogInteractionsLoader}
 */
public class CallLogInteractionsLoaderTest extends AndroidTestCase {

    public void testCallLogInteractions_pruneDuplicates_containsDuplicates() {
        List<ContactInteraction> interactions = new ArrayList<>();
        int maxToRetrieve = 5;

        ContentValues interactionOneValues = new ContentValues();
        interactionOneValues.put(Calls.DATE, 1L);
        interactions.add(new CallLogInteraction(interactionOneValues));

        ContentValues interactionTwoValues = new ContentValues();
        interactionTwoValues.put(Calls.DATE, 1L);
        interactions.add(new CallLogInteraction(interactionTwoValues));

        interactions = CallLogInteractionsLoader.pruneDuplicateCallLogInteractions(interactions,
                maxToRetrieve);
        assertEquals(1, interactions.size());
    }

    public void testCallLogInteractions_pruneDuplicates_containsNoDuplicates() {
        List<ContactInteraction> interactions = new ArrayList<>();
        int maxToRetrieve = 5;

        ContentValues interactionOneValues = new ContentValues();
        interactionOneValues.put(Calls.DATE, 1L);
        interactions.add(new CallLogInteraction(interactionOneValues));

        ContentValues interactionTwoValues = new ContentValues();
        interactionTwoValues.put(Calls.DATE, 5L);
        interactions.add(new CallLogInteraction(interactionTwoValues));

        interactions = CallLogInteractionsLoader.pruneDuplicateCallLogInteractions(interactions,
                maxToRetrieve);
        assertEquals(2, interactions.size());
    }

    public void testCallLogInteractions_maxToRetrieve() {
        List<ContactInteraction> interactions = new ArrayList<>();
        int maxToRetrieve = 1;

        ContentValues interactionOneValues = new ContentValues();
        interactionOneValues.put(Calls.DATE, 1L);
        interactions.add(new CallLogInteraction(interactionOneValues));

        ContentValues interactionTwoValues = new ContentValues();
        interactionTwoValues.put(Calls.DATE, 5L);
        interactions.add(new CallLogInteraction(interactionTwoValues));

        interactions = CallLogInteractionsLoader.pruneDuplicateCallLogInteractions(interactions,
                maxToRetrieve);
        assertEquals(1, interactions.size());
    }
}