Fix unit tests for people service.
Change-Id: I27f46b65055880f53fccc0e8a609c520fa0ef053 Test: Built and tested on device. Bug: 150242664
This commit is contained in:
@@ -42,14 +42,16 @@ class AggregateEventHistoryImpl implements EventHistory {
|
||||
@NonNull
|
||||
@Override
|
||||
public EventIndex getEventIndex(Set<Integer> eventTypes) {
|
||||
EventIndex merged = new EventIndex();
|
||||
EventIndex merged = null;
|
||||
for (EventHistory eventHistory : mEventHistoryList) {
|
||||
EventIndex eventIndex = eventHistory.getEventIndex(eventTypes);
|
||||
if (!eventIndex.isEmpty()) {
|
||||
if (merged == null) {
|
||||
merged = eventIndex;
|
||||
} else if (!eventIndex.isEmpty()) {
|
||||
merged = EventIndex.combine(merged, eventIndex);
|
||||
}
|
||||
}
|
||||
return merged;
|
||||
return merged != null ? merged : EventIndex.EMPTY;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
||||
@@ -192,7 +192,10 @@ class ConversationStore {
|
||||
mLocusIdToShortcutIdMap.clear();
|
||||
mNotifChannelIdToShortcutIdMap.clear();
|
||||
mPhoneNumberToShortcutIdMap.clear();
|
||||
mConversationInfosProtoDiskReadWriter.deleteConversationsFile();
|
||||
ConversationInfosProtoDiskReadWriter writer = getConversationInfosProtoDiskReadWriter();
|
||||
if (writer != null) {
|
||||
writer.deleteConversationsFile();
|
||||
}
|
||||
}
|
||||
|
||||
@MainThread
|
||||
|
||||
@@ -129,8 +129,7 @@ public class EventIndex {
|
||||
}
|
||||
|
||||
EventIndex(@NonNull EventIndex from) {
|
||||
this(from.mInjector, Arrays.copyOf(from.mEventBitmaps, TIME_SLOT_TYPES_COUNT),
|
||||
from.mLastUpdatedTime);
|
||||
this(from.mInjector, from.mEventBitmaps, from.mLastUpdatedTime);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -140,7 +139,7 @@ public class EventIndex {
|
||||
|
||||
private EventIndex(@NonNull Injector injector, long[] eventBitmaps, long lastUpdatedTime) {
|
||||
mInjector = injector;
|
||||
mEventBitmaps = eventBitmaps;
|
||||
mEventBitmaps = Arrays.copyOf(eventBitmaps, TIME_SLOT_TYPES_COUNT);
|
||||
mLastUpdatedTime = lastUpdatedTime;
|
||||
}
|
||||
|
||||
|
||||
@@ -335,9 +335,9 @@ public final class DataManagerTest {
|
||||
throws IntentFilter.MalformedMimeTypeException {
|
||||
mDataManager.onUserUnlocked(USER_ID_PRIMARY);
|
||||
AppTarget appTarget = new AppTarget.Builder(
|
||||
new AppTargetId(TEST_SHORTCUT_ID),
|
||||
TEST_PKG_NAME,
|
||||
UserHandle.of(USER_ID_PRIMARY))
|
||||
new AppTargetId(TEST_SHORTCUT_ID),
|
||||
TEST_PKG_NAME,
|
||||
UserHandle.of(USER_ID_PRIMARY))
|
||||
.setClassName(TEST_CLASS_NAME)
|
||||
.build();
|
||||
AppTargetEvent appTargetEvent =
|
||||
@@ -347,8 +347,7 @@ public final class DataManagerTest {
|
||||
|
||||
mDataManager.reportShareTargetEvent(appTargetEvent, intentFilter);
|
||||
|
||||
List<Range<Long>> activeShareTimeSlots = getActiveSlotsForTestShortcut(
|
||||
Event.SHARE_EVENT_TYPES);
|
||||
List<Range<Long>> activeShareTimeSlots = getActiveSlotsForAppShares();
|
||||
assertEquals(1, activeShareTimeSlots.size());
|
||||
}
|
||||
|
||||
@@ -665,8 +664,7 @@ public final class DataManagerTest {
|
||||
return conversations;
|
||||
}
|
||||
|
||||
private List<Range<Long>> getActiveSlotsForTestShortcut(
|
||||
Set<Integer> eventTypes) {
|
||||
private List<Range<Long>> getActiveSlotsForTestShortcut(Set<Integer> eventTypes) {
|
||||
List<Range<Long>> activeSlots = new ArrayList<>();
|
||||
mDataManager.forPackagesInProfile(USER_ID_PRIMARY, packageData ->
|
||||
activeSlots.addAll(
|
||||
@@ -676,6 +674,16 @@ public final class DataManagerTest {
|
||||
return activeSlots;
|
||||
}
|
||||
|
||||
private List<Range<Long>> getActiveSlotsForAppShares() {
|
||||
List<Range<Long>> activeSlots = new ArrayList<>();
|
||||
mDataManager.forPackagesInProfile(USER_ID_PRIMARY, packageData ->
|
||||
activeSlots.addAll(
|
||||
packageData.getClassLevelEventHistory(TEST_CLASS_NAME)
|
||||
.getEventIndex(Event.SHARE_EVENT_TYPES)
|
||||
.getActiveTimeSlots()));
|
||||
return activeSlots;
|
||||
}
|
||||
|
||||
private ShortcutInfo buildShortcutInfo(String packageName, int userId, String id,
|
||||
@Nullable Person person) {
|
||||
Context mockContext = mock(Context.class);
|
||||
|
||||
Reference in New Issue
Block a user