@Config(minSdk = LOLLIPOP) @Test public void testSomeApiLevel() { assertThat(Build.VERSION.SDK_INT).isAtLeast(LOLLIPOP); } }
@Test public void testSomeApiLevel() { assertThat(Build.VERSION.SDK_INT).isAtLeast(LOLLIPOP); } }
@Test public void query_shouldReturnColumnIndexes() throws Exception { ShadowDownloadManager manager = new ShadowDownloadManager(); long id = manager.enqueue(request.setDestinationUri(destination)); Cursor cursor = manager.query(new DownloadManager.Query().setFilterById(id)); assertThat(cursor.getColumnIndex(DownloadManager.COLUMN_URI)).isAtLeast(0); assertThat(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI)).isAtLeast(0); assertThat(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_FILENAME)).isAtLeast(0); assertThat(cursor.getColumnIndex(DownloadManager.COLUMN_DESCRIPTION)).isAtLeast(0); assertThat(cursor.getColumnIndex(DownloadManager.COLUMN_REASON)).isAtLeast(0); assertThat(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS)).isAtLeast(0); }
@Test public void testReturnsByte_whenReadsUpToMarkLimit_withNoMoreBytesAvailable() throws IOException { MarkEnforcingInputStream is = new MarkEnforcingInputStream(new ByteArrayInputStream(new byte[MARK_LIMIT])); for (int i = 0; i < MARK_LIMIT; i++) { assertThat(is.read()).isAtLeast(0); } }
@Test public void matchData_MatchesAnyTypeAndSubtype() throws IntentFilter.MalformedMimeTypeException { IntentFilter intentFilter = new IntentFilter(); intentFilter.addDataScheme("content"); intentFilter.addDataType("*/*"); Uri uri = Uri.parse("content://authority/images"); assertThat(intentFilter.matchData("image/test", "content", uri)).isAtLeast(0); assertThat(intentFilter.matchData("image/*", "content", uri)).isAtLeast(0); assertThat(intentFilter.matchData("video/test", "content", uri)).isAtLeast(0); assertThat(intentFilter.matchData("video/*", "content", uri)).isAtLeast(0); }
@Test public void matchData_MatchEmpty() throws IntentFilter.MalformedMimeTypeException { IntentFilter intentFilter = new IntentFilter(); assertThat(intentFilter.matchData(null, "noscheme", null)) .isAtLeast(0); }
@Test public void testReturnsByte_whenReadsUpToMarkLimit_withMoreBytesAvailable() throws IOException { MarkEnforcingInputStream is = new MarkEnforcingInputStream(new ByteArrayInputStream(new byte[DATA_SIZE])); is.mark(MARK_LIMIT); for (int i = 0; i < MARK_LIMIT; i++) { assertThat(is.read()).isAtLeast(0); } }
@Test public void testResetUnsetsLimit() throws IOException { MarkEnforcingInputStream is = new MarkEnforcingInputStream(new ByteArrayInputStream(new byte[DATA_SIZE])); is.mark(MARK_LIMIT); for (int i = 0; i < MARK_LIMIT; i++) { assertThat(is.read()).isAtLeast(0); } is.reset(); for (int i = 0; i < DATA_SIZE; i++) { assertThat(is.read()).isAtLeast(0); } }
@Test public void glGenFramebuffers() { int[] framebuffers = new int[1]; GLES20.glGenFramebuffers(1, framebuffers, 0); assertThat(framebuffers[0]).isAtLeast(1); }
@Test public void glGenTextures() { int[] textures = new int[1]; GLES20.glGenTextures(1, textures, 0); assertThat(textures[0]).isAtLeast(1); }
@Test public void glCreateShader_validEnum() { assertThat(GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER)).isAtLeast(1); }
@Test public void glCreateProgram() { assertThat(GLES20.glCreateProgram()).isAtLeast(1); }
@Test public void matchData_MatchScheme() throws IntentFilter.MalformedMimeTypeException { IntentFilter intentFilter = new IntentFilter(); intentFilter.addDataScheme("http"); Uri uriTest1 = Uri.parse("http://testHost1:1"); assertThat(intentFilter.matchData(null, "http", uriTest1)) .isAtLeast(0); }
@Test public void matchData_MatchType() throws IntentFilter.MalformedMimeTypeException { IntentFilter intentFilter = new IntentFilter(); intentFilter.addDataType("image/test"); intentFilter.addDataScheme("http"); Uri uriTest1 = Uri.parse("http://testHost1:1"); assertThat(intentFilter.matchData("image/test", "http", uriTest1)) .isAtLeast(0); }
@Test public void testReturnsEndOfStream_whenReadsSingleBytePastMarkLimit() throws IOException { MarkEnforcingInputStream is = new MarkEnforcingInputStream(new ByteArrayInputStream(new byte[DATA_SIZE])); is.mark(MARK_LIMIT); for (int i = 0; i < MARK_LIMIT; i++) { assertThat(is.read()).isAtLeast(0); } assertEquals(-1, is.read()); }
@Test public void obtainStyledAttributesShouldDereferenceValues() { Resources.Theme theme = resources.newTheme(); theme.applyStyle(R.style.MyBlackTheme, false); TypedArray arr = theme.obtainStyledAttributes(new int[]{android.R.attr.windowBackground}); TypedValue value = new TypedValue(); arr.getValue(0, value); arr.recycle(); assertThat(value.type).isAtLeast(TYPE_FIRST_COLOR_INT); assertThat(value.type).isAtMost(TYPE_LAST_INT); }
@Test public void matchData_MatchesPartialType() throws IntentFilter.MalformedMimeTypeException { IntentFilter intentFilter = new IntentFilter(); intentFilter.addDataScheme("content"); intentFilter.addDataType("image/*"); Uri uri = Uri.parse("content://authority/images"); assertThat(intentFilter.matchData("image/test", "content", uri)).isAtLeast(0); assertThat(intentFilter.matchData("video/test", "content", uri)).isLessThan(0); }
@Test public void testDoesNotReadIntoBuffer_withZeroBytesRemainingInMarkLimit() throws IOException { byte[] expected = new byte[MARK_LIMIT]; for (int i = 0; i < MARK_LIMIT; i++) { expected[i] = (byte) (i + 1); } byte[] buffer = new byte[MARK_LIMIT]; System.arraycopy(expected, 0, buffer, 0, MARK_LIMIT); // All zeros. MarkEnforcingInputStream is = new MarkEnforcingInputStream(new ByteArrayInputStream(new byte[DATA_SIZE])); is.mark(MARK_LIMIT); for (int i = 0; i < MARK_LIMIT; i++) { assertThat(is.read()).isAtLeast(0); } assertEquals(-1, is.read(buffer)); assertThat(buffer).isEqualTo(expected); }
@Test public void matchData_MatchAll() throws IntentFilter.MalformedMimeTypeException{ IntentFilter intentFilter = new IntentFilter(); intentFilter.addDataType("image/test"); intentFilter.addDataScheme("http"); intentFilter.addDataAuthority("testHost1", "1"); Uri uriTest1 = Uri.parse("http://testHost1:1"); assertThat(intentFilter.matchData("image/test", "http", uriTest1)) .isAtLeast(0); }
private void assertInvariants(Parcel p) { assertWithMessage("capacity >= size").that(p.dataCapacity()).isAtLeast(p.dataSize()); assertWithMessage("position <= size").that(p.dataPosition()).isAtMost(p.dataSize()); assertWithMessage("available = size - position") .that(p.dataAvail()) .isEqualTo(p.dataSize() - p.dataPosition()); assertWithMessage("size % 4 == 0").that(p.dataSize() % 4).isEqualTo(0); assertWithMessage("capacity % 4 == 0").that(p.dataSize() % 4).isEqualTo(0); } }