148411f52807c013a8e6ad921d6b1c705e7c385d1Sungsoo Lim/*
2816a4be1a0f34f6a48877c8afd3dbbca19eac435Nick Chalko * Copyright (C) 2015 The Android Open Source Project
348411f52807c013a8e6ad921d6b1c705e7c385d1Sungsoo Lim *
448411f52807c013a8e6ad921d6b1c705e7c385d1Sungsoo Lim * Licensed under the Apache License, Version 2.0 (the "License");
548411f52807c013a8e6ad921d6b1c705e7c385d1Sungsoo Lim * you may not use this file except in compliance with the License.
648411f52807c013a8e6ad921d6b1c705e7c385d1Sungsoo Lim * You may obtain a copy of the License at
748411f52807c013a8e6ad921d6b1c705e7c385d1Sungsoo Lim *
848411f52807c013a8e6ad921d6b1c705e7c385d1Sungsoo Lim *      http://www.apache.org/licenses/LICENSE-2.0
948411f52807c013a8e6ad921d6b1c705e7c385d1Sungsoo Lim *
1048411f52807c013a8e6ad921d6b1c705e7c385d1Sungsoo Lim * Unless required by applicable law or agreed to in writing, software
1148411f52807c013a8e6ad921d6b1c705e7c385d1Sungsoo Lim * distributed under the License is distributed on an "AS IS" BASIS,
1248411f52807c013a8e6ad921d6b1c705e7c385d1Sungsoo Lim * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1348411f52807c013a8e6ad921d6b1c705e7c385d1Sungsoo Lim * See the License for the specific language governing permissions and
141abddd9f6225298066094e20a6c29061b6af4590Nick Chalko * limitations under the License
1548411f52807c013a8e6ad921d6b1c705e7c385d1Sungsoo Lim */
1648411f52807c013a8e6ad921d6b1c705e7c385d1Sungsoo Lim
171abddd9f6225298066094e20a6c29061b6af4590Nick Chalkopackage com.android.tv.testing.dvr;
1848411f52807c013a8e6ad921d6b1c705e7c385d1Sungsoo Lim
19633eb826b8c97731dfc5ef12c7bf78a63734275dNick Chalkoimport com.android.tv.dvr.data.ScheduledRecording;
20ba5845f23b8fbc985890f892961abc8b39886611Nick Chalkoimport junit.framework.Assert;
21ba5845f23b8fbc985890f892961abc8b39886611Nick Chalko
2295961816a768da387f0b5523cf4363ace2044089Nick Chalko/** Static utils for using {@link ScheduledRecording} in tests. */
23ba5845f23b8fbc985890f892961abc8b39886611Nick Chalkopublic final class RecordingTestUtils {
2465fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko    private static final String INPUT_ID = "input_id";
2565fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko    private static final int CHANNEL_ID = 273;
2665fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko
2795961816a768da387f0b5523cf4363ace2044089Nick Chalko    public static ScheduledRecording createTestRecordingWithIdAndPeriod(
2895961816a768da387f0b5523cf4363ace2044089Nick Chalko            long id, String inputId, long channelId, long startTime, long endTime) {
2965fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko        return ScheduledRecording.builder(inputId, channelId, startTime, endTime)
301abddd9f6225298066094e20a6c29061b6af4590Nick Chalko                .setId(id)
312e1279b8bbe0603fb4399b25b73121bed5953c46Nick Chalko                .setChannelId(channelId)
321abddd9f6225298066094e20a6c29061b6af4590Nick Chalko                .build();
3348411f52807c013a8e6ad921d6b1c705e7c385d1Sungsoo Lim    }
34ba5845f23b8fbc985890f892961abc8b39886611Nick Chalko
3595961816a768da387f0b5523cf4363ace2044089Nick Chalko    public static ScheduledRecording createTestRecordingWithPeriod(
3695961816a768da387f0b5523cf4363ace2044089Nick Chalko            String inputId, long channelId, long startTime, long endTime) {
3795961816a768da387f0b5523cf4363ace2044089Nick Chalko        return createTestRecordingWithIdAndPeriod(
3895961816a768da387f0b5523cf4363ace2044089Nick Chalko                ScheduledRecording.ID_NOT_SET, inputId, channelId, startTime, endTime);
392e1279b8bbe0603fb4399b25b73121bed5953c46Nick Chalko    }
402e1279b8bbe0603fb4399b25b73121bed5953c46Nick Chalko
4195961816a768da387f0b5523cf4363ace2044089Nick Chalko    public static ScheduledRecording createTestRecordingWithPriorityAndPeriod(
4295961816a768da387f0b5523cf4363ace2044089Nick Chalko            long channelId, long priority, long startTime, long endTime) {
4365fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko        return ScheduledRecording.builder(INPUT_ID, CHANNEL_ID, startTime, endTime)
4465fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko                .setChannelId(channelId)
4565fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko                .setPriority(priority)
4665fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko                .build();
4765fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko    }
4865fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko
4995961816a768da387f0b5523cf4363ace2044089Nick Chalko    public static ScheduledRecording createTestRecordingWithIdAndPriorityAndPeriod(
5095961816a768da387f0b5523cf4363ace2044089Nick Chalko            long id, long channelId, long priority, long startTime, long endTime) {
5165fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko        return ScheduledRecording.builder(INPUT_ID, CHANNEL_ID, startTime, endTime)
5265fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko                .setId(id)
5365fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko                .setChannelId(channelId)
5465fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko                .setPriority(priority)
5565fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko                .build();
56ba5845f23b8fbc985890f892961abc8b39886611Nick Chalko    }
57ba5845f23b8fbc985890f892961abc8b39886611Nick Chalko
5895961816a768da387f0b5523cf4363ace2044089Nick Chalko    public static ScheduledRecording normalizePriority(ScheduledRecording orig) {
592e1279b8bbe0603fb4399b25b73121bed5953c46Nick Chalko        return ScheduledRecording.buildFrom(orig).setPriority(orig.getId()).build();
60ba5845f23b8fbc985890f892961abc8b39886611Nick Chalko    }
61ba5845f23b8fbc985890f892961abc8b39886611Nick Chalko
6295961816a768da387f0b5523cf4363ace2044089Nick Chalko    public static void assertRecordingEquals(
6395961816a768da387f0b5523cf4363ace2044089Nick Chalko            ScheduledRecording expected, ScheduledRecording actual) {
64ba5845f23b8fbc985890f892961abc8b39886611Nick Chalko        Assert.assertEquals("id", expected.getId(), actual.getId());
652e1279b8bbe0603fb4399b25b73121bed5953c46Nick Chalko        Assert.assertEquals("channel", expected.getChannelId(), actual.getChannelId());
662e1279b8bbe0603fb4399b25b73121bed5953c46Nick Chalko        Assert.assertEquals("programId", expected.getProgramId(), actual.getProgramId());
672e1279b8bbe0603fb4399b25b73121bed5953c46Nick Chalko        Assert.assertEquals("priority", expected.getPriority(), actual.getPriority());
68ba5845f23b8fbc985890f892961abc8b39886611Nick Chalko        Assert.assertEquals("start time", expected.getStartTimeMs(), actual.getStartTimeMs());
69ba5845f23b8fbc985890f892961abc8b39886611Nick Chalko        Assert.assertEquals("end time", expected.getEndTimeMs(), actual.getEndTimeMs());
70ba5845f23b8fbc985890f892961abc8b39886611Nick Chalko        Assert.assertEquals("state", expected.getState(), actual.getState());
7195961816a768da387f0b5523cf4363ace2044089Nick Chalko        Assert.assertEquals(
7295961816a768da387f0b5523cf4363ace2044089Nick Chalko                "parent series recording",
7395961816a768da387f0b5523cf4363ace2044089Nick Chalko                expected.getSeriesRecordingId(),
7465fda1eaa94968bb55d5ded10dcb0b3f37fb05f2Nick Chalko                actual.getSeriesRecordingId());
75ba5845f23b8fbc985890f892961abc8b39886611Nick Chalko    }
76ba5845f23b8fbc985890f892961abc8b39886611Nick Chalko
7795961816a768da387f0b5523cf4363ace2044089Nick Chalko    private RecordingTestUtils() {}
7848411f52807c013a8e6ad921d6b1c705e7c385d1Sungsoo Lim}
79