From ba5845f23b8fbc985890f892961abc8b39886611 Mon Sep 17 00:00:00 2001 From: Nick Chalko Date: Fri, 26 Feb 2016 13:38:57 -0800 Subject: Sync to ub-tv-interns at cc7c29d2a24a1343498f6d95ca5a79e003e6aefe Change-Id: I580da190231e47c65b69f425b30ec4685eb50ce4 --- .../src/com/android/tv/testing/ChannelUtils.java | 2 +- .../src/com/android/tv/testing/ProgramUtils.java | 4 ++- .../tv/testing/TvContentRatingConstants.java | 7 +++++ tests/common/src/com/android/tv/testing/Utils.java | 25 ----------------- .../android/tv/testing/dvr/RecordingTestUtils.java | 32 ++++++++++++++++++++-- .../android/tv/testing/uihelper/MenuHelper.java | 14 ++-------- 6 files changed, 43 insertions(+), 41 deletions(-) (limited to 'tests/common/src/com/android/tv/testing') diff --git a/tests/common/src/com/android/tv/testing/ChannelUtils.java b/tests/common/src/com/android/tv/testing/ChannelUtils.java index 00881c86..e09843a6 100644 --- a/tests/common/src/com/android/tv/testing/ChannelUtils.java +++ b/tests/common/src/com/android/tv/testing/ChannelUtils.java @@ -96,7 +96,7 @@ public class ChannelUtils { } else { values.putNull(Channels.COLUMN_VIDEO_FORMAT); } - if (Build.VERSION.SDK_INT >= 23) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (!TextUtils.isEmpty(channel.appLinkText)) { values.put(Channels.COLUMN_APP_LINK_TEXT, channel.appLinkText); } diff --git a/tests/common/src/com/android/tv/testing/ProgramUtils.java b/tests/common/src/com/android/tv/testing/ProgramUtils.java index 493891b6..227eb84a 100644 --- a/tests/common/src/com/android/tv/testing/ProgramUtils.java +++ b/tests/common/src/com/android/tv/testing/ProgramUtils.java @@ -25,6 +25,8 @@ import android.media.tv.TvContract.Programs; import android.net.Uri; import android.util.Log; +import com.android.tv.common.TvContentRatingCache; + import java.util.ArrayList; import java.util.concurrent.TimeUnit; @@ -48,7 +50,7 @@ public class ProgramUtils { values.put(Programs.COLUMN_CHANNEL_ID, channelId); values.put(Programs.COLUMN_SHORT_DESCRIPTION, program.description); values.put(Programs.COLUMN_CONTENT_RATING, - Utils.contentRatingsToString(program.contentRatings)); + TvContentRatingCache.contentRatingsToString(program.contentRatings)); long currentTimeMs = System.currentTimeMillis(); long targetEndTimeMs = currentTimeMs + PROGRAM_INSERT_DURATION_MS; diff --git a/tests/common/src/com/android/tv/testing/TvContentRatingConstants.java b/tests/common/src/com/android/tv/testing/TvContentRatingConstants.java index 0795a89c..71af8297 100644 --- a/tests/common/src/com/android/tv/testing/TvContentRatingConstants.java +++ b/tests/common/src/com/android/tv/testing/TvContentRatingConstants.java @@ -33,6 +33,8 @@ public final class TvContentRatingConstants { public static final TvContentRating CONTENT_RATING_US_TV_Y7_US_TV_FV = TvContentRating.createRating("com.android.tv", "US_TV", "US_TV_Y7", "US_TV_FV"); + public static String STRING_US_TV_Y7_US_TV_FV = "com.android.tv/US_TV/US_TV_Y7/US_TV_FV"; + /** * A content rating object. * @@ -43,6 +45,8 @@ public final class TvContentRatingConstants { public static final TvContentRating CONTENT_RATING_US_TV_MA = TvContentRating.createRating("com.android.tv", "US_TV", "US_TV_MA"); + public static String STRING_US_TV_MA = "com.android.tv/US_TV/US_TV_MA"; + /** * A content rating object. * @@ -54,4 +58,7 @@ public final class TvContentRatingConstants { public static final TvContentRating CONTENT_RATING_US_TV_PG_US_TV_L_US_TV_S = TvContentRating.createRating("com.android.tv", "US_TV", "US_TV_PG", "US_TV_L", "US_TV_S"); + + public static String STRING_US_TV_PG_US_TV_L_US_TV_S + = "com.android.tv/US_TV/US_TV_Y7/US_TV_L/US_TV_S"; } diff --git a/tests/common/src/com/android/tv/testing/Utils.java b/tests/common/src/com/android/tv/testing/Utils.java index 9e1bd3e9..6bc4e24e 100644 --- a/tests/common/src/com/android/tv/testing/Utils.java +++ b/tests/common/src/com/android/tv/testing/Utils.java @@ -95,31 +95,6 @@ public final class Utils { return null; } - public static TvContentRating[] stringToContentRatings(String commaSeparatedRatings) { - if (TextUtils.isEmpty(commaSeparatedRatings)) { - return null; - } - String[] ratings = commaSeparatedRatings.split("\\s*,\\s*"); - TvContentRating[] contentRatings = new TvContentRating[ratings.length]; - for (int i = 0; i < contentRatings.length; ++i) { - contentRatings[i] = TvContentRating.unflattenFromString(ratings[i]); - } - return contentRatings; - } - - public static String contentRatingsToString(TvContentRating[] contentRatings) { - if (contentRatings == null || contentRatings.length == 0) { - return null; - } - final String DELIMITER = ","; - StringBuilder ratings = new StringBuilder(contentRatings[0].flattenToString()); - for (int i = 1; i < contentRatings.length; ++i) { - ratings.append(DELIMITER); - ratings.append(contentRatings[i].flattenToString()); - } - return ratings.toString(); - } - /** * Return the Random class which is needed to make random data for testing. * Default seed of the random is today's date. diff --git a/tests/common/src/com/android/tv/testing/dvr/RecordingTestUtils.java b/tests/common/src/com/android/tv/testing/dvr/RecordingTestUtils.java index 30e21e2e..458c9f2c 100644 --- a/tests/common/src/com/android/tv/testing/dvr/RecordingTestUtils.java +++ b/tests/common/src/com/android/tv/testing/dvr/RecordingTestUtils.java @@ -16,19 +16,47 @@ package com.android.tv.testing.dvr; +import android.support.annotation.RequiresPermission; + import com.android.tv.data.Channel; import com.android.tv.dvr.Recording; +import junit.framework.Assert; + import java.util.Collections; /** * Static utils for using {@link Recording} in tests. */ -public class RecordingTestUtils { - public static Recording createTestRecordingWithPeriod(long id, long startTime, long endTime) { +public final class RecordingTestUtils { + public static Recording createTestRecordingWithIdAndPeriod(long id, long startTime, + long endTime) { return Recording.builder(new Channel.Builder().build(), startTime, endTime) .setId(id) .setPrograms(Collections.EMPTY_LIST) .build(); } + + public static Recording createTestRecordingWithPeriod(long startTime, long endTime) { + return createTestRecordingWithIdAndPeriod(Recording.ID_NOT_SET, startTime, endTime); + } + + public static Recording normalizePriority(Recording orig){ + return Recording.buildFrom(orig).setPriority(orig.getId()).build(); + } + + public static void assertRecordingEquals(Recording expected, Recording actual) { + Assert.assertEquals("id", expected.getId(), actual.getId()); + Assert.assertEquals("uri", expected.getUri(), actual.getUri()); + Assert.assertEquals("channel", expected.getChannel(), actual.getChannel()); + Assert.assertEquals("programs", expected.getPrograms(), actual.getPrograms()); + Assert.assertEquals("start time", expected.getStartTimeMs(), actual.getStartTimeMs()); + Assert.assertEquals("end time", expected.getEndTimeMs(), actual.getEndTimeMs()); + Assert.assertEquals("media size", expected.getSize(), actual.getSize()); + Assert.assertEquals("state", expected.getState(), actual.getState()); + Assert.assertEquals("parent season recording", expected.getParentSeasonRecording(), + actual.getParentSeasonRecording()); + } + + private RecordingTestUtils() { } } diff --git a/tests/common/src/com/android/tv/testing/uihelper/MenuHelper.java b/tests/common/src/com/android/tv/testing/uihelper/MenuHelper.java index 3d992618..ea5360a3 100644 --- a/tests/common/src/com/android/tv/testing/uihelper/MenuHelper.java +++ b/tests/common/src/com/android/tv/testing/uihelper/MenuHelper.java @@ -116,14 +116,9 @@ public class MenuHelper extends BaseUiDeviceHelper { Direction.RIGHT); } - public UiObject2 assertPressOptionsChannelSources() { + public UiObject2 assertPressOptionsSettings() { return assertPressMenuItem(R.string.menu_title_options, - R.string.options_item_channel_sources); - } - - public UiObject2 assertPressOptionsAbout() { - return assertPressMenuItem(R.string.menu_title_options, - R.string.options_item_about); + R.string.options_item_settings); } public UiObject2 assertPressOptionsClosedCaptions() { @@ -139,11 +134,6 @@ public class MenuHelper extends BaseUiDeviceHelper { return assertPressMenuItem(R.string.menu_title_options, R.string.options_item_multi_audio); } - public UiObject2 assertPressOptionsParentalControls() { - return assertPressMenuItem(R.string.menu_title_options, - R.string.options_item_parental_controls); - } - public UiObject2 assertPressProgramGuide() { return assertPressMenuItem(R.string.menu_title_channels, R.string.channels_item_program_guide); -- cgit v1.2.3