-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#457: Converted java to Kotlin #835
base: dev
Are you sure you want to change the base?
Changes from 5 commits
2289519
5126d52
9adb008
3a5dd0d
8904edd
6a2d3bf
d0a775c
1367aa5
c0fa2d3
5299712
7b7b6c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package pl.droidsonroids.gif | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation | ||
import org.assertj.core.api.Assertions | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class AllocationByteCountTest { | ||
@Test | ||
@Throws(Exception::class) | ||
fun allocationByteCountIsConsistent() { | ||
val resources = getInstrumentation().context.resources | ||
val drawable = GifDrawable(resources, pl.droidsonroids.gif.test.R.raw.test) | ||
val metaData = GifAnimationMetaData(resources, pl.droidsonroids.gif.test.R.raw.test) | ||
Assertions.assertThat(drawable.frameByteCount + metaData.allocationByteCount) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. import |
||
.isEqualTo(drawable.allocationByteCount) | ||
Assertions.assertThat(metaData.getDrawableAllocationByteCount(null, 1)) | ||
.isEqualTo(drawable.allocationByteCount) | ||
Assertions.assertThat(metaData.getDrawableAllocationByteCount(drawable, 1)) | ||
.isEqualTo(drawable.allocationByteCount) | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package pl.droidsonroids.gif | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.rules.ExpectedException | ||
import org.junit.rules.TemporaryFolder | ||
import org.junit.runner.RunWith | ||
import pl.droidsonroids.gif.GifIOException | ||
import java.io.File | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class ErrnoMessageTest { | ||
@get:Rule | ||
var mExpectedException = ExpectedException.none() | ||
|
||
@get:Rule | ||
var mTemporaryFolder = TemporaryFolder() | ||
@Test | ||
@Throws(Exception::class) | ||
fun errnoMessageAppendedToOpenFailed() { | ||
mExpectedException.expect(GifIOException::class.java) | ||
mExpectedException.expectMessage("GifError 101: Failed to open given input: No such file or directory") | ||
val nonExistentFile = File(mTemporaryFolder.root, "non-existent") | ||
GifDrawable(nonExistentFile) | ||
} | ||
|
||
@Test | ||
@Throws(Exception::class) | ||
fun errnoMessageAppendedToReadFailed() { | ||
mExpectedException.expect(GifIOException::class.java) | ||
mExpectedException.expectMessage("GifError 102: Failed to read from given input: Is a directory") | ||
GifDrawable(mTemporaryFolder.root) | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package pl.droidsonroids.gif | ||
|
||
import android.graphics.drawable.Drawable | ||
import org.assertj.core.api.AbstractAssert | ||
import org.assertj.core.api.Assertions | ||
import pl.droidsonroids.gif.GifDrawable | ||
|
||
internal class GifDrawableAssert private constructor(actual: GifDrawable) : | ||
AbstractAssert<GifDrawableAssert?, GifDrawable?>(actual, GifDrawableAssert::class.java) { | ||
fun hasLoopCountEqualTo(loopCount: Int): GifDrawableAssert { | ||
Assertions.assertThat(actual!!.loopCount).isEqualTo(loopCount) | ||
return this | ||
} | ||
|
||
companion object { | ||
fun assertThat(actual: Drawable): GifDrawableAssert { | ||
Assertions.assertThat(actual).isInstanceOf(GifDrawable::class.java) | ||
return GifDrawableAssert(actual as GifDrawable) | ||
} | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package pl.droidsonroids.gif | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import org.hamcrest.CoreMatchers | ||
import org.junit.After | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.rules.ExpectedException | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class GifDrawableExceptionTest { | ||
@get:Rule | ||
var expectedException = ExpectedException.none() | ||
private var gifDrawable: GifDrawable? = null | ||
@Before | ||
@Throws(Exception::class) | ||
fun setUp() { | ||
val resources = InstrumentationRegistry.getInstrumentation().context.resources | ||
gifDrawable = GifDrawable(resources, pl.droidsonroids.gif.test.R.raw.test) | ||
} | ||
|
||
@After | ||
fun tearDown() { | ||
gifDrawable!!.recycle() | ||
} | ||
|
||
@Test | ||
@Throws(Exception::class) | ||
fun frameIndexOutOfBoundsMessageContainsRange() { | ||
val numberOfFrames = gifDrawable!!.numberOfFrames | ||
val invalidFrameIndex = numberOfFrames + 10 | ||
expectedException.expectMessage(CoreMatchers.containsString(Integer.toString(numberOfFrames))) | ||
expectedException.expect(IndexOutOfBoundsException::class.java) | ||
gifDrawable!!.getFrameDuration(invalidFrameIndex) | ||
} | ||
|
||
@Test | ||
@Throws(Exception::class) | ||
fun exceptionThrownWhenPixelsArrayTooSmall() { | ||
expectedException.expect(ArrayIndexOutOfBoundsException::class.java) | ||
gifDrawable!!.getPixels(IntArray(0)) | ||
} | ||
|
||
@Test | ||
@Throws(Exception::class) | ||
fun exceptionThrownWhenPixelCoordinateXOutOfRange() { | ||
expectedException.expect(IllegalArgumentException::class.java) | ||
gifDrawable!!.getPixel(gifDrawable!!.intrinsicWidth, 0) | ||
} | ||
|
||
@Test | ||
@Throws(Exception::class) | ||
fun exceptionThrownWhenPixelCoordinateYOutOfRange() { | ||
expectedException.expect(IllegalArgumentException::class.java) | ||
gifDrawable!!.getPixel(0, gifDrawable!!.intrinsicHeight) | ||
} | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be still java 1.8
See https://github.com/koral--/android-gif-drawable/issues/826
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The project does not compile for me when I move it back to 1.8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I'll check this further ASAP.