Java 类android.test.MoreAsserts 实例源码
项目:GitHub
文件:RealmConfigurationTests.java
@Test
public void encryptionKey_keyStorage() throws Exception {
// Generates a key and uses it in a RealmConfiguration.
byte[] oldKey = TestHelper.getRandomKey(12345);
byte[] key = oldKey;
RealmConfiguration config = new RealmConfiguration.Builder(context)
.directory(configFactory.getRoot())
.encryptionKey(key)
.build();
// Generates a different key and assigns it to the same variable.
byte[] newKey = TestHelper.getRandomKey(67890);
MoreAsserts.assertNotEqual(key, newKey);
key = newKey;
MoreAsserts.assertEquals(key, newKey);
// Ensures that the stored key did not change.
MoreAsserts.assertEquals(oldKey, config.getEncryptionKey());
}
项目:ExoPlayer-Offline
文件:FakeTrackOutput.java
public void assertEquals(FakeTrackOutput expected) {
Assert.assertEquals(expected.format, format);
Assert.assertEquals(expected.sampleTimesUs.size(), sampleTimesUs.size());
MoreAsserts.assertEquals(expected.sampleData, sampleData);
for (int i = 0; i < sampleTimesUs.size(); i++) {
Assert.assertEquals(expected.sampleTimesUs.get(i), sampleTimesUs.get(i));
Assert.assertEquals(expected.sampleFlags.get(i), sampleFlags.get(i));
Assert.assertEquals(expected.sampleStartOffsets.get(i), sampleStartOffsets.get(i));
Assert.assertEquals(expected.sampleEndOffsets.get(i), sampleEndOffsets.get(i));
if (expected.sampleEncryptionKeys.get(i) == null) {
Assert.assertNull(sampleEncryptionKeys.get(i));
} else {
MoreAsserts.assertEquals(expected.sampleEncryptionKeys.get(i), sampleEncryptionKeys.get(i));
}
}
}
项目:brailleback
文件:TranslatorServiceTest.java
/** Tests that the translator service can translate computer braille. */
public void testTranslateComputerBraille() throws Exception {
ITranslatorService service = getServiceInterface();
assertTrue("expected braille table check to succeed",
service.checkTable(TEST_BRAILLE_TABLE_ID));
TranslationResult result = service.translate("Hello!",
TEST_BRAILLE_TABLE_ID, -1);
MoreAsserts.assertEquals(
new byte[] { 0x53, 0x11, 0x07, 0x07, 0x15, 0x2e },
result.getCells());
MoreAsserts.assertEquals(new int[] { 0, 1, 2, 3, 4, 5 },
result.getTextToBraillePositions());
MoreAsserts.assertEquals(new int[] { 0, 1, 2, 3, 4, 5 },
result.getBrailleToTextPositions());
assertEquals(-1, result.getCursorPosition());
}
项目:android_packages_apps_tv
文件:DvrScheduleManagerTest.java
public void testGetConflictingSchedules_noConflict() {
long priority = 0;
long channelId = 0;
List<ScheduledRecording> schedules = new ArrayList<>();
schedules.add(RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(++channelId,
++priority, 0L, 200L));
MoreAsserts.assertEmpty(DvrScheduleManager.getConflictingSchedules(schedules, 1));
schedules.add(RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(++channelId,
++priority, 0L, 100L));
MoreAsserts.assertEmpty(DvrScheduleManager.getConflictingSchedules(schedules, 2));
schedules.add(RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(++channelId,
++priority, 100L, 200L));
MoreAsserts.assertEmpty(DvrScheduleManager.getConflictingSchedules(schedules, 2));
schedules.add(RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(++channelId,
++priority, 0L, 100L));
MoreAsserts.assertEmpty(DvrScheduleManager.getConflictingSchedules(schedules, 3));
schedules.add(RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(++channelId,
++priority, 100L, 200L));
MoreAsserts.assertEmpty(DvrScheduleManager.getConflictingSchedules(schedules, 3));
}
项目:android_packages_apps_tv
文件:DvrScheduleManagerTest.java
public void testGetConflictingSchedules_conflict2() {
// The case when there is a long schedule.
long priority = 0;
long channelId = 0;
List<ScheduledRecording> schedules = new ArrayList<>();
ScheduledRecording r1 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
++channelId, ++priority, 0L, 1000L);
schedules.add(r1);
MoreAsserts.assertEmpty(DvrScheduleManager.getConflictingSchedules(schedules, 1));
ScheduledRecording r2 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
++channelId, ++priority, 0L, 100L);
schedules.add(r2);
MoreAsserts.assertContentsInOrder(DvrScheduleManager.getConflictingSchedules(schedules, 1),
r1);
MoreAsserts.assertEmpty(DvrScheduleManager.getConflictingSchedules(schedules, 2));
ScheduledRecording r3 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
++channelId, ++priority, 100L, 200L);
schedules.add(r3);
MoreAsserts.assertContentsInOrder(DvrScheduleManager.getConflictingSchedules(schedules, 1),
r1);
MoreAsserts.assertEmpty(DvrScheduleManager.getConflictingSchedules(schedules, 2));
}
项目:android_packages_apps_tv
文件:DvrScheduleManagerTest.java
public void testGetConflictingSchedules_period1() {
long priority = 0;
long channelId = 0;
List<ScheduledRecording> schedules = new ArrayList<>();
ScheduledRecording r1 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
++channelId, ++priority, 0L, 200L);
schedules.add(r1);
ScheduledRecording r2 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
++channelId, ++priority, 0L, 100L);
schedules.add(r2);
MoreAsserts.assertContentsInOrder(DvrScheduleManager.getConflictingSchedules(schedules, 1,
Collections.singletonList(new Range<>(10L, 20L))), r1);
MoreAsserts.assertContentsInOrder(DvrScheduleManager.getConflictingSchedules(schedules, 1,
Collections.singletonList(new Range<>(110L, 120L))), r1);
}
项目:android_packages_apps_tv
文件:DvrScheduleManagerTest.java
public void testGetConflictingSchedules_period2() {
long priority = 0;
long channelId = 0;
List<ScheduledRecording> schedules = new ArrayList<>();
ScheduledRecording r1 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
++channelId, ++priority, 0L, 200L);
schedules.add(r1);
ScheduledRecording r2 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
++channelId, ++priority, 100L, 200L);
schedules.add(r2);
MoreAsserts.assertContentsInOrder(DvrScheduleManager.getConflictingSchedules(schedules, 1,
Collections.singletonList(new Range<>(10L, 20L))), r1);
MoreAsserts.assertContentsInOrder(DvrScheduleManager.getConflictingSchedules(schedules, 1,
Collections.singletonList(new Range<>(110L, 120L))), r1);
}
项目:android_packages_apps_tv
文件:DvrScheduleManagerTest.java
public void testGetConflictingSchedules_addSchedules1() {
long priority = 0;
long channelId = 0;
List<ScheduledRecording> schedules = new ArrayList<>();
ScheduledRecording r1 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
++channelId, ++priority, 0L, 200L);
schedules.add(r1);
ScheduledRecording r2 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
++channelId, ++priority, 0L, 100L);
schedules.add(r2);
MoreAsserts.assertContentsInOrder(DvrScheduleManager.getConflictingSchedules(
Collections.singletonList(
ScheduledRecording.builder(INPUT_ID, ++channelId, 10L, 20L)
.setPriority(++priority).build()),
schedules, 1), r2, r1);
MoreAsserts.assertContentsInOrder(DvrScheduleManager.getConflictingSchedules(
Collections.singletonList(
ScheduledRecording.builder(INPUT_ID, ++channelId, 110L, 120L)
.setPriority(++priority).build()),
schedules, 1), r1);
}
项目:android_packages_apps_tv
文件:DvrScheduleManagerTest.java
public void testGetConflictingSchedules_addSchedules2() {
long priority = 0;
long channelId = 0;
List<ScheduledRecording> schedules = new ArrayList<>();
ScheduledRecording r1 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
++channelId, ++priority, 0L, 200L);
schedules.add(r1);
ScheduledRecording r2 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
++channelId, ++priority, 100L, 200L);
schedules.add(r2);
MoreAsserts.assertContentsInOrder(DvrScheduleManager.getConflictingSchedules(
Collections.singletonList(
ScheduledRecording.builder(INPUT_ID, ++channelId, 10L, 20L)
.setPriority(++priority).build()),
schedules, 1), r1);
MoreAsserts.assertContentsInOrder(DvrScheduleManager.getConflictingSchedules(
Collections.singletonList(
ScheduledRecording.builder(INPUT_ID, ++channelId, 110L, 120L)
.setPriority(++priority).build()),
schedules, 1), r2, r1);
}
项目:android_packages_apps_tv
文件:DvrScheduleManagerTest.java
public void testGetConflictingSchedules_addLowestPriority() {
long priority = 0;
long channelId = 0;
List<ScheduledRecording> schedules = new ArrayList<>();
ScheduledRecording r1 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
++channelId, ++priority, 0L, 400L);
schedules.add(r1);
ScheduledRecording r2 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
++channelId, ++priority, 100L, 200L);
schedules.add(r2);
// Returning r1 even though r1 has the higher priority than the new one. That's because r1
// starts at 0 and stops at 100, and the new one will be recorded successfully.
MoreAsserts.assertContentsInOrder(DvrScheduleManager.getConflictingSchedules(
Collections.singletonList(
ScheduledRecording.builder(INPUT_ID, ++channelId, 200L, 300L)
.setPriority(0).build()),
schedules, 1), r1);
}
项目:android_packages_apps_tv
文件:DvrScheduleManagerTest.java
public void testGetConflictingSchedule_startEarlyAndFail() {
long priority = 0;
long channelId = 0;
List<ScheduledRecording> schedules = new ArrayList<>();
ScheduledRecording r1 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
++channelId, ++priority, 200L, 300L);
schedules.add(r1);
ScheduledRecording r2 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
++channelId, ++priority, 0L, 400L);
schedules.add(r2);
ScheduledRecording r3 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
++channelId, ++priority, 100L, 200L);
schedules.add(r3);
// r2 starts recording and fails when r3 starts. r1 is recorded successfully.
MoreAsserts.assertContentsInOrder(DvrScheduleManager.getConflictingSchedules(schedules, 1),
r2);
}
项目:android_packages_apps_tv
文件:DvrScheduleManagerTest.java
public void testGetConflictingSchedule_startLate() {
long priority = 0;
long channelId = 0;
List<ScheduledRecording> schedules = new ArrayList<>();
ScheduledRecording r1 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
++channelId, ++priority, 200L, 400L);
schedules.add(r1);
ScheduledRecording r2 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
++channelId, ++priority, 100L, 300L);
schedules.add(r2);
ScheduledRecording r3 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
++channelId, ++priority, 0L, 200L);
schedules.add(r3);
// r2 and r1 are clipped.
MoreAsserts.assertContentsInOrder(DvrScheduleManager.getConflictingSchedules(schedules, 1),
r2, r1);
}
项目:android_packages_apps_tv
文件:DvrScheduleManagerTest.java
public void testGetConflictingSchedulesForWatching_otherChannels() {
// The other channels are to be recorded.
long priority = 0;
long channelToWatch = 1;
long channelId = 1;
List<ScheduledRecording> schedules = new ArrayList<>();
ScheduledRecording r1 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
++channelId, ++priority, 0L, 200L);
schedules.add(r1);
ScheduledRecording r2 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
++channelId, ++priority, 0L, 200L);
schedules.add(r2);
MoreAsserts.assertEmpty(DvrScheduleManager.getConflictingSchedulesForWatching(
INPUT_ID, channelToWatch, 0L, ++priority, schedules, 3));
MoreAsserts.assertContentsInOrder(DvrScheduleManager.getConflictingSchedulesForWatching(
INPUT_ID, channelToWatch, 0L, ++priority, schedules, 2), r1);
}
项目:android_packages_apps_tv
文件:DvrScheduleManagerTest.java
public void testGetConflictingSchedulesForWatching_sameChannel1() {
long priority = 0;
long channelToWatch = 1;
long channelId = 1;
List<ScheduledRecording> schedules = new ArrayList<>();
ScheduledRecording r1 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
channelToWatch, ++priority, 0L, 200L);
schedules.add(r1);
ScheduledRecording r2 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
++channelId, ++priority, 0L, 200L);
schedules.add(r2);
MoreAsserts.assertEmpty(DvrScheduleManager.getConflictingSchedulesForWatching(
INPUT_ID, channelToWatch, 0L, ++priority, schedules, 2));
MoreAsserts.assertContentsInOrder(DvrScheduleManager.getConflictingSchedulesForWatching(
INPUT_ID, channelToWatch, 0L, ++priority, schedules, 1), r2);
}
项目:android_packages_apps_tv
文件:DvrScheduleManagerTest.java
public void testGetConflictingSchedulesForWatching_sameChannel2() {
long priority = 0;
long channelToWatch = 1;
long channelId = 1;
List<ScheduledRecording> schedules = new ArrayList<>();
ScheduledRecording r1 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
++channelId, ++priority, 0L, 200L);
schedules.add(r1);
ScheduledRecording r2 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
channelToWatch, ++priority, 0L, 200L);
schedules.add(r2);
MoreAsserts.assertEmpty(DvrScheduleManager.getConflictingSchedulesForWatching(
INPUT_ID, channelToWatch, 0L, ++priority, schedules, 2));
MoreAsserts.assertContentsInOrder(DvrScheduleManager.getConflictingSchedulesForWatching(
INPUT_ID, channelToWatch, 0L, ++priority, schedules, 1), r1);
}
项目:android_packages_apps_tv
文件:DvrScheduleManagerTest.java
public void testGetConflictingSchedulesForWatching_sameChannelConflict1() {
long priority = 0;
long channelToWatch = 1;
long channelId = 1;
List<ScheduledRecording> schedules = new ArrayList<>();
ScheduledRecording r1 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
++channelId, ++priority, 0L, 200L);
schedules.add(r1);
ScheduledRecording r2 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
channelToWatch, ++priority, 0L, 200L);
schedules.add(r2);
ScheduledRecording r3 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
channelToWatch, ++priority, 0L, 200L);
schedules.add(r3);
MoreAsserts.assertContentsInOrder(DvrScheduleManager.getConflictingSchedulesForWatching(
INPUT_ID, channelToWatch, 0L, ++priority, schedules, 3), r2);
MoreAsserts.assertContentsInOrder(DvrScheduleManager.getConflictingSchedulesForWatching(
INPUT_ID, channelToWatch, 0L, ++priority, schedules, 2), r2);
MoreAsserts.assertContentsInOrder(DvrScheduleManager.getConflictingSchedulesForWatching(
INPUT_ID, channelToWatch, 0L, ++priority, schedules, 1), r2, r1);
}
项目:android_packages_apps_tv
文件:DvrScheduleManagerTest.java
public void testGetConflictingSchedulesForWatching_sameChannelConflict2() {
long priority = 0;
long channelToWatch = 1;
long channelId = 1;
List<ScheduledRecording> schedules = new ArrayList<>();
ScheduledRecording r1 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
channelToWatch, ++priority, 0L, 200L);
schedules.add(r1);
ScheduledRecording r2 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
channelToWatch, ++priority, 0L, 200L);
schedules.add(r2);
ScheduledRecording r3 = RecordingTestUtils.createTestRecordingWithPriorityAndPeriod(
++channelId, ++priority, 0L, 200L);
schedules.add(r3);
MoreAsserts.assertContentsInOrder(DvrScheduleManager.getConflictingSchedulesForWatching(
INPUT_ID, channelToWatch, 0L, ++priority, schedules, 3), r1);
MoreAsserts.assertContentsInOrder(DvrScheduleManager.getConflictingSchedulesForWatching(
INPUT_ID, channelToWatch, 0L, ++priority, schedules, 2), r1);
MoreAsserts.assertContentsInOrder(DvrScheduleManager.getConflictingSchedulesForWatching(
INPUT_ID, channelToWatch, 0L, ++priority, schedules, 1), r3, r1);
}
项目:android_packages_apps_tv
文件:SeriesRecordingSchedulerTest.java
public void testPickOneProgramPerEpisode_manyPerEpisode() {
SeriesRecording seriesRecording = SeriesRecording.buildFrom(mBaseSeriesRecording)
.setId(SERIES_RECORDING_ID1).build();
mDataManager.addSeriesRecording(seriesRecording);
List<Program> programs = new ArrayList<>();
Program program1 = new Program.Builder(mBaseProgram).setSeasonNumber(SEASON_NUMBER1)
.setEpisodeNumber(EPISODE_NUMBER1).setStartTimeUtcMillis(0).build();
programs.add(program1);
Program program2 = new Program.Builder(program1).setStartTimeUtcMillis(1).build();
programs.add(program2);
Program program3 = new Program.Builder(mBaseProgram).setSeasonNumber(SEASON_NUMBER2)
.setEpisodeNumber(EPISODE_NUMBER2).build();
programs.add(program3);
Program program4 = new Program.Builder(program1).setStartTimeUtcMillis(1).build();
programs.add(program4);
LongSparseArray<List<Program>> result = SeriesRecordingScheduler.pickOneProgramPerEpisode(
mDataManager, Collections.singletonList(seriesRecording), programs);
MoreAsserts.assertContentsInAnyOrder(result.get(SERIES_RECORDING_ID1), program1, program3);
}
项目:android_packages_apps_tv
文件:RecommenderTest.java
public void testRecommendChannels_includeRecommendedOnly_allChannelsHaveScore() {
createRecommender(true, START_DATAMANAGER_RUNNABLE_ADD_FOUR_CHANNELS);
setChannelScores_scoreIncreasesAsChannelIdIncreases();
// recommendChannels must be sorted by score in decreasing order.
// (i.e. sorted by channel ID in decreasing order in this case)
MoreAsserts.assertContentsInOrder(mRecommender.recommendChannels(),
mChannel_4, mChannel_3, mChannel_2, mChannel_1);
assertEquals(0, mRecommender.recommendChannels(-5).size());
assertEquals(0, mRecommender.recommendChannels(0).size());
MoreAsserts.assertContentsInOrder(mRecommender.recommendChannels(3),
mChannel_4, mChannel_3, mChannel_2);
MoreAsserts.assertContentsInOrder(mRecommender.recommendChannels(4),
mChannel_4, mChannel_3, mChannel_2, mChannel_1);
MoreAsserts.assertContentsInOrder(mRecommender.recommendChannels(5),
mChannel_4, mChannel_3, mChannel_2, mChannel_1);
}
项目:android_packages_apps_tv
文件:RecommenderTest.java
public void testRecommendChannels_notIncludeRecommendedOnly_allChannelsHaveScore() {
createRecommender(false, START_DATAMANAGER_RUNNABLE_ADD_FOUR_CHANNELS);
setChannelScores_scoreIncreasesAsChannelIdIncreases();
// recommendChannels must be sorted by score in decreasing order.
// (i.e. sorted by channel ID in decreasing order in this case)
MoreAsserts.assertContentsInOrder(mRecommender.recommendChannels(),
mChannel_4, mChannel_3, mChannel_2, mChannel_1);
assertEquals(0, mRecommender.recommendChannels(-5).size());
assertEquals(0, mRecommender.recommendChannels(0).size());
MoreAsserts.assertContentsInOrder(mRecommender.recommendChannels(3),
mChannel_4, mChannel_3, mChannel_2);
MoreAsserts.assertContentsInOrder(mRecommender.recommendChannels(4),
mChannel_4, mChannel_3, mChannel_2, mChannel_1);
MoreAsserts.assertContentsInOrder(mRecommender.recommendChannels(5),
mChannel_4, mChannel_3, mChannel_2, mChannel_1);
}
项目:android_packages_apps_tv
文件:RecommenderTest.java
public void testRecommendChannels_includeRecommendedOnly_fewChannelsHaveScore() {
createRecommender(true, START_DATAMANAGER_RUNNABLE_ADD_FOUR_CHANNELS);
mEvaluator.setChannelScore(mChannel_1.getId(), 1.0);
mEvaluator.setChannelScore(mChannel_2.getId(), 1.0);
// Only two channels are recommended because recommender doesn't recommend other channels.
MoreAsserts.assertContentsInAnyOrder(mRecommender.recommendChannels(),
mChannel_1, mChannel_2);
assertEquals(0, mRecommender.recommendChannels(-5).size());
assertEquals(0, mRecommender.recommendChannels(0).size());
MoreAsserts.assertContentsInAnyOrder(mRecommender.recommendChannels(3),
mChannel_1, mChannel_2);
MoreAsserts.assertContentsInAnyOrder(mRecommender.recommendChannels(4),
mChannel_1, mChannel_2);
MoreAsserts.assertContentsInAnyOrder(mRecommender.recommendChannels(5),
mChannel_1, mChannel_2);
}
项目:android_packages_apps_tv
文件:RecommenderTest.java
public void testRecommendChannels_notIncludeRecommendedOnly_fewChannelsHaveScore() {
createRecommender(false, START_DATAMANAGER_RUNNABLE_ADD_FOUR_CHANNELS);
mEvaluator.setChannelScore(mChannel_1.getId(), 1.0);
mEvaluator.setChannelScore(mChannel_2.getId(), 1.0);
assertEquals(4, mRecommender.recommendChannels().size());
MoreAsserts.assertContentsInAnyOrder(mRecommender.recommendChannels().subList(0, 2),
mChannel_1, mChannel_2);
assertEquals(0, mRecommender.recommendChannels(-5).size());
assertEquals(0, mRecommender.recommendChannels(0).size());
assertEquals(3, mRecommender.recommendChannels(3).size());
MoreAsserts.assertContentsInAnyOrder(mRecommender.recommendChannels(3).subList(0, 2),
mChannel_1, mChannel_2);
assertEquals(4, mRecommender.recommendChannels(4).size());
MoreAsserts.assertContentsInAnyOrder(mRecommender.recommendChannels(4).subList(0, 2),
mChannel_1, mChannel_2);
assertEquals(4, mRecommender.recommendChannels(5).size());
MoreAsserts.assertContentsInAnyOrder(mRecommender.recommendChannels(5).subList(0, 2),
mChannel_1, mChannel_2);
}
项目:android_packages_apps_tv
文件:RecommenderTest.java
public void testGetChannelSortKey_recommendFewChannels() {
// Test with recommending 3 channels.
createRecommender(true, START_DATAMANAGER_RUNNABLE_ADD_FOUR_CHANNELS);
setChannelScores_scoreIncreasesAsChannelIdIncreases();
List<Channel> expectedChannelList = mRecommender.recommendChannels(3);
// A channel which is not recommended by the recommender has to get an invalid sort key.
assertEquals(Recommender.INVALID_CHANNEL_SORT_KEY,
mRecommender.getChannelSortKey(mChannel_1.getId()));
List<Channel> channelList = Arrays.asList(mChannel_2, mChannel_3, mChannel_4);
Collections.sort(channelList, CHANNEL_SORT_KEY_COMPARATOR);
MoreAsserts.assertContentsInOrder(channelList, expectedChannelList.toArray());
assertSortKeyNotInvalid(channelList);
}
项目:sqlite-android
文件:DatabaseLocaleTest.java
@Suppress // not supporting localized collators
@MediumTest
public void testLocaleenUS() throws Exception {
insertStrings();
Log.i("LocaleTest", "about to call setLocale en_US");
mDatabase.setLocale(new Locale("en", "US"));
String[] results;
results = query("SELECT data FROM test ORDER BY data COLLATE LOCALIZED ASC");
// The database code currently uses PRIMARY collation strength,
// meaning that all versions of a character compare equal (regardless
// of case or accents), leaving the "cote" flavors in database order.
MoreAsserts.assertEquals(results, new String[] {
STRINGS[4], // "boy"
STRINGS[0], // sundry forms of "cote"
STRINGS[1],
STRINGS[2],
STRINGS[3],
STRINGS[6], // "COTE"
STRINGS[5], // "dog"
});
}
项目:ExoPlayer-Demo
文件:FakeTrackOutput.java
public void assertEquals(FakeTrackOutput expected) {
Assert.assertEquals(expected.format, format);
Assert.assertEquals(expected.sampleTimesUs.size(), sampleTimesUs.size());
MoreAsserts.assertEquals(expected.sampleData, sampleData);
for (int i = 0; i < sampleTimesUs.size(); i++) {
Assert.assertEquals(expected.sampleTimesUs.get(i), sampleTimesUs.get(i));
Assert.assertEquals(expected.sampleFlags.get(i), sampleFlags.get(i));
Assert.assertEquals(expected.sampleStartOffsets.get(i), sampleStartOffsets.get(i));
Assert.assertEquals(expected.sampleEndOffsets.get(i), sampleEndOffsets.get(i));
if (expected.sampleEncryptionKeys.get(i) == null) {
Assert.assertNull(sampleEncryptionKeys.get(i));
} else {
MoreAsserts.assertEquals(expected.sampleEncryptionKeys.get(i), sampleEncryptionKeys.get(i));
}
}
}
项目:videoPickPlayer
文件:CacheDataSourceTest.java
private void assertReadData(CacheDataSource cacheDataSource, boolean unknownLength, int position,
int length) throws IOException {
int actualLength = TEST_DATA.length - position;
if (length != C.LENGTH_UNSET) {
actualLength = Math.min(actualLength, length);
}
assertEquals(unknownLength ? length : actualLength,
cacheDataSource.open(new DataSpec(Uri.EMPTY, position, length, KEY_1)));
byte[] buffer = new byte[100];
int index = 0;
while (true) {
int read = cacheDataSource.read(buffer, index, buffer.length - index);
if (read == C.RESULT_END_OF_INPUT) {
break;
}
index += read;
}
assertEquals(actualLength, index);
MoreAsserts.assertEquals(Arrays.copyOfRange(TEST_DATA, position, position + actualLength),
Arrays.copyOf(buffer, index));
cacheDataSource.close();
}
项目:fantasywear
文件:LeagueParserTest.java
public void testParser() throws Exception {
League league = new League.Builder()
.league_key("key1")
.league_name("name1")
.build();
InputStream is = getInstrumentation().getContext().getResources()
.openRawResource(R.raw.league_example);
// Can't use try-with-resources here; we support pre-API-19 devices.
//noinspection TryFinallyCanBeTryWithResources
try {
InputStreamReader isr = new InputStreamReader(is, "UTF-8");
MoreAsserts.assertEquals(new League[] { league }, LeagueParser.parseXml(isr));
} finally {
is.close();
}
}
项目:fantasywear
文件:LeagueTableTest.java
public void testUpdateLeagues_clearAll() {
League[] leagues = new League[] {
new League.Builder()
.account_name(ACCOUNT.name)
.league_key("key")
.league_name("name")
.build(),
};
League[] leagues2 = new League[] {
new League.Builder()
.account_name(ACCOUNT2.name)
.league_key("key")
.league_name("name")
.build(),
};
League[] noLeagues = new League[] {};
LeagueTable.updateLeagues(mTestContext, ACCOUNT, leagues);
LeagueTable.updateLeagues(mTestContext, ACCOUNT2, leagues2);
LeagueTable.updateLeagues(mTestContext, ACCOUNT, noLeagues);
MoreAsserts.assertEquals(noLeagues, LeagueTable.getLeagues(mTestContext, ACCOUNT));
MoreAsserts.assertEquals(leagues2, LeagueTable.getLeagues(mTestContext, ACCOUNT2));
}
项目:authenticator
文件:AccountDbTest.java
public void testConstruct_whenDatabaseWithoutProviderColumn() {
deleteAccountDb();
SQLiteDatabase database =
DependencyInjector.getContext().openOrCreateDatabase(
AccountDb.PATH, Context.MODE_PRIVATE, null);
database.execSQL("CREATE TABLE " + AccountDb.TABLE_NAME + " (first INTEGER)");
MoreAsserts.assertContentsInAnyOrder(
AccountDb.listTableColumnNamesLowerCase(database, AccountDb.TABLE_NAME),
"first");
database.close();
database = null;
accountDb = DependencyInjector.getAccountDb();
MoreAsserts.assertContentsInAnyOrder(
AccountDb.listTableColumnNamesLowerCase(accountDb.mDatabase, AccountDb.TABLE_NAME),
"first", AccountDb.PROVIDER_COLUMN);
}
项目:j2objc
文件:SpannableTest.java
@MediumTest
public void testGetSpans() {
Spannable spannable = newSpannableWithText("abcdef");
Object emptySpan = new Object();
spannable.setSpan(emptySpan, 1, 1, 0);
Object unemptySpan = new Object();
spannable.setSpan(unemptySpan, 1, 2, 0);
Object[] spans;
// Empty spans are included when they merely abut the query region
// but other spans are not, unless the query region is empty, in
// in which case any abutting spans are returned.
spans = spannable.getSpans(0, 1, Object.class);
MoreAsserts.assertEquals(new Object[]{emptySpan}, spans);
spans = spannable.getSpans(0, 2, Object.class);
MoreAsserts.assertEquals(new Object[]{emptySpan, unemptySpan}, spans);
spans = spannable.getSpans(1, 2, Object.class);
MoreAsserts.assertEquals(new Object[]{emptySpan, unemptySpan}, spans);
spans = spannable.getSpans(2, 2, Object.class);
MoreAsserts.assertEquals(new Object[]{unemptySpan}, spans);
}
项目:transistor
文件:CacheAsserts.java
/** Asserts that the cache contains the given data for {@code uriString}. */
public static void assertDataCached(Cache cache, Uri uri, byte[] expected) throws IOException {
CacheDataSource dataSource = new CacheDataSource(cache, DummyDataSource.INSTANCE, 0);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
DataSourceInputStream inputStream = new DataSourceInputStream(dataSource,
new DataSpec(uri, DataSpec.FLAG_ALLOW_CACHING_UNKNOWN_LENGTH));
try {
inputStream.open();
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
} catch (IOException e) {
// Ignore
} finally {
inputStream.close();
}
MoreAsserts.assertEquals("Cached data doesn't match expected for '" + uri + "',",
expected, outputStream.toByteArray());
}
项目:transistor
文件:FakeTrackOutput.java
public void assertEquals(FakeTrackOutput expected) {
Assert.assertEquals(expected.format, format);
Assert.assertEquals(expected.sampleTimesUs.size(), sampleTimesUs.size());
MoreAsserts.assertEquals(expected.sampleData, sampleData);
for (int i = 0; i < sampleTimesUs.size(); i++) {
Assert.assertEquals(expected.sampleTimesUs.get(i), sampleTimesUs.get(i));
Assert.assertEquals(expected.sampleFlags.get(i), sampleFlags.get(i));
Assert.assertEquals(expected.sampleStartOffsets.get(i), sampleStartOffsets.get(i));
Assert.assertEquals(expected.sampleEndOffsets.get(i), sampleEndOffsets.get(i));
if (expected.cryptoDatas.get(i) == null) {
Assert.assertNull(cryptoDatas.get(i));
} else {
Assert.assertEquals(expected.cryptoDatas.get(i), cryptoDatas.get(i));
}
}
}
项目:transistor
文件:CachedContentIndexTest.java
public void testStoreV1() throws Exception {
index.addNew(new CachedContent(2, "KLMNO", 2560));
index.addNew(new CachedContent(5, "ABCDE", 10));
index.store();
byte[] buffer = new byte[testIndexV1File.length];
FileInputStream fos = new FileInputStream(new File(cacheDir, CachedContentIndex.FILE_NAME));
assertEquals(testIndexV1File.length, fos.read(buffer));
assertEquals(-1, fos.read());
fos.close();
// TODO: The order of the CachedContent stored in index file isn't defined so this test may fail
// on a different implementation of the underlying set
MoreAsserts.assertEquals(testIndexV1File, buffer);
}
项目:transistor
文件:SsManifestTest.java
private static void assertManifestEquals(SsManifest expected, SsManifest actual) {
assertEquals(expected.durationUs, actual.durationUs);
assertEquals(expected.dvrWindowLengthUs, actual.dvrWindowLengthUs);
assertEquals(expected.isLive, actual.isLive);
assertEquals(expected.lookAheadCount, actual.lookAheadCount);
assertEquals(expected.majorVersion, actual.majorVersion);
assertEquals(expected.minorVersion, actual.minorVersion);
assertEquals(expected.protectionElement.uuid, actual.protectionElement.uuid);
assertEquals(expected.protectionElement, actual.protectionElement);
for (int i = 0; i < expected.streamElements.length; i++) {
StreamElement expectedStreamElement = expected.streamElements[i];
StreamElement actualStreamElement = actual.streamElements[i];
assertEquals(expectedStreamElement.chunkCount, actualStreamElement.chunkCount);
assertEquals(expectedStreamElement.displayHeight, actualStreamElement.displayHeight);
assertEquals(expectedStreamElement.displayWidth, actualStreamElement.displayWidth);
assertEquals(expectedStreamElement.language, actualStreamElement.language);
assertEquals(expectedStreamElement.maxHeight, actualStreamElement.maxHeight);
assertEquals(expectedStreamElement.maxWidth, actualStreamElement.maxWidth);
assertEquals(expectedStreamElement.name, actualStreamElement.name);
assertEquals(expectedStreamElement.subType, actualStreamElement.subType);
assertEquals(expectedStreamElement.timescale, actualStreamElement.timescale);
assertEquals(expectedStreamElement.type, actualStreamElement.type);
MoreAsserts.assertEquals(expectedStreamElement.formats, actualStreamElement.formats);
}
}
项目:google-authenticator-android
文件:AccountDbTest.java
public void testConstruct_whenDatabaseWithoutProviderColumn() {
deleteAccountDb();
SQLiteDatabase database =
DependencyInjector.getContext().openOrCreateDatabase(
AccountDb.PATH, Context.MODE_PRIVATE, null);
database.execSQL("CREATE TABLE " + AccountDb.TABLE_NAME + " (first INTEGER)");
MoreAsserts.assertContentsInAnyOrder(
AccountDb.listTableColumnNamesLowerCase(database, AccountDb.TABLE_NAME),
"first");
database.close();
database = null;
accountDb = DependencyInjector.getAccountDb();
MoreAsserts.assertContentsInAnyOrder(
AccountDb.listTableColumnNamesLowerCase(accountDb.mDatabase, AccountDb.TABLE_NAME),
"first", AccountDb.PROVIDER_COLUMN);
}