本文整理汇总了Java中android.test.MoreAsserts.assertEquals方法的典型用法代码示例。如果您正苦于以下问题:Java MoreAsserts.assertEquals方法的具体用法?Java MoreAsserts.assertEquals怎么用?Java MoreAsserts.assertEquals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.test.MoreAsserts
的用法示例。
在下文中一共展示了MoreAsserts.assertEquals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encryptionKey_keyStorage
import android.test.MoreAsserts; //导入方法依赖的package包/类
@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());
}
示例2: assertEquals
import android.test.MoreAsserts; //导入方法依赖的package包/类
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));
}
}
}
示例3: testTranslateComputerBraille
import android.test.MoreAsserts; //导入方法依赖的package包/类
/** 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());
}
示例4: testLocaleenUS
import android.test.MoreAsserts; //导入方法依赖的package包/类
@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"
});
}
示例5: assertReadData
import android.test.MoreAsserts; //导入方法依赖的package包/类
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();
}
示例6: testParser
import android.test.MoreAsserts; //导入方法依赖的package包/类
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();
}
}
示例7: testStoreV1
import android.test.MoreAsserts; //导入方法依赖的package包/类
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);
}
示例8: assertManifestEquals
import android.test.MoreAsserts; //导入方法依赖的package包/类
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);
}
}
示例9: testGetSpans
import android.test.MoreAsserts; //导入方法依赖的package包/类
@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);
}
示例10: assertSample
import android.test.MoreAsserts; //导入方法依赖的package包/类
public void assertSample(int index, byte[] data, long timeUs, int flags, byte[] encryptionKey) {
byte[] actualData = getSampleData(index);
MoreAsserts.assertEquals(data, actualData);
Assert.assertEquals(timeUs, (long) sampleTimesUs.get(index));
Assert.assertEquals(flags, (int) sampleFlags.get(index));
byte[] sampleEncryptionKey = sampleEncryptionKeys.get(index);
if (encryptionKey == null) {
Assert.assertEquals(null, sampleEncryptionKey);
} else {
MoreAsserts.assertEquals(encryptionKey, sampleEncryptionKey);
}
}
示例11: testStringToContentRatings_double
import android.test.MoreAsserts; //导入方法依赖的package包/类
public void testStringToContentRatings_double() {
TvContentRating[] results = TvContentRatingCache.stringToContentRatings(
TvContentRatingConstants.STRING_US_TV_MA + ","
+ TvContentRatingConstants.STRING_US_TV_MA);
MoreAsserts
.assertEquals("ratings", asArray(TvContentRatingConstants.CONTENT_RATING_US_TV_MA),
results);
}
示例12: testParseApicFrame
import android.test.MoreAsserts; //导入方法依赖的package包/类
public void testParseApicFrame() throws ParserException {
byte[] rawId3 = new byte[] {73, 68, 51, 4, 0, 0, 0, 0, 0, 45, 65, 80, 73, 67, 0, 0, 0, 35, 0, 0,
3, 105, 109, 97, 103, 101, 47, 106, 112, 101, 103, 0, 16, 72, 101, 108, 108, 111, 32, 87,
111, 114, 108, 100, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
Id3Parser parser = new Id3Parser();
List<Id3Frame> id3Frames = parser.parse(rawId3, rawId3.length);
assertEquals(1, id3Frames.size());
ApicFrame apicFrame = (ApicFrame) id3Frames.get(0);
assertEquals("image/jpeg", apicFrame.mimeType);
assertEquals(16, apicFrame.pictureType);
assertEquals("Hello World", apicFrame.description);
assertEquals(10, apicFrame.pictureData.length);
MoreAsserts.assertEquals(new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}, apicFrame.pictureData);
}
示例13: assertSample
import android.test.MoreAsserts; //导入方法依赖的package包/类
public void assertSample(int index, byte[] data, long timeUs, int flags, byte[] encryptionKey) {
byte[] actualData = Arrays.copyOfRange(sampleData, sampleStartOffsets.get(index),
sampleEndOffsets.get(index));
MoreAsserts.assertEquals(data, actualData);
Assert.assertEquals(timeUs, (long) sampleTimesUs.get(index));
Assert.assertEquals(flags, (int) sampleFlags.get(index));
byte[] sampleEncryptionKey = sampleEncryptionKeys.get(index);
if (encryptionKey == null) {
Assert.assertEquals(null, sampleEncryptionKey);
} else {
MoreAsserts.assertEquals(encryptionKey, sampleEncryptionKey);
}
}
示例14: testDecodeApicFrame
import android.test.MoreAsserts; //导入方法依赖的package包/类
public void testDecodeApicFrame() throws MetadataDecoderException {
byte[] rawId3 = new byte[] {73, 68, 51, 4, 0, 0, 0, 0, 0, 45, 65, 80, 73, 67, 0, 0, 0, 35, 0, 0,
3, 105, 109, 97, 103, 101, 47, 106, 112, 101, 103, 0, 16, 72, 101, 108, 108, 111, 32, 87,
111, 114, 108, 100, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
Id3Decoder decoder = new Id3Decoder();
List<Id3Frame> id3Frames = decoder.decode(rawId3, rawId3.length);
assertEquals(1, id3Frames.size());
ApicFrame apicFrame = (ApicFrame) id3Frames.get(0);
assertEquals("image/jpeg", apicFrame.mimeType);
assertEquals(16, apicFrame.pictureType);
assertEquals("Hello World", apicFrame.description);
assertEquals(10, apicFrame.pictureData.length);
MoreAsserts.assertEquals(new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}, apicFrame.pictureData);
}
示例15: testRemoveColumns
import android.test.MoreAsserts; //导入方法依赖的package包/类
public void testRemoveColumns() {
CommandCursor cursor = new CommandCursor("cmd_test_1");
assertNotNull(cursor);
cursor.addColumn("colName1");
cursor.addColumn("colName2");
cursor.addColumn("colName3");
cursor.addColumn("colName4");
cursor.addColumn("colName5");
cursor.addColumn("colName6");
String [] expected1 = {
"colName1",
"colName2",
"colName3",
"colName4",
"colName5",
"colName6",
};
MoreAsserts.assertEquals(expected1, cursor.getColumnNames());
cursor.removeColumn("colName3");
cursor.removeColumn("colName5");
String [] expected2 = {
"colName1",
"colName2",
"colName4",
"colName6",
};
MoreAsserts.assertEquals(expected2, cursor.getColumnNames());
}