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 import junit.framework.Assert; 21 22 /** Static utils for using {@link ScheduledRecording} in tests. */ 23 public final class RecordingTestUtils { 24 private static final String INPUT_ID = "input_id"; 25 private static final int CHANNEL_ID = 273; 26 createTestRecordingWithIdAndPeriod( long id, String inputId, long channelId, long startTime, long endTime)27 public static ScheduledRecording createTestRecordingWithIdAndPeriod( 28 long id, String inputId, long channelId, long startTime, long endTime) { 29 return ScheduledRecording.builder(inputId, channelId, startTime, endTime) 30 .setId(id) 31 .setChannelId(channelId) 32 .build(); 33 } 34 createTestRecordingWithPeriod( String inputId, long channelId, long startTime, long endTime)35 public static ScheduledRecording createTestRecordingWithPeriod( 36 String inputId, long channelId, long startTime, long endTime) { 37 return createTestRecordingWithIdAndPeriod( 38 ScheduledRecording.ID_NOT_SET, inputId, channelId, startTime, endTime); 39 } 40 createTestRecordingWithPriorityAndPeriod( long channelId, long priority, long startTime, long endTime)41 public static ScheduledRecording createTestRecordingWithPriorityAndPeriod( 42 long channelId, long priority, long startTime, long endTime) { 43 return ScheduledRecording.builder(INPUT_ID, CHANNEL_ID, startTime, endTime) 44 .setChannelId(channelId) 45 .setPriority(priority) 46 .build(); 47 } 48 createTestRecordingWithIdAndPriorityAndPeriod( long id, long channelId, long priority, long startTime, long endTime)49 public static ScheduledRecording createTestRecordingWithIdAndPriorityAndPeriod( 50 long id, long channelId, long priority, long startTime, long endTime) { 51 return ScheduledRecording.builder(INPUT_ID, CHANNEL_ID, startTime, endTime) 52 .setId(id) 53 .setChannelId(channelId) 54 .setPriority(priority) 55 .build(); 56 } 57 normalizePriority(ScheduledRecording orig)58 public static ScheduledRecording normalizePriority(ScheduledRecording orig) { 59 return ScheduledRecording.buildFrom(orig).setPriority(orig.getId()).build(); 60 } 61 assertRecordingEquals( ScheduledRecording expected, ScheduledRecording actual)62 public static void assertRecordingEquals( 63 ScheduledRecording expected, ScheduledRecording actual) { 64 Assert.assertEquals("id", expected.getId(), actual.getId()); 65 Assert.assertEquals("channel", expected.getChannelId(), actual.getChannelId()); 66 Assert.assertEquals("programId", expected.getProgramId(), actual.getProgramId()); 67 Assert.assertEquals("priority", expected.getPriority(), actual.getPriority()); 68 Assert.assertEquals("start time", expected.getStartTimeMs(), actual.getStartTimeMs()); 69 Assert.assertEquals("end time", expected.getEndTimeMs(), actual.getEndTimeMs()); 70 Assert.assertEquals("state", expected.getState(), actual.getState()); 71 Assert.assertEquals( 72 "parent series recording", 73 expected.getSeriesRecordingId(), 74 actual.getSeriesRecordingId()); 75 } 76 RecordingTestUtils()77 private RecordingTestUtils() {} 78 } 79