aboutsummaryrefslogtreecommitdiff
path: root/tests/common/src/com/android/tv/testing/dvr/RecordingTestUtils.java
blob: 72bac8fcdbf62cfb9060495c6b6b8cf329bcdc9f (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
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package com.android.tv.testing.dvr;

import com.android.tv.dvr.data.ScheduledRecording;
import junit.framework.Assert;

/** Static utils for using {@link ScheduledRecording} in tests. */
public final class RecordingTestUtils {
    private static final String INPUT_ID = "input_id";
    private static final int CHANNEL_ID = 273;

    public static ScheduledRecording createTestRecordingWithIdAndPeriod(
            long id, String inputId, long channelId, long startTime, long endTime) {
        return ScheduledRecording.builder(inputId, channelId, startTime, endTime)
                .setId(id)
                .setChannelId(channelId)
                .build();
    }

    public static ScheduledRecording createTestRecordingWithPeriod(
            String inputId, long channelId, long startTime, long endTime) {
        return createTestRecordingWithIdAndPeriod(
                ScheduledRecording.ID_NOT_SET, inputId, channelId, startTime, endTime);
    }

    public static ScheduledRecording createTestRecordingWithPriorityAndPeriod(
            long channelId, long priority, long startTime, long endTime) {
        return ScheduledRecording.builder(INPUT_ID, CHANNEL_ID, startTime, endTime)
                .setChannelId(channelId)
                .setPriority(priority)
                .build();
    }

    public static ScheduledRecording createTestRecordingWithIdAndPriorityAndPeriod(
            long id, long channelId, long priority, long startTime, long endTime) {
        return ScheduledRecording.builder(INPUT_ID, CHANNEL_ID, startTime, endTime)
                .setId(id)
                .setChannelId(channelId)
                .setPriority(priority)
                .build();
    }

    public static ScheduledRecording normalizePriority(ScheduledRecording orig) {
        return ScheduledRecording.buildFrom(orig).setPriority(orig.getId()).build();
    }

    public static void assertRecordingEquals(
            ScheduledRecording expected, ScheduledRecording actual) {
        Assert.assertEquals("id", expected.getId(), actual.getId());
        Assert.assertEquals("channel", expected.getChannelId(), actual.getChannelId());
        Assert.assertEquals("programId", expected.getProgramId(), actual.getProgramId());
        Assert.assertEquals("priority", expected.getPriority(), actual.getPriority());
        Assert.assertEquals("start time", expected.getStartTimeMs(), actual.getStartTimeMs());
        Assert.assertEquals("end time", expected.getEndTimeMs(), actual.getEndTimeMs());
        Assert.assertEquals("state", expected.getState(), actual.getState());
        Assert.assertEquals(
                "parent series recording",
                expected.getSeriesRecordingId(),
                actual.getSeriesRecordingId());
    }

    private RecordingTestUtils() {}
}