1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 17 package com.android.tv.testing.dvr; 18 19 import com.android.tv.dvr.data.ScheduledRecording; 20 21 import junit.framework.Assert; 22 23 /** 24 * Static utils for using {@link ScheduledRecording} in tests. 25 */ 26 public final class RecordingTestUtils { 27 private static final String INPUT_ID = "input_id"; 28 private static final int CHANNEL_ID = 273; 29 30 public static ScheduledRecording createTestRecordingWithIdAndPeriod(long id, String inputId, 31 long channelId, long startTime, long endTime) { 32 return ScheduledRecording.builder(inputId, channelId, startTime, endTime) 33 .setId(id) 34 .setChannelId(channelId) 35 .build(); 36 } 37 38 public static ScheduledRecording createTestRecordingWithPeriod(String inputId, 39 long channelId, long startTime, long endTime) { 40 return createTestRecordingWithIdAndPeriod(ScheduledRecording.ID_NOT_SET, inputId, channelId, 41 startTime, endTime); 42 } 43 44 public static ScheduledRecording createTestRecordingWithPriorityAndPeriod(long channelId, 45 long priority, long startTime, long endTime) { 46 return ScheduledRecording.builder(INPUT_ID, CHANNEL_ID, startTime, endTime) 47 .setChannelId(channelId) 48 .setPriority(priority) 49 .build(); 50 } 51 52 public static ScheduledRecording createTestRecordingWithIdAndPriorityAndPeriod(long id, 53 long channelId, long priority, long startTime, long endTime) { 54 return ScheduledRecording.builder(INPUT_ID, CHANNEL_ID, startTime, endTime) 55 .setId(id) 56 .setChannelId(channelId) 57 .setPriority(priority) 58 .build(); 59 } 60 61 public static ScheduledRecording normalizePriority(ScheduledRecording orig){ 62 return ScheduledRecording.buildFrom(orig).setPriority(orig.getId()).build(); 63 } 64 65 public static void assertRecordingEquals(ScheduledRecording expected, ScheduledRecording actual) { 66 Assert.assertEquals("id", expected.getId(), actual.getId()); 67 Assert.assertEquals("channel", expected.getChannelId(), actual.getChannelId()); 68 Assert.assertEquals("programId", expected.getProgramId(), actual.getProgramId()); 69 Assert.assertEquals("priority", expected.getPriority(), actual.getPriority()); 70 Assert.assertEquals("start time", expected.getStartTimeMs(), actual.getStartTimeMs()); 71 Assert.assertEquals("end time", expected.getEndTimeMs(), actual.getEndTimeMs()); 72 Assert.assertEquals("state", expected.getState(), actual.getState()); 73 Assert.assertEquals("parent series recording", expected.getSeriesRecordingId(), 74 actual.getSeriesRecordingId()); 75 } 76 77 private RecordingTestUtils() { } 78 } 79