1 /* 2 * Copyright (C) 2016 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.dvr.provider; 18 19 import static org.junit.Assert.assertFalse; 20 import static org.junit.Assert.assertTrue; 21 22 import android.os.Build; 23 import android.support.test.filters.SdkSuppress; 24 import android.support.test.filters.SmallTest; 25 26 import com.android.tv.dvr.data.SeasonEpisodeNumber; 27 28 import org.junit.Test; 29 30 import java.util.ArrayList; 31 import java.util.List; 32 33 /** 34 * Tests for {@link EpisodicProgramLoadTask} 35 */ 36 @SmallTest 37 @SdkSuppress(minSdkVersion = Build.VERSION_CODES.N) 38 public class EpisodicProgramLoadTaskTest { 39 private static final long SERIES_RECORDING_ID1 = 1; 40 private static final long SERIES_RECORDING_ID2 = 2; 41 private static final String SEASON_NUMBER1 = "SEASON NUMBER1"; 42 private static final String SEASON_NUMBER2 = "SEASON NUMBER2"; 43 private static final String EPISODE_NUMBER1 = "EPISODE NUMBER1"; 44 private static final String EPISODE_NUMBER2 = "EPISODE NUMBER2"; 45 46 @Test 47 public void testEpisodeAlreadyScheduled_true() { 48 List<SeasonEpisodeNumber> seasonEpisodeNumbers = new ArrayList<>(); 49 SeasonEpisodeNumber seasonEpisodeNumber = new SeasonEpisodeNumber( 50 SERIES_RECORDING_ID1, SEASON_NUMBER1, EPISODE_NUMBER1); 51 seasonEpisodeNumbers.add(seasonEpisodeNumber); 52 assertTrue(seasonEpisodeNumbers.contains( 53 new SeasonEpisodeNumber(SERIES_RECORDING_ID1, SEASON_NUMBER1, EPISODE_NUMBER1))); 54 } 55 56 @Test 57 public void testEpisodeAlreadyScheduled_false() { 58 List<SeasonEpisodeNumber> seasonEpisodeNumbers = new ArrayList<>(); 59 SeasonEpisodeNumber seasonEpisodeNumber = new SeasonEpisodeNumber( 60 SERIES_RECORDING_ID1, SEASON_NUMBER1, EPISODE_NUMBER1); 61 seasonEpisodeNumbers.add(seasonEpisodeNumber); 62 assertFalse(seasonEpisodeNumbers.contains( 63 new SeasonEpisodeNumber(SERIES_RECORDING_ID2, SEASON_NUMBER1, EPISODE_NUMBER1))); 64 assertFalse(seasonEpisodeNumbers.contains( 65 new SeasonEpisodeNumber(SERIES_RECORDING_ID1, SEASON_NUMBER2, EPISODE_NUMBER1))); 66 assertFalse(seasonEpisodeNumbers.contains( 67 new SeasonEpisodeNumber(SERIES_RECORDING_ID1, SEASON_NUMBER1, EPISODE_NUMBER2))); 68 } 69 70 @Test 71 public void testEpisodeAlreadyScheduled_null() { 72 List<SeasonEpisodeNumber> seasonEpisodeNumbers = new ArrayList<>(); 73 SeasonEpisodeNumber seasonEpisodeNumber = new SeasonEpisodeNumber( 74 SERIES_RECORDING_ID1, SEASON_NUMBER1, EPISODE_NUMBER1); 75 seasonEpisodeNumbers.add(seasonEpisodeNumber); 76 assertFalse(seasonEpisodeNumbers.contains( 77 new SeasonEpisodeNumber(SERIES_RECORDING_ID1, null, EPISODE_NUMBER1))); 78 assertFalse(seasonEpisodeNumbers.contains( 79 new SeasonEpisodeNumber(SERIES_RECORDING_ID1, SEASON_NUMBER1, null))); 80 assertFalse(seasonEpisodeNumbers.contains( 81 new SeasonEpisodeNumber(SERIES_RECORDING_ID1, null, null))); 82 } 83 }