-
-
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
Open
rahul13agrawal
wants to merge
11
commits into
koral--:dev
Choose a base branch
from
rahul13agrawal:rahul/converted-to-kotlin
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2289519
Rename .java to .kt
rahul-quicksell 5126d52
Converted java to kotlin.
rahul-quicksell 9adb008
Rename .java to .kt
rahul-quicksell 3a5dd0d
Converted test cases to Kotlin
rahul-quicksell 8904edd
fixed test case failing
rahul-quicksell 6a2d3bf
reformatted code
rahul-quicksell d0a775c
Formatted code
rahul-quicksell 1367aa5
updated the code as per review comments
rahul-quicksell c0fa2d3
test fail fix
rahul-quicksell 5299712
fixed documentation
rahul-quicksell 7b7b6c0
Merge branch 'dev' into rahul/converted-to-kotlin
rahul13agrawal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
android-gif-drawable/src/androidTest/java/pl/droidsonroids/gif/AllocationByteCountTest.java
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
android-gif-drawable/src/androidTest/java/pl/droidsonroids/gif/AllocationByteCountTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package pl.droidsonroids.gif | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import pl.droidsonroids.gif.test.R | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class AllocationByteCountTest { | ||
|
||
@Test | ||
fun allocationByteCountIsConsistent() { | ||
val resources = getInstrumentation().context.resources | ||
|
||
val drawable = GifDrawable(resources, R.raw.test) | ||
|
||
val metaData = GifAnimationMetaData(resources, R.raw.test) | ||
|
||
assertThat(drawable.frameByteCount + metaData.allocationByteCount) | ||
.isEqualTo(drawable.allocationByteCount) | ||
assertThat(metaData.getDrawableAllocationByteCount(null, 1)) | ||
.isEqualTo(drawable.allocationByteCount) | ||
assertThat(metaData.getDrawableAllocationByteCount(drawable, 1)) | ||
.isEqualTo(drawable.allocationByteCount) | ||
} | ||
} |
36 changes: 0 additions & 36 deletions
36
android-gif-drawable/src/androidTest/java/pl/droidsonroids/gif/ErrnoMessageTest.java
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
android-gif-drawable/src/androidTest/java/pl/droidsonroids/gif/ErrnoMessageTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
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 | ||
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 | ||
fun errnoMessageAppendedToReadFailed() { | ||
mExpectedException.expect(GifIOException::class.java) | ||
|
||
mExpectedException.expectMessage("GifError 102: Failed to read from given input: Is a directory") | ||
|
||
GifDrawable(mTemporaryFolder.root) | ||
} | ||
} |
23 changes: 0 additions & 23 deletions
23
android-gif-drawable/src/androidTest/java/pl/droidsonroids/gif/GifDrawableAssert.java
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
android-gif-drawable/src/androidTest/java/pl/droidsonroids/gif/GifDrawableAssert.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package pl.droidsonroids.gif | ||
|
||
import android.graphics.drawable.Drawable | ||
import org.assertj.core.api.AbstractAssert | ||
import org.assertj.core.api.Assertions | ||
import org.assertj.core.api.Assertions.assertThat | ||
import pl.droidsonroids.gif.GifDrawable | ||
|
||
internal class GifDrawableAssert private constructor(actual: GifDrawable) : | ||
AbstractAssert<GifDrawableAssert?, GifDrawable?>(actual, GifDrawableAssert::class.java) { | ||
fun hasLoopCountEqualTo(loopCount: Int): GifDrawableAssert { | ||
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) | ||
} | ||
} | ||
} |
61 changes: 0 additions & 61 deletions
61
android-gif-drawable/src/androidTest/java/pl/droidsonroids/gif/GifDrawableExceptionTest.java
This file was deleted.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
android-gif-drawable/src/androidTest/java/pl/droidsonroids/gif/GifDrawableExceptionTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
import pl.droidsonroids.gif.test.R | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class GifDrawableExceptionTest { | ||
|
||
@get:Rule | ||
var expectedException = ExpectedException.none() | ||
|
||
private lateinit var gifDrawable: GifDrawable | ||
|
||
@Before | ||
fun setUp() { | ||
val resources = InstrumentationRegistry.getInstrumentation().context.resources | ||
gifDrawable = GifDrawable(resources, R.raw.test) | ||
} | ||
|
||
@After | ||
fun tearDown() { | ||
gifDrawable.recycle() | ||
} | ||
|
||
@Test | ||
fun frameIndexOutOfBoundsMessageContainsRange() { | ||
val numberOfFrames = gifDrawable.numberOfFrames | ||
val invalidFrameIndex = numberOfFrames + 10 | ||
|
||
expectedException.expectMessage(CoreMatchers.containsString(numberOfFrames.toString())) | ||
expectedException.expect(IndexOutOfBoundsException::class.java) | ||
gifDrawable.getFrameDuration(invalidFrameIndex) | ||
} | ||
|
||
@Test | ||
fun exceptionThrownWhenPixelsArrayTooSmall() { | ||
expectedException.expect(ArrayIndexOutOfBoundsException::class.java) | ||
gifDrawable.getPixels(IntArray(0)) | ||
} | ||
|
||
@Test | ||
fun exceptionThrownWhenPixelCoordinateXOutOfRange() { | ||
expectedException.expect(IllegalArgumentException::class.java) | ||
gifDrawable.getPixel(gifDrawable.intrinsicWidth, 0) | ||
} | ||
|
||
@Test | ||
fun exceptionThrownWhenPixelCoordinateYOutOfRange() { | ||
expectedException.expect(IllegalArgumentException::class.java) | ||
gifDrawable.getPixel(0, gifDrawable.intrinsicHeight) | ||
} | ||
} |
56 changes: 0 additions & 56 deletions
56
android-gif-drawable/src/androidTest/java/pl/droidsonroids/gif/GifViewDescriptorTest.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.